static void draw_hilight_box (HWND hWnd, HDC hdc, COOLBARITEMDATA* item) { int l,r,t,b; WINDOWINFO *info = (WINDOWINFO*)GetWindowInfo (hWnd); DWORD color; DWORD mainc = GetWindowElementAttr (hWnd, WE_MAINC_THREED_BODY); l = item->RcTitle.left; t = item->RcTitle.top; r = item->RcTitle.right - 1; b = item->RcTitle.bottom - 1; color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_DARKER); SetPenColor (hdc, RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), GetBValue (color), GetAValue (color))); MoveTo (hdc, l, t); LineTo (hdc, l, b); MoveTo (hdc, r - 1, t); LineTo (hdc, r - 1, b); color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_LIGHTER); SetPenColor (hdc, RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), GetBValue (color), GetAValue (color))); MoveTo (hdc, l + 1, t); LineTo (hdc, l + 1, b); MoveTo (hdc, r, t); LineTo (hdc, r, b); }
/* * * * ¨x¨x¨x¨x¨x¨x¨xtop_line(dark) * ---------top_line(light) * ¨† ¨‡ ¨‡¨† * left_line(dark+light) ¨† ¨‡ ¨‡¨†right_line(light+dark) * ¨† ¨‡ ¨‡¨† * base_line_left ¨{¨{¨{¨{¨{¨{¨{ ¨{¨{¨{¨{¨{¨{¨{ base_line_right */ static void draw_hilight_box (HWND hWnd, HDC hdc, COOL_INDICATOR_ITEMDATA* item) { int l,r,t,b; WINDOWINFO *info = (WINDOWINFO*)GetWindowInfo (hWnd); DWORD color; DWORD mainc = GetWindowElementAttr (hWnd, WE_FGC_THREED_BODY); //UI@hilight_box_color if(item == NULL) return; l = item->RcTitle.left; t = item->RcTitle.top + 2; r = item->RcTitle.right + 1; b = item->RcTitle.bottom + 1; color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_DARKER); SetPenColor (hdc, RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), GetBValue (color), GetAValue (color))); MoveTo (hdc, l, t); LineTo (hdc, l, b); //left_line_dark MoveTo (hdc, r, t); LineTo (hdc, r, b); //right_line_dark MoveTo (hdc, l, t); LineTo (hdc, r, t); //top_line_dark color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_LIGHTER); SetPenColor (hdc, RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), GetBValue (color), GetAValue (color))); MoveTo (hdc, l + 1, t); LineTo (hdc, l + 1, b); //left_line_light MoveTo (hdc, r - 1, t); LineTo (hdc, r - 1, b); //right_line_light MoveTo (hdc, l, t+1); LineTo (hdc, r, t+1); //top_line_light mainc = GetWindowElementPixelEx(hWnd, hdc, WE_FGC_THREED_BODY); //to avoid hdc use the color as ARGB SetBrushColor(hdc, mainc); //base line color RECT rP; GetWindowRect(GetParent(hWnd), &rP); int x, y, w, h; x = 0; y = item->RcTitle.bottom + 2; w = item->RcTitle.left + 2; h = 4; FillBox(hdc, x, y, w, h); //base_line_left x = item->RcTitle.right + 1; y = item->RcTitle.bottom + 2; w = RECTW(rP) - x; h = 4; FillBox(hdc, x, y, w, h); //base_line_right }
static void draw_hilighted_item(HWND hDlg, HDC hdc) { LicensePlate_CtrlInfo_t* ctrlInfo; HWND hwndWidget; int prevSel; RECT rect; int x, y, w, h; gal_pixel hilightColor, normalColor; hilightColor = RGBA2Pixel(HDC_SCREEN, 0xDC, 0xDC, 0xDC, 0xFF); // hilightColor = RGBA2Pixel(HDC_SCREEN, 0x00, 0xFF, 0x99, 0xFF); normalColor = RGBA2Pixel(HDC_SCREEN, 0x99, 0x99, 0x99, 0xFF); ctrlInfo = (LicensePlate_CtrlInfo_t*)GetWindowAdditionalData(hDlg); if(ctrlInfo != NULL) { if(ctrlInfo->curSel >= 0) { hwndWidget = GetDlgItem(hDlg, ID_NUMBER_START + ctrlInfo->curSel); GetWindowRect(hwndWidget, &rect); w = ctrlInfo->pBmpArrow->bmWidth; h = ctrlInfo->pBmpArrow->bmHeight; x = rect.left; y = rect.top - h - 4; if(w < RECTW(rect)) { x = rect.left + ( (RECTW(rect) - w) >> 1 ); } FillBoxWithBitmap(hdc, x, y, w, h, ctrlInfo->pBmpArrow); if(hwndWidget && hwndWidget != HWND_INVALID) { SetWindowBkColor(hwndWidget, hilightColor ); } prevSel = ctrlInfo->curSel - 1; if(prevSel >= 0) { hwndWidget = GetDlgItem(hDlg, ID_NUMBER_START + prevSel ); if(hwndWidget && hwndWidget != HWND_INVALID) { SetWindowBkColor(hwndWidget, normalColor ); } } } else {
static void draw_frame_lines(HWND hDlg, HDC hdc) { RECT rect_parent, rect_plate_num; gal_pixel lineColor; GetClientRect(hDlg, &rect_parent); int line_w = RECTW(rect_parent); //three lines lineColor = RGBA2Pixel(hdc, 0X42, 0xCE, 0xFF, 0xFF); SetPenColor(hdc, lineColor); MoveTo(hdc, 0, ctrlData[IDX_SWITCH_ICON].y-1); LineTo(hdc, line_w, ctrlData[IDX_SWITCH_ICON].y-1); MoveTo(hdc, 0, ctrlData[IDX_SWITCH_ICON].y+ctrlData[IDX_SWITCH_ICON].h+1); LineTo(hdc, line_w, ctrlData[IDX_SWITCH_ICON].y+ctrlData[IDX_SWITCH_ICON].h+1); GetWindowRect(GetDlgItem(hDlg, ID_NUMBER_START), &rect_plate_num); MoveTo(hdc, 0, rect_plate_num.bottom + 24); LineTo(hdc, line_w, rect_plate_num.bottom + 24); }
int MiniGUIMain (int argc, const char* argv[]) { MSG Msg; HWND hMainWnd; MAINWINCREATE CreateInfo; #ifdef _MGRM_PROCESSES JoinLayer (NAME_DEF_LAYER , "helloworld" , 0 , 0); #endif CreateInfo.dwStyle = WS_VISIBLE | WS_BORDER | WS_CAPTION; CreateInfo.dwExStyle = WS_EX_NONE; CreateInfo.spCaption = "HelloWorld"; CreateInfo.hMenu = 0; CreateInfo.hCursor = GetSystemCursor (0); CreateInfo.hIcon = 0; CreateInfo.MainWindowProc = HelloWinProc; CreateInfo.lx = 0; CreateInfo.ty = 0; CreateInfo.rx = 240; CreateInfo.by = 180; CreateInfo.iBkColor = RGBA2Pixel(HDC_SCREEN, 0xff, 0xff, 0xff, 0x00); CreateInfo.dwAddData = 0; CreateInfo.hHosting = HWND_DESKTOP; hMainWnd = CreateMainWindow (&CreateInfo); if (LoadBitmap (HDC_SCREEN, &bmp_bkgnd, "/res/topbar/playback.png")) return 1; if (hMainWnd == HWND_INVALID) return -1; ShowWindow (hMainWnd, SW_SHOWNORMAL); while (GetMessage (&Msg, hMainWnd)) { fprintf(stderr, "msg\n"); TranslateMessage (&Msg); DispatchMessage (&Msg); } UnloadBitmap(&bmp_bkgnd); MainWindowThreadCleanup (hMainWnd); return 0; }
static void DrawCoolBox (HWND hWnd, HDC hdc, PCOOLBARCTRL pdata) { COOLBARITEMDATA* tmpdata; RECT rc; int l,t; WINDOWINFO *info = (WINDOWINFO*)GetWindowInfo (hWnd); DWORD color; DWORD mainc = GetWindowElementAttr (hWnd, WE_MAINC_THREED_BODY); GetClientRect (hWnd, &rc); if (pdata->BackBmp) { FillBoxWithBitmap (hdc, 0, 0, rc.right, rc.bottom, pdata->BackBmp); } color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_DARKEST); SetPenColor (hdc, RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), GetBValue (color), GetAValue (color))); MoveTo (hdc, 0, 0); LineTo (hdc, rc.right, 0); MoveTo (hdc, 0, rc.bottom - 2); LineTo (hdc, rc.right, rc.bottom - 2); color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_LIGHTEST); SetPenColor (hdc, RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), GetBValue (color), GetAValue (color))); MoveTo (hdc, 0, 1); LineTo (hdc, rc.right, 1); MoveTo (hdc, 0, rc.bottom - 1); LineTo (hdc, rc.right, rc.bottom - 1); tmpdata = pdata->head; while (tmpdata) { l = tmpdata->RcTitle.left; t = tmpdata->RcTitle.top; switch (tmpdata->ItemType) { case TYPE_BARITEM: { WINDOWINFO *info = (WINDOWINFO*)GetWindowInfo (hWnd); RECT rcTmp; rcTmp.left = l + 2; rcTmp.top = 4; rcTmp.right = l + 4; rcTmp.bottom = rc.bottom - 4; info->we_rdr->draw_3dbox (hdc, &rcTmp, GetWindowElementAttr (hWnd, WE_MAINC_THREED_BODY), LFRDR_BTN_STATUS_PRESSED); } break; case TYPE_BMPITEM: FillBoxWithBitmap (hdc, l + 2, t + 2, pdata->ItemWidth, pdata->ItemHeight, tmpdata->Bmp); break; case TYPE_TEXTITEM: { SIZE size; int h; WINDOWINFO *info; RECT rc; if (tmpdata->Caption == NULL || tmpdata->Caption [0] == '\0') break; GetTextExtent (hdc, tmpdata->Caption, -1, &size); h = (pdata->ItemHeight - size.cy) / 2; SetBkMode (hdc, BM_TRANSPARENT); if (tmpdata->Disable) { info = (WINDOWINFO*)GetWindowInfo (hWnd); rc.left = l + 2; rc.top = t + h + 2; rc.right = rc.left + size.cx; rc.bottom = rc.top + size.cy; info->we_rdr->disabled_text_out (hWnd, hdc, tmpdata->Caption, &rc, DT_SINGLELINE); } else { SetBkColor (hdc, GetWindowBkColor (hWnd)); SetTextColor (hdc, PIXEL_black); TextOut (hdc, l+2, t + h + 2, tmpdata->Caption); } break; } default: break; } tmpdata = tmpdata->next; } if ((tmpdata = GetCurSel (pdata)) == NULL) return; draw_hilight_box (hWnd, hdc, tmpdata); }
static int HelloWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam) { HDC hdc; static HWND hwnd; static int i = 0; switch (message) { case MSG_PAINT: hdc = BeginPaint (hWnd); TextOut (hdc, 60, 60, "Hello world!"); EndPaint (hWnd, hdc); return 0; case 888888888888888888: { HDC hdc2 = (HDC)wParam; const RECT* clip = (const RECT*) lParam; BOOL fGetDC = FALSE; RECT rcTemp; if (hdc2 == 0) { hdc2 = GetClientDC (hWnd); fGetDC = TRUE; } if (clip) { rcTemp = *clip; ScreenToClient (hWnd, &rcTemp.left, &rcTemp.top); ScreenToClient (hWnd, &rcTemp.right, &rcTemp.bottom); IncludeClipRect (hdc2, &rcTemp); } FillBoxWithBitmap (HDC_SCREEN, 0, 0, 0, 0, &bmp_bkgnd); if (fGetDC) ReleaseDC (hdc2); return 0; } break; case MSG_CREATE: hwnd = CreateWindowEx("static", "", WS_CHILD | WS_VISIBLE, WS_EX_NONE, 123, 0, 0, 50, 50, hWnd, NULL); SetWindowBkColor(hwnd, RGBA2Pixel(HDC_SCREEN, 0x00, 0x00, 0xff, 0x10)); break; case MSG_KEYDOWN: if (i) { SetWindowBkColor(hwnd, RGBA2Pixel(HDC_SCREEN, 0x00, 0x00, 0xff, 0x10)); } else { SetWindowBkColor(hwnd, RGB2Pixel(HDC_SCREEN, 0x00, 0xff, 0xff)); } i = 1-i; break; case MSG_CLOSE: DestroyMainWindow (hWnd); PostQuitMessage (hWnd); return 0; } return DefaultMainWinProc (hWnd, message, wParam, lParam); }