diff --git a/contrib/samples/mmedia/mmboard.cpp b/contrib/samples/mmedia/mmboard.cpp index a11274d13c..a5450edfa1 100644 --- a/contrib/samples/mmedia/mmboard.cpp +++ b/contrib/samples/mmedia/mmboard.cpp @@ -379,11 +379,11 @@ void MMBoardFrame::CloseVideoWindow() { if (!m_video_window) return; - - m_sizer->Remove(m_video_window); + + m_sizer->Detach( m_video_window ); delete m_video_window; m_video_window = NULL; - + m_sizer->Fit(this); } diff --git a/contrib/src/fl/gcupdatesmgr.cpp b/contrib/src/fl/gcupdatesmgr.cpp index 5790666c9d..3a55694b35 100644 --- a/contrib/src/fl/gcupdatesmgr.cpp +++ b/contrib/src/fl/gcupdatesmgr.cpp @@ -172,8 +172,8 @@ void cbGCUpdatesMgr::UpdateNow() // number of bars, that were changed in the current row int nBars = 0; - wxRect r1 = pRow->mUMgrData.mPrevBounds; - wxRect r2 = pRow->mBoundsInParent; + //wxRect r1 = pRow->mUMgrData.mPrevBounds; + //wxRect r2 = pRow->mBoundsInParent; if ( WasChanged( pRow->mUMgrData, pRow->mBoundsInParent ) ) diff --git a/contrib/src/gizmos/multicell.cpp b/contrib/src/gizmos/multicell.cpp index 632c054674..a7a9020b38 100644 --- a/contrib/src/gizmos/multicell.cpp +++ b/contrib/src/gizmos/multicell.cpp @@ -296,11 +296,10 @@ void wxMultiCellSizer::RecalcSizes() wxPoint c_point; wxSize c_size; - wxNode *current; - current = m_children.GetFirst(); + wxSizerItemList::Node *current = m_children.GetFirst(); while (current != NULL) { - wxSizerItem *item = (wxSizerItem*) current->Data(); + wxSizerItem *item = current->GetData(); wxMultiCellItemHandle *rect; if (item != NULL && @@ -372,7 +371,7 @@ void wxMultiCellSizer::RecalcSizes() } item->SetDimension(c_point, c_size); } - current = current->Next(); + current = current->GetNext(); } } //--------------------------------------------------------------------------- @@ -404,10 +403,10 @@ void wxMultiCellSizer :: GetMinimums() m_weights[x]->SetWidth(0); } - wxNode *node = m_children.GetFirst(); + wxSizerItemList::Node *node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*) node->Data(); + wxSizerItem *item = node->GetData(); wxMultiCellItemHandle *rect; if (item != NULL && (rect = (wxMultiCellItemHandle *)item->GetUserData()) != NULL) @@ -506,7 +505,7 @@ void wxMultiCellSizer :: GetMinimums() m_maxWidth[col] = wxMax(m_maxWidth[col], m_defaultCellSize.GetWidth()); m_weights[col]->SetWidth(wxMax(m_weights[col]->GetWidth(), rect->GetWeight().GetWidth())); } - node = node->Next(); + node = node->GetNext(); } } } // wxMultiCellSizer :: GetMinimums diff --git a/docs/latex/wx/sizer.tex b/docs/latex/wx/sizer.tex index d6b90c9c4e..84fce8519a 100644 --- a/docs/latex/wx/sizer.tex +++ b/docs/latex/wx/sizer.tex @@ -128,19 +128,14 @@ Here, the sizer will do the actual calculation of its children minimal sizes. \func{bool}{Detach}{\param{wxSizer* }{sizer}} -\func{bool}{Detach}{\param{int }{nth}} +\func{bool}{Detach}{\param{size\_t }{index}} Detach a child from the sizer without destroying it. {\it window} is the window to be -detached, {\it sizer} is the equivalent sizer and {\it nth} is the position of +detached, {\it sizer} is the equivalent sizer and {\it index} is the position of the child in the sizer, typically 0 for the first item. This method does not cause any layout or resizing to take place, call \helpref{wxSizer::Layout}{wxsizerlayout} to update the layout "on screen" after detaching a child from the sizer. -{\bf NB:} Detaching a wxWindow from a wxSizer is equivalent to Removing it. There is -currently no wxSizer method that will detach and destroy a window automatically. -You must either act to destroy it yourself, or allow its parent to destroy it in the -normal course of events. - Returns TRUE if the child item was found and detached, FALSE otherwise. \wxheading{See also} @@ -191,15 +186,15 @@ size of all the children and their borders or the minimal size set by \membersection{wxSizer::Insert}\label{wxsizerinsert} -\func{void}{Insert}{\param{int }{before}, \param{wxWindow* }{window}, \param{int }{proportion = 0},\param{int }{flag = 0}, \param{int }{border = 0}, \param{wxObject* }{userData = NULL}} +\func{void}{Insert}{\param{size\_t }{index}, \param{wxWindow* }{window}, \param{int }{proportion = 0},\param{int }{flag = 0}, \param{int }{border = 0}, \param{wxObject* }{userData = NULL}} -\func{void}{Insert}{\param{int }{before}, \param{wxSizer* }{sizer}, \param{int }{proportion = 0}, \param{int }{flag = 0}, \param{int }{border = 0}, \param{wxObject* }{userData = NULL}} +\func{void}{Insert}{\param{size\_t }{index}, \param{wxSizer* }{sizer}, \param{int }{proportion = 0}, \param{int }{flag = 0}, \param{int }{border = 0}, \param{wxObject* }{userData = NULL}} -\func{void}{Insert}{\param{int }{before}, \param{int }{width}, \param{int }{height}, \param{int }{proportion = 0}, \param{int }{flag = 0}, \param{int }{border = 0}, \param{wxObject* }{userData = NULL}} +\func{void}{Insert}{\param{size\_t }{index}, \param{int }{width}, \param{int }{height}, \param{int }{proportion = 0}, \param{int }{flag = 0}, \param{int }{border = 0}, \param{wxObject* }{userData = NULL}} -Insert a child into the sizer. +Insert a child into the sizer before any existing item at {\it index}. -\docparam{before}{The position this child should assume in the sizer.} +\docparam{index}{The position this child should assume in the sizer.} See \helpref{wxSizer::Add}{wxsizeradd} for the meaning of the other parameters. @@ -236,16 +231,18 @@ and sizes. \func{bool}{Remove}{\param{wxSizer* }{sizer}} -\func{bool}{Remove}{\param{int }{nth}} +\func{bool}{Remove}{\param{size\_t }{index}} -Removes a child from the sizer. {\it window} is the window to be removed, {\it sizer} is the -equivalent sizer and {\it nth} is the position of the child in the sizer, typically 0 for -the first item. This method does not cause any layout or resizing to take place, call +Removes a child from the sizer and destroys it. {\it sizer} is the wxSizer to be removed, +{\it index} is the position of the child in the sizer, typically 0 for the first item. +This method does not cause any layout or resizing to take place, call \helpref{wxSizer::Layout}{wxsizerlayout} to update the layout "on screen" after removing a child from the sizer. -{\bf NB:} wxWindows are not deleted by Remove, but wxSizers are. To remove a sizer without -deleting it, use \helpref{wxSizer::Detach}{wxsizerdetach} instead. +{\bf NB:} The method taking a wxWindow* parameter is deprecated. For historical reasons +it does not destroy the window as would usually be expected from Remove. You should use +\helpref{wxSizer::Detach}{wxsizerdetach} in new code instead. There is currently no wxSizer +method that will both detach and destroy a wxWindow item. Returns TRUE if the child item was found and removed, FALSE otherwise. @@ -275,7 +272,7 @@ bigger. \func{void}{SetItemMinSize}{\param{wxSizer* }{sizer}, \param{int}{ width}, \param{int}{ height}} -\func{void}{SetItemMinSize}{\param{int}{ pos}, \param{int}{ width}, \param{int}{ height}} +\func{void}{SetItemMinSize}{\param{size\_t }{index}, \param{int}{ width}, \param{int}{ height}} Set an item's minimum size by window, sizer, or position. The item will be found recursively in the sizer's descendants. This function enables an application to set the size of an item @@ -307,6 +304,8 @@ minimal size. For windows with managed scrollbars this will set them appropriate \func{void}{Show}{\param{wxSizer* }{sizer}, \param{bool }{show = TRUE}} -Shows or hides a window or sizer. To make a sizer item disappear or -reappear, use Show() followed by Layout(). +\func{void}{Show}{\param{size\_t }{index}, \param{bool }{show = TRUE}} + +Shows or hides the {\it window}, {\it sizer}, or item at {\it index}. +To make a sizer item disappear or reappear, use Show() followed by Layout(). diff --git a/include/wx/event.h b/include/wx/event.h index 744263bba4..a07982cc9a 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -863,8 +863,8 @@ public: // Get Y position wxCoord GetY() const { return m_y; } - // deprecated - long KeyCode() const { return m_keyCode; } + // deprecated, Use GetKeyCode instead. + wxDEPRECATED( long KeyCode() const ); virtual wxEvent *Clone() const { return new wxKeyEvent(*this); } diff --git a/include/wx/sizer.h b/include/wx/sizer.h index 10899c790a..3c41d70a55 100644 --- a/include/wx/sizer.h +++ b/include/wx/sizer.h @@ -6,6 +6,7 @@ // Created: // RCS-ID: $Id$ // Copyright: (c) Robin Dunn, Dirk Holtwick and Robert Roebling +// (c) 2003, Ron Lee // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -38,13 +39,26 @@ class WXDLLEXPORT wxSizerItem: public wxObject { public: // spacer - wxSizerItem( int width, int height, int option, int flag, int border, wxObject* userData); + wxSizerItem( int width, + int height, + int proportion, + int flag, + int border, + wxObject* userData); // window - wxSizerItem( wxWindow *window, int option, int flag, int border, wxObject* userData ); + wxSizerItem( wxWindow *window, + int proportion, + int flag, + int border, + wxObject* userData ); // subsizer - wxSizerItem( wxSizer *sizer, int option, int flag, int border, wxObject* userData ); + wxSizerItem( wxSizer *sizer, + int proportion, + int flag, + int border, + wxObject* userData ); ~wxSizerItem(); @@ -60,6 +74,8 @@ public: wxSize GetMinSize() { return m_minSize; } + void SetInitSize( int x, int y ) + { m_minSize.x = x; m_minSize.y = y; } void SetRatio( int width, int height ) // if either of dimensions is zero, ratio is assumed to be 1 @@ -76,16 +92,22 @@ public: bool IsSizer(); bool IsSpacer(); - void SetInitSize( int x, int y ) - { m_minSize.x = x; m_minSize.y = y; } - void SetOption( int option ) - { m_option = option; } + // Deprecated in 2.6, use {G,S}etProportion instead. + wxDEPRECATED( void SetOption( int option ) ); + wxDEPRECATED( int GetOption() const ); + + void SetProportion( int proportion ) + { m_proportion = proportion; } + int GetProportion() const + { return m_proportion; } void SetFlag( int flag ) { m_flag = flag; } + int GetFlag() const + { return m_flag; } void SetBorder( int border ) { m_border = border; } - void Show ( bool show ) - { m_show = show; } + int GetBorder() const + { return m_border; } wxWindow *GetWindow() const { return m_window; } @@ -95,14 +117,15 @@ public: { return m_sizer; } void SetSizer( wxSizer *sizer ) { m_sizer = sizer; } - int GetOption() const - { return m_option; } - int GetFlag() const - { return m_flag; } - int GetBorder() const - { return m_border; } + const wxSize &GetSpacer() const + { return m_size; } + void SetSpacer( const wxSize &size ) + { m_size = size; m_minSize = size; } + + void Show ( bool show ); bool IsShown() const { return m_show; } + wxObject* GetUserData() { return m_userData; } wxPoint GetPosition() @@ -114,25 +137,28 @@ protected: wxSize m_size; wxPoint m_pos; wxSize m_minSize; - int m_option; + int m_proportion; int m_border; int m_flag; - // If TRUE, then this item is considered in the layout + // If true, then this item is considered in the layout // calculation. Otherwise, it is skipped over. bool m_show; - // als: aspect ratio can always be calculated from m_size, - // but this would cause precision loss when the window - // is shrinked. it is safer to preserve initial value. + + // Aspect ratio can always be calculated from m_size, + // but this would cause precision loss when the window + // is shrunk. It is safer to preserve the initial value. float m_ratio; wxObject *m_userData; -private: - DECLARE_CLASS(wxSizerItem); + DECLARE_DYNAMIC_CLASS(wxSizerItem); DECLARE_NO_COPY_CLASS(wxSizerItem) }; +WX_DECLARE_EXPORTED_LIST( wxSizerItem, wxSizerItemList ); + + //--------------------------------------------------------------------------- // wxSizer //--------------------------------------------------------------------------- @@ -144,30 +170,75 @@ public: ~wxSizer(); /* These should be called Append() really. */ - virtual void Add( wxWindow *window, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); - virtual void Add( wxSizer *sizer, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); - virtual void Add( int width, int height, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); + virtual void Add( wxWindow *window, + int proportion = 0, + int flag = 0, + int border = 0, + wxObject* userData = NULL ); + virtual void Add( wxSizer *sizer, + int proportion = 0, + int flag = 0, + int border = 0, + wxObject* userData = NULL ); + virtual void Add( int width, + int height, + int proportion = 0, + int flag = 0, + int border = 0, + wxObject* userData = NULL ); + virtual void Add( wxSizerItem *item ); - virtual void Insert( int before, wxWindow *window, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); - virtual void Insert( int before, wxSizer *sizer, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); - virtual void Insert( int before, int width, int height, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); + virtual void Insert( size_t index, + wxWindow *window, + int proportion = 0, + int flag = 0, + int border = 0, + wxObject* userData = NULL ); + virtual void Insert( size_t index, + wxSizer *sizer, + int proportion = 0, + int flag = 0, + int border = 0, + wxObject* userData = NULL ); + virtual void Insert( size_t index, + int width, + int height, + int proportion = 0, + int flag = 0, + int border = 0, + wxObject* userData = NULL ); + virtual void Insert( size_t index, + wxSizerItem *item ); - virtual void Prepend( wxWindow *window, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); - virtual void Prepend( wxSizer *sizer, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); - virtual void Prepend( int width, int height, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); + virtual void Prepend( wxWindow *window, + int proportion = 0, + int flag = 0, + int border = 0, + wxObject* userData = NULL ); + virtual void Prepend( wxSizer *sizer, + int proportion = 0, + int flag = 0, + int border = 0, + wxObject* userData = NULL ); + virtual void Prepend( int width, + int height, + int proportion = 0, + int flag = 0, + int border = 0, + wxObject* userData = NULL ); + virtual void Prepend( wxSizerItem *item ); - // Remove will delete a sizer, but not a window. - virtual bool Remove( wxWindow *window ); + // Deprecated in 2.6 since historically it does not delete the window, + // use Detach instead. + wxDEPRECATED( virtual bool Remove( wxWindow *window ) ); virtual bool Remove( wxSizer *sizer ); - virtual bool Remove( int pos ); + virtual bool Remove( size_t index ); - // Detach will never destroy a sizer or window. - virtual bool Detach( wxWindow *window ) - { return Remove( window ); } + virtual bool Detach( wxWindow *window ); virtual bool Detach( wxSizer *sizer ); - virtual bool Detach( int pos ); + virtual bool Detach( size_t index ); - virtual void Clear( bool delete_windows=FALSE ); + virtual void Clear( bool delete_windows=false ); virtual void DeleteWindows(); void SetMinSize( int width, int height ) @@ -187,10 +258,10 @@ public: bool SetItemMinSize( wxSizer *sizer, wxSize size ) { return DoSetItemMinSize( sizer, size.x, size.y ); } - bool SetItemMinSize( int pos, int width, int height ) - { return DoSetItemMinSize( pos, width, height ); } - bool SetItemMinSize( int pos, wxSize size ) - { return DoSetItemMinSize( pos, size.x, size.y ); } + bool SetItemMinSize( size_t index, int width, int height ) + { return DoSetItemMinSize( index, width, height ); } + bool SetItemMinSize( size_t index, wxSize size ) + { return DoSetItemMinSize( index, size.x, size.y ); } wxSize GetSize() { return m_size; } @@ -210,31 +281,36 @@ public: void SetSizeHints( wxWindow *window ); void SetVirtualSizeHints( wxWindow *window ); - wxList& GetChildren() + wxSizerItemList& GetChildren() { return m_children; } void SetDimension( int x, int y, int width, int height ); - // Manage whether individual windows or sub-sizers are considered + // Manage whether individual scene items are considered // in the layout calculations or not. - void Show( wxWindow *window, bool show = TRUE ); - void Hide( wxWindow *window ) - { Show (window, FALSE); } - void Show( wxSizer *sizer, bool show = TRUE ); + void Show( wxWindow *window, bool show = true ); + void Show( wxSizer *sizer, bool show = true ); + void Show( size_t index, bool show = true ); + void Hide( wxSizer *sizer ) - { Show (sizer, FALSE); } + { Show( sizer, false ); } + void Hide( wxWindow *window ) + { Show( window, false ); } + void Hide( size_t index ) + { Show( index, false ); } bool IsShown( wxWindow *window ); bool IsShown( wxSizer *sizer ); + bool IsShown( size_t index ); // Recursively call wxWindow::Show () on all sizer items. void ShowItems (bool show); protected: - wxSize m_size; - wxSize m_minSize; - wxPoint m_position; - wxList m_children; + wxSize m_size; + wxSize m_minSize; + wxPoint m_position; + wxSizerItemList m_children; wxSize GetMaxWindowSize( wxWindow *window ); wxSize GetMinWindowSize( wxWindow *window ); @@ -246,10 +322,9 @@ protected: virtual void DoSetMinSize( int width, int height ); virtual bool DoSetItemMinSize( wxWindow *window, int width, int height ); virtual bool DoSetItemMinSize( wxSizer *sizer, int width, int height ); - virtual bool DoSetItemMinSize( int pos, int width, int height ); + virtual bool DoSetItemMinSize( size_t index, int width, int height ); -private: - DECLARE_CLASS(wxSizer); + DECLARE_DYNAMIC_CLASS(wxSizer); }; //--------------------------------------------------------------------------- @@ -285,8 +360,7 @@ protected: void SetItemBounds( wxSizerItem *item, int x, int y, int w, int h ); -private: - DECLARE_CLASS(wxGridSizer); + DECLARE_DYNAMIC_CLASS(wxGridSizer); }; //--------------------------------------------------------------------------- @@ -316,8 +390,7 @@ protected: void CreateArrays(); -private: - DECLARE_CLASS(wxFlexGridSizer); + DECLARE_DYNAMIC_CLASS(wxFlexGridSizer); DECLARE_NO_COPY_CLASS(wxFlexGridSizer) }; @@ -347,8 +420,7 @@ protected: int m_fixedWidth; int m_fixedHeight; -private: - DECLARE_CLASS(wxBoxSizer); + DECLARE_DYNAMIC_CLASS(wxBoxSizer); }; //--------------------------------------------------------------------------- @@ -373,8 +445,7 @@ public: protected: wxStaticBox *m_staticBox; -private: - DECLARE_CLASS(wxStaticBoxSizer); + DECLARE_DYNAMIC_CLASS(wxStaticBoxSizer); DECLARE_NO_COPY_CLASS(wxStaticBoxSizer) }; @@ -402,8 +473,7 @@ public: protected: wxNotebook *m_notebook; -private: - DECLARE_CLASS(wxNotebookSizer); + DECLARE_DYNAMIC_CLASS(wxNotebookSizer); DECLARE_NO_COPY_CLASS(wxNotebookSizer) }; diff --git a/samples/checklst/checklst.cpp b/samples/checklst/checklst.cpp index 6a16991ec3..41c135cc71 100644 --- a/samples/checklst/checklst.cpp +++ b/samples/checklst/checklst.cpp @@ -290,7 +290,7 @@ void CheckListBoxFrame::OnToggleSelection(wxCommandEvent& event) { wxSizer *sizer = m_panel->GetSizer(); - sizer->Remove(m_pListBox); + sizer->Detach( m_pListBox ); delete m_pListBox; CreateCheckListbox(event.IsChecked() ? wxLB_EXTENDED : 0); diff --git a/samples/opengl/cube/cube.cpp b/samples/opengl/cube/cube.cpp index 2172b9472c..7bab5df213 100644 --- a/samples/opengl/cube/cube.cpp +++ b/samples/opengl/cube/cube.cpp @@ -78,7 +78,7 @@ ScanCodeCtrl::ScanCodeCtrl( wxWindow* parent, wxWindowID id, int code, void ScanCodeCtrl::OnKeyDown( wxKeyEvent& event ) { wxString buf; - buf.Printf( "0x%04x", event.KeyCode() ); + buf.Printf( "0x%04x", event.GetKeyCode() ); SetValue( buf ); } diff --git a/samples/thread/thread.cpp b/samples/thread/thread.cpp index 25cec9bb13..5e4e5f34c8 100644 --- a/samples/thread/thread.cpp +++ b/samples/thread/thread.cpp @@ -223,7 +223,7 @@ void *MyThread::Entry() { wxString text; - text.Printf(wxT("Thread 0x%x started (priority = %u).\n"), + text.Printf(wxT("Thread 0x%lx started (priority = %u).\n"), GetId(), GetPriority()); WriteText(text); // wxLogMessage(text); -- test wxLog thread safeness @@ -234,14 +234,14 @@ void *MyThread::Entry() if ( TestDestroy() ) break; - text.Printf(wxT("[%u] Thread 0x%x here.\n"), m_count, GetId()); + text.Printf(wxT("[%u] Thread 0x%lx here.\n"), m_count, GetId()); WriteText(text); // wxSleep() can't be called from non-GUI thread! wxThread::Sleep(1000); } - text.Printf(wxT("Thread 0x%x finished.\n"), GetId()); + text.Printf(wxT("Thread 0x%lx finished.\n"), GetId()); WriteText(text); // wxLogMessage(text); -- test wxLog thread safeness diff --git a/samples/widgets/button.cpp b/samples/widgets/button.cpp index 0652f1c7a6..973ba9f9d1 100644 --- a/samples/widgets/button.cpp +++ b/samples/widgets/button.cpp @@ -266,7 +266,7 @@ void ButtonWidgetsPage::CreateButton() size_t count = m_sizerButton->GetChildren().GetCount(); for ( size_t n = 0; n < count; n++ ) { - m_sizerButton->Remove(0); + m_sizerButton->Remove( 0u ); } delete m_button; diff --git a/samples/widgets/combobox.cpp b/samples/widgets/combobox.cpp index f37c4721a5..42883f7e31 100644 --- a/samples/widgets/combobox.cpp +++ b/samples/widgets/combobox.cpp @@ -340,7 +340,7 @@ void ComboboxWidgetsPage::CreateCombo() items.Add(m_combobox->GetString(n)); } - m_sizerCombo->Remove(m_combobox); + m_sizerCombo->Detach( m_combobox ); delete m_combobox; } diff --git a/samples/widgets/gauge.cpp b/samples/widgets/gauge.cpp index dc9e21bb09..2678098955 100644 --- a/samples/widgets/gauge.cpp +++ b/samples/widgets/gauge.cpp @@ -271,7 +271,7 @@ void GaugeWidgetsPage::CreateGauge() { val = m_gauge->GetValue(); - m_sizerGauge->Remove(m_gauge); + m_sizerGauge->Detach( m_gauge ); delete m_gauge; } diff --git a/samples/widgets/listbox.cpp b/samples/widgets/listbox.cpp index fa0f8be644..9b074e4c91 100644 --- a/samples/widgets/listbox.cpp +++ b/samples/widgets/listbox.cpp @@ -351,7 +351,7 @@ void ListboxWidgetsPage::CreateLbox() items.Add(m_lbox->GetString(n)); } - m_sizerLbox->Remove(m_lbox); + m_sizerLbox->Detach( m_lbox ); delete m_lbox; } diff --git a/samples/widgets/notebook.cpp b/samples/widgets/notebook.cpp index 6d6ea11165..8534da6d87 100644 --- a/samples/widgets/notebook.cpp +++ b/samples/widgets/notebook.cpp @@ -397,7 +397,7 @@ void NotebookWidgetsPage::CreateNotebook() notebook->GetPageImage(n)); } - m_sizerNotebook->Remove(notebook); + m_sizerNotebook->Detach( notebook ); delete notebook; // restore selection diff --git a/samples/widgets/radiobox.cpp b/samples/widgets/radiobox.cpp index 90cb6bb5fa..962529b808 100644 --- a/samples/widgets/radiobox.cpp +++ b/samples/widgets/radiobox.cpp @@ -288,7 +288,7 @@ void RadioWidgetsPage::CreateRadio() { sel = m_radio->GetSelection(); - m_sizerRadio->Remove(m_radio); + m_sizerRadio->Detach( m_radio ); delete m_radio; } diff --git a/samples/widgets/slider.cpp b/samples/widgets/slider.cpp index 9793994642..caf36d4113 100644 --- a/samples/widgets/slider.cpp +++ b/samples/widgets/slider.cpp @@ -315,13 +315,13 @@ void SliderWidgetsPage::CreateSlider() val = valOld; } - m_sizerSlider->Remove(m_slider); + m_sizerSlider->Detach( m_slider ); if ( m_sizerSlider->GetChildren().GetCount() ) { // we have 2 spacers, remove them too - m_sizerSlider->Remove((int)0); - m_sizerSlider->Remove((int)0); + m_sizerSlider->Remove( 0u ); + m_sizerSlider->Remove( 0u ); } delete m_slider; diff --git a/samples/widgets/spinbtn.cpp b/samples/widgets/spinbtn.cpp index fa798dd287..cbf9acc024 100644 --- a/samples/widgets/spinbtn.cpp +++ b/samples/widgets/spinbtn.cpp @@ -285,13 +285,13 @@ void SpinBtnWidgetsPage::CreateSpin() val = valOld; } - m_sizerSpin->Remove(m_spinbtn); - m_sizerSpin->Remove(m_spinctrl); + m_sizerSpin->Detach( m_spinbtn ); + m_sizerSpin->Detach( m_spinctrl ); // there are 3 spacers left - m_sizerSpin->Remove((int)0); - m_sizerSpin->Remove((int)0); - m_sizerSpin->Remove((int)0); + m_sizerSpin->Remove( 0u ); + m_sizerSpin->Remove( 0u ); + m_sizerSpin->Remove( 0u ); delete m_spinbtn; delete m_spinctrl; diff --git a/samples/widgets/textctrl.cpp b/samples/widgets/textctrl.cpp index 9fc4ead7eb..0832b9a65d 100644 --- a/samples/widgets/textctrl.cpp +++ b/samples/widgets/textctrl.cpp @@ -542,7 +542,7 @@ void TextWidgetsPage::CreateText() { valueOld = m_text->GetValue(); - m_sizerText->Remove(m_text); + m_sizerText->Detach( m_text ); delete m_text; } else diff --git a/src/common/event.cpp b/src/common/event.cpp index 6e578317e2..324e98031d 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -570,7 +570,12 @@ wxKeyEvent::wxKeyEvent(const wxKeyEvent& evt) m_uniChar = evt.m_uniChar; #endif } - + +long wxKeyEvent::KeyCode() const +{ + return m_keyCode; +} + wxWindowCreateEvent::wxWindowCreateEvent(wxWindow *win) { SetEventType(wxEVT_CREATE); diff --git a/src/common/prntbase.cpp b/src/common/prntbase.cpp index c1c3a939d0..34cfe0b5a1 100644 --- a/src/common/prntbase.cpp +++ b/src/common/prntbase.cpp @@ -285,7 +285,7 @@ void wxPreviewControlBar::OnPrint(wxCommandEvent& WXUNUSED(event)) void wxPreviewControlBar::OnChar(wxKeyEvent &event) { - switch(event.KeyCode()) + switch(event.GetKeyCode()) { case WXK_NEXT: OnNext(); break; diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index 79da84f99d..d99c1d7213 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -6,6 +6,7 @@ // Created: // RCS-ID: $Id$ // Copyright: (c) Robin Dunn, Dirk Holtwick and Robert Roebling +// (c) 2003, Ron Lee // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -24,6 +25,7 @@ #include "wx/utils.h" #include "wx/statbox.h" #include "wx/notebook.h" +#include //--------------------------------------------------------------------------- @@ -39,32 +41,35 @@ IMPLEMENT_ABSTRACT_CLASS(wxStaticBoxSizer, wxBoxSizer) IMPLEMENT_ABSTRACT_CLASS(wxNotebookSizer, wxSizer) #endif +WX_DEFINE_EXPORTED_LIST( wxSizerItemList ); + + //--------------------------------------------------------------------------- // wxSizerItem //--------------------------------------------------------------------------- -wxSizerItem::wxSizerItem( int width, int height, int option, int flag, int border, wxObject* userData ) - : m_window( 0 ) - , m_sizer( 0 ) +wxSizerItem::wxSizerItem( int width, int height, int proportion, int flag, int border, wxObject* userData ) + : m_window( NULL ) + , m_sizer( NULL ) , m_size( wxSize( width, height ) ) // size is set directly , m_minSize( m_size ) // minimal size is the initial size - , m_option( option ) + , m_proportion( proportion ) , m_border( border ) , m_flag( flag ) - , m_show( TRUE ) // Cannot be changed + , m_show( true ) , m_userData( userData ) { SetRatio( m_size ); } -wxSizerItem::wxSizerItem( wxWindow *window, int option, int flag, int border, wxObject* userData ) +wxSizerItem::wxSizerItem( wxWindow *window, int proportion, int flag, int border, wxObject* userData ) : m_window( window ) - , m_sizer( 0 ) + , m_sizer( NULL ) , m_minSize( window->GetSize() ) // minimal size is the initial size - , m_option( option ) + , m_proportion( proportion ) , m_border( border ) , m_flag( flag ) - , m_show( TRUE ) + , m_show( true ) , m_userData( userData ) { // aspect ratio calculated from initial size @@ -73,14 +78,14 @@ wxSizerItem::wxSizerItem( wxWindow *window, int option, int flag, int border, wx // m_size is calculated later } -wxSizerItem::wxSizerItem( wxSizer *sizer, int option, int flag, int border, wxObject* userData ) - : m_window( 0 ) +wxSizerItem::wxSizerItem( wxSizer *sizer, int proportion, int flag, int border, wxObject* userData ) + : m_window( NULL ) , m_sizer( sizer ) - , m_option( option ) + , m_proportion( proportion ) , m_border( border ) , m_flag( flag ) - , m_show( TRUE ) - , m_ratio( 0 ) + , m_show( true ) + , m_ratio( 0.0 ) , m_userData( userData ) { // m_minSize is calculated later @@ -242,15 +247,37 @@ bool wxSizerItem::IsSpacer() return (m_window == NULL) && (m_sizer == NULL); } +void wxSizerItem::Show( bool show ) +{ + m_show = show; + + if( IsWindow() ) + m_window->Show( show ); + else if( IsSizer() ) + m_sizer->ShowItems( show ); + + // ... nothing else to do to hide/show spacers +} + +void wxSizerItem::SetOption( int option ) +{ + SetProportion( option ); +} + +int wxSizerItem::GetOption() const +{ + return GetProportion(); +} + + //--------------------------------------------------------------------------- // wxSizer //--------------------------------------------------------------------------- wxSizer::wxSizer() + : m_minSize( wxSize( 0, 0 ) ) { - m_children.DeleteContents( TRUE ); - m_minSize.x = 0; - m_minSize.y = 0; + m_children.DeleteContents( true ); } wxSizer::~wxSizer() @@ -258,148 +285,199 @@ wxSizer::~wxSizer() Clear(); } -void wxSizer::Add( wxWindow *window, int option, int flag, int border, wxObject* userData ) +void wxSizer::Add( wxWindow *window, int proportion, int flag, int border, wxObject* userData ) { - m_children.Append( new wxSizerItem( window, option, flag, border, userData ) ); - window->SetContainingSizer(this); + m_children.Append( new wxSizerItem( window, proportion, flag, border, userData ) ); + window->SetContainingSizer( this ); } -void wxSizer::Add( wxSizer *sizer, int option, int flag, int border, wxObject* userData ) +void wxSizer::Add( wxSizer *sizer, int proportion, int flag, int border, wxObject* userData ) { - m_children.Append( new wxSizerItem( sizer, option, flag, border, userData ) ); + m_children.Append( new wxSizerItem( sizer, proportion, flag, border, userData ) ); } -void wxSizer::Add( int width, int height, int option, int flag, int border, wxObject* userData ) +void wxSizer::Add( int width, int height, int proportion, int flag, int border, wxObject* userData ) { - m_children.Append( new wxSizerItem( width, height, option, flag, border, userData ) ); + m_children.Append( new wxSizerItem( width, height, proportion, flag, border, userData ) ); } -void wxSizer::Prepend( wxWindow *window, int option, int flag, int border, wxObject* userData ) +void wxSizer::Add( wxSizerItem *item ) { - m_children.Insert( new wxSizerItem( window, option, flag, border, userData ) ); - window->SetContainingSizer(this); + m_children.Append( item ); + + if( item->GetWindow() ) + item->GetWindow()->SetContainingSizer( this ); } -void wxSizer::Prepend( wxSizer *sizer, int option, int flag, int border, wxObject* userData ) +void wxSizer::Prepend( wxWindow *window, int proportion, int flag, int border, wxObject* userData ) { - m_children.Insert( new wxSizerItem( sizer, option, flag, border, userData ) ); + m_children.Insert( new wxSizerItem( window, proportion, flag, border, userData ) ); + window->SetContainingSizer( this ); } -void wxSizer::Prepend( int width, int height, int option, int flag, int border, wxObject* userData ) +void wxSizer::Prepend( wxSizer *sizer, int proportion, int flag, int border, wxObject* userData ) { - m_children.Insert( new wxSizerItem( width, height, option, flag, border, userData ) ); + m_children.Insert( new wxSizerItem( sizer, proportion, flag, border, userData ) ); } -void wxSizer::Insert( int before, wxWindow *window, int option, int flag, int border, wxObject* userData ) +void wxSizer::Prepend( int width, int height, int proportion, int flag, int border, wxObject* userData ) { - m_children.Insert( before, new wxSizerItem( window, option, flag, border, userData ) ); - window->SetContainingSizer(this); + m_children.Insert( new wxSizerItem( width, height, proportion, flag, border, userData ) ); } -void wxSizer::Insert( int before, wxSizer *sizer, int option, int flag, int border, wxObject* userData ) +void wxSizer::Prepend( wxSizerItem *item ) { - m_children.Insert( before, new wxSizerItem( sizer, option, flag, border, userData ) ); + m_children.Insert( item ); + + if( item->GetWindow() ) + item->GetWindow()->SetContainingSizer( this ); } -void wxSizer::Insert( int before, int width, int height, int option, int flag, int border, wxObject* userData ) +void wxSizer::Insert( size_t index, + wxWindow *window, + int proportion, + int flag, + int border, + wxObject* userData ) { - m_children.Insert( before, new wxSizerItem( width, height, option, flag, border, userData ) ); + m_children.Insert( index, + new wxSizerItem( window, proportion, flag, border, userData ) ); + window->SetContainingSizer( this ); +} + +void wxSizer::Insert( size_t index, + wxSizer *sizer, + int proportion, + int flag, + int border, + wxObject* userData ) +{ + m_children.Insert( index, + new wxSizerItem( sizer, proportion, flag, border, userData ) ); +} + +void wxSizer::Insert( size_t index, + int width, + int height, + int proportion, + int flag, + int border, + wxObject* userData ) +{ + m_children.Insert( index, + new wxSizerItem( width, height, proportion, flag, border, userData ) ); +} + +void wxSizer::Insert( size_t index, wxSizerItem *item ) +{ + m_children.Insert( index, item ); + + if( item->GetWindow() ) + item->GetWindow()->SetContainingSizer( this ); } bool wxSizer::Remove( wxWindow *window ) { - wxASSERT( window ); - - wxNode *node = m_children.First(); - while (node) - { - wxSizerItem *item = (wxSizerItem*)node->Data(); - if (item->GetWindow() == window) - { - item->GetWindow()->SetContainingSizer(NULL); - m_children.DeleteNode( node ); - return TRUE; - } - node = node->Next(); - } - - return FALSE; + return Detach( window ); } bool wxSizer::Remove( wxSizer *sizer ) { - wxASSERT( sizer ); + wxASSERT_MSG( sizer, _T("Removing NULL sizer") ); - wxNode *node = m_children.First(); + wxSizerItemList::Node *node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*)node->Data(); + wxSizerItem *item = node->GetData(); + if (item->GetSizer() == sizer) - { - m_children.DeleteNode( node ); - return TRUE; - } - node = node->Next(); + return m_children.DeleteNode( node ); + + node = node->GetNext(); } - return FALSE; + return false; } -bool wxSizer::Remove( int pos ) +bool wxSizer::Remove( size_t index ) { - if ((size_t)pos >= m_children.GetCount()) - return FALSE; - wxNode *node = m_children.Nth( pos ); - if (!node) return FALSE; + wxCHECK_MSG( index < m_children.GetCount(), + false, + _T("Remove index is out of range") ); - m_children.DeleteNode( node ); + wxSizerItemList::Node *node = m_children.Item( index ); - return TRUE; + wxCHECK_MSG( node, false, _T("Failed to find child node") ); + + return m_children.DeleteNode( node ); } bool wxSizer::Detach( wxSizer *sizer ) { - wxASSERT( sizer ); + wxASSERT_MSG( sizer, _T("Detaching NULL sizer") ); - wxNode *node = m_children.First(); + wxSizerItemList::Node *node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*)node->Data(); + wxSizerItem *item = node->GetData(); + if (item->GetSizer() == sizer) { item->DetachSizer(); - m_children.DeleteNode( node ); - return TRUE; + return m_children.DeleteNode( node ); } - node = node->Next(); + node = node->GetNext(); } - return FALSE; + return false; } -bool wxSizer::Detach( int pos ) +bool wxSizer::Detach( wxWindow *window ) { - if ((size_t)pos >= m_children.GetCount()) - return FALSE; - wxNode *node = m_children.Nth( pos ); - if (!node) return FALSE; + wxASSERT_MSG( window, _T("Detaching NULL window") ); - ( (wxSizerItem*)node->Data() )->DetachSizer(); - m_children.DeleteNode( node ); + wxSizerItemList::Node *node = m_children.GetFirst(); + while (node) + { + wxSizerItem *item = node->GetData(); - return TRUE; + if (item->GetWindow() == window) + { + item->GetWindow()->SetContainingSizer( NULL ); + return m_children.DeleteNode( node ); + } + node = node->GetNext(); + } + + return false; +} + +bool wxSizer::Detach( size_t index ) +{ + wxCHECK_MSG( index < m_children.GetCount(), + false, + _T("Detach index is out of range") ); + + wxSizerItemList::Node *node = m_children.Item( index ); + + wxCHECK_MSG( node, false, _T("Failed to find child node") ); + + node->GetData()->DetachSizer(); + + return m_children.DeleteNode( node ); } void wxSizer::Clear( bool delete_windows ) { // First clear the ContainingSizer pointers - wxNode *node = m_children.First(); + wxSizerItemList::Node *node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*)node->Data(); + wxSizerItem *item = node->GetData(); + if (item->IsWindow()) - item->GetWindow()->SetContainingSizer(NULL); - node = node->Next(); + item->GetWindow()->SetContainingSizer( NULL ); + node = node->GetNext(); } // Destroy the windows if needed @@ -412,12 +490,13 @@ void wxSizer::Clear( bool delete_windows ) void wxSizer::DeleteWindows() { - wxNode *node = m_children.First(); + wxSizerItemList::Node *node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*)node->Data(); + wxSizerItem *item = node->GetData(); + item->DeleteWindows(); - node = node->Next(); + node = node->GetNext(); } } @@ -484,9 +563,10 @@ wxSize wxSizer::GetMaxWindowSize( wxWindow *window ) wxSize wxSizer::GetMinWindowSize( wxWindow *window ) { - wxSize minSize( GetMinSize() ); - wxSize size( window->GetSize() ); - wxSize client_size( window->GetClientSize() ); + wxSize minSize( GetMinSize() ); + wxSize size( window->GetSize() ); + wxSize client_size( window->GetClientSize() ); + return wxSize( minSize.x+size.x-client_size.x, minSize.y+size.y-client_size.y ); } @@ -568,80 +648,88 @@ void wxSizer::DoSetMinSize( int width, int height ) bool wxSizer::DoSetItemMinSize( wxWindow *window, int width, int height ) { - wxASSERT( window ); + wxASSERT_MSG( window, _T("SetMinSize for NULL window") ); - wxNode *node = m_children.First(); + // Is it our immediate child? + + wxSizerItemList::Node *node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*)node->Data(); + wxSizerItem *item = node->GetData(); + if (item->GetWindow() == window) { item->SetInitSize( width, height ); - return TRUE; + return true; } - node = node->Next(); + node = node->GetNext(); } - node = m_children.First(); + // No? Search any subsizers we own then + + node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*)node->Data(); - if (item->GetSizer()) + wxSizerItem *item = node->GetData(); + + if ( item->GetSizer() && + item->GetSizer()->DoSetItemMinSize( window, width, height ) ) { - // It's a sizer, so lets search recursively. - if (item->GetSizer()->DoSetItemMinSize( window, width, height )) - { - // A child sizer found the requested windw, exit. - return TRUE; - } + // A child sizer found the requested windw, exit. + return true; } - node = node->Next(); + node = node->GetNext(); } - return FALSE; + return false; } bool wxSizer::DoSetItemMinSize( wxSizer *sizer, int width, int height ) { - wxASSERT( sizer ); + wxASSERT_MSG( sizer, _T("SetMinSize for NULL sizer") ); - wxNode *node = m_children.First(); + // Is it our immediate child? + + wxSizerItemList::Node *node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*)node->Data(); + wxSizerItem *item = node->GetData(); + if (item->GetSizer() == sizer) { item->GetSizer()->DoSetMinSize( width, height ); - return TRUE; + return true; } - node = node->Next(); + node = node->GetNext(); } - node = m_children.First(); + // No? Search any subsizers we own then + + node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*)node->Data(); - if (item->GetSizer()) + wxSizerItem *item = node->GetData(); + + if ( item->GetSizer() && + item->GetSizer()->DoSetItemMinSize( sizer, width, height ) ) { - // It's a sizer, so lets search recursively. - if (item->GetSizer()->DoSetItemMinSize( sizer, width, height )) - { - // A child sizer found the requested windw, exit. - return TRUE; - } + // A child found the requested sizer, exit. + return true; } - node = node->Next(); + node = node->GetNext(); } - return FALSE; + return false; } -bool wxSizer::DoSetItemMinSize( int pos, int width, int height ) +bool wxSizer::DoSetItemMinSize( size_t index, int width, int height ) { - wxNode *node = m_children.Nth( pos ); - if (!node) return FALSE; + wxSizerItemList::Node *node = m_children.Item( index ); + + wxCHECK_MSG( node, false, _T("Failed to find child node") ); + + wxSizerItem *item = node->GetData(); - wxSizerItem *item = (wxSizerItem*) node->Data(); if (item->GetSizer()) { // Sizers contains the minimal size in them, if not calculated ... @@ -653,111 +741,129 @@ bool wxSizer::DoSetItemMinSize( int pos, int width, int height ) item->SetInitSize( width, height ); } - return TRUE; + return true; } -void wxSizer::Show(wxWindow *window, bool show) +void wxSizer::Show( wxWindow *window, bool show ) { - wxNode *node = m_children.GetFirst(); + wxASSERT_MSG( window, _T("Show for NULL window") ); + + wxSizerItemList::Node *node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*) node->Data(); + wxSizerItem *item = node->GetData(); - if (item->IsWindow() && item->GetWindow() == window) + if (item->GetWindow() == window) { - item->Show(show); - window->Show(show); - return; + item->Show( show ); + break; } - node = node->Next(); + node = node->GetNext(); } } -void wxSizer::Show(wxSizer *sizer, bool show) +void wxSizer::Show( wxSizer *sizer, bool show ) { - wxNode *node = m_children.GetFirst(); + wxASSERT_MSG( sizer, _T("Show for NULL sizer") ); + + wxSizerItemList::Node *node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*) node->Data(); + wxSizerItem *item = node->GetData(); - if (item->IsSizer() && item->GetSizer() == sizer) + if (item->GetSizer() == sizer) { - item->Show(show); - sizer->ShowItems(show); - return; + item->Show( show ); + break; } - node = node->Next(); + node = node->GetNext(); } } -void wxSizer::ShowItems (bool show) +void wxSizer::Show( size_t index, bool show ) { - wxNode *node = m_children.GetFirst(); + wxCHECK_RET( index < m_children.GetCount(), + _T("Show index is out of range") ); + + m_children.Item( index )->GetData()->Show( show ); +} + +void wxSizer::ShowItems( bool show ) +{ + wxSizerItemList::Node *node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*) node->Data(); - - if (item->IsWindow()) - item->GetWindow()->Show (show); - else if (item->IsSizer()) - item->GetSizer()->ShowItems (show); - - node = node->Next(); + node->GetData()->Show( show ); + node = node->GetNext(); } } -bool wxSizer::IsShown (wxWindow *window) +bool wxSizer::IsShown( wxWindow *window ) { - wxNode *node = m_children.GetFirst(); + wxSizerItemList::Node *node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*) node->Data(); + wxSizerItem *item = node->GetData(); - if (item->IsWindow() && item->GetWindow() == window) + if (item->GetWindow() == window) { return item->IsShown(); } - node = node->Next(); + node = node->GetNext(); } - return FALSE; + wxFAIL_MSG( _T("IsShown failed to find sizer item") ); + + return false; } -bool wxSizer::IsShown (wxSizer *sizer) +bool wxSizer::IsShown( wxSizer *sizer ) { - wxNode *node = m_children.GetFirst(); + wxSizerItemList::Node *node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*) node->Data(); + wxSizerItem *item = node->GetData(); - if (item->IsSizer() && item->GetSizer() == sizer) + if (item->GetSizer() == sizer) { return item->IsShown(); } - node = node->Next(); + node = node->GetNext(); } - return FALSE; + wxFAIL_MSG( _T("IsShown failed to find sizer item") ); + + return false; } +bool wxSizer::IsShown( size_t index ) +{ + wxCHECK_MSG( index < m_children.GetCount(), + false, + _T("IsShown index is out of range") ); + + return m_children.Item( index )->GetData()->IsShown(); +} + + //--------------------------------------------------------------------------- // wxGridSizer //--------------------------------------------------------------------------- wxGridSizer::wxGridSizer( int rows, int cols, int vgap, int hgap ) + : m_rows( rows ) + , m_cols( cols ) + , m_vgap( vgap ) + , m_hgap( hgap ) { - m_rows = rows; - m_cols = cols; - m_vgap = vgap; - m_hgap = hgap; } wxGridSizer::wxGridSizer( int cols, int vgap, int hgap ) + : m_rows( 0 ) + , m_cols( cols ) + , m_vgap( vgap ) + , m_hgap( hgap ) { - m_rows = 0; - m_cols = cols; - m_vgap = vgap; - m_hgap = hgap; } int wxGridSizer::CalcRowsCols(int& nrows, int& ncols) const @@ -807,10 +913,11 @@ void wxGridSizer::RecalcSizes() int i = r * ncols + c; if (i < nitems) { - wxNode *node = m_children.Nth( i ); - wxASSERT( node ); + wxSizerItemList::Node *node = m_children.Item( i ); - SetItemBounds( (wxSizerItem*) node->Data(), x, y, w, h); + wxASSERT_MSG( node, _T("Failed to find SizerItemList node") ); + + SetItemBounds( node->GetData(), x, y, w, h); } y = y + h + m_vgap; } @@ -828,19 +935,20 @@ wxSize wxGridSizer::CalcMin() int w = 0; int h = 0; - wxNode *node = m_children.First(); + wxSizerItemList::Node *node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*)node->Data(); - wxSize sz( item->CalcMin() ); + wxSizerItem *item = node->GetData(); + wxSize sz( item->CalcMin() ); + w = wxMax( w, sz.x ); h = wxMax( h, sz.y ); - node = node->Next(); + node = node->GetNext(); } - return wxSize(ncols * w + (ncols-1) * m_hgap, - nrows * h + (nrows-1) * m_vgap); + return wxSize( ncols * w + (ncols-1) * m_hgap, + nrows * h + (nrows-1) * m_vgap ); } void wxGridSizer::SetItemBounds( wxSizerItem *item, int x, int y, int w, int h ) @@ -883,16 +991,16 @@ void wxGridSizer::SetItemBounds( wxSizerItem *item, int x, int y, int w, int h ) wxFlexGridSizer::wxFlexGridSizer( int rows, int cols, int vgap, int hgap ) : wxGridSizer( rows, cols, vgap, hgap ) + , m_rowHeights( NULL ) + , m_colWidths( NULL ) { - m_rowHeights = (int*) NULL; - m_colWidths = (int*) NULL; } wxFlexGridSizer::wxFlexGridSizer( int cols, int vgap, int hgap ) : wxGridSizer( cols, vgap, hgap ) + , m_rowHeights( NULL ) + , m_colWidths( NULL ) { - m_rowHeights = (int*) NULL; - m_colWidths = (int*) NULL; } wxFlexGridSizer::~wxFlexGridSizer() @@ -979,13 +1087,14 @@ void wxFlexGridSizer::RecalcSizes() int i = r * ncols + c; if (i < nitems) { - wxNode *node = m_children.Nth( i ); - wxASSERT( node ); + wxSizerItemList::Node *node = m_children.Item( i ); + + wxASSERT_MSG( node, _T("Failed to find node") ); int w = wxMax( 0, wxMin( m_colWidths[c], sz.x - x ) ); int h = wxMax( 0, wxMin( m_rowHeights[r], sz.y - y ) ); - SetItemBounds( (wxSizerItem*) node->Data(), x, y, w, h); + SetItemBounds( node->GetData(), x, y, w, h); } y = y + m_rowHeights[r] + m_vgap; } @@ -1001,18 +1110,20 @@ wxSize wxFlexGridSizer::CalcMin() CreateArrays(); - int i = 0; - wxNode *node = m_children.First(); + int i = 0; + wxSizerItemList::Node *node = m_children.GetFirst(); + while (node) { - wxSizerItem *item = (wxSizerItem*)node->Data(); - wxSize sz( item->CalcMin() ); - int row = i / ncols; - int col = i % ncols; + wxSizerItem *item = node->GetData(); + wxSize sz( item->CalcMin() ); + int row = i / ncols; + int col = i % ncols; + m_rowHeights[ row ] = wxMax( sz.y, m_rowHeights[ row ] ); m_colWidths[ col ] = wxMax( sz.x, m_colWidths[ col ] ); - node = node->Next(); + node = node->GetNext(); i++; } @@ -1051,8 +1162,8 @@ void wxFlexGridSizer::RemoveGrowableCol( size_t WXUNUSED(idx) ) //--------------------------------------------------------------------------- wxBoxSizer::wxBoxSizer( int orient ) + : m_orient( orient ) { - m_orient = orient; } void wxBoxSizer::RecalcSizes() @@ -1078,22 +1189,23 @@ void wxBoxSizer::RecalcSizes() wxPoint pt( m_position ); - wxNode *node = m_children.GetFirst(); + wxSizerItemList::Node *node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*) node->Data(); + wxSizerItem *item = node->GetData(); + if (item->IsShown()) { int weight = 1; - if (item->GetOption()) - weight = item->GetOption(); + if (item->GetProportion()) + weight = item->GetProportion(); wxSize size( item->CalcMin() ); if (m_orient == wxVERTICAL) { wxCoord height = size.y; - if (item->GetOption()) + if (item->GetProportion()) { height = (delta * weight) + extra; extra = 0; // only the first item will get the remainder as extra size @@ -1118,7 +1230,7 @@ void wxBoxSizer::RecalcSizes() else { wxCoord width = size.x; - if (item->GetOption()) + if (item->GetProportion()) { width = (delta * weight) + extra; extra = 0; // only the first item will get the remainder as extra size @@ -1142,7 +1254,7 @@ void wxBoxSizer::RecalcSizes() } } - node = node->Next(); + node = node->GetNext(); } } @@ -1158,14 +1270,16 @@ wxSize wxBoxSizer::CalcMin() m_fixedHeight = 0; // Find how long each stretch unit needs to be - int stretchSize = 1; - wxNode *node = m_children.GetFirst(); + int stretchSize = 1; + wxSizerItemList::Node *node = m_children.GetFirst(); + while (node) { - wxSizerItem *item = (wxSizerItem*) node->Data(); - if (item->IsShown() && item->GetOption() != 0) + wxSizerItem *item = node->GetData(); + + if (item->IsShown() && item->GetProportion() != 0) { - int stretch = item->GetOption(); + int stretch = item->GetProportion(); wxSize size( item->CalcMin() ); int sizePerStretch; // Integer division rounded up is (a + b - 1) / b @@ -1176,24 +1290,26 @@ wxSize wxBoxSizer::CalcMin() if (sizePerStretch > stretchSize) stretchSize = sizePerStretch; } - node = node->Next(); + node = node->GetNext(); } + // Calculate overall minimum size node = m_children.GetFirst(); while (node) { - wxSizerItem *item = (wxSizerItem*) node->Data(); + wxSizerItem *item = node->GetData(); + if (item->IsShown()) { - m_stretchable += item->GetOption(); + m_stretchable += item->GetProportion(); wxSize size( item->CalcMin() ); - if (item->GetOption() != 0) + if (item->GetProportion() != 0) { if (m_orient == wxHORIZONTAL) - size.x = stretchSize * item->GetOption(); + size.x = stretchSize * item->GetProportion(); else - size.y = stretchSize * item->GetOption(); + size.y = stretchSize * item->GetProportion(); } if (m_orient == wxHORIZONTAL) @@ -1207,7 +1323,7 @@ wxSize wxBoxSizer::CalcMin() m_minWidth = wxMax( m_minWidth, size.x ); } - if (item->GetOption() == 0) + if (item->GetProportion() == 0) { if (m_orient == wxVERTICAL) { @@ -1221,7 +1337,7 @@ wxSize wxBoxSizer::CalcMin() } } } - node = node->Next(); + node = node->GetNext(); } return wxSize( m_minWidth, m_minHeight ); @@ -1234,15 +1350,15 @@ wxSize wxBoxSizer::CalcMin() #if wxUSE_STATBOX wxStaticBoxSizer::wxStaticBoxSizer( wxStaticBox *box, int orient ) - : wxBoxSizer( orient ) + : wxBoxSizer( orient ) + , m_staticBox( box ) { wxASSERT_MSG( box, wxT("wxStaticBoxSizer needs a static box") ); - - m_staticBox = box; } -static void GetStaticBoxBorders(wxStaticBox *box, - int *borderTop, int *borderOther) +static void GetStaticBoxBorders( wxStaticBox *box, + int *borderTop, + int *borderOther) { // this has to be done platform by platform as there is no way to // guess the thickness of a wxStaticBox border @@ -1297,10 +1413,9 @@ wxSize wxStaticBoxSizer::CalcMin() #if wxUSE_NOTEBOOK wxNotebookSizer::wxNotebookSizer( wxNotebook *nb ) + : m_notebook( nb ) { wxASSERT_MSG( nb, wxT("wxNotebookSizer needs a notebook") ); - - m_notebook = nb; } void wxNotebookSizer::RecalcSizes() diff --git a/src/common/valtext.cpp b/src/common/valtext.cpp index fc7bc3e4c7..8511859d66 100644 --- a/src/common/valtext.cpp +++ b/src/common/valtext.cpp @@ -269,7 +269,7 @@ void wxTextValidator::OnChar(wxKeyEvent& event) if ( m_validatorWindow ) { - int keyCode = (int)event.KeyCode(); + int keyCode = event.GetKeyCode(); // we don't filter special keys and Delete if ( diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index e962ac1f81..ea559005e6 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -274,7 +274,7 @@ wxWindowBase::~wxWindowBase() #endif // wxUSE_CONSTRAINTS if ( m_containingSizer ) - m_containingSizer->Remove((wxWindow*)this); + m_containingSizer->Detach( (wxWindow*)this ); if ( m_windowSizer ) delete m_windowSizer; diff --git a/src/generic/calctrl.cpp b/src/generic/calctrl.cpp index bf04de7d3a..688946988a 100644 --- a/src/generic/calctrl.cpp +++ b/src/generic/calctrl.cpp @@ -1571,7 +1571,7 @@ void wxCalendarCtrl::OnYearChange(wxCommandEvent& event) void wxCalendarCtrl::OnChar(wxKeyEvent& event) { wxDateTime target; - switch ( event.KeyCode() ) + switch ( event.GetKeyCode() ) { case _T('+'): case WXK_ADD: diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 3e78ad3a4b..a3390abd70 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -923,7 +923,7 @@ void wxGridCellNumberEditor::StartingKey(wxKeyEvent& event) { if ( !HasRange() ) { - int keycode = (int) event.KeyCode(); + int keycode = event.GetKeyCode(); if ( isdigit(keycode) || keycode == '+' || keycode == '-' || keycode == WXK_NUMPAD0 || keycode == WXK_NUMPAD1 @@ -1063,7 +1063,7 @@ void wxGridCellFloatEditor::Reset() void wxGridCellFloatEditor::StartingKey(wxKeyEvent& event) { - int keycode = (int)event.KeyCode(); + int keycode = event.GetKeyCode(); if ( isdigit(keycode) || keycode == '+' || keycode == '-' || keycode == '.' || keycode == WXK_NUMPAD0 || keycode == WXK_NUMPAD1 @@ -1495,7 +1495,7 @@ wxString wxGridCellChoiceEditor::GetValue() const void wxGridCellEditorEvtHandler::OnKeyDown(wxKeyEvent& event) { - switch ( event.KeyCode() ) + switch ( event.GetKeyCode() ) { case WXK_ESCAPE: m_editor->Reset(); @@ -1520,7 +1520,7 @@ void wxGridCellEditorEvtHandler::OnKeyDown(wxKeyEvent& event) void wxGridCellEditorEvtHandler::OnChar(wxKeyEvent& event) { - switch ( event.KeyCode() ) + switch ( event.GetKeyCode() ) { case WXK_ESCAPE: case WXK_TAB: @@ -6082,7 +6082,7 @@ void wxGrid::OnKeyDown( wxKeyEvent& event ) // try local handlers // - switch ( event.KeyCode() ) + switch ( event.GetKeyCode() ) { case WXK_UP: if ( event.ControlDown() ) @@ -6247,7 +6247,7 @@ void wxGrid::OnKeyDown( wxKeyEvent& event ) // is special and will always start editing, for // other keys - ask the editor itself - if ( (event.KeyCode() == WXK_F2 && !event.HasModifiers()) + if ( (event.GetKeyCode() == WXK_F2 && !event.HasModifiers()) || editor->IsAcceptedKey(event) ) { // ensure cell is visble @@ -6285,7 +6285,7 @@ void wxGrid::OnKeyUp( wxKeyEvent& event ) { // try local handlers // - if ( event.KeyCode() == WXK_SHIFT ) + if ( event.GetKeyCode() == WXK_SHIFT ) { if ( m_selectingTopLeft != wxGridNoCellCoords && m_selectingBottomRight != wxGridNoCellCoords ) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 9d120c8dac..2f36eec8a0 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -3408,7 +3408,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) wxListEvent le( wxEVT_COMMAND_LIST_KEY_DOWN, GetParent()->GetId() ); le.m_itemIndex = m_current; GetLine(m_current)->GetItem( 0, le.m_item ); - le.m_code = (int)event.KeyCode(); + le.m_code = event.GetKeyCode(); le.SetEventObject( parent ); parent->GetEventHandler()->ProcessEvent( le ); } @@ -3425,7 +3425,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) ke.SetEventObject( parent ); if (parent->GetEventHandler()->ProcessEvent( ke )) return; - if (event.KeyCode() == WXK_TAB) + if (event.GetKeyCode() == WXK_TAB) { wxNavigationKeyEvent nevent; nevent.SetWindowChange( event.ControlDown() ); @@ -3443,7 +3443,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) return; } - switch (event.KeyCode()) + switch (event.GetKeyCode()) { case WXK_UP: if ( m_current > 0 ) diff --git a/src/generic/logg.cpp b/src/generic/logg.cpp index 5e1c3ce2b4..08c07e692c 100644 --- a/src/generic/logg.cpp +++ b/src/generic/logg.cpp @@ -998,14 +998,14 @@ void wxLogDialog::OnDetails(wxCommandEvent& WXUNUSED(event)) { m_btnDetails->SetLabel(ms_details + EXPAND_SUFFIX); - sizer->Remove(m_listctrl); + sizer->Detach( m_listctrl ); #if wxUSE_STATLINE - sizer->Remove(m_statline); + sizer->Detach( m_statline ); #endif // wxUSE_STATLINE #if wxUSE_FILE - sizer->Remove(m_btnSave); + sizer->Detach( m_btnSave ); #endif // wxUSE_FILE } else // show details now diff --git a/src/generic/proplist.cpp b/src/generic/proplist.cpp index cd6af4d9c1..4fa9768e1d 100644 --- a/src/generic/proplist.cpp +++ b/src/generic/proplist.cpp @@ -542,7 +542,7 @@ void wxPropertyListView::ShowListBoxControl(bool show) if (show) m_middleSizer->Prepend( m_valueList, 0, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, 3 ); else - m_middleSizer->Remove( 0 ); + m_middleSizer->Remove( 0u ); m_propertyWindow->Layout(); } diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index c02717df41..054b388fcc 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -2529,7 +2529,7 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event ) // home : go to root // end : go to last item without opening parents // alnum : start or continue searching for the item with this prefix - int keyCode = event.KeyCode(); + int keyCode = event.GetKeyCode(); switch ( keyCode ) { case '+': diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 8ed30aed10..ab4fa422ed 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -614,7 +614,7 @@ void wxComboBox::SetEditable( bool editable ) void wxComboBox::OnChar( wxKeyEvent &event ) { - if ( event.KeyCode() == WXK_RETURN ) + if ( event.GetKeyCode() == WXK_RETURN ) { wxString value = GetValue(); diff --git a/src/gtk/scrolwin.cpp b/src/gtk/scrolwin.cpp index a18ec663f7..ff1c2da0a0 100644 --- a/src/gtk/scrolwin.cpp +++ b/src/gtk/scrolwin.cpp @@ -895,7 +895,7 @@ void wxScrolledWindow::OnChar(wxKeyEvent& event) yScrollOld = GetScrollPos(wxVERTICAL); int dsty; - switch ( event.KeyCode() ) + switch ( event.GetKeyCode() ) { case WXK_PAGEUP: case WXK_PRIOR: diff --git a/src/gtk/spinctrl.cpp b/src/gtk/spinctrl.cpp index f04242957b..6eed70a286 100644 --- a/src/gtk/spinctrl.cpp +++ b/src/gtk/spinctrl.cpp @@ -255,7 +255,7 @@ void wxSpinCtrl::OnChar( wxKeyEvent &event ) { wxCHECK_RET( m_widget != NULL, wxT("invalid spin ctrl") ); - if (event.KeyCode() == WXK_RETURN) + if (event.GetKeyCode() == WXK_RETURN) { wxWindow *top_frame = m_parent; while (top_frame->GetParent() && !(top_frame->GetParent()->IsTopLevel())) diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index d449dcfb75..d238a913fa 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -1175,7 +1175,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event ) { wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); - if ((key_event.KeyCode() == WXK_RETURN) && (m_windowStyle & wxPROCESS_ENTER)) + if ((key_event.GetKeyCode() == WXK_RETURN) && (m_windowStyle & wxPROCESS_ENTER)) { wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); event.SetEventObject(this); @@ -1183,7 +1183,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event ) if (GetEventHandler()->ProcessEvent(event)) return; } - if ((key_event.KeyCode() == WXK_RETURN) && !(m_windowStyle & wxTE_MULTILINE)) + if ((key_event.GetKeyCode() == WXK_RETURN) && !(m_windowStyle & wxTE_MULTILINE)) { // This will invoke the dialog default action, such // as the clicking the default button. diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 8ed30aed10..ab4fa422ed 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -614,7 +614,7 @@ void wxComboBox::SetEditable( bool editable ) void wxComboBox::OnChar( wxKeyEvent &event ) { - if ( event.KeyCode() == WXK_RETURN ) + if ( event.GetKeyCode() == WXK_RETURN ) { wxString value = GetValue(); diff --git a/src/gtk1/scrolwin.cpp b/src/gtk1/scrolwin.cpp index a18ec663f7..ff1c2da0a0 100644 --- a/src/gtk1/scrolwin.cpp +++ b/src/gtk1/scrolwin.cpp @@ -895,7 +895,7 @@ void wxScrolledWindow::OnChar(wxKeyEvent& event) yScrollOld = GetScrollPos(wxVERTICAL); int dsty; - switch ( event.KeyCode() ) + switch ( event.GetKeyCode() ) { case WXK_PAGEUP: case WXK_PRIOR: diff --git a/src/gtk1/spinctrl.cpp b/src/gtk1/spinctrl.cpp index f04242957b..6eed70a286 100644 --- a/src/gtk1/spinctrl.cpp +++ b/src/gtk1/spinctrl.cpp @@ -255,7 +255,7 @@ void wxSpinCtrl::OnChar( wxKeyEvent &event ) { wxCHECK_RET( m_widget != NULL, wxT("invalid spin ctrl") ); - if (event.KeyCode() == WXK_RETURN) + if (event.GetKeyCode() == WXK_RETURN) { wxWindow *top_frame = m_parent; while (top_frame->GetParent() && !(top_frame->GetParent()->IsTopLevel())) diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index d449dcfb75..d238a913fa 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -1175,7 +1175,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event ) { wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); - if ((key_event.KeyCode() == WXK_RETURN) && (m_windowStyle & wxPROCESS_ENTER)) + if ((key_event.GetKeyCode() == WXK_RETURN) && (m_windowStyle & wxPROCESS_ENTER)) { wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); event.SetEventObject(this); @@ -1183,7 +1183,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event ) if (GetEventHandler()->ProcessEvent(event)) return; } - if ((key_event.KeyCode() == WXK_RETURN) && !(m_windowStyle & wxTE_MULTILINE)) + if ((key_event.GetKeyCode() == WXK_RETURN) && !(m_windowStyle & wxTE_MULTILINE)) { // This will invoke the dialog default action, such // as the clicking the default button.