new default theme for wxAuiNotebook
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43146 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -39,11 +39,12 @@ enum wxAuiNotebookOption
|
||||
wxAUI_NB_TAB_SPLIT = 1 << 4,
|
||||
wxAUI_NB_TAB_MOVE = 1 << 5,
|
||||
wxAUI_NB_TAB_EXTERNAL_MOVE = 1 << 6,
|
||||
wxAUI_NB_SCROLL_BUTTONS = 1 << 7,
|
||||
wxAUI_NB_WINDOWLIST_BUTTON = 1 << 8,
|
||||
wxAUI_NB_CLOSE_BUTTON = 1 << 9,
|
||||
wxAUI_NB_CLOSE_ON_ACTIVE_TAB = 1 << 10,
|
||||
wxAUI_NB_CLOSE_ON_ALL_TABS = 1 << 11,
|
||||
wxAUI_NB_TAB_FIXED_WIDTH = 1 << 7,
|
||||
wxAUI_NB_SCROLL_BUTTONS = 1 << 8,
|
||||
wxAUI_NB_WINDOWLIST_BUTTON = 1 << 9,
|
||||
wxAUI_NB_CLOSE_BUTTON = 1 << 10,
|
||||
wxAUI_NB_CLOSE_ON_ACTIVE_TAB = 1 << 11,
|
||||
wxAUI_NB_CLOSE_ON_ALL_TABS = 1 << 12,
|
||||
|
||||
|
||||
wxAUI_NB_DEFAULT_STYLE = wxAUI_NB_TOP |
|
||||
@@ -56,7 +57,6 @@ enum wxAuiNotebookOption
|
||||
|
||||
|
||||
|
||||
|
||||
// tab art class
|
||||
|
||||
class WXDLLIMPEXP_AUI wxAuiTabArt
|
||||
@@ -66,6 +66,12 @@ public:
|
||||
wxAuiTabArt() { }
|
||||
virtual ~wxAuiTabArt() { }
|
||||
|
||||
virtual wxAuiTabArt* Clone() = 0;
|
||||
virtual void SetFlags(unsigned int flags) = 0;
|
||||
|
||||
virtual void SetSizingInfo(const wxSize& tab_ctrl_size,
|
||||
size_t tab_count) = 0;
|
||||
|
||||
virtual void SetNormalFont(const wxFont& font) = 0;
|
||||
virtual void SetSelectedFont(const wxFont& font) = 0;
|
||||
virtual void SetMeasuringFont(const wxFont& font) = 0;
|
||||
@@ -95,6 +101,8 @@ public:
|
||||
const wxBitmap& bitmap_override,
|
||||
wxRect* out_rect) = 0;
|
||||
|
||||
virtual int GetIndentSize() = 0;
|
||||
|
||||
virtual wxSize GetTabSize(
|
||||
wxDC& dc,
|
||||
wxWindow* wnd,
|
||||
@@ -112,15 +120,20 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class WXDLLIMPEXP_AUI wxAuiDefaultTabArt : public wxAuiTabArt
|
||||
class WXDLLIMPEXP_AUI wxAuiSimpleTabArt : public wxAuiTabArt
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
wxAuiDefaultTabArt();
|
||||
virtual ~wxAuiDefaultTabArt();
|
||||
wxAuiSimpleTabArt();
|
||||
virtual ~wxAuiSimpleTabArt();
|
||||
|
||||
wxAuiTabArt* Clone();
|
||||
void SetFlags(unsigned int flags);
|
||||
|
||||
void SetSizingInfo(const wxSize& tab_ctrl_size,
|
||||
size_t tab_count);
|
||||
|
||||
void SetWindow(wxWindow* wnd);
|
||||
void SetNormalFont(const wxFont& font);
|
||||
void SetSelectedFont(const wxFont& font);
|
||||
void SetMeasuringFont(const wxFont& font);
|
||||
@@ -150,6 +163,8 @@ public:
|
||||
const wxBitmap& bitmap_override,
|
||||
wxRect* out_rect);
|
||||
|
||||
int GetIndentSize();
|
||||
|
||||
wxSize GetTabSize(
|
||||
wxDC& dc,
|
||||
wxWindow* wnd,
|
||||
@@ -183,9 +198,96 @@ private:
|
||||
wxBitmap m_disabled_right_bmp;
|
||||
wxBitmap m_active_windowlist_bmp;
|
||||
wxBitmap m_disabled_windowlist_bmp;
|
||||
|
||||
int m_fixed_tab_width;
|
||||
unsigned int m_flags;
|
||||
};
|
||||
|
||||
|
||||
class WXDLLIMPEXP_AUI wxAuiDefaultTabArt : public wxAuiTabArt
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
wxAuiDefaultTabArt();
|
||||
virtual ~wxAuiDefaultTabArt();
|
||||
|
||||
wxAuiTabArt* Clone();
|
||||
void SetFlags(unsigned int flags);
|
||||
void SetSizingInfo(const wxSize& tab_ctrl_size,
|
||||
size_t tab_count);
|
||||
|
||||
void SetNormalFont(const wxFont& font);
|
||||
void SetSelectedFont(const wxFont& font);
|
||||
void SetMeasuringFont(const wxFont& font);
|
||||
|
||||
void DrawBackground(
|
||||
wxDC& dc,
|
||||
wxWindow* wnd,
|
||||
const wxRect& rect);
|
||||
|
||||
void DrawTab(wxDC& dc,
|
||||
wxWindow* wnd,
|
||||
const wxRect& in_rect,
|
||||
const wxString& caption,
|
||||
bool active,
|
||||
int close_button_state,
|
||||
wxRect* out_tab_rect,
|
||||
wxRect* out_button_rect,
|
||||
int* x_extent);
|
||||
|
||||
void DrawButton(
|
||||
wxDC& dc,
|
||||
wxWindow* wnd,
|
||||
const wxRect& in_rect,
|
||||
int bitmap_id,
|
||||
int button_state,
|
||||
int orientation,
|
||||
const wxBitmap& bitmap_override,
|
||||
wxRect* out_rect);
|
||||
|
||||
int GetIndentSize();
|
||||
|
||||
wxSize GetTabSize(
|
||||
wxDC& dc,
|
||||
wxWindow* wnd,
|
||||
const wxString& caption,
|
||||
bool active,
|
||||
int close_button_state,
|
||||
int* x_extent);
|
||||
|
||||
int ShowWindowList(
|
||||
wxWindow* wnd,
|
||||
const wxArrayString& items,
|
||||
int active_idx);
|
||||
|
||||
int GetBestTabCtrlSize(wxWindow* wnd);
|
||||
|
||||
private:
|
||||
|
||||
wxFont m_normal_font;
|
||||
wxFont m_selected_font;
|
||||
wxFont m_measuring_font;
|
||||
wxPen m_normal_bkpen;
|
||||
wxPen m_selected_bkpen;
|
||||
wxBrush m_normal_bkbrush;
|
||||
wxBrush m_selected_bkbrush;
|
||||
wxBrush m_bkbrush;
|
||||
wxBitmap m_active_close_bmp;
|
||||
wxBitmap m_disabled_close_bmp;
|
||||
wxBitmap m_active_left_bmp;
|
||||
wxBitmap m_disabled_left_bmp;
|
||||
wxBitmap m_active_right_bmp;
|
||||
wxBitmap m_disabled_right_bmp;
|
||||
wxBitmap m_active_windowlist_bmp;
|
||||
wxBitmap m_disabled_windowlist_bmp;
|
||||
|
||||
int m_fixed_tab_width;
|
||||
unsigned int m_flags;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// event declarations/classes
|
||||
|
||||
|
@@ -94,6 +94,9 @@ class MyFrame : public wxFrame
|
||||
ID_NotebookAllowTabSplit,
|
||||
ID_NotebookWindowList,
|
||||
ID_NotebookScrollButtons,
|
||||
ID_NotebookTabFixedWidth,
|
||||
ID_NotebookArtGloss,
|
||||
ID_NotebookArtSimple,
|
||||
ID_FirstPerspective = ID_CreatePerspective+1000
|
||||
};
|
||||
|
||||
@@ -155,6 +158,7 @@ private:
|
||||
wxArrayString m_perspectives;
|
||||
wxMenu* m_perspectives_menu;
|
||||
long m_notebook_style;
|
||||
long m_notebook_theme;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
@@ -575,6 +579,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(ID_NoVenetianFade, MyFrame::OnManagerFlag)
|
||||
EVT_MENU(ID_TransparentDrag, MyFrame::OnManagerFlag)
|
||||
EVT_MENU(ID_AllowActivePane, MyFrame::OnManagerFlag)
|
||||
EVT_MENU(ID_NotebookTabFixedWidth, MyFrame::OnNotebookFlag)
|
||||
EVT_MENU(ID_NotebookNoCloseButton, MyFrame::OnNotebookFlag)
|
||||
EVT_MENU(ID_NotebookCloseButton, MyFrame::OnNotebookFlag)
|
||||
EVT_MENU(ID_NotebookCloseButtonAll, MyFrame::OnNotebookFlag)
|
||||
@@ -584,6 +589,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(ID_NotebookAllowTabSplit, MyFrame::OnNotebookFlag)
|
||||
EVT_MENU(ID_NotebookScrollButtons, MyFrame::OnNotebookFlag)
|
||||
EVT_MENU(ID_NotebookWindowList, MyFrame::OnNotebookFlag)
|
||||
EVT_MENU(ID_NotebookArtGloss, MyFrame::OnNotebookFlag)
|
||||
EVT_MENU(ID_NotebookArtSimple, MyFrame::OnNotebookFlag)
|
||||
EVT_MENU(ID_NoGradient, MyFrame::OnGradient)
|
||||
EVT_MENU(ID_VerticalGradient, MyFrame::OnGradient)
|
||||
EVT_MENU(ID_HorizontalGradient, MyFrame::OnGradient)
|
||||
@@ -596,6 +603,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(ID_NotebookContent, MyFrame::OnChangeContentPane)
|
||||
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
|
||||
EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
|
||||
EVT_UPDATE_UI(ID_NotebookTabFixedWidth, MyFrame::OnUpdateUI)
|
||||
EVT_UPDATE_UI(ID_NotebookNoCloseButton, MyFrame::OnUpdateUI)
|
||||
EVT_UPDATE_UI(ID_NotebookCloseButton, MyFrame::OnUpdateUI)
|
||||
EVT_UPDATE_UI(ID_NotebookCloseButtonAll, MyFrame::OnUpdateUI)
|
||||
@@ -640,6 +648,7 @@ MyFrame::MyFrame(wxWindow* parent,
|
||||
|
||||
// set up default notebook style
|
||||
m_notebook_style = wxAUI_NB_DEFAULT_STYLE | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER;
|
||||
m_notebook_theme = 0;
|
||||
|
||||
// create menu
|
||||
wxMenuBar* mb = new wxMenuBar;
|
||||
@@ -681,6 +690,9 @@ MyFrame::MyFrame(wxWindow* parent,
|
||||
options_menu->Append(ID_Settings, _("Settings Pane"));
|
||||
|
||||
wxMenu* notebook_menu = new wxMenu;
|
||||
notebook_menu->AppendRadioItem(ID_NotebookArtGloss, _("Glossy Theme (Default)"));
|
||||
notebook_menu->AppendRadioItem(ID_NotebookArtSimple, _("Simple Theme"));
|
||||
notebook_menu->AppendSeparator();
|
||||
notebook_menu->AppendRadioItem(ID_NotebookNoCloseButton, _("No Close Button"));
|
||||
notebook_menu->AppendRadioItem(ID_NotebookCloseButton, _("Close Button at Right"));
|
||||
notebook_menu->AppendRadioItem(ID_NotebookCloseButtonAll, _("Close Button on All Tabs"));
|
||||
@@ -691,6 +703,7 @@ MyFrame::MyFrame(wxWindow* parent,
|
||||
notebook_menu->AppendCheckItem(ID_NotebookAllowTabSplit, _("Allow Notebook Split"));
|
||||
notebook_menu->AppendCheckItem(ID_NotebookScrollButtons, _("Scroll Buttons Visible"));
|
||||
notebook_menu->AppendCheckItem(ID_NotebookWindowList, _("Window List Button Visible"));
|
||||
notebook_menu->AppendCheckItem(ID_NotebookTabFixedWidth, _("Fixed-width Tabs"));
|
||||
|
||||
m_perspectives_menu = new wxMenu;
|
||||
m_perspectives_menu->Append(ID_CreatePerspective, _("Create Perspective"));
|
||||
@@ -1069,7 +1082,10 @@ void MyFrame::OnNotebookFlag(wxCommandEvent& event)
|
||||
{
|
||||
m_notebook_style ^= wxAUI_NB_SCROLL_BUTTONS;
|
||||
}
|
||||
|
||||
else if (id == ID_NotebookTabFixedWidth)
|
||||
{
|
||||
m_notebook_style ^= wxAUI_NB_TAB_FIXED_WIDTH;
|
||||
}
|
||||
|
||||
|
||||
size_t i, count;
|
||||
@@ -1077,11 +1093,24 @@ void MyFrame::OnNotebookFlag(wxCommandEvent& event)
|
||||
for (i = 0, count = all_panes.GetCount(); i < count; ++i)
|
||||
{
|
||||
wxAuiPaneInfo& pane = all_panes.Item(i);
|
||||
|
||||
if (pane.window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
||||
{
|
||||
pane.window->SetWindowStyleFlag(m_notebook_style);
|
||||
pane.window->Refresh();
|
||||
wxAuiNotebook* nb = (wxAuiNotebook*)pane.window;
|
||||
|
||||
if (id == ID_NotebookArtGloss)
|
||||
{
|
||||
nb->SetArtProvider(new wxAuiDefaultTabArt);
|
||||
m_notebook_theme = 0;
|
||||
}
|
||||
else if (id == ID_NotebookArtSimple)
|
||||
{
|
||||
nb->SetArtProvider(new wxAuiSimpleTabArt);
|
||||
m_notebook_theme = 1;
|
||||
}
|
||||
|
||||
|
||||
nb->SetWindowStyleFlag(m_notebook_style);
|
||||
nb->Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1158,6 +1187,16 @@ void MyFrame::OnUpdateUI(wxUpdateUIEvent& event)
|
||||
case ID_NotebookWindowList:
|
||||
event.Check((m_notebook_style & wxAUI_NB_WINDOWLIST_BUTTON) != 0);
|
||||
break;
|
||||
case ID_NotebookTabFixedWidth:
|
||||
event.Check((m_notebook_style & wxAUI_NB_TAB_FIXED_WIDTH) != 0);
|
||||
break;
|
||||
case ID_NotebookArtGloss:
|
||||
event.Check(m_notebook_style == 0);
|
||||
break;
|
||||
case ID_NotebookArtSimple:
|
||||
event.Check(m_notebook_style == 1);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1409,7 +1448,7 @@ wxAuiNotebook* MyFrame::CreateNotebook()
|
||||
wxSize(430,200),
|
||||
m_notebook_style);
|
||||
|
||||
ctrl->AddPage(CreateHTMLCtrl(ctrl), wxT("Welcome"));
|
||||
ctrl->AddPage(CreateHTMLCtrl(ctrl), wxT("Welcome to wxAUI"));
|
||||
|
||||
wxPanel *panel = new wxPanel( ctrl, wxID_ANY );
|
||||
wxFlexGridSizer *flex = new wxFlexGridSizer( 2 );
|
||||
@@ -1446,7 +1485,7 @@ wxAuiNotebook* MyFrame::CreateNotebook()
|
||||
wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 6") );
|
||||
|
||||
ctrl->AddPage( new wxTextCtrl( ctrl, wxID_ANY, wxT("Some more text"),
|
||||
wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 7") );
|
||||
wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 7 (longer title)") );
|
||||
|
||||
ctrl->AddPage( new wxTextCtrl( ctrl, wxID_ANY, wxT("Some more text"),
|
||||
wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 8") );
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user