| 1 | #include "DST_WinManager.h" |
|---|
| 2 | #include "DST_OSDImage.h" |
|---|
| 3 | #include "DST_UserInterface.h" |
|---|
| 4 | #include "DST_DataStrings.h" |
|---|
| 5 | |
|---|
| 6 | #if 0 |
|---|
| 7 | ____CPowerDownCautionWin___() |
|---|
| 8 | #endif |
|---|
| 9 | |
|---|
| 10 | #define MAX_SECONDS 60 |
|---|
| 11 | //class CPowerDownCautionWin : public CWindow |
|---|
| 12 | //{ |
|---|
| 13 | //private: |
|---|
| 14 | static bool CPowerDownCautionWin_needShutDown; |
|---|
| 15 | static int CPowerDownCautionWin_nMaxWidth; |
|---|
| 16 | static int CPowerDownCautionWin_nCoundDown; |
|---|
| 17 | //public: |
|---|
| 18 | DS_U16* CPowerDownCautionWin_GetTextNWidth(int *textWidth, int countDown, int fontSize); |
|---|
| 19 | // CPowerDownCautionWin(SWinEventMsg event):CWindow(event) |
|---|
| 20 | void CPowerDownCautionWin_Constructor(CWindow *this, SWinEventMsg event) |
|---|
| 21 | { |
|---|
| 22 | this->SetWinName(this, "PowerDownCaution"); |
|---|
| 23 | this->setFontStyle(this, 20, 0xFFC8C8C8, ALIGN_MIDDLE,ALIGN_LEFT); |
|---|
| 24 | CPowerDownCautionWin_needShutDown = false; |
|---|
| 25 | CPowerDownCautionWin_nMaxWidth = 0; |
|---|
| 26 | CPowerDownCautionWin_nCoundDown = MAX_SECONDS; |
|---|
| 27 | CPowerDownCautionWin_GetTextNWidth(&CPowerDownCautionWin_nMaxWidth,CPowerDownCautionWin_nCoundDown,this->FontGetSize(this)); |
|---|
| 28 | |
|---|
| 29 | this->rect.w = 9+DST_GetImageWidth(bracon_gui_caution)+10+CPowerDownCautionWin_nMaxWidth+10; |
|---|
| 30 | this->rect.h = 92; |
|---|
| 31 | this->rect.x = (DST_GetScreenWidth() - this->rect.w) / 2; |
|---|
| 32 | this->rect.y = DST_GetScreenHeight()*9/10 - this->rect.h; |
|---|
| 33 | |
|---|
| 34 | this->SetTimeOut(this, 0); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | void CPowerDownCautionWin_Destructor(CWindow *this) |
|---|
| 38 | { |
|---|
| 39 | if(CPowerDownCautionWin_needShutDown) DST_SendWindowEventWithOnlyCmd(WM_POWER_OFF); |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | DS_U16* CPowerDownCautionWin_GetTextNWidth(int *textWidth, int countDown, int fontSize) |
|---|
| 43 | { |
|---|
| 44 | static DS_U16 final[100]; |
|---|
| 45 | char tmpStr[10]; |
|---|
| 46 | int nStrLen = 0; |
|---|
| 47 | int i = 0; |
|---|
| 48 | DS_U16* fianlStr; |
|---|
| 49 | |
|---|
| 50 | memset(final,0,sizeof(final)); |
|---|
| 51 | memset(tmpStr,0,sizeof(tmpStr)); |
|---|
| 52 | sprintf(tmpStr," %d", countDown); |
|---|
| 53 | str2uni(&final[strlen16(final)], (char *)tmpStr); |
|---|
| 54 | strcpy16(&final[strlen16(final)], pz_PowerDownCountDown_P2[OSD_Lang]); |
|---|
| 55 | memset(tmpStr,0,sizeof(tmpStr)); |
|---|
| 56 | sprintf(tmpStr," "); |
|---|
| 57 | str2uni(&final[strlen16(final)], (char *)tmpStr); |
|---|
| 58 | strcpy16(&final[strlen16(final)], pz_PowerDownCountDown_P1[OSD_Lang]); |
|---|
| 59 | |
|---|
| 60 | *textWidth = DST_GetTextWidthUni(final,fontSize); |
|---|
| 61 | |
|---|
| 62 | for( i=0;i<100;i++) |
|---|
| 63 | { |
|---|
| 64 | if(final[i]==0) break; |
|---|
| 65 | nStrLen++; |
|---|
| 66 | } |
|---|
| 67 | fianlStr = (DS_U16*)DST_OS_Malloc((nStrLen+1) * sizeof(DS_U16)); |
|---|
| 68 | memset(fianlStr, 0, (nStrLen+1) * sizeof(DS_U16)); |
|---|
| 69 | memcpy(fianlStr,final,(nStrLen+1) * sizeof(DS_U16)); |
|---|
| 70 | return fianlStr; |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | // virtual void Show(WinID id) |
|---|
| 74 | void CPowerDownCautionWin_ShowWindow(CWindow *this, WinID id) |
|---|
| 75 | { |
|---|
| 76 | DST_Printf("id=%d\n",id); |
|---|
| 77 | switch(id) |
|---|
| 78 | { |
|---|
| 79 | case WIN_ERROR: |
|---|
| 80 | case WIN_POWER_DOWN_CAUTION: |
|---|
| 81 | break; |
|---|
| 82 | default: |
|---|
| 83 | this->KillTimer(this, 1); |
|---|
| 84 | this->Close(this); |
|---|
| 85 | break; |
|---|
| 86 | } |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | // virtual void Show() |
|---|
| 90 | void CPowerDownCautionWin_Show(CWindow *this) |
|---|
| 91 | { |
|---|
| 92 | int nWidth = 0; |
|---|
| 93 | DS_U16* str; |
|---|
| 94 | |
|---|
| 95 | this->DrawBox32(this, 0, 0, this->rect.w, this->rect.h, CONV32_16(0xFF262626)); |
|---|
| 96 | this->DrawImage(this, 9, 9, bracon_gui_caution,true); |
|---|
| 97 | |
|---|
| 98 | str = CPowerDownCautionWin_GetTextNWidth(&nWidth, CPowerDownCautionWin_nCoundDown, this->FontGetSize(this)); |
|---|
| 99 | this->DrawTextUni(this, 9+DST_GetImageWidth(bracon_gui_caution)+10, 0, CPowerDownCautionWin_nMaxWidth, this->rect.h, str, &(this->font)); |
|---|
| 100 | DST_OS_Free(&str); |
|---|
| 101 | this->SetTimer(this, 1, 1000); |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | // virtual void OnMessage(SWinEventMsg event) |
|---|
| 105 | void CPowerDownCautionWin_OnMessage(CWindow *this, SWinEventMsg event) |
|---|
| 106 | { |
|---|
| 107 | switch (event.cmd) |
|---|
| 108 | { |
|---|
| 109 | case WM_POWER_OFF: |
|---|
| 110 | this->Close(this); |
|---|
| 111 | break; |
|---|
| 112 | default: break; |
|---|
| 113 | } |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | // virtual void OnTimer(char nID) |
|---|
| 117 | void CPowerDownCautionWin_OnTimer(CWindow *this, char nID) |
|---|
| 118 | { |
|---|
| 119 | switch(nID) |
|---|
| 120 | { |
|---|
| 121 | case 1: |
|---|
| 122 | this->KillTimer(this, 1); |
|---|
| 123 | this->UpdateScreen(this); |
|---|
| 124 | CPowerDownCautionWin_nCoundDown--; |
|---|
| 125 | if(CPowerDownCautionWin_nCoundDown == 0) |
|---|
| 126 | { |
|---|
| 127 | DST_g_bSleepTimerOut = true; |
|---|
| 128 | CPowerDownCautionWin_needShutDown = true; |
|---|
| 129 | this->Close(this); |
|---|
| 130 | return; |
|---|
| 131 | } |
|---|
| 132 | this->Show(this); |
|---|
| 133 | this->UpdateScreen(this); |
|---|
| 134 | break; |
|---|
| 135 | } |
|---|
| 136 | } |
|---|
| 137 | |
|---|
| 138 | //}; |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | void DST_CreatePowerDownCautionWin(SWinEventMsg event) |
|---|
| 142 | { |
|---|
| 143 | CWindow*pWin = NewCWindow(event); |
|---|
| 144 | pWin->Destructor = CPowerDownCautionWin_Destructor; |
|---|
| 145 | pWin->OnMessage = CPowerDownCautionWin_OnMessage; |
|---|
| 146 | pWin->OnTimer = CPowerDownCautionWin_OnTimer; |
|---|
| 147 | pWin->ShowWindow = CPowerDownCautionWin_ShowWindow; |
|---|
| 148 | pWin->Show = CPowerDownCautionWin_Show; |
|---|
| 149 | // »ý¼ºÀÚ È£Ãâ |
|---|
| 150 | CPowerDownCautionWin_Constructor(pWin, event); |
|---|
| 151 | // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï |
|---|
| 152 | DST_AddWin((WinID)(event.data[0]), pWin); |
|---|
| 153 | } |
|---|
| 154 | |
|---|