]> git.saurik.com Git - wxWidgets.git/commitdiff
Add support for icons in wxAUI panes title bars.
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 12 Jan 2011 13:39:36 +0000 (13:39 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 12 Jan 2011 13:39:36 +0000 (13:39 +0000)
Add wxAuiPaneInfo::Icon() method and shows its use in the sample.

Closes #12856.

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

docs/changes.txt
include/wx/aui/dockart.h
include/wx/aui/framemanager.h
interface/wx/aui/framemanager.h
samples/aui/auidemo.cpp
src/aui/dockart.cpp

index bfb639063235c4459a6dd48b969390d4a4dacda1..3f35549ed63916ed918de5c66cc67e7fcceec569 100644 (file)
@@ -433,6 +433,7 @@ All (GUI):
 - Added wxCommandLinkButton (Rickard Westerlund, GSoC 2010 project).
 - Added wxUIActionSimulator (Steven Lamerton, GSoC 2010 project).
 - wxAUI: support auto-orientable toolbars (wsu).
+- wxAUI: add support for icons in pane title bars (triton).
 - Added wxDataViewCtrl::Set/GetCurrentItem().
 - Added possibility to disable individual wxDataViewCtrl items (Neno Ganchev).
 - wxHTML: render in RTL order inside RTL window (Richard Bullington-McGuire).
index 444308bdc99acadadc90357dbdeaeb84bf33368b..027f399644ff6d291ae7862e33d80c41076ea054 100644 (file)
@@ -130,6 +130,10 @@ public:
                   const wxRect& rect,
                   wxAuiPaneInfo& pane);
 
+    void DrawIcon(wxDC& dc,
+                  const wxRect& rect,
+                  wxAuiPaneInfo& pane);
+
 protected:
 
     void DrawCaptionBackground(wxDC& dc, const wxRect& rect, bool active);
index ef5be06f56c6e455ccadebb836c126601b1770d2..73a452efacf57b61f698d998a5c278522b2cfcec 100644 (file)
@@ -173,6 +173,7 @@ public:
     {
         name = c.name;
         caption = c.caption;
+        icon = c.icon;
         window = c.window;
         frame = c.frame;
         state = c.state;
@@ -271,6 +272,7 @@ public:
     }
     wxAuiPaneInfo& Name(const wxString& n) { name = n; return *this; }
     wxAuiPaneInfo& Caption(const wxString& c) { caption = c; return *this; }
+    wxAuiPaneInfo& Icon(const wxBitmap& b) { icon = b; return *this; }
     wxAuiPaneInfo& Left() { dock_direction = wxAUI_DOCK_LEFT; return *this; }
     wxAuiPaneInfo& Right() { dock_direction = wxAUI_DOCK_RIGHT; return *this; }
     wxAuiPaneInfo& Top() { dock_direction = wxAUI_DOCK_TOP; return *this; }
@@ -418,6 +420,7 @@ public:
 public:
     wxString name;        // name of the pane
     wxString caption;     // caption displayed on the window
+    wxBitmap icon;        // icon of the pane, may be invalid
 
     wxWindow* window;     // window that is in this pane
     wxFrame* frame;       // floating frame window that holds the pane
@@ -438,6 +441,7 @@ public:
 
     wxAuiPaneButtonArray buttons; // buttons on the pane
 
+
     wxRect rect;              // current rectangle (populated by wxAUI)
 
     bool IsValid() const;
index 36855b16a164475c384378851ec6357dc7256265..ba58430ce5d058a5eea06431a32a36a15263cf7c 100644 (file)
@@ -570,6 +570,17 @@ public:
     */
     wxAuiPaneInfo& Hide();
 
+    /**
+        Icon() sets the icon of the pane.
+
+        Notice that the height of the icon should be smaller than the value
+        returned by wxAuiDockArt::GetMetric(wxAUI_DOCKART_CAPTION_SIZE) to
+        ensure that it appears correctly.
+
+        @since 2.9.2
+    */
+    wxAuiPaneInfo& Icon(const wxBitmap& b);
+
     /**
         IsBottomDockable() returns @true if the pane can be docked at the bottom of the
         managed frame.
index 33dbaac0caea09cd5dd6baca26bb3dfbaa330c70..570138976d0d335b44f510c9341bc5f605119ff6 100644 (file)
@@ -916,9 +916,19 @@ MyFrame::MyFrame(wxWindow* parent,
                   CloseButton(true).MaximizeButton(true));
 
     wxWindow* wnd10 = CreateTextCtrl(wxT("This pane will prompt the user before hiding."));
+
+    // Give this pane an icon, too, just for testing.
+    int iconSize = m_mgr.GetArtProvider()->GetMetric(wxAUI_DOCKART_CAPTION_SIZE);
+
+    // Make it even to use 16 pixel icons with default 17 caption height.
+    iconSize &= ~1;
+
     m_mgr.AddPane(wnd10, wxAuiPaneInfo().
                   Name(wxT("test10")).Caption(wxT("Text Pane with Hide Prompt")).
-                  Bottom().Layer(1).Position(1));
+                  Bottom().Layer(1).Position(1).
+                  Icon(wxArtProvider::GetBitmap(wxART_WARNING,
+                                                wxART_OTHER,
+                                                wxSize(iconSize, iconSize))));
 
     m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
                   Name(wxT("test11")).Caption(wxT("Fixed Pane")).
index 3d9675b2baa5bb3dab3582327c3b8baabe5abebb..003b47aa3fce3d3d59f10d2a284a2d2fc56def08 100644 (file)
@@ -547,6 +547,14 @@ void wxAuiDefaultDockArt::DrawCaption(wxDC& dc, wxWindow *WXUNUSED(window),
     DrawCaptionBackground(dc, rect,
                           (pane.state & wxAuiPaneInfo::optionActive)?true:false);
 
+    int caption_offset = 0;
+    if ( pane.icon.IsOk() )
+    {
+        DrawIcon(dc, rect, pane);
+
+        caption_offset += pane.icon.GetWidth() + 3;
+    }
+
     if (pane.state & wxAuiPaneInfo::optionActive)
         dc.SetTextForeground(m_active_caption_text_colour);
     else
@@ -569,10 +577,19 @@ void wxAuiDefaultDockArt::DrawCaption(wxDC& dc, wxWindow *WXUNUSED(window),
     wxString draw_text = wxAuiChopText(dc, text, clip_rect.width);
 
     dc.SetClippingRegion(clip_rect);
-    dc.DrawText(draw_text, rect.x+3, rect.y+(rect.height/2)-(h/2)-1);
+    dc.DrawText(draw_text, rect.x+3 + caption_offset, rect.y+(rect.height/2)-(h/2)-1);
     dc.DestroyClippingRegion();
 }
 
+void
+wxAuiDefaultDockArt::DrawIcon(wxDC& dc, const wxRect& rect, wxAuiPaneInfo& pane)
+{
+   // Draw the icon centered vertically
+   dc.DrawBitmap(pane.icon,
+                 rect.x+2, rect.y+(rect.height-pane.icon.GetHeight())/2,
+                 true);
+}
+
 void wxAuiDefaultDockArt::DrawGripper(wxDC& dc, wxWindow *WXUNUSED(window),
                                    const wxRect& rect,
                                    wxAuiPaneInfo& pane)