wxAUI_NB_TAB_SPLIT = 1 << 4,
wxAUI_NB_TAB_MOVE = 1 << 5,
wxAUI_NB_SCROLL_BUTTONS = 1 << 6,
- wxAUI_NB_PAGELIST_BUTTON = 1 << 7,
+ wxAUI_NB_WINDOWLIST_BUTTON = 1 << 7,
wxAUI_NB_CLOSE_BUTTON = 1 << 8,
wxAUI_NB_CLOSE_ON_ACTIVE_TAB = 1 << 9,
wxAUI_NB_CLOSE_ON_ALL_TABS = 1 << 10,
virtual void DrawBackground(
wxDC* dc,
+ wxWindow* wnd,
const wxRect& rect) = 0;
virtual void DrawTab(wxDC* dc,
+ wxWindow* wnd,
const wxRect& in_rect,
const wxString& caption,
bool active,
virtual 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) = 0;
+
+ virtual int ShowWindowList(
+ wxWindow* wnd,
+ const wxArrayString& items,
+ int active_idx) = 0;
virtual wxSize GetTabSize(
wxDC* dc,
+ wxWindow* wnd,
const wxString& caption,
bool active,
int close_button_state,
int* x_extent) = 0;
-
- virtual int GetBestTabCtrlSize(wxWindow* wnd) = 0;
+
+ virtual int GetBestTabCtrlSize(wxWindow* wnd) = 0;
};
wxAuiDefaultTabArt();
virtual ~wxAuiDefaultTabArt();
+ void SetWindow(wxWindow* wnd);
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,
void DrawButton(
wxDC* dc,
+ wxWindow* wnd,
const wxRect& in_rect,
int bitmap_id,
int button_state,
const wxBitmap& bitmap_override,
wxRect* out_rect);
+ int ShowWindowList(
+ wxWindow* wnd,
+ const wxArrayString& items,
+ int active_idx);
+
wxSize GetTabSize(
wxDC* dc,
+ wxWindow* wnd,
const wxString& caption,
bool active,
int close_button_state,
int* x_extent);
- int GetBestTabCtrlSize(wxWindow* wnd);
+ int GetBestTabCtrlSize(wxWindow* wnd);
private:
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;
};
protected:
- virtual void Render(wxDC* dc);
+ virtual void Render(wxDC* dc, wxWindow* wnd);
-private:
+protected:
wxAuiTabArt* m_art;
wxAuiNotebookPageArray m_pages;
ID_NotebookCloseButtonActive,
ID_NotebookAllowTabMove,
ID_NotebookAllowTabSplit,
+ ID_NotebookWindowList,
+ ID_NotebookScrollButtons,
ID_FirstPerspective = ID_CreatePerspective+1000
};
EVT_MENU(ID_NotebookCloseButtonActive, MyFrame::OnNotebookFlag)
EVT_MENU(ID_NotebookAllowTabMove, MyFrame::OnNotebookFlag)
EVT_MENU(ID_NotebookAllowTabSplit, MyFrame::OnNotebookFlag)
+ EVT_MENU(ID_NotebookScrollButtons, MyFrame::OnNotebookFlag)
+ EVT_MENU(ID_NotebookWindowList, MyFrame::OnNotebookFlag)
EVT_MENU(ID_NoGradient, MyFrame::OnGradient)
EVT_MENU(ID_VerticalGradient, MyFrame::OnGradient)
EVT_MENU(ID_HorizontalGradient, MyFrame::OnGradient)
EVT_UPDATE_UI(ID_NotebookCloseButtonActive, MyFrame::OnUpdateUI)
EVT_UPDATE_UI(ID_NotebookAllowTabMove, MyFrame::OnUpdateUI)
EVT_UPDATE_UI(ID_NotebookAllowTabSplit, MyFrame::OnUpdateUI)
+ EVT_UPDATE_UI(ID_NotebookScrollButtons, MyFrame::OnUpdateUI)
+ EVT_UPDATE_UI(ID_NotebookWindowList, MyFrame::OnUpdateUI)
EVT_UPDATE_UI(ID_AllowFloating, MyFrame::OnUpdateUI)
EVT_UPDATE_UI(ID_TransparentHint, MyFrame::OnUpdateUI)
EVT_UPDATE_UI(ID_VenetianBlindsHint, MyFrame::OnUpdateUI)
notebook_menu->AppendSeparator();
notebook_menu->AppendCheckItem(ID_NotebookAllowTabMove, _("Allow Tab Move"));
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"));
m_perspectives_menu = new wxMenu;
m_perspectives_menu->Append(ID_CreatePerspective, _("Create Perspective"));
{
m_notebook_style ^= wxAUI_NB_TAB_MOVE;
}
-
- if (id == ID_NotebookAllowTabSplit)
+ else if (id == ID_NotebookAllowTabSplit)
{
m_notebook_style ^= wxAUI_NB_TAB_SPLIT;
}
+ else if (id == ID_NotebookWindowList)
+ {
+ m_notebook_style ^= wxAUI_NB_WINDOWLIST_BUTTON;
+ }
+ else if (id == ID_NotebookScrollButtons)
+ {
+ m_notebook_style ^= wxAUI_NB_SCROLL_BUTTONS;
+ }
case ID_NotebookAllowTabMove:
event.Check((m_notebook_style & wxAUI_NB_TAB_MOVE) != 0);
break;
+ case ID_NotebookScrollButtons:
+ event.Check((m_notebook_style & wxAUI_NB_SCROLL_BUTTONS) != 0);
+ break;
+ case ID_NotebookWindowList:
+ event.Check((m_notebook_style & wxAUI_NB_WINDOWLIST_BUTTON) != 0);
+ break;
}
}
0x1f, 0xfe, 0x1f, 0xfc, 0x1f, 0xfe, 0x1f, 0xff, 0x9f, 0xff, 0xdf, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+ static unsigned char list_bits[] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x0f, 0xf8, 0xff, 0xff, 0x0f, 0xf8, 0x1f, 0xfc, 0x3f, 0xfe, 0x7f, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+
+
m_active_close_bmp = BitmapFromBits(close_bits, 16, 16, *wxBLACK);
m_disabled_close_bmp = BitmapFromBits(close_bits, 16, 16, wxColour(128,128,128));
m_active_right_bmp = BitmapFromBits(right_bits, 16, 16, *wxBLACK);
m_disabled_right_bmp = BitmapFromBits(right_bits, 16, 16, wxColour(128,128,128));
+
+ m_active_windowlist_bmp = BitmapFromBits(list_bits, 16, 16, *wxBLACK);
+ m_disabled_windowlist_bmp = BitmapFromBits(list_bits, 16, 16, wxColour(128,128,128));
+
}
wxAuiDefaultTabArt::~wxAuiDefaultTabArt()
}
void wxAuiDefaultTabArt::DrawBackground(wxDC* dc,
- const wxRect& rect)
+ wxWindow* WXUNUSED(wnd),
+ const wxRect& rect)
{
// draw background
dc->SetBrush(m_bkbrush);
// x_extent - the advance x; where the next tab should start
void wxAuiDefaultTabArt::DrawTab(wxDC* dc,
- const wxRect& in_rect,
- const wxString& caption_text,
- bool active,
- int close_button_state,
- wxRect* out_tab_rect,
- wxRect* out_button_rect,
- int* x_extent)
+ wxWindow* wnd,
+ const wxRect& in_rect,
+ const wxString& caption_text,
+ bool active,
+ int close_button_state,
+ wxRect* out_tab_rect,
+ wxRect* out_button_rect,
+ int* x_extent)
{
wxCoord normal_textx, normal_texty;
wxCoord selected_textx, selected_texty;
dc->GetTextExtent(caption, &normal_textx, &normal_texty);
// figure out the size of the tab
- wxSize tab_size = GetTabSize(dc, caption, active, close_button_state, x_extent);
+ wxSize tab_size = GetTabSize(dc, wnd, caption, active, close_button_state, x_extent);
wxCoord tab_height = tab_size.y;
wxCoord tab_width = tab_size.x;
wxSize wxAuiDefaultTabArt::GetTabSize(wxDC* dc,
- const wxString& caption,
- bool WXUNUSED(active),
- int close_button_state,
- int* x_extent)
+ wxWindow* WXUNUSED(wnd),
+ const wxString& caption,
+ bool WXUNUSED(active),
+ int close_button_state,
+ int* x_extent)
{
wxCoord measured_textx, measured_texty;
void wxAuiDefaultTabArt::DrawButton(
- wxDC* dc,
- const wxRect& in_rect,
- int bitmap_id,
- int button_state,
- int orientation,
- const wxBitmap& bitmap_override,
- wxRect* out_rect)
+ wxDC* dc,
+ wxWindow* WXUNUSED(wnd),
+ const wxRect& in_rect,
+ int bitmap_id,
+ int button_state,
+ int orientation,
+ const wxBitmap& bitmap_override,
+ wxRect* out_rect)
{
wxBitmap bmp;
wxRect rect;
else
bmp = m_active_right_bmp;
break;
+ case wxAUI_BUTTON_WINDOWLIST:
+ if (button_state & wxAUI_BUTTON_STATE_DISABLED)
+ bmp = m_disabled_windowlist_bmp;
+ else
+ bmp = m_active_windowlist_bmp;
+ break;
}
}
+
+// -- GUI helper classes and functions --
+
+class wxAuiCommandCapture : public wxEvtHandler
+{
+public:
+
+ wxAuiCommandCapture() { m_last_id = 0; }
+ int GetCommandId() const { return m_last_id; }
+
+ bool ProcessEvent(wxEvent& evt)
+ {
+ if (evt.GetEventType() == wxEVT_COMMAND_MENU_SELECTED)
+ {
+ m_last_id = evt.GetId();
+ return true;
+ }
+
+ if (GetNextHandler())
+ return GetNextHandler()->ProcessEvent(evt);
+
+ return false;
+ }
+
+private:
+ int m_last_id;
+};
+
+
+
+int wxAuiDefaultTabArt::ShowWindowList(wxWindow* wnd,
+ const wxArrayString& items,
+ int active_idx)
+{
+ wxMenu menuPopup;
+
+ size_t i, count = items.GetCount();
+ for (i = 0; i < count; ++i)
+ {
+ menuPopup.AppendCheckItem(1000+i, items.Item(i));
+ }
+
+ if (active_idx != -1)
+ {
+ menuPopup.Check(1000+active_idx, true);
+ }
+
+ // find out where to put the popup menu of window
+ // items. Subtract 100 for now to center the menu
+ // a bit, until a better mechanism can be implemented
+ wxPoint pt = ::wxGetMousePosition();
+ pt = wnd->ScreenToClient(pt);
+ if (pt.x < 100)
+ pt.x = 0;
+ else
+ pt.x -= 100;
+
+ // find out the screen coordinate at the bottom of the tab ctrl
+ wxRect cli_rect = wnd->GetClientRect();
+ pt.y = cli_rect.y + cli_rect.height;
+
+ wxAuiCommandCapture* cc = new wxAuiCommandCapture;
+ wnd->PushEventHandler(cc);
+ wnd->PopupMenu(&menuPopup, pt);
+ int command = cc->GetCommandId();
+ wnd->PopEventHandler(true);
+
+ if (command >= 1000)
+ return command-1000;
+
+ return -1;
+}
+
int wxAuiDefaultTabArt::GetBestTabCtrlSize(wxWindow* wnd)
{
wxClientDC dc(wnd);
dc.SetFont(m_measuring_font);
int x_ext = 0;
- wxSize s = GetTabSize(&dc, wxT("ABCDEFGHIj"), true, wxAUI_BUTTON_STATE_HIDDEN, &x_ext);
+ wxSize s = GetTabSize(&dc,
+ wnd,
+ wxT("ABCDEFGHIj"),
+ true,
+ wxAUI_BUTTON_STATE_HIDDEN,
+ &x_ext);
return s.y+3;
}
m_art = new wxAuiDefaultTabArt;
AddButton(wxAUI_BUTTON_LEFT, wxLEFT);
- AddButton(wxAUI_BUTTON_RIGHT, wxRIGHT);
+ AddButton(wxAUI_BUTTON_RIGHT, wxRIGHT);
+ AddButton(wxAUI_BUTTON_WINDOWLIST, wxRIGHT);
AddButton(wxAUI_BUTTON_CLOSE, wxRIGHT);
}
m_flags = flags;
// check for new close button settings
+ RemoveButton(wxAUI_BUTTON_LEFT);
+ RemoveButton(wxAUI_BUTTON_RIGHT);
+ RemoveButton(wxAUI_BUTTON_WINDOWLIST);
RemoveButton(wxAUI_BUTTON_CLOSE);
+
+
+ if (flags & wxAUI_NB_SCROLL_BUTTONS)
+ {
+ AddButton(wxAUI_BUTTON_LEFT, wxLEFT);
+ AddButton(wxAUI_BUTTON_RIGHT, wxRIGHT);
+ }
+
+ if (flags & wxAUI_NB_WINDOWLIST_BUTTON)
+ {
+ AddButton(wxAUI_BUTTON_WINDOWLIST, wxRIGHT);
+ }
+
if (flags & wxAUI_NB_CLOSE_BUTTON)
{
AddButton(wxAUI_BUTTON_CLOSE, wxRIGHT);
// Render() renders the tab catalog to the specified DC
// It is a virtual function and can be overridden to
// provide custom drawing capabilities
-void wxAuiTabContainer::Render(wxDC* raw_dc)
+void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd)
{
wxMemoryDC dc;
wxBitmap bmp;
int x_extent = 0;
wxSize size = m_art->GetTabSize(&dc,
+ wnd,
page.caption,
page.active,
close_button ?
// draw background
- m_art->DrawBackground(&dc, m_rect);
+ m_art->DrawBackground(&dc, wnd, m_rect);
// draw buttons
int left_buttons_width = 0;
button_rect.SetWidth(offset);
m_art->DrawButton(&dc,
+ wnd,
button_rect,
button.id,
button.cur_state,
wxRect button_rect(offset, 1, 1000, m_rect.height);
m_art->DrawButton(&dc,
+ wnd,
button_rect,
button.id,
button.cur_state,
rect.x = offset;
- m_art->DrawTab(&dc,
- rect,
- page.caption,
- page.active,
- tab_button.cur_state,
- &page.rect,
- &tab_button.rect,
- &x_extent);
+ m_art->DrawTab(&dc,
+ wnd,
+ rect,
+ page.caption,
+ page.active,
+ tab_button.cur_state,
+ &page.rect,
+ &tab_button.rect,
+ &x_extent);
if (page.active)
{
rect.x = active_offset;
m_art->DrawTab(&dc,
- rect,
- page.caption,
- page.active,
- tab_button.cur_state,
- &page.rect,
- &tab_button.rect,
- &x_extent);
+ wnd,
+ rect,
+ page.caption,
+ page.active,
+ tab_button.cur_state,
+ &page.rect,
+ &tab_button.rect,
+ &x_extent);
}
dc.DestroyClippingRegion();
dc.SetFont(GetFont());
if (GetPageCount() > 0)
- Render(&dc);
+ Render(&dc, this);
}
void wxAuiTabCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt))
Refresh();
Update();
}
+ }
+ else if (button == wxAUI_BUTTON_WINDOWLIST)
+ {
+ wxArrayString as;
+
+ size_t i, page_count = m_pages.GetCount();
+ for (i = 0; i < page_count; ++i)
+ {
+ wxAuiNotebookPage& page = m_pages.Item(i);
+ as.Add(page.caption);
+ }
+
+ int idx = GetArtProvider()->ShowWindowList(this, as, GetActivePage());
+
+ if (idx != -1)
+ {
+ wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, m_windowId);
+ e.SetSelection(idx);
+ e.SetOldSelection(GetActivePage());
+ e.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(e);
+ }
}
else
{
for (i = 0; i < page_count; ++i)
{
wxAuiNotebookPage& page = pages.Item(i);
- page.window->SetSize(m_rect.x, m_rect.y+tab_height, m_rect.width, m_rect.height-tab_height);
+ page.window->SetSize(m_rect.x, m_rect.y+tab_height,
+ m_rect.width, m_rect.height-tab_height);
if (page.window->IsKindOf(CLASSINFO(wxAuiMDIChildFrame)))
{