#include "wx/control.h"
-// tab art class
+
+enum wxAuiNotebookOption
+{
+ wxAUI_NB_TOP = 1 << 0,
+ wxAUI_NB_LEFT = 1 << 1, // not implemented yet
+ wxAUI_NB_RIGHT = 1 << 2, // not implemented yet
+ wxAUI_NB_BOTTOM = 1 << 3, // not implemented yet
+ wxAUI_NB_TAB_SPLIT = 1 << 4,
+ wxAUI_NB_TAB_MOVE = 1 << 5,
+ wxAUI_NB_SCROLL_BUTTONS = 1 << 6,
+ wxAUI_NB_CLOSE_BUTTON = 1 << 7,
+ wxAUI_NB_PAGELIST_BUTTON = 1 << 8,
+ wxAUI_NB_CLOSE_ON_ACTIVE_TAB = 1 << 9,
+ wxAUI_NB_CLOSE_ON_ALL_TABS = 1 << 10,
+
+ wxAUI_NB_DEFAULT_STYLE = wxAUI_NB_TOP |
+ wxAUI_NB_TAB_SPLIT |
+ wxAUI_NB_TAB_MOVE |
+ wxAUI_NB_SCROLL_BUTTONS// |
+ //wxAUI_NB_CLOSE_ON_ALL_TABS
+};
+
+
+
+// tab art class
+
class WXDLLIMPEXP_AUI wxTabArt
{
public:
const wxRect& in_rect,
const wxString& caption,
bool active,
+ bool with_close_button,
wxRect* out_rect,
int* x_extent) = 0;
wxDC* dc,
const wxString& caption,
bool active,
+ bool with_close_button,
int* x_extent) = 0;
virtual int GetBestTabCtrlSize(wxWindow* wnd) = 0;
const wxRect& in_rect,
const wxString& caption,
bool active,
+ bool with_close_button,
wxRect* out_rect,
int* x_extent);
wxDC* dc,
const wxString& caption,
bool active,
+ bool with_close_button,
int* x_extent);
int GetBestTabCtrlSize(wxWindow* wnd);
void SetArtProvider(wxTabArt* art);
wxTabArt* GetArtProvider();
+ void SetFlags(unsigned int flags);
+ unsigned int GetFlags() const;
+
bool AddPage(wxWindow* page, const wxAuiNotebookPage& info);
bool InsertPage(wxWindow* page, const wxAuiNotebookPage& info, size_t idx);
bool MovePage(wxWindow* page, size_t new_idx);
wxAuiTabContainerButtonArray m_buttons;
wxRect m_rect;
size_t m_tab_offset;
+ unsigned int m_flags;
};
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = 0);
+ long style = wxAUI_NB_DEFAULT_STYLE);
virtual ~wxAuiMultiNotebook();
protected:
void DoSizing();
- void InitNotebook();
+ void InitNotebook(long style);
void OnChildFocus(wxChildFocusEvent& evt);
void OnRender(wxFrameManagerEvent& evt);
int m_tab_ctrl_height;
int m_last_drag_x;
+ unsigned int m_flags;
#ifndef SWIG
DECLARE_EVENT_TABLE()
const wxRect& in_rect,
const wxString& caption_text,
bool active,
+ bool with_close_button,
wxRect* out_rect,
int* x_extent)
{
dc->GetTextExtent(caption, &normal_textx, &normal_texty);
// figure out the size of the tab
- wxSize tab_size = GetTabSize(dc, caption, active, x_extent);
+ wxSize tab_size = GetTabSize(dc, caption, active, with_close_button, x_extent);
wxCoord tab_height = tab_size.y;
wxCoord tab_width = tab_size.x;
//dc->DrawLines(active ? 6 : 7, points);
dc->DrawLines(7, points);
- // -- draw text --
+ int text_offset;
+
+ int close_button_width = 0;
+ if (with_close_button)
+ {
+ close_button_width = m_active_close_bmp.GetWidth();
+ text_offset = tab_x + (tab_height/2) + ((tab_width-close_button_width)/2) - (textx/2);
+ }
+ else
+ {
+ text_offset = tab_x + (tab_height/3) + (tab_width/2) - (textx/2);
+ }
+
+
+ // draw tab text
dc->DrawText(caption,
- tab_x + (tab_height/3) + (tab_width/2) - (textx/2),
+ text_offset,
(tab_y + tab_height)/2 - (texty/2) + 1);
+
+ // draw close button if necessary
+ if (with_close_button)
+ {
+ wxBitmap bmp;
+ if (active)
+ bmp = m_active_close_bmp;
+ else
+ bmp = m_disabled_close_bmp;
+
+ wxRect rect(tab_x + tab_width - close_button_width - 1, tab_y + 1,
+ close_button_width, tab_height - 1);
+ DrawButtonS(*dc, rect, bmp, *wxWHITE, wxAUI_BUTTON_STATE_NORMAL);
+ }
+
+
*out_rect = wxRect(tab_x, tab_y, tab_width, tab_height);
}
wxSize wxDefaultTabArt::GetTabSize(wxDC* dc,
const wxString& caption,
bool WXUNUSED(active),
+ bool with_close_button,
int* x_extent)
{
wxCoord measured_textx, measured_texty;
wxCoord tab_height = measured_texty + 4;
wxCoord tab_width = measured_textx + tab_height + 5;
+ if (with_close_button)
+ tab_width += m_active_close_bmp.GetWidth();
+
*x_extent = tab_width - (tab_height/2) - 1;
return wxSize(tab_width, tab_height);
wxClientDC dc(wnd);
dc.SetFont(m_measuring_font);
int x_ext = 0;
- wxSize s = GetTabSize(&dc, wxT("ABCDEFGHIj"), true, &x_ext);
+ wxSize s = GetTabSize(&dc, wxT("ABCDEFGHIj"), true, false, &x_ext);
return s.y+3;
}
wxAuiTabContainer::wxAuiTabContainer()
{
m_tab_offset = 0;
+ m_flags = 0;
m_art = new wxDefaultTabArt;
AddButton(wxAUI_BUTTON_LEFT, wxLEFT);
return m_art;
}
+void wxAuiTabContainer::SetFlags(unsigned int flags)
+{
+ m_flags = flags;
+}
+
+unsigned int wxAuiTabContainer::GetFlags() const
+{
+ return m_flags;
+}
+
+
void wxAuiTabContainer::SetNormalFont(const wxFont& font)
{
m_art->SetNormalFont(font);
for (i = 0; i < page_count; ++i)
{
wxAuiNotebookPage& page = m_pages.Item(i);
+
+ // determine if a close button is on this tab
+ bool close_button = false;
+ if ((m_flags & wxAUI_NB_CLOSE_ON_ALL_TABS) != 0 ||
+ ((m_flags & wxAUI_NB_CLOSE_ON_ACTIVE_TAB) != 0 && page.active))
+ {
+ close_button = true;
+ }
+
+
int x_extent = 0;
- wxSize size = m_art->GetTabSize(&dc, page.caption, page.active, &x_extent);
+ wxSize size = m_art->GetTabSize(&dc, page.caption, page.active, close_button, &x_extent);
if (i+1 < page_count)
total_width += x_extent;
offset = left_buttons_width;
-
+ // set a clipping region to the tabs don't draw over the buttons
dc.SetClippingRegion(left_buttons_width, 0,
m_rect.GetWidth() - right_buttons_width - left_buttons_width - 2,
m_rect.GetHeight());
+
+
// draw the tabs
{
wxAuiNotebookPage& page = m_pages.Item(i);
+ // determine if a close button is on this tab
+ bool close_button = false;
+ if ((m_flags & wxAUI_NB_CLOSE_ON_ALL_TABS) != 0 ||
+ ((m_flags & wxAUI_NB_CLOSE_ON_ACTIVE_TAB) != 0 && page.active))
+ {
+ close_button = true;
+ }
+
rect.x = offset;
m_art->DrawTab(&dc,
rect,
page.caption,
page.active,
+ close_button,
&page.rect,
&x_extent);
{
wxAuiNotebookPage& page = m_pages.Item(active);
+ // determine if a close button is on this tab
+ bool close_button = false;
+ if ((m_flags & wxAUI_NB_CLOSE_ON_ALL_TABS) != 0 ||
+ ((m_flags & wxAUI_NB_CLOSE_ON_ACTIVE_TAB) != 0 && page.active))
+ {
+ close_button = true;
+ }
+
rect.x = active_offset;
m_art->DrawTab(&dc,
rect,
page.caption,
page.active,
+ close_button,
&page.rect,
&x_extent);
}
const wxSize& size,
long style) : wxControl(parent, id, pos, size, style)
{
- InitNotebook();
+ InitNotebook(style);
}
bool wxAuiMultiNotebook::Create(wxWindow* parent,
if (!wxControl::Create(parent, id, pos, size, style))
return false;
- InitNotebook();
+ InitNotebook(style);
return true;
}
// InitNotebook() contains common initialization
// code called by all constructors
-void wxAuiMultiNotebook::InitNotebook()
+void wxAuiMultiNotebook::InitNotebook(long style)
{
m_curpage = -1;
m_tab_id_counter = 10000;
m_dummy_wnd = NULL;
m_tab_ctrl_height = 20;
-
+ m_flags = (unsigned int)style;
+
m_normal_font = *wxNORMAL_FONT;
m_selected_font = *wxNORMAL_FONT;
m_selected_font.SetWeight(wxBOLD);
wxDefaultPosition,
wxDefaultSize,
wxNO_BORDER);
+ tabframe->m_tabs->SetFlags(m_flags);
m_mgr.AddPane(tabframe,
wxPaneInfo().Center().CaptionVisible(false));
wxDefaultPosition,
wxDefaultSize,
wxNO_BORDER);
+ new_tabs->m_tabs->SetFlags(m_flags);
+
m_mgr.AddPane(new_tabs,
wxPaneInfo().Bottom().CaptionVisible(false),
mouse_client_pt);