int clAuiSimpleTabArt::GetBestTabCtrlSize(wxWindow* wnd, const wxAuiNotebookPageArray& pages, const wxSize& required_bmp_size) { wxClientDC dc(wnd); dc.SetFont(m_measuring_font); int x_ext = 0; // sometimes a standard bitmap size needs to be enforced, especially // if some tabs have bitmaps and others don't. This is important because // it prevents the tab control from resizing when tabs are added. wxBitmap bmp; if (pages.GetCount() && pages.Item(0).bitmap.IsOk()) { bmp = pages.Item(0).bitmap; } wxSize s = GetTabSize(dc, wnd, wxT("ABCDEFGHIj"), bmp.IsOk() ? bmp : wxNullBitmap, true, wxAUI_BUTTON_STATE_HIDDEN, &x_ext); return s.y+3; }
int wxAuiGenericTabArt::GetBestTabCtrlSize(wxWindow* wnd, const wxAuiNotebookPageArray& pages, const wxSize& requiredBmp_size) { wxClientDC dc(wnd); dc.SetFont(m_measuringFont); // sometimes a standard bitmap size needs to be enforced, especially // if some tabs have bitmaps and others don't. This is important because // it prevents the tab control from resizing when tabs are added. wxBitmap measureBmp; if (requiredBmp_size.IsFullySpecified()) { measureBmp.Create(requiredBmp_size.x, requiredBmp_size.y); } int max_y = 0; size_t i, page_count = pages.GetCount(); for (i = 0; i < page_count; ++i) { wxAuiNotebookPage& page = pages.Item(i); wxBitmap bmp; if (measureBmp.IsOk()) bmp = measureBmp; else bmp = page.bitmap; // we don't use the caption text because we don't // want tab heights to be different in the case // of a very short piece of text on one tab and a very // tall piece of text on another tab int x_ext = 0; wxSize s = GetTabSize(dc, wnd, wxT("ABCDEFGHIj"), bmp, true, wxAUI_BUTTON_STATE_HIDDEN, &x_ext); max_y = wxMax(max_y, s.y); } return max_y+2; }
int gd::FlatAuiTabArt::ShowDropDown(wxWindow* wnd, const wxAuiNotebookPageArray& pages, int active_idx) { wxMenu menuPopup; size_t i, count = pages.GetCount(); for (i = 0; i < count; ++i) { const wxAuiNotebookPage& page = pages.Item(i); wxString caption = page.caption; // if there is no caption, make it a space. This will prevent // an assert in the menu code. if (caption.IsEmpty()) caption = wxT(" "); menuPopup.AppendCheckItem(1000+i, caption); } if (active_idx != -1) { menuPopup.Check(1000+active_idx, true); } // find out where to put the popup menu of window items wxPoint pt = ::wxGetMousePosition(); pt = wnd->ScreenToClient(pt); // 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; GDAuiCommandCapture* cc = new GDAuiCommandCapture; wnd->PushEventHandler(cc); wnd->PopupMenu(&menuPopup, pt); int command = cc->GetCommandId(); wnd->PopEventHandler(true); if (command >= 1000) return command-1000; return -1; }
int wxAuiSimpleTabArt::ShowDropDown(wxWindow* wnd, const wxAuiNotebookPageArray& pages, int active_idx) { wxMenu menuPopup; size_t i, count = pages.GetCount(); for (i = 0; i < count; ++i) { const wxAuiNotebookPage& page = pages.Item(i); menuPopup.AppendCheckItem(1000+i, page.caption); } 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; }