]> git.saurik.com Git - wxWidgets.git/commitdiff
Added SetToolNormalBitmap and SetToolDisabledBitmap
authorRobin Dunn <robin@alldunn.com>
Tue, 6 Feb 2007 21:13:03 +0000 (21:13 +0000)
committerRobin Dunn <robin@alldunn.com>
Tue, 6 Feb 2007 21:13:03 +0000 (21:13 +0000)
(ported from 2.8 branch)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44388 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/toolbar.tex
include/wx/gtk/tbargtk.h
include/wx/mac/carbon/toolbar.h
include/wx/msw/tbar95.h
include/wx/tbarbase.h
src/gtk/tbargtk.cpp
src/mac/carbon/toolbar.cpp
src/msw/tbar95.cpp

index 122767fb7982c1de9367a2356719798e631e87a5..400dd86252f51a46c20dbc67d279c095273d8150 100644 (file)
@@ -761,6 +761,17 @@ and not the eventual size of the tool button.
 Sets the client data associated with the tool.
 
 
+\membersection{wxToolBar::SetToolDisabledBitmap}\label{wxtoolbarsettooldisabledbitmap}
+
+\func{void}{SetToolDisabledBitmap}{\param{int }{id}, \param{const wxBitmap\& }{bitmap}}
+
+Sets the bitmap to be used by the tool with the given ID when the tool
+is in a disabled state.  This can only be used on Button tools, not
+controls.  NOTE: The native toolbar classes on the main platforms all
+synthesize the disabled bitmap from the normal bitmap, so this
+function will have no effect on those platforms.
+
+
 \membersection{wxToolBar::SetToolLongHelp}\label{wxtoolbarsettoollonghelp}
 
 \func{void}{SetToolLongHelp}{\param{int }{toolId}, \param{const wxString\& }{helpString}}
@@ -824,6 +835,15 @@ An application might use short help for identifying the tool purpose in a toolti
 \helpref{wxToolBar::GetToolShortHelp}{wxtoolbargettoolshorthelp}, \helpref{wxToolBar::SetToolLongHelp}{wxtoolbarsettoollonghelp}
 
 
+\membersection{wxToolBar::SetToolNormalBitmap}\label{wxtoolbarsettoolnormalbitmap}
+
+\func{void}{SetToolNormalBitmap}{\param{int }{id}, \param{const wxBitmap\& }{bitmap}}
+
+Sets the bitmap to be used by the tool with the given ID.  This can
+only be used on Button tools, not controls.
+
+
+
 \membersection{wxToolBar::SetToolSeparation}\label{wxtoolbarsettoolseparation}
 
 \func{void}{SetToolSeparation}{\param{int}{ separation}}
index 28fc7ee00bd8643d94964c45f1c5971de70a0c5d..bcf5da4a0d11b11b576edd8e11f157aa2ed6b259 100644 (file)
@@ -52,6 +52,9 @@ public:
 
     virtual void SetWindowStyleFlag( long style );
 
+    virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap);
+    virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap);
+    
     static wxVisualAttributes
     GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
     
index 62c91785e14e9f5ea9017d07d3995f67d5c8fe7b..7673d04a43e8a71e19f1b99f47509dd3b6510866 100644 (file)
@@ -57,7 +57,10 @@ class WXDLLEXPORT wxToolBar: public wxToolBarBase
 
     virtual void SetRows(int nRows);
 
-  // Add all the buttons
+    virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap);
+    virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap);
+
+    // Add all the buttons
 
     virtual wxString MacGetToolTipString( wxPoint &where ) ;
     void OnPaint(wxPaintEvent& event) ;
index daa168e3d63a4d0828abb4d64f0f34e7a9e612be..4a3be73333eb42aad3410d9c5c05b48e368465ef 100644 (file)
@@ -54,6 +54,9 @@ public:
 
     virtual void SetRows(int nRows);
 
+    virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap);
+    virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap);
+    
     // implementation only from now on
     // -------------------------------
 
index 3aa70ce99dc4b62ee6c8fb6dc4f1328275aa496b..7872e6670b2539abcc26419ddad9580919eea0b7 100644 (file)
@@ -372,6 +372,9 @@ public:
     virtual void SetToolLongHelp(int toolid, const wxString& helpString);
     virtual wxString GetToolLongHelp(int toolid) const;
 
+    virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap) {}
+    virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap) {}
+
     // margins/packing/separation
     // --------------------------
 
index 3ce3d74f7d16d2352051678fc8c4cbd08686d87d..f1e0bcc9ad4467c6ebfd72b4e2c35049c2603579 100644 (file)
@@ -597,6 +597,30 @@ void wxToolBar::SetToolShortHelp( int id, const wxString& helpString )
     }
 }
 
+void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap )
+{
+    wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
+    if ( tool )
+    {
+        wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
+
+        tool->SetNormalBitmap(bitmap);
+        tool->SetImage(tool->GetBitmap());
+    }    
+}
+
+void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap )
+{
+    wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
+    if ( tool )
+    {
+        wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
+
+        tool->SetDisabledBitmap(bitmap);
+        tool->SetImage(tool->GetBitmap());
+    }    
+}
+
 // ----------------------------------------------------------------------------
 // wxToolBar idle handling
 // ----------------------------------------------------------------------------
index 60e0a5cf9fccc300778f7656699138b46a813daa..f65ba6d135d456807ea3d6fab610680894125e2e 100644 (file)
@@ -168,10 +168,19 @@ public:
         m_toolbarItemRef = ref;
         if ( m_toolbarItemRef )
         {
+            wxFont f;
+            wxFontEncoding enc;
+            if ( GetToolBar() )
+                f = GetToolBar()->GetFont();
+            if ( f.IsOk() )
+                enc = f.GetEncoding();
+            else
+                enc = wxFont::GetDefaultEncoding();
+            
             HIToolbarItemSetHelpText(
                 m_toolbarItemRef,
-                wxMacCFStringHolder( GetShortHelp(), GetToolBar()->GetFont().GetEncoding() ),
-                wxMacCFStringHolder( GetLongHelp(), GetToolBar()->GetFont().GetEncoding() ) );
+                wxMacCFStringHolder( GetShortHelp(), enc ),
+                wxMacCFStringHolder( GetLongHelp(), enc ) );
         }
     }
 
@@ -1312,6 +1321,33 @@ void wxToolBar::MacSuperChangedPosition()
 #endif
 }
 
+void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap )
+{
+    wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
+    if ( tool )
+    {
+        wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
+
+        tool->SetNormalBitmap(bitmap);
+
+        // a side-effect of the UpdateToggleImage function is that it always changes the bitmap used on the button.
+        tool->UpdateToggleImage( tool->CanBeToggled() && tool->IsToggled() );
+    }    
+}
+
+void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap )
+{
+    wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
+    if ( tool )
+    {
+        wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
+
+        tool->SetDisabledBitmap(bitmap);
+        
+        // TODO:  what to do for this one?
+    }    
+}
+
 wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
 {
     wxToolBarTool *tool;
@@ -1365,6 +1401,7 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase)
     Rect toolrect = { 0, 0, toolSize.y, toolSize.x };
     ControlRef controlHandle = NULL;
     OSStatus err = 0;
+    tool->Attach( this );
 
     switch (tool->GetStyle())
     {
@@ -1494,7 +1531,6 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase)
             tool->UpdateToggleImage( true );
 
         // nothing special to do here - we relayout in Realize() later
-        tool->Attach( this );
         InvalidateBestSize();
     }
     else
index 8d5ad8a0c7d5dac72e86129dee9cb1d9a6d4a61b..5e4d811bf00016560be98d5686e6718b00814004 100644 (file)
@@ -1331,6 +1331,30 @@ void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(tog
     wxFAIL_MSG( _T("not implemented") );
 }
 
+void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap )
+{
+    wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
+    if ( tool )
+    {
+        wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
+
+        tool->SetNormalBitmap(bitmap);
+        Realize();
+    }    
+}
+
+void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap )
+{
+    wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
+    if ( tool )
+    {
+        wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
+
+        tool->SetDisabledBitmap(bitmap);
+        Realize();
+    }    
+}
+
 // ----------------------------------------------------------------------------
 // event handlers
 // ----------------------------------------------------------------------------