static int set_ime_stat (int cli, int clifd, void* buff, size_t len) { int ret, data; memcpy(&data, buff, sizeof(int)); ret = SendMessage (HWND_DESKTOP, MSG_IME_SETSTATUS, HISWORD(data), LOSWORD(data)); return ServerSendReply (clifd, &ret, sizeof (int)); }
static inline void CheckCapturedMouseMessage (PMSG pMsg) { if (__mg_capture_wnd == pMsg->hwnd && pMsg->message >= MSG_FIRSTMOUSEMSG && pMsg->message <= MSG_LASTMOUSEMSG && !(pMsg->wParam & KS_CAPTURED)) { int x, y; x = LOSWORD (pMsg->lParam); y = HISWORD (pMsg->lParam); ClientToScreen (pMsg->hwnd, &x, &y); pMsg->lParam = MAKELONG (x, y); pMsg->wParam |= KS_CAPTURED; } }
static void lv_notify_process (HWND hwnd, int id, int code, DWORD addData) { if (code == LVN_KEYDOWN) { PLVNM_KEYDOWN down; int key; down = (PLVNM_KEYDOWN)addData; key = LOWORD(down->wParam); if (key == SCANCODE_REMOVE) { int nItem; nItem = SendMessage (hwnd, LVM_GETSELECTEDITEM, 0, 0); if (nItem > 0) { if( MessageBox (hMainWnd, "are you really want to delete this file?", "warning", MB_YESNO) == IDYES) { // not really delete yet. SendMessage (hwnd, LVM_DELITEM, nItem, 0); } } } if (key == SCANCODE_ENTER) { } } if (code == LVN_ITEMRUP) { PLVNM_ITEMRUP up; int x, y; up = (PLVNM_ITEMRUP)addData; x = LOSWORD(up->lParam); y = HISWORD(up->lParam); ClientToScreen (hChildWnd1, &x, &y); TrackPopupMenu (GetPopupSubMenu (hRightMenu), TPM_LEFTALIGN | TPM_LEFTBUTTON , x, y, hMainWnd); } if (code == LVN_ITEMDBCLK) { int nItem = SendMessage (hwnd, LVM_GETSELECTEDITEM, 0, 0); if (nItem > 0) { if( MessageBox (hMainWnd, "Are you really want to open this file?", "Question", MB_YESNO) == IDYES) { MessageBox (hMainWnd, "Me too.", "Sorry", MB_OK); } } } }
static int CoolBarCtrlProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam) { HDC hdc; PCOOLBARCTRL TbarData; PCOOLBARITEMDATA pTbid; switch (message) { case MSG_CREATE: { DWORD data; DWORD dwStyle; const char* caption; if ((TbarData = (COOLBARCTRL*) calloc (1, sizeof (COOLBARCTRL))) == NULL) return 1; TbarData->nCount = 0; TbarData->head = TbarData->tail = NULL; TbarData->BackBmp = NULL; TbarData->iSel = -1; TbarData->iMvOver = -1; TbarData->ShowHint = TRUE; TbarData->hToolTip = 0; ExcludeWindowStyle (hWnd, WS_BORDER); dwStyle = GetWindowStyle (hWnd); if (dwStyle & CBS_BMP_32X32) { TbarData->ItemWidth = 32; TbarData->ItemHeight = 32; } else if (dwStyle & CBS_BMP_CUSTOM) { data = GetWindowAdditionalData (hWnd); TbarData->ItemWidth = LOWORD (data); TbarData->ItemHeight = HIWORD (data); } else { TbarData->ItemWidth = 16; TbarData->ItemHeight = 16; } caption = GetWindowCaption (hWnd); if ((dwStyle & CBS_USEBKBMP) && caption [0]) { TbarData->BackBmp = (BITMAP*)calloc (1, sizeof (BITMAP)); if (LoadBitmap (HDC_SCREEN, TbarData->BackBmp, caption) < 0) { free (TbarData->BackBmp); TbarData->BackBmp = NULL; break; } } SetWindowAdditionalData2 (hWnd, (DWORD)TbarData); } break; case MSG_DESTROY: { COOLBARITEMDATA* unloaddata, *tmp; TbarData = (PCOOLBARCTRL) GetWindowAdditionalData2(hWnd); if (TbarData->hToolTip != 0) { DestroyToolTipWin (TbarData->hToolTip); TbarData->hToolTip = 0; } if (TbarData->BackBmp) { UnloadBitmap (TbarData->BackBmp); free (TbarData->BackBmp); } unloaddata = TbarData->head; while (unloaddata) { tmp = unloaddata->next; free (unloaddata); unloaddata = tmp; } free (TbarData); } break; case MSG_SIZECHANGING: { const RECT* rcExpect = (const RECT*)wParam; RECT* rcResult = (RECT*)lParam; TbarData = (PCOOLBARCTRL) GetWindowAdditionalData2(hWnd); rcResult->left = rcExpect->left; rcResult->top = rcExpect->top; rcResult->right = rcExpect->right; rcResult->bottom = rcExpect->top + TbarData->ItemHeight + 8; return 0; } case MSG_SIZECHANGED: { RECT* rcWin = (RECT*)wParam; RECT* rcClient = (RECT*)lParam; *rcClient = *rcWin; return 1; } case MSG_NCPAINT: return 0; case MSG_PAINT: { TbarData = (PCOOLBARCTRL) GetWindowAdditionalData2(hWnd); hdc = BeginPaint (hWnd); DrawCoolBox (hWnd, hdc, TbarData); EndPaint (hWnd, hdc); return 0; } case CBM_ADDITEM: { COOLBARITEMINFO* TbarInfo = NULL; COOLBARITEMDATA* ptemp; RECT rc; TbarData = (PCOOLBARCTRL) GetWindowAdditionalData2 (hWnd); TbarInfo = (COOLBARITEMINFO*) lParam; if (!(ptemp = (COOLBARITEMDATA*)calloc (1, sizeof (COOLBARITEMDATA)))) { return -1; } GetClientRect (hWnd, &rc); ptemp->id = TbarInfo->id; ptemp->Disable = 0; ptemp->ItemType = TbarInfo->ItemType; if (TbarInfo->ItemHint) { strncpy (ptemp->Hint, TbarInfo->ItemHint, LEN_HINT); ptemp->Hint [LEN_HINT] = '\0'; } else ptemp->Hint [0] = '\0'; if (TbarInfo->Caption) { strncpy (ptemp->Caption, TbarInfo->Caption, LEN_TITLE); ptemp->Caption [LEN_TITLE] = '\0'; } else ptemp->Caption [0] = '\0'; ptemp->Bmp = TbarInfo->Bmp; set_item_rect (hWnd, TbarData, ptemp); ptemp->next = NULL; if (TbarData->nCount == 0) { TbarData->head = TbarData->tail = ptemp; } else if (TbarData->nCount > 0) { TbarData->tail->next = ptemp; TbarData->tail = ptemp; } ptemp->insPos = TbarData->nCount; TbarData->nCount++; InvalidateRect (hWnd, NULL, TRUE); return 0; } case CBM_ENABLE: TbarData = (PCOOLBARCTRL)GetWindowAdditionalData2 (hWnd); if (enable_item (TbarData, wParam, lParam)) return -1; InvalidateRect (hWnd, NULL, TRUE); return 0; case MSG_LBUTTONDOWN: { int posx, posy; TbarData=(PCOOLBARCTRL) GetWindowAdditionalData2(hWnd); posx = LOSWORD (lParam); posy = HISWORD (lParam); if (GetCapture () == hWnd) break; SetCapture (hWnd); if ((pTbid = GetCurTag (posx, posy, TbarData)) == NULL) break; TbarData->iSel = pTbid->insPos; break; } case MSG_LBUTTONUP: { int x, y; TbarData = (PCOOLBARCTRL)GetWindowAdditionalData2(hWnd); x = LOSWORD(lParam); y = HISWORD(lParam); if (GetCapture() != hWnd) break; ReleaseCapture (); ScreenToClient (hWnd, &x, &y); if ((pTbid = GetCurTag(x, y, TbarData)) == NULL) { break; } if (TbarData->iSel == pTbid->insPos && !pTbid->Disable) NotifyParent (hWnd, GetDlgCtrlID(hWnd), pTbid->id); TbarData->iSel = -1; break; } case MSG_MOUSEMOVE: { int x, y; TbarData = (PCOOLBARCTRL) GetWindowAdditionalData2(hWnd); x = LOSWORD(lParam); y = HISWORD(lParam); if (GetCapture() == hWnd) ScreenToClient (hWnd, &x, &y); if ((pTbid = GetCurTag (x, y, TbarData)) == NULL) { unhilight (hWnd); break; } if (TbarData->iMvOver == pTbid->insPos) break; unhilight (hWnd); TbarData->iMvOver = pTbid->insPos; hilight (hWnd, TbarData, pTbid); break; } case MSG_MOUSEMOVEIN: if (!wParam) unhilight (hWnd); break; case MSG_NCLBUTTONDOWN: case MSG_KILLFOCUS: unhilight (hWnd); break; } return DefaultControlProc (hWnd, message, wParam, lParam); }
static int ColorDlgProc (HWND hDlg, int message, WPARAM wParam, LPARAM lParam) { PSCOLORDIA scld; switch (message) { case MSG_INITDIALOG: { int i, j; Uint8 r, g, b; HDC hdc, mdc; scld = (PSCOLORDIA)lParam; SetWindowAdditionalData (hDlg, (LPARAM)scld); hdc = GetClientDC (hDlg); scld->SpaceDC = CreateCompatibleDCEx(hdc, scld->sp_w, scld->sp_h); mdc = CreateCompatibleDCEx (hdc, 360, 256); for (i = 0; i < 360; i ++) { for (j = 0; j < 256; j ++) { HSV2RGB (i, j, 200, &r, &g, &b); SetPixelRGB(mdc, i, 256-j, r, g, b); } } StretchBlt(mdc, 0, 0, 360, 256, scld->SpaceDC, 0, 0, scld->sp_w, scld->sp_h, 0); DeleteMemDC(mdc); ReleaseDC(hdc); } break; case MSG_CLOSE: EndDialog (hDlg, SELCOLOR_CANCEL); break; case MSG_DESTROY: scld = (PSCOLORDIA)GetWindowAdditionalData (hDlg); DeleteMemDC (scld->SpaceDC); break; case MSG_PAINT: { HDC hdc; scld = (PSCOLORDIA)GetWindowAdditionalData (hDlg); hdc = BeginPaint (hDlg); DrawAllSpace (hdc, scld); EndPaint (hDlg, hdc); return 0; } case MSG_COMMAND: { int msg = HIWORD(wParam); int id = LOWORD(wParam); scld = (PSCOLORDIA)GetWindowAdditionalData (hDlg); if (msg == EN_CONTCHANGED) { UpdateValue (hDlg, id, scld); } switch(id) { case IDC_CANCEL: EndDialog (hDlg, SELCOLOR_CANCEL); break; case IDC_OK: scld->H = scld->clrh; scld->S = scld->clrs; scld->V = scld->clrv; HSV2RGB (scld->clrh, scld->clrs, scld->clrv, &scld->R, &scld->G, &scld->B); scld->PIXEL = RGB2Pixel (HDC_SCREEN, scld->R, scld->G, scld->B); EndDialog (hDlg, SELCOLOR_OK); break; } break; } case MSG_LBUTTONDOWN: { int x = LOSWORD (lParam); int y = HISWORD (lParam); scld = (PSCOLORDIA)GetWindowAdditionalData (hDlg); if (PtInRect (&scld->rcSpace, x, y)) { HDC dc = GetClientDC (hDlg); scld->clrh = (x-scld->rcSpace.left)*360/RECTW(scld->rcSpace); scld->clrs = 256-(y-scld->rcSpace.top)*256/RECTH(scld->rcSpace); DrawAllSpace (dc, scld); SetValue (hDlg, scld); ReleaseDC (dc); } if (PtInRect(&scld->rcYSpace, x,y)) { HDC dc = GetClientDC (hDlg); scld->clrv = (y-scld->rcYSpace.top)*256 / RECTH(scld->rcYSpace); DrawAllSpace (dc, scld); SetValue (hDlg, scld); ReleaseDC (dc); } } } return DefaultDialogProc (hDlg, message, wParam, lParam); }
static void click_tab_bar (HWND hwnd, PCONTROL ctrl, PPROPSHEETDATA propsheet, LPARAM lParam) { int x = LOSWORD(lParam), y = HISWORD(lParam); PPROPPAGE page; RECT title_rc = {0, 0, 0, 0}; int scrollbtn_left = 0; int scroll_clicked; title_rc.bottom = propsheet->head_rc.bottom; title_rc.top = propsheet->head_rc.top; if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) { page = propsheet->head; while (page) { title_rc.left = title_rc.right; title_rc.right = title_rc.left + page->width; if (PtInRect (&title_rc, x, y) && page != propsheet->active) { show_hide_page (propsheet->active, SW_HIDE); propsheet->active = page; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (page, SW_SHOW); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return; } page = page->next; } } else { /* Normal style !!! */ page = propsheet->first_display_page; title_rc.right = (propsheet->overload == TRUE) ? title_rc.right + get_metrics(MWM_SB_WIDTH) : title_rc.right; /* check if left-right-scroll-bar clicked if they are clicked, just change the active title */ if (propsheet->overload == TRUE) { scrollbtn_left = propsheet->head_rc.right - get_metrics (MWM_SB_WIDTH); scroll_clicked = test_clicked_scroll_button (x, y, title_rc.top, title_rc.bottom, propsheet); if (scroll_clicked == LEFT_SCROLL_BTN_CLICKED) { scroll_tab_left (hwnd, ctrl, propsheet); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return; } if (scroll_clicked == RIGHT_SCROLL_BTN_CLICKED) { scroll_tab_right (hwnd, ctrl, propsheet); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return; } } while (page) { title_rc.left = title_rc.right; title_rc.right = title_rc.left + page->width; if (propsheet->overload == TRUE) if (title_rc.right > scrollbtn_left) return; if (PtInRect (&title_rc, x, y) && page != propsheet->active) { show_hide_page (propsheet->active, SW_HIDE); propsheet->active = page; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (page, SW_SHOW); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return; } page = page->next; } } }
int CIMEWnd::MsgProc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam) { HDC hdc; switch (message) { case MSG_PAINT: hdc = BeginPaint (hwnd); draw_border (hwnd, hdc); logo.Show(hdc, IMELOGO_LEFT,IMELOGO_TOP,1); icon.Show (hdc,imeRect.left, imeRect.top, imemgr.cur_ime_bmp_idx); icon.Show (hdc,subimeRect.left,subimeRect.top,imemgr.cur_subime_bmp_idx); EndPaint (hwnd, hdc); break; case MSG_LBUTTONDOWN: { old_x = LOWORD(lParam); old_y = HIWORD(lParam); int ret = Key_Check(old_x,old_y); if(ret == 1) { changeInputMothed(hwnd); }else if(ret == 2) { if(imemgr.cur_ime_type == IME_QUANPIN) { SendMessage(HWND_DESKTOP,MSG_KEYDOWN,SCANCODE_LEFTCONTROL,0); SendMessage(HWND_DESKTOP,MSG_KEYUP,SCANCODE_LEFTCONTROL,0); }else if(imemgr.cur_ime_type == IME_T9){ SendMessage(HWND_DESKTOP,MSG_KEYDOWN,SCANCODE_LEFTCONTROL,0); SendMessage(HWND_DESKTOP,MSG_KEYUP,SCANCODE_LEFTCONTROL,0); }else{ //关闭状态不用发消息 } }else{ SetCapture (hwnd); ClientToScreen (hwnd,&old_x,&old_y); fCaptured=true; } break; } case MSG_LBUTTONUP: { if(fCaptured){ ReleaseCapture (); fCaptured=false; } } break; case MSG_MOUSEMOVE: { if (fCaptured) { RECT rcWindow; GetWindowRect(hwnd, &rcWindow); int x = LOSWORD(lParam); int y = HISWORD(lParam); /* if( rcWindow.left < 0) rcWindow.left = 0; if(rcWindow.right > 800) rcWindow.right = 800; if( rcWindow.top < 0) rcWindow.top = 0; if(rcWindow.bottom > 480) rcWindow.bottom = 480; */ OffsetRect(&rcWindow, x - old_x, y - old_y); //if( (rcWindow.left > 0) && (rcWindow.right < 800) && (rcWindow.top > 0) && (rcWindow.bottom < 480)) { MoveWindow(hwnd, rcWindow.left, rcWindow.top, RECTW(rcWindow), RECTH(rcWindow), TRUE); //RECT rc; //GetWindowRect(hWnd, &rc); //DPRINTF(JINFO, "rc %d %d\n",rc.left,rc.top); //g_SKB->move(rc.left, rc.top - 50); old_x = x; old_y = y; } } break; } case MSG_USER_IME_STATUS: { int type = imemgr.changeIme (); //fprintf(stderr,"get type %d \n",type); if(type == IME_CLOSE){ //std::cerr << "ime close\n"; mgiSetActiveIMEWindow(imecon_handle,""); }else if(type == IME_QUANPIN){ mgiSetActiveIMEWindow(imecon_handle,"quanpin"); }else if(type == IME_T9){ //fprintf(stderr,"change to mgphone\n"); if(!mgiSetActiveIMEWindow(imecon_handle,"mgphone")) { fprintf(stderr,"change ime to mgphone faild\n"); }else { SendNotifyMessage (t9_ime_hwnd, MSG_IME_OPEN, 0, 0); ShowWindow (t9_ime_hwnd,SW_SHOW); } } InvalidateRect (hwnd,&refRect,TRUE); } break; }; return DefaultMainWinProc (hwnd, message, wParam, lParam); }
static __s32 homeWndProc(__gui_msg_t * msg) { HomeDescriptor * hdp; H_WIN wndGesture; EWin_InheritInfo_ForHeader * extWinIfno; H_WIN hwnd; char name[20]; hdp = (HomeDescriptor *)GUI_WinGetAddData(msg->h_deswin); if (NULL == hdp) { if (GUI_MSG_CREATE != msg->id) { LogE("Failed to get home window private date, message ID (%d)", msg->id); return GUI_ManWinDefaultProc(msg); } } switch (msg->id) { case GUI_MSG_CREATE: hdp = homeWndInit(msg); if (!hdp) { GUI_PostQuitMessage(msg->h_deswin); LogE("Create Home window failed"); return -1; } if(hdp->ewii.suspend){ GUI_SetTimer(msg->h_deswin,SUSPEND_TIMER,6000,NULL); }else{ __msg("suspend is null"); } GUI_WinSetAddData(msg->h_deswin, (__u32)hdp); GUI_WinSetFocusChild(hdp->hFocusWin); break; case GUI_MSG_DESTROY: GG_GestureClose(hdp->inertia); if (hdp->ewii.gdi.font) { GUI_SFT_ReleaseFont(hdp->ewii.gdi.font); } esMEMS_Mfree(0, hdp); break; case GUI_MSG_TOUCH: #ifdef THIS_DEBUG //LogMI("Touch:%x,%d,%d", msg->dwAddData1, LOSWORD(msg->dwAddData2), HISWORD(msg->dwAddData2)); #endif if(standy_en){ if(hdp->ewii.suspend == 1){ dsk_display_lcd_on(); }else if(hdp->ewii.suspend == 2){ }else if(hdp->ewii.suspend == 3){ GUI_LyrWinDelete(hdp->StandyWindow); } standy_en = 0; break; } if(LOSWORD(msg->dwAddData2) > 320 || HISWORD(msg->dwAddData2) > 240){ break; } GUI_ResetTimer(msg->h_deswin,SUSPEND_TIMER,6000,NULL); if (GUI_MSG_TOUCH_DOWN == msg->dwAddData1) { wndGesture = EWin_GestureAttrCollect(GUI_WinGetFocusChild(msg->h_deswin), LOSWORD(msg->dwAddData2), HISWORD(msg->dwAddData2)); if (wndGesture) { extWinIfno = GUI_WinGetAttr(wndGesture); GG_GestureOnDown(hdp->inertia, msg, LOSWORD(msg->dwAddData2), HISWORD(msg->dwAddData2), &extWinIfno->gestureArgs); } } else if (GUI_MSG_TOUCH_MOVE == msg->dwAddData1) { GG_GestureOnMove(hdp->inertia, msg, LOSWORD(msg->dwAddData2), HISWORD(msg->dwAddData2)); } else if (GUI_MSG_TOUCH_UP == msg->dwAddData1) { GG_GestureOnUp(hdp->inertia, msg, LOSWORD(msg->dwAddData2), HISWORD(msg->dwAddData2)); }else if(GUI_MSG_TOUCH_LONGDOWN == msg->dwAddData1){ GG_GestureOnLpress(hdp->inertia, msg, LOSWORD(msg->dwAddData2), HISWORD(msg->dwAddData2)); } break; case GUI_MSG_TIMER: if (HOME_GESTURE_TIMER == msg->dwAddData1) { GG_GestureOnTimer(hdp->inertia, msg); }else if(SUSPEND_TIMER == msg->dwAddData1){ if(!standy_en){ if(hdp->ewii.suspend==1){ dsk_display_lcd_off(); //standy_en = 1; }else if(hdp->ewii.suspend==2){ msg->h_deswin = GUI_WinGetFocusChild(msg->h_deswin); msg->id = GUI_MSG_USER_GESTURE_DONE; msg->dwAddData2 = MAKELONG(320,0); GUI_PostMessage(msg); //standy_en = 1; }else if(hdp->ewii.suspend==3){ hdp->StandyWindow = StandyWndCreate("d:\\res\\boot_ui\\logo.bmp"); }else{ } standy_en = 1; } } break; case GUI_MSG_USER_WIN_CHANGE: if (HOME_SUBWIN_UPDATE == msg->dwAddData2) { GUI_LyrWinSetSta(hdp->ewii.lyrLow,GUI_LYRWIN_STA_SLEEP); GUI_LyrWinSetSta(hdp->ewii.lyrHigher,GUI_LYRWIN_STA_SLEEP); GUI_LyrWinSetSta(hdp->ewii.inilyrHigher,GUI_LYRWIN_STA_SLEEP); hdp->hFocusWin = SettingWndCreate(&hdp->ewii); if(hdp->hFocusWin){ GUI_WinSetFocusChild(hdp->hFocusWin); } }else if(HOME_SUBWIN_SETTING_TIME== msg->dwAddData2){ GUI_LyrWinSetSta(hdp->ewii.inilyrHigher,GUI_LYRWIN_STA_SLEEP); GUI_LyrWinSetSta(hdp->ewii.lyrHigher,GUI_LYRWIN_STA_SLEEP); GUI_LyrWinSetSta(hdp->ewii.lyrLow,GUI_LYRWIN_STA_SLEEP); hdp->hFocusWin = Setting_TimeWndCreate(&hdp->ewii); if(hdp->hFocusWin){ GUI_WinSetFocusChild(hdp->hFocusWin); } }else { if(GUI_ManWinDelete(hdp->hFocusWin)==ORANGE_OK){ GUI_WinSetFocusChild(GUI_WinGetFirstChild(msg->h_deswin)); GUI_LyrWinSetSta(hdp->ewii.lyrLow,GUI_LYRWIN_STA_ON); GUI_LyrWinSetSta(hdp->ewii.lyrHigher,GUI_LYRWIN_STA_ON); GUI_LyrWinSetSta(hdp->ewii.inilyrHigher,GUI_LYRWIN_STA_ON); } } break; default: #ifdef THIS_DEBUG // LogMI("Unhandled home window message (%d)", msg->id); #endif GUI_ManWinDefaultProc(msg); break; } return 0; }
static int PlatformProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam) { switch (message) { case MSG_CREATE: { if (!hmWnd) hmWnd = hWnd; unsigned char* pdr = 0; int w,h,p; RECT r; key_down = FALSE; GetClientRect(hWnd, &r); #if RGB555 sdc = CreateMemDC(width, height, 16, MEMDC_FLAG_SWSURFACE, 0x7C00, 0x3E0, 0x1F, 0x8000); #else sdc = CreateMemDC(width, height, 16, MEMDC_FLAG_SWSURFACE, 0xF800, 0x7E0, 0x1F, 0x00); #endif pdr = LockDC(sdc, &r, &w, &h, &p); UnlockDC(sdc); #if RGB555 fmt = COLOR_FORMAT_RGB555; #else fmt = COLOR_FORMAT_RGB565; #endif ps_initialize(); canvas = ps_canvas_create_with_data(pdr, fmt, w, h, p); context = ps_context_create(canvas, 0); on_init(context, width, height); } break; case MSG_TIMER: on_timer(); break; case MSG_PAINT: { HDC hdc = BeginPaint(hWnd); on_draw(context); BitBlt(sdc, 0, 0, width, height, hdc, 0, 0, 0); EndPaint(hWnd, hdc); } return 0; case MSG_ERASEBKGND: return 0; case MSG_LBUTTONDOWN: { key_down = TRUE; on_mouse_event(LEFT_BUTTON_DOWN, key_conv(wParam), LOSWORD(lParam), HISWORD(lParam)); } break; case MSG_LBUTTONUP: { key_down = FALSE; on_mouse_event(LEFT_BUTTON_UP, key_conv(wParam), LOSWORD(lParam), HISWORD(lParam)); } break; case MSG_MOUSEMOVE: { DWORD k = key_conv(wParam); if (key_down) k |= EVT_LBUTTON; on_mouse_event(MOUSE_MOVE, k, LOSWORD(lParam), HISWORD(lParam)); } break; case MSG_KEYDOWN: on_key_event(KEY_EVENT_DOWN, get_virtual_key(wParam)); break; case MSG_KEYUP: on_key_event(KEY_EVENT_UP, get_virtual_key(wParam)); break; case MSG_SIZECHANGED: { RECT r; int w,h,p; unsigned char* pdr = 0; ps_canvas* old_canvas = 0; RECT* rc = (RECT*)lParam; width = RECTWP(rc); height = RECTHP(rc); if (sdc) DeleteMemDC(sdc); if (width < 1) width = 1; if (height < 1) height = 1; #if RGB555 sdc = CreateMemDC(width, height, 16, MEMDC_FLAG_SWSURFACE, 0x7C00, 0x3E0, 0x1F, 0x8000); #else sdc = CreateMemDC(width, height, 16, MEMDC_FLAG_SWSURFACE, 0xF800, 0x7E0, 0x1F, 0x00); #endif GetClientRect(hWnd, &r); pdr = LockDC(sdc, &r, &w, &h, &p); UnlockDC(sdc); canvas = ps_canvas_create_with_data(pdr, fmt, w, h, p); old_canvas = ps_context_set_canvas(context, canvas); ps_canvas_unref(old_canvas); on_size(width, height); } break; case MSG_CLOSE: on_term(context); ps_context_unref(context); ps_canvas_unref(canvas); ps_shutdown(); DeleteMemDC(sdc); DestroyMainWindow (hWnd); PostQuitMessage (hWnd); return 0; } return DefaultMainWinProc(hWnd, message, wParam, lParam); }
static void this_mouse_handler(void* context, int message, WPARAM wParam, LPARAM lParam) { int x, y; int i = 0; DSPITEM* item; static int old_x = 0, old_y = 0; x = LOSWORD (lParam); y = HISWORD (lParam); switch(message) { case MSG_DT_LBUTTONDOWN: { item = icon_info.app_items; for(i = 0; i < icon_info.nr_apps; i++, item++) { if (PtInRect(&item->hot_spot_rc, x, y)) { icon_info.focus = i; old_x = x; old_y = y; SendMessage(HWND_DESKTOP, MSG_ERASEDESKTOP, 0, (LPARAM)&item->hot_spot_rc); break; } } break; } case MSG_DT_LBUTTONUP: { icon_info.focus = 0xFFFF; SendMessage(HWND_DESKTOP, MSG_ERASEDESKTOP, 0, 0); break; } case MSG_DT_LBUTTONDBLCLK: { char buff [PATH_MAX + NAME_MAX + 1]; item = icon_info.app_items; for(i = 0; i < icon_info.nr_apps; i++, item++) { if (PtInRect(&item->hot_spot_rc, x, y)) { if(item->cdpath) { chdir(item->path); } strcpy (buff, item->path); strcat (buff, item->name); exec_app_name(buff, item->name, "-layer"); break; } } break; } case MSG_DT_MOUSEMOVE: { RECT rc; if (icon_info.focus == 0xFFFF) break; item = icon_info.app_items; for(i = 0; i < icon_info.nr_apps; i++, item++) { if (i == icon_info.focus ) { GetBoundRect(&rc, &item->text_rc, &item->hot_spot_rc); item->hot_spot_rc.left += x - old_x; item->hot_spot_rc.right += x - old_x; item->hot_spot_rc.top += y - old_y; item->hot_spot_rc.bottom += y - old_y; item->text_rc.left += x - old_x; item->text_rc.right += x - old_x; item->text_rc.top += y - old_y; item->text_rc.bottom += y - old_y; old_x = x; old_y = y; GetBoundRect(&rc, &rc, &item->hot_spot_rc); GetBoundRect(&rc, &rc, &item->text_rc); SendMessage(HWND_DESKTOP, MSG_ERASEDESKTOP, 0, (LPARAM)&rc); } } break; } case MSG_DT_RBUTTONUP: { BOOL flag = FALSE; item = icon_info.app_items; for(i = 0; i < icon_info.nr_apps; i++, item++) { if (PtInRect(&item->hot_spot_rc, x, y)) { icon_info.focus = i; SendMessage(HWND_DESKTOP, MSG_ERASEDESKTOP, 0, (LPARAM)&item->hot_spot_rc); TrackPopupMenu (((Context *)context)->icon_menu, TPM_DEFAULT, x, y, HWND_DESKTOP); flag = TRUE; break; } } if(!flag) TrackPopupMenu (((Context *)context)->hmenu, TPM_DEFAULT, x, y, HWND_DESKTOP); break; } } }
/** * 通过回调函数的方式取触摸屏消息 */ static __s32 tp_msg_cb(void *msg) { __msrv_msg_t *pmsg; __u8 error; __u32 i; __input_event_packet_t *pPacket; __input_event_t *pEventFrame; __input_event_t pEvent_type; __input_event_t pEvent_x; __input_event_t pEvent_y; __input_event_t pEvent_speed_dir; __input_event_t pEvent_speed_val; if (msg == NULL) { __msg("invalid argument for call back\n"); return EPDK_FAIL; } /* dump packet events */ pPacket = (__input_event_packet_t *)msg; if (pPacket->event_cnt <= 0 || pPacket->event_cnt > INPUT_MAX_EVENT_NR) { __msg("invalid event count number\n"); return EPDK_FAIL; } //__inf("\n------------------------------------------------\n"); for (i = 0; i < pPacket->event_cnt; i++) { pEventFrame = &(pPacket->events[i]); /*__inf("Event %d: type = %d, code = %d, value = %d\n", i + 1, pEventFrame->type, pEventFrame->code, pEventFrame->value );*/ if(pEventFrame->type == EV_ABS) { if(pEventFrame->code == ABS_MISC) { eLIBs_memcpy(&pEvent_type, pEventFrame, sizeof(__input_event_t)); } else if(pEventFrame->code == ABS_X) { eLIBs_memcpy(&pEvent_x, pEventFrame, sizeof(__input_event_t)); } else if(pEventFrame->code == ABS_Y) { eLIBs_memcpy(&pEvent_y, pEventFrame, sizeof(__input_event_t)); } else if(pEventFrame->code == ABS_RUDDER) { eLIBs_memcpy(&pEvent_speed_dir, pEventFrame, sizeof(__input_event_t)); } else if(pEventFrame->code == ABS_BRAKE) { eLIBs_memcpy(&pEvent_speed_val, pEventFrame, sizeof(__input_event_t)); } } else if(pEventFrame->type == EV_SYN) { break; } } //__inf("\n------------------------------------------------\n"); esKRNL_SemPend(emit_ctr.p_array_sem, 0, &error); pmsg = get_msg_buf(&emit_ctr); esKRNL_SemPost(emit_ctr.p_array_sem); pmsg->type = GUI_MSG_TOUCH; switch( pEvent_type.value) { case EV_TP_PRESS_START: { pmsg->id = GUI_MSG_TOUCH_DOWN; pmsg->data = (pEvent_y.value<<16) + pEvent_x.value; pmsg->reserved = (pEvent_speed_dir.value<<16) + pEvent_speed_val.value; last_touch_action = GUI_MSG_TOUCH_DOWN; break; } case EV_TP_PRESS_MOVE: pmsg->id = GUI_MSG_TOUCH_MOVE; pmsg->data = (pEvent_y.value<<16) + pEvent_x.value; pmsg->reserved = (pEvent_speed_dir.value<<16) + pEvent_speed_val.value; last_touch_action = GUI_MSG_TOUCH_MOVE; break; case EV_TP_PINCH_IN: pmsg->id = GUI_MSG_TOUCH_ZOOMIN; pmsg->data = (pEvent_y.value<<16) + pEvent_x.value; pmsg->reserved = (pEvent_speed_dir.value<<16) + pEvent_speed_val.value; last_touch_action = GUI_MSG_TOUCH_ZOOMIN; break; case EV_TP_PINCH_OUT: pmsg->id = GUI_MSG_TOUCH_ZOOMOUT; pmsg->data = (pEvent_y.value<<16) + pEvent_x.value; pmsg->reserved = (pEvent_speed_dir.value<<16) + pEvent_speed_val.value; last_touch_action = GUI_MSG_TOUCH_ZOOMOUT; break; case EV_TP_PRESS_HOLD: pmsg->id = last_touch_action; pmsg->data = (pEvent_y.value<<16) + pEvent_x.value; pmsg->reserved = (pEvent_speed_dir.value<<16) + pEvent_speed_val.value; break; case EV_TP_ACTION_NULL: case EV_TP_ACTION_CLICK: case EV_TP_ACTION_DOWN: case EV_TP_ACTION_UP: case EV_TP_ACTION_LEFT: case EV_TP_ACTION_RIGHT: case EV_TP_ACTION_ANTICLOCKWISE: case EV_TP_ACTION_CLOCKWISE: case EV_TP_ACTION_LD2RU: case EV_TP_ACTION_RU2LD: case EV_TP_ACTION_LU2RD: case EV_TP_ACTION_RD2LU: pmsg->id = GUI_MSG_TOUCH_UP; pmsg->data = (pEvent_y.value<<16) + pEvent_x.value; pmsg->reserved = (pEvent_speed_dir.value<<16) + pEvent_speed_val.value; break; default: __msg("cannot identify message: %x\n", pEvent_type.value); return EPDK_FALSE; } __msg("------------------------------------------------\n"); __msg("pmsg->type = %d, pmsg->id = %d\n", pmsg->type, pmsg->id); __msg("x = %d, y = %d\n", LOSWORD(pmsg->data), HISWORD(pmsg->data)); __msg("------------------------------------------------\n"); esKRNL_QPost(emit_ctr.psys_msg_queue, pmsg); return EPDK_TRUE; }
static void _touch_proc( __gui_msg_t * msg ) { __u32 tmp_sta = 0; __s32 x, y; RECT client_rect; spinbox_para_t *user_data; user_data = (spinbox_para_t *)(((spinbox_data_t *)GUI_CtrlWinGetAddData(msg->h_deswin))->data); x = LOSWORD(msg->dwAddData2); y = HISWORD(msg->dwAddData2); GUI_WinGetClientRECT(msg->h_deswin, &client_rect); switch(msg->dwAddData1) { case GUI_MSG_TOUCH_LONGDOWN: case GUI_MSG_TOUCH_DOWN: { if (GUI_WinGetCaptureWin () != msg->h_deswin) { GUI_WinSetCaptureWin(msg->h_deswin); } if(user_data->spin_sta == 0) { if(x < client_rect.width/2) tmp_sta = 0; else tmp_sta = 1; } else { if(y < client_rect.height/2) tmp_sta = 0; else tmp_sta = 1; } if(tmp_sta == 0) { user_data->cur_value--; if(user_data->cur_value < user_data->min_value) user_data->cur_value = user_data->max_value; SPINBOX_DRAWFLAG(msg->h_deswin) |= BST_LEFT; } else { user_data->cur_value++; if(user_data->cur_value > user_data->max_value) user_data->cur_value = user_data->min_value; SPINBOX_DRAWFLAG(msg->h_deswin) &= (~ BST_LEFT); } { __gui_notify_msg_t notify_msg; notify_msg.hWnd = msg->h_deswin; notify_msg.id = GUI_WinGetItemId(msg->h_deswin); notify_msg.msgcode = SPN_CHG; notify_msg.dwAddData= user_data->cur_value; GUI_NotifyParent (¬ify_msg); } SPINBOX_DRAWSTATUS(msg->h_deswin) |= BST_PUSHED; GUI_InvalidateRect (msg->h_deswin, NULL, EPDK_TRUE); } break; case GUI_MSG_TOUCH_MOVE: { } break; case GUI_MSG_TOUCH_UP: { { __gui_notify_msg_t notify_msg; notify_msg.hWnd = msg->h_deswin; notify_msg.id = GUI_WinGetItemId(msg->h_deswin); notify_msg.msgcode = SPN_STOPCHG; notify_msg.dwAddData= user_data->cur_value; GUI_NotifyParent (¬ify_msg); } SPINBOX_DRAWSTATUS(msg->h_deswin) &= (~ BST_PUSHED); GUI_InvalidateRect (msg->h_deswin, NULL, EPDK_TRUE); if (GUI_WinGetCaptureWin () == msg->h_deswin) { GUI_WinReleaseCapture(); } } break; default: break; } }