1: /*
     2:  ============================================================================
     3:  xoblite™ -> an advanced "extended shell" for Microsoft® Windows® 11
     4:  Copyright © 2002-2026 Karl Henrik Henriksson [qwilk/@xoblite]
     5:  Copyright © 2001-2004 The Blackbox for Windows Development Team
     6:  http://xoblite.net/ + https://github.com/xoblite/
     7:  ============================================================================
     8: 
     9:   Blackbox for Windows is free software, released under the
    10:   GNU General Public License (GPL version 2 or later), with an extension
    11:   that allows linking of proprietary modules under a controlled interface.
    12:   What this means is that plugins etc. are allowed to be released
    13:   under any license the author wishes. Please note, however, that the
    14:   original Blackbox gradient math code used in Blackbox for Windows
    15:   is available under the BSD license.
    16: 
    17:   http://www.fsf.org/licenses/gpl.html
    18:   http://www.fsf.org/licenses/gpl-faq.html#LinkingOverControlledInterface
    19:   http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5
    20: 
    21:   This program is distributed in the hope that it will be useful,
    22:   but WITHOUT ANY WARRANTY; without even the implied warranty of
    23:   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    24:   GNU General Public License for more details.
    25: 
    26:   For additional license information, please read the included license.html.
    27: 
    28:  ============================================================================
    29: */
    30: 
    31: #include "TaskbarMenu.h" 
    32: #include "..\Menu\FolderItem.h" 
    33: #include "..\Menu\MenuCommon.h" 
    34: #include "..\API\BBApi.h" 
    35: #include "..\Settings\Settings.h" 
    36: 
    37: extern MenuCommon *pMenuCommon;
    38: extern Settings *pSettings;
    39: 
    40: #define GROUP_TASKBAR_MODE 1 
    41: #define GROUP_TASKBAR_SORT 2 
    42: 
    43: //===========================================================================
    44: 
    45: TaskbarMenu::TaskbarMenu(char* pszTitle) : FolderItem(NULL, pszTitle, NULL)
    46: {
    47: }
    48: 
    49: TaskbarMenu::~TaskbarMenu()
    50: {
    51:     m_pParent->RemoveChild(m_pSubMenu);
    52:     if (m_pSubMenu) delete m_pSubMenu;
    53:     m_pSubMenu = NULL;
    54: }
    55: 
    56: //===========================================================================
    57: 
    58: bool TaskbarMenu::Active(bool bActivate)
    59: {
    60:     if (bActivate && !m_bActive) UpdateFolder();
    61:     return FolderItem::Active(bActivate);
    62: }
    63: 
    64: void TaskbarMenu::Attached(Menu* pMenu)
    65: {
    66:     m_pParent = pMenu;
    67:     m_pSubMenu = new Menu(pMenuCommon->hInst);
    68:     m_pParent->AddChild(m_pSubMenu);
    69:     m_pSubMenu->SetParent(m_pParent);
    70: }
    71: 
    72: //===========================================================================
    73: 
    74: void TaskbarMenu::UpdateFolder()
    75: {
    76:     m_pSubMenu->DeleteMenuItems();
    77:     pMenuCommon->AddHeaderItem(m_pSubMenu, m_pszTitleANSI);
    78: 
    79:     //====================
    80: 
    81:     MenuItem* groupItem;
    82:     groupItem = pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_COMMAND, "@xoblite Taskbar Hide", NULL, "Hidden", (pSettings->taskbarMode == TASKBAR_MODE_HIDDEN));
    83:     groupItem->AddToSelectionGroup(GROUP_TASKBAR_MODE);
    84:     groupItem = pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_COMMAND, "@xoblite Taskbar Mode Bars", NULL, "Bars mode", (pSettings->taskbarMode == TASKBAR_MODE_BARS));
    85:     groupItem->AddToSelectionGroup(GROUP_TASKBAR_MODE);
    86:     groupItem = pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_COMMAND, "@xoblite Taskbar Mode Bars+Icons", NULL, "Bars+Icons mode", (pSettings->taskbarMode == TASKBAR_MODE_BARSICONS));
    87:     groupItem->AddToSelectionGroup(GROUP_TASKBAR_MODE);
    88:     if (!pSettings->toolbarVertical)
    89:     {
    90:         groupItem = pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_COMMAND, "@xoblite Taskbar Mode Icons", NULL, "Icons mode", (pSettings->taskbarMode == TASKBAR_MODE_ICONS));
    91:         groupItem->AddToSelectionGroup(GROUP_TASKBAR_MODE);
    92:     }
    93: 
    94:     pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_SEPARATOR, NULL, NULL, NULL, false);
    95: 
    96:     //====================
    97: 
    98:     char command[50];
    99:     sprintf_s(command, sizeofArray(command), "\"@xoblite Taskbar Items\" %d 1 255", pSettings->taskbarMaxItems);
   100:     pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_EDITINT, command, NULL, "Max # of visible items:", false);
   101: 
   102:     Menu* sortingSubMenu = MakeMenu("Sort visible items");
   103:     groupItem = pMenuCommon->CreateMenuItem(sortingSubMenu, MENUITEM_COMMAND, "@xoblite Taskbar Sort Last Used", NULL, "Last used", (pSettings->taskbarSorting == TASKBAR_SORT_BY_LAST_USED));
   104:     groupItem->AddToSelectionGroup(GROUP_TASKBAR_SORT);
   105:     groupItem = pMenuCommon->CreateMenuItem(sortingSubMenu, MENUITEM_COMMAND, "@xoblite Taskbar Sort Follow Active", NULL, "Follow active", (pSettings->taskbarSorting == TASKBAR_SORT_FOLLOW_ACTIVE));
   106:     groupItem->AddToSelectionGroup(GROUP_TASKBAR_SORT);
   107:     groupItem = pMenuCommon->CreateMenuItem(sortingSubMenu, MENUITEM_COMMAND, "@xoblite Taskbar Sort Disabled", NULL, "Disabled", (pSettings->taskbarSorting == TASKBAR_SORT_DISABLED));
   108:     groupItem->AddToSelectionGroup(GROUP_TASKBAR_SORT);
   109:     MakeSubmenu(m_pSubMenu, sortingSubMenu, "Sort visible items");
   110: 
   111:     pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_SEPARATOR, NULL, NULL, NULL, false);
   112: 
   113:     //====================
   114: 
   115:     pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_BOOLEAN, "@xoblite Taskbar ToggleShowTaskWorkspace", NULL, "Show task workspace", pSettings->taskbarShowTaskWorkspace);
   116:     pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_BOOLEAN, "@xoblite Taskbar ToggleCurrentOnly", NULL, "Current workspace only", pSettings->taskbarCurrentOnly);
   117:     pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_BOOLEAN, "@xoblite Taskbar ToggleFlashing", NULL, "Disable task flashing", !pSettings->taskbarFlashing);
   118: 
   119:     pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_SEPARATOR, NULL, NULL, NULL, false);
   120: 
   121:     //====================
   122: 
   123:     sprintf_s(command, sizeofArray(command), "\"@xoblite Taskbar IconSaturation\" %d 0 255", pSettings->taskbarSaturationValue);
   124:     pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_EDITINT, command, NULL, "Icon saturation:", false);
   125:     sprintf_s(command, sizeofArray(command), "\"@xoblite Taskbar IconHue\" %d 0 255", pSettings->taskbarHueIntensity);
   126:     pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_EDITINT, command, NULL, "Icon hue:", false);
   127: 
   128:     pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_BOOLEAN, "@xoblite Taskbar ToggleActiveSatHue", NULL, "Active task sat/hue", pSettings->taskbarActiveSatHue);
   129: 
   130:     pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_BOOLEAN, "@xoblite Taskbar ToggleInactiveBackground", NULL, "Inactive task background", pSettings->taskbarInactiveBackground);
   131: 
   132:     pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_SEPARATOR, NULL, NULL, NULL, false);
   133: 
   134:     //====================
   135: 
   136: //  pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_BOOLEAN, "@xoblite Taskbar ToggleActiveLivePreview", NULL, "Active task live preview", pSettings->taskbarActiveLivePreview);
   137: //  pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_BOOLEAN, "@xoblite Taskbar ToggleInactiveBackground", NULL, "Inactive task background", pSettings->taskbarInactiveBackground);
   138: 
   139: //  pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_SEPARATOR, NULL, NULL, NULL, false);
   140: 
   141:     //====================
   142: 
   143:     pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_BOOLEAN, "@xoblite Taskbar TogglePreviews", NULL, "Show previews", pSettings->taskbarPreviews);
   144:     pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_BOOLEAN, "@xoblite Taskbar ToggleTooltips", NULL, "Show tooltips", pSettings->taskbarTooltips);
   145: 
   146:     //====================
   147: 
   148:     pMenuCommon->AddFooterItem(m_pSubMenu, "");
   149:     m_pSubMenu->Invalidate();
   150:     m_pSubMenu->Validate();
   151: }
   152: 
   153: //===========================================================================
   154: