static BOOL task_enum_func(tasklist const * tl, LPARAM lParam) { struct en* en = (struct en *)lParam; bool is_top = tl->hwnd == en->hwndTop; bool iconic = !is_top && IsIconic(tl->hwnd); en->i++; if ((en->desk == -1 && iconic) // iconic tasks || (en->desk == tl->wkspc // tasks for one workspace && ((en->flags & e_alltasks) || false == iconic))) { char buf[100]; MenuItem *mi; sprintf(buf, "@BBCore.ActivateWindow %d", en->i); mi = MakeMenuItem(en->m, tl->caption, buf, is_top); //#ifdef BBOPT_MENUICONS if (tl->icon && Settings_menu.iconSize) /* BlackboxZero 1.3.2012 */ MenuItemOption(mi, BBMENUITEM_SETHICON, tl->icon); //#endif if (en->desk != -1) { sprintf(buf, "@BBCore.MinimizeWindow %d", en->i); MenuItemOption(mi, BBMENUITEM_RCOMMAND, buf); if (iconic) MenuItemOption(mi, BBMENUITEM_DISABLED); } en->n ++; } return TRUE; }
//=========================================================================== static BOOL CALLBACK recoverwindow_enum_proc(HWND hwnd, LPARAM lParam) { char windowtext[100]; char classname[100]; char appname[100]; char broam[100]; char text[400]; RECT r; MenuItem *mi; if (IsWindowEnabled(hwnd) && (IsIconic(hwnd) || (GetClientRect(hwnd, &r) && r.right && r.bottom)) && GetWindowText(hwnd, windowtext, sizeof(windowtext))) { classname[0] = 0; //GetClassName(hwnd, classname, sizeof classname); GetAppByWindow(hwnd, appname); sprintf (broam, "@BBCore.RecoverWindow %p", hwnd); sprintf (text, "%s : \"%s\"", appname, windowtext); mi = MakeMenuItem((Menu*)lParam, text, broam, FALSE != IsWindowVisible(hwnd)); MenuItemOption(mi, BBMENUITEM_JUSTIFY, DT_LEFT); } return TRUE; }
//=========================================================================== Menu* MakeDesktopMenu(int mode, bool popup) { DesktopInfo DI; struct string_node *sl; int n, d; Menu *m, *s, *i = NULL; if (mode == 2) { m = MakeNamedMenu(NLS0("Tasks"), "Core_tasks_menu", popup); } else { i = build_task_folder(-1, NLS0("Icons"), popup); if (mode == 1) return i; m = MakeNamedMenu(NLS0("Workspaces"), "Core_tasks_workspaces", popup); } getWorkspaces().GetDesktopInfo(DI); for (n = 0, d = DI.nScreens, sl = DI.deskNames; n < d; ++n, sl = sl->next) { if (mode == 0) { char buf[100]; MenuItem *fi; fi = MakeSubmenu(m, build_task_folder(n, sl->str, popup), NULL); sprintf(buf, "@BBCore.SwitchToWorkspace %d", n+1); MenuItemOption(fi, BBMENUITEM_LCOMMAND, buf); if (n == DI.number) MenuItemOption(fi, BBMENUITEM_CHECKED); } else { fill_task_folder(m, n, e_alltasks); if (n == d-1) return m; MakeMenuNOP(m, NULL); } } MakeMenuNOP(m, NULL); MakeSubmenu(m, i, NULL); s = MakeNamedMenu(NLS0("New/Remove"), "Core_workspaces_setup", popup); MakeMenuItem(s, NLS0("New Workspace"), "@BBCore.AddWorkspace", false); if (d > 1) MakeMenuItem(s, NLS0("Remove Last"), "@BBCore.DelWorkspace", false); MakeMenuItemString(s, NLS0("Workspace Names"), "@BBCore.SetWorkspaceNames", Settings_workspaceNames); MakeSubmenu(m, s, NULL); MakeMenuGrip(s, "New/Remove"); MakeMenuGrip(m, "Workspaces"); return m; }
Menu *n_menu::convert(char **broam_key, const char *_id_string, bool _popup) { this->id_string = _id_string; this->popup = _popup; this->broam_key = broam_key; //dbg_printf("<%s>", id_string); Menu *pMenu = MakeNamedMenu(title, id_string, popup); _menuitem *mi = items; while (mi) { MenuItem *pItem = mi->_make_item(pMenu); if (mi->disabled) MenuItemOption(pItem, BBMENUITEM_DISABLED); mi = mi->next; } return pMenu; }
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; }
// recursive parsing of menu file static Menu* ParseMenu(struct menu_src *src, const char *title, const char *IDString) { char line[4000]; char data[4000]; char buffer[4000]; char command[40]; char label[MAX_PATH]; Menu *pMenu, *pSub; MenuItem *pItem; int f, e_cmd; const char *p_label, *p_data, *cp, *p_cmd; pMenu = NULL; for(;;) { p_label = NULL; p_data = data; if (0 == src->level) { // read default menu from string NextToken(line, &src->default_menu, "\n"); } else { f = ReadNextCommand(src->fp[src->level-1], line, sizeof(line)); if (!f) { if (src->level > 1) { dec_inc_level(src); continue; // continue from included file } e_cmd = e_no_end; goto skip; } } cp = replace_environment_strings(line, sizeof line); //dbg_printf("Menu %08x line:%s", pMenu, line); // get the command if (false == get_string_within(command, sizeof command, &cp, "[]")) continue; // search the command e_cmd = get_string_index(command, menu_cmds); if (get_string_within(label, sizeof label, &cp, "()")) p_label = label; if (false == get_string_within(data, sizeof data, &cp, "{}")) p_data = label; skip: if (NULL == pMenu) { if (e_begin == e_cmd) { // If the line contains [begin] we create the menu // If no menu title has been defined, display Blackbox version... #ifdef BBXMENU if (src->default_menu) strcpy(label, "bbXMenu"); else #endif if (0 == label[0] && src->default_menu) p_label = GetBBVersion(); pMenu = MakeNamedMenu(p_label, IDString, src->popup); continue; } if (NULL == title) title = NLS0("missing [begin]"); pMenu = MakeNamedMenu(title, IDString, src->popup); } pItem = NULL; switch (e_cmd) { //==================== // [begin] is like [submenu] when within the menu case e_begin: case e_submenu: sprintf(buffer, "%s_%s", IDString, label); strlwr(buffer + strlen(IDString)); pSub = ParseMenu(src, p_data, buffer); if (pSub) pItem = MakeSubmenu(pMenu, pSub, label); else pItem = MakeMenuNOP(pMenu, label); break; //==================== case e_no_end: MakeMenuNOP(pMenu, NLS0("missing [end]")); case e_end: MenuOption(pMenu, BBMENU_ISDROPTARGET); return pMenu; //==================== case e_include: { char dir[MAX_PATH]; file_directory(dir, src->path[src->level-1]); replace_shellfolders_from_base(buffer, p_data, false, dir); if (false == add_inc_level(src, buffer)) { replace_shellfolders(buffer, p_data, false); if (false == add_inc_level(src, buffer)) MakeMenuNOP(pMenu, NLS0("[include] failed")); } continue; } //==================== // a [nop] item will insert an inactive item with optional text case e_nop: pItem = MakeMenuNOP(pMenu, label); break; // a insert separator, we treat [sep] like [nop] with no label case e_sep1: case e_sep2: pItem = MakeMenuNOP(pMenu, NULL); break; //==================== // a [path] item is pointing to a dynamic folder... case e_path: p_cmd = get_special_command(&p_data, buffer, sizeof buffer); pItem = MakeMenuItemPath(pMenu, label, p_data, p_cmd); break; // a [insertpath] item will insert items from a folder... case e_insertpath: p_cmd = get_special_command(&p_data, buffer, sizeof buffer); pItem = MakeMenuItemPath(pMenu, NULL, p_data, p_cmd); break; // a [stylemenu] item is pointing to a dynamic style folder... case e_stylesmenu: pItem = MakeMenuItemPath(pMenu, label, p_data, MM_STYLE_BROAM); break; // a [styledir] item will insert styles from a folder... case e_stylesdir: pItem = MakeMenuItemPath(pMenu, NULL, p_data, MM_STYLE_BROAM); break; // a [rcmenu] item is pointing to a dynamic rc files folder... case e_rcmenu: pItem = MakeMenuItemPath(pMenu, label, p_data, MM_EDIT_BROAM); break; case e_themesmenu: pItem = MakeMenuItemPath(pMenu, label, p_data, MM_THEME_BROAM); break; //==================== // special items... case e_workspaces: pItem = MakeSubmenu(pMenu, MakeDesktopMenu(0, src->popup), p_label); break; case e_icons: pItem = MakeSubmenu(pMenu, MakeDesktopMenu(1, src->popup), p_label); break; case e_tasks: pItem = MakeSubmenu(pMenu, MakeDesktopMenu(2, src->popup), p_label); break; case e_config: pItem = MakeSubmenu(pMenu, MakeConfigMenu(src->popup), p_label); break; //==================== case e_exec: if ('@' == data[0]) { pItem = MakeMenuItem(pMenu, label, data, false); MenuItemOption(pItem, BBMENUITEM_UPDCHECK); } else { goto core_broam; } break; //==================== case e_other: f = get_workspace_number(command); // check for 'workspace1..' if (-1 != f) { pItem = MakeSubmenu(pMenu, MakeTaskFolder(f, src->popup), p_label); } else { p_data = data; goto core_broam; } break; //==================== // everything else is converted to a '@BBCore.xxx' broam core_broam: f = sprintf(buffer, "@bbCore.%s", command); strlwr(buffer+8); if (p_data[0]) sprintf(buffer + f, " %s", p_data); pItem = MakeMenuItem(pMenu, label[0]?label:command, buffer, false); break; } //#ifdef BBOPT_MENUICONS if ( Settings_menu.iconSize ) { if (pItem && get_string_within(label, sizeof label, &cp, "<>")) MenuItemOption(pItem, BBMENUITEM_SETICON, label); } //#endif } }