OSDN Git Service

Patch: [ 1541158 ] New high-color toolbar icons.
authorGal Hammer <galh@users.sourceforge.net>
Thu, 17 Aug 2006 05:40:37 +0000 (05:40 +0000)
committerGal Hammer <galh@users.sourceforge.net>
Thu, 17 Aug 2006 05:40:37 +0000 (05:40 +0000)
Src/BCMenu.cpp
Src/Changes.txt
Src/MainFrm.cpp
Src/MainFrm.h
Src/Merge.rc
Src/res/ToolbarDisabled.bmp [new file with mode: 0644]
Src/res/ToolbarEnabled.bmp [new file with mode: 0644]
Src/resource.h

index 55dec9d..e398f83 100644 (file)
@@ -775,8 +775,12 @@ void BCMenu::DrawItem_WinXP (LPDRAWITEMSTRUCT lpDIS)
                                                        DitherBlt(lpDIS->hDC,rect.left+dx,rect.top+dy,m_iconX,m_iconY,
                                                        (HBITMAP)(bitmapstandard),0,0,transparentcol);
                                                else
-                                                       DitherBlt2(pDC,rect.left+dx,rect.top+dy,m_iconX,m_iconY,
-                                                       bitmapstandard,0,0,transparentcol);
+                                                       if(hicolor_bitmaps)
+                                                               DitherBlt3(pDC,rect.left+dx,rect.top+dy,m_iconX,m_iconY,
+                                                               bitmapstandard,transparentcol);
+                                                       else
+                                                               DitherBlt2(pDC,rect.left+dx,rect.top+dy,m_iconX,m_iconY,
+                                                               bitmapstandard,0,0,transparentcol);
                                                if(state&ODS_SELECTED)pDC->Draw3dRect (rect,crSelect,crSelect);
                                                bitmapstandard.DeleteObject();
                                        }
@@ -2193,7 +2197,7 @@ void BCMenu::GetTransparentBitmap(CBitmap &bmp)
        CBitmap bmp2;
        ddc2.CreateCompatibleDC(NULL);
        bmp2.CreateCompatibleBitmap(&ddc,BitMap.bmWidth,BitMap.bmHeight);
-       col=RGB(192,192,192);
+       col=RGB(255,0,255); // Original was RGB(192,192,192)
        brush.CreateSolidBrush(col);
        CBitmap * pddcOldBmp2 = ddc2.SelectObject(&bmp2);
        CRect rect(0,0,BitMap.bmWidth,BitMap.bmHeight);
index 3c5f74a..c065ffe 100644 (file)
@@ -2,6 +2,11 @@ Src\Changes.txt
 Add new items to top.
 (This summarizes all changes to all files under Src, including Src\Languages.)
 
+2006-08-17 Gal
+ PATCH: [ 1541158 ] New high-color toolbar icons
+  Src: BCMenu.cpp MainFrm.cpp MainFrm.h Merge.rc resource.h
+  Src/res: ToolbarDisabled.bmp ToolbarEnabled.bmp
+
 2006-08-16 Takashi
  PATCH: [ 1539568 ] draw icon at modified line (it was changed to line revision marks)
   Src: GhostTextBuffer.cpp GhostTextBuffer.h MergeDoc.cpp MergeDoc.h
index 4405675..ca0df07 100644 (file)
@@ -89,6 +89,9 @@ static char THIS_FILE[] = __FILE__;
 extern CLogFile gLog;
 
 static BOOL add_regexp PARAMS((struct regexp_list **, char const*, BOOL bShowError));
+
+static void LoadToolbarImageList(UINT nIDResource, CImageList& ImgList);
+
 /////////////////////////////////////////////////////////////////////////////
 // CMainFrame
 
@@ -304,14 +307,11 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
        RebuildRegExpList(FALSE);
        GetFontProperties();
        
-       m_wndToolBar.SetBorders(1, 1, 1, 1);
-       if (!m_wndToolBar.Create(this, WS_CHILD|WS_VISIBLE|CBRS_GRIPPER|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC) ||
-               !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
+       if (!CreateToobar())
        {
                TRACE0("Failed to create toolbar\n");
                return -1;      // fail to create
        }
-       VERIFY(m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT));
        
        if (!m_wndStatusBar.Create(this) ||
                !m_wndStatusBar.SetIndicators(indicators,
@@ -325,18 +325,6 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
        if (m_options.GetBool(OPT_SHOW_STATUSBAR) == false)
                CMDIFrameWnd::ShowControlBar(&m_wndStatusBar, false, 0);
 
-       // TODO: Remove this if you don't want tool tips or a resizeable toolbar
-       m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
-               CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
-
-       // TODO: Delete these three lines if you don't want the toolbar to
-       //  be dockable
-       m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
-       EnableDocking(CBRS_ALIGN_ANY);
-       DockControlBar(&m_wndToolBar);
-       if (m_options.GetBool(OPT_SHOW_TOOLBAR) == false)
-               CMDIFrameWnd::ShowControlBar(&m_wndToolBar, false, 0);
-
        // CG: The following line was added by the Splash Screen component.
        CSplashWnd::ShowSplashScreen(this);
 
@@ -3129,3 +3117,63 @@ void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
                }
        }
 }
+
+BOOL CMainFrame::CreateToobar()
+{
+       if (!m_wndToolBar.Create(this, WS_CHILD|WS_VISIBLE|CBRS_GRIPPER|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC) ||
+               !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
+       {
+               return FALSE;
+       }
+
+       m_wndToolBar.SetBorders(1, 1, 1, 1);
+       VERIFY(m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT));
+
+       // Remove this if you don't want tool tips or a resizable toolbar
+       m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
+               CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+
+       // Delete these three lines if you don't want the toolbar to
+       // be dockable
+       m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
+       EnableDocking(CBRS_ALIGN_ANY);
+       DockControlBar(&m_wndToolBar);
+
+       LoadToolbarImageList(IDB_TOOLBAR_ENABLED, m_ToolbarImages[TOOLBAR_IMAGES_ENABLED]);
+       LoadToolbarImageList(IDB_TOOLBAR_DISABLED, m_ToolbarImages[TOOLBAR_IMAGES_DISABLED]);
+
+       CToolBarCtrl& BarCtrl = m_wndToolBar.GetToolBarCtrl();
+       BarCtrl.SetImageList(&m_ToolbarImages[TOOLBAR_IMAGES_ENABLED]);
+       BarCtrl.SetDisabledImageList(&m_ToolbarImages[TOOLBAR_IMAGES_DISABLED]);
+
+       if (m_options.GetBool(OPT_SHOW_TOOLBAR) == false)
+       {
+               CMDIFrameWnd::ShowControlBar(&m_wndToolBar, false, 0);
+       }
+
+       return TRUE;
+}
+
+/**
+ * @brief Load a transparent 24-bit color image list.
+ */
+static void LoadHiColImageList(UINT nIDResource, int nWidth, int nHeight, int nCount, CImageList& ImgList, COLORREF crMask = RGB(255,0,255))
+{
+       CBitmap bm;
+       VERIFY(bm.LoadBitmap(nIDResource));
+       VERIFY(ImgList.Create(nWidth, nHeight, ILC_COLORDDB|ILC_MASK, nCount, 0));
+       int nIndex = ImgList.Add(&bm, crMask);
+       ASSERT(-1 != nIndex);
+}
+
+/**
+ * @brief Load toolbar image list.
+ */
+static void LoadToolbarImageList(UINT nIDResource, CImageList& ImgList)
+{
+       static const int ImageWidth = 16;
+       static const int ImageHeight = 15;
+       static const int ImageCount     = 19;
+
+       LoadHiColImageList(nIDResource, ImageWidth, ImageHeight, ImageHeight, ImgList);
+}
index cff0a22..a70d23a 100644 (file)
@@ -198,6 +198,15 @@ protected:
 
        enum
        {
+               TOOLBAR_IMAGES_ENABLED,
+               TOOLBAR_IMAGES_DISABLED,
+               TOOLBAR_IMAGES_COUNT
+       };
+
+       CImageList m_ToolbarImages[TOOLBAR_IMAGES_COUNT];
+
+       enum
+       {
                MENU_DEFAULT,
                MENU_MERGEVIEW,
                MENU_DIRVIEW,
@@ -288,6 +297,7 @@ private:
        void ShowFontChangeMessage();
        void OptionsInit();
        void OpenFileOrUrl(LPCTSTR szFile, LPCTSTR szUrl);
+       BOOL CreateToobar();
        CMergeEditView * GetActiveMergeEditView();
 };
 
index 827a9f1..86e89c5 100644 (file)
@@ -1661,7 +1661,8 @@ IDR_SPLASH              IMAGE                   "res\\splash.jpg"
 // Bitmap
 //
 
-IDR_MAINFRAME           BITMAP                  "res\\Toolbar.bmp"
+IDB_TOOLBAR_ENABLED     BITMAP                  "res\\ToolbarEnabled.bmp"
+IDB_TOOLBAR_DISABLED    BITMAP                  "res\\ToolbarDisabled.bmp"
 IDB_EDIT_COPY           BITMAP                  "res\\copy.bmp"
 IDB_EDIT_CUT            BITMAP                  "res\\cut.bmp"
 IDB_EDIT_PASTE          BITMAP                  "res\\paste.bmp"
diff --git a/Src/res/ToolbarDisabled.bmp b/Src/res/ToolbarDisabled.bmp
new file mode 100644 (file)
index 0000000..436ed6c
Binary files /dev/null and b/Src/res/ToolbarDisabled.bmp differ
diff --git a/Src/res/ToolbarEnabled.bmp b/Src/res/ToolbarEnabled.bmp
new file mode 100644 (file)
index 0000000..c219393
Binary files /dev/null and b/Src/res/ToolbarEnabled.bmp differ
index 58cf47e..43114b5 100644 (file)
@@ -81,6 +81,8 @@
 #define IDB_EDIT_GOTO_NEXT_BOOKMARK     343
 #define IDB_EDIT_GOTO_PREV_BOOKMARK     344
 #define IDB_EDIT_CLEAR_ALL_BOOKMARKS    345
+#define IDB_TOOLBAR_ENABLED             100  // = IDR_MAINFRAME
+#define IDB_TOOLBAR_DISABLED            346
 #define IDI_FOLDER                      500
 #define IDI_LFOLDER                     501
 #define IDI_RFOLDER                     502