void curses_widgets_update_from_dfui_progress(const struct dfui_progress *pr, struct curses_widget *pbar, struct curses_widget *plab, struct curses_widget *pcan) { const char *short_desc; struct timeval now; long msec_diff; struct curses_widget *w; int short_desc_changed; gettimeofday(&now, NULL); msec_diff = (now.tv_sec - last_update.tv_sec) * 1000 + (now.tv_usec - last_update.tv_usec) / 1000; short_desc = dfui_info_get_short_desc(dfui_progress_get_info(pr)); short_desc_changed = (strncmp(plab->text, short_desc, MIN(55, strlen(short_desc))) != 0); if (msec_diff < 100 && !dfui_progress_get_streaming(pr) && !short_desc_changed) return; if (dfui_progress_get_amount(pr) != pbar->amount || short_desc_changed || dfui_progress_get_streaming(pr)) { strcpy_max(plab->text, short_desc, 58); curses_widget_draw(plab); pbar->amount = dfui_progress_get_amount(pr); curses_widget_draw(pbar); if (dfui_progress_get_streaming(pr)) { /* add a label with the text */ w = curses_form_widget_add(pbar->form, 0, ++last_y, 58, CURSES_LABEL, FIFTY_EIGHT_SPACES, 0, CURSES_WIDGET_CENTER); strcpy_max(w->text, dfui_progress_get_msg_line(pr), 58); if (last_y >= pbar->form->int_height) { pbar->form->int_height = last_y + 1; } curses_form_widget_ensure_visible(w); curses_widget_draw(w); } } else { curses_progress_spin(pbar); } wmove(pcan->form->win, pcan->y + 1, pcan->x + pcan->width + 1); curses_form_refresh(NULL); last_update = now; }
void Toolbar_setlabel(void) { // Get current workspace name... DesktopInfo DI; GetDesktopInfo (& DI); _tcsncpy_s(Toolbar_WorkspaceName, 80, DI.name, _TRUNCATE); if (Toolbar_ShowingExternalLabel) return; Toolbar_CurrentWindow[0] = 0; struct tasklist* tl; dolist (tl, GetTaskListPtr()) if (tl->active) break; if (tl) strcpy_max(Toolbar_CurrentWindow, tl->caption, sizeof(Toolbar_CurrentWindow)/sizeof(TCHAR)); //else strcpy(Toolbar_CurrentWindow, _T("Blackbox")); }
struct curses_form * curses_form_construct_from_dfui_progress(const struct dfui_progress *pr, struct curses_widget **pbar, struct curses_widget **plab, struct curses_widget **pcan) { struct curses_form *cf; const char *desc; desc = dfui_info_get_short_desc(dfui_progress_get_info(pr)); cf = curses_form_new(dfui_info_get_name(dfui_progress_get_info(pr))); cf->width = 60; cf->height = 6; if (dfui_progress_get_streaming(pr)) { cf->height = 20; } *plab = curses_form_widget_add(cf, 0, 1, 58, CURSES_LABEL, FIFTY_EIGHT_SPACES, 0, CURSES_WIDGET_CENTER); strcpy_max((*plab)->text, desc, 58); *pbar = curses_form_widget_add(cf, 0, 3, 40, CURSES_PROGRESS, "", 0, CURSES_WIDGET_CENTER); *pcan = curses_form_widget_add(cf, 0, 5, 0, CURSES_BUTTON, "Cancel", 0, CURSES_WIDGET_CENTER | CURSES_WIDGET_WIDEN); (*pbar)->amount = dfui_progress_get_amount(pr); last_y = (*pbar)->y + 2; curses_form_finalize(cf); gettimeofday(&last_update, NULL); return(cf); }
Menu *CfgMenuMaker(const char *title, const char *defbroam, const struct cfgmenu *pm, bool pop, char *menu_id) { char buf[100]; char *broam_dot; char *end_id; Menu *pMenu, *pSub; end_id = strchr(menu_id, 0); pMenu = MakeNamedMenu(title, menu_id, pop); broam_dot = strchr(strcpy_max(buf, defbroam, sizeof buf), 0); for (;pm->text; ++pm) { const char *item_text = pm->text; const void *v = pm->pvalue; const char *cmd = pm->command; const struct int_item *iip; bool disabled, checked; MenuItem *pItem; disabled = checked = false; if (cmd) { if ('@' != *cmd) strcpy(broam_dot, cmd), cmd = buf; if (NULL != (iip = get_int_item(v))) { pItem = MakeMenuItemInt( pMenu, item_text, cmd, *iip->v, iip->minval, iip->maxval); if (-2 != iip->offval) MenuItemOption(pItem, BBMENUITEM_OFFVAL, iip->offval, 10000 == iip->maxval ? NLS0("auto") : NULL); continue; } else if (is_string_item(v)) { MakeMenuItemString(pMenu, item_text, cmd, (const char*)v); continue; } else if (is_fixed_string(v)) { checked = 0 == stricmp((const char *)v, strchr(cmd, ' ')+1); } else if (v) { checked = *(bool*)v; } disabled = (v == &Settings_styleXPFix && Settings_altMethod) || (v == &Settings_menu.dropShadows && false == usingXP) ; pItem = MakeMenuItem(pMenu, item_text, cmd, checked && false == disabled); } else if (v) { sprintf(end_id, "_%s", item_text); if ((DWORD_PTR)v <= SUB_PLUGIN_SLIT) pSub = PluginManager_GetMenu(item_text, menu_id, pop, (int)(DWORD_PTR)v); else pSub = CfgMenuMaker(item_text, defbroam, (struct cfgmenu*)v, pop, menu_id); if (NULL == pSub) continue; pItem = MakeSubmenu(pMenu, pSub, NULL); } else { pItem = MakeMenuNOP(pMenu, item_text); } if (disabled) MenuItemOption(pItem, BBMENUITEM_DISABLED); } return pMenu; }
//=========================================================================== LRESULT CALLBACK Toolbar_WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static UINT msgs[] = { BB_RECONFIGURE, BB_TASKSUPDATE, BB_SETTOOLBARLABEL, BB_BROADCAST, BB_DESKTOPINFO, BB_REDRAWGUI, 0 }; switch (message) { //==================== case WM_CREATE: DisableInputMethod(hwnd); TBInfo.hwnd = Toolbar_hwnd = hwnd; MessageManager_AddMessages (hwnd, msgs); MakeSticky(hwnd); Toolbar_UpdatePosition(); break; //==================== case WM_DESTROY: RemoveSticky(hwnd); MessageManager_RemoveMessages (hwnd, msgs); SetDesktopMargin(Toolbar_hwnd, 0, 0); if (Toolbar_hFont) DeleteObject(Toolbar_hFont), Toolbar_hFont = NULL; TBInfo.hwnd = Toolbar_hwnd = NULL; break; //==================== case BB_RECONFIGURE: tbreconfig: Toolbar_UpdatePosition(); Toolbar_ShowMenu(false); InvalidateRect(hwnd, NULL, FALSE); break; //==================== case BB_REDRAWGUI: if (wParam & BBRG_TOOLBAR) { Toolbar_force_button_pressed = 0 != (wParam & BBRG_PRESSED); Toolbar_UpdatePosition(); InvalidateRect(hwnd, NULL, FALSE); } break; //==================== case BB_TASKSUPDATE: showlabel: Toolbar_setlabel(); InvalidateRect(hwnd, NULL, FALSE); break; case BB_DESKTOPINFO: Toolbar_setlabel(); InvalidateRect(hwnd, NULL, FALSE); break; //==================== case WM_ACTIVATEAPP: if (wParam) SetOnTop(hwnd); break; //==================== case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); PaintToolbar(hdc, &ps.rcPaint); EndPaint(hwnd, &ps); break; } //==================== case BB_SETTOOLBARLABEL: SetTimer(hwnd, TOOLBAR_SETLABEL_TIMER, 2000, (TIMERPROC)NULL); Toolbar_ShowingExternalLabel = true; strcpy_max(Toolbar_CurrentWindow, (LPCTSTR)lParam, sizeof(Toolbar_CurrentWindow)/sizeof(TCHAR)); InvalidateRect(hwnd, NULL, FALSE); break; //==================== case WM_TIMER: if (wParam == TOOLBAR_AUTOHIDE_TIMER) { if (TBInfo.autoHide) { if (check_mouse(hwnd) || (TBInfo.bbsb_hwnd && check_mouse(TBInfo.bbsb_hwnd))) break; Toolbar_AutoHide(true); } KillTimer(hwnd, wParam); break; } if (wParam == TOOLBAR_UPDATE_TIMER) { Toolbar_setclock(); InvalidateRect(hwnd, NULL, FALSE); break; } KillTimer(hwnd, wParam); if (wParam == TOOLBAR_SETLABEL_TIMER) { Toolbar_ShowingExternalLabel = false; goto showlabel; } break; //==================== /* case WM_DROPFILES: drop_style((HDROP)wParam); break; */ //==================== case WM_LBUTTONDOWN: if (wParam & MK_CONTROL) { // Allow window to move if control key is being held down, UpdateWindow(hwnd); SendMessage(hwnd, WM_SYSCOMMAND, 0xf012, 0); break; } goto left_mouse; case WM_LBUTTONDBLCLK: if (wParam & MK_CONTROL) { // double click moves the window back to the default position Toolbar_set_pos(); break; } goto left_mouse; case WM_MOUSEMOVE: if (TBInfo.autohidden) { // bring back from autohide SetTimer(hwnd, TOOLBAR_AUTOHIDE_TIMER, 250, NULL); Toolbar_AutoHide(false); break; } goto left_mouse; case WM_LBUTTONUP: left_mouse: { POINT MouseEventPoint; MouseEventPoint.x = (short)LOWORD(lParam); MouseEventPoint.y = (short)HIWORD(lParam); if (HandleCapture(hwnd, message, MouseEventPoint)) break; for (int i=0; i<5; i++) if (CheckButton( hwnd, message, MouseEventPoint, &Toolbar_Button[i].r, &Toolbar_Button[i].pressed, Toolbar_button_event, i )) goto _break; if (message == WM_LBUTTONDOWN) SetActiveWindow(hwnd); } _break: break; //==================== // show menus case WM_RBUTTONUP: { int x = (short)LOWORD(lParam); if (x < tbClockW) PostMessage(BBhwnd, BB_MENU, BB_MENU_TASKS, 0); else if (x >= TBInfo.width - tbClockW) PostMessage(BBhwnd, BB_MENU, BB_MENU_ROOT, 0); else Toolbar_ShowMenu(true); break; } //==================== case WM_MBUTTONUP: // Is shift key held down? if (wParam & MK_SHIFT) PostMessage(BBhwnd, BB_TOGGLEPLUGINS, 0, 0); else PostMessage(BBhwnd, BB_TOGGLETRAY, 0, 0); break; //==================== // If moved, snap window to screen edges... case WM_WINDOWPOSCHANGING: if (Toolbar_moving) SnapWindowToEdge((WINDOWPOS*)lParam, 0, SNAP_FULLSCREEN); break; case WM_ENTERSIZEMOVE: Toolbar_moving = true; break; case WM_EXITSIZEMOVE: Toolbar_moving = false; break; //==================== case BB_BROADCAST: if (0 == _tmemcmp((LPTSTR)lParam, _T("@Toolbar"), 8)) { const TCHAR *argument = (LPTSTR)lParam; const struct cfgmenu *p_menu, *p_item; const void *v = exec_internal_broam(argument, tb_main, &p_menu, &p_item); if (v) goto tbreconfig; break; } if (!_tcsicmp((LPCTSTR)lParam, _T("@BBShowPlugins"))) { Toolbar_hidden = false; Toolbar_UpdatePosition(); break; } if (!_tcsicmp((LPCTSTR)lParam, _T("@BBHidePlugins"))) { if (Settings_toolbarPluginToggle) { Toolbar_hidden = true; Toolbar_UpdatePosition(); } break; } break; case WM_CLOSE: break; default: return DefWindowProc(hwnd,message,wParam,lParam); //==================== } return 0; }