Use wxBitmapBundle in wxAuiToolBar and wxAuiPaneInfo too
Allow specifying bitmap bundles instead of single bitmaps for the AUI toolbar images and pane icons.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#if wxUSE_AUI
|
||||
|
||||
#include "wx/bmpbndl.h"
|
||||
#include "wx/control.h"
|
||||
#include "wx/sizer.h"
|
||||
#include "wx/pen.h"
|
||||
@@ -165,14 +166,22 @@ public:
|
||||
void SetLabel(const wxString& s) { m_label = s; }
|
||||
const wxString& GetLabel() const { return m_label; }
|
||||
|
||||
void SetBitmap(const wxBitmap& bmp) { m_bitmap = bmp; }
|
||||
const wxBitmap& GetBitmap() const { return m_bitmap; }
|
||||
void SetBitmap(const wxBitmapBundle& bmp) { m_bitmap = bmp; }
|
||||
const wxBitmapBundle& GetBitmapBundle() const { return m_bitmap; }
|
||||
wxBitmap GetBitmapFor(wxWindow* wnd) const { return m_bitmap.GetBitmapFor(wnd); }
|
||||
wxBitmap GetBitmap() const { return GetBitmapFor(m_window); }
|
||||
|
||||
void SetDisabledBitmap(const wxBitmap& bmp) { m_disabledBitmap = bmp; }
|
||||
const wxBitmap& GetDisabledBitmap() const { return m_disabledBitmap; }
|
||||
void SetDisabledBitmap(const wxBitmapBundle& bmp) { m_disabledBitmap = bmp; }
|
||||
const wxBitmapBundle& GetDisabledBitmapBundle() const { return m_disabledBitmap; }
|
||||
wxBitmap GetDisabledBitmapFor(wxWindow* wnd) const { return m_disabledBitmap.GetBitmapFor(wnd); }
|
||||
wxBitmap GetDisabledBitmap() const { return GetBitmapFor(m_window); }
|
||||
|
||||
void SetHoverBitmap(const wxBitmap& bmp) { m_hoverBitmap = bmp; }
|
||||
const wxBitmap& GetHoverBitmap() const { return m_hoverBitmap; }
|
||||
// Return the bitmap for the current state, normal or disabled.
|
||||
wxBitmap GetCurrentBitmapFor(wxWindow* wnd) const;
|
||||
|
||||
void SetHoverBitmap(const wxBitmapBundle& bmp) { m_hoverBitmap = bmp; }
|
||||
const wxBitmapBundle& GetHoverBitmapBundle() const { return m_hoverBitmap; }
|
||||
wxBitmap GetHoverBitmap() const { return m_hoverBitmap.GetBitmapFor(m_window); }
|
||||
|
||||
void SetShortHelp(const wxString& s) { m_shortHelp = s; }
|
||||
const wxString& GetShortHelp() const { return m_shortHelp; }
|
||||
@@ -220,9 +229,9 @@ private:
|
||||
|
||||
wxWindow* m_window; // item's associated window
|
||||
wxString m_label; // label displayed on the item
|
||||
wxBitmap m_bitmap; // item's bitmap
|
||||
wxBitmap m_disabledBitmap; // item's disabled bitmap
|
||||
wxBitmap m_hoverBitmap; // item's hover bitmap
|
||||
wxBitmapBundle m_bitmap; // item's bitmap
|
||||
wxBitmapBundle m_disabledBitmap; // item's disabled bitmap
|
||||
wxBitmapBundle m_hoverBitmap; // item's hover bitmap
|
||||
wxString m_shortHelp; // short help (for tooltip)
|
||||
wxString m_longHelp; // long help (for status bar)
|
||||
wxSizerItem* m_sizerItem; // sizer item
|
||||
@@ -424,10 +433,10 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
wxBitmap m_buttonDropDownBmp;
|
||||
wxBitmap m_disabledButtonDropDownBmp;
|
||||
wxBitmap m_overflowBmp;
|
||||
wxBitmap m_disabledOverflowBmp;
|
||||
wxBitmapBundle m_buttonDropDownBmp;
|
||||
wxBitmapBundle m_disabledButtonDropDownBmp;
|
||||
wxBitmapBundle m_overflowBmp;
|
||||
wxBitmapBundle m_disabledOverflowBmp;
|
||||
wxColour m_baseColour;
|
||||
wxColour m_highlightColour;
|
||||
wxFont m_font;
|
||||
@@ -481,22 +490,22 @@ public:
|
||||
|
||||
wxAuiToolBarItem* AddTool(int toolId,
|
||||
const wxString& label,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmapBundle& bitmap,
|
||||
const wxString& shortHelpString = wxEmptyString,
|
||||
wxItemKind kind = wxITEM_NORMAL);
|
||||
|
||||
wxAuiToolBarItem* AddTool(int toolId,
|
||||
const wxString& label,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmap& disabledBitmap,
|
||||
const wxBitmapBundle& bitmap,
|
||||
const wxBitmapBundle& disabledBitmap,
|
||||
wxItemKind kind,
|
||||
const wxString& shortHelpString,
|
||||
const wxString& longHelpString,
|
||||
wxObject* clientData);
|
||||
|
||||
wxAuiToolBarItem* AddTool(int toolId,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmap& disabledBitmap,
|
||||
const wxBitmapBundle& bitmap,
|
||||
const wxBitmapBundle& disabledBitmap,
|
||||
bool toggle = false,
|
||||
wxObject* clientData = NULL,
|
||||
const wxString& shortHelpString = wxEmptyString,
|
||||
@@ -591,7 +600,7 @@ public:
|
||||
void SetToolLabel(int toolId, const wxString& label);
|
||||
|
||||
wxBitmap GetToolBitmap(int toolId) const;
|
||||
void SetToolBitmap(int toolId, const wxBitmap& bitmap);
|
||||
void SetToolBitmap(int toolId, const wxBitmapBundle& bitmap);
|
||||
|
||||
wxString GetToolShortHelp(int toolId) const;
|
||||
void SetToolShortHelp(int toolId, const wxString& helpString);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "wx/pen.h"
|
||||
#include "wx/brush.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/bmpbndl.h"
|
||||
#include "wx/colour.h"
|
||||
|
||||
// dock art provider code - a dock provider provides all drawing
|
||||
@@ -159,14 +159,14 @@ protected:
|
||||
wxBrush m_backgroundBrush;
|
||||
wxBrush m_gripperBrush;
|
||||
wxFont m_captionFont;
|
||||
wxBitmap m_inactiveCloseBitmap;
|
||||
wxBitmap m_inactivePinBitmap;
|
||||
wxBitmap m_inactiveMaximizeBitmap;
|
||||
wxBitmap m_inactiveRestoreBitmap;
|
||||
wxBitmap m_activeCloseBitmap;
|
||||
wxBitmap m_activePinBitmap;
|
||||
wxBitmap m_activeMaximizeBitmap;
|
||||
wxBitmap m_activeRestoreBitmap;
|
||||
wxBitmapBundle m_inactiveCloseBitmap;
|
||||
wxBitmapBundle m_inactivePinBitmap;
|
||||
wxBitmapBundle m_inactiveMaximizeBitmap;
|
||||
wxBitmapBundle m_inactiveRestoreBitmap;
|
||||
wxBitmapBundle m_activeCloseBitmap;
|
||||
wxBitmapBundle m_activePinBitmap;
|
||||
wxBitmapBundle m_activeMaximizeBitmap;
|
||||
wxBitmapBundle m_activeRestoreBitmap;
|
||||
wxPen m_gripperPen1;
|
||||
wxPen m_gripperPen2;
|
||||
wxPen m_gripperPen3;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "wx/window.h"
|
||||
#include "wx/timer.h"
|
||||
#include "wx/sizer.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/bmpbndl.h"
|
||||
|
||||
enum wxAuiManagerDock
|
||||
{
|
||||
@@ -223,7 +223,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& Icon(const wxBitmapBundle& 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; }
|
||||
@@ -371,7 +371,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
|
||||
wxBitmapBundle 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
|
||||
|
||||
@@ -299,29 +299,29 @@ public:
|
||||
/**
|
||||
|
||||
*/
|
||||
void SetBitmap(const wxBitmap& bmp);
|
||||
void SetBitmap(const wxBitmapBundle& bmp);
|
||||
/**
|
||||
|
||||
*/
|
||||
const wxBitmap& GetBitmap() const;
|
||||
wxBitmap GetBitmap() const;
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
void SetDisabledBitmap(const wxBitmap& bmp);
|
||||
void SetDisabledBitmap(const wxBitmapBundle& bmp);
|
||||
/**
|
||||
|
||||
*/
|
||||
const wxBitmap& GetDisabledBitmap() const;
|
||||
wxBitmap GetDisabledBitmap() const;
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
void SetHoverBitmap(const wxBitmap& bmp);
|
||||
void SetHoverBitmap(const wxBitmapBundle& bmp);
|
||||
/**
|
||||
|
||||
*/
|
||||
const wxBitmap& GetHoverBitmap() const;
|
||||
wxBitmap GetHoverBitmap() const;
|
||||
|
||||
/**
|
||||
|
||||
@@ -705,22 +705,22 @@ public:
|
||||
|
||||
wxAuiToolBarItem* AddTool(int toolId,
|
||||
const wxString& label,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmapBundle& bitmap,
|
||||
const wxString& short_help_string = wxEmptyString,
|
||||
wxItemKind kind = wxITEM_NORMAL);
|
||||
|
||||
wxAuiToolBarItem* AddTool(int toolId,
|
||||
const wxString& label,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmap& disabled_bitmap,
|
||||
const wxBitmapBundle& bitmap,
|
||||
const wxBitmapBundle& disabled_bitmap,
|
||||
wxItemKind kind,
|
||||
const wxString& short_help_string,
|
||||
const wxString& long_help_string,
|
||||
wxObject* client_data);
|
||||
|
||||
wxAuiToolBarItem* AddTool(int toolId,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmap& disabled_bitmap,
|
||||
const wxBitmapBundle& bitmap,
|
||||
const wxBitmapBundle& disabled_bitmap,
|
||||
bool toggle = false,
|
||||
wxObject* client_data = NULL,
|
||||
const wxString& short_help_string = wxEmptyString,
|
||||
@@ -861,7 +861,7 @@ public:
|
||||
void SetToolLabel(int toolId, const wxString& label);
|
||||
|
||||
wxBitmap GetToolBitmap(int toolId) const;
|
||||
void SetToolBitmap(int toolId, const wxBitmap& bitmap);
|
||||
void SetToolBitmap(int toolId, const wxBitmapBundle& bitmap);
|
||||
|
||||
wxString GetToolShortHelp(int toolId) const;
|
||||
void SetToolShortHelp(int toolId, const wxString& help_string);
|
||||
|
||||
@@ -745,7 +745,7 @@ public:
|
||||
|
||||
@since 2.9.2
|
||||
*/
|
||||
wxAuiPaneInfo& Icon(const wxBitmap& b);
|
||||
wxAuiPaneInfo& Icon(const wxBitmapBundle& b);
|
||||
|
||||
/**
|
||||
IsBottomDockable() returns @true if the pane can be docked at the bottom of the
|
||||
|
||||
@@ -112,6 +112,23 @@ private:
|
||||
int m_lastId;
|
||||
};
|
||||
|
||||
wxBitmap wxAuiToolBarItem::GetCurrentBitmapFor(wxWindow* wnd) const
|
||||
{
|
||||
// We suppose that we don't have disabled bitmap if we don't have the
|
||||
// normal one neither.
|
||||
if ( !m_bitmap.IsOk() )
|
||||
return wxNullBitmap;
|
||||
|
||||
if ( m_state & wxAUI_BUTTON_STATE_DISABLED )
|
||||
{
|
||||
if ( m_disabledBitmap.IsOk() )
|
||||
return m_disabledBitmap.GetBitmapFor(wnd);
|
||||
|
||||
return m_bitmap.GetBitmapFor(wnd).ConvertToDisabled();
|
||||
}
|
||||
|
||||
return m_bitmap.GetBitmapFor(wnd);
|
||||
}
|
||||
|
||||
wxAuiGenericToolBarArt::wxAuiGenericToolBarArt()
|
||||
{
|
||||
@@ -280,10 +297,7 @@ void wxAuiGenericToolBarArt::DrawButton(
|
||||
int bmpX = 0, bmpY = 0;
|
||||
int textX = 0, textY = 0;
|
||||
|
||||
const wxBitmap& bmp = item.GetState() & wxAUI_BUTTON_STATE_DISABLED
|
||||
? item.GetDisabledBitmap()
|
||||
: item.GetBitmap();
|
||||
|
||||
const wxBitmap& bmp = item.GetCurrentBitmapFor(wnd);
|
||||
const wxSize bmpSize = bmp.IsOk() ? bmp.GetScaledSize() : wxSize(0, 0);
|
||||
|
||||
if (m_textOrientation == wxAUI_TBTOOL_TEXT_BOTTOM)
|
||||
@@ -396,22 +410,25 @@ void wxAuiGenericToolBarArt::DrawDropDownButton(
|
||||
|
||||
|
||||
|
||||
const wxSize sizeDropDown = m_buttonDropDownBmp.GetPreferredSizeFor(wnd);
|
||||
dropBmpX = dropDownRect.x +
|
||||
(dropDownRect.width/2) -
|
||||
(m_buttonDropDownBmp.GetScaledWidth()/2);
|
||||
(sizeDropDown.x/2);
|
||||
dropBmpY = dropDownRect.y +
|
||||
(dropDownRect.height/2) -
|
||||
(m_buttonDropDownBmp.GetScaledHeight()/2);
|
||||
(sizeDropDown.y/2);
|
||||
|
||||
|
||||
const wxBitmap& bmp = item.GetCurrentBitmapFor(wnd);
|
||||
|
||||
if (m_textOrientation == wxAUI_TBTOOL_TEXT_BOTTOM)
|
||||
{
|
||||
bmpX = buttonRect.x +
|
||||
(buttonRect.width/2) -
|
||||
(item.GetBitmap().GetScaledWidth()/2);
|
||||
(bmp.GetScaledWidth()/2);
|
||||
bmpY = buttonRect.y +
|
||||
((buttonRect.height-textHeight)/2) -
|
||||
(item.GetBitmap().GetScaledHeight()/2);
|
||||
(bmp.GetScaledHeight()/2);
|
||||
|
||||
textX = rect.x + (rect.width/2) - (textWidth/2) + 1;
|
||||
textY = rect.y + rect.height - textHeight - 1;
|
||||
@@ -422,9 +439,9 @@ void wxAuiGenericToolBarArt::DrawDropDownButton(
|
||||
|
||||
bmpY = rect.y +
|
||||
(rect.height/2) -
|
||||
(item.GetBitmap().GetScaledHeight()/2);
|
||||
(bmp.GetScaledHeight()/2);
|
||||
|
||||
textX = bmpX + wnd->FromDIP(3) + item.GetBitmap().GetScaledWidth();
|
||||
textX = bmpX + wnd->FromDIP(3) + bmp.GetScaledWidth();
|
||||
textY = rect.y +
|
||||
(rect.height/2) -
|
||||
(textHeight/2);
|
||||
@@ -458,24 +475,21 @@ void wxAuiGenericToolBarArt::DrawDropDownButton(
|
||||
dc.DrawRectangle(dropDownRect);
|
||||
}
|
||||
|
||||
wxBitmap bmp;
|
||||
wxBitmap dropbmp;
|
||||
if (!bmp.IsOk())
|
||||
return;
|
||||
|
||||
wxBitmapBundle dropbmp;
|
||||
if (item.GetState() & wxAUI_BUTTON_STATE_DISABLED)
|
||||
{
|
||||
bmp = item.GetDisabledBitmap();
|
||||
dropbmp = m_disabledButtonDropDownBmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
bmp = item.GetBitmap();
|
||||
dropbmp = m_buttonDropDownBmp;
|
||||
}
|
||||
|
||||
if (!bmp.IsOk())
|
||||
return;
|
||||
|
||||
dc.DrawBitmap(bmp, bmpX, bmpY, true);
|
||||
dc.DrawBitmap(dropbmp, dropBmpX, dropBmpY, true);
|
||||
dc.DrawBitmap(dropbmp.GetBitmapFor(wnd), dropBmpX, dropBmpY, true);
|
||||
|
||||
// set the item's text color based on if it is disabled
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
||||
@@ -560,10 +574,10 @@ wxSize wxAuiGenericToolBarArt::GetToolSize(
|
||||
wxWindow* wnd,
|
||||
const wxAuiToolBarItem& item)
|
||||
{
|
||||
if (!item.GetBitmap().IsOk() && !(m_flags & wxAUI_TB_TEXT))
|
||||
const wxBitmap& bmp = item.GetBitmapBundle().GetBitmapFor(wnd);
|
||||
if (!bmp.IsOk() && !(m_flags & wxAUI_TB_TEXT))
|
||||
return wnd->FromDIP(wxSize(16,16));
|
||||
|
||||
const wxBitmap& bmp = item.GetBitmap();
|
||||
int width = bmp.IsOk() ? bmp.GetScaledWidth() : 0;
|
||||
int height = bmp.IsOk() ? bmp.GetScaledHeight() : 0;
|
||||
|
||||
@@ -682,7 +696,7 @@ void wxAuiGenericToolBarArt::DrawGripper(wxDC& dc,
|
||||
}
|
||||
|
||||
void wxAuiGenericToolBarArt::DrawOverflowButton(wxDC& dc,
|
||||
wxWindow* WXUNUSED(wnd),
|
||||
wxWindow* wnd,
|
||||
const wxRect& rect,
|
||||
int state)
|
||||
{
|
||||
@@ -709,9 +723,10 @@ void wxAuiGenericToolBarArt::DrawOverflowButton(wxDC& dc,
|
||||
}
|
||||
}
|
||||
|
||||
int x = rect.x+1+(rect.width-m_overflowBmp.GetScaledWidth())/2;
|
||||
int y = rect.y+1+(rect.height-m_overflowBmp.GetScaledHeight())/2;
|
||||
dc.DrawBitmap(m_overflowBmp, x, y, true);
|
||||
const wxBitmap overflowBmp = m_overflowBmp.GetBitmapFor(wnd);
|
||||
int x = rect.x+1+(rect.width-overflowBmp.GetScaledWidth())/2;
|
||||
int y = rect.y+1+(rect.height-overflowBmp.GetScaledHeight())/2;
|
||||
dc.DrawBitmap(overflowBmp, x, y, true);
|
||||
}
|
||||
|
||||
int wxAuiGenericToolBarArt::GetElementSize(int element_id)
|
||||
@@ -760,7 +775,7 @@ int wxAuiGenericToolBarArt::ShowDropDown(wxWindow* wnd,
|
||||
|
||||
wxMenuItem* m = new wxMenuItem(&menuPopup, item.GetId(), text, item.GetShortHelp());
|
||||
|
||||
m->SetBitmap(item.GetBitmap());
|
||||
m->SetBitmap(item.GetBitmapBundle().GetBitmapFor(wnd));
|
||||
menuPopup.Append(m);
|
||||
items_added++;
|
||||
}
|
||||
@@ -946,14 +961,14 @@ wxAuiToolBarArt* wxAuiToolBar::GetArtProvider() const
|
||||
|
||||
wxAuiToolBarItem* wxAuiToolBar::AddTool(int tool_id,
|
||||
const wxString& label,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmapBundle& bitmap,
|
||||
const wxString& shortHelp_string,
|
||||
wxItemKind kind)
|
||||
{
|
||||
return AddTool(tool_id,
|
||||
label,
|
||||
bitmap,
|
||||
wxNullBitmap,
|
||||
wxBitmapBundle(),
|
||||
kind,
|
||||
shortHelp_string,
|
||||
wxEmptyString,
|
||||
@@ -963,8 +978,8 @@ wxAuiToolBarItem* wxAuiToolBar::AddTool(int tool_id,
|
||||
|
||||
wxAuiToolBarItem* wxAuiToolBar::AddTool(int tool_id,
|
||||
const wxString& label,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmap& disabledBitmap,
|
||||
const wxBitmapBundle& bitmap,
|
||||
const wxBitmapBundle& disabledBitmap,
|
||||
wxItemKind kind,
|
||||
const wxString& shortHelpString,
|
||||
const wxString& longHelpString,
|
||||
@@ -992,14 +1007,6 @@ wxAuiToolBarItem* wxAuiToolBar::AddTool(int tool_id,
|
||||
if (item.m_toolId == wxID_ANY)
|
||||
item.m_toolId = wxNewId();
|
||||
|
||||
if (!item.m_disabledBitmap.IsOk())
|
||||
{
|
||||
// no disabled bitmap specified, we need to make one
|
||||
if (item.m_bitmap.IsOk())
|
||||
{
|
||||
item.m_disabledBitmap = item.m_bitmap.ConvertToDisabled();
|
||||
}
|
||||
}
|
||||
m_items.Add(item);
|
||||
return &m_items.Last();
|
||||
}
|
||||
@@ -1010,8 +1017,8 @@ wxAuiToolBarItem* wxAuiToolBar::AddControl(wxControl* control,
|
||||
wxAuiToolBarItem item;
|
||||
item.m_window = (wxWindow*)control;
|
||||
item.m_label = label;
|
||||
item.m_bitmap = wxNullBitmap;
|
||||
item.m_disabledBitmap = wxNullBitmap;
|
||||
item.m_bitmap = wxBitmapBundle();
|
||||
item.m_disabledBitmap = wxBitmapBundle();
|
||||
item.m_active = true;
|
||||
item.m_dropDown = false;
|
||||
item.m_spacerPixels = 0;
|
||||
@@ -1039,8 +1046,8 @@ wxAuiToolBarItem* wxAuiToolBar::AddLabel(int tool_id,
|
||||
wxAuiToolBarItem item;
|
||||
item.m_window = NULL;
|
||||
item.m_label = label;
|
||||
item.m_bitmap = wxNullBitmap;
|
||||
item.m_disabledBitmap = wxNullBitmap;
|
||||
item.m_bitmap = wxBitmapBundle();
|
||||
item.m_disabledBitmap = wxBitmapBundle();
|
||||
item.m_active = true;
|
||||
item.m_dropDown = false;
|
||||
item.m_spacerPixels = 0;
|
||||
@@ -1065,8 +1072,8 @@ wxAuiToolBarItem* wxAuiToolBar::AddSeparator()
|
||||
wxAuiToolBarItem item;
|
||||
item.m_window = NULL;
|
||||
item.m_label = wxEmptyString;
|
||||
item.m_bitmap = wxNullBitmap;
|
||||
item.m_disabledBitmap = wxNullBitmap;
|
||||
item.m_bitmap = wxBitmapBundle();
|
||||
item.m_disabledBitmap = wxBitmapBundle();
|
||||
item.m_active = true;
|
||||
item.m_dropDown = false;
|
||||
item.m_toolId = -1;
|
||||
@@ -1087,8 +1094,8 @@ wxAuiToolBarItem* wxAuiToolBar::AddSpacer(int pixels)
|
||||
wxAuiToolBarItem item;
|
||||
item.m_window = NULL;
|
||||
item.m_label = wxEmptyString;
|
||||
item.m_bitmap = wxNullBitmap;
|
||||
item.m_disabledBitmap = wxNullBitmap;
|
||||
item.m_bitmap = wxBitmapBundle();
|
||||
item.m_disabledBitmap = wxBitmapBundle();
|
||||
item.m_active = true;
|
||||
item.m_dropDown = false;
|
||||
item.m_spacerPixels = pixels;
|
||||
@@ -1110,8 +1117,8 @@ wxAuiToolBarItem* wxAuiToolBar::AddStretchSpacer(int proportion)
|
||||
wxAuiToolBarItem item;
|
||||
item.m_window = NULL;
|
||||
item.m_label = wxEmptyString;
|
||||
item.m_bitmap = wxNullBitmap;
|
||||
item.m_disabledBitmap = wxNullBitmap;
|
||||
item.m_bitmap = wxBitmapBundle();
|
||||
item.m_disabledBitmap = wxBitmapBundle();
|
||||
item.m_active = true;
|
||||
item.m_dropDown = false;
|
||||
item.m_spacerPixels = 0;
|
||||
@@ -1639,10 +1646,10 @@ wxBitmap wxAuiToolBar::GetToolBitmap(int tool_id) const
|
||||
if (!tool)
|
||||
return wxNullBitmap;
|
||||
|
||||
return tool->m_bitmap;
|
||||
return tool->m_bitmap.GetBitmapFor(this);
|
||||
}
|
||||
|
||||
void wxAuiToolBar::SetToolBitmap(int tool_id, const wxBitmap& bitmap)
|
||||
void wxAuiToolBar::SetToolBitmap(int tool_id, const wxBitmapBundle& bitmap)
|
||||
{
|
||||
wxAuiToolBarItem* tool = FindTool(tool_id);
|
||||
if (tool)
|
||||
|
||||
@@ -153,15 +153,16 @@ void wxAuiMSWToolBarArt::DrawButton(
|
||||
int bmpX = 0, bmpY = 0;
|
||||
int textX = 0, textY = 0;
|
||||
|
||||
const wxBitmap& bmp = item.GetCurrentBitmapFor(wnd);
|
||||
if ( m_textOrientation == wxAUI_TBTOOL_TEXT_BOTTOM )
|
||||
{
|
||||
bmpX = rect.x +
|
||||
(rect.width / 2) -
|
||||
(item.GetBitmap().GetWidth() / 2);
|
||||
(bmp.GetWidth() / 2);
|
||||
|
||||
bmpY = rect.y +
|
||||
((rect.height - textHeight) / 2) -
|
||||
(item.GetBitmap().GetHeight() / 2);
|
||||
(bmp.GetHeight() / 2);
|
||||
|
||||
textX = rect.x + (rect.width / 2) - (textWidth / 2) + 1;
|
||||
textY = rect.y + rect.height - textHeight - 1;
|
||||
@@ -172,20 +173,14 @@ void wxAuiMSWToolBarArt::DrawButton(
|
||||
|
||||
bmpY = rect.y +
|
||||
(rect.height / 2) -
|
||||
(item.GetBitmap().GetHeight() / 2);
|
||||
(bmp.GetHeight() / 2);
|
||||
|
||||
textX = bmpX + wnd->FromDIP(3) + item.GetBitmap().GetWidth();
|
||||
textX = bmpX + wnd->FromDIP(3) + bmp.GetWidth();
|
||||
textY = rect.y +
|
||||
(rect.height / 2) -
|
||||
(textHeight / 2);
|
||||
}
|
||||
|
||||
wxBitmap bmp;
|
||||
if ( item.GetState() & wxAUI_BUTTON_STATE_DISABLED )
|
||||
bmp = item.GetDisabledBitmap();
|
||||
else
|
||||
bmp = item.GetBitmap();
|
||||
|
||||
if ( bmp.IsOk() )
|
||||
dc.DrawBitmap(bmp, bmpX, bmpY, true);
|
||||
|
||||
@@ -271,14 +266,18 @@ void wxAuiMSWToolBarArt::DrawDropDownButton(
|
||||
&dropDownR,
|
||||
NULL);
|
||||
|
||||
const wxBitmap& bmp = item.GetCurrentBitmapFor(wnd);
|
||||
if ( !bmp.IsOk() )
|
||||
return;
|
||||
|
||||
if ( m_textOrientation == wxAUI_TBTOOL_TEXT_BOTTOM )
|
||||
{
|
||||
bmpX = buttonRect.x +
|
||||
(buttonRect.width / 2) -
|
||||
(item.GetBitmap().GetWidth() / 2);
|
||||
(bmp.GetWidth() / 2);
|
||||
bmpY = buttonRect.y +
|
||||
((buttonRect.height - textHeight) / 2) -
|
||||
(item.GetBitmap().GetHeight() / 2);
|
||||
(bmp.GetHeight() / 2);
|
||||
|
||||
textX = rect.x + (rect.width / 2) - (textWidth / 2) + 1;
|
||||
textY = rect.y + rect.height - textHeight - 1;
|
||||
@@ -289,27 +288,14 @@ void wxAuiMSWToolBarArt::DrawDropDownButton(
|
||||
|
||||
bmpY = rect.y +
|
||||
(rect.height / 2) -
|
||||
(item.GetBitmap().GetHeight() / 2);
|
||||
(bmp.GetHeight() / 2);
|
||||
|
||||
textX = bmpX + wnd->FromDIP(3) + item.GetBitmap().GetWidth();
|
||||
textX = bmpX + wnd->FromDIP(3) + bmp.GetWidth();
|
||||
textY = rect.y +
|
||||
(rect.height / 2) -
|
||||
(textHeight / 2);
|
||||
}
|
||||
|
||||
wxBitmap bmp;
|
||||
if ( item.GetState() & wxAUI_BUTTON_STATE_DISABLED )
|
||||
{
|
||||
bmp = item.GetDisabledBitmap();
|
||||
}
|
||||
else
|
||||
{
|
||||
bmp = item.GetBitmap();
|
||||
}
|
||||
|
||||
if ( !bmp.IsOk() )
|
||||
return;
|
||||
|
||||
dc.DrawBitmap(bmp, bmpX, bmpY, true);
|
||||
|
||||
// set the item's text color based on if it is disabled
|
||||
@@ -433,7 +419,7 @@ wxSize wxAuiMSWToolBarArt::GetToolSize(
|
||||
{
|
||||
if ( m_themed )
|
||||
{
|
||||
if ( !item.GetBitmap().IsOk() && !(m_flags & wxAUI_TB_TEXT) )
|
||||
if ( !item.GetBitmapBundle().IsOk() && !(m_flags & wxAUI_TB_TEXT) )
|
||||
return m_buttonSize;
|
||||
|
||||
wxSize size = wxAuiGenericToolBarArt::GetToolSize(dc, wnd, item);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "wx/aui/tabart.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/settings.h"
|
||||
#include "wx/dcclient.h"
|
||||
#include "wx/image.h"
|
||||
@@ -646,7 +647,8 @@ void wxAuiDefaultDockArt::DrawCaption(wxDC& dc,
|
||||
{
|
||||
DrawIcon(dc, window, rect, pane);
|
||||
|
||||
caption_offset += pane.icon.GetScaledWidth() + window->FromDIP(3);
|
||||
const wxBitmap& icon = pane.icon.GetBitmapFor(window);
|
||||
caption_offset += icon.GetScaledWidth() + window->FromDIP(3);
|
||||
}
|
||||
|
||||
if (pane.state & wxAuiPaneInfo::optionActive)
|
||||
@@ -685,10 +687,17 @@ void wxAuiDefaultDockArt::DrawIcon(wxDC& dc, const wxRect& rect, wxAuiPaneInfo&
|
||||
void
|
||||
wxAuiDefaultDockArt::DrawIcon(wxDC& dc, wxWindow *window, const wxRect& rect, wxAuiPaneInfo& pane)
|
||||
{
|
||||
if (!window)
|
||||
{
|
||||
window = wxTheApp->GetTopWindow();
|
||||
wxCHECK_RET( window, "must have some window" );
|
||||
}
|
||||
|
||||
// Draw the icon centered vertically
|
||||
int xOffset = window ? window->FromDIP(2) : 2;
|
||||
dc.DrawBitmap(pane.icon,
|
||||
rect.x+xOffset, rect.y+(rect.height-pane.icon.GetScaledHeight())/2,
|
||||
int xOffset = window->FromDIP(2);
|
||||
const wxBitmap& icon = pane.icon.GetBitmapFor(window);
|
||||
dc.DrawBitmap(icon,
|
||||
rect.x+xOffset, rect.y+(rect.height-icon.GetScaledHeight())/2,
|
||||
true);
|
||||
}
|
||||
|
||||
@@ -751,40 +760,42 @@ void wxAuiDefaultDockArt::DrawPaneButton(wxDC& dc,
|
||||
const wxRect& _rect,
|
||||
wxAuiPaneInfo& pane)
|
||||
{
|
||||
wxBitmap bmp;
|
||||
wxBitmapBundle bb;
|
||||
switch (button)
|
||||
{
|
||||
default:
|
||||
case wxAUI_BUTTON_CLOSE:
|
||||
if (pane.state & wxAuiPaneInfo::optionActive)
|
||||
bmp = m_activeCloseBitmap;
|
||||
bb = m_activeCloseBitmap;
|
||||
else
|
||||
bmp = m_inactiveCloseBitmap;
|
||||
bb = m_inactiveCloseBitmap;
|
||||
break;
|
||||
case wxAUI_BUTTON_PIN:
|
||||
if (pane.state & wxAuiPaneInfo::optionActive)
|
||||
bmp = m_activePinBitmap;
|
||||
bb = m_activePinBitmap;
|
||||
else
|
||||
bmp = m_inactivePinBitmap;
|
||||
bb = m_inactivePinBitmap;
|
||||
break;
|
||||
case wxAUI_BUTTON_MAXIMIZE_RESTORE:
|
||||
if (pane.IsMaximized())
|
||||
{
|
||||
if (pane.state & wxAuiPaneInfo::optionActive)
|
||||
bmp = m_activeRestoreBitmap;
|
||||
bb = m_activeRestoreBitmap;
|
||||
else
|
||||
bmp = m_inactiveRestoreBitmap;
|
||||
bb = m_inactiveRestoreBitmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pane.state & wxAuiPaneInfo::optionActive)
|
||||
bmp = m_activeMaximizeBitmap;
|
||||
bb = m_activeMaximizeBitmap;
|
||||
else
|
||||
bmp = m_inactiveMaximizeBitmap;
|
||||
bb = m_inactiveMaximizeBitmap;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
const wxBitmap& bmp = bb.GetBitmapFor(window);
|
||||
|
||||
wxRect rect = _rect;
|
||||
|
||||
rect.y = rect.y + (rect.height/2) - (bmp.GetScaledHeight()/2);
|
||||
|
||||
Reference in New Issue
Block a user