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 "Toolbar.h" 
    32: #include "..\Menu\PreviewItem.h" 
    33: 
    34: const char szToolbarName[] = "BBToolbar"; // Window class etc.
    35: 
    36: extern BImage *pBImage;
    37: extern Desktop *pDesktop;
    38: extern Toolbar *pToolbar;
    39: extern Taskbar *pTaskbar;
    40: extern Tooltips *pTooltips;
    41: extern Settings *pSettings;
    42: extern Workspaces *pWorkspaces;
    43: extern MenuCommon *pMenuCommon;
    44: extern PreviewItem* pPreviewItem;
    45: 
    46: int toolbarMessageSubscription[] = { BB_RECONFIGURE, BB_TOGGLETOOLBAR, BB_TOGGLESYSTEMBAR, BB_ADDTASK, BB_REMOVETASK, BB_REDRAW, BB_ACTIVETASK, BB_ACTIVATESHELLWINDOW, BB_TASKSUPDATE, BB_TRAYUPDATE, 0 };
    47: 
    48: //===========================================================================
    49: 
    50: Toolbar::Toolbar(HINSTANCE hInstance)
    51: {
    52:     WNDCLASS wc;
    53:     hToolbarInstance = hInstance;
    54:     hBlackboxWnd = GetBBWnd();
    55: 
    56:     cachedBackground = CreateCompatibleDC(NULL);
    57:     cachedToolbarButton = CreateCompatibleDC(NULL);
    58:     cachedToolbarButtonPressed = CreateCompatibleDC(NULL);
    59:     cachedBitmapsExist = false;
    60: 
    61:     cachedToolbarWindowLabel = CreateCompatibleDC(NULL);
    62:     SetRectEmpty(&currentWindowLabelRect);
    63: 
    64:     ButtonPressed1 = ButtonPressed2 = ButtonPressed3 = ButtonPressed4 = false;
    65:     toolbarVerticalPeeking = ToolbarPosInProgress = false;
    66:     saveWidthAfterDelay = throttlingAddRemoveUpdates = throttlingActivityUpdates = updatesThrottled = false;
    67:     fullscreenDetected = false;
    68:     thumbnail = NULL;
    69: 
    70:     CurrentWindow[0] = '\0';
    71:     clockTimerCounter = 0;
    72: 
    73:     hToolbarCalendarWnd = hToolbarCalendarChildWnd = NULL;
    74: 
    75:     // Save original DesktopArea...
    76: //  SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID)&origDesktopArea, SPIF_SENDCHANGE);
    77: 
    78:     //====================
    79: 
    80:     GetClockText(true); // Note: Get the toolbar clock string first since it is used when calculating the initial window dimensions...
    81:     GetDimensions();
    82:     GetPlacement();
    83: 
    84:     //====================
    85: 
    86:     // Register our window class...
    87:     ZeroMemory(&wc,sizeof(wc));
    88:     wc.hInstance = hToolbarInstance;        
    89:     wc.lpfnWndProc = ToolbarWndProc;            // window procedure
    90:     wc.lpszClassName = szToolbarName;           // window class name
    91:     wc.hbrBackground = NULL;                    // no class background brush
    92:     wc.style = CS_DBLCLKS;                      // class styles (e.g. to accept doubleclicks)
    93:     wc.hCursor = LoadCursor(NULL, IDC_ARROW);   // always display the regular arrow cursor
    94: 
    95:     if (!RegisterClass(&wc))
    96:     {
    97:         MessageBox(0, "Error registering toolbar window class!", szToolbarName, MB_OK | MB_ICONERROR | MB_TOPMOST);
    98:         Log("Toolbar: Error registering window class!", NULL);
    99:         return;
   100:     }
   101: 
   102:     hToolbarWnd = CreateWindowEx(
   103:         WS_EX_TOOLWINDOW | WS_EX_ACCEPTFILES | WS_EX_LAYERED,   // window style
   104:         szToolbarName,                                          // window class
   105:         NULL,                                                   // window name
   106:         WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,           // window parameters
   107:         ToolbarX,                                               // x position
   108:         ToolbarY,                                               // y position
   109:         ToolbarWidth,                                           // window width
   110:         ToolbarHeight,                                          // window height
   111:         NULL, // hBlackboxWnd,                                  // owner window
   112:         NULL,                                                   // no menu
   113:         hToolbarInstance,                                       // hInstance
   114:         NULL                                                    // no window creation data
   115:     );
   116: 
   117:     if (!hToolbarWnd)
   118:     {                          
   119:         UnregisterClass(szToolbarName, hToolbarInstance);
   120:         MessageBox(0, "Error creating toolbar window!", szToolbarName, MB_OK | MB_ICONERROR | MB_TOPMOST);
   121:         Log("Toolbar: Error creating window!", NULL);
   122:         return;
   123:     }
   124: 
   125:     //====================
   126: 
   127:     // Subscribe to Blackbox messages applicable to the toolbar...
   128:     SendMessage(hBlackboxWnd, BB_REGISTERMESSAGE, (WPARAM)hToolbarWnd, (LPARAM)toolbarMessageSubscription);
   129: 
   130:     // Make the toolbar window sticky...
   131:     MakeSticky(hToolbarWnd);    
   132:     // Set toolbar window z-order position... (regular or always on top)
   133: //  if (pSettings->toolbarOnTop) SetWindowPos(hToolbarWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE);
   134:     // Update the toolbar window...
   135:     ShowWindow(hToolbarWnd, pSettings->toolbarHidden ? SW_HIDE : SW_SHOWNOACTIVATE);
   136:     UpdatePosition(); // Note: This in turn also calls UpdateToolbarWindow() and sets the basic toolbar window z-order position... (regular or always on top)
   137: 
   138:     // Finally, if not set to be always on top, we move the toolbar window to be placed just above the *box desktop in the z-order...
   139:     if (!pSettings->toolbarOnTop) SetWindowPos(hToolbarWnd, FindWindow("BBDesktop", NULL), 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | SWP_NOSENDCHANGING | SWP_NOOWNERZORDER);
   140:     else SetForegroundWindow(hToolbarWnd);
   141: 
   142:     //====================
   143: 
   144:     // Update DesktopArea (depending on blackbox.rc fullMaximization setting)...
   145: //  UpdateDesktopArea();
   146: 
   147:     // Set timer for the toolbar clock+windowLabel update checks... (every 250 msecs, but only updating the toolbar if any there have been any changes since the last check etc)
   148:     if (!SetTimer(hToolbarWnd, TOOLBAR_UPDATE_TIMER, 250, (TIMERPROC)NULL))
   149:     {
   150:         MessageBox(0, "Error setting toolbar update timer!", szToolbarName, MB_OK | MB_ICONERROR | MB_TOPMOST);
   151:         Log("Toolbar: Could not set update timer!", NULL);
   152:         return;
   153:     }
   154: 
   155:     //====================
   156: 
   157:     INITCOMMONCONTROLSEX ic;
   158:     ZeroMemory(&ic, sizeof(ic));
   159:     ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
   160:     ic.dwICC = ICC_BAR_CLASSES | ICC_DATE_CLASSES; // Load the tooltip and date-and-time-picker control classes
   161:     InitCommonControlsEx(&ic);
   162: 
   163:     //====================
   164: 
   165:     // Initialize the tooltips subsystem for possible later use by the taskbar...
   166:     pTooltips->Initialize(hToolbarInstance, hToolbarWnd);
   167: }
   168: 
   169: //===========================================================================
   170: 
   171: Toolbar::~Toolbar()
   172: {
   173:     // Kill timers...
   174:     KillTimer(hToolbarWnd, TOOLBAR_UPDATE_TIMER);
   175:     if (saveWidthAfterDelay && !pSettings->toolbarVertical)
   176:     {
   177:         KillTimer(hToolbarWnd, TOOLBAR_SAVE_WIDTH_TIMER);
   178:         WriteInt(pSettings->xobrcFile, "xoblite.toolbar.horizontal.width:", pSettings->toolbarHorizontalWidth);
   179:     }
   180:     
   181:     // Restore original DesktopArea...
   182: //  SystemParametersInfo(SPI_SETWORKAREA, 0, (PVOID)&origDesktopArea, SPIF_SENDCHANGE);
   183: 
   184:     // Unsubscribe to previously subscribed Blackbox messages...
   185:     SendMessage(hBlackboxWnd, BB_UNREGISTERMESSAGE, (WPARAM)hToolbarWnd, (LPARAM)toolbarMessageSubscription);
   186: 
   187:     // Delete taskbar live preview thumbnail...
   188:     if (thumbnail != NULL) DwmUnregisterThumbnail(thumbnail);
   189: 
   190:     // Destroy the toolbar calendar child window...
   191:     if (hToolbarCalendarChildWnd != NULL) DestroyWindow(hToolbarCalendarChildWnd);
   192:     if (hToolbarCalendarWnd != NULL) DestroyWindow(hToolbarCalendarWnd);
   193: 
   194:     DestroyWindow(hToolbarWnd); // Destroy toolbar window...
   195:     UnregisterClass(szToolbarName, hToolbarInstance); // Unregister toolbar window class...
   196: 
   197:     // Delete cached bitmaps...
   198:     if (cachedToolbarWindowLabel) DeleteDC(cachedToolbarWindowLabel);
   199:     if (cachedToolbarButtonPressed) DeleteDC(cachedToolbarButtonPressed);
   200:     if (cachedToolbarButton) DeleteDC(cachedToolbarButton);
   201:     if (cachedBackground) DeleteDC(cachedBackground);
   202: }
   203: 
   204: //===========================================================================
   205: 
   206: LRESULT CALLBACK ToolbarWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
   207: {
   208:     switch (message)
   209:     {
   210:         //====================
   211: 
   212:         case BB_TASKSUPDATE:
   213:         {
   214:             if ((pSettings->taskbarMode != TASKBAR_MODE_HIDDEN) && pTaskbar)
   215:             {
   216: //              if (pSettings->debugLogging) SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"Toolbar -> BB_TASKSUPDATE (taskbar visible)");
   217: 
   218:                 if (lParam == TASKITEM_ADDED || lParam == TASKITEM_REMOVED || lParam == TASKITEM_REFRESH)
   219:                 {
   220:                     if (!pToolbar->throttlingAddRemoveUpdates)
   221:                     {
   222:                         // Wait at least 200 msec between add/remove related UI updates to avoid
   223:                         // excessive toolbar updating when e.g. launching many-multi-window apps...
   224:                         if (pToolbar->throttlingActivityUpdates) KillTimer(pToolbar->hToolbarWnd, TOOLBAR_THROTTLE_UPDATES_TIMER);
   225:                         pToolbar->throttlingAddRemoveUpdates = true;
   226:                         if (!SetTimer(pToolbar->hToolbarWnd, TOOLBAR_THROTTLE_UPDATES_TIMER, 200, (TIMERPROC)NULL)) pToolbar->throttlingAddRemoveUpdates = false;
   227: 
   228:                         pTaskbar->cachedTaskButtonsExist = false;
   229:                         pToolbar->UpdatePosition();
   230: /*
   231:                         if (pSettings->debugLogging)
   232:                         {
   233:                             if (lParam == TASKITEM_ADDED) SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"Toolbar -> TASKITEM_ADDED");
   234:                             else if (lParam == TASKITEM_REMOVED) SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"Toolbar -> TASKITEM_REMOVED");
   235:                             else if (lParam == TASKITEM_REFRESH) SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"Toolbar -> TASKITEM_REFRESH");
   236:                         }
   237: */
   238:                     }
   239:                     else pToolbar->updatesThrottled = true;
   240:                 }
   241: 
   242:                 //====================
   243: 
   244:                 else if (lParam == TASKITEM_MODIFIED || lParam == TASKITEM_FLASHED)
   245:                 {
   246:                     if (wParam != NULL)
   247:                     {
   248:                         int i = pTaskbar->FindTask((HWND)wParam);
   249:                         pToolbar->UpdateToolbarWindow();
   250: /*
   251:                         if (pSettings->debugLogging)
   252:                         {
   253:                             if (lParam == TASKITEM_MODIFIED) SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"Toolbar -> TASKITEM_MODIFIED");
   254:                             else if (lParam == TASKITEM_FLASHED) SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"Toolbar -> TASKITEM_FLASHED");
   255:                         }
   256: */
   257:                     }
   258:                 }
   259: 
   260:                 //====================
   261: 
   262:                 else if (lParam == TASKITEM_ACTIVATED)
   263:                 {
   264:                     if (pTaskbar->FindTask((HWND)wParam) >= 0)
   265:                     {
   266:                         if (!pToolbar->throttlingActivityUpdates || !pToolbar->throttlingAddRemoveUpdates)
   267:                         {
   268:                             // Wait at least 100 msec between activity related UI updates to
   269:                             // suppress e.g. active task flipping when operating the menu...
   270:                             pToolbar->throttlingActivityUpdates = true;
   271:                             if (!SetTimer(pToolbar->hToolbarWnd, TOOLBAR_THROTTLE_UPDATES_TIMER, 100, (TIMERPROC)NULL)) pToolbar->throttlingActivityUpdates = false;
   272:                             pToolbar->UpdateToolbarWindow();
   273:                         }
   274:                         else pToolbar->updatesThrottled = true;
   275: 
   276: //                      if (pSettings->debugLogging) SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"Toolbar -> TASKITEM_ACTIVATED -> Taskbar item activated...");
   277:                     }
   278:                     else
   279:                     {
   280: //                      if (pSettings->debugLogging) SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"Toolbar -> TASKITEM_ACTIVATED -> Non-taskbar item activated...");
   281:                         pToolbar->UpdateToolbarWindow();
   282:                     }
   283:                 }
   284:             }
   285: 
   286:             break;
   287:         }
   288: 
   289:         //====================
   290: 
   291:         case BB_ADDTASK:
   292:         {
   293:             pTaskbar->AddTask((HWND)wParam);
   294:             break;
   295:         }
   296: 
   297:         case BB_REMOVETASK:
   298:         {
   299:             pTaskbar->RemoveTask((HWND)wParam);
   300:             break;
   301:         }
   302: 
   303:         case BB_ACTIVETASK:
   304:         {
   305:             pTaskbar->SetActiveTask((HWND)wParam);
   306:             break;
   307:         }
   308: 
   309:         case BB_REDRAW:
   310:         {
   311:             pTaskbar->RedrawTask((HWND)wParam);
   312:             break;
   313:         }
   314: 
   315:         case BB_ACTIVATESHELLWINDOW:
   316:         {
   317:             pTaskbar->ActivateShellWindow();
   318:             break;
   319:         }
   320: 
   321:         //====================
   322: 
   323:         case WM_TIMER:
   324:         {
   325:             if (wParam == TOOLBAR_THROTTLE_UPDATES_TIMER)
   326:             {
   327:                 KillTimer(pToolbar->hToolbarWnd, TOOLBAR_THROTTLE_UPDATES_TIMER);
   328: 
   329:                 if (pToolbar->updatesThrottled)
   330:                 {
   331:                     if (pToolbar->throttlingAddRemoveUpdates)
   332:                     {
   333:                         pTaskbar->cachedTaskButtonsExist = false;
   334:                         pToolbar->UpdatePosition();
   335: 
   336:                         // if (pSettings->debugLogging) SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"Toolbar -> throttlingAddRemoveUpdates ended.");
   337:                     }
   338:                     else // if (pToolbar->throttlingActivityUpdates)
   339:                     {
   340:                         pToolbar->UpdateToolbarWindow();
   341: 
   342:                         // if (pSettings->debugLogging) SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"Toolbar -> throttlingActivityUpdates ended.");
   343:                     }
   344:                 }
   345: 
   346:                 pToolbar->throttlingAddRemoveUpdates = pToolbar->throttlingActivityUpdates = pToolbar->updatesThrottled = false;
   347: 
   348:                 return 0;
   349:             }
   350: 
   351:             //====================
   352: 
   353:             else if (wParam == TOOLBAR_SAVE_WIDTH_TIMER)
   354:             {
   355:                 KillTimer(pToolbar->hToolbarWnd, TOOLBAR_SAVE_WIDTH_TIMER);
   356:                 if (pToolbar->saveWidthAfterDelay)
   357:                 {
   358:                     if (pSettings->toolbarVertical) WriteInt(pSettings->xobrcFile, "xoblite.toolbar.vertical.width:", pSettings->toolbarVerticalWidth);
   359:                     else WriteInt(pSettings->xobrcFile, "xoblite.toolbar.horizontal.width:", pSettings->toolbarHorizontalWidth);
   360:                     pToolbar->saveWidthAfterDelay = false;
   361:                 }
   362:                 return 0;
   363:             }
   364: 
   365:             //====================
   366: 
   367:             else // TOOLBAR_UPDATE_TIMER
   368:             {
   369:                 bool updateToolbar = false;
   370: 
   371:                 // Should we update the toolbar clock? (nb. every 40x250 msec == 10 seconds; same as the Desktop clock)
   372:                 if (pToolbar->clockTimerCounter < 40) pToolbar->clockTimerCounter++;
   373:                 else
   374:                 {
   375:                     if (pToolbar->GetClockText(false)) updateToolbar = true;
   376:                     pToolbar->clockTimerCounter = 0;
   377:                 }
   378: 
   379:                 // Should we update the toolbar windowLabel? (nb. only applicable if the taskbar is hidden)
   380:                 if (pSettings->taskbarMode == TASKBAR_MODE_HIDDEN)
   381:                 {
   382:                     int i = pTaskbar->GetActiveTask();
   383:                     if (i >= 0)
   384:                     {
   385:                         if (pTaskbar->taskList[i]->hidden || IsIconic(pTaskbar->taskList[i]->hwnd))
   386:                         {
   387:                             if (wcslen(pToolbar->CurrentWindow) > 0)
   388:                             {
   389:                                 pToolbar->CurrentWindow[0] = '\0'; // -> Display "xoblite" as the toolbar windowLabel instead...
   390:                                 updateToolbar = true;
   391:                             }
   392:                         }
   393:                         else if (_wcsicmp(pToolbar->CurrentWindow, pTaskbar->taskList[i]->captionUnicode)) // Has the active task's window title text changed?
   394:                         {
   395:                             wcscpy_s(pToolbar->CurrentWindow, sizeofArray(pToolbar->CurrentWindow), pTaskbar->taskList[i]->captionUnicode);
   396:                             updateToolbar = true;
   397:                         }
   398: 
   399:                         // if (updateToolbar && pSettings->debugLogging) SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"Toolbar -> TOOLBAR_UPDATE_TIMER -> WindowLabel updated.");
   400:                     }
   401:                 }
   402: 
   403:                 // Has the number of visible task buttons on the taskbar changed? (nb. this should normally happen automatically,
   404:                 // but every now and then the toolbar and taskbar may fall out of sync drawing so let's add a failsafe... :) )
   405: //              if (pTaskbar->GetTaskButtonsToDraw() != pTaskbar->taskButtonsLastDrawn) updateToolbar = true;
   406:                 
   407:                 if (updateToolbar) pToolbar->UpdateToolbarWindow();
   408: 
   409:                 return 0;
   410:             }
   411: 
   412:             return 0;
   413:         }
   414: 
   415:         //====================
   416: 
   417:         case WM_DROPFILES:
   418:         {
   419:             return pTaskbar->DropFiles(hwnd, wParam, (pSettings->taskbarMode != TASKBAR_MODE_HIDDEN));
   420:         }
   421:  
   422:         //====================
   423: 
   424:         case BB_RECONFIGURE:
   425:         {
   426:             SetRectEmpty(&pToolbar->currentWindowLabelRect);
   427:             pToolbar->UpdatePosition(); // Gets new settings and resizes window if needed...
   428: 
   429:             if (pSettings->taskbarTooltips)
   430:             {
   431:                 // Update the tooltips colours (background+text), matching the current toolbar style colors...
   432: //              SendMessage(pTooltips->hToolTipsWnd, TTM_SETTIPBKCOLOR, (WPARAM)pSettings->Toolbar->TextColor, 0);
   433: //              SendMessage(pTooltips->hToolTipsWnd, TTM_SETTIPTEXTCOLOR, (WPARAM)pSettings->Toolbar->Color, 0);
   434: //              SendMessage(pTooltips->hToolTipsWnd, TTM_SETTIPBKCOLOR, (WPARAM)pSettings->ToolbarWindowLabel->Color, 0);
   435: //              SendMessage(pTooltips->hToolTipsWnd, TTM_SETTIPTEXTCOLOR, (WPARAM)pSettings->ToolbarWindowLabel->TextColor, 0);
   436:             }
   437: 
   438:             break;
   439:         }
   440: 
   441:         //====================
   442: 
   443:         case BB_TOGGLETOOLBAR:
   444:         {
   445:             if (!pSettings->toolbarHidden) pSettings->toolbarHidden = true;
   446:             else pSettings->toolbarHidden = false;
   447: 
   448:             if (!pSettings->toolbarHidden) pToolbar->UpdatePosition();
   449:             ShowWindow(pToolbar->hToolbarWnd, pSettings->toolbarHidden ? SW_HIDE : SW_SHOWNOACTIVATE);
   450: 
   451:             if (pDesktop) pDesktop->UpdateDesktopWindow(); // In case e.g. the workspace indicators need to be moved given the new toolbar placement
   452: 
   453:             PlaySoundFX(SFX_TOGGLE_ELEMENT);
   454: 
   455:             WriteBool(pSettings->xobrcFile, "xoblite.toolbar.hidden:", pSettings->toolbarHidden);
   456: 
   457:             break;
   458:         }
   459: 
   460:         //====================
   461: 
   462:         case BB_TOGGLESYSTEMBAR:
   463:         {
   464:             pToolbar->ToolbarModeButtonPressed(true);
   465:             break;
   466:         }
   467: 
   468:         //====================
   469: 
   470:         case WM_CLOSE:
   471:         {
   472:             return 0;
   473:         }
   474: 
   475:         //====================
   476: 
   477:         case WM_DISPLAYCHANGE:
   478:         {
   479:             if (pSettings->toolbarHidden) break;
   480:             pToolbar->UpdatePosition();
   481:             break;
   482:         }
   483: 
   484:         case WM_SETTINGCHANGE:
   485:         {
   486:             // Update the toolbar's position (and maybe also dimensions) if the work area changes...
   487:             // (e.g. if the Explorer taskbar is moved to another screen edge)
   488:             if (pSettings->toolbarHidden) break;
   489:             if (wParam == SPI_SETWORKAREA) pToolbar->UpdatePosition();
   490:             return 0;
   491:         }
   492: 
   493:         //====================
   494: /*
   495:         case WM_MOUSEACTIVATE:
   496:         {
   497:             return MA_NOACTIVATE;
   498:         }
   499:         
   500:         case WM_ACTIVATE:
   501:         {
   502:             if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE) SetActiveWindow(hwnd);
   503:             return 0;
   504:         }
   505: */
   506:         //====================
   507: 
   508:         case WM_EXITSIZEMOVE:
   509:         {
   510:             if (pToolbar->ToolbarPosInProgress)
   511:             {
   512:                 pToolbar->ToolbarPosInProgress = false;
   513: 
   514:                 RECT r;
   515:                 GetWindowRect(pToolbar->hToolbarWnd, &r);
   516:                 pSettings->ToolbarPlacement.placement = PLACEMENT_MANUAL;
   517:                 pSettings->ToolbarPlacement.rcx = pToolbar->ToolbarX = r.left;
   518:                 pSettings->ToolbarPlacement.rcy = pToolbar->ToolbarY = r.top;
   519: 
   520: //              pToolbar->UpdatePosition();
   521:                 pToolbar->UpdateToolbarWindow();
   522: 
   523:                 KillTimer(pToolbar->hToolbarWnd, TOOLBAR_SAVE_WIDTH_TIMER);
   524:                 pToolbar->saveWidthAfterDelay = true;
   525:                 SetTimer(pToolbar->hToolbarWnd, TOOLBAR_SAVE_WIDTH_TIMER, 1000, (TIMERPROC)NULL);
   526:             }
   527: 
   528:             return 0;
   529:         }
   530: 
   531:         //====================
   532: 
   533:         // Allow window to move if control key is being held down,
   534:         // holding down the shift key and left clicking moves the window
   535:         // back to the default position...
   536:         case WM_NCHITTEST:
   537:         {
   538:             if ((GetAsyncKeyState(VK_CONTROL) & 0x8000))
   539:             {
   540:                 POINT pt;
   541:                 pt.x = GET_X_LPARAM(lParam);
   542:                 pt.y = GET_Y_LPARAM(lParam);
   543:                 ScreenToClient(hwnd, &pt);
   544: 
   545:                 if ((pSettings->taskbarMode != TASKBAR_MODE_HIDDEN) && PtInRect(&pToolbar->winlabelRect, pt)) return HTCLIENT;
   546:                 else
   547:                 {
   548:                     pToolbar->ToolbarPosInProgress = true;
   549:                     return HTCAPTION;
   550:                 }
   551:             }
   552: 
   553:             return HTCLIENT;
   554:         }
   555: 
   556:         //====================
   557: 
   558:         case WM_LBUTTONDOWN:
   559:         case WM_LBUTTONUP:
   560:         case WM_LBUTTONDBLCLK:
   561:         case WM_RBUTTONDOWN:
   562:         case WM_RBUTTONUP:
   563:         case WM_MBUTTONDOWN:
   564:         case WM_MBUTTONUP:
   565:         case WM_XBUTTONDOWN:
   566:         case WM_XBUTTONUP:
   567:         {
   568:             if (pSettings->taskbarMode != TASKBAR_MODE_HIDDEN)
   569:             {
   570:                 if (pTaskbar->MouseButtonOnTaskbar(hwnd, message, wParam, lParam))
   571:                 {
   572:                     return DefWindowProc(hwnd, message, wParam, lParam);
   573:                 }
   574:             }
   575: 
   576:             //====================
   577: 
   578:             POINT pt = { LOWORD(lParam), HIWORD(lParam) };
   579: 
   580:             //====================
   581: 
   582:             // Check if any of the toolbar buttons (up/down/left/right) have been clicked...
   583:             if (message == WM_LBUTTONDOWN)
   584:             {
   585:                 TRACKMOUSEEVENT track;
   586:                 ZeroMemory(&track,sizeof(track));
   587:                 track.cbSize = sizeof(track);
   588:                 track.dwFlags = TME_LEAVE;
   589:                 track.dwHoverTime = HOVER_DEFAULT;
   590:                 track.hwndTrack = pToolbar->hToolbarWnd;
   591:                 _TrackMouseEvent(&track);
   592: 
   593:                 if (!pSettings->toolbarDownUpButtonsHidden && (pSettings->numberOfWorkspaces > 1))
   594:                 {
   595:                     if (PtInRect(&pToolbar->button1Rect, pt))
   596:                     {
   597:                         pToolbar->ButtonPressed1 = true;
   598:                         // InvalidateRect(pToolbar->hToolbarWnd, &pToolbar->button1Rect, false);
   599:                         pToolbar->UpdateToolbarWindow();
   600:                     }
   601:                     else if (PtInRect(&pToolbar->button2Rect, pt))
   602:                     {
   603:                         pToolbar->ButtonPressed2 = true;
   604:                         // InvalidateRect(pToolbar->hToolbarWnd, &pToolbar->button2Rect, false);
   605:                         pToolbar->UpdateToolbarWindow();
   606:                     }
   607:                 }
   608: 
   609:                 if (!pSettings->toolbarLeftRightButtonsHidden)
   610:                 {
   611:                     if (PtInRect(&pToolbar->button3Rect, pt))
   612:                     {
   613:                         pToolbar->ButtonPressed3 = true;
   614:                         // InvalidateRect(pToolbar->hToolbarWnd, &pToolbar->button3Rect, false);
   615:                         pToolbar->UpdateToolbarWindow();
   616:                     }
   617:                     else if (PtInRect(&pToolbar->button4Rect, pt))
   618:                     {
   619:                         pToolbar->ButtonPressed4 = true;
   620:                         // InvalidateRect(pToolbar->hToolbarWnd, &pToolbar->button4Rect, false);
   621:                         pToolbar->UpdateToolbarWindow();
   622:                     }
   623:                 }
   624: 
   625:                 if (pMenuCommon) pMenuCommon->Hide();
   626:             }
   627:             else if (message == WM_LBUTTONUP)
   628:             {
   629:                 if (pToolbar->ButtonPressed1) // Toolbar "down" button
   630:                 {
   631:                     if ((strnlen_s(pSettings->toolbarDownButtonOverride, sizeofArray(pSettings->toolbarDownButtonOverride)) > 0) && !(GetAsyncKeyState(VK_MENU) & 0x8000))
   632:                     {
   633:                         BBSmartExecute(pSettings->toolbarDownButtonOverride); // -> User configured override command for the "down" button
   634:                     }
   635:                     else SendMessage(pToolbar->hBlackboxWnd, BB_WORKSPACE, 0, 0); // -> Previous workspace ("DeskLeft")
   636:                 }
   637:                 else if (pToolbar->ButtonPressed2) // Toolbar "up" button
   638:                 {
   639:                     if ((strnlen_s(pSettings->toolbarUpButtonOverride, sizeofArray(pSettings->toolbarUpButtonOverride)) > 0) && !(GetAsyncKeyState(VK_MENU) & 0x8000))
   640:                     {
   641:                         BBSmartExecute(pSettings->toolbarUpButtonOverride); // -> User configured override command for the "up" button
   642:                     }
   643:                     else SendMessage(pToolbar->hBlackboxWnd, BB_WORKSPACE, 1, 0); // -> Next workspace ("DeskRight")
   644:                 }
   645:                 else if (pToolbar->ButtonPressed3) // Toolbar "left" button
   646:                 {
   647:                     if ((strnlen_s(pSettings->toolbarLeftButtonOverride, sizeofArray(pSettings->toolbarLeftButtonOverride)) > 0) && !(GetAsyncKeyState(VK_MENU) & 0x8000))
   648:                     {
   649:                         BBSmartExecute(pSettings->toolbarLeftButtonOverride); // -> User configured override command for the "left" button
   650:                     }
   651:                     else pToolbar->ToolbarModeButtonPressed(false); // -> Previous toolbar mode
   652:                 }
   653:                 else if (pToolbar->ButtonPressed4) // Toolbar "right" button
   654:                 {
   655:                     if ((strnlen_s(pSettings->toolbarRightButtonOverride, sizeofArray(pSettings->toolbarRightButtonOverride)) > 0) && !(GetAsyncKeyState(VK_MENU) & 0x8000))
   656:                     {
   657:                         BBSmartExecute(pSettings->toolbarRightButtonOverride); // -> User configured override command for the "right" button
   658:                     }
   659:                     else pToolbar->ToolbarModeButtonPressed(true); // -> Next toolbar mode
   660:                 }
   661: 
   662:                 pToolbar->ButtonPressed1 = pToolbar->ButtonPressed2 = pToolbar->ButtonPressed3 = pToolbar->ButtonPressed4 = false;
   663:                 pToolbar->UpdateToolbarWindow();
   664:             }
   665: 
   666:             //====================
   667: 
   668:             // Check if the toolbar workspace label has been clicked...
   669:             else if (!pSettings->toolbarLabelHidden && (pSettings->numberOfWorkspaces > 1) && PtInRect(&pToolbar->labelRect, pt))
   670:             {
   671:                 switch (message)
   672:                 {
   673:                     case WM_LBUTTONDBLCLK:
   674:                     {
   675:                         if (strnlen_s(pSettings->toolbarLabelDLClickOverride, sizeofArray(pSettings->toolbarLabelDLClickOverride)) > 0) BBSmartExecute(pSettings->toolbarLabelDLClickOverride); // Run the command defined by the toolbar label DL mouse click override...
   676:                         else if (pSettings->underExplorer) BBExecute(GetDesktopWindow(), NULL, "ms-settings:", "", NULL, SW_SHOWNORMAL, false); // Open Windows Settings
   677:                         else BBExecute(GetDesktopWindow(), NULL, pSettings->preferredEditor, pSettings->xobrcDefaultFile, NULL, SW_SHOWNORMAL, false); // Edit current workspace names in xoblite.rc
   678:                         break;
   679:                     }
   680: 
   681:                     case WM_RBUTTONUP:
   682:                     {
   683:                         if (strnlen_s(pSettings->toolbarLabelRClickOverride, sizeofArray(pSettings->toolbarLabelRClickOverride)) > 0)
   684:                         {
   685:                             if (GetAsyncKeyState(VK_MENU) & 0x8000) SendMessage(GetBBWnd(), BB_MENU, 0, 0); // -> Main menu (i.e. an Alt+R click "fallback" from the configured override)
   686:                             else BBSmartExecute(pSettings->toolbarLabelRClickOverride);
   687:                         }
   688:                         else if (GetAsyncKeyState(VK_MENU) & 0x8000) SendMessage(GetBBWnd(), BB_MENU, 1, 0); // -> Workspaces menu
   689:                         else SendMessage(GetBBWnd(), BB_MENU, 0, 0); // -> Main menu
   690:                         break;
   691:                     }
   692: 
   693:                     case WM_MBUTTONUP:
   694:                     {
   695:                         if (strnlen_s(pSettings->toolbarLabelMClickOverride, sizeofArray(pSettings->toolbarLabelMClickOverride)) > 0)
   696:                         {
   697:                             BBSmartExecute(pSettings->toolbarLabelMClickOverride);
   698:                         }
   699:                         else if (GetAsyncKeyState(VK_MENU) & 0x8000) PostMessage(GetBBWnd(), BB_TOGGLEDOCK, 0, 0); // -> Toggle dock
   700:                         else if (GetAsyncKeyState(VK_SHIFT) & 0x8000) PostMessage(GetBBWnd(), BB_TOGGLEPLUGINS, 0, 0); // -> Toggle plugins
   701:                         else if (pSettings->taskbarMode != TASKBAR_MODE_HIDDEN) pToolbar->ToolbarModeButtonPressed(true); // -> Next toolbar mode
   702:                         break;
   703:                     }
   704: 
   705:                     case WM_XBUTTONUP:
   706:                     {
   707:                         if (HIWORD(wParam) == XBUTTON1)
   708:                         {
   709:                             if (strnlen_s(pSettings->toolbarLabelX1ClickOverride, sizeofArray(pSettings->toolbarLabelX1ClickOverride)) > 0)
   710:                             {
   711:                                 BBSmartExecute(pSettings->toolbarLabelX1ClickOverride);
   712:                             }
   713:                             else pToolbar->ToggleOrientation();
   714:                         }
   715:                         else if (HIWORD(wParam) == XBUTTON2)
   716:                         {
   717:                             if (strnlen_s(pSettings->toolbarLabelX2ClickOverride, sizeofArray(pSettings->toolbarLabelX2ClickOverride)) > 0)
   718:                             {
   719:                                 BBSmartExecute(pSettings->toolbarLabelX2ClickOverride);
   720:                             }
   721:                             else if (pSettings->toolbarVertical)
   722:                             {
   723:                                 if (pToolbar->toolbarVerticalPeeking) pToolbar->toolbarVerticalPeeking = false;
   724:                                 else pToolbar->toolbarVerticalPeeking = true;
   725:                                 pToolbar->UpdatePosition();
   726:                                 PlaySoundFX(SFX_TOGGLE_ELEMENT);
   727:                             }
   728:                         }
   729:                         break;
   730:                     }
   731: 
   732:                     default: { break; }
   733:                 }
   734:             }
   735: 
   736:             //====================
   737: 
   738:             // Check if the toolbar clock has been clicked...
   739:             else if (!pSettings->toolbarClockHidden && PtInRect(&pToolbar->clockRect, pt))
   740:             {
   741:                 switch (message)
   742:                 {
   743:                     case WM_LBUTTONDBLCLK:
   744:                     {
   745:                         if (GetAsyncKeyState(VK_SHIFT) & 0x8000) pToolbar->ToggleCalendar();
   746:                         else if (strnlen_s(pSettings->toolbarClockDLClickOverride, sizeofArray(pSettings->toolbarClockDLClickOverride)) > 0) BBSmartExecute(pSettings->toolbarClockDLClickOverride); // Run the command defined by the toolbar clock DL mouse click override...
   747: //                      else if (pSettings->underExplorer) BBExecute(GetDesktopWindow(), NULL, "ms-clock:", "", NULL, SW_SHOWNORMAL, false); // Open date/time properties
   748: //                      else if (pSettings->underExplorer) BBExecute(GetDesktopWindow(), NULL, "ms-settings:dateandtime", "", NULL, SW_SHOWNORMAL, false); // Open date/time properties
   749:                         else if (pSettings->underExplorer) BBExecute(GetDesktopWindow(), NULL, "ms-actioncenter:", "", NULL, SW_SHOWNORMAL, false);
   750:                         else BBExecute(GetDesktopWindow(), NULL, "control.exe", "timedate.cpl", NULL, SW_SHOWNORMAL, false); // Open date/time properties
   751:                         break;
   752:                     }
   753: 
   754:                     case WM_RBUTTONUP:
   755:                     {
   756:                         if (strnlen_s(pSettings->toolbarClockRClickOverride, sizeofArray(pSettings->toolbarClockRClickOverride)) > 0)
   757:                         {
   758:                             if (GetAsyncKeyState(VK_MENU) & 0x8000) SendMessage(GetBBWnd(), BB_MENU, 2, 0); // -> Configuration menu (i.e. an Alt+R click "fallback" from the configured override)
   759:                             else BBSmartExecute(pSettings->toolbarClockRClickOverride);
   760:                         }
   761:                         else SendMessage(GetBBWnd(), BB_MENU, 2, 0); // -> Configuration menu
   762:                         break;
   763:                     }
   764: 
   765:                     case WM_MBUTTONUP:
   766:                     {
   767:                         if (strnlen_s(pSettings->toolbarClockMClickOverride, sizeofArray(pSettings->toolbarClockMClickOverride)) > 0)
   768:                         {
   769:                             BBSmartExecute(pSettings->toolbarClockMClickOverride);
   770:                         }
   771:                         else if (GetAsyncKeyState(VK_MENU) & 0x8000) PostMessage(GetBBWnd(), BB_TOGGLEDOCK, 0, 0); // -> Toggle dock
   772:                         else if (GetAsyncKeyState(VK_SHIFT) & 0x8000) PostMessage(GetBBWnd(), BB_TOGGLEPLUGINS, 0, 0); // -> Toggle plugins
   773:                         else if (pSettings->taskbarMode != TASKBAR_MODE_HIDDEN) pToolbar->ToolbarModeButtonPressed(true); // -> Next toolbar mode
   774:                         break;
   775:                     }
   776: 
   777:                     case WM_XBUTTONUP:
   778:                     {
   779:                         if (HIWORD(wParam) == XBUTTON1)
   780:                         {
   781:                             if (strnlen_s(pSettings->toolbarClockX1ClickOverride, sizeofArray(pSettings->toolbarClockX1ClickOverride)) > 0)
   782:                             {
   783:                                 BBSmartExecute(pSettings->toolbarClockX1ClickOverride);
   784:                             }
   785:                             else pToolbar->ToggleOrientation();
   786:                         }
   787:                         else if (HIWORD(wParam) == XBUTTON2)
   788:                         {
   789:                             if (strnlen_s(pSettings->toolbarClockX2ClickOverride, sizeofArray(pSettings->toolbarClockX2ClickOverride)) > 0)
   790:                             {
   791:                                 BBSmartExecute(pSettings->toolbarClockX2ClickOverride);
   792:                             }
   793:                             else if (pSettings->toolbarVertical)
   794:                             {
   795:                                 if (pToolbar->toolbarVerticalPeeking) pToolbar->toolbarVerticalPeeking = false;
   796:                                 else pToolbar->toolbarVerticalPeeking = true;
   797:                                 pToolbar->UpdatePosition();
   798:                                 PlaySoundFX(SFX_TOGGLE_ELEMENT);
   799:                             }
   800:                         }
   801:                         break;
   802:                     }
   803: 
   804:                     default: { break; }
   805:                 }
   806:             }
   807: 
   808:             //====================
   809: /*
   810:             case WM_LBUTTONDBLCLK:
   811:             {
   812:                 if (GetAsyncKeyState(VK_MENU) & 0x8000)
   813:                 {
   814:                     if (pSettings->toolbarVertical)
   815:                     {
   816:                         if (pToolbar->toolbarVerticalPeeking) pToolbar->toolbarVerticalPeeking = false;
   817:                         else pToolbar->toolbarVerticalPeeking = true;
   818:                         pToolbar->UpdatePosition();
   819:                     }
   820:                 }
   821:                 else ...
   822: 
   823:                 break;
   824:             }
   825: 
   826:             //====================
   827: 
   828:             else if (message == WM_RBUTTONUP)
   829:             {
   830:                 if (GetAsyncKeyState(VK_MENU) & 0x8000) SendMessage(GetBBWnd(), BB_MENU, 0, 0); // -> Main menu
   831:                 else
   832:                 {
   833:                     POINT pt = {LOWORD(lParam), HIWORD(lParam)};
   834: //                  if (!pSettings->toolbarLabelHidden && (pSettings->numberOfWorkspaces > 1) && PtInRect(&pToolbar->labelRect, pt)) SendMessage(GetBBWnd(), BB_MENU, 1, 0); // -> Workspaces menu
   835: //                  else if (!pSettings->toolbarClockHidden && PtInRect(&pToolbar->clockRect, pt)) SendMessage(GetBBWnd(), BB_MENU, 2, 0); // -> Configuration menu
   836: //                  else SendMessage(GetBBWnd(), BB_MENU, 0, 0); // -> Main menu
   837:                     if (!pSettings->toolbarClockHidden && PtInRect(&pToolbar->clockRect, pt)) SendMessage(GetBBWnd(), BB_MENU, 2, 0); // -> Configuration menu
   838:                     else SendMessage(GetBBWnd(), BB_MENU, 0, 0); // -> Main menu
   839:                 }
   840:             }
   841: 
   842:             //====================
   843: 
   844:             else if (message == WM_MBUTTONUP)
   845:             {
   846:                 if (GetAsyncKeyState(VK_MENU) & 0x8000) PostMessage(GetBBWnd(), BB_TOGGLEDOCK, 0, 0); // -> Toggle dock
   847:                 else if (GetAsyncKeyState(VK_SHIFT) & 0x8000) PostMessage(GetBBWnd(), BB_TOGGLEPLUGINS, 0, 0); // -> Toggle plugins
   848:                 else
   849:                 {
   850:                     POINT pt = {LOWORD(lParam), HIWORD(lParam)};
   851:                     if ((pSettings->taskbarMode != TASKBAR_MODE_HIDDEN) || !PtInRect(&pToolbar->winlabelRect, pt)) pToolbar->ToolbarModeButtonPressed(true); // -> Next toolbar mode
   852:                 }
   853:             }
   854: 
   855:             //====================
   856: 
   857:             else if (message == WM_XBUTTONDOWN)
   858:             {
   859:                 if (HIWORD(wParam) == XBUTTON1)
   860:                 {
   861:                     if (GetAsyncKeyState(VK_MENU) & 0x8000)
   862:                     {
   863:                         if (pSettings->toolbarVertical)
   864:                         {
   865:                             if (pToolbar->toolbarVerticalPeeking) pToolbar->toolbarVerticalPeeking = false;
   866:                             else pToolbar->toolbarVerticalPeeking = true;
   867:                             pToolbar->UpdatePosition();
   868:                             PlaySoundFX(SFX_TOGGLE_ELEMENT);
   869:                         }
   870:                     }
   871: //                  else if (GetAsyncKeyState(VK_SHIFT) & 0x8000) BBExecute(GetDesktopWindow(), NULL, "control.exe", "desk.cpl,,3", NULL, SW_SHOWNORMAL, false);
   872:                     else pToolbar->ToggleOrientation();
   873:                 }
   874:                 else if (HIWORD(wParam) == XBUTTON2)
   875:                 {
   876:                     if (pSettings->toolbarVertical)
   877:                     {
   878:                         // Toggle toolbar peeking if already in vertical orientation...
   879:                         if (pToolbar->toolbarVerticalPeeking) pToolbar->toolbarVerticalPeeking = false;
   880:                         else pToolbar->toolbarVerticalPeeking = true;
   881:                     }
   882:                     else
   883:                     {
   884:                         // Change to vertical toolbar orientation and enable peeking directly...
   885:                         pSettings->toolbarVertical = true;
   886:                         pToolbar->toolbarVerticalPeeking = true;
   887: //                      WriteBool(pSettings->xobrcFile, "xoblite.toolbar.vertical:", pSettings->toolbarVertical);
   888:                     }
   889: 
   890:                     pToolbar->UpdatePosition();
   891:                     PlaySoundFX(SFX_TOGGLE_ELEMENT);
   892:                 }
   893:             }
   894: */
   895:             break;
   896:         }
   897: 
   898:         //====================
   899: 
   900:         case WM_MOUSEWHEEL: // -> Regular vertical mouse scroll wheel i.e. up/down movement
   901:         case WM_MOUSEHWHEEL: // -> Horizontal mouse scroll wheel (or more commonly, a touchpad) i.e. left/right movement
   902:         {
   903:             // Only allow mousewheel resizing when the control key is held down
   904:             // and the toolbar width is defined as a percentage of the screen size...
   905:             if ((message == WM_MOUSEWHEEL) && (GetAsyncKeyState(VK_CONTROL) & 0x8000))
   906:             {
   907:                 if (pSettings->toolbarVertical) // Toolbar in vertical orientation
   908:                 {
   909:                     if (pSettings->toolbarVerticalWidth > 100) return 0; // Toolbar width is defined in pixels (not supported for mousewheel resizing)
   910: 
   911:                     if (GET_WHEEL_DELTA_WPARAM(wParam) < 0)
   912:                     {
   913:                         if (pSettings->toolbarVerticalWidth > 5) // Minimum 5% of the (main) screen width
   914:                         {
   915:                             pSettings->toolbarVerticalWidth--;
   916:                             pToolbar->UpdateWidth();
   917:                         }
   918:                     }
   919:                     else if (GET_WHEEL_DELTA_WPARAM(wParam) > 0)
   920:                     {
   921:                         if (pSettings->toolbarVerticalWidth < 25) // Maximum 25% of the (main) screen width
   922:                         {
   923:                             pSettings->toolbarVerticalWidth++;
   924:                             pToolbar->UpdateWidth();
   925:                         }
   926:                     }
   927:                 }
   928:                 else // Toolbar in horizontal orientation
   929:                 {
   930:                     if (pSettings->toolbarHorizontalWidth > 100) return 0; // Toolbar width is defined in pixels (not supported for mousewheel resizing)
   931: 
   932:                     if (GET_WHEEL_DELTA_WPARAM(wParam) < 0)
   933:                     {
   934:                         if (pSettings->toolbarHorizontalWidth > 30) // Minimum 30% of the (main) screen width
   935:                         {
   936:                             pSettings->toolbarHorizontalWidth--;
   937:                             pToolbar->UpdateWidth();
   938:                         }
   939:                     }
   940:                     else if (GET_WHEEL_DELTA_WPARAM(wParam) > 0)
   941:                     {
   942:                         if (pSettings->toolbarHorizontalWidth < 100) // Maximum 100% of the (main) screen width
   943:                         {
   944:                             pSettings->toolbarHorizontalWidth++;
   945:                             pToolbar->UpdateWidth();
   946:                         }
   947:                     }
   948:                 }
   949:             }
   950: 
   951:             //====================
   952: 
   953:             // ...otherwise the mousewheel scrolls the visible span of taskbar items, if the total
   954:             // number of taskbar items is > than the configured maximum simultaneously visible...
   955:             else if (pSettings->taskbarMode != TASKBAR_MODE_HIDDEN)
   956:             {
   957:                 if (((message == WM_MOUSEWHEEL) && (GET_WHEEL_DELTA_WPARAM(wParam) < 0)) || ((message == WM_MOUSEHWHEEL) && (GET_WHEEL_DELTA_WPARAM(wParam) > 0)))
   958:                 {
   959:                     pTaskbar->taskButtonsOffset++;
   960:                     int firstButton = pTaskbar->FindFirstVisible();
   961:                     if (pTaskbar->FindLastVisible(firstButton) < 0) pTaskbar->taskButtonsOffset--; // Couldn't scroll further down/right...
   962:                     else pToolbar->UpdateToolbarWindow();
   963:                 }
   964:                 else if (pTaskbar->taskButtonsOffset > 0)
   965:                 {
   966:                     pTaskbar->taskButtonsOffset--;
   967:                     pToolbar->UpdateToolbarWindow();
   968:                 }
   969:             }
   970: 
   971:             return 0;
   972:         }
   973: 
   974:         //====================
   975: 
   976:         case WM_MOUSEMOVE:
   977:         {
   978:             pTaskbar->MouseHoveringOverTaskbar(hwnd, message, wParam, lParam);
   979:             return 0;
   980:         }
   981: 
   982:         //====================
   983: /*
   984:         case WM_MOUSEHOVER:
   985:         case WM_NCMOUSEHOVER:
   986:         {
   987:             return 0;
   988:         }
   989: */
   990:         //====================
   991: 
   992:         case WM_MOUSELEAVE:
   993:         case WM_NCMOUSELEAVE:
   994:         {
   995:             pToolbar->ButtonPressed1 = pToolbar->ButtonPressed2 = pToolbar->ButtonPressed3 = pToolbar->ButtonPressed4 = false;
   996:             pToolbar->UpdateToolbarWindow();
   997:             if (pPreviewItem)
   998:             {
   999:                 pPreviewItem->Hide();
  1000:                 if (pToolbar->thumbnail != NULL)
  1001:                 {
  1002:                     DwmUnregisterThumbnail(pToolbar->thumbnail);
  1003:                     pToolbar->thumbnail = NULL;
  1004:                 }
  1005:                 pTaskbar->lastHoveredTaskButton = -1;
  1006:             }
  1007:             break;
  1008:         }
  1009: 
  1010:         //====================
  1011: 
  1012:         // If moved, snap window to screen edges...
  1013:         case WM_WINDOWPOSCHANGING:
  1014:         {
  1015:             // Snap window to screen edges when in manual positioning mode?
  1016:             if ((pSettings->ToolbarPlacement.placement == PLACEMENT_MANUAL) && pSettings->toolbarSnapToEdges)
  1017:             {
  1018:                 if (pToolbar)
  1019:                 {
  1020:                     if (IsWindowVisible(hwnd)) SnapWindowToEdge((WINDOWPOS*)lParam, pSettings->edgeSnapThreshold, true);
  1021:                 }
  1022:             }
  1023:             return 0;
  1024:         }
  1025: 
  1026:         //====================
  1027: 
  1028:         default: { return DefWindowProc(hwnd, message, wParam, lParam); }
  1029: 
  1030:     //====================
  1031:     }
  1032:     return 0;
  1033: }
  1034: 
  1035: //===========================================================================
  1036: // Function: UpdateToolbarWindow
  1037: // Purpose: ...
  1038: //===========================================================================
  1039: 
  1040: void Toolbar::UpdateToolbarWindow()
  1041: {
  1042:     if (fullscreenDetected) return;
  1043: 
  1044:     // Fetch the new size and position parameters for the toolbar window...
  1045: //  GetDimensions();
  1046: 
  1047: //  if (pSettings->debugLogging) SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"Toolbar -> UpdateToolbarWindow()");
  1048: 
  1049:     RECT r;
  1050:     SetRect(&r, 0, 0, ToolbarWidth, ToolbarHeight);
  1051: 
  1052:     HDC hdc = GetWindowDC(hToolbarWnd);
  1053:     HBITMAP bufbmp = CreateCompatibleBitmap(hdc, r.right - r.left, r.bottom - r.top);
  1054:     DeleteObject(SelectObject(cachedBackground, bufbmp));
  1055:     ReleaseDC(hToolbarWnd, hdc);
  1056: 
  1057:     //====================
  1058: 
  1059:     // Draw toolbar background...
  1060:     SetRect(&r, 0, 0, ToolbarWidth, ToolbarHeight);
  1061:     if (pSettings->Toolbar->type == B_IMAGEFROMFILE) DrawImageIntoRect(cachedBackground, r, pSettings->Toolbar, false, true);
  1062:     else MakeGradientSuper(cachedBackground, r, pSettings->Toolbar->type, pSettings->Toolbar->Color1, pSettings->Toolbar->Color2, pSettings->Toolbar->Color3, pSettings->Toolbar->Color4, pSettings->Toolbar->Color5, pSettings->Toolbar->Color6, pSettings->Toolbar->Color7, pSettings->Toolbar->Color8, pSettings->Toolbar->interlaced, pSettings->Toolbar->bevelstyle, pSettings->Toolbar->bevelposition, pSettings->bevelWidth, pSettings->Toolbar->borderColor, pSettings->Toolbar->borderWidth);
  1063: 
  1064:     if (!pSettings->ToolbarBorder->parentRelative && (pSettings->Toolbar->borderWidth > 0))
  1065:     {
  1066:         CreateBorderSuper(cachedBackground, r, pSettings->ToolbarBorder->type, pSettings->ToolbarBorder->Color1, pSettings->ToolbarBorder->Color2, pSettings->ToolbarBorder->Color3, pSettings->ToolbarBorder->Color4, pSettings->ToolbarBorder->Color5, pSettings->ToolbarBorder->Color6, pSettings->ToolbarBorder->Color7, pSettings->ToolbarBorder->Color8, pSettings->Toolbar->borderWidth);
  1067:     }
  1068: 
  1069:     //====================
  1070: 
  1071:     // Should any toolbar corners be rounded off? If so, we need to perform some pixel re-shuffling
  1072:     // *before* any subsequent per pixel alpha operations... (because these in turn affect pixel data)
  1073:     int corners = 0;
  1074:     if (pSettings->toolbarRoundedCorners)
  1075:     {
  1076:         switch (pSettings->ToolbarPlacement.placement)
  1077:         {
  1078:             case PLACEMENT_TOP_LEFT: { corners = CORNER_BOTTOMRIGHT; break; }
  1079:             case PLACEMENT_CENTER_LEFT: { corners = CORNER_TOPRIGHT | CORNER_BOTTOMRIGHT; break; }
  1080:             case PLACEMENT_BOTTOM_LEFT: { corners = CORNER_TOPRIGHT; break; }
  1081:             case PLACEMENT_TOP_CENTER: { corners = CORNER_BOTTOMLEFT | CORNER_BOTTOMRIGHT; break; }
  1082:             case PLACEMENT_BOTTOM_CENTER: { corners = CORNER_TOPLEFT | CORNER_TOPRIGHT; break; }
  1083:             case PLACEMENT_TOP_RIGHT: { corners = CORNER_BOTTOMLEFT; break; }
  1084:             case PLACEMENT_CENTER_RIGHT: { corners = CORNER_TOPLEFT | CORNER_BOTTOMLEFT; break; }
  1085:             case PLACEMENT_BOTTOM_RIGHT: { corners = CORNER_TOPLEFT; break; }
  1086:             default: { corners = CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | CORNER_BOTTOMRIGHT; break; }
  1087:         }
  1088: 
  1089:         PrepareCorner(cachedBackground, r, corners, pSettings->Toolbar->bevelstyle, pSettings->Toolbar->bevelposition, 1, pSettings->Toolbar->borderWidth);
  1090:     }
  1091: 
  1092:     //====================
  1093: 
  1094:     if (!pSettings->toolbarLabelHidden && !pSettings->ToolbarLabel->parentRelative && (pSettings->numberOfWorkspaces > 1))
  1095:     {
  1096:         // Paint workspace label background...
  1097:         if (pSettings->ToolbarLabel->type == B_IMAGEFROMFILE) DrawImageIntoRect(cachedBackground, labelRect, pSettings->ToolbarLabel, false, true);
  1098:         else MakeGradientSuper(cachedBackground, labelRect, pSettings->ToolbarLabel->type, pSettings->ToolbarLabel->Color1, pSettings->ToolbarLabel->Color2, pSettings->ToolbarLabel->Color3, pSettings->ToolbarLabel->Color4, pSettings->ToolbarLabel->Color5, pSettings->ToolbarLabel->Color6, pSettings->ToolbarLabel->Color7, pSettings->ToolbarLabel->Color8, pSettings->ToolbarLabel->interlaced, pSettings->ToolbarLabel->bevelstyle, pSettings->ToolbarLabel->bevelposition, pSettings->bevelWidth, pSettings->ToolbarLabel->borderColor, pSettings->ToolbarLabel->borderWidth);
  1099:     }
  1100: 
  1101:     if (!pSettings->toolbarClockHidden && !pSettings->ToolbarClock->parentRelative)
  1102:     {
  1103:         // Paint clock background...
  1104:         if (pSettings->ToolbarClock->type == B_IMAGEFROMFILE) DrawImageIntoRect(cachedBackground, clockRect, pSettings->ToolbarClock, false, true);
  1105:         else MakeGradientSuper(cachedBackground, clockRect, pSettings->ToolbarClock->type, pSettings->ToolbarClock->Color1, pSettings->ToolbarClock->Color2, pSettings->ToolbarClock->Color3, pSettings->ToolbarClock->Color4, pSettings->ToolbarClock->Color5, pSettings->ToolbarClock->Color6, pSettings->ToolbarClock->Color7, pSettings->ToolbarClock->Color8, pSettings->ToolbarClock->interlaced, pSettings->ToolbarClock->bevelstyle, pSettings->ToolbarClock->bevelposition, pSettings->bevelWidth, pSettings->ToolbarClock->borderColor, pSettings->ToolbarClock->borderWidth);
  1106:     }
  1107: 
  1108:     //====================
  1109: 
  1110: //  HBITMAP tempBitmap, oldBitmap;
  1111: 
  1112: /*
  1113:     // If we have not yet created cached bitmaps, let's do that...
  1114:     if (!cachedBitmapsExist)
  1115:     {
  1116:         HBITMAP tempBitmap, oldBitmap;
  1117: 
  1118:         // Create a temporary bitmap...
  1119:         tempBitmap = CreateCompatibleBitmap(hdc, ToolbarWidth, ToolbarHeight);
  1120:         // Delete the previously cached gradient...
  1121:         oldBitmap = (HBITMAP)SelectObject(cachedBackground, tempBitmap);
  1122:         DeleteObject(oldBitmap);
  1123:         // Paint background + border... (now using MakeGradient instead of CreateBorder + DrawGradient)
  1124:         GetClientRect(hToolbarWnd, &r);
  1125:         //              MakeGradient(cachedBackground, r, pSettings->Toolbar->type, pSettings->Toolbar->Color, pSettings->Toolbar->ColorTo, pSettings->Toolbar->interlaced, pSettings->Toolbar->bevelstyle, pSettings->Toolbar->bevelposition, pSettings->bevelWidth, pSettings->Toolbar->borderColor, pSettings->Toolbar->borderWidth);
  1126:         MakeGradientEx(cachedBackground, r, pSettings->Toolbar->type, pSettings->Toolbar->Color, pSettings->Toolbar->ColorTo, pSettings->Toolbar->Color3, pSettings->Toolbar->Color4, pSettings->Toolbar->interlaced, pSettings->Toolbar->bevelstyle, pSettings->Toolbar->bevelposition, pSettings->bevelWidth, pSettings->Toolbar->borderColor, pSettings->Toolbar->borderWidth);
  1127: 
  1128:         //====================
  1129: 
  1130:         if (!pSettings->ToolbarLabel->parentRelative && pSettings->numberOfWorkspaces > 1)
  1131:         {
  1132:             // Paint workspaces background...
  1133: //                  MakeGradient(cachedBackground, labelRect, pSettings->ToolbarLabel->type, pSettings->ToolbarLabel->Color, pSettings->ToolbarLabel->ColorTo, pSettings->ToolbarLabel->interlaced, pSettings->ToolbarLabel->bevelstyle, pSettings->ToolbarLabel->bevelposition, pSettings->bevelWidth, pSettings->ToolbarLabel->borderColor, pSettings->ToolbarLabel->borderWidth);
  1134:             MakeGradientEx(cachedBackground, labelRect, pSettings->ToolbarLabel->type, pSettings->ToolbarLabel->Color, pSettings->ToolbarLabel->ColorTo, pSettings->ToolbarLabel->Color3, pSettings->ToolbarLabel->Color4, pSettings->ToolbarLabel->interlaced, pSettings->ToolbarLabel->bevelstyle, pSettings->ToolbarLabel->bevelposition, pSettings->bevelWidth, pSettings->ToolbarLabel->borderColor, pSettings->ToolbarLabel->borderWidth);
  1135:         }
  1136: 
  1137:         //====================
  1138: 
  1139:         if (!pSettings->ToolbarClock->parentRelative)
  1140:         {
  1141:             // Paint clock background...
  1142: //                  MakeGradient(cachedBackground, clockRect, pSettings->ToolbarClock->type, pSettings->ToolbarClock->Color, pSettings->ToolbarClock->ColorTo, pSettings->ToolbarClock->interlaced, pSettings->ToolbarClock->bevelstyle, pSettings->ToolbarClock->bevelposition, pSettings->bevelWidth, pSettings->ToolbarClock->borderColor, pSettings->ToolbarClock->borderWidth);
  1143:             MakeGradientEx(cachedBackground, clockRect, pSettings->ToolbarClock->type, pSettings->ToolbarClock->Color, pSettings->ToolbarClock->ColorTo, pSettings->ToolbarClock->Color3, pSettings->ToolbarClock->Color4, pSettings->ToolbarClock->interlaced, pSettings->ToolbarClock->bevelstyle, pSettings->ToolbarClock->bevelposition, pSettings->bevelWidth, pSettings->ToolbarClock->borderColor, pSettings->ToolbarClock->borderWidth);
  1144:         }
  1145: 
  1146:         //====================
  1147: 
  1148:         // Clean up - delete the temporary bitmap...
  1149:         DeleteObject(tempBitmap);
  1150: */
  1151:         //====================
  1152: /*
  1153:         if (!pSettings->ToolbarButton->parentRelative)
  1154:         {
  1155:             // Create a temporary bitmap...
  1156:             tempBitmap = CreateCompatibleBitmap(hdc, tbButtonWH, tbButtonWH);
  1157:             // Delete the previously cached gradient...
  1158:             oldBitmap = (HBITMAP)SelectObject(cachedToolbarButton, tempBitmap);
  1159:             DeleteObject(oldBitmap);
  1160:             // Paint button background...
  1161:             r.left = 0; r.top = 0;  r.right = tbButtonWH; r.bottom = tbButtonWH;
  1162:             //                  MakeGradient(cachedToolbarButton, r, pSettings->ToolbarButton->type, pSettings->ToolbarButton->Color, pSettings->ToolbarButton->ColorTo, pSettings->ToolbarButton->interlaced, pSettings->ToolbarButton->bevelstyle, pSettings->ToolbarButton->bevelposition, pSettings->bevelWidth, pSettings->ToolbarButton->borderColor, pSettings->ToolbarButton->borderWidth);
  1163:             MakeGradientEx(cachedToolbarButton, r, pSettings->ToolbarButton->type, pSettings->ToolbarButton->Color, pSettings->ToolbarButton->ColorTo, pSettings->ToolbarButton->Color3, pSettings->ToolbarButton->Color4, pSettings->ToolbarButton->interlaced, pSettings->ToolbarButton->bevelstyle, pSettings->ToolbarButton->bevelposition, pSettings->bevelWidth, pSettings->ToolbarButton->borderColor, pSettings->ToolbarButton->borderWidth);
  1164:             // Clean up - delete the temporary bitmap...
  1165:             DeleteObject(tempBitmap);
  1166:         }
  1167: */
  1168:         //====================
  1169: 
  1170:         if (!pSettings->ToolbarButton->parentRelative)
  1171:         {
  1172:             // Paint unpressed workspace/task buttons...
  1173:             if (!pSettings->toolbarDownUpButtonsHidden && (pSettings->numberOfWorkspaces > 1))
  1174:             {
  1175: ////            BitBlt(cachedBackground, button1Rect.left, button1Rect.top, tbButtonWH, tbButtonWH, cachedToolbarButton, 0, 0, SRCCOPY);
  1176: ////            BitBlt(cachedBackground, button2Rect.left, button2Rect.top, tbButtonWH, tbButtonWH, cachedToolbarButton, 0, 0, SRCCOPY);
  1177:                 if (!ButtonPressed1)
  1178:                 {
  1179:                     if (pSettings->ToolbarButton->type == B_IMAGEFROMFILE) DrawImageIntoRect(cachedBackground, button1Rect, pSettings->ToolbarButton, true, true);
  1180:                     else MakeGradientSuper(cachedBackground, button1Rect, pSettings->ToolbarButton->type, pSettings->ToolbarButton->Color1, pSettings->ToolbarButton->Color2, pSettings->ToolbarButton->Color3, pSettings->ToolbarButton->Color4, pSettings->ToolbarButton->Color5, pSettings->ToolbarButton->Color6, pSettings->ToolbarButton->Color7, pSettings->ToolbarButton->Color8, pSettings->ToolbarButton->interlaced, pSettings->ToolbarButton->bevelstyle, pSettings->ToolbarButton->bevelposition, pSettings->bevelWidth, pSettings->ToolbarButton->borderColor, pSettings->ToolbarButton->borderWidth);
  1181:                 }
  1182:                 if (!ButtonPressed2)
  1183:                 {
  1184:                     if (pSettings->ToolbarButton->type == B_IMAGEFROMFILE) DrawImageIntoRect(cachedBackground, button2Rect, pSettings->ToolbarButton, true, true);
  1185:                     else MakeGradientSuper(cachedBackground, button2Rect, pSettings->ToolbarButton->type, pSettings->ToolbarButton->Color1, pSettings->ToolbarButton->Color2, pSettings->ToolbarButton->Color3, pSettings->ToolbarButton->Color4, pSettings->ToolbarButton->Color5, pSettings->ToolbarButton->Color6, pSettings->ToolbarButton->Color7, pSettings->ToolbarButton->Color8, pSettings->ToolbarButton->interlaced, pSettings->ToolbarButton->bevelstyle, pSettings->ToolbarButton->bevelposition, pSettings->bevelWidth, pSettings->ToolbarButton->borderColor, pSettings->ToolbarButton->borderWidth);
  1186:                 }
  1187:             }
  1188: 
  1189:             if (!pSettings->toolbarLeftRightButtonsHidden)
  1190:             {
  1191: ////            BitBlt(cachedBackground, button3Rect.left, button3Rect.top, tbButtonWH, tbButtonWH, cachedToolbarButton, 0, 0, SRCCOPY);
  1192: ////            BitBlt(cachedBackground, button4Rect.left, button4Rect.top, tbButtonWH, tbButtonWH, cachedToolbarButton, 0, 0, SRCCOPY);
  1193:                 if (!ButtonPressed3)
  1194:                 {
  1195:                     if (pSettings->ToolbarButton->type == B_IMAGEFROMFILE) DrawImageIntoRect(cachedBackground, button3Rect, pSettings->ToolbarButton, true, true);
  1196:                     else MakeGradientSuper(cachedBackground, button3Rect, pSettings->ToolbarButton->type, pSettings->ToolbarButton->Color1, pSettings->ToolbarButton->Color2, pSettings->ToolbarButton->Color3, pSettings->ToolbarButton->Color4, pSettings->ToolbarButton->Color5, pSettings->ToolbarButton->Color6, pSettings->ToolbarButton->Color7, pSettings->ToolbarButton->Color8, pSettings->ToolbarButton->interlaced, pSettings->ToolbarButton->bevelstyle, pSettings->ToolbarButton->bevelposition, pSettings->bevelWidth, pSettings->ToolbarButton->borderColor, pSettings->ToolbarButton->borderWidth);
  1197:                 }
  1198:                 if (!ButtonPressed4)
  1199:                 {
  1200:                     if (pSettings->ToolbarButton->type == B_IMAGEFROMFILE) DrawImageIntoRect(cachedBackground, button4Rect, pSettings->ToolbarButton, true, true);
  1201:                     else MakeGradientSuper(cachedBackground, button4Rect, pSettings->ToolbarButton->type, pSettings->ToolbarButton->Color1, pSettings->ToolbarButton->Color2, pSettings->ToolbarButton->Color3, pSettings->ToolbarButton->Color4, pSettings->ToolbarButton->Color5, pSettings->ToolbarButton->Color6, pSettings->ToolbarButton->Color7, pSettings->ToolbarButton->Color8, pSettings->ToolbarButton->interlaced, pSettings->ToolbarButton->bevelstyle, pSettings->ToolbarButton->bevelposition, pSettings->bevelWidth, pSettings->ToolbarButton->borderColor, pSettings->ToolbarButton->borderWidth);
  1202:                 }
  1203:             }
  1204:         }
  1205: 
  1206:         //====================
  1207: /*
  1208:         // Set the "cached bitmaps created" indicator...
  1209:         cachedBitmapsExist = true;
  1210:     }
  1211: */
  1212:     //====================
  1213: 
  1214:     // Copy the cached bitmap into the temporary buffer...
  1215: //  BitBlt(buf, ps.rcPaint.left, ps.rcPaint.top, updateRectWidth, updateRectHeight, cachedBackground, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY);
  1216: 
  1217:     //====================
  1218: 
  1219:     // Paint windowlabel background+text or taskbar buttons?
  1220:     if (pSettings->taskbarMode != TASKBAR_MODE_HIDDEN) pTaskbar->DrawTaskbar(cachedBackground, 0, winlabelRect);
  1221:     else DrawWindowLabel(cachedBackground, winlabelRect, false); // TOOLBAR_MODE_WINDOWLABEL
  1222: 
  1223:     //====================
  1224: /*
  1225:     if (!pSettings->ToolbarButtonPressed->parentRelative && (ButtonPressed1 || ButtonPressed2 || ButtonPressed3 || ButtonPressed4))
  1226:     {
  1227:         // Paint pressed workspace/task buttons...
  1228:         // (not cached since they are not normally visible)
  1229:         HDC src = CreateCompatibleDC(NULL);
  1230:         HBITMAP srcbmp = CreateCompatibleBitmap(hdc, tbButtonWH, tbButtonWH);
  1231:         HBITMAP oldsrc = (HBITMAP)SelectObject(src, srcbmp);
  1232: 
  1233:         r.left = 0; r.top = 0;  r.right = tbButtonWH; r.bottom = tbButtonWH;
  1234:         // MakeGradient(src, r, pSettings->ToolbarButtonPressed->type, pSettings->ToolbarButtonPressed->Color, pSettings->ToolbarButtonPressed->ColorTo, pSettings->ToolbarButtonPressed->interlaced, pSettings->ToolbarButtonPressed->bevelstyle, pSettings->ToolbarButtonPressed->bevelposition, pSettings->bevelWidth, pSettings->ToolbarButtonPressed->borderColor, pSettings->ToolbarButtonPressed->borderWidth);
  1235:         MakeGradientEx(src, r, pSettings->ToolbarButtonPressed->type, pSettings->ToolbarButtonPressed->Color, pSettings->ToolbarButtonPressed->ColorTo, pSettings->ToolbarButtonPressed->Color3, pSettings->ToolbarButtonPressed->Color4, pSettings->ToolbarButtonPressed->interlaced, pSettings->ToolbarButtonPressed->bevelstyle, pSettings->ToolbarButtonPressed->bevelposition, pSettings->bevelWidth, pSettings->ToolbarButtonPressed->borderColor, pSettings->ToolbarButtonPressed->borderWidth);
  1236: 
  1237:         if (!pSettings->toolbarDownUpButtonsHidden && (pSettings->numberOfWorkspaces > 1))
  1238:         {
  1239:             if (ButtonPressed1) BitBlt(cachedBackground, button1Rect.left, button1Rect.top, tbButtonWH, tbButtonWH, src, 0, 0, SRCCOPY);
  1240:             if (ButtonPressed2) BitBlt(cachedBackground, button2Rect.left, button2Rect.top, tbButtonWH, tbButtonWH, src, 0, 0, SRCCOPY);
  1241:         }
  1242: 
  1243:         if (!pSettings->toolbarLeftRightButtonsHidden)
  1244:         {
  1245:             if (ButtonPressed3) BitBlt(cachedBackground, button3Rect.left, button3Rect.top, tbButtonWH, tbButtonWH, src, 0, 0, SRCCOPY);
  1246:             if (ButtonPressed4) BitBlt(cachedBackground, button4Rect.left, button4Rect.top, tbButtonWH, tbButtonWH, src, 0, 0, SRCCOPY);
  1247:         }
  1248: 
  1249:         SelectObject(src, oldsrc);
  1250:         DeleteDC(src);
  1251:         DeleteObject(srcbmp);
  1252:         DeleteObject(oldsrc);
  1253:     }
  1254: */
  1255:     if (!pSettings->ToolbarButtonPressed->parentRelative)
  1256:     {
  1257:         if (!pSettings->toolbarDownUpButtonsHidden && (pSettings->numberOfWorkspaces > 1))
  1258:         {
  1259:             if (ButtonPressed1)
  1260:             {
  1261:                 if (pSettings->ToolbarButtonPressed->type == B_IMAGEFROMFILE) DrawImageIntoRect(cachedBackground, button1Rect, pSettings->ToolbarButtonPressed, true, true);
  1262:                 else MakeGradientSuper(cachedBackground, button1Rect, pSettings->ToolbarButtonPressed->type, pSettings->ToolbarButtonPressed->Color1, pSettings->ToolbarButtonPressed->Color2, pSettings->ToolbarButtonPressed->Color3, pSettings->ToolbarButtonPressed->Color4, pSettings->ToolbarButtonPressed->Color5, pSettings->ToolbarButtonPressed->Color6, pSettings->ToolbarButtonPressed->Color7, pSettings->ToolbarButtonPressed->Color8, pSettings->ToolbarButtonPressed->interlaced, pSettings->ToolbarButtonPressed->bevelstyle, pSettings->ToolbarButtonPressed->bevelposition, pSettings->bevelWidth, pSettings->ToolbarButtonPressed->borderColor, pSettings->ToolbarButtonPressed->borderWidth);
  1263:             }
  1264:             if (ButtonPressed2)
  1265:             {
  1266:                 if (pSettings->ToolbarButtonPressed->type == B_IMAGEFROMFILE) DrawImageIntoRect(cachedBackground, button2Rect, pSettings->ToolbarButtonPressed, true, true);
  1267:                 else MakeGradientSuper(cachedBackground, button2Rect, pSettings->ToolbarButtonPressed->type, pSettings->ToolbarButtonPressed->Color1, pSettings->ToolbarButtonPressed->Color2, pSettings->ToolbarButtonPressed->Color3, pSettings->ToolbarButtonPressed->Color4, pSettings->ToolbarButtonPressed->Color5, pSettings->ToolbarButtonPressed->Color6, pSettings->ToolbarButtonPressed->Color7, pSettings->ToolbarButtonPressed->Color8, pSettings->ToolbarButtonPressed->interlaced, pSettings->ToolbarButtonPressed->bevelstyle, pSettings->ToolbarButtonPressed->bevelposition, pSettings->bevelWidth, pSettings->ToolbarButtonPressed->borderColor, pSettings->ToolbarButtonPressed->borderWidth);
  1268:             }
  1269:         }
  1270: 
  1271:         if (!pSettings->toolbarLeftRightButtonsHidden)
  1272:         {
  1273:             if (ButtonPressed3)
  1274:             {
  1275:                 if (pSettings->ToolbarButtonPressed->type == B_IMAGEFROMFILE) DrawImageIntoRect(cachedBackground, button3Rect, pSettings->ToolbarButtonPressed, true, true);
  1276:                 else MakeGradientSuper(cachedBackground, button3Rect, pSettings->ToolbarButtonPressed->type, pSettings->ToolbarButtonPressed->Color1, pSettings->ToolbarButtonPressed->Color2, pSettings->ToolbarButtonPressed->Color3, pSettings->ToolbarButtonPressed->Color4, pSettings->ToolbarButtonPressed->Color5, pSettings->ToolbarButtonPressed->Color6, pSettings->ToolbarButtonPressed->Color7, pSettings->ToolbarButtonPressed->Color8, pSettings->ToolbarButtonPressed->interlaced, pSettings->ToolbarButtonPressed->bevelstyle, pSettings->ToolbarButtonPressed->bevelposition, pSettings->bevelWidth, pSettings->ToolbarButtonPressed->borderColor, pSettings->ToolbarButtonPressed->borderWidth);
  1277:             }
  1278:             if (ButtonPressed4)
  1279:             {
  1280:                 if (pSettings->ToolbarButtonPressed->type == B_IMAGEFROMFILE) DrawImageIntoRect(cachedBackground, button4Rect, pSettings->ToolbarButtonPressed, true, true);
  1281:                 else MakeGradientSuper(cachedBackground, button4Rect, pSettings->ToolbarButtonPressed->type, pSettings->ToolbarButtonPressed->Color1, pSettings->ToolbarButtonPressed->Color2, pSettings->ToolbarButtonPressed->Color3, pSettings->ToolbarButtonPressed->Color4, pSettings->ToolbarButtonPressed->Color5, pSettings->ToolbarButtonPressed->Color6, pSettings->ToolbarButtonPressed->Color7, pSettings->ToolbarButtonPressed->Color8, pSettings->ToolbarButtonPressed->interlaced, pSettings->ToolbarButtonPressed->bevelstyle, pSettings->ToolbarButtonPressed->bevelposition, pSettings->bevelWidth, pSettings->ToolbarButtonPressed->borderColor, pSettings->ToolbarButtonPressed->borderWidth);
  1282:             }
  1283:         }
  1284:     }
  1285: 
  1286:     //====================
  1287: 
  1288:     unsigned int format;
  1289:     HFONT font;
  1290:     HGDIOBJ oldfont;
  1291: 
  1292:     if (!pSettings->toolbarLabelHidden && (pSettings->numberOfWorkspaces > 1))
  1293:     {
  1294:         // Draw workspace label...
  1295:         if (pWorkspaces) strcpy_s(ToolbarWorkspaceName, sizeofArray(ToolbarWorkspaceName), (LPSTR)pWorkspaces->workspaceNames[pSettings->currentWorkspace].c_str());
  1296:         font = CreateFont(pSettings->ToolbarLabel->FontHeight, 0, 0, 0, pSettings->ToolbarLabel->FontWeight, false, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, pSettings->ToolbarLabel->Font);
  1297:         oldfont = SelectObject(cachedBackground, font);
  1298:         SetBkMode(cachedBackground, TRANSPARENT);
  1299:         format = pSettings->ToolbarLabel->Justify | DT_VCENTER | DT_NOPREFIX | DT_SINGLELINE | DT_WORD_ELLIPSIS;
  1300:         CopyRect(&r, &labelRect);
  1301:         r.left = r.left + pSettings->ToolbarLabel->marginWidth + 2;
  1302:         r.right = r.right - pSettings->ToolbarLabel->marginWidth - 2;
  1303: 
  1304:         char ToolbarWorkspaceNameANSI[MAX_LINE_LENGTH];
  1305:         strcpy_s(ToolbarWorkspaceNameANSI, sizeofArray(ToolbarWorkspaceNameANSI), ToolbarWorkspaceName);
  1306:         strcat_s(ToolbarWorkspaceNameANSI, sizeofArray(ToolbarWorkspaceNameANSI), "\0"); // Just in case...
  1307:         wchar_t ToolbarWorkspaceNameUnicode[MAX_LINE_LENGTH];
  1308:         MultiByteToWideChar(CP_UTF8, 0, ToolbarWorkspaceNameANSI, strnlen_s(ToolbarWorkspaceNameANSI, sizeofArray(ToolbarWorkspaceNameANSI))+1, ToolbarWorkspaceNameUnicode, MAX_LINE_LENGTH);
  1309: 
  1310:         DrawTextWithEffectsUnicode(cachedBackground, r, ToolbarWorkspaceNameUnicode, format, pSettings->ToolbarLabel->TextColor, pSettings->ToolbarLabel->FontOutline, pSettings->ToolbarLabel->OutlineColor, pSettings->ToolbarLabel->FontShadow, pSettings->ToolbarLabel->ShadowColor, pSettings->ToolbarLabel->ShadowX, pSettings->ToolbarLabel->ShadowY);
  1311: 
  1312:         DeleteObject(SelectObject(cachedBackground, oldfont));
  1313:     }
  1314: 
  1315:     if (!pSettings->toolbarClockHidden)
  1316:     {
  1317:         // Draw clock...
  1318:         font = CreateFont(pSettings->ToolbarClock->FontHeight, 0, 0, 0, pSettings->ToolbarClock->FontWeight, false, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, pSettings->ToolbarClock->Font);
  1319:         oldfont = SelectObject(cachedBackground, font);
  1320:         SetBkMode(cachedBackground, TRANSPARENT);
  1321:         format = pSettings->ToolbarClock->Justify | DT_VCENTER | DT_NOPREFIX | DT_SINGLELINE | DT_WORD_ELLIPSIS;
  1322:         SetTextColor(cachedBackground, pSettings->ToolbarClock->TextColor);
  1323:         CopyRect(&r, &clockRect);
  1324:         r.left = r.left + pSettings->ToolbarClock->marginWidth + 2;
  1325:         r.right = r.right - pSettings->ToolbarClock->marginWidth - 2;
  1326: 
  1327:         DrawTextWithEffectsUnicode(cachedBackground, r, CurrentTime, format, pSettings->ToolbarClock->TextColor, pSettings->ToolbarClock->FontOutline, pSettings->ToolbarClock->OutlineColor, pSettings->ToolbarClock->FontShadow, pSettings->ToolbarClock->ShadowColor, pSettings->ToolbarClock->ShadowX, pSettings->ToolbarClock->ShadowY);
  1328: 
  1329:         DeleteObject(SelectObject(cachedBackground, oldfont));
  1330:     }
  1331: 
  1332:     //====================
  1333: 
  1334:     if (!pSettings->toolbarDownUpButtonsHidden || !pSettings->toolbarLeftRightButtonsHidden)
  1335:     {
  1336:         // Draw arrows on workspace/task buttons (nb. there is limited gain from
  1337:         // caching these since the button itself can be parentrelative)...
  1338:         HPEN activePen, inactivePen, oldPen;
  1339: 
  1340:         activePen = CreatePen(PS_SOLID, 1, pSettings->ToolbarButtonPressed->PicColor);
  1341:         inactivePen = CreatePen(PS_SOLID, 1, pSettings->ToolbarButton->PicColor);
  1342: 
  1343:         oldPen = (HPEN)SelectObject(cachedBackground, inactivePen);
  1344: 
  1345:         int xcenter;
  1346:         int xoffset = tbButtonWH / 2;
  1347:         int ycenter = button1Rect.top + tbButtonWH / 2;
  1348: 
  1349:         if (!pSettings->toolbarDownUpButtonsHidden && (pSettings->numberOfWorkspaces > 1))
  1350:         {
  1351:             xcenter = button1Rect.left + xoffset;
  1352:             if (ButtonPressed1) SelectObject(cachedBackground, activePen);
  1353:             DrawButtonGlyph(cachedBackground, TOOLBAR_BUTTON_GLYPH_DOWN, xcenter, ycenter);
  1354:             if (ButtonPressed1) SelectObject(cachedBackground, inactivePen);
  1355: 
  1356:             xcenter = button2Rect.left + xoffset;
  1357:             if (ButtonPressed2) SelectObject(cachedBackground, activePen);
  1358:             DrawButtonGlyph(cachedBackground, TOOLBAR_BUTTON_GLYPH_UP, xcenter, ycenter);
  1359:             if (ButtonPressed2) SelectObject(cachedBackground, inactivePen);
  1360:         }
  1361: 
  1362:         if (!pSettings->toolbarLeftRightButtonsHidden)
  1363:         {
  1364:             xcenter = button3Rect.left + xoffset;
  1365:             if (ButtonPressed3) SelectObject(cachedBackground, activePen);
  1366:             DrawButtonGlyph(cachedBackground, TOOLBAR_BUTTON_GLYPH_LEFT, xcenter, ycenter);
  1367:             if (ButtonPressed3) SelectObject(cachedBackground, inactivePen);
  1368: 
  1369:             xcenter = button4Rect.left + xoffset;
  1370:             if (ButtonPressed4) SelectObject(cachedBackground, activePen);
  1371:             DrawButtonGlyph(cachedBackground, TOOLBAR_BUTTON_GLYPH_RIGHT, xcenter, ycenter);
  1372:             if (ButtonPressed4) SelectObject(cachedBackground, inactivePen);
  1373:         }
  1374: 
  1375:         SelectObject(cachedBackground, oldPen);
  1376:         DeleteObject(inactivePen);
  1377:         DeleteObject(activePen);
  1378:     }
  1379: 
  1380:     //====================
  1381: 
  1382:     // Apply per pixel alpha, selectively per toolbar element... 8)
  1383:     SetRect(&r, 0, 0, ToolbarWidth, ToolbarHeight);
  1384:     AlphaRect(cachedBackground, r, pSettings->toolbarTransparencyAlpha);
  1385: 
  1386:     if (pSettings->numberOfWorkspaces > 1)
  1387:     {
  1388:         if (!pSettings->toolbarLabelHidden && (pSettings->toolbarLabelTransparencyAlpha != pSettings->toolbarTransparencyAlpha)) AlphaRect(cachedBackground, labelRect, pSettings->toolbarLabelTransparencyAlpha);
  1389: 
  1390:         if (!pSettings->toolbarDownUpButtonsHidden && !pSettings->ToolbarButton->parentRelative && (pSettings->toolbarButtonTransparencyAlpha != pSettings->toolbarTransparencyAlpha))
  1391:         {
  1392:             AlphaRect(cachedBackground, button1Rect, pSettings->toolbarButtonTransparencyAlpha);
  1393:             AlphaRect(cachedBackground, button2Rect, pSettings->toolbarButtonTransparencyAlpha);
  1394:         }
  1395:     }
  1396: 
  1397:     if (pSettings->taskbarMode == TASKBAR_MODE_HIDDEN) // -> Taskbar hidden, showing WindowLabel
  1398:     {
  1399:         if (pSettings->toolbarWindowLabelTransparencyAlpha != pSettings->toolbarTransparencyAlpha) AlphaRect(cachedBackground, winlabelRect, pSettings->toolbarWindowLabelTransparencyAlpha);
  1400:     }
  1401: 
  1402:     if (!pSettings->toolbarClockHidden && (pSettings->toolbarClockTransparencyAlpha != pSettings->toolbarTransparencyAlpha)) AlphaRect(cachedBackground, clockRect, pSettings->toolbarClockTransparencyAlpha);
  1403: 
  1404:     if (!pSettings->toolbarLeftRightButtonsHidden && !pSettings->ToolbarButton->parentRelative && (pSettings->toolbarButtonTransparencyAlpha != pSettings->toolbarTransparencyAlpha))
  1405:     {
  1406:         AlphaRect(cachedBackground, button3Rect, pSettings->toolbarButtonTransparencyAlpha);
  1407:         AlphaRect(cachedBackground, button4Rect, pSettings->toolbarButtonTransparencyAlpha);
  1408:     }
  1409: 
  1410:     if ((pSettings->taskbarMode != TASKBAR_MODE_HIDDEN) && pTaskbar->activeTaskAvailable) AlphaRect(cachedBackground, pTaskbar->ActiveTaskRect, pSettings->taskbarActiveTransparencyAlpha);
  1411: 
  1412:     if (pSettings->toolbarRoundedCorners)
  1413:     {
  1414:         int corners = 0;
  1415:         switch (pSettings->ToolbarPlacement.placement)
  1416:         {
  1417:             case PLACEMENT_TOP_LEFT: { corners = CORNER_BOTTOMRIGHT; break; }
  1418:             case PLACEMENT_CENTER_LEFT: { corners = CORNER_TOPRIGHT | CORNER_BOTTOMRIGHT; break; }
  1419:             case PLACEMENT_BOTTOM_LEFT: { corners = CORNER_TOPRIGHT; break; }
  1420:             case PLACEMENT_TOP_CENTER: { corners = CORNER_BOTTOMLEFT | CORNER_BOTTOMRIGHT; break; }
  1421:             case PLACEMENT_BOTTOM_CENTER: { corners = CORNER_TOPLEFT | CORNER_TOPRIGHT; break; }
  1422:             case PLACEMENT_TOP_RIGHT: { corners = CORNER_BOTTOMLEFT; break; }
  1423:             case PLACEMENT_CENTER_RIGHT: { corners = CORNER_TOPLEFT | CORNER_BOTTOMLEFT; break; }
  1424:             case PLACEMENT_BOTTOM_RIGHT: { corners = CORNER_TOPLEFT; break; }
  1425:             default: { corners = CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | CORNER_BOTTOMRIGHT; break; }
  1426:         }
  1427: 
  1428:         // Apply rounded corners to the toolbar itself...
  1429:         AlphaCorner(cachedBackground, r, corners, 0, 0, 0, pSettings->Toolbar->borderWidth, 0, pSettings->toolbarTransparencyAlpha);
  1430: 
  1431:         // Apply rounded "outer" corners (i.e. left/right corners respectively if horizontally oriented,
  1432:         // top/bottom corners respectively if vertically oriented) also to the toolbar label+clock if they are parentRelative...
  1433:         if (pSettings->toolbarVertical)
  1434:         {
  1435:             if (!pSettings->toolbarLabelHidden && pSettings->ToolbarLabel->parentRelative) AlphaCorner(cachedBackground, labelRect, (corners & (CORNER_TOPLEFT | CORNER_TOPRIGHT)), 0, 0, 0, pSettings->Toolbar->borderWidth, pSettings->toolbarTransparencyAlpha, pSettings->toolbarLabelTransparencyAlpha);
  1436:             if (!pSettings->toolbarClockHidden && pSettings->ToolbarClock->parentRelative) AlphaCorner(cachedBackground, clockRect, (corners & (CORNER_BOTTOMLEFT | CORNER_BOTTOMRIGHT)), 0, 0, 0, pSettings->Toolbar->borderWidth, pSettings->toolbarTransparencyAlpha, pSettings->toolbarClockTransparencyAlpha);
  1437:         }
  1438:         else
  1439:         {
  1440:             if (!pSettings->toolbarLabelHidden && pSettings->ToolbarLabel->parentRelative) AlphaCorner(cachedBackground, labelRect, (corners & (CORNER_TOPLEFT | CORNER_BOTTOMLEFT)), 0, 0, 0, pSettings->Toolbar->borderWidth, pSettings->toolbarTransparencyAlpha, pSettings->toolbarLabelTransparencyAlpha);
  1441:             if (!pSettings->toolbarClockHidden && pSettings->ToolbarClock->parentRelative) AlphaCorner(cachedBackground, clockRect, (corners & (CORNER_TOPRIGHT | CORNER_BOTTOMRIGHT)), 0, 0, 0, pSettings->Toolbar->borderWidth, pSettings->toolbarTransparencyAlpha, pSettings->toolbarClockTransparencyAlpha);
  1442:         }
  1443:     }
  1444: 
  1445:     AlphaApply(cachedBackground, r);
  1446: 
  1447:     //====================
  1448: 
  1449:     if (bufbmp) DeleteObject(bufbmp);
  1450: 
  1451:     POINT pt;
  1452:     pt.x = ToolbarX, pt.y = ToolbarY;
  1453:     POINT ptSrc;
  1454:     ptSrc.x = 0, ptSrc.y = 0;
  1455: 
  1456:     BLENDFUNCTION bf;
  1457:     bf.BlendOp = AC_SRC_OVER;
  1458:     bf.BlendFlags = 0;
  1459:     bf.AlphaFormat = AC_SRC_ALPHA;
  1460:     bf.SourceConstantAlpha = (unsigned char)255;
  1461: 
  1462:     SIZE windowSize = { ToolbarWidth, ToolbarHeight };
  1463:     BOOL result = UpdateLayeredWindow(hToolbarWnd, NULL, &pt, &windowSize, cachedBackground, &ptSrc, 0, &bf, ULW_ALPHA);
  1464: /*
  1465:     if (!cachedBackground) SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"xoblite -> Toolbar -> Invalid cachedBackground!");
  1466: 
  1467:     if (result == 0)
  1468:     {
  1469:         int error = GetLastError();
  1470:         char msg[255];
  1471:         sprintf_s(msg, sizeofArray(msg), "xoblite -> Toolbar -> UpdateLayeredWindow failed! [error code %d]", error);
  1472:         SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_ERROR_MESSAGE, (LPARAM)msg);
  1473:     }
  1474: */
  1475: }
  1476: 
  1477: //===========================================================================
  1478: 
  1479: void Toolbar::DrawWindowLabel(HDC hdc, RECT r, bool backgroundOnly)
  1480: {
  1481:     // Delete any existing taskbar tooltips... (just in case)
  1482:     if (pSettings->taskbarTooltips) pTooltips->DeleteAllTooltips();
  1483: 
  1484:     //====================
  1485: 
  1486:     RECT wlRect, wlTextRect;
  1487:     CopyRect(&wlRect, &r);
  1488: //  if (pSettings->toolbarVertical && (pSettings->taskbarMode == TASKBAR_MODE_HIDDEN)) wlRect.bottom -= pSettings->Toolbar->marginWidth;
  1489:     CopyRect(&wlTextRect, &wlRect);
  1490: 
  1491:     //====================
  1492: 
  1493:     // Has the windowLabel bounding rect changed since we last
  1494:     // cached it? If so, let's create a new cached bitmap...
  1495:     if (!EqualRect(&currentWindowLabelRect, &wlRect))
  1496:     {
  1497:         CopyRect(&currentWindowLabelRect, &wlRect);
  1498:         currentWindowLabelWidth = wlRect.right - wlRect.left;
  1499:         currentWindowLabelHeight = wlRect.bottom - wlRect.top;
  1500: 
  1501:         if (!pSettings->ToolbarWindowLabel->parentRelative)
  1502:         {
  1503:             // Create a temporary bitmap...
  1504:             HBITMAP tempBitmap = CreateCompatibleBitmap(hdc, currentWindowLabelWidth, currentWindowLabelHeight);
  1505:             // Delete the previously cached gradient...
  1506:             HBITMAP oldBitmap = (HBITMAP)SelectObject(cachedToolbarWindowLabel, tempBitmap);
  1507:             DeleteObject(oldBitmap);
  1508:             // Paint the windowLabel background...
  1509:             r.left = 0; r.top = 0;  r.right = currentWindowLabelWidth; r.bottom = currentWindowLabelHeight;
  1510:             if (pSettings->ToolbarWindowLabel->type == B_IMAGEFROMFILE) DrawImageIntoRect(cachedToolbarWindowLabel, r, pSettings->ToolbarWindowLabel, false, true);
  1511:             else MakeGradientSuper(cachedToolbarWindowLabel, r, pSettings->ToolbarWindowLabel->type, pSettings->ToolbarWindowLabel->Color1, pSettings->ToolbarWindowLabel->Color2, pSettings->ToolbarWindowLabel->Color3, pSettings->ToolbarWindowLabel->Color4, pSettings->ToolbarWindowLabel->Color5, pSettings->ToolbarWindowLabel->Color6, pSettings->ToolbarWindowLabel->Color7, pSettings->ToolbarWindowLabel->Color8, pSettings->ToolbarWindowLabel->interlaced, pSettings->ToolbarWindowLabel->bevelstyle, pSettings->ToolbarWindowLabel->bevelposition, pSettings->bevelWidth, pSettings->ToolbarWindowLabel->borderColor, pSettings->ToolbarWindowLabel->borderWidth);
  1512:             // Clean up - delete the temporary bitmap...
  1513:             DeleteObject(tempBitmap);
  1514:         }
  1515:     }
  1516: 
  1517:     //====================
  1518: 
  1519:     if (!pSettings->ToolbarWindowLabel->parentRelative)
  1520:     {
  1521:         // Copy the cached bitmap into the temporary buffer...
  1522:         BitBlt(hdc, wlRect.left, wlRect.top, currentWindowLabelWidth, currentWindowLabelHeight, cachedToolbarWindowLabel, 0, 0, SRCCOPY);
  1523: 
  1524:         // Below: Simple placeholder hack to allow image alpha for the otherwise pre-cached ToolbarWindowLabel too...
  1525: //      if (pSettings->ToolbarWindowLabel->type == B_IMAGEFROMFILE) DrawImageIntoRect(hdc, wlRect, pSettings->ToolbarWindowLabel, false, true);
  1526: //      else BitBlt(hdc, wlRect.left, wlRect.top, currentWindowLabelWidth, currentWindowLabelHeight, cachedToolbarWindowLabel, 0, 0, SRCCOPY);
  1527:     }
  1528: 
  1529:     //====================
  1530: 
  1531:     if (!backgroundOnly)
  1532:     {
  1533:         // Draw window label...
  1534: 
  1535:         HFONT font = CreateFont(pSettings->ToolbarWindowLabel->FontHeight, 0, 0, 0, pSettings->ToolbarWindowLabel->FontWeight, false, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, pSettings->ToolbarWindowLabel->Font);
  1536:         HGDIOBJ oldfont = SelectObject(hdc, font);
  1537:         SetBkMode(hdc, TRANSPARENT);
  1538: 
  1539: //      wlTextRect.left = wlTextRect.left + 3;
  1540: //      wlTextRect.right = wlTextRect.right - 3;
  1541:         // Using the same padding as for the taskbar... (-> looks better, unified look =] )
  1542:         int windowLabelHeight = wlTextRect.bottom - wlTextRect.top;
  1543:         int iconSize = 11;
  1544:         if (windowLabelHeight > 20) iconSize = 16;
  1545:         int padding = ((windowLabelHeight - iconSize) / 2);
  1546:         InflateRect(&wlTextRect, -padding, 0);
  1547: 
  1548:         unsigned int format = pSettings->ToolbarWindowLabel->Justify | DT_VCENTER | DT_NOPREFIX | DT_SINGLELINE | DT_WORD_ELLIPSIS;
  1549: 
  1550:         if (wcslen(CurrentWindow)) DrawTextWithEffectsUnicode(hdc, wlTextRect, CurrentWindow, format, pSettings->ToolbarWindowLabel->TextColor, pSettings->ToolbarWindowLabel->FontOutline, pSettings->ToolbarWindowLabel->OutlineColor, pSettings->ToolbarWindowLabel->FontShadow, pSettings->ToolbarWindowLabel->ShadowColor, pSettings->ToolbarWindowLabel->ShadowX, pSettings->ToolbarWindowLabel->ShadowY);
  1551:         else DrawTextWithEffects(hdc, wlTextRect, "Welcome to xoblite.", format, pSettings->ToolbarWindowLabel->TextColor, pSettings->ToolbarWindowLabel->FontOutline, pSettings->ToolbarWindowLabel->OutlineColor, pSettings->ToolbarWindowLabel->FontShadow, pSettings->ToolbarWindowLabel->ShadowColor, pSettings->ToolbarWindowLabel->ShadowX, pSettings->ToolbarWindowLabel->ShadowY);
  1552: 
  1553:         DeleteObject(SelectObject(hdc, oldfont));
  1554:     }
  1555: }
  1556: 
  1557: //===========================================================================
  1558: 
  1559: void Toolbar::DrawButtonGlyph(HDC hdc, int glyph, int xcenter, int ycenter)
  1560: {
  1561:     switch (glyph)
  1562:     {
  1563:         case TOOLBAR_BUTTON_GLYPH_DOWN:
  1564:         {
  1565:             if (pSettings->doubleScaleHiDPI)
  1566:             {
  1567:                 MoveToEx(hdc, xcenter, ycenter+2, NULL);
  1568:                 LineTo(hdc, xcenter+1, ycenter+2);
  1569:                 MoveToEx(hdc, xcenter-1, ycenter+1, NULL);
  1570:                 LineTo(hdc, xcenter+2, ycenter+1);
  1571:                 MoveToEx(hdc, xcenter-2, ycenter, NULL);
  1572:                 LineTo(hdc, xcenter+3, ycenter);
  1573:                 MoveToEx(hdc, xcenter-3, ycenter-1, NULL);
  1574:                 LineTo(hdc, xcenter+4, ycenter-1);
  1575:                 MoveToEx(hdc, xcenter-4, ycenter-2, NULL);
  1576:                 LineTo(hdc, xcenter+5, ycenter-2);
  1577:             }
  1578:             else
  1579:             {
  1580:                 MoveToEx(hdc, xcenter, ycenter+1, NULL);
  1581:                 LineTo(hdc, xcenter+1, ycenter+1);
  1582:                 MoveToEx(hdc, xcenter-1, ycenter, NULL);
  1583:                 LineTo(hdc, xcenter+2, ycenter);
  1584:                 MoveToEx(hdc, xcenter-2, ycenter-1, NULL);
  1585:                 LineTo(hdc, xcenter+3, ycenter-1);
  1586:             }
  1587: 
  1588:             return;
  1589:         }
  1590: 
  1591:         //====================
  1592: 
  1593:         case TOOLBAR_BUTTON_GLYPH_UP:
  1594:         {
  1595:             if (pSettings->doubleScaleHiDPI)
  1596:             {
  1597:                 MoveToEx(hdc, xcenter, ycenter-2, NULL);
  1598:                 LineTo(hdc, xcenter+1, ycenter-2);
  1599:                 MoveToEx(hdc, xcenter-1, ycenter-1, NULL);
  1600:                 LineTo(hdc, xcenter+2, ycenter-1);
  1601:                 MoveToEx(hdc, xcenter-2, ycenter, NULL);
  1602:                 LineTo(hdc, xcenter+3, ycenter);
  1603:                 MoveToEx(hdc, xcenter-3, ycenter+1, NULL);
  1604:                 LineTo(hdc, xcenter+4, ycenter+1);
  1605:                 MoveToEx(hdc, xcenter-4, ycenter+2, NULL);
  1606:                 LineTo(hdc, xcenter+5, ycenter+2);
  1607:             }
  1608:             else
  1609:             {
  1610:                 MoveToEx(hdc, xcenter, ycenter-1, NULL);
  1611:                 LineTo(hdc, xcenter+1, ycenter-1);
  1612:                 MoveToEx(hdc, xcenter-1, ycenter, NULL);
  1613:                 LineTo(hdc, xcenter+2, ycenter);
  1614:                 MoveToEx(hdc, xcenter-2, ycenter+1, NULL);
  1615:                 LineTo(hdc, xcenter+3, ycenter+1);
  1616:             }
  1617: 
  1618:             return;
  1619:         }
  1620: 
  1621:         //====================
  1622: 
  1623:         case TOOLBAR_BUTTON_GLYPH_LEFT:
  1624:         {
  1625:             if (pSettings->doubleScaleHiDPI)
  1626:             {
  1627:                 MoveToEx(hdc, xcenter-2, ycenter, NULL);
  1628:                 LineTo(hdc, xcenter-2, ycenter+1);
  1629:                 MoveToEx(hdc, xcenter-1, ycenter-1, NULL);
  1630:                 LineTo(hdc, xcenter-1, ycenter+2);
  1631:                 MoveToEx(hdc, xcenter, ycenter-2, NULL);
  1632:                 LineTo(hdc, xcenter, ycenter+3);
  1633:                 MoveToEx(hdc, xcenter+1, ycenter-3, NULL);
  1634:                 LineTo(hdc, xcenter+1, ycenter+4);
  1635:                 MoveToEx(hdc, xcenter+2, ycenter-4, NULL);
  1636:                 LineTo(hdc, xcenter+2, ycenter+5);
  1637:             }
  1638:             else
  1639:             {
  1640:                 MoveToEx(hdc, xcenter-1, ycenter, NULL);
  1641:                 LineTo(hdc, xcenter-1, ycenter+1);
  1642:                 MoveToEx(hdc, xcenter, ycenter-1, NULL);
  1643:                 LineTo(hdc, xcenter, ycenter+2);
  1644:                 MoveToEx(hdc, xcenter+1, ycenter-2, NULL);
  1645:                 LineTo(hdc, xcenter+1, ycenter+3);
  1646:             }
  1647: 
  1648:             return;
  1649:         }
  1650: 
  1651:         //====================
  1652: 
  1653:         case TOOLBAR_BUTTON_GLYPH_RIGHT:
  1654:         {
  1655:             if (pSettings->doubleScaleHiDPI)
  1656:             {
  1657:                 MoveToEx(hdc, xcenter-2, ycenter-4, NULL);
  1658:                 LineTo(hdc, xcenter-2, ycenter+5);
  1659:                 MoveToEx(hdc, xcenter-1, ycenter-3, NULL);
  1660:                 LineTo(hdc, xcenter-1, ycenter+4);
  1661:                 MoveToEx(hdc, xcenter, ycenter-2, NULL);
  1662:                 LineTo(hdc, xcenter, ycenter+3);
  1663:                 MoveToEx(hdc, xcenter+1, ycenter-1, NULL);
  1664:                 LineTo(hdc, xcenter+1, ycenter+2);
  1665:                 MoveToEx(hdc, xcenter+2, ycenter, NULL);
  1666:                 LineTo(hdc, xcenter+2, ycenter+1);
  1667:             }
  1668:             else
  1669:             {
  1670:                 MoveToEx(hdc, xcenter-1, ycenter-2, NULL);
  1671:                 LineTo(hdc, xcenter-1, ycenter+3);
  1672:                 MoveToEx(hdc, xcenter, ycenter-1, NULL);
  1673:                 LineTo(hdc, xcenter, ycenter+2);
  1674:                 MoveToEx(hdc, xcenter+1, ycenter, NULL);
  1675:                 LineTo(hdc, xcenter+1, ycenter+1);
  1676:             }
  1677: 
  1678:             return;
  1679:         }
  1680:     }
  1681: }
  1682: 
  1683: //===========================================================================
  1684: 
  1685: bool Toolbar::GetClockText(bool forceUpdate)
  1686: {
  1687:     time(&systemTime);
  1688:     localtime_s(&localTime, &systemTime);
  1689:     currentMinute = localTime.tm_min;
  1690: 
  1691:     // Only update the toolbar clock if the current minute has changed...
  1692:     if ((currentMinute != displayedMinute) || forceUpdate)
  1693:     {
  1694:         // Format the toolbar clock string based on the related xoblite.rc setting... (nb. we need to convert the format string from ANSI to Unicode first)
  1695:         wchar_t toolbarClockFormatInUnicode[MAX_LINE_LENGTH];
  1696:         MultiByteToWideChar(CP_UTF8, 0, pSettings->toolbarClockFormat, strnlen_s(pSettings->toolbarClockFormat, sizeofArray(pSettings->toolbarClockFormat))+1, toolbarClockFormatInUnicode, MAX_LINE_LENGTH);
  1697:         wcsftime(CurrentTime, sizeof(CurrentTime), toolbarClockFormatInUnicode, &localTime);
  1698: 
  1699:         // Remember minute shown in display, now wait until minute changes before updating again...
  1700:         displayedMinute = currentMinute;
  1701: 
  1702:         return true;
  1703:     }
  1704:     else return false;
  1705: }
  1706: 
  1707: //===========================================================================
  1708: 
  1709: void Toolbar::GetDimensions()
  1710: {
  1711: //  ScreenWidth = GetSystemMetrics(SM_CXSCREEN);
  1712: //  ScreenHeight = GetSystemMetrics(SM_CYSCREEN);
  1713: 
  1714:     int ScreenLeft, ScreenTop;
  1715: 
  1716:     if (!pSettings->explorerHidden)
  1717:     {
  1718:         RECT workArea;
  1719:         SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID)&workArea, SPIF_SENDCHANGE);
  1720:         ScreenLeft = workArea.left;
  1721:         ScreenTop = workArea.top;
  1722:         ScreenWidth = workArea.right - workArea.left;
  1723:         ScreenHeight = workArea.bottom - workArea.top;
  1724:     }
  1725:     else
  1726:     {
  1727:         ScreenLeft = GetSystemMetrics(SM_XVIRTUALSCREEN);
  1728:         ScreenTop = GetSystemMetrics(SM_YVIRTUALSCREEN);
  1729:         ScreenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
  1730:         ScreenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
  1731:     }
  1732: 
  1733:     //====================
  1734: 
  1735:     // Calculate element heights...
  1736: 
  1737:     int toolbarMarginPlusBorder = pSettings->Toolbar->marginWidth + pSettings->Toolbar->borderWidth;
  1738: 
  1739:     tbLabelH = pSettings->ToolbarLabel->FontHeight + (2 * pSettings->ToolbarLabel->marginWidth) + (2 * pSettings->ToolbarLabel->borderWidth);
  1740:     tbWinLabelH = pSettings->ToolbarWindowLabel->FontHeight + (2 * pSettings->ToolbarWindowLabel->marginWidth) + (2 * pSettings->ToolbarWindowLabel->borderWidth);
  1741:     tbClockH = pSettings->ToolbarClock->FontHeight + (2 * pSettings->ToolbarClock->marginWidth) + (2 * pSettings->ToolbarClock->borderWidth);
  1742: 
  1743:     int glyphSize = 7;
  1744:     if (pSettings->doubleScaleHiDPI) glyphSize += 4;
  1745:     tbButtonWH = glyphSize + (2 * pSettings->ToolbarButton->marginWidth) + (2 * pSettings->ToolbarButton->borderWidth);
  1746:     tbButtonWH = tbButtonWH | 1; // Force odd sized buttons for glyphs to be centered...
  1747: 
  1748:     int maxHeight = 15; // Minimum height 15 pixels
  1749:     if (tbLabelH > maxHeight) maxHeight = tbLabelH;
  1750:     if (tbWinLabelH > maxHeight) maxHeight = tbWinLabelH;
  1751:     if (tbClockH > maxHeight) maxHeight = tbClockH;
  1752:     if (tbButtonWH > maxHeight) maxHeight = tbButtonWH;
  1753:     maxHeight = maxHeight | 1; // Force odd size for buttons/glyphs to be centered...
  1754: 
  1755:     tbLabelH = tbWinLabelH = tbClockH = maxHeight;
  1756: 
  1757:     int extraButtonPadding = (maxHeight - tbButtonWH) / 2;
  1758: 
  1759:     //====================
  1760: 
  1761:     // Calculate the toolbar workspace label and clock widths...
  1762: 
  1763:     SIZE size;
  1764:     HDC fonthdc = CreateDC("DISPLAY", NULL, NULL, NULL);
  1765: 
  1766:     // Get the width of the toolbar workspace label...
  1767:     HFONT tempfont = CreateFont(pSettings->ToolbarLabel->FontHeight, 0, 0, 0, pSettings->ToolbarLabel->FontWeight, false, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, pSettings->ToolbarLabel->Font);
  1768:     HGDIOBJ oldtempfont = SelectObject(fonthdc, tempfont);
  1769:     if (pWorkspaces) strcpy_s(ToolbarWorkspaceName, sizeofArray(ToolbarWorkspaceName), (LPSTR)pWorkspaces->workspaceNames[pSettings->currentWorkspace].c_str());
  1770:     GetTextExtentPoint32(fonthdc, ToolbarWorkspaceName, strnlen_s(ToolbarWorkspaceName, sizeofArray(ToolbarWorkspaceName)), &size);
  1771: //  tbLabelW = size.cx + 6 + (2 * pSettings->ToolbarLabel->marginWidth) + (2 * pSettings->ToolbarLabel->borderWidth);
  1772:     tbLabelW = size.cx + (2 * (tbLabelH - pSettings->ToolbarLabel->FontHeight)) + (2 * pSettings->ToolbarLabel->marginWidth) + (2 * pSettings->ToolbarLabel->borderWidth);
  1773: 
  1774:     // Get the width of the toolbar clock...
  1775:     DeleteObject(SelectObject(fonthdc, oldtempfont));
  1776:     tempfont = CreateFont(pSettings->ToolbarClock->FontHeight, 0, 0, 0, pSettings->ToolbarClock->FontWeight, false, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, pSettings->ToolbarClock->Font);
  1777:     oldtempfont = SelectObject(fonthdc, tempfont);
  1778:     GetTextExtentPoint32W(fonthdc, CurrentTime, wcslen(CurrentTime), &size);
  1779: //  tbClockW = size.cx + 6 + (2 * pSettings->ToolbarClock->marginWidth) + (2 * pSettings->ToolbarClock->borderWidth);
  1780:     tbClockW = size.cx + (2 * (tbClockH - pSettings->ToolbarClock->FontHeight)) + (2 * pSettings->ToolbarClock->marginWidth) + (2 * pSettings->ToolbarClock->borderWidth);
  1781: 
  1782:     if ((pSettings->toolbarLabelHidden || (pSettings->numberOfWorkspaces < 2)) && pSettings->toolbarClockHidden)
  1783:     {
  1784:         // Both the workspace label and the clock are hidden...
  1785:         tbLabelW = tbLabelH = tbClockW = tbClockH = 0;
  1786:     }
  1787:     else if (pSettings->toolbarLabelHidden || (pSettings->numberOfWorkspaces < 2))
  1788:     {
  1789:         // Only the workspace label is hidden...
  1790:         tbLabelW = tbLabelH = 0;
  1791:     }
  1792:     else if (pSettings->toolbarClockHidden)
  1793:     {
  1794:         // Only the toolbar clock is hidden...
  1795:         tbClockW = tbClockH = 0;
  1796:     }
  1797:     else if (!pSettings->toolbarAllowAsymmetry || pSettings->toolbarVertical)
  1798:     {
  1799:         // Both the workspace label and the clock are visible, so unless we're using horizontal orientation
  1800:         // *and* asymmetry between the two is configured allowed, the widest of the two sets the width...
  1801:         if (tbClockW > tbLabelW) tbLabelW = tbClockW;
  1802:         else tbClockW = tbLabelW;
  1803:     }
  1804: 
  1805:     DeleteObject(SelectObject(fonthdc, oldtempfont));
  1806:     DeleteDC(fonthdc);
  1807: 
  1808:     //====================
  1809: 
  1810:     // Get number of taskbar buttons to draw... (nb. this also honours any configured maximum number of taskbar items)
  1811:     pTaskbar->GetTaskButtonsToDraw();
  1812: 
  1813:     //====================
  1814: 
  1815:     // ####################################################
  1816:     // ##### Horizontal toolbar orientation (default) #####
  1817:     // ####################################################
  1818: 
  1819:     if (!pSettings->toolbarVertical)
  1820:     {
  1821:         // If the toolbar width is configured as <= 100 this defines its width as a percentage of the screen width,
  1822:         // and if configured as > 100 this defines its width in number of pixels...
  1823:         if (pSettings->toolbarHorizontalWidth <= 100)
  1824:         {
  1825:             ToolbarWidth = (ScreenWidth * pSettings->toolbarHorizontalWidth) / 100;
  1826:         }
  1827:         else ToolbarWidth = pSettings->toolbarHorizontalWidth;
  1828: 
  1829:         //====================
  1830: 
  1831:         // The toolbar height must be a minimum 17 pixels for the taskbar buttons to
  1832:         // look decent, so if it is not we need to adjust the element heights accordingly...
  1833: 
  1834:         ToolbarHeight = maxHeight + (2 * toolbarMarginPlusBorder);
  1835: 
  1836:         if (ToolbarHeight < 17)
  1837:         {
  1838:             int diffHeight = 17 - ToolbarHeight;
  1839:             ToolbarHeight = 17;
  1840:             maxHeight += diffHeight;
  1841:             extraButtonPadding = (maxHeight - tbButtonWH) / 2;
  1842:             tbLabelH = tbWinLabelH = tbClockH = maxHeight;
  1843:             tbLabelW = tbClockW += (2*diffHeight);
  1844: 
  1845:             if (pSettings->numberOfWorkspaces < 2) tbLabelW = tbLabelH = 0;
  1846:         }
  1847: 
  1848:         //====================
  1849: 
  1850:         // Adaptively calculate each toolbar element's position depending on the visibility of the other toolbar elements...
  1851: 
  1852:         int offsetLeftX = toolbarMarginPlusBorder;
  1853:         int offsetRightX = ToolbarWidth - toolbarMarginPlusBorder;
  1854:         int offsetY = toolbarMarginPlusBorder;
  1855: 
  1856:         if (!pSettings->toolbarLabelHidden && (pSettings->numberOfWorkspaces > 1))
  1857:         {
  1858:             tbLabelX = offsetLeftX;
  1859:             tbLabelY = offsetY;
  1860:             offsetLeftX += (tbLabelW + pSettings->Toolbar->marginWidth);
  1861:         }
  1862: 
  1863:         if (!pSettings->toolbarDownUpButtonsHidden && (pSettings->numberOfWorkspaces > 1))
  1864:         {
  1865:             tbButtonX1 = offsetLeftX + extraButtonPadding;
  1866:             tbButtonX2 = tbButtonX1 + tbButtonWH + extraButtonPadding + pSettings->Toolbar->marginWidth;
  1867:             offsetLeftX += ((2*tbButtonWH) + (3*extraButtonPadding) + (2*pSettings->Toolbar->marginWidth));
  1868:         }
  1869: 
  1870:         if (!pSettings->toolbarClockHidden)
  1871:         {
  1872:             tbClockX = offsetRightX - tbClockW;
  1873:             tbClockY = offsetY;
  1874:             offsetRightX -= (tbClockW + pSettings->Toolbar->marginWidth);
  1875:         }
  1876: 
  1877:         if (!pSettings->toolbarLeftRightButtonsHidden)
  1878:         {
  1879:             tbButtonX4 = offsetRightX - extraButtonPadding - tbButtonWH;
  1880:             tbButtonX3 = tbButtonX4 - extraButtonPadding - pSettings->Toolbar->marginWidth - tbButtonWH;
  1881:             offsetRightX -= ((2*tbButtonWH) + (3*extraButtonPadding) + (2*pSettings->Toolbar->marginWidth));
  1882:         }
  1883: 
  1884:         tbButtonY = (ToolbarHeight - tbButtonWH) / 2;
  1885: 
  1886:         tbWinLabelX = offsetLeftX;
  1887:         tbWinLabelY = offsetY;
  1888:         tbWinLabelW = offsetRightX - offsetLeftX;
  1889:         if (tbWinLabelW < 0) tbWinLabelW = 0; // Make sure windowlabel width is acceptable; could be < 0 if toolbar width (percentage) is too small!
  1890: 
  1891: /*
  1892:         tbLabelX = toolbarMarginPlusBorder;
  1893:         tbLabelY = tbLabelX;
  1894: 
  1895:         tbClockX = ToolbarWidth - tbClockW - toolbarMarginPlusBorder;
  1896:         tbClockY = tbLabelY;
  1897: 
  1898:         if (pSettings->numberOfWorkspaces > 1)
  1899:         {
  1900:             tbWinLabelX = tbLabelX + tbLabelW + (2*tbButtonWH) + (3*pSettings->Toolbar->marginWidth) + (3*extraButtonPadding);
  1901:             tbWinLabelY = tbLabelY;
  1902:             tbWinLabelW = ToolbarWidth - (2*tbWinLabelX);
  1903:         }
  1904:         else
  1905:         {
  1906:             tbWinLabelX = tbLabelX;
  1907:             tbWinLabelY = tbLabelY;
  1908:             tbWinLabelW = ToolbarWidth - (2*tbLabelX) - tbClockW - (2*tbButtonWH) - (3*pSettings->Toolbar->marginWidth) - (3*extraButtonPadding);
  1909:         }
  1910: 
  1911:         // Make sure windowlabel width is acceptable, could be < 0 if toolbar width (percentage) is too small!
  1912:         if (tbWinLabelW < 0) tbWinLabelW = 0;
  1913: 
  1914:         tbButtonX1 = tbLabelX + tbLabelW + pSettings->Toolbar->marginWidth + extraButtonPadding;
  1915:         tbButtonX2 = tbButtonX1 + tbButtonWH + pSettings->Toolbar->marginWidth + extraButtonPadding;
  1916:         tbButtonX3 = tbWinLabelX + tbWinLabelW + pSettings->Toolbar->marginWidth + extraButtonPadding;
  1917:         tbButtonX4 = tbButtonX3 + tbButtonWH + pSettings->Toolbar->marginWidth + extraButtonPadding;
  1918: 
  1919: //      tbButtonWH = maxHeight;
  1920: //      tbButtonY = toolbarMarginPlusBorder;
  1921:         tbButtonY = (ToolbarHeight - tbButtonWH) / 2;
  1922: */
  1923:     }
  1924: 
  1925:     //====================
  1926: 
  1927:     // ########################################
  1928:     // ##### Vertical toolbar orientation #####
  1929:     // ########################################
  1930: 
  1931:     else
  1932:     {
  1933:         // In vertical mode the windowlabel width == the clock width, or the minimum width defined in xoblite.rc...
  1934: 
  1935:         if (toolbarVerticalPeeking)
  1936:         {
  1937:             tbWinLabelW = (ScreenWidth / 2) - (2 * toolbarMarginPlusBorder); // Temporarily "peek" increase the toolbar width to 50% of screen width
  1938:         }
  1939:         else if (pSettings->toolbarVerticalWidth != 0) // (-> Fallback to automatic width if 0 (not specified), see below)
  1940:         {
  1941:             // The vertical toolbar width can be minimum 5% of screen width, maximum 25% of screen width...
  1942:             int verticalWidth = pSettings->toolbarVerticalWidth;
  1943: 
  1944:             if (verticalWidth <= 100) // -> Parse width value as % of screen width (minimum 5% of screen width, maximum 25% of screen width)
  1945:             {
  1946:                 if (verticalWidth < 5) verticalWidth = 5;
  1947:                 else if (verticalWidth > 25) verticalWidth = 25;
  1948:                 verticalWidth = (ScreenWidth * verticalWidth) / 100;
  1949: //              verticalWidth = (GetSystemMetrics(SM_CXVIRTUALSCREEN) * verticalWidth) / 100;
  1950:             }
  1951:             else // if (width > 100) -> Parse width value as number of pixels (again, minimum 5% of screen width, maximum 25% of screen width)
  1952:             {
  1953:                 int minWidth = (ScreenWidth * 5) / 100;
  1954:                 int maxWidth = (ScreenWidth * 25) / 100;
  1955: //              int minWidth = (GetSystemMetrics(SM_CXVIRTUALSCREEN) * 5) / 100;
  1956: //              int maxWidth = (GetSystemMetrics(SM_CXVIRTUALSCREEN) * 25) / 100;
  1957:                 if (verticalWidth < minWidth) verticalWidth = minWidth;
  1958:                 else if (verticalWidth > maxWidth) verticalWidth = maxWidth;
  1959:             }
  1960: 
  1961:             tbWinLabelW = verticalWidth - (2 * toolbarMarginPlusBorder);
  1962:         }
  1963:         else if (tbClockW > 0) tbWinLabelW = tbClockW;
  1964:         else if (tbLabelW > 0) tbWinLabelW = tbLabelW;
  1965:         else tbWinLabelW = (ScreenWidth / 10); // Failsafe
  1966: 
  1967:         tbLabelW = tbClockW = tbWinLabelW;
  1968: 
  1969:         //====================
  1970: 
  1971:         ToolbarWidth = tbWinLabelW + (toolbarMarginPlusBorder * 2);
  1972: 
  1973:         // Simple failsafe: Perform an additional width check in case the toolbar buttons are *unusually* large...
  1974:         // (i.e. using very large toolbar.button.marginwidth's *cough* Pitkon *cough* ;) )
  1975:         if (!pSettings->toolbarDownUpButtonsHidden || !pSettings->toolbarLeftRightButtonsHidden)
  1976:         {
  1977:             int buttonsCheckWidth;
  1978:             if (pSettings->numberOfWorkspaces > 1) buttonsCheckWidth = (tbButtonWH * 4) + (pSettings->Toolbar->marginWidth * 10) + (toolbarMarginPlusBorder * 2);
  1979:             else buttonsCheckWidth = (tbButtonWH * 2) + (pSettings->Toolbar->marginWidth * 4) + (toolbarMarginPlusBorder * 2);
  1980:             if (ToolbarWidth < buttonsCheckWidth)
  1981:             {
  1982:                 ToolbarWidth = buttonsCheckWidth;
  1983:                 tbWinLabelW = tbClockW = ToolbarWidth - (toolbarMarginPlusBorder * 2);
  1984:                 if (tbLabelW > 0) tbLabelW = tbWinLabelW;
  1985:             }
  1986:         }
  1987: 
  1988:         //====================
  1989: 
  1990:         // Adaptively calculate each toolbar element's position depending on the visibility of the other toolbar elements...
  1991: 
  1992:         int offsetX = toolbarMarginPlusBorder;
  1993:         int offsetY = toolbarMarginPlusBorder;
  1994: 
  1995:         if (!pSettings->toolbarLabelHidden && (pSettings->numberOfWorkspaces > 1))
  1996:         {
  1997:             tbLabelX = offsetX;
  1998:             tbLabelY = offsetY;
  1999:             offsetY += (tbLabelH + pSettings->Toolbar->marginWidth);
  2000:         }
  2001: 
  2002:         tbWinLabelX = offsetX;
  2003:         tbWinLabelY = offsetY;
  2004:         if ((pSettings->taskbarMode != TASKBAR_MODE_HIDDEN) && (pTaskbar->taskButtonsToDraw > 0))
  2005:         {
  2006:             tbWinLabelH = tbWinLabelH * pTaskbar->taskButtonsToDraw;
  2007: //          tbWinLabelH -= pSettings->Toolbar->marginWidth; // ...because we only add extra padding in between the task buttons... (i.e. remove last added padding)
  2008: 
  2009:             // If applicable, add some room vertically for taskbar scrolling indicators at *both* ends of the taskbar...
  2010:             // (nb. we need to do this because we do *not* recalculate the toolbar height upon taskbar scrolling only, i.e. no or either or both indicator(s) may be visible)
  2011:             int leftTopPadding = 0, rightBottomPadding = 0;
  2012:             int taskbarScrollIndicatorSize = pTaskbar->GetTaskbarScrollIndicatorSizes(&leftTopPadding, &rightBottomPadding);
  2013:             if ((leftTopPadding > 0) || (rightBottomPadding > 0)) tbWinLabelH += (taskbarScrollIndicatorSize * 2);
  2014:         }
  2015:         offsetY += tbWinLabelH;
  2016: 
  2017:         if ((!pSettings->toolbarDownUpButtonsHidden && (pSettings->numberOfWorkspaces > 1)) || !pSettings->toolbarLeftRightButtonsHidden)
  2018:         {
  2019:             if ((!pSettings->toolbarDownUpButtonsHidden && (pSettings->numberOfWorkspaces > 1)) && !pSettings->toolbarLeftRightButtonsHidden)
  2020:             {
  2021:                 tbButtonX1 = offsetX + (extraButtonPadding*2);
  2022:                 tbButtonX2 = tbButtonX1 + tbButtonWH + pSettings->Toolbar->marginWidth + extraButtonPadding;
  2023:                 tbButtonX3 = ToolbarWidth - tbButtonX2 - tbButtonWH;
  2024:                 tbButtonX4 = ToolbarWidth - tbButtonX1 - tbButtonWH;
  2025:             }
  2026:             else if (!pSettings->toolbarDownUpButtonsHidden && (pSettings->numberOfWorkspaces > 1))
  2027:             {
  2028:                 tbButtonX1 = (ToolbarWidth/2) - (pSettings->Toolbar->marginWidth/2) - (extraButtonPadding/2) - tbButtonWH;
  2029:                 tbButtonX2 = tbButtonX1 + tbButtonWH + pSettings->Toolbar->marginWidth + extraButtonPadding;
  2030:             }
  2031:             else if (!pSettings->toolbarLeftRightButtonsHidden)
  2032:             {
  2033:                 tbButtonX3 = (ToolbarWidth/2) - (pSettings->Toolbar->marginWidth/2) - (extraButtonPadding/2) - tbButtonWH;
  2034:                 tbButtonX4 = tbButtonX3 + tbButtonWH + pSettings->Toolbar->marginWidth + extraButtonPadding;
  2035:             }
  2036: 
  2037:             tbButtonY = offsetY + pSettings->Toolbar->marginWidth + extraButtonPadding;
  2038:             offsetY += (pSettings->Toolbar->marginWidth + tbButtonWH + (extraButtonPadding * 2));
  2039:         }
  2040: 
  2041:         if (!pSettings->toolbarClockHidden)
  2042:         {
  2043:             tbClockX = offsetX;
  2044:             tbClockY = offsetY + pSettings->Toolbar->marginWidth;
  2045:             offsetY += (pSettings->Toolbar->marginWidth + tbClockH);
  2046:         }
  2047: 
  2048:         ToolbarHeight = offsetY + toolbarMarginPlusBorder;
  2049: 
  2050: 
  2051: 
  2052: 
  2053: 
  2054: 
  2055: 
  2056: /*
  2057:         if (pSettings->numberOfWorkspaces > 1)
  2058:         {
  2059:             tbWinLabelY = tbLabelY + tbLabelH + pSettings->Toolbar->marginWidth;
  2060:         }
  2061:         else tbWinLabelY = toolbarMarginPlusBorder;
  2062: 
  2063:         tbButtonX1 = tbWinLabelX + (extraButtonPadding*2);
  2064:         tbButtonX2 = tbButtonX1 + tbButtonWH + pSettings->Toolbar->marginWidth + extraButtonPadding;
  2065:         if (pSettings->numberOfWorkspaces > 1)
  2066:         {
  2067:             tbButtonX3 = ToolbarWidth - tbButtonX2 - tbButtonWH;
  2068:             tbButtonX4 = ToolbarWidth - tbButtonX1 - tbButtonWH;
  2069:         }
  2070:         else
  2071:         {
  2072:             int twoButtonsWidth = tbButtonX2 + tbButtonWH - tbButtonX1;
  2073:             tbButtonX3 = (ToolbarWidth/2) - (twoButtonsWidth/2);
  2074:             tbButtonX4 = tbButtonX3 + tbButtonWH + pSettings->Toolbar->marginWidth + extraButtonPadding;
  2075:         }
  2076:         tbButtonY = tbWinLabelY + tbWinLabelH + extraButtonPadding;
  2077: 
  2078:         tbClockY = tbButtonY + tbButtonWH + extraButtonPadding + pSettings->Toolbar->marginWidth;
  2079: 
  2080: //      tbButtonY = tbLabelY + tbLabelH + pSettings->Toolbar->marginWidth + extraButtonPadding;
  2081: //      tbWinLabelY = tbButtonY + tbButtonWH + extraButtonPadding + pSettings->Toolbar->marginWidth;
  2082: //      tbClockY = tbWinLabelY + tbWinLabelH;
  2083: 
  2084:         ToolbarHeight = tbClockY + tbClockH + toolbarMarginPlusBorder;
  2085: */
  2086:     }
  2087: 
  2088:     //====================
  2089: 
  2090:     // Save the element rect's so we can later on e.g. check if a specific element has been clicked...
  2091:     SetRect(&labelRect, tbLabelX, tbLabelY, tbLabelX+tbLabelW, tbLabelY+tbLabelH);
  2092:     SetRect(&winlabelRect, tbWinLabelX, tbWinLabelY, tbWinLabelX+tbWinLabelW, tbWinLabelY+tbWinLabelH);
  2093:     SetRect(&clockRect, tbClockX, tbClockY, tbClockX+tbClockW, tbClockY+tbClockH);
  2094: 
  2095:     SetRect(&button1Rect, tbButtonX1, tbButtonY, tbButtonX1+tbButtonWH, tbButtonY+tbButtonWH);
  2096:     SetRect(&button2Rect, tbButtonX2, tbButtonY, tbButtonX2+tbButtonWH, tbButtonY+tbButtonWH);
  2097:     SetRect(&button3Rect, tbButtonX3, tbButtonY, tbButtonX3+tbButtonWH, tbButtonY+tbButtonWH);
  2098:     SetRect(&button4Rect, tbButtonX4, tbButtonY, tbButtonX4+tbButtonWH, tbButtonY+tbButtonWH);
  2099: }
  2100: 
  2101: //===========================================================================
  2102: 
  2103: void Toolbar::GetPlacement()
  2104: {
  2105:     pSettings->ToolbarPlacement.width = ToolbarWidth;
  2106:     pSettings->ToolbarPlacement.height = ToolbarHeight;
  2107: 
  2108:     // If toolbar width is defined in pixels (i.e. > 100) or if the toolbar
  2109:     // is vertically oriented we treat the position as relative to the entire
  2110:     // virtual screen, i.e. with multi monitor support...
  2111: //  if (pSettings->toolbarVertical || (pSettings->toolbarHorizontalWidth > 100)) pSettings->PositionFromPlacement(&pSettings->ToolbarPlacement, true);
  2112:     // ...and if toolbar is defined as a percentage of the screen width
  2113:     // (i.e. <= 100) we treat the position as relative to the main screen/monitor...
  2114: //  else pSettings->PositionFromPlacement(&pSettings->ToolbarPlacement, false);
  2115: 
  2116: //  if (pSettings->ToolbarPlacement.placement == PLACEMENT_MANUAL) pSettings->PositionFromPlacement(&pSettings->ToolbarPlacement, true);
  2117: //  else pSettings->PositionFromPlacement(&pSettings->ToolbarPlacement, false);
  2118:     pSettings->PositionFromPlacement(&pSettings->ToolbarPlacement);
  2119: 
  2120:     ToolbarX = pSettings->ToolbarPlacement.x;
  2121:     ToolbarY = pSettings->ToolbarPlacement.y;
  2122: }
  2123: 
  2124: //===========================================================================
  2125: 
  2126: void Toolbar::UpdateWidth()
  2127: {
  2128:     pToolbar->GetDimensions();
  2129:     pToolbar->GetPlacement();
  2130: 
  2131:     // Force re-rendering of the background and task button bitmaps...
  2132:     pToolbar->cachedBitmapsExist = false;
  2133:     if (pSettings->taskbarMode != TASKBAR_MODE_HIDDEN) pTaskbar->cachedTaskButtonsExist = false;
  2134:     pToolbar->UpdateToolbarWindow();
  2135: 
  2136:     if (pSettings->toolbarOnTop) SetWindowPos(pToolbar->hToolbarWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE);
  2137:     else SetWindowPos(pToolbar->hToolbarWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE);
  2138: 
  2139:     // Due to the number of repeated updates when using the mousewheel to change the toolbar width,
  2140:     // we wait a second before saving the width to xoblite.rc, in case we're not done resizing yet...
  2141:     KillTimer(pToolbar->hToolbarWnd, TOOLBAR_SAVE_WIDTH_TIMER);
  2142:     pToolbar->saveWidthAfterDelay = true;
  2143:     SetTimer(pToolbar->hToolbarWnd, TOOLBAR_SAVE_WIDTH_TIMER, 1000, (TIMERPROC)NULL);
  2144: }
  2145: 
  2146: //===========================================================================
  2147: 
  2148: void Toolbar::UpdatePosition()
  2149: {
  2150: //  if (pSettings->debugLogging) SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"Toolbar -> UpdatePosition()");
  2151: 
  2152:     // Fetch the new size and position parameters for our window...
  2153:     GetDimensions();
  2154:     GetPlacement();
  2155: 
  2156:     // Force re-rendering of the background, windowLabel and task button bitmaps...
  2157:     cachedBitmapsExist = false;
  2158:     if (pSettings->taskbarMode != TASKBAR_MODE_HIDDEN) pTaskbar->cachedTaskButtonsExist = false;
  2159:     else SetRectEmpty(&currentWindowLabelRect);
  2160: 
  2161:     // Update the toolbar window...
  2162:     UpdateToolbarWindow();
  2163: 
  2164:     // Update the always on top setting for the toolbar window...
  2165:     if (pSettings->toolbarOnTop) SetWindowPos(hToolbarWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE);
  2166:     else SetWindowPos(hToolbarWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE);
  2167: 
  2168:     // Update the desktop area...
  2169: //  UpdateDesktopArea();
  2170: 
  2171:     // Save placement to xoblite.rc...
  2172: //  pSettings->WritePlacement(&pSettings->ToolbarPlacement);
  2173: }
  2174: 
  2175: //====================
  2176: /*
  2177: void Toolbar::UpdateDesktopArea()
  2178: {
  2179:     if (pSettings->desktopDisabled) return;
  2180: 
  2181:     RECT newWorkArea;
  2182: 
  2183:     if (pSettings->fullMaximization)
  2184:     {
  2185:         SetRect(&newWorkArea, 0, 0, ScreenWidth, ScreenHeight);
  2186:     }
  2187:     else if (pSettings->desktopAreaNotDefined)
  2188:     {
  2189:         newWorkArea.left = 0;
  2190:         newWorkArea.right = ScreenWidth;
  2191: 
  2192:         if (ToolbarY == 0)
  2193:         {
  2194:             newWorkArea.top =  ToolbarHeight + 5;
  2195:             newWorkArea.bottom = ScreenHeight;
  2196:         }
  2197:         else
  2198:         {
  2199:             newWorkArea.top = 0;
  2200:             newWorkArea.bottom = ScreenHeight - ToolbarHeight - 5;
  2201:         }
  2202:     }
  2203:     else
  2204:     {
  2205:         newWorkArea.left = pSettings->desktopArea.left;
  2206:         newWorkArea.top = pSettings->desktopArea.top;
  2207:         newWorkArea.right = ScreenWidth - pSettings->desktopArea.right;
  2208:         newWorkArea.bottom = ScreenHeight - pSettings->desktopArea.bottom;
  2209:     }
  2210: 
  2211:     SystemParametersInfo(SPI_SETWORKAREA, 0, (PVOID)&newWorkArea, SPIF_SENDCHANGE);
  2212:     SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID)&newWorkArea, SPIF_SENDCHANGE); // ...is this really needed?
  2213: }
  2214: */
  2215: //===========================================================================
  2216: 
  2217: void Toolbar::MoveToMouse()
  2218: {
  2219:     POINT pos;
  2220:     GetCursorPos(&pos);
  2221:     ToolbarX = pos.x - (ToolbarWidth / 2);
  2222:     ToolbarY = pos.y - (ToolbarHeight / 2);
  2223: 
  2224:     SetWindowPos(hToolbarWnd, HWND_TOP, ToolbarX, ToolbarY, 0, 0, SWP_NOSIZE | SWP_NOREDRAW);
  2225:     SetForegroundWindow(hToolbarWnd);
  2226: }
  2227: 
  2228: //===========================================================================
  2229: 
  2230: void Toolbar::ToggleOrientation()
  2231: {
  2232:     // Toggle toolbar orientation... (horizontal<->vertical)
  2233:     if (pSettings->toolbarVertical) pSettings->toolbarVertical = false;
  2234:     else pSettings->toolbarVertical = true;
  2235: 
  2236:     pToolbar->UpdatePosition();
  2237:     PlaySoundFX(SFX_TOGGLE_ELEMENT);
  2238: 
  2239:     WriteBool(pSettings->xobrcFile, "xoblite.toolbar.vertical:", pSettings->toolbarVertical);
  2240: }
  2241: 
  2242: //===========================================================================
  2243: 
  2244: void Toolbar::ToggleAlwaysOnTop()
  2245: {
  2246:     if (!pSettings->toolbarOnTop)
  2247:     {
  2248:         pSettings->toolbarOnTop = true;
  2249:         SetWindowPos(hToolbarWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE);
  2250:     }
  2251:     else
  2252:     {
  2253:         pSettings->toolbarOnTop = false;
  2254:         SetWindowPos(hToolbarWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE);
  2255:     }
  2256: 
  2257:     WriteBool(pSettings->xobrcFile, "xoblite.toolbar.onTop:", pSettings->toolbarOnTop);
  2258: }
  2259: 
  2260: //===========================================================================
  2261: 
  2262: void Toolbar::ToolbarModeButtonPressed(bool nextMode)
  2263: {
  2264:     if (nextMode) // -> Next toolbar mode
  2265:     {
  2266:         if (pSettings->taskbarMode == TASKBAR_MODE_HIDDEN) pSettings->taskbarMode = TASKBAR_MODE_BARS;
  2267:         else if (pSettings->taskbarMode == TASKBAR_MODE_BARS) pSettings->taskbarMode = TASKBAR_MODE_BARSICONS;
  2268:         else if (pSettings->taskbarMode == TASKBAR_MODE_BARSICONS)
  2269:         {
  2270:             if (!pSettings->toolbarVertical) pSettings->taskbarMode = TASKBAR_MODE_ICONS;
  2271:             else pSettings->taskbarMode = TASKBAR_MODE_HIDDEN;
  2272:         }
  2273:         else pSettings->taskbarMode = TASKBAR_MODE_HIDDEN;
  2274:     }
  2275:     else // -> Previous toolbar mode
  2276:     {
  2277:         if (pSettings->taskbarMode == TASKBAR_MODE_BARS) pSettings->taskbarMode = TASKBAR_MODE_HIDDEN;
  2278:         else if (pSettings->taskbarMode == TASKBAR_MODE_BARSICONS) pSettings->taskbarMode = TASKBAR_MODE_BARS;
  2279:         else if (pSettings->taskbarMode == TASKBAR_MODE_ICONS) pSettings->taskbarMode = TASKBAR_MODE_BARSICONS;
  2280:         else // if (pSettings->taskbarMode == TASKBAR_MODE_HIDDEN)
  2281:         {
  2282:             if (!pSettings->toolbarVertical) pSettings->taskbarMode = TASKBAR_MODE_ICONS;
  2283:             else pSettings->taskbarMode = TASKBAR_MODE_BARSICONS;
  2284:         }
  2285:     }
  2286: 
  2287:     if ((pSettings->taskbarMode == TASKBAR_MODE_HIDDEN) && pSettings->taskbarTooltips) pTooltips->DeleteAllTooltips();
  2288: 
  2289:     UpdatePosition(); // -> Refreshes the toolbar including the change of modes
  2290:     PlaySoundFX(SFX_TOGGLE_ELEMENT);
  2291: 
  2292:     // Save the taskbar mode change to xoblite.rc... (or legacy supported extensions.rc)
  2293:     if (pSettings->taskbarMode == TASKBAR_MODE_BARS) WriteString(pSettings->xobrcFile, "xoblite.taskbar.mode:", "Bars");
  2294:     else if (pSettings->taskbarMode == TASKBAR_MODE_BARSICONS) WriteString(pSettings->xobrcFile, "xoblite.taskbar.mode:", "Bars+Icons");
  2295:     else if (pSettings->taskbarMode == TASKBAR_MODE_ICONS) WriteString(pSettings->xobrcFile, "xoblite.taskbar.mode:", "Icons");
  2296:     else WriteString(pSettings->xobrcFile, "xoblite.taskbar.mode:", "Hidden");
  2297: }
  2298: 
  2299: //===========================================================================
  2300: 
  2301: bool Toolbar::CheckIfMouseHover()
  2302: {
  2303:     POINT mousepos;
  2304:     GetCursorPos(&mousepos);
  2305:     if (mousepos.x >= ToolbarX && mousepos.x <= (ToolbarX + ToolbarWidth))
  2306:     {
  2307:         if (mousepos.y >= ToolbarY && mousepos.y <= (ToolbarY + ToolbarHeight)) return true;
  2308:     }
  2309: 
  2310:     return false;
  2311: }
  2312: 
  2313: //===========================================================================
  2314: // Function: FullscreenDetected
  2315: // Purpose: Hide the toolbar (no updating) if an application goes fullscreen
  2316: //===========================================================================
  2317: 
  2318: void Toolbar::FullscreenDetected(bool fullscreen)
  2319: {
  2320:     if (fullscreen)
  2321:     {
  2322:         fullscreenDetected = true;
  2323:         ShowWindow(hToolbarWnd, SW_HIDE);
  2324:     }
  2325:     else
  2326:     {
  2327:         fullscreenDetected = false;
  2328:         if (!pSettings->toolbarHidden) ShowWindow(hToolbarWnd, SW_SHOWNOACTIVATE);
  2329:         UpdateToolbarWindow();
  2330:     }
  2331: }
  2332: 
  2333: //===========================================================================
  2334: // Function: ToggleCalendar
  2335: // Purpose: ...
  2336: //===========================================================================
  2337: 
  2338: void Toolbar::ToggleCalendar()
  2339: {
  2340: /*
  2341:     if (hToolbarCalendarWnd == NULL)
  2342:     {
  2343:         SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_REGULAR_MESSAGE, (LPARAM)"Opening calendar...");
  2344: 
  2345:         hToolbarCalendarWnd = CreateDialog(hToolbarInstance, "BBCalendar", hToolbarWnd, ToolbarCalendarWndProc);
  2346:         if (hToolbarCalendarWnd != NULL)
  2347:         {
  2348:             SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"hToolbarCalendarWnd created successfully.");
  2349: 
  2350:             hToolbarCalendarChildWnd = CreateWindowEx(
  2351:                 0,
  2352:                 MONTHCAL_CLASS,
  2353:                 "",
  2354:                 WS_BORDER | WS_CHILD | WS_VISIBLE | MCS_DAYSTATE,
  2355:                 0, 0, 0, 0,
  2356:                 hToolbarCalendarWnd,
  2357:                 NULL,
  2358:                 hToolbarInstance,
  2359:                 NULL
  2360:             );
  2361: 
  2362:             if (hToolbarCalendarChildWnd == NULL)
  2363:             {
  2364:                 SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_ERROR_MESSAGE, (LPARAM)"Error creating hToolbarCalendarChildWnd!");
  2365:                 DestroyWindow(hToolbarCalendarWnd);
  2366:                 hToolbarCalendarWnd = NULL;
  2367:                 return;
  2368:             }
  2369: 
  2370:             SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_INFORMATION_MESSAGE, (LPARAM)"hToolbarCalendarChildWnd created successfully.");
  2371: 
  2372:             RECT r;
  2373:             r.left = 100;
  2374:             r.top = 100;
  2375:             MonthCal_GetMinReqRect(hToolbarCalendarChildWnd, &r);
  2376:             SetWindowPos(hToolbarCalendarChildWnd, NULL, r.left, r.top, r.right, r.bottom, SWP_NOZORDER);
  2377: 
  2378:             MonthCal_SetCurrentView(hToolbarCalendarChildWnd, MCMV_YEAR);
  2379: 
  2380:             ShowWindow(hToolbarCalendarChildWnd, SW_SHOW);
  2381:             ShowWindow(hToolbarCalendarWnd, SW_SHOW);
  2382:         }
  2383:         else SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_ERROR_MESSAGE, (LPARAM)"Error creating hToolbarCalendarWnd!");
  2384:     }
  2385:     else
  2386:     {
  2387:         SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_REGULAR_MESSAGE, (LPARAM)"Closing calendar...");
  2388:         ShowWindow(hToolbarCalendarWnd, SW_HIDE);
  2389:         DestroyWindow(hToolbarCalendarChildWnd);
  2390:         hToolbarCalendarChildWnd = NULL;
  2391:         DestroyWindow(hToolbarCalendarWnd);
  2392:         hToolbarCalendarWnd = NULL;
  2393:     }
  2394: */
  2395: }
  2396: 
  2397: //====================
  2398: 
  2399: BOOL CALLBACK ToolbarCalendarWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  2400: {
  2401: /*
  2402:     switch (message)
  2403:     {
  2404:         case WM_INITDIALOG: { return TRUE; }
  2405:         default: { return FALSE; }
  2406:     }
  2407: */
  2408:     return FALSE;
  2409: }
  2410: 
  2411: //===========================================================================
  2412: