#include "MenuMaker.h"
extern vector<Menu*> g_Menues;
extern Settings *pSettings;
extern PluginManager *pPluginManager;
MenuMaker::MenuMaker()
{
m_pRoot = NULL;
m_pDesktopMenu = NULL;
m_pToolbarMenu = NULL;
m_pSystembarMenu = NULL;
m_pSlitMenu = NULL;
m_pStylesMenu = NULL;
m_pThemesMenu = NULL;
m_pPluginMenu = NULL;
m_pTitle = NULL;
m_pEntry = NULL;
m_pSelEntry = NULL;
m_pBottom = NULL;
m_hDefaultFont = 0;
m_hEntryFont = 0;
}
MenuMaker::~MenuMaker()
{
int i;
if (m_pRoot)
{
int msgs[] = { BB_MENU, BB_HIDEMENU, 0 };
SendMessage (GetBBWnd(), BB_UNREGISTERMESSAGE, (WPARAM)m_RootMenus[0]->GetWindow(), (LPARAM)msgs);
}
DeleteObject(m_hDefaultFont);
DeleteObject(m_hEntryFont);
delete m_pTitle;
delete m_pEntry;
delete m_pSelEntry;
delete m_pBottom;
if (m_pRoot) delete m_pRoot;
if (m_pDesktopMenu) delete m_pDesktopMenu;
if (m_pToolbarMenu) delete m_pToolbarMenu;
if (m_pSystembarMenu) delete m_pSystembarMenu;
if (m_pSlitMenu) delete m_pSlitMenu;
if (m_pStylesMenu) delete m_pStylesMenu;
if (m_pThemesMenu) delete m_pThemesMenu;
if (m_pPluginMenu) DelMenu(m_pPluginMenu);
for (i = 0; i < (int)m_Painters.size(); i++) delete m_Painters[i];
}
void MenuMaker::Initialize(HINSTANCE pMenuInst)
{
hInst = pMenuInst;
ReadConfig();
ParseMenu();
if (!m_pRoot)
{
if (!m_RootMenus.empty()) m_pRoot = m_RootMenus[0];
}
if (m_pRoot)
{
int msgs[] = { BB_MENU, BB_HIDEMENU, 0 };
SendMessage(GetBBWnd(), BB_REGISTERMESSAGE, (WPARAM) m_RootMenus[0]->GetWindow(), (LPARAM)msgs);
}
}
void MenuMaker::ReadConfig()
{
if (m_pTitle) delete m_pTitle;
m_pTitle = MakePainter(pSettings->MenuTitle->Color,
pSettings->MenuTitle->ColorTo,
pSettings->MenuTitle->type,
pSettings->MenuTitle->interlaced,
pSettings->MenuTitle->bevelstyle,
pSettings->MenuTitle->bevelposition,
pSettings->bevelWidth);
MenuItem::SetTitleAlignment(pSettings->MenuTitle->Justify);
if (m_pEntry) delete m_pEntry;
m_pEntry = new Painter;
MenuItem::SetAlignment(pSettings->MenuFrame->Justify);
if (m_pSelEntry) delete m_pSelEntry;
m_pSelEntry = MakePainter(pSettings->MenuHilite->Color,
pSettings->MenuHilite->ColorTo,
pSettings->MenuHilite->type,
pSettings->MenuHilite->interlaced,
pSettings->MenuHilite->bevelstyle,
pSettings->MenuHilite->bevelposition,
pSettings->bevelWidth);
if (m_pBottom) delete m_pBottom;
m_pBottom = new Painter;
if ((!stricmp(pSettings->menuBullet, "triangle")) || (!stricmp(pSettings->menuBullet, "arrow")))
FolderItem::SetBulletStyle(BS_TRIANGLE);
else if (!stricmp(pSettings->menuBullet, "square")) FolderItem::SetBulletStyle(BS_SQUARE);
else if (!stricmp(pSettings->menuBullet, "diamond")) FolderItem::SetBulletStyle(BS_DIAMOND);
else if (!stricmp(pSettings->menuBullet, "circle")) FolderItem::SetBulletStyle(BS_CIRCLE);
else if (!stricmp(pSettings->menuBullet, "triple")) FolderItem::SetBulletStyle(BS_TRIPLE);
else if (!stricmp(pSettings->menuBullet, "comment")) FolderItem::SetBulletStyle(BS_COMMENT);
else if (!stricmp(pSettings->menuBullet, "grid")) FolderItem::SetBulletStyle(BS_GRID);
else FolderItem::SetBulletStyle(BS_EMPTY);
if (!stricmp(pSettings->menuBulletPosition, "LeftJustify")||!stricmp(pSettings->menuBulletPosition, "Left"))
{
FolderItem::SetBulletPosition(DT_LEFT);
CommandItem::SetBulletPosition(DT_LEFT);
}
else
{
FolderItem::SetBulletPosition(DT_RIGHT);
CommandItem::SetBulletPosition(DT_RIGHT);
}
m_nBorderWidth = pSettings->menuBorderWidth;
m_nBorderColor = pSettings->menuBorderColor;
if (m_hDefaultFont) DeleteObject(m_hDefaultFont);
if (strlen(pSettings->MenuTitle->Font)) m_hDefaultFont = CreateFont(pSettings->MenuTitle->FontHeight, 0, 0, 0, pSettings->MenuTitle->FontWeight, false, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, pSettings->MenuTitle->Font);
else
{
LOGFONT logFont;
SystemParametersInfo(SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
m_hDefaultFont = CreateFontIndirect(&logFont);
}
m_nSeparatorHeight = 6;
if (m_hEntryFont) DeleteObject(m_hEntryFont);
if (strlen(pSettings->MenuFrame->Font)) m_hEntryFont = CreateFont(pSettings->MenuFrame->FontHeight, 0, 0, 0, pSettings->MenuFrame->FontWeight, false, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, pSettings->MenuFrame->Font);
else m_hEntryFont = m_hDefaultFont;
m_pTitle->SetFont(m_hDefaultFont, pSettings->MenuTitle->TextColor);
m_pEntry->SetFont(m_hEntryFont, pSettings->MenuFrame->TextColor);
m_pSelEntry->SetFont(m_hEntryFont, pSettings->MenuHilite->TextColor);
SIZE size;
HDC fonthdc = CreateDC("DISPLAY", NULL, NULL, NULL);
HGDIOBJ oldDefaultfont = SelectObject(fonthdc, m_hDefaultFont);
if (!stricmp(pSettings->MenuTitle->Font, "nu")) size.cy = 7;
else GetTextExtentPoint32(fonthdc, "TQkgfp/", 8, &size);
if (!pSettings->slimlineMetrics && pSettings->MenuTitle->marginWidth != 0)
{
m_nTitleHeight = size.cy + (2 * pSettings->MenuTitle->marginWidth) + (2 * pSettings->MenuTitle->borderWidth);
}
else
{
if (pSettings->MenuTitle->bevelstyle != BEVEL_FLAT)
{
if (pSettings->MenuTitle->bevelposition == BEVEL2) m_nTitleHeight = size.cy + 6;
else m_nTitleHeight = size.cy + 4;
}
else m_nTitleHeight = size.cy + 2;
m_nTitleHeight += (2 * m_nBorderWidth);
}
int minTitleFontHeight = pSettings->MenuTitle->FontHeight + (2 * m_nBorderWidth);
if (m_nTitleHeight < minTitleFontHeight) m_nTitleHeight = minTitleFontHeight;
SelectObject(fonthdc, oldDefaultfont);
HGDIOBJ oldEntryfont = SelectObject(fonthdc, m_hEntryFont);
if (!stricmp(pSettings->MenuFrame->Font, "nu")) size.cy = 7;
else GetTextExtentPoint32(fonthdc, "TQkgfp/", 8, &size);
if (!pSettings->slimlineMetrics && pSettings->MenuFrame->marginWidth != 0)
{
m_nSubmenuHeight = size.cy + (2 * pSettings->MenuFrame->marginWidth);
}
else
{
if (pSettings->MenuHilite->bevelstyle != BEVEL_FLAT)
{
if (pSettings->MenuHilite->bevelposition == BEVEL2) m_nSubmenuHeight = size.cy + 4;
else m_nSubmenuHeight = size.cy + 2;
}
else m_nSubmenuHeight = size.cy + 2;
m_nSubmenuHeight += (2 * pSettings->MenuHilite->borderWidth);
}
if (m_nSubmenuHeight < pSettings->MenuFrame->FontHeight) m_nSubmenuHeight = pSettings->MenuFrame->FontHeight;
SelectObject(fonthdc, oldEntryfont);
DeleteDC(fonthdc);
m_nBottomHeight = 0;
int smallIndent = 3 + m_nBorderWidth;
if (!pSettings->slimlineMetrics) smallIndent += pSettings->MenuFrame->marginWidth;
int bulletIndent = 13 + m_nBorderWidth;
if (!pSettings->slimlineMetrics) bulletIndent += pSettings->MenuFrame->marginWidth;
if (!stricmp(pSettings->menuBullet, "empty"))
{
MenuItem::SetIndent(bulletIndent);
MenuItem::SetRightIndent(bulletIndent);
}
else if (!stricmp(pSettings->menuBulletPosition, "LeftJustify")||!stricmp(pSettings->menuBulletPosition, "Left"))
{
MenuItem::SetIndent(bulletIndent);
MenuItem::SetRightIndent(smallIndent);
}
else
{
MenuItem::SetIndent(smallIndent);
MenuItem::SetRightIndent(bulletIndent);
}
}
void MenuMaker::ParseMenu()
{
FILE *pMenu = FileOpen(pSettings->menuFile);
if (!stricmp(ReadString(pSettings->menuFile, "[begin]", ""), ""))
{
FileClose(pMenu);
char msg[MAX_LINE_LENGTH];
strcpy(msg, pSettings->menuFile);
strcat(msg,
"\n\nYour menu file does not seem to be valid. \n\n"
"Do you want to create a new menu file with default items? \n"
"(clicking \"No\" will open your current menu file for editing) ");
if (MessageBox(GetDesktopWindow(), msg, "xoblite", MB_YESNO | MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST) == IDYES)
{
pSettings->WriteDefaultMenu();
}
else PostMessage(GetBBWnd(), BB_EDITFILE, 1, 0);
pMenu = FileOpen(pSettings->menuFile);
}
m_pRoot = new Menu(hInst);
ParseFolder(pMenu, m_pRoot);
m_pRoot->Validate();
m_RootMenus.insert(m_RootMenus.begin(), m_pRoot);
m_pDesktopMenu = new DesktopMenu("Workspaces", this);
m_RootMenus.insert(m_RootMenus.begin()+1, m_pDesktopMenu);
m_pToolbarMenu = new ToolbarMenu("Toolbar", this);
m_RootMenus.insert(m_RootMenus.begin()+2, m_pToolbarMenu);
m_pSystembarMenu = new SystembarMenu("Systembar", this);
m_RootMenus.insert(m_RootMenus.begin()+3, m_pSystembarMenu);
m_pSlitMenu = new SlitMenu("Slit", this);
m_RootMenus.insert(m_RootMenus.begin()+4, m_pSlitMenu);
m_pStylesMenu = new StylesMenu("Styles", this);
m_RootMenus.insert(m_RootMenus.begin()+5, m_pStylesMenu);
m_pThemesMenu = new ThemesMenu("Themes", this);
m_RootMenus.insert(m_RootMenus.begin()+6, m_pThemesMenu);
FileClose(pMenu);
}
void MenuMaker::ParseFolder(FILE *pMenu, Menu *pRoot)
{
for(;;)
{
char szLineBuffer[MAX_LINE_LENGTH]="";
if (!ReadNextCommand(pMenu, szLineBuffer, sizeof(szLineBuffer)))
break;
if (!ParseLine(pMenu, pRoot, szLineBuffer))
break;
}
}
bool MenuMaker::ParseLine(FILE *pMenu, Menu *pRoot, char *pszLine)
{
char command[MAX_LINE_LENGTH]="", label[MAX_LINE_LENGTH]="", data[MAX_LINE_LENGTH]="";
Painter* pPainter = m_pEntry;
MenuItem* pMenuItem = NULL;
if (!strchr(pszLine, '['))
return true;
while (*pszLine && isspace(*pszLine)) pszLine++;
if (strchr(pszLine, '$')) ReplaceShellFolders(pszLine);
if (strchr(pszLine, '%')) ReplaceEnvVars(pszLine);
strcpy(data, Tokenize(pszLine, command, " "));
if (*data == '(')
{
strcpy(data, Tokenize(data, label, ")"));
memmove(label, label+1, strlen(label));
}
if (*data == '{') StrRemoveEncap(data);
if (!stricmp(command, "[begin]"))
{
if (!stricmp(label, ""))
{
strcpy(m_szHotListName, "xoblite ");
strcat(m_szHotListName, (LPSTR)GetBBVersion());
}
else strcpy(m_szHotListName, label);
AddHeaderItem(m_pRoot, m_szHotListName);
return true;
}
else if (!stricmp(command, "[submenu]"))
{
Menu* pSub = new Menu(hInst);
AddHeaderItem(pSub, strlen(data) ? data : label);
ParseFolder(pMenu, pSub);
pSub->Validate();
pMenuItem = new FolderItem(pSub, label);
}
else if (!stricmp(command, "[end]"))
{
AddBottomItem(pRoot);
return false;
}
else if (!stricmp(command, "[include]"))
{
if (!FileExists(label))
{
char message[MAX_LINE_LENGTH];
strcpy(message, "xoblite was unable to include...\n\n");
strcat(message, label);
strcat(message, "\n\n...into the menu. Please check your menu configuration file. ");
MessageBox(GetBBWnd(), message, "xoblite", MB_OK | MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST);
CreateMenuItem(pRoot, "[nop]", NULL, "[include failed]", false);
return true;
}
FILE *pMenu = FileOpen(label);
ParseFolder(pMenu, pRoot);
FileClose(pMenu);
return true;
}
else if (!stricmp(command, "[path]"))
pMenuItem = new SpecialFolder(data, this, label, 1);
else if (!stricmp(command, "[stylesmenu]"))
pMenuItem = new SpecialFolder(data, this, label, 0);
else if (!stricmp(command, "[themesmenu]"))
pMenuItem = new SpecialFolder(pSettings->themesFolder, this, label, 2);
else if (!stricmp(command, "[stylesdir]"))
{
InsertFolder(pRoot, label, false, false);
return true;
}
else if (!stricmp(command, "[stylestree]"))
{
InsertFolder(pRoot, label, true, false);
return true;
}
else if (!stricmp(command, "[workspaces]"))
pMenuItem = new FolderItem(new DesktopMenu(label ? label : "Workspaces", this), label ? label : "Workspaces");
else if (!stricmp(command, "[tasks]"))
pMenuItem = new DesktopMenuItem("Icons", this, 255);
else if (!stricmp(command, "[config]"))
pMenuItem = new FolderItem(new ConfigMenu(label ? label : "Configuration", this), label ? label : "Configuration");
else
{
CreateMenuItem(pRoot, command, data, label, false);
return true;
}
pMenuItem->SetHeight(m_nSubmenuHeight);
pMenuItem->SetPainter(pPainter);
pMenuItem->SetActivePainter(m_pSelEntry);
pRoot->AddMenuItem(pMenuItem);
return true;
}
void MenuMaker::AddHeaderItem(Menu* pMenu, LPSTR pszTitle)
{
MenuItem* pHead = new TitleItem(pszTitle, MENU_HEADER);
pHead->SetPainter(m_pTitle);
pHead->SetHeight(m_nTitleHeight);
pMenu->AddMenuItem(pHead);
}
void MenuMaker::AddBottomItem(Menu* pMenu)
{
MenuItem* pMenuItem = new TitleItem("", MENU_NOP);
pMenuItem->SetPainter(m_pBottom);
pMenuItem->SetHeight(m_nBottomHeight);
pMenu->AddMenuItem(pMenuItem);
}
void MenuMaker::InsertFolder(Menu *pMenu, LPSTR pszFolder, bool includeSubFolders, bool themesMenu)
{
char tempPath[MAX_LINE_LENGTH];
strcpy(tempPath, pszFolder);
char pszPattern[MAX_LINE_LENGTH];
long handle;
_finddata_t found;
MenuItem* pItem = NULL;
char itemCmd[MAX_LINE_LENGTH];
char itemTitle[MAX_LINE_LENGTH];
bool directoryFound = false, itemFound = false;
// First, we create a file search pattern by taking the path to the directory...
strcpy(pszPattern, tempPath);
if (pszPattern[strlen(pszPattern)] != '\\') strcat(pszPattern, "\\");
// ...and adding a wildcard pattern
strcat(pszPattern, "*");
// Using this pattern, we then search for items in the directory
handle = _findfirst(pszPattern, &found);
if (includeSubFolders || themesMenu)
{
if (handle != -1)
{
do
{
if (strcmp(found.name, ".") == 0 || strcmp(found.name, "..") == 0 || (found.attrib & _A_HIDDEN))
continue;
if (found.attrib & _A_SUBDIR)
{
if (themesMenu)
{
strcpy(itemCmd, pszPattern);
itemCmd[strlen(itemCmd)-1] = '\0';
strcat(itemCmd, found.name);
strcpy(itemTitle, found.name);
CreateMenuItem(pMenu, "[theme]", itemCmd, itemTitle, IsInString(bbrcPath(), itemCmd));
}
else
{
char dirPath[MAX_LINE_LENGTH];
strcpy(dirPath,"\"");
strcat(dirPath, pszPattern);
dirPath[strlen(dirPath)-1] = '\0';
strcat(dirPath, found.name);
strcat(dirPath, "\"");
pItem = new SpecialFolder(dirPath, this, found.name, 0);
pItem->SetHeight(m_nSubmenuHeight);
pItem->SetPainter(m_pEntry);
pItem->SetActivePainter(m_pSelEntry);
pMenu->AddMenuItem(pItem);
directoryFound = true;
}
}
else continue;
}
while(_findnext(handle, &found)==0);
}
_findclose(handle);
handle = _findfirst(pszPattern, &found);
}
if ((handle != -1) && !themesMenu)
{
do
{
if(strcmp(found.name, ".") == 0 || strcmp(found.name, "..") == 0 || (found.attrib & _A_HIDDEN))
continue;
if(found.attrib & _A_SUBDIR)
continue;
else
{
strcpy(itemCmd, pszPattern);
itemCmd[strlen(itemCmd)-1] = '\0';
strcat(itemCmd, found.name);
strcpy(itemTitle, found.name);
if (IsInString(itemTitle, ".style")) PathRemoveExtension(itemTitle);
CreateMenuItem(pMenu, "[style]", itemCmd, itemTitle, (!stricmp(itemCmd, pSettings->styleFile)));
itemFound = true;
}
}
while(_findnext(handle, &found)==0);
}
_findclose(handle);
if (directoryFound && itemFound) CreateMenuItem(pMenu, "[separator]", NULL, NULL, false);
pMenu->Sort(0,0);
}
Menu* MenuMaker::LoadFolder(LPSTR pszTitle, LPSTR pszFolder, int menuType)
{
char folder[MAX_LINE_LENGTH], title[MAX_LINE_LENGTH];
strcpy(folder, pszFolder);
strcpy(title, pszTitle);
long handle;
_finddata_t found;
MenuItem* pItem = NULL;
char itemCmd[MAX_LINE_LENGTH], itemTitle[MAX_LINE_LENGTH], dirPath[MAX_LINE_LENGTH];
bool directoryFound = false, itemFound = false;
Menu* pMenu = new Menu(hInst);
AddHeaderItem(pMenu, title);
if (menuType == 2)
{
char bbpath[MAX_LINE_LENGTH];
GetBlackboxPath(bbpath, MAX_LINE_LENGTH);
bbpath[strlen(bbpath)-1] = 0;
CreateMenuItem(pMenu, "[theme]", bbpath, "<Default>", !IsInString(bbrcPath(), "themes"));
}
char folderToken[MAX_LINE_LENGTH], folderPattern[MAX_LINE_LENGTH];
while (strlen(folder))
{
strcpy(folder, Tokenize(folder, folderToken, "|"));
if (folderToken[0] == '\"') StrRemoveEncap(folderToken);
LPSTR wildcardPointer = strchr(folderToken, '*');
if (wildcardPointer != NULL)
{
strcpy(folderPattern, folderToken);
int i = (int)(wildcardPointer - folderToken);
folderToken[i] = '\0';
}
else
{
if (folderToken[strlen(folderToken)] != '\\') strcat(folderToken, "\\");
strcpy(folderPattern, folderToken);
strcat(folderPattern, "*");
}
handle = _findfirst(folderPattern, &found);
if (handle != -1)
{
do
{
if (strcmp(found.name, ".") == 0 || strcmp(found.name, "..") == 0 || (found.attrib & _A_HIDDEN))
continue;
if (found.attrib & _A_SUBDIR)
{
if (menuType == 2)
{
strcpy(itemCmd, folderToken);
strcat(itemCmd, found.name);
strcpy(itemTitle, found.name);
CreateMenuItem(pMenu, "[theme]", itemCmd, itemTitle, IsInString(bbrcPath(), itemCmd));
}
else
{
strcpy(dirPath,"\"");
strcat(dirPath, folderToken);
strcat(dirPath, found.name);
strcat(dirPath, "\"");
pItem = new SpecialFolder(dirPath, this, found.name, menuType);
pItem->SetHeight(m_nSubmenuHeight);
pItem->SetPainter(m_pEntry);
pItem->SetActivePainter(m_pSelEntry);
pMenu->AddMenuItem(pItem);
directoryFound = true;
}
}
else
{
if (menuType == 0)
{
if (IsInString(found.name, ".3dc")) continue;
strcpy(itemCmd, folderToken);
strcat(itemCmd, found.name);
strcpy(itemTitle, found.name);
if (IsInString(itemTitle, ".style")) PathRemoveExtension(itemTitle);
CreateMenuItem(pMenu, "[style]", itemCmd, itemTitle, (!stricmp(itemCmd, pSettings->styleFile)));
itemFound = true;
}
else if (menuType == 1)
{
strcpy(itemCmd, "\"");
strcat(itemCmd, folderToken);
strcat(itemCmd, found.name);
strcat(itemCmd, "\"");
strcpy(itemTitle, found.name);
if (IsInString(itemTitle, ".lnk")) PathRemoveExtension(itemTitle);
CreateMenuItem(pMenu, "[exec]", itemCmd, itemTitle, false);
itemFound = true;
}
}
}
while (_findnext(handle, &found)==0);
}
_findclose(handle);
}
if (directoryFound && itemFound) CreateMenuItem(pMenu, "[separator]", NULL, NULL, false);
if (menuType == 2) pMenu->Sort(1,0);
else pMenu->Sort(0,0);
AddBottomItem(pMenu);
pMenu->Validate();
return pMenu;
}
void MenuMaker::Show(int index)
{
m_RootMenus[index]->Show();
SetFocus(m_RootMenus[index]->GetWindow());
}
void MenuMaker::Hide(int index)
{
pSettings->menuEditboxAlreadyActive = false;
for (int i=0; i < (int)m_RootMenus.size(); i++)
{
if (m_RootMenus[i]->IsPinned())
m_RootMenus[i]->SetPinned(false);
m_RootMenus[i]->Hide(HIDE_PARENTS);
m_RootMenus[i]->Hide(HIDE_CHILDREN);
}
if (m_pPluginMenu)
{
m_pPluginMenu->Hide(HIDE_PARENTS);
m_pPluginMenu->Hide(HIDE_CHILDREN);
ShowWindow(m_pPluginMenu->GetWindow(), SW_HIDE);
}
}
void MenuMaker::ShowRootMenu()
{
m_pRoot->SetPinned(true);
m_pRoot->Show();
}
void MenuMaker::ShowDesktopMenu()
{
m_pDesktopMenu->SetPinned(true);
m_pDesktopMenu->Show();
}
void MenuMaker::ShowToolbarMenu()
{
m_pToolbarMenu->SetPinned(true);
m_pToolbarMenu->Show();
}
void MenuMaker::ShowSystembarMenu()
{
m_pSystembarMenu->SetPinned(true);
m_pSystembarMenu->Show();
}
void MenuMaker::ShowSlitMenu()
{
m_pSlitMenu->SetPinned(true);
m_pSlitMenu->Show();
}
void MenuMaker::ShowStylesMenu()
{
m_pStylesMenu->SetPinned(true);
m_pStylesMenu->Show();
}
void MenuMaker::ShowThemesMenu()
{
m_pThemesMenu->SetPinned(true);
m_pThemesMenu->Show();
}
Painter* MenuMaker::MakePainter(DWORD dwColor, DWORD dwGradColor, int nType, bool bInterlaced, int bevelStyle, int bevelPosition, int bevelWidth)
{
Painter* pNewPainter = NULL;
if (nType == 255)
pNewPainter = new GradientPainter(dwColor, dwGradColor, nType, bInterlaced, bevelStyle, bevelPosition, bevelWidth);
else
{
pNewPainter = new GradientPainter(dwColor, dwGradColor, nType, bInterlaced, bevelStyle, bevelPosition, bevelWidth);
}
return pNewPainter;
}
MenuItem* MenuMaker::CreateMenuItem(Menu *pMenu, char* pszCommand, char* pszArgument, char* pszTitle, bool isSelected)
{
MenuItem *newMenuItem = NULL;
if (pMenu)
{
if (!stricmp(pszCommand, "[separator]"))
{
if (pSettings->menuSeparators)
{
newMenuItem = new TitleItem("", MENU_SEPARATOR);
newMenuItem->SetHeight(m_nSeparatorHeight);
newMenuItem->SetPainter(m_pEntry);
newMenuItem->SetSortPriority(2);
pMenu->AddMenuItem(newMenuItem);
}
}
else if (!stricmp(pszCommand, "[nop]"))
{
if (pszTitle == NULL) newMenuItem = new TitleItem("", MENU_NOP);
else newMenuItem = new TitleItem(pszTitle, MENU_NOP);
newMenuItem->SetHeight(m_nSubmenuHeight);
newMenuItem->SetPainter(m_pEntry);
pMenu->AddMenuItem(newMenuItem);
}
else if (!stricmp(pszCommand, "<edit-string>"))
{
char Cmd[MAX_LINE_LENGTH], init_string[MAX_LINE_LENGTH];
LPSTR tokens[2];
tokens[0] = Cmd;
tokens[1] = init_string;
Cmd[0] = init_string[0] = '\0';
BBTokenize (pszArgument, tokens, 1, init_string);
newMenuItem = new StringItem(pszTitle, Cmd, init_string);
newMenuItem->SetHeight(m_nSubmenuHeight);
newMenuItem->SetPainter(m_pEntry);
newMenuItem->SetActivePainter(m_pSelEntry);
pMenu->AddMenuItem(newMenuItem);
}
else
{
newMenuItem = new CommandItem(pszCommand, pszArgument, pszTitle, isSelected);
newMenuItem->SetHeight(m_nSubmenuHeight);
newMenuItem->SetPainter(m_pEntry);
newMenuItem->SetActivePainter(m_pSelEntry);
pMenu->AddMenuItem(newMenuItem);
}
}
return newMenuItem;
}
syntax highlighting by