⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 待机画面浮动链接要求.txt

📁 手机待机浮动窗口
💻 TXT
字号:
Eric Wu 说:
http://mikie.iki.fi/lxr/source/ContextNotify/src/Drawer.cpp#010
Eric Wu 说:
这有画浮动窗口的程序可以参考
神话 说:
收到,谢谢!
Eric Wu 说:
注意还有截取键盘的部分
Eric Wu 说:
处理 长按键


LXR index for ContextPhone 
ContextPhone/ ContextNotify/ src/ Drawer.cpp 
 [ source navigation ]
 
ContextPhone: General information, Building instructions and source code packages 
  Platform:  [ Series60 ] 
 
Version:  [ v3 ] [ v4 ] [ v5 ] 
 
 

--------------------------------------------------------------------------------

001 #include "drawer.h"
002 #include "symbian_auto_ptr.h"
003 #include <e32std.h>
004 #include <w32std.h>
005 #include <coedef.h>
006 #include <apgwgnam.h>
007 
008 /*
009  * Concepts:
010  * !Drawing on top of Phone screen!
011  */
012 
013 const TUid KUidPhone = { 0x100058b3 };
014 const TUid KUidMenu = { 0x101f4cd2 };
015 
016 const TInt KIconSep = 1;
017 
018 class CDrawerImpl : public CDrawer {
019 public:
020         virtual TInt    AddIconL(CFbsBitmap* data, CFbsBitmap* mask);
021         virtual void    RemoveIcon(TInt Id);
022         virtual void    ChangeIconL(CFbsBitmap* data, CFbsBitmap* mask, TInt Id);
023         CDrawerImpl(RWsSession& aWsSession);
024         virtual ~CDrawerImpl();
025 
026         virtual void ForegroundChanged(TUid AppUid);
027         
028         void ConstructL();
029         void StartL();
030         void Listen();
031         void Release();
032         void Draw(const TRect& aRect);
033 
034         void RunL();
035         TInt RunError(TInt aError);
036         void DoCancel();
037 
038         TBool reception_bar_on_screen();
039 
040         RWsSession& iWsSession; 
041         CWindowGc* gc;
042         CWsScreenDevice* screen;
043         RWindowGroup wg; bool wg_is_open;
044         RWindow w; bool w_is_open;
045 
046         RPointerArray<CFbsBitmap> iIcons;
047         RPointerArray<CFbsBitmap> iMasks;
048         bool    full_redraw;
049 };
050 
051 CDrawer::CDrawer(CActive::TPriority aPriority) : CActive(aPriority)
052 {
053 }
054 
055 CDrawer::~CDrawer()
056 {
057 }
058 
059 CDrawer* CDrawer::NewL(RWsSession& aWsSession)
060 {
061         auto_ptr<CDrawerImpl> ret(new (ELeave) CDrawerImpl(aWsSession));
062         ret->ConstructL();
063         return ret.release();
064 }
065 
066 TInt    CDrawerImpl::AddIconL(CFbsBitmap* aIcon, CFbsBitmap* aMask)
067 {
068         User::LeaveIfError(iIcons.Append(aIcon));
069         TInt err=iMasks.Append(aMask);
070         if (err!=KErrNone) {
071                 iIcons.Remove(iIcons.Count()-1);
072                 User::Leave(err);
073         }
074         TSize ws=w.Size(), is=aIcon->SizeInPixels();
075         ws.iWidth+=is.iWidth+KIconSep;
076         if (is.iHeight > ws.iHeight) ws.iHeight=is.iHeight;
077         w.SetSize(ws);
078 
079         full_redraw=true; Draw(TRect());
080         return iIcons.Count()-1;
081 }
082 
083 void    CDrawerImpl::RemoveIcon(TInt Id)
084 {
085         if (Id<0 || Id >= iIcons.Count()) return;
086 
087         TSize ws=w.Size(), is=iIcons[Id]->SizeInPixels();
088 
089         delete iIcons[Id];
090         iIcons[Id]=0;
091         delete iMasks[Id];
092         iMasks[Id]=0;
093 
094         ws.iWidth-=(is.iWidth+KIconSep);
095         w.SetSize(ws);
096         full_redraw=true; Draw(TRect());
097 }
098 
099 void    CDrawerImpl::ChangeIconL(CFbsBitmap* data, CFbsBitmap* aMask, TInt Id)
100 {
101         if (Id<0 || Id >= iIcons.Count()) User::Leave(KErrNotFound);
102 
103         delete iIcons[Id];
104         iIcons[Id]=data;
105         delete iMasks[Id];
106         iMasks[Id]=aMask;
107 
108         full_redraw=true; Draw(TRect());
109 }
110 
111 CDrawerImpl::CDrawerImpl(RWsSession& aWsSession) : CDrawer(EPriorityHigh), iWsSession(aWsSession)
112 {
113 }
114 
115 void CDrawerImpl::ConstructL()
116 {
117         screen=new (ELeave) CWsScreenDevice(iWsSession);
118         User::LeaveIfError(screen->Construct());
119 
120         User::LeaveIfError(screen->CreateContext(gc));
121 
122         wg=RWindowGroup(iWsSession);
123         User::LeaveIfError(wg.Construct((TUint32)&wg, EFalse));
124         wg_is_open=true;
125         wg.SetOrdinalPosition(1, ECoeWinPriorityAlwaysAtFront+1);
126         wg.EnableReceiptOfFocus(EFalse);
127 
128         CApaWindowGroupName* wn=CApaWindowGroupName::NewLC(iWsSession);
129         wn->SetHidden(ETrue);
130         wn->SetWindowGroupName(wg);
131         CleanupStack::PopAndDestroy();
132 
133         w=RWindow(iWsSession);
134         User::LeaveIfError(w.Construct(wg, (TUint32)&w));
135         w_is_open=true;
136 
137         w.Activate();
138 //<<<<<<< Drawer.cpp
139         //w.SetExtent( TPoint(1, 45), TSize(0, 0) );
140 //      w.SetExtent( TPoint(156, 1), TSize(0,0));
141 //=======
142         w.SetExtent( TPoint(1, 46), TSize(0, 0) );
143 //>>>>>>> 1.5
144         w.SetBackgroundColor( KRgbWhite );
145         w.SetOrdinalPosition(1, ECoeWinPriorityAlwaysAtFront+1);
146         w.SetNonFading(ETrue);
147 
148         TInt wgid=iWsSession.GetFocusWindowGroup();
149         CApaWindowGroupName* gn;
150         gn=CApaWindowGroupName::NewLC(iWsSession, wgid);
151 
152         ForegroundChanged(gn->AppUid());
153         CleanupStack::PopAndDestroy();
154 
155         CActiveScheduler::Add(this);
156 
157         Listen();
158 }
159 
160 CDrawerImpl::~CDrawerImpl()
161 {
162         Cancel();
163 
164         int i;
165         for (i=0; i<iIcons.Count(); i++) {
166                 delete iIcons[i];
167                 delete iMasks[i];
168         }
169         iIcons.Close(); iMasks.Close();
170 
171         delete gc;
172         delete screen;
173         if (w_is_open) w.Close();
174         if (wg_is_open) wg.Close();
175 }
176 
177 void CDrawerImpl::StartL()
178 {
179 }
180 
181 void CDrawerImpl::Listen()
182 {
183         iStatus=KRequestPending;
184         iWsSession.RedrawReady(&iStatus);
185         SetActive();
186 }
187 
188 void CDrawerImpl::Release()
189 {
190 }
191 
192 void CDrawerImpl::RunL()
193 {
194         TWsRedrawEvent e;
195         iWsSession.GetRedraw(e);
196 
197         Draw(e.Rect());
198 
199         Listen();
200 }
201 
202 void CDrawerImpl::Draw(const TRect& serverRect)
203 {
204         TRect aRect=serverRect;
205 
206         gc->Activate(w);
207 
208         if (full_redraw) {
209                 aRect=TRect(TPoint(0,0), w.Size());
210         }
211         full_redraw=false;
212         w.Invalidate(aRect);
213         w.BeginRedraw();
214 
215         gc->SetPenStyle(CGraphicsContext::ENullPen);
216         gc->SetBrushColor(KRgbWhite);
217         gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
218         gc->DrawRect(aRect);
219 
220         int xpos=0, i;
221         for (i=0; i<iIcons.Count(); i++) {
222                 if (iIcons[i]!=0 && iMasks[i]!=0) {
223                         xpos+=KIconSep;
224                         TRect r( TPoint(0, 0), iIcons[i]->SizeInPixels());
225                         gc->BitBltMasked(TPoint(xpos, 0), iIcons[i], r, iMasks[i], ETrue);
226                         xpos+=r.Width();
227                 }
228         }
229 
230         w.EndRedraw();
231         gc->Deactivate();
232         iWsSession.Flush();
233 }
234 
235 TInt CDrawerImpl::RunError(TInt aError)
236 {
237         return aError;
238 }
239 
240 void CDrawerImpl::DoCancel()
241 {
242         iWsSession.RedrawReadyCancel();
243 }
244 
245 void CDrawerImpl::ForegroundChanged(TUid AppUid)
246 {
247 
248 #ifdef __WINS__
249         if (AppUid==KUidMenu) {
250 #else
251         if (AppUid==KUidPhone) {
252 #endif
253                 w.SetVisible(ETrue);
254         } else {
255                 w.SetVisible(EFalse);
256         }
257 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -