📄 popupwindow.cpp
字号:
/*
* ============================================================================
* Name : CPopupWindow from PicaInfoPopupWindow.cpp
* Part of : PicaClient
* Created : 2004-11-12 by zhao guo qing
* Implementation notes:
* Initial content was generated by Series 60 AppWizard.
* Version :
* Copyright: mmim
* ============================================================================
*/
// INCLUDE FILES
#include <eiklabel.h>
#include <aknconsts.h>
#include <akncontext.h>
#include <eikenv.h>
#include <avkon.mbg>
#include <akniconutils.h>
#include "PopupWindow.h"
const TInt KInfoInterval = 500000; //时间间隔500毫秒
const TInt KStayInterval = 30000000; //提示框停留时间30秒
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CPopupWindow::CPopupWindow() : iColor(KRgbDarkBlue)
{
iInernalLeft = 0;
}
// EPOC default constructor can leave.
void CPopupWindow::ConstructL(const TRect& aRect)
{
iMyWindowGroup=RWindowGroup(iCoeEnv->WsSession());
TUint32 ppp = (TUint32)&iMyWindowGroup;
User::LeaveIfError(iMyWindowGroup.Construct((TUint32)&iMyWindowGroup));
TUint32 child = iMyWindowGroup.Child();
iMyWindowGroup.SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
iMyWindowGroup.EnableReceiptOfFocus(EFalse);
iMyWindowGroup.EnableFocusChangeEvents();
iMyWindowGroup.EnableGroupChangeEvents();
CreateWindowL(&iMyWindowGroup);
iTimer = CTimeOutTimer::NewL(CActive::EPriorityStandard, *this);
AknIconUtils::CreateIconL(iIcon, iIconMask, _L("\\Resource\\Apps\\Avkon2.mbm"), EMbmAvkonQgn_stat_chi_pinyin, EMbmAvkonQgn_stat_chi_pinyin_mask);
AknIconUtils::SetSize(iIcon, aRect.Size());
AknIconUtils::SetSize(iIconMask, aRect.Size());
TUint32 pid = Window().Parent();
RWindowTreeNode* ssGroup = (RWindowTreeNode*)pid;
child = ssGroup->Child();
child = iMyWindowGroup.Child();
child = (TUint32)&Window();
TRgb backgroundColour = KRgbRed; // for example
backgroundColour.SetAlpha(0);
TInt err = Window().SetTransparencyFactor(backgroundColour);
if(KErrNone == err)
{
// Window().SetBackgroundColor(backgroundColour);
}
SetRect(aRect);
// EnableDragEvents();
ActivateL();
iInernalLeft = 0;
}
// Destructor
CPopupWindow::~CPopupWindow()
{
iMyWindowGroup.Close();
if(iTimer)
{
iTimer->Cancel();
delete iTimer;
iTimer = NULL;
}
delete iIcon;
delete iIconMask;
}
// ---------------------------------------------------------
// CAknExSpanePopUpWindow
// ---------------------------------------------------------
//
void CPopupWindow::SetColor(TRgb aColor)
{
iColor = aColor;
}
void CPopupWindow::SetShowMsg(const TDesC & msg)
{
iTimer->Cancel();
iDrawMsg.Copy(msg);
iInernalLeft = 0;
TRect rect = Rect();
const CFont * iFont = iCoeEnv->NormalFont();
iMsgLen = iFont->TextWidthInPixels(iDrawMsg);
if(iMsgLen > rect.Width())
{
iTimer->After(KInfoInterval);
}
DrawNow();
}
void CPopupWindow::TimerExpired()
{
TRect rect = Rect();
iInernalLeft -= 10;
if((rect.Width() - 4 - iInernalLeft) >= iMsgLen)
{
iInernalLeft = 0;
}
iTimer->After(KInfoInterval);
DrawNow();
}
// ---------------------------------------------------------
// CAknExSpanePopUpWindow::Draw(const TRect& aRect) const
// Draw function.
// ---------------------------------------------------------
//
void CPopupWindow::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
TRect rect = Rect();
gc.Clear(rect);
TRect sRect = TRect(TPoint(0,0), rect.Size());
gc.BitBltMasked(TPoint(0,0), iIcon, sRect, iIconMask, ETrue);
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -