Add support for icons in wxAUI panes title bars.
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
This commit is contained in:
parent
17731af57d
commit
4254f67216
@ -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).
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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")).
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user