wxDataViewCtrl (Andrew Xu).
- Fix item alignment in icon view in the generic wxListCtrl.
+GTK:
+
+- Fix wxNotebook best size calculation.
+
MSW:
- Fixed regression with initial focus in the dialogs in 2.9.3.
bool SetPageImage(size_t nPage, int nImage);
// control the appearance of the notebook pages
- // set the size (the same for all pages)
- void SetPageSize(const wxSize& size);
// set the padding between tabs (in pixels)
void SetPadding(const wxSize& padding);
// sets the size of the tabs (assumes all tabs are the same size)
void SetTabSize(const wxSize& sz);
+ // geometry
+ virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
// operations
EVT_MENU(ID_NEXT_PAGE, MyFrame::OnNextPage)
EVT_MENU(ID_CHANGE_SELECTION, MyFrame::OnChangeSelection)
EVT_MENU(ID_SET_SELECTION, MyFrame::OnSetSelection)
+ EVT_MENU(ID_GET_PAGE_SIZE, MyFrame::OnGetPageSize)
+ EVT_MENU(ID_SET_PAGE_SIZE, MyFrame::OnSetPageSize)
#if wxUSE_HELP
EVT_MENU(ID_CONTEXT_HELP, MyFrame::OnContextHelp)
menuPageOperations->AppendSeparator();
menuPageOperations->Append(ID_CHANGE_SELECTION, wxT("&Change selection to 0\tCtrl-0"));
menuPageOperations->Append(ID_SET_SELECTION, wxT("&Set selection to 0\tShift-Ctrl-0"));
+ menuPageOperations->AppendSeparator();
+ menuPageOperations->Append(ID_GET_PAGE_SIZE, "Sho&w page size");
+ menuPageOperations->Append(ID_SET_PAGE_SIZE, "Set &page size");
wxMenu *menuOperations = new wxMenu;
#if wxUSE_HELP
currBook->SetSelection(0);
}
+void MyFrame::OnGetPageSize(wxCommandEvent& WXUNUSED(event))
+{
+ wxBookCtrlBase* const currBook = GetCurrentBook();
+ if ( !currBook )
+ return;
+
+ const wxSize sizePage = currBook->GetPage(0)->GetSize();
+ const wxSize sizeBook = currBook->GetSize();
+
+ wxLogMessage("Page size is (%d, %d), book size (%d, %d)",
+ sizePage.x, sizePage.y,
+ sizeBook.x, sizeBook.y);
+}
+
+void MyFrame::OnSetPageSize(wxCommandEvent& WXUNUSED(event))
+{
+ wxBookCtrlBase* const currBook = GetCurrentBook();
+ if ( !currBook )
+ return;
+
+ const wxSize sizePage(300, 300);
+ currBook->SetPageSize(sizePage);
+
+ wxLogMessage("Page size set to (%d, %d)",
+ sizePage.x, sizePage.y);
+}
+
void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(event) )
{
static int s_nPages = wxNOT_FOUND;
void OnNextPage(wxCommandEvent& event);
void OnChangeSelection(wxCommandEvent &event);
void OnSetSelection(wxCommandEvent &event);
+ void OnGetPageSize(wxCommandEvent &event);
+ void OnSetPageSize(wxCommandEvent &event);
void OnAddSubPage(wxCommandEvent& event);
void OnAddPageBefore(wxCommandEvent& event);
ID_ADD_SUB_PAGE,
ID_CHANGE_SELECTION,
ID_SET_SELECTION,
+ ID_GET_PAGE_SIZE,
+ ID_SET_PAGE_SIZE,
#if wxUSE_HELP
ID_CONTEXT_HELP,
return true;
}
-void wxNotebook::SetPageSize( const wxSize &WXUNUSED(size) )
+wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
{
- wxFAIL_MSG( wxT("wxNotebook::SetPageSize not implemented") );
+ // Compute the max size of the tab labels.
+ wxSize sizeTabMax;
+ const size_t pageCount = GetPageCount();
+ for ( size_t n = 0; n < pageCount; n++ )
+ {
+ GtkRequisition req;
+ gtk_widget_size_request(GetNotebookPage(n)->m_box, &req);
+ sizeTabMax.IncTo(wxSize(req.width, req.height));
+ }
+
+ // Unfortunately this doesn't account for the real tab size and I don't
+ // know how to find it, e.g. where do the margins below come from.
+ const int PAGE_MARGIN = 3;
+ const int TAB_MARGIN = 4;
+
+ sizeTabMax.IncBy(3*TAB_MARGIN);
+
+ wxSize sizeFull(sizePage);
+ if ( IsVertical() )
+ sizeFull.y += sizeTabMax.y;
+ else
+ sizeFull.x += sizeTabMax.x;
+
+ sizeFull.IncBy(2*PAGE_MARGIN);
+
+ return sizeFull;
}
void wxNotebook::SetPadding( const wxSize &padding )