From 1f6831ea9bdb641c28a583b6cc329e38158eef3e Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Mon, 25 Jul 2011 22:31:17 +0000 Subject: [PATCH 01/52] Fixed containr.h compilation with gcc. At least apple-gcc 4.0 and 4.2 gave a compilation error on the three Connect calls in containr.h, insisting (unless using -fpermissive) on a declaration of Connect because there are no arguments to it that depend on a template parameter. Fixed by prepending BaseWindowClass to the Connect calls. Regression since r68363. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68420 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/containr.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/wx/containr.h b/include/wx/containr.h index 7cb13e8fc1..3e7b5e38c1 100644 --- a/include/wx/containr.h +++ b/include/wx/containr.h @@ -166,13 +166,13 @@ public: m_container.SetContainerWindow(this); #ifndef wxHAS_NATIVE_TAB_TRAVERSAL - Connect(wxEVT_NAVIGATION_KEY, + BaseWindowClass::Connect(wxEVT_NAVIGATION_KEY, wxNavigationKeyEventHandler(wxNavigationEnabled::OnNavigationKey)); - Connect(wxEVT_SET_FOCUS, + BaseWindowClass::Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(wxNavigationEnabled::OnFocus)); - Connect(wxEVT_CHILD_FOCUS, + BaseWindowClass::Connect(wxEVT_CHILD_FOCUS, wxChildFocusEventHandler(wxNavigationEnabled::OnChildFocus)); #endif // !wxHAS_NATIVE_TAB_TRAVERSAL } From bc91da96108226f34bbec4ae2664e0a5cd77b0fc Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Mon, 25 Jul 2011 23:31:01 +0000 Subject: [PATCH 02/52] Fixed wxOSX-Cocoa compilation. OS X' wxComboBox::Init does not exist anymore since r68366 but an implementation still was present in combobox_osx.cpp which is used in Cocoa compilation. Removed the function. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68421 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/combobox_osx.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/osx/combobox_osx.cpp b/src/osx/combobox_osx.cpp index 1f3190f085..fe9f812f75 100644 --- a/src/osx/combobox_osx.cpp +++ b/src/osx/combobox_osx.cpp @@ -25,10 +25,6 @@ wxComboBox::~wxComboBox() { } -void wxComboBox::Init() -{ -} - bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, From 9f1bf9401340bd1e3025ca1bd8111e7b6d2bf657 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 26 Jul 2011 11:31:21 +0000 Subject: [PATCH 03/52] Compilation fix: include wx/event.h from wx/containr.h. We now need wxEVT_XXX constants declarations in this file (at least when not wxHAS_NATIVE_TAB_TRAVERSAL) so include wx/event.h to fix PCH-less build of wxOSX. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68426 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/containr.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/wx/containr.h b/include/wx/containr.h index 3e7b5e38c1..29dba36d6b 100644 --- a/include/wx/containr.h +++ b/include/wx/containr.h @@ -14,6 +14,11 @@ #include "wx/defs.h" +#ifndef wxHAS_NATIVE_TAB_TRAVERSAL + // We need wxEVT_XXX declarations in this case. + #include "wx/event.h" +#endif + class WXDLLIMPEXP_FWD_CORE wxWindow; class WXDLLIMPEXP_FWD_CORE wxWindowBase; @@ -116,9 +121,6 @@ protected: #else // !wxHAS_NATIVE_TAB_TRAVERSAL -class WXDLLIMPEXP_FWD_CORE wxFocusEvent; -class WXDLLIMPEXP_FWD_CORE wxNavigationKeyEvent; - // ---------------------------------------------------------------------------- // wxControlContainer for TAB navigation implemented in wx itself // ---------------------------------------------------------------------------- From d298f18ffb4bd0bd758b10f34c9e01cd119d1365 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 26 Jul 2011 21:37:20 +0000 Subject: [PATCH 04/52] Mention wxGTK wxAnimation implementation limitations in the docs. The native GTK implementation doesn't provide information about the frames count nor access to individual frames. See #13365. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68437 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/wx/animate.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/interface/wx/animate.h b/interface/wx/animate.h index 5b4e5b5cde..19716e2c99 100644 --- a/interface/wx/animate.h +++ b/interface/wx/animate.h @@ -228,11 +228,17 @@ public: /** Returns the i-th frame as a wxImage. + + This method is not implemented in the native wxGTK implementation of + this class and always returns an invalid image there. */ virtual wxImage GetFrame(unsigned int i) const; /** Returns the number of frames for this animation. + + This method is not implemented in the native wxGTK implementation of + this class and always returns 0 there. */ virtual unsigned int GetFrameCount() const; From 6ce832135e0cd665403406e7276630f415a7875b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 29 Jul 2011 15:11:54 +0000 Subject: [PATCH 05/52] Add wxTextCtrl::PositionToCoords() functions for wxMSW and wxGTK. The new method allows to find the coordinates in pixels of the given character in a text control. Closes #13221. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68450 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/gtk/textctrl.h | 2 + include/wx/msw/textctrl.h | 2 + include/wx/textctrl.h | 24 ++++++++ interface/wx/textctrl.h | 22 +++++++ samples/text/text.cpp | 20 +++++++ src/common/textcmn.cpp | 13 ++++ src/gtk/textctrl.cpp | 31 ++++++++++ src/msw/textctrl.cpp | 87 +++++++++++++++++++++++++++ tests/controls/textctrltest.cpp | 102 ++++++++++++++++++++++++++++++++ 10 files changed, 304 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index a0ca39762d..8187f093a6 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -444,6 +444,7 @@ All: All (GUI): - Added documented, public wxNavigationEnabled<> class. +- Added wxTextCtrl::PositionToCoords() (Navaneeth). - Support float, double and file name values in wxGenericValidator (troelsk). - Fix keyboard navigation in wxGrid with hidden columns (ivan_14_32). - Add wxDataViewEvent::IsEditCancelled() (Allonii). diff --git a/include/wx/gtk/textctrl.h b/include/wx/gtk/textctrl.h index 9db822c90b..336a5cfa2e 100644 --- a/include/wx/gtk/textctrl.h +++ b/include/wx/gtk/textctrl.h @@ -167,6 +167,8 @@ protected: virtual void DoSetValue(const wxString &value, int flags = 0); + virtual wxPoint DoPositionToCoords(long pos) const; + // wrappers hiding the differences between functions doing the same thing // for GtkTextView and GtkEntry (all of them use current window style to // set the given characteristic) diff --git a/include/wx/msw/textctrl.h b/include/wx/msw/textctrl.h index 888ea4c76b..f8fdf1f1a8 100644 --- a/include/wx/msw/textctrl.h +++ b/include/wx/msw/textctrl.h @@ -198,6 +198,8 @@ protected: virtual void DoSetValue(const wxString &value, int flags = 0); + virtual wxPoint DoPositionToCoords(long pos) const; + // return true if this control has a user-set limit on amount of text (i.e. // the limit is due to a previous call to SetMaxLength() and not built in) bool HasSpaceLimit(unsigned int *len) const; diff --git a/include/wx/textctrl.h b/include/wx/textctrl.h index f26cb8aa10..d412a3dc43 100644 --- a/include/wx/textctrl.h +++ b/include/wx/textctrl.h @@ -574,6 +574,11 @@ public: virtual long XYToPosition(long x, long y) const = 0; virtual bool PositionToXY(long pos, long *x, long *y) const = 0; + // translate the given position (which is just an index in the text control) + // to client coordinates + wxPoint PositionToCoords(long pos) const; + + virtual void ShowPosition(long pos) = 0; // find the character at position given in pixels @@ -592,6 +597,13 @@ protected: virtual bool DoLoadFile(const wxString& file, int fileType); virtual bool DoSaveFile(const wxString& file, int fileType); + // Return true if the given position is valid, i.e. positive and less than + // the last position. + virtual bool IsValidPosition(long pos) const = 0; + + // Default stub implementation of PositionToCoords() always returns + // wxDefaultPosition. + virtual wxPoint DoPositionToCoords(long pos) const; // the name of the last file loaded with LoadFile() which will be used by // SaveFile() by default @@ -625,6 +637,12 @@ public: wxTextEntryBase::SetValue(value); } +protected: + virtual bool IsValidPosition(long pos) const + { + return pos >= 0 && pos <= GetLastPosition(); + } + private: wxDECLARE_NO_COPY_CLASS(wxTextCtrlIface); }; @@ -723,6 +741,12 @@ protected: virtual bool DoLoadFile(const wxString& file, int fileType); virtual bool DoSaveFile(const wxString& file, int fileType); + // Another wxTextAreaBase override. + virtual bool IsValidPosition(long pos) const + { + return pos >= 0 && pos <= GetLastPosition(); + } + // implement the wxTextEntry pure virtual method virtual wxWindow *GetEditableWindow() { return this; } diff --git a/interface/wx/textctrl.h b/interface/wx/textctrl.h index 746954eca8..6dfd914320 100644 --- a/interface/wx/textctrl.h +++ b/interface/wx/textctrl.h @@ -1348,6 +1348,28 @@ public: */ virtual bool PositionToXY(long pos, long* x, long* y) const; + /** + Converts given text position to client coordinates in pixels. + + This function allows to find where is the character at the given + position displayed in the text control. + + @onlyfor{wxmsw,wxgtk}. Additionally, wxGTK only implements this method + for multiline controls and ::wxDefaultPosition is always returned for + the single line ones. + + @param pos + Text position in 0 to GetLastPosition() range (inclusive). + @return + On success returns a wxPoint which contains client coordinates for + the given position in pixels, otherwise returns ::wxDefaultPosition. + + @since 2.9.3 + + @see XYToPosition(), PositionToXY() + */ + wxPoint PositionToCoords(long pos) const; + /** Saves the contents of the control in a text file. diff --git a/samples/text/text.cpp b/samples/text/text.cpp index 6c3ddf400a..d25968ce9e 100644 --- a/samples/text/text.cpp +++ b/samples/text/text.cpp @@ -128,6 +128,7 @@ public: void DoSelectText(); void DoMoveToEndOfText(); void DoMoveToEndOfEntry(); + void DoGetWindowCoordinates(); // return true if currently text control has any selection bool HasSelection() const @@ -217,6 +218,10 @@ public: void OnMoveToEndOfText( wxCommandEvent& WXUNUSED(event) ) { m_panel->DoMoveToEndOfText(); } + + void OnGetWindowCoordinates( wxCommandEvent& WXUNUSED(event) ) + { m_panel->DoGetWindowCoordinates(); } + void OnMoveToEndOfEntry( wxCommandEvent& WXUNUSED(event) ) { m_panel->DoMoveToEndOfEntry(); } @@ -415,6 +420,7 @@ enum TEXT_ADD_FREEZE, TEXT_ADD_LINE, TEXT_MOVE_ENDTEXT, + TEXT_GET_WINDOW_COORD, TEXT_MOVE_ENDENTRY, TEXT_SET_EDITABLE, TEXT_SET_ENABLED, @@ -513,6 +519,7 @@ bool MyApp::OnInit() menuText->Append(TEXT_LINE_UP, wxT("Scroll text one line up")); menuText->Append(TEXT_PAGE_DOWN, wxT("Scroll text one page down")); menuText->Append(TEXT_PAGE_UP, wxT("Scroll text one page up")); + menuText->Append(TEXT_GET_WINDOW_COORD, wxT("Get window coordinates")); menuText->AppendSeparator(); menuText->Append(TEXT_GET_LINE, wxT("Get the text of a line of the tabbed multiline")); menuText->Append(TEXT_GET_LINELENGTH, wxT("Get the length of a line of the tabbed multiline")); @@ -1318,6 +1325,18 @@ void MyPanel::DoMoveToEndOfText() m_multitext->SetFocus(); } +void MyPanel::DoGetWindowCoordinates() +{ + wxTextCtrl * const text = GetFocusedText(); + + const wxPoint pt0 = text->PositionToCoords(0); + const wxPoint ptCur = text->PositionToCoords(text->GetInsertionPoint()); + *m_log << "Current position coordinates: " + "(" << ptCur.x << ", " << ptCur.y << "), " + "first position coordinates: " + "(" << pt0.x << ", " << pt0.y << ")\n"; +} + void MyPanel::DoMoveToEndOfEntry() { m_text->SetInsertionPointEnd(); @@ -1380,6 +1399,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(TEXT_ADD_FREEZE, MyFrame::OnAddTextFreeze) EVT_MENU(TEXT_ADD_LINE, MyFrame::OnAddTextLine) EVT_MENU(TEXT_MOVE_ENDTEXT, MyFrame::OnMoveToEndOfText) + EVT_MENU(TEXT_GET_WINDOW_COORD, MyFrame::OnGetWindowCoordinates) EVT_MENU(TEXT_MOVE_ENDENTRY, MyFrame::OnMoveToEndOfEntry) EVT_MENU(TEXT_SET_EDITABLE, MyFrame::OnSetEditable) diff --git a/src/common/textcmn.cpp b/src/common/textcmn.cpp index 96f70e5d47..9e04aedcaa 100644 --- a/src/common/textcmn.cpp +++ b/src/common/textcmn.cpp @@ -1084,6 +1084,19 @@ wxTextAreaBase::HitTest(const wxPoint& WXUNUSED(pt), long * WXUNUSED(pos)) const return wxTE_HT_UNKNOWN; } +wxPoint wxTextAreaBase::PositionToCoords(long pos) const +{ + wxCHECK_MSG( IsValidPosition(pos), wxDefaultPosition, + wxS("Position argument out of range.") ); + + return DoPositionToCoords(pos); +} + +wxPoint wxTextAreaBase::DoPositionToCoords(long WXUNUSED(pos)) const +{ + return wxDefaultPosition; +} + #else // !wxUSE_TEXTCTRL // define this one even if !wxUSE_TEXTCTRL because it is also used by other diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index ee0c631afc..ae9f03cd16 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -1218,6 +1218,37 @@ int wxTextCtrl::GetLineLength(long lineNo) const } } +wxPoint wxTextCtrl::DoPositionToCoords(long pos) const +{ + if ( !IsMultiLine() ) + { + // Single line text entry (GtkTextEntry) doesn't have support for + // getting the coordinates for the given offset. Perhaps we could + // find them ourselves by using GetTextExtent() but for now just leave + // it unimplemented, this function is more useful for multiline + // controls anyhow. + return wxDefaultPosition; + } + + // Window coordinates for the given position is calculated by getting + // the buffer coordinates and converting them to window coordinates. + GtkTextView *textview = GTK_TEXT_VIEW(m_text); + + GtkTextIter iter; + gtk_text_buffer_get_iter_at_offset(m_buffer, &iter, pos); + + GdkRectangle bufferCoords; + gtk_text_view_get_iter_location(textview, &iter, &bufferCoords); + + gint winCoordX = 0, + winCoordY = 0; + gtk_text_view_buffer_to_window_coords(textview, GTK_TEXT_WINDOW_WIDGET, + bufferCoords.x, bufferCoords.y, + &winCoordX, &winCoordY); + + return wxPoint(winCoordX, winCoordY); +} + int wxTextCtrl::GetNumberOfLines() const { if ( IsMultiLine() ) diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 3cf85ba094..850ea6ee93 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -1489,6 +1489,93 @@ wxTextCtrl::HitTest(const wxPoint& pt, long *posOut) const return rc; } +wxPoint wxTextCtrl::DoPositionToCoords(long pos) const +{ + // FIXME: This code is broken for rich edit version 2.0 as it uses the same + // API as plain edit i.e. the coordinates are returned directly instead of + // filling the POINT passed as WPARAM with them but we can't distinguish + // between 2.0 and 3.0 unfortunately (see also the use of EM_POSFROMCHAR + // above). +#if wxUSE_RICHEDIT + if ( IsRich() ) + { + POINT pt; + LRESULT rc = ::SendMessage(GetHwnd(), EM_POSFROMCHAR, (WPARAM)&pt, pos); + if ( rc != -1 ) + return wxPoint(pt.x, pt.y); + } + else +#endif // wxUSE_RICHEDIT + { + LRESULT rc = ::SendMessage(GetHwnd(), EM_POSFROMCHAR, pos, 0); + if ( rc == -1 ) + { + // Finding coordinates for the last position of the control fails + // in plain EDIT control, try to compensate for it by finding it + // ourselves from the position of the previous character. + if ( pos < GetLastPosition() ) + { + // It's not the expected correctable failure case so just fail. + return wxDefaultPosition; + } + + if ( pos == 0 ) + { + // We're being asked the coordinates of the first (and last and + // only) position in an empty control. There is no way to get + // it directly with EM_POSFROMCHAR but EM_GETMARGINS returns + // the correct value for at least the horizontal offset. + rc = ::SendMessage(GetHwnd(), EM_GETMARGINS, 0, 0); + + // Text control seems to effectively add 1 to margin. + return wxPoint(LOWORD(rc) + 1, 1); + } + + // We do have a previous character, try to get its coordinates. + rc = ::SendMessage(GetHwnd(), EM_POSFROMCHAR, pos - 1, 0); + if ( rc == -1 ) + { + // If getting coordinates of the previous character failed as + // well, just give up. + return wxDefaultPosition; + } + + wxString prevChar = GetRange(pos - 1, pos); + wxSize prevCharSize = GetTextExtent(prevChar); + + if ( prevChar == wxT("\n" )) + { + // 'pos' is at the beginning of a new line so its X coordinate + // should be the same as X coordinate of the first character of + // any other line while its Y coordinate will be approximately + // (but we can't compute it exactly...) one character height + // more than that of the previous character. + LRESULT coords0 = ::SendMessage(GetHwnd(), EM_POSFROMCHAR, 0, 0); + if ( coords0 == -1 ) + return wxDefaultPosition; + + rc = MAKELPARAM(LOWORD(coords0), HIWORD(rc) + prevCharSize.y); + } + else + { + // Simple case: previous character is in the same line so this + // one is just after it. + rc += MAKELPARAM(prevCharSize.x, 0); + } + } + + // Notice that {LO,HI}WORD macros return WORDs, i.e. unsigned shorts, + // while we want to have signed values here (the y coordinate of any + // position above the first currently visible line is negative, for + // example), hence the need for casts. + return wxPoint(static_cast(LOWORD(rc)), + static_cast(HIWORD(rc))); + } + + return wxDefaultPosition; +} + + // ---------------------------------------------------------------------------- // // ---------------------------------------------------------------------------- diff --git a/tests/controls/textctrltest.cpp b/tests/controls/textctrltest.cpp index 24213ce94f..86f0fbee7a 100644 --- a/tests/controls/textctrltest.cpp +++ b/tests/controls/textctrltest.cpp @@ -59,6 +59,9 @@ private: CPPUNIT_TEST( Style ); CPPUNIT_TEST( Lines ); CPPUNIT_TEST( LogTextCtrl ); + CPPUNIT_TEST( PositionToCoords ); + CPPUNIT_TEST( PositionToCoordsRich ); + CPPUNIT_TEST( PositionToCoordsRich2 ); CPPUNIT_TEST_SUITE_END(); void MultiLineReplace(); @@ -71,6 +74,11 @@ private: void Style(); void Lines(); void LogTextCtrl(); + void PositionToCoords(); + void PositionToCoordsRich(); + void PositionToCoordsRich2(); + + void DoPositionToCoordsTestWithStyle(long style); wxTextCtrl *m_text; @@ -422,4 +430,98 @@ void TextCtrlTestCase::LogTextCtrl() CPPUNIT_ASSERT(!m_text->IsEmpty()); } +void TextCtrlTestCase::PositionToCoords() +{ + DoPositionToCoordsTestWithStyle(0); +} + +void TextCtrlTestCase::PositionToCoordsRich() +{ + DoPositionToCoordsTestWithStyle(wxTE_RICH); +} + +void TextCtrlTestCase::PositionToCoordsRich2() +{ + DoPositionToCoordsTestWithStyle(wxTE_RICH2); +} + +void TextCtrlTestCase::DoPositionToCoordsTestWithStyle(long style) +{ + static const int TEXT_HEIGHT = 200; + + delete m_text; + m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "", + wxDefaultPosition, wxSize(400, TEXT_HEIGHT), + wxTE_MULTILINE | style); + + // Asking for invalid index should fail. + WX_ASSERT_FAILS_WITH_ASSERT( m_text->PositionToCoords(1) ); + + // Getting position shouldn't return wxDefaultPosition except if the method + // is not implemented at all in the current port. + const wxPoint pos0 = m_text->PositionToCoords(0); + if ( pos0 == wxDefaultPosition ) + { +#if defined(__WXMSW__) || defined(__WXGTK20__) + CPPUNIT_FAIL( "PositionToCoords() unexpectedly failed." ); +#endif + return; + } + + CPPUNIT_ASSERT(pos0.x >= 0); + CPPUNIT_ASSERT(pos0.y >= 0); + + + m_text->SetValue("Hello"); + wxYield(); // Let GTK layout the control correctly. + + // Position of non-first character should be positive. + const long posHello4 = m_text->PositionToCoords(4).x; + CPPUNIT_ASSERT( posHello4 > 0 ); + + // Asking for position beyond the last character should succeed and return + // reasonable result. + CPPUNIT_ASSERT( m_text->PositionToCoords(5).x > posHello4 ); + + // But asking for the next position should fail. + WX_ASSERT_FAILS_WITH_ASSERT( m_text->PositionToCoords(6) ); + + // Test getting the coordinates of the last character when it is in the + // beginning of a new line to exercise MSW code which has specific logic + // for it. + m_text->AppendText("\n"); + const wxPoint posLast = m_text->PositionToCoords(m_text->GetLastPosition()); + CPPUNIT_ASSERT_EQUAL( pos0.x, posLast.x ); + CPPUNIT_ASSERT( posLast.y > 0 ); + + + // Add enough contents to the control to make sure it has a scrollbar. + m_text->SetValue("First line" + wxString(50, '\n') + "Last line"); + m_text->SetInsertionPoint(0); + wxYield(); // Let GTK layout the control correctly. + + // This shouldn't change anything for the first position coordinates. + CPPUNIT_ASSERT_EQUAL( pos0, m_text->PositionToCoords(0) ); + + // And the last one must be beyond the window boundary and so not be + // visible -- but getting its coordinate should still work. + CPPUNIT_ASSERT + ( + m_text->PositionToCoords(m_text->GetLastPosition()).y > TEXT_HEIGHT + ); + + + // Now make it scroll to the end and check that the first position now has + // negative offset as its above the visible part of the window while the + // last position is in its bounds. + m_text->SetInsertionPointEnd(); + + CPPUNIT_ASSERT( m_text->PositionToCoords(0).y < 0 ); + CPPUNIT_ASSERT + ( + m_text->PositionToCoords(m_text->GetInsertionPoint()).y <= TEXT_HEIGHT + ); +} + + #endif //wxUSE_TEXTCTRL From c29c95fe24973b94fd724db767193171ca7c513d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Jul 2011 11:30:03 +0000 Subject: [PATCH 06/52] Resolve ambiguity between GetClientXXX() methods in wxOSX wxComboBox. Use wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST for wxOSX/Cocoa too, not only for wxOSX/Carbon. This macro adds methods to explicitly disambiguate between the two inherited versions of each GetClientXXX() method, the one from wxItemContainer and the other one from wxEvtHandler. Closes #11637. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68459 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/osx/combobox.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/wx/osx/combobox.h b/include/wx/osx/combobox.h index 8d875edd34..4a31de9135 100644 --- a/include/wx/osx/combobox.h +++ b/include/wx/osx/combobox.h @@ -144,9 +144,7 @@ class WXDLLIMPEXP_CORE wxComboBox : virtual bool OSXHandleClicked( double timestampsec ); -#if wxOSX_USE_CARBON wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST -#endif #if wxOSX_USE_COCOA wxComboWidgetImpl* GetComboPeer() const; From bf8f10225c08bf5473fa35423f56e01f1819f971 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Jul 2011 11:30:08 +0000 Subject: [PATCH 07/52] Get rid of ugly wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST macro. Replace it with wxWindowWithItems<> template class which takes care of disambiguating between the two inherited Get/SetClientXXX() versions and use it as a base class in all clases that previously used the macro. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68460 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/ctrlsub.h | 67 +++++++++++++++++++++----------------- include/wx/gtk1/combobox.h | 5 ++- include/wx/htmllbox.h | 7 ++-- include/wx/odcombo.h | 9 ++--- include/wx/osx/combobox.h | 9 +++-- include/wx/univ/combobox.h | 5 ++- src/generic/odcombo.cpp | 1 - 7 files changed, 50 insertions(+), 53 deletions(-) diff --git a/include/wx/ctrlsub.h b/include/wx/ctrlsub.h index 82a98dfdfb..76f8353220 100644 --- a/include/wx/ctrlsub.h +++ b/include/wx/ctrlsub.h @@ -395,41 +395,48 @@ private: wxClientDataType m_clientDataItemsType; }; -// this macro must (unfortunately) be used in any class deriving from both -// wxItemContainer and wxControl because otherwise there is ambiguity when -// calling GetClientXXX() functions -- the compiler can't choose between the -// two versions -#define wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST \ - void SetClientData(void *data) \ - { wxEvtHandler::SetClientData(data); } \ - void *GetClientData() const \ - { return wxEvtHandler::GetClientData(); } \ - void SetClientObject(wxClientData *data) \ - { wxEvtHandler::SetClientObject(data); } \ - wxClientData *GetClientObject() const \ - { return wxEvtHandler::GetClientObject(); } \ - void SetClientData(unsigned int n, void* clientData) \ - { wxItemContainer::SetClientData(n, clientData); } \ - void* GetClientData(unsigned int n) const \ - { return wxItemContainer::GetClientData(n); } \ - void SetClientObject(unsigned int n, wxClientData* clientData) \ - { wxItemContainer::SetClientObject(n, clientData); } \ - wxClientData* GetClientObject(unsigned int n) const \ - { return wxItemContainer::GetClientObject(n); } +// Inheriting directly from a wxWindow-derived class and wxItemContainer +// unfortunately introduces an ambiguity for all GetClientXXX() methods as they +// are inherited twice: the "global" versions from wxWindow and the per-item +// versions taking the index from wxItemContainer. +// +// So we need to explicitly resolve them and this helper template class is +// provided to do it. To use it, simply inherit from wxWindowWithItems instead of Window and Container interface directly. +template +class wxWindowWithItems : public W, public C +{ +public: + typedef W BaseWindowClass; + typedef C BaseContainerInterface; -class WXDLLIMPEXP_CORE wxControlWithItemsBase : public wxControl, - public wxItemContainer + wxWindowWithItems() { } + + void SetClientData(void *data) + { BaseWindowClass::SetClientData(data); } + void *GetClientData() const + { return BaseWindowClass::GetClientData(); } + void SetClientObject(wxClientData *data) + { BaseWindowClass::SetClientObject(data); } + wxClientData *GetClientObject() const + { return BaseWindowClass::GetClientObject(); } + + void SetClientData(unsigned int n, void* clientData) + { wxItemContainer::SetClientData(n, clientData); } + void* GetClientData(unsigned int n) const + { return wxItemContainer::GetClientData(n); } + void SetClientObject(unsigned int n, wxClientData* clientData) + { wxItemContainer::SetClientObject(n, clientData); } + wxClientData* GetClientObject(unsigned int n) const + { return wxItemContainer::GetClientObject(n); } +}; + +class WXDLLIMPEXP_CORE wxControlWithItemsBase : + public wxWindowWithItems { public: wxControlWithItemsBase() { } - // we have to redefine these functions here to avoid ambiguities in classes - // deriving from us which would arise otherwise because both base classses - // have the methods with the same names - hopefully, a smart compiler can - // optimize away these simple inline wrappers so we don't suffer much from - // this - wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST - // usually the controls like list/combo boxes have their own background // colour virtual bool ShouldInheritColours() const { return false; } diff --git a/include/wx/gtk1/combobox.h b/include/wx/gtk1/combobox.h index 1d4149e3a8..77d2502cac 100644 --- a/include/wx/gtk1/combobox.h +++ b/include/wx/gtk1/combobox.h @@ -34,7 +34,8 @@ extern WXDLLIMPEXP_BASE const wxChar* wxEmptyString; // wxComboBox //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase +class WXDLLIMPEXP_CORE wxComboBox : + public wxWindowWithItems { public: inline wxComboBox() {} @@ -154,8 +155,6 @@ public: bool IsOwnGtkWindow( GdkWindow *window ); void DoApplyWidgetStyle(GtkRcStyle *style); - wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST - static wxVisualAttributes GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); diff --git a/include/wx/htmllbox.h b/include/wx/htmllbox.h index f610b8383f..1a941159dd 100644 --- a/include/wx/htmllbox.h +++ b/include/wx/htmllbox.h @@ -196,8 +196,8 @@ private: #define wxHLB_DEFAULT_STYLE wxBORDER_SUNKEN #define wxHLB_MULTIPLE wxLB_MULTIPLE -class WXDLLIMPEXP_HTML wxSimpleHtmlListBox : public wxHtmlListBox, - public wxItemContainer +class WXDLLIMPEXP_HTML wxSimpleHtmlListBox : + public wxWindowWithItems { DECLARE_ABSTRACT_CLASS(wxSimpleHtmlListBox) public: @@ -254,9 +254,6 @@ public: int GetSelection() const { return wxVListBox::GetSelection(); } - // see ctrlsub.h for more info about this: - wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST - // accessing strings // ----------------- diff --git a/include/wx/odcombo.h b/include/wx/odcombo.h index 4879c2bbfc..26415e8d24 100644 --- a/include/wx/odcombo.h +++ b/include/wx/odcombo.h @@ -233,15 +233,15 @@ private: // the wxComboCtrl. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_ADV wxOwnerDrawnComboBox : public wxComboCtrl, - public wxItemContainer +class WXDLLIMPEXP_ADV wxOwnerDrawnComboBox : + public wxWindowWithItems { //friend class wxComboPopupWindow; friend class wxVListBoxComboPopup; public: // ctors and such - wxOwnerDrawnComboBox() : wxComboCtrl() { Init(); } + wxOwnerDrawnComboBox() { Init(); } wxOwnerDrawnComboBox(wxWindow *parent, wxWindowID id, @@ -253,7 +253,6 @@ public: long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxComboBoxNameStr) - : wxComboCtrl() { Init(); @@ -339,8 +338,6 @@ public: virtual bool IsSorted() const { return HasFlag(wxCB_SORT); } - wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST - protected: virtual void DoClear(); virtual void DoDeleteOneItem(unsigned int n); diff --git a/include/wx/osx/combobox.h b/include/wx/osx/combobox.h index 4a31de9135..e814474732 100644 --- a/include/wx/osx/combobox.h +++ b/include/wx/osx/combobox.h @@ -26,12 +26,13 @@ class wxComboWidgetImpl; // Combobox item class WXDLLIMPEXP_CORE wxComboBox : + public wxWindowWithItems< #if wxOSX_USE_CARBON - public wxNavigationEnabled, + wxNavigationEnabled, #else - public wxControl, + wxControl, #endif - public wxComboBoxBase + wxComboBoxBase> { DECLARE_DYNAMIC_CLASS(wxComboBox) @@ -144,8 +145,6 @@ class WXDLLIMPEXP_CORE wxComboBox : virtual bool OSXHandleClicked( double timestampsec ); - wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST - #if wxOSX_USE_COCOA wxComboWidgetImpl* GetComboPeer() const; #endif diff --git a/include/wx/univ/combobox.h b/include/wx/univ/combobox.h index 93b3128633..04343ac4fe 100644 --- a/include/wx/univ/combobox.h +++ b/include/wx/univ/combobox.h @@ -34,7 +34,8 @@ class WXDLLIMPEXP_FWD_CORE wxListBox; // NB: Normally we'd like wxComboBox to inherit from wxComboBoxBase, but here // we can't really do that since both wxComboBoxBase and wxComboCtrl inherit // from wxTextCtrl. -class WXDLLIMPEXP_CORE wxComboBox : public wxComboCtrl, public wxItemContainer +class WXDLLIMPEXP_CORE wxComboBox : + public wxWindowWithItems { public: // ctors and such @@ -141,8 +142,6 @@ public: virtual int GetSelection() const; virtual wxString GetStringSelection() const; - wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST - // we have our own input handler and our own actions // (but wxComboCtrl already handled Popup/Dismiss) /* diff --git a/src/generic/odcombo.cpp b/src/generic/odcombo.cpp index 06ca2e58a5..6425dd145d 100644 --- a/src/generic/odcombo.cpp +++ b/src/generic/odcombo.cpp @@ -902,7 +902,6 @@ wxOwnerDrawnComboBox::wxOwnerDrawnComboBox(wxWindow *parent, long style, const wxValidator& validator, const wxString& name) - : wxComboCtrl() { Init(); From 75618d57e4882fa5693b10374daef43c83aed8d8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Jul 2011 17:40:00 +0000 Subject: [PATCH 08/52] Emphasize that wxStandardPaths must not be created directly. wxStandardPaths::Get() must be used instead as the correct object to use might have a different type. See #11239. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68462 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/wx/stdpaths.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/interface/wx/stdpaths.h b/interface/wx/stdpaths.h index 4d25136413..b4f577662f 100644 --- a/interface/wx/stdpaths.h +++ b/interface/wx/stdpaths.h @@ -12,6 +12,13 @@ wxStandardPaths returns the standard locations in the file system and should be used by applications to find their data files in a portable way. + Note that you must not create objects of class wxStandardPaths directly, + but use the global standard paths object returned by wxStandardPaths::Get() + (which can be of a type derived from wxStandardPaths and not of exactly + this type) and call the methods you need on it. The object returned by + Get() may be customized by overriding wxAppTraits::GetStandardPaths() + methods. + In the description of the methods below, the example return values are given for the Unix, Windows and Mac OS X systems, however please note that these are just the examples and the actual values may differ. For example, under Windows: @@ -42,10 +49,6 @@ This class is MT-safe: its methods may be called concurrently from different threads without additional locking. - Note that you don't allocate an instance of class wxStandardPaths, but retrieve the - global standard paths object using @c wxStandardPaths::Get on which you call the - desired methods. - @library{wxbase} @category{file} From d641b2d2a0bfe4d815838e73f4a85c2234254f6d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Jul 2011 21:54:05 +0000 Subject: [PATCH 09/52] Fix stock accelerators handling in wxOSX. No modifiers were used for stock accelerators, i.e. Append(wxID_NEW) resulted in an item with the label "New" and plain "N" as accelerator in wxOSX. This was due to wxACCEL_CMD not being handled in wxAcceleratorEntry::ToString() so map it to the same prefix as wxACCEL_CTRL there, this is enough to make the accelerators work even though it's not clear whether this is really the best thing to do or if we should use a separate "Cmd+" prefix for it (and recognize it in Parse() too then) as otherwise it's unclear why do we have wxACCEL_CMD at all, it just seems to be treated identically to wxACCEL_CTRL everywhere. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68463 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/accelcmn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/accelcmn.cpp b/src/common/accelcmn.cpp index 4d05f3de4d..f52fc05de3 100644 --- a/src/common/accelcmn.cpp +++ b/src/common/accelcmn.cpp @@ -307,7 +307,7 @@ wxString wxAcceleratorEntry::ToString() const int flags = GetFlags(); if ( flags & wxACCEL_ALT ) text += _("Alt+"); - if ( flags & wxACCEL_CTRL ) + if ( flags & (wxACCEL_CTRL | wxACCEL_CMD) ) text += _("Ctrl+"); if ( flags & wxACCEL_SHIFT ) text += _("Shift+"); From 2d5c15163a2e346c30fe3136e6668a20bab7d7d2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Jul 2011 21:54:08 +0000 Subject: [PATCH 10/52] Fix off by one error in wxTextCtrl::GetLineLength() in wxOSX. The trailing new line shouldn't be counted in the line length. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68464 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/textctrl_osx.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index 0af4f04bcc..8c2f1d83da 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -775,9 +775,10 @@ int wxTextWidgetImpl::GetLineLength(long lineNo) const count = 0; for (size_t j = i; j < content.length(); j++) { - count++; if (content[j] == '\n') return count; + + count++; } return count; From 567e5e47ee9af2f6e7343cb94bd890a3a6104f1e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Jul 2011 21:54:15 +0000 Subject: [PATCH 11/52] Improve wxTextCtrl::GetNumberOfLines() unit test and documentation. First, enable execution of the Lines() wxTextCtrl unit test case under wxOSX as it passes since the fix in the previous commit. Do add a test for GetNumberOfLines() that currently doesn't work in the same way under all platforms -- but with this test we at least can be sure how does it work exactly where. Also mention the current discrepancy in this function behaviour in the documentation. See #12366. Fix Lines() wxTextCtrl unit test to pass under wxGTK too. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68465 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/wx/textctrl.h | 16 ++++++---------- tests/controls/textctrltest.cpp | 12 +++++++++++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/interface/wx/textctrl.h b/interface/wx/textctrl.h index 6dfd914320..422a703e5a 100644 --- a/interface/wx/textctrl.h +++ b/interface/wx/textctrl.h @@ -1197,19 +1197,15 @@ public: /** Returns the number of lines in the text control buffer. + The returned number is the number of logical lines, i.e. just the count + of the number of newline characters in the control + 1, for wxGTK and + wxOSX/Cocoa ports while it is the number of physical lines, i.e. the + count of lines actually shown in the control, in wxMSW and wxOSX/Carbon. + Because of this discrepancy, it is not recommended to use this function. + @remarks Note that even empty text controls have one line (where the insertion point is), so GetNumberOfLines() never returns 0. - For wxGTK using GTK+ 1.2.x and earlier, the number of lines in a - multi-line text control is calculated by actually counting newline - characters in the buffer, i.e. this function returns the number of - logical lines and doesn't depend on whether any of them are wrapped. - For all the other platforms, the number of physical lines in the - control is returned. - Also note that you may wish to avoid using functions that work with - line numbers if you are working with controls that contain large - amounts of text as this function has O(N) complexity for N being - the number of lines. */ virtual int GetNumberOfLines() const; diff --git a/tests/controls/textctrltest.cpp b/tests/controls/textctrltest.cpp index 86f0fbee7a..1c001d3ac2 100644 --- a/tests/controls/textctrltest.cpp +++ b/tests/controls/textctrltest.cpp @@ -388,7 +388,6 @@ void TextCtrlTestCase::Style() void TextCtrlTestCase::Lines() { -#ifndef __WXOSX__ delete m_text; m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "", wxDefaultPosition, wxSize(400, 200), wxTE_MULTILINE | wxTE_DONTWRAP); @@ -407,6 +406,17 @@ void TextCtrlTestCase::Lines() CPPUNIT_ASSERT_EQUAL(5, m_text->GetNumberOfLines()); CPPUNIT_ASSERT_EQUAL(0, m_text->GetLineLength(3)); CPPUNIT_ASSERT_EQUAL("", m_text->GetLineText(3)); + + // Verify that wrapped lines count as 2 lines. + // + // This currently doesn't work neither in wxGTK nor wxOSX/Cocoa, see + // #12366, where GetNumberOfLines() always returns the number of logical, + // not physical, lines. + m_text->AppendText("\n" + wxString(50, '1') + ' ' + wxString(50, '2')); +#if defined(__WXGTK__) || defined(__WXOSX_COCOA__) + CPPUNIT_ASSERT_EQUAL(6, m_text->GetNumberOfLines()); +#else + CPPUNIT_ASSERT_EQUAL(7, m_text->GetNumberOfLines()); #endif } From 66fc8b0e64a5caea19192d24b05d3b4c59443b79 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Jul 2011 21:54:18 +0000 Subject: [PATCH 12/52] Avoid bogus focus loss event when wxTextCtrl is modified in wxOSX. A wxEVT_KILL_FOCUS event was generated when wxTextCtrl::WriteText() was called in wxOSX, even though the control didn't lose focus at all in this case. This was completely unexpected and thoroughly confused wxGrid code which closed the in place editor immediately after showing it because of this (this was perhaps only the case since r68319 but the changes there were correct so they only masked the real bug). Avoid this bogus event by remembering the NSView currently being programmatically modified and not doing anything in textDidEndEditing notification if it is generated for this view. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68466 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/cocoa/textctrl.mm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index b5913b841b..f22f8de86e 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -57,11 +57,18 @@ - (void)setSelectable:(BOOL)flag; @end +// An object of this class is created before the text is modified +// programmatically and destroyed as soon as this is done. It does several +// things, like ensuring that the control is editable to allow setting its text +// at all and eating any unwanted focus loss events from textDidEndEditing: +// which don't really correspond to focus change. class wxMacEditHelper { public : wxMacEditHelper( NSView* textView ) { + m_viewPreviouslyEdited = ms_viewCurrentlyEdited; + ms_viewCurrentlyEdited = m_textView = textView; m_formerEditable = YES; if ( textView ) @@ -79,14 +86,27 @@ public : [m_textView setEditable:m_formerEditable]; [m_textView setSelectable:m_formerSelectable]; } + + ms_viewCurrentlyEdited = m_viewPreviouslyEdited; } + // Returns the last view we were instantiated for or NULL. + static NSView *GetCurrentlyEditedView() { return ms_viewCurrentlyEdited; } + protected : BOOL m_formerEditable ; BOOL m_formerSelectable; NSView* m_textView; + + // The original value of ms_viewCurrentlyEdited when this object was + // created. + NSView* m_viewPreviouslyEdited; + + static NSView* ms_viewCurrentlyEdited; } ; +NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil; + @implementation wxNSSecureTextField + (void)initialize @@ -222,6 +242,15 @@ protected : - (void)textDidEndEditing:(NSNotification *)aNotification { wxUnusedVar(aNotification); + + if ( self == wxMacEditHelper::GetCurrentlyEditedView() ) + { + // This notification is generated as the result of calling our own + // wxTextCtrl method (e.g. WriteText()) and doesn't correspond to any + // real focus loss event so skip generating it. + return; + } + wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self ); if ( impl ) { From e999b903ca76951f79936b639e65a9db5adfce37 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Jul 2011 21:54:21 +0000 Subject: [PATCH 13/52] Generate events with WXK_NONE Unicode keys for non-characters in wxOSX. The keyboard keys not corresponding to real characters, such as cursor arrows or function keys, must generate wxKeyEvents with WXK_NONE as Unicode key code to make it possible to distinguish them from the printable characters but wxOSX generated events with valid Unicode key codes for them instead. Avoid this by excluding Unicode key codes corresponding to code points in the Unicode private use area: while this doesn't seem to be documented anywhere, all non-printable characters seem to have their Unicode representation inside it. This change brings wxOSX keyboard event generation in line with the other ports and, as a side effect, also closes #12423. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68467 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/cocoa/window.mm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index b859eba7cb..ec4381d4c0 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -368,7 +368,16 @@ void wxWidgetCocoaImpl::SetupKeyEvent(wxKeyEvent &wxevent , NSEvent * nsEvent, N } #if wxUSE_UNICODE - wxevent.m_uniChar = aunichar; + // OS X generates events with key codes in Unicode private use area for + // unprintable symbols such as cursor arrows (WXK_UP is mapped to U+F700) + // and function keys (WXK_F2 is U+F705). We don't want to use them as the + // result of wxKeyEvent::GetUnicodeKey() however as it's supposed to return + // WXK_NONE for "non characters" so explicitly exclude them. + // + // We only exclude the private use area inside the Basic Multilingual Plane + // as key codes beyond it don't seem to be currently used. + if ( !(aunichar >= 0xe000 && aunichar < 0xf900) ) + wxevent.m_uniChar = aunichar; #endif wxevent.m_keyCode = keyval; From 9c5c5c9cfd18dbad30de0b703659c1b81a155a65 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Jul 2011 23:38:43 +0000 Subject: [PATCH 14/52] Fix crash in wxArray::insert() overload taking iterator range. The iterator passed as argument could be invalidated by the function itself, update it before using it. Closes #13371. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68468 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/common/dynarray.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 8187f093a6..0d0b99255f 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -440,6 +440,7 @@ Major new features in this release All: - Fix parsing of negated long options in wxCmdLineParser (roed_bis). +- Fix crash in wxArray::insert() overload taking iterator range (wsu). All (GUI): diff --git a/src/common/dynarray.cpp b/src/common/dynarray.cpp index 86a106d556..175fa4a36e 100644 --- a/src/common/dynarray.cpp +++ b/src/common/dynarray.cpp @@ -358,6 +358,9 @@ void name::insert(iterator it, const_iterator first, const_iterator last) \ return; \ Grow(nInsert); \ \ + /* old iterator could have been invalidated by Grow(). */ \ + it = begin() + nInsert; \ + \ memmove(&m_pItems[nIndex + nInsert], &m_pItems[nIndex], \ (m_nCount - nIndex)*sizeof(T)); \ for (size_t i = 0; i < nInsert; ++i, ++it, ++first) \ From bd5754f2531ab75430f2177a28bff5645600a5ff Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 31 Jul 2011 12:19:51 +0000 Subject: [PATCH 15/52] Correct typo in wxArray::insert() fix of r68468. A wrong variable was mistakenly used. Closes #13371. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68470 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/dynarray.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/dynarray.cpp b/src/common/dynarray.cpp index 175fa4a36e..8d62ca6b06 100644 --- a/src/common/dynarray.cpp +++ b/src/common/dynarray.cpp @@ -359,7 +359,7 @@ void name::insert(iterator it, const_iterator first, const_iterator last) \ Grow(nInsert); \ \ /* old iterator could have been invalidated by Grow(). */ \ - it = begin() + nInsert; \ + it = begin() + nIndex; \ \ memmove(&m_pItems[nIndex + nInsert], &m_pItems[nIndex], \ (m_nCount - nIndex)*sizeof(T)); \ From 7198c3368055d88249a338eb33b21f051f674806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 31 Jul 2011 13:25:30 +0000 Subject: [PATCH 16/52] Disable symbols visibility support for the Clang compiler. Even Clang++ shipped with Xcode 4.1 still can't handle visibility of non-inline methods in exported template classes if the default visibility is 'hidden'. Disable visibility support for Clang for now, we'll revisit it in the future. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68471 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- build/aclocal/visibility.m4 | 5 +++++ configure | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/build/aclocal/visibility.m4 b/build/aclocal/visibility.m4 index 52c97f9c8e..05f9b80dec 100644 --- a/build/aclocal/visibility.m4 +++ b/build/aclocal/visibility.m4 @@ -49,6 +49,11 @@ AC_DEFUN([WX_VISIBILITY], error this platform has no visibility; #endif + /* at the time of Xcode 4.1 / Clang 3, Clang++ still didn't have the bugs sorted out: */ + #if defined(__clang__) + clang compiler is still broken w.r.t. visibility; + #endif + extern __attribute__((__visibility__("hidden"))) int hiddenvar; extern __attribute__((__visibility__("default"))) int exportedvar; extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); diff --git a/configure b/configure index c79bdc5bb4..f602dbf16b 100755 --- a/configure +++ b/configure @@ -35001,6 +35001,11 @@ cat >>conftest.$ac_ext <<_ACEOF error this platform has no visibility; #endif + /* at the time of Xcode 4.1 / Clang 3, Clang++ still didn't have the bugs sorted out: */ + #if defined(__clang__) + clang compiler is still broken w.r.t. visibility; + #endif + extern __attribute__((__visibility__("hidden"))) int hiddenvar; extern __attribute__((__visibility__("default"))) int exportedvar; extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); From 1969499c6fadcac1b8d39e90dce428726f430307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 31 Jul 2011 13:25:33 +0000 Subject: [PATCH 17/52] Silence Clang warning about numeric_limits<> specialization. libstdc++ (which is used by Clang) defines numeric_limits<> as a struct and Clang issues a warning about our specialization that uses 'class'. As libstdc++ developers have no intention of fixing this, silence the Clang warning by using 'struct' for it. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68472 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/longlong.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/wx/longlong.h b/include/wx/longlong.h index 7c76d5f677..19c580110e 100644 --- a/include/wx/longlong.h +++ b/include/wx/longlong.h @@ -1097,15 +1097,15 @@ WXDLLIMPEXP_BASE class wxTextInputStream &operator>>(class wxTextInputStream &st namespace std { -template<> class numeric_limits - : public numeric_limits -{ -}; - -template<> class numeric_limits - : public numeric_limits -{ -}; +#ifdef __clang__ + // libstdc++ (used by Clang) uses struct for numeric_limits; unlike gcc, clang + // warns about this + template<> struct numeric_limits : public numeric_limits {}; + template<> struct numeric_limits : public numeric_limits {}; +#else + template<> class numeric_limits : public numeric_limits {}; + template<> class numeric_limits : public numeric_limits {}; +#endif } // namespace std From d6f2b04c723e0e949bfc01a000c60cfac5b96185 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 2 Aug 2011 19:46:35 +0000 Subject: [PATCH 18/52] Remove documentation of non-existent wxTextAttr::CreateFont(). This method doesn't exist (only GetFont() does), so don't document it. Closes #13372. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68491 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/wx/textctrl.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/interface/wx/textctrl.h b/interface/wx/textctrl.h index 422a703e5a..c17e10f917 100644 --- a/interface/wx/textctrl.h +++ b/interface/wx/textctrl.h @@ -220,11 +220,6 @@ public: bool Apply(const wxTextAttr& style, const wxTextAttr* compareWith = NULL); - /** - Creates a font from the font attributes. - */ - wxFont CreateFont() const; - /** Copies all defined/valid properties from overlay to current object. */ From 9be02147f08bb5be2251eb5c51e6160a4209fd9f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 2 Aug 2011 19:46:40 +0000 Subject: [PATCH 19/52] Fix wxSocket::WaitForAccept() in blocking mode. When wxSocket::WaitForAccept() was called from another thread or on a socket with wxSOCKET_BLOCK flag it didn't work because it called wxSocketImpl::Select() with wxSOCKET_CONNECTION_FLAG which was only handled for the client sockets in this function. Handle it now for the server ones too, this should allow blocking server sockets to work again. Closes #12836. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68492 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/socket.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/common/socket.cpp b/src/common/socket.cpp index 64803df7a4..36a9dc1090 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -1297,17 +1297,31 @@ wxSocketEventFlags wxSocketImpl::Select(wxSocketEventFlags flags, exceptfds; // always want to know about errors if ( flags & wxSOCKET_INPUT_FLAG ) - { preadfds = &readfds; + + if ( flags & wxSOCKET_OUTPUT_FLAG ) + pwritefds = &writefds; + + // When using non-blocking connect() the client socket becomes connected + // (successfully or not) when it becomes writable but when using + // non-blocking accept() the server socket becomes connected when it + // becomes readable. + if ( flags & wxSOCKET_CONNECTION_FLAG ) + { + if ( m_server ) + preadfds = &readfds; + else + pwritefds = &writefds; + } + + if ( preadfds ) + { wxFD_ZERO(preadfds); wxFD_SET(m_fd, preadfds); } - // when using non-blocking connect() the socket becomes connected - // (successfully or not) when it becomes writable - if ( flags & (wxSOCKET_OUTPUT_FLAG | wxSOCKET_CONNECTION_FLAG) ) + if ( pwritefds ) { - pwritefds = &writefds; wxFD_ZERO(pwritefds); wxFD_SET(m_fd, pwritefds); } From 57429bfda5e510aa5df3f4c75936c33b6f174c26 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 2 Aug 2011 19:46:44 +0000 Subject: [PATCH 20/52] Don't un-maximize the window when Iconize(false) is called in wxMSW. Calling Iconize(false) on a maximized window restored it to its normal state instead of doing nothing as expected. Return immediately from Iconize() if the requested state is already the current one to avoid it. Closes #13373. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68493 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/toplevel.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 5b271f01a2..45ef33843b 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -737,6 +737,13 @@ bool wxTopLevelWindowMSW::IsMaximized() const void wxTopLevelWindowMSW::Iconize(bool iconize) { + if ( iconize == m_iconized ) + { + // Do nothing, in particular don't restore non-iconized windows when + // Iconize(false) is called as this would wrongly un-maximize them. + return; + } + if ( IsShown() ) { // change the window state immediately From 6c797d8fd16ef5b2fedc1e554455e3144eeaa383 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 2 Aug 2011 19:49:02 +0000 Subject: [PATCH 21/52] Initialize the native printer info for ConvertFromNative if it hasn't been done already. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68494 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/printdlg.h | 2 ++ src/msw/printdlg.cpp | 36 +++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/include/wx/msw/printdlg.h b/include/wx/msw/printdlg.h index 754e212f9f..bcca2b91e9 100644 --- a/include/wx/msw/printdlg.h +++ b/include/wx/msw/printdlg.h @@ -20,6 +20,7 @@ #include "wx/printdlg.h" class WXDLLIMPEXP_FWD_CORE wxDC; +class WinPrinter; //---------------------------------------------------------------------------- // wxWindowsPrintNativeData @@ -37,6 +38,7 @@ public: virtual bool Ok() const { return IsOk(); } virtual bool IsOk() const; + void InitializeDevMode(const wxString &printerName = wxEmptyString, WinPrinter* printer = NULL); void* GetDevMode() const { return m_devMode; } void SetDevMode(void* data) { m_devMode = data; } void* GetDevNames() const { return m_devNames; } diff --git a/src/msw/printdlg.cpp b/src/msw/printdlg.cpp index 205009999b..fac6fdf743 100644 --- a/src/msw/printdlg.cpp +++ b/src/msw/printdlg.cpp @@ -192,6 +192,9 @@ bool wxWindowsPrintNativeData::IsOk() const bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data ) { + if ( !m_devMode ) + InitializeDevMode(); + if ( !m_devMode ) return false; @@ -383,20 +386,21 @@ bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data ) return true; } -bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data ) +void wxWindowsPrintNativeData::InitializeDevMode(const wxString& printerName, WinPrinter* printer) { - HGLOBAL hDevMode = static_cast(m_devMode); - WinPrinter printer; - LPTSTR szPrinterName = (LPTSTR)data.GetPrinterName().wx_str(); + if (m_devMode) + return; + + LPTSTR szPrinterName = (LPTSTR)printerName.wx_str(); // From MSDN: How To Modify Printer Settings with the DocumentProperties() Function // The purpose of this is to fill the DEVMODE with privdata from printer driver. // If we have a printer name and OpenPrinter sucessfully returns // this replaces the PrintDlg function which creates the DEVMODE filled only with data from default printer. - if ( !m_devMode && !data.GetPrinterName().IsEmpty() ) + if ( !m_devMode && !printerName.IsEmpty() ) { // Open printer - if ( printer.Open( data.GetPrinterName() ) == TRUE ) + if ( printer && printer->Open( printerName ) == TRUE ) { DWORD dwNeeded, dwRet; @@ -424,12 +428,11 @@ bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data ) { // If failure, cleanup GlobalFree( tempDevMode ); - printer.Close(); + printer->Close(); } else { - hDevMode = tempDevMode; - m_devMode = hDevMode; + m_devMode = tempDevMode; tempDevMode = NULL; } } @@ -471,8 +474,7 @@ bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data ) } else { - hDevMode = pd.hDevMode; - m_devMode = hDevMode; + m_devMode = pd.hDevMode; pd.hDevMode = NULL; // We'll create a new DEVNAMEs structure below. @@ -487,6 +489,18 @@ bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data ) } } +} + +bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data ) +{ + WinPrinter printer; + LPTSTR szPrinterName = (LPTSTR)data.GetPrinterName().wx_str(); + + if (!m_devMode) + InitializeDevMode(data.GetPrinterName(), &printer); + + HGLOBAL hDevMode = static_cast(m_devMode); + if ( hDevMode ) { GlobalPtrLock lockDevMode(hDevMode); From ec3f5752a02c56fa6cfa0ce593cc7439d547009c Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 2 Aug 2011 20:23:42 +0000 Subject: [PATCH 22/52] If -1 is passed to InsertItem for the imageIndex then don't set wxLIST_MASK_IMAGE git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68495 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/listctrl.cpp | 6 ++++-- src/msw/listctrl.cpp | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index bcf799a00b..09354910b6 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -4027,7 +4027,7 @@ void wxListMainWindow::InsertItem( wxListItem &item ) wxListLineData *line = new wxListLineData(this); line->SetItem( item.m_col, item ); - if ( item.m_mask & wxLIST_MASK_IMAGE ) + if ( item.m_mask & wxLIST_MASK_IMAGE && item.GetImage() != -1) { // Reset the buffered height if it's not big enough for the new image. if (m_small_image_list) @@ -4866,7 +4866,9 @@ long wxGenericListCtrl::InsertItem( long index, const wxString &label, int image wxListItem info; info.m_text = label; info.m_image = imageIndex; - info.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_IMAGE; + info.m_mask = wxLIST_MASK_TEXT; + if (imageIndex > -1) + info.m_mask |= wxLIST_MASK_IMAGE; info.m_itemId = index; return InsertItem( info ); } diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 9d49a3be10..1e1c9a722c 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1727,7 +1727,9 @@ long wxListCtrl::InsertItem(long index, const wxString& label, int imageIndex) wxListItem info; info.m_image = imageIndex; info.m_text = label; - info.m_mask = wxLIST_MASK_IMAGE | wxLIST_MASK_TEXT; + info.m_mask = wxLIST_MASK_TEXT; + if (imageIndex > -1) + info.m_mask |= wxLIST_MASK_IMAGE; info.m_itemId = index; return InsertItem(info); } From 2a0777a8f079e4f2991f219dc641de3798143f79 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 3 Aug 2011 00:45:38 +0000 Subject: [PATCH 23/52] No real changes, just rename a variable. "focussed" spelling is unusual and inconsistent with "focused" used in many other places in the same file, so renamed "focussed_child_of_parent" and also use standard camelCase naming convention for it. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68501 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/containr.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/containr.cpp b/src/common/containr.cpp index 29756da696..910804bc4d 100644 --- a/src/common/containr.cpp +++ b/src/common/containr.cpp @@ -472,18 +472,18 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) // looping inside this panel (normally, the focus will go to // the next/previous item after this panel in the parent // panel). - wxWindow *focussed_child_of_parent = m_winParent; + wxWindow *focusedParent = m_winParent; while ( parent ) { // we don't want to tab into a different dialog or frame - if ( focussed_child_of_parent->IsTopLevel() ) + if ( focusedParent->IsTopLevel() ) break; - event.SetCurrentFocus( focussed_child_of_parent ); + event.SetCurrentFocus( focusedParent ); if ( parent->GetEventHandler()->ProcessEvent( event ) ) return; - focussed_child_of_parent = parent; + focusedParent = parent; parent = parent->GetParent(); } From 6e92c2991bb840f1eb9f551638fd64ca5b1b86ac Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 3 Aug 2011 00:45:42 +0000 Subject: [PATCH 24/52] Fix bug with TAB being able to switch focus between MDI frames. The keyboard navigation code correctly checked that TAB was not propagated above the TLW containing the window in which the key was pressed to avoid switching focus between different TLWs by pressing TAB. However wxMDIChildFrame is not a TLW and so it was possible to switch focus between two different MDI child frames by pressing TAB. This was unexpected and counterintuitive, especially because the frame receiving focus was not even activated (which might be another bug). Fix this by adding a new wxWindow::IsTopNavigationDomain() virtual method that can be overridden to indicate that a window is a self-contained "keyboard navigation domain" and that keyboard events shouldn't propagate outside of it and override it in both wxTopLevelWindow and wxMDIChildFrame to ensure that it behaves correctly. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68502 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/mdi.h | 5 +++++ include/wx/toplevel.h | 1 + include/wx/window.h | 9 +++++++++ src/common/containr.cpp | 7 +++++-- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/wx/mdi.h b/include/wx/mdi.h index 37f0fa5208..6425de2253 100644 --- a/include/wx/mdi.h +++ b/include/wx/mdi.h @@ -176,6 +176,11 @@ public: // level windows too virtual bool IsTopLevel() const { return false; } + // In all ports keyboard navigation must stop at MDI child frame level and + // can't cross its boundary. Indicate this by overriding this function to + // return true. + virtual bool IsTopNavigationDomain() const { return true; } + protected: wxMDIParentFrame *m_mdiParent; }; diff --git a/include/wx/toplevel.h b/include/wx/toplevel.h index bf8123e5ab..28a56fe596 100644 --- a/include/wx/toplevel.h +++ b/include/wx/toplevel.h @@ -282,6 +282,7 @@ public: // override some base class virtuals virtual bool Destroy(); virtual bool IsTopLevel() const { return true; } + virtual bool IsTopNavigationDomain() const { return true; } virtual bool IsVisible() const { return IsShown(); } // event handlers diff --git a/include/wx/window.h b/include/wx/window.h index 07f1f084bb..31ffe5332b 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -1422,6 +1422,15 @@ public: virtual wxWindow *GetMainWindowOfCompositeControl() { return (wxWindow*)this; } + // If this function returns true, keyboard navigation events shouldn't + // escape from it. A typical example of such "navigation domain" is a top + // level window because pressing TAB in one of them must not transfer focus + // to a different top level window. But it's not limited to them, e.g. MDI + // children frames are not top level windows (and their IsTopLevel() + // returns false) but still are self-contained navigation domains as well. + virtual bool IsTopNavigationDomain() const { return false; } + + protected: // helper for the derived class Create() methods: the first overload, with // validator parameter, should be used for child windows while the second diff --git a/src/common/containr.cpp b/src/common/containr.cpp index 910804bc4d..2fda844c96 100644 --- a/src/common/containr.cpp +++ b/src/common/containr.cpp @@ -475,8 +475,11 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) wxWindow *focusedParent = m_winParent; while ( parent ) { - // we don't want to tab into a different dialog or frame - if ( focusedParent->IsTopLevel() ) + // We don't want to tab into a different dialog or frame or + // even an MDI child frame, so test for this explicitly + // (and in particular don't just use IsTopLevel() which + // would return false in the latter case). + if ( focusedParent->IsTopNavigationDomain() ) break; event.SetCurrentFocus( focusedParent ); From 41d9dcbc6047e00f84de319d8036c80dd711c638 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 3 Aug 2011 11:41:17 +0000 Subject: [PATCH 25/52] Outline and line spacing can now be reset via the UI; format dialog layout improvements git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68505 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/richtext/richtextdialogs.pjd | 1935 ++++++++++-------------- src/richtext/richtextindentspage.cpp | 114 +- src/richtext/richtextliststylepage.cpp | 101 +- 3 files changed, 896 insertions(+), 1254 deletions(-) diff --git a/src/richtext/richtextdialogs.pjd b/src/richtext/richtextdialogs.pjd index 82b5a5ff9e..3df8163d19 100644 --- a/src/richtext/richtextdialogs.pjd +++ b/src/richtext/richtextdialogs.pjd @@ -3067,7 +3067,6 @@ 1 0 0 - "3/10/2006" "wbStaticTextProxy" "wxID_STATIC" 5105 @@ -3130,115 +3129,87 @@ "" - "wxBoxSizer H" + "wxTextCtrl: ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT" "dialog-control-document" "" - "sizer" + "textctrl" 0 1 0 0 - "3/10/2006" - "wbBoxSizerProxy" - "Horizontal" - "" + "wbTextCtrlProxy" + "wxEVT_COMMAND_TEXT_UPDATED|OnIndentLeftUpdated" + "ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT" + 10103 + "" + "wxTextCtrl" + "wxTextCtrl" + 1 + 0 + "" + "" + "m_indentLeft" + "" + 0 + "The left indent." + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 50 + -1 "Expand" "Centre" 0 5 - 0 - 0 - 0 - 0 + 1 + 1 + 1 + 1 0 0 0 - "<Any platform>" - - "wxTextCtrl: ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "3/10/2006" - "wbTextCtrlProxy" - "wxEVT_COMMAND_TEXT_UPDATED|OnIndentLeftUpdated" - "ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT" - 10103 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_indentLeft" - "" - 0 - "The left indent." - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - 50 - -1 - "Centre" - "Centre" - 1 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - 0 - + "" + "" "wxStaticText: wxID_STATIC" @@ -3249,7 +3220,6 @@ 1 0 0 - "3/10/2006" "wbStaticTextProxy" "wxID_STATIC" 5105 @@ -3312,115 +3282,87 @@ "" - "wxBoxSizer H" + "wxTextCtrl: ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST" "dialog-control-document" "" - "sizer" + "textctrl" 0 1 0 0 - "3/10/2006" - "wbBoxSizerProxy" - "Horizontal" - "" + "wbTextCtrlProxy" + "wxEVT_COMMAND_TEXT_UPDATED|OnIndentLeftFirstUpdated" + "ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST" + 10104 + "" + "wxTextCtrl" + "wxTextCtrl" + 1 + 0 + "" + "" + "m_indentLeftFirst" + "" + 0 + "The first line indent." + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 50 + -1 "Expand" "Centre" 0 5 - 0 - 0 - 0 - 0 + 1 + 1 + 1 + 1 0 0 0 - "<Any platform>" - - "wxTextCtrl: ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "3/10/2006" - "wbTextCtrlProxy" - "wxEVT_COMMAND_TEXT_UPDATED|OnIndentLeftFirstUpdated" - "ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST" - 10104 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_indentLeftFirst" - "" - 0 - "The first line indent." - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - 50 - -1 - "Centre" - "Centre" - 1 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - 0 - + "" + "" "wxStaticText: wxID_STATIC" @@ -3431,7 +3373,6 @@ 1 0 0 - "3/10/2006" "wbStaticTextProxy" "wxID_STATIC" 5105 @@ -3494,115 +3435,87 @@ "" - "wxBoxSizer H" + "wxTextCtrl: ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT" "dialog-control-document" "" - "sizer" + "textctrl" 0 1 0 0 - "3/10/2006" - "wbBoxSizerProxy" - "Horizontal" - "" + "wbTextCtrlProxy" + "wxEVT_COMMAND_TEXT_UPDATED|OnIndentRightUpdated" + "ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT" + 10113 + "" + "wxTextCtrl" + "wxTextCtrl" + 1 + 0 + "" + "" + "m_indentRight" + "" + 0 + "The right indent." + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 50 + -1 "Expand" "Centre" 0 5 - 0 - 0 - 0 - 0 + 1 + 1 + 1 + 1 0 0 0 - "<Any platform>" - - "wxTextCtrl: ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "3/10/2006" - "wbTextCtrlProxy" - "wxEVT_COMMAND_TEXT_UPDATED|OnIndentRightUpdated" - "ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT" - 10113 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_indentRight" - "" - 0 - "The right indent." - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - 50 - -1 - "Centre" - "Centre" - 1 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - 0 - + "" + "" "wxStaticText: wxID_STATIC" @@ -3697,8 +3610,8 @@ "" "" "m_outlineLevelCtrl" - "Normal|1|2|3|4|5|6|7|8|9" - "Normal" + "(none)|1|2|3|4|5|6|7|8|9|10" + "(none)" "The outline level." "" "" @@ -3725,11 +3638,11 @@ "" -1 -1 - 90 + 85 -1 "Expand" "Centre" - 1 + 0 5 1 1 @@ -4010,7 +3923,7 @@ 0 "3/10/2006" "wbFlexGridSizerProxy" - "1" + "" "" 2 30 @@ -4038,7 +3951,6 @@ 1 0 0 - "3/10/2006" "wbStaticTextProxy" "wxID_STATIC" 5105 @@ -4101,115 +4013,87 @@ "" - "wxBoxSizer H" + "wxTextCtrl: ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE" "dialog-control-document" "" - "sizer" + "textctrl" 0 1 0 0 - "3/10/2006" - "wbBoxSizerProxy" - "Horizontal" - "" + "wbTextCtrlProxy" + "wxEVT_COMMAND_TEXT_UPDATED|OnSpacingBeforeUpdated" + "ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE" + 10114 + "" + "wxTextCtrl" + "wxTextCtrl" + 1 + 0 + "" + "" + "m_spacingBefore" + "" + 0 + "The spacing before the paragraph." + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 50 + -1 "Expand" "Centre" 0 5 - 0 - 0 - 0 - 0 + 1 + 1 + 1 + 1 0 0 0 - "<Any platform>" - - "wxTextCtrl: ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "3/10/2006" - "wbTextCtrlProxy" - "wxEVT_COMMAND_TEXT_UPDATED|OnSpacingBeforeUpdated" - "ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE" - 10114 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_spacingBefore" - "" - 0 - "The spacing before the paragraph." - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - 50 - -1 - "Centre" - "Centre" - 1 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - 0 - + "" + "" "wxStaticText: wxID_STATIC" @@ -4220,7 +4104,6 @@ 1 0 0 - "3/10/2006" "wbStaticTextProxy" "wxID_STATIC" 5105 @@ -4283,115 +4166,87 @@ "" - "wxBoxSizer H" + "wxTextCtrl: ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER" "dialog-control-document" "" - "sizer" + "textctrl" 0 1 0 0 - "3/10/2006" - "wbBoxSizerProxy" - "Horizontal" - "" + "wbTextCtrlProxy" + "wxEVT_COMMAND_TEXT_UPDATED|OnSpacingAfterUpdated" + "ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER" + 10116 + "" + "wxTextCtrl" + "wxTextCtrl" + 1 + 0 + "" + "" + "m_spacingAfter" + "" + 0 + "" + "The spacing after the paragraph." + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 50 + -1 "Expand" "Centre" - 1 + 0 5 - 0 - 0 - 0 - 0 + 1 + 1 + 1 + 1 0 0 0 - "<Any platform>" - - "wxTextCtrl: ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "3/10/2006" - "wbTextCtrlProxy" - "wxEVT_COMMAND_TEXT_UPDATED|OnSpacingAfterUpdated" - "ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER" - 10116 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_spacingAfter" - "" - 0 - "" - "The spacing after the paragraph." - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - 50 - -1 - "Centre" - "Centre" - 1 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - 0 - + "" + "" "wxStaticText: wxID_STATIC" @@ -4465,96 +4320,69 @@ "" - "wxBoxSizer H" + "wxComboBox: ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE" "dialog-control-document" "" - "sizer" + "combobox" 0 1 0 0 - "3/10/2006" - "wbBoxSizerProxy" - "Horizontal" - "" + "wbComboBoxProxy" + "wxEVT_COMMAND_COMBOBOX_SELECTED|OnSpacingLineSelected" + "ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE" + 10115 + "" + "wxComboBox" + "wxComboBox" + 1 + 0 + "" + "" + "m_spacingLine" + "(none)|Single|1.1|1.2|1.3|1.4|1.5|1.6|1.7|1.8|1.9|2" + "(none)" + "The line spacing." + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 85 + -1 "Expand" "Centre" 0 5 - 0 - 0 - 0 - 0 + 1 + 1 + 1 + 1 0 0 0 - "<Any platform>" - - "wxComboBox: ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE" - "dialog-control-document" - "" - "combobox" - 0 - 1 - 0 - 0 - "3/10/2006" - "wbComboBoxProxy" - "wxEVT_COMMAND_COMBOBOX_SELECTED|OnSpacingLineSelected" - "ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE" - 10115 - "" - "wxComboBox" - "wxComboBox" - 1 - 0 - "" - "" - "m_spacingLine" - "Single|1.1|1.2|1.3|1.4|1.5|1.6|1.7|1.8|1.9|2" - "Single" - "The line spacing." - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 1 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - 90 - -1 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - + "" + "" @@ -13222,7 +13050,6 @@ 1 0 0 - "18/10/2006" "wbStaticTextProxy" "wxID_STATIC" 5105 @@ -13285,115 +13112,87 @@ "" - "wxBoxSizer H" + "wxTextCtrl: ID_RICHTEXTLISTSTYLEPAGE_INDENTLEFT" "dialog-control-document" "" - "sizer" + "textctrl" 0 1 0 0 - "18/10/2006" - "wbBoxSizerProxy" - "Horizontal" - "" - "Centre" + "wbTextCtrlProxy" + "wxEVT_COMMAND_TEXT_UPDATED|OnIndentLeftUpdated" + "ID_RICHTEXTLISTSTYLEPAGE_INDENTLEFT" + 10634 + "" + "wxTextCtrl" + "wxTextCtrl" + 1 + 0 + "" + "" + "m_indentLeft" + "" + 0 + "The left indent." + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 50 + -1 + "Expand" "Centre" 0 5 - 0 - 0 - 0 - 0 + 1 + 1 + 1 + 1 0 0 0 - "<Any platform>" - - "wxTextCtrl: ID_RICHTEXTLISTSTYLEPAGE_INDENTLEFT" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "18/10/2006" - "wbTextCtrlProxy" - "wxEVT_COMMAND_TEXT_UPDATED|OnIndentLeftUpdated" - "ID_RICHTEXTLISTSTYLEPAGE_INDENTLEFT" - 10634 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_indentLeft" - "" - 0 - "The left indent." - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - 50 - -1 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - 0 - + "" + "" "wxStaticText: wxID_STATIC" @@ -13404,7 +13203,6 @@ 1 0 0 - "18/10/2006" "wbStaticTextProxy" "wxID_STATIC" 5105 @@ -13467,115 +13265,87 @@ "" - "wxBoxSizer H" + "wxTextCtrl: ID_RICHTEXTLISTSTYLEPAGE_INDENTFIRSTLINE" "dialog-control-document" "" - "sizer" + "textctrl" 0 1 0 0 - "18/10/2006" - "wbBoxSizerProxy" - "Horizontal" - "" - "Centre" + "wbTextCtrlProxy" + "wxEVT_COMMAND_TEXT_UPDATED|OnIndentFirstLineUpdated" + "ID_RICHTEXTLISTSTYLEPAGE_INDENTFIRSTLINE" + 10635 + "" + "wxTextCtrl" + "wxTextCtrl" + 1 + 0 + "" + "" + "m_indentLeftFirst" + "" + 0 + "The first line indent." + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 50 + -1 + "Expand" "Centre" 0 5 - 0 - 0 - 0 - 0 + 1 + 1 + 1 + 1 0 0 0 - "<Any platform>" - - "wxTextCtrl: ID_RICHTEXTLISTSTYLEPAGE_INDENTFIRSTLINE" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "18/10/2006" - "wbTextCtrlProxy" - "wxEVT_COMMAND_TEXT_UPDATED|OnIndentFirstLineUpdated" - "ID_RICHTEXTLISTSTYLEPAGE_INDENTFIRSTLINE" - 10635 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_indentLeftFirst" - "" - 0 - "The first line indent." - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - 50 - -1 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - 0 - + "" + "" "wxStaticText: wxID_STATIC" @@ -13649,115 +13419,87 @@ "" - "wxBoxSizer H" + "wxTextCtrl: ID_RICHTEXTLISTSTYLEPAGE_INDENTRIGHT" "dialog-control-document" "" - "sizer" + "textctrl" 0 1 0 0 - "18/10/2006" - "wbBoxSizerProxy" - "Horizontal" - "" - "Centre" + "wbTextCtrlProxy" + "wxEVT_COMMAND_TEXT_UPDATED|OnIndentRightUpdated" + "ID_RICHTEXTLISTSTYLEPAGE_INDENTRIGHT" + 10636 + "" + "wxTextCtrl" + "wxTextCtrl" + 1 + 0 + "" + "" + "m_indentRight" + "" + 0 + "The right indent." + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 50 + -1 + "Expand" "Centre" 0 5 - 0 - 0 - 0 - 0 + 1 + 1 + 1 + 1 0 0 0 - "<Any platform>" - - "wxTextCtrl: ID_RICHTEXTLISTSTYLEPAGE_INDENTRIGHT" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "18/10/2006" - "wbTextCtrlProxy" - "wxEVT_COMMAND_TEXT_UPDATED|OnIndentRightUpdated" - "ID_RICHTEXTLISTSTYLEPAGE_INDENTRIGHT" - 10636 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_indentRight" - "" - 0 - "The right indent." - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - 50 - -1 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - 0 - + "" + "" @@ -14056,7 +13798,6 @@ 1 0 0 - "18/10/2006" "wbStaticTextProxy" "wxID_STATIC" 5105 @@ -14119,115 +13860,87 @@ "" - "wxBoxSizer H" + "wxTextCtrl: ID_RICHTEXTLISTSTYLEPAGE_SPACINGBEFORE" "dialog-control-document" "" - "sizer" + "textctrl" 0 1 0 0 - "18/10/2006" - "wbBoxSizerProxy" - "Horizontal" - "" - "Centre" + "wbTextCtrlProxy" + "wxEVT_COMMAND_TEXT_UPDATED|OnSpacingBeforeUpdated" + "ID_RICHTEXTLISTSTYLEPAGE_SPACINGBEFORE" + 10637 + "" + "wxTextCtrl" + "wxTextCtrl" + 1 + 0 + "" + "" + "m_spacingBefore" + "" + 0 + "The spacing before the paragraph." + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 50 + -1 + "Expand" "Centre" 0 5 - 0 - 0 - 0 - 0 + 1 + 1 + 1 + 1 0 0 0 - "<Any platform>" - - "wxTextCtrl: ID_RICHTEXTLISTSTYLEPAGE_SPACINGBEFORE" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "18/10/2006" - "wbTextCtrlProxy" - "wxEVT_COMMAND_TEXT_UPDATED|OnSpacingBeforeUpdated" - "ID_RICHTEXTLISTSTYLEPAGE_SPACINGBEFORE" - 10637 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_spacingBefore" - "" - 0 - "The spacing before the paragraph." - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - 50 - -1 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - 0 - + "" + "" "wxStaticText: wxID_STATIC" @@ -14238,7 +13951,6 @@ 1 0 0 - "18/10/2006" "wbStaticTextProxy" "wxID_STATIC" 5105 @@ -14301,115 +14013,87 @@ "" - "wxBoxSizer H" + "wxTextCtrl: ID_RICHTEXTLISTSTYLEPAGE_SPACINGAFTER" "dialog-control-document" "" - "sizer" + "textctrl" 0 1 0 0 - "18/10/2006" - "wbBoxSizerProxy" - "Horizontal" - "" - "Centre" + "wbTextCtrlProxy" + "wxEVT_COMMAND_TEXT_UPDATED|OnSpacingAfterUpdated" + "ID_RICHTEXTLISTSTYLEPAGE_SPACINGAFTER" + 10638 + "" + "wxTextCtrl" + "wxTextCtrl" + 1 + 0 + "" + "" + "m_spacingAfter" + "" + 0 + "The spacing after the paragraph." + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 50 + -1 + "Expand" "Centre" 0 5 - 0 - 0 - 0 - 0 + 1 + 1 + 1 + 1 0 0 0 - "<Any platform>" - - "wxTextCtrl: ID_RICHTEXTLISTSTYLEPAGE_SPACINGAFTER" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "18/10/2006" - "wbTextCtrlProxy" - "wxEVT_COMMAND_TEXT_UPDATED|OnSpacingAfterUpdated" - "ID_RICHTEXTLISTSTYLEPAGE_SPACINGAFTER" - 10638 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_spacingAfter" - "" - 0 - "The spacing after the paragraph." - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - 50 - -1 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - 0 - + "" + "" "wxStaticText: wxID_STATIC" @@ -14483,96 +14167,69 @@ "" - "wxBoxSizer H" + "wxComboBox: ID_RICHTEXTLISTSTYLEPAGE_LINESPACING" "dialog-control-document" "" - "sizer" + "combobox" 0 1 0 0 - "18/10/2006" - "wbBoxSizerProxy" - "Horizontal" - "" - "Centre" + "wbComboBoxProxy" + "wxEVT_COMMAND_COMBOBOX_SELECTED|OnLineSpacingSelected" + "ID_RICHTEXTLISTSTYLEPAGE_LINESPACING" + 10639 + "" + "wxComboBox" + "wxComboBox" + 1 + 0 + "" + "" + "m_spacingLine" + "(none)|Single|1.1|1.2|1.3|1.4|1.5|1.6|1.7|1.8|1.9|2" + "(none)" + "The line spacing." + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + "" + "" + "" + "" + "" + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 85 + -1 + "Expand" "Centre" 0 5 - 0 - 0 - 0 - 0 + 1 + 1 + 1 + 1 0 0 0 - "<Any platform>" - - "wxComboBox: ID_RICHTEXTLISTSTYLEPAGE_LINESPACING" - "dialog-control-document" - "" - "combobox" - 0 - 1 - 0 - 0 - "18/10/2006" - "wbComboBoxProxy" - "wxEVT_COMMAND_COMBOBOX_SELECTED|OnLineSpacingSelected" - "ID_RICHTEXTLISTSTYLEPAGE_LINESPACING" - 10639 - "" - "wxComboBox" - "wxComboBox" - 1 - 0 - "" - "" - "m_spacingLine" - "Single|1.5|2" - "Single" - "The line spacing." - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 1 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - + "" + "" @@ -14851,6 +14508,14 @@ "wbBoxSizerProxy" "Vertical" "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 0 0 0 diff --git a/src/richtext/richtextindentspage.cpp b/src/richtext/richtextindentspage.cpp index f73bb16211..626de8d2d1 100644 --- a/src/richtext/richtextindentspage.cpp +++ b/src/richtext/richtextindentspage.cpp @@ -207,44 +207,35 @@ void wxRichTextIndentsSpacingPage::CreateControls() wxStaticText* itemStaticText23 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Left:"), wxDefaultPosition, wxDefaultSize, 0 ); itemFlexGridSizer22->Add(itemStaticText23, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxHORIZONTAL); - itemFlexGridSizer22->Add(itemBoxSizer24, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5); - m_indentLeft = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 ); m_indentLeft->SetHelpText(_("The left indent.")); if (wxRichTextIndentsSpacingPage::ShowToolTips()) m_indentLeft->SetToolTip(_("The left indent.")); - itemBoxSizer24->Add(m_indentLeft, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemFlexGridSizer22->Add(m_indentLeft, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxStaticText* itemStaticText26 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Left (&first line):"), wxDefaultPosition, wxDefaultSize, 0 ); - itemFlexGridSizer22->Add(itemStaticText26, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - - wxBoxSizer* itemBoxSizer27 = new wxBoxSizer(wxHORIZONTAL); - itemFlexGridSizer22->Add(itemBoxSizer27, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5); + wxStaticText* itemStaticText25 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Left (&first line):"), wxDefaultPosition, wxDefaultSize, 0 ); + itemFlexGridSizer22->Add(itemStaticText25, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_indentLeftFirst = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 ); m_indentLeftFirst->SetHelpText(_("The first line indent.")); if (wxRichTextIndentsSpacingPage::ShowToolTips()) m_indentLeftFirst->SetToolTip(_("The first line indent.")); - itemBoxSizer27->Add(m_indentLeftFirst, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemFlexGridSizer22->Add(m_indentLeftFirst, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxStaticText* itemStaticText29 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Right:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemFlexGridSizer22->Add(itemStaticText29, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - - wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxHORIZONTAL); - itemFlexGridSizer22->Add(itemBoxSizer30, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5); + wxStaticText* itemStaticText27 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Right:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemFlexGridSizer22->Add(itemStaticText27, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_indentRight = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 ); m_indentRight->SetHelpText(_("The right indent.")); if (wxRichTextIndentsSpacingPage::ShowToolTips()) m_indentRight->SetToolTip(_("The right indent.")); - itemBoxSizer30->Add(m_indentRight, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemFlexGridSizer22->Add(m_indentRight, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxStaticText* itemStaticText32 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Outline level:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemFlexGridSizer22->Add(itemStaticText32, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxStaticText* itemStaticText29 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Outline level:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemFlexGridSizer22->Add(itemStaticText29, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); wxArrayString m_outlineLevelCtrlStrings; - m_outlineLevelCtrlStrings.Add(_("Normal")); + m_outlineLevelCtrlStrings.Add(_("(none)")); m_outlineLevelCtrlStrings.Add(_("1")); m_outlineLevelCtrlStrings.Add(_("2")); m_outlineLevelCtrlStrings.Add(_("3")); @@ -254,65 +245,57 @@ void wxRichTextIndentsSpacingPage::CreateControls() m_outlineLevelCtrlStrings.Add(_("7")); m_outlineLevelCtrlStrings.Add(_("8")); m_outlineLevelCtrlStrings.Add(_("9")); - m_outlineLevelCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL, _("Normal"), wxDefaultPosition, wxSize(90, -1), m_outlineLevelCtrlStrings, wxCB_READONLY ); - m_outlineLevelCtrl->SetStringSelection(_("Normal")); + m_outlineLevelCtrlStrings.Add(_("10")); + m_outlineLevelCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL, _("(none)"), wxDefaultPosition, wxSize(85, -1), m_outlineLevelCtrlStrings, wxCB_READONLY ); + m_outlineLevelCtrl->SetStringSelection(_("(none)")); m_outlineLevelCtrl->SetHelpText(_("The outline level.")); if (wxRichTextIndentsSpacingPage::ShowToolTips()) m_outlineLevelCtrl->SetToolTip(_("The outline level.")); - itemFlexGridSizer22->Add(m_outlineLevelCtrl, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemFlexGridSizer22->Add(m_outlineLevelCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5); - wxStaticLine* itemStaticLine35 = new wxStaticLine( itemRichTextDialogPage1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); - itemBoxSizer4->Add(itemStaticLine35, 0, wxGROW|wxTOP|wxBOTTOM, 5); + wxStaticLine* itemStaticLine32 = new wxStaticLine( itemRichTextDialogPage1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); + itemBoxSizer4->Add(itemStaticLine32, 0, wxGROW|wxTOP|wxBOTTOM, 5); itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5); - wxBoxSizer* itemBoxSizer37 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer4->Add(itemBoxSizer37, 0, wxGROW, 5); + wxBoxSizer* itemBoxSizer34 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer4->Add(itemBoxSizer34, 0, wxGROW, 5); - wxStaticText* itemStaticText38 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Spacing (tenths of a mm)"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer37->Add(itemStaticText38, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); + wxStaticText* itemStaticText35 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Spacing (tenths of a mm)"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer34->Add(itemStaticText35, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - wxBoxSizer* itemBoxSizer39 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer37->Add(itemBoxSizer39, 0, wxALIGN_LEFT|wxALL, 5); + wxBoxSizer* itemBoxSizer36 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer34->Add(itemBoxSizer36, 0, wxALIGN_LEFT|wxALL, 5); - itemBoxSizer39->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5); + itemBoxSizer36->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5); - wxFlexGridSizer* itemFlexGridSizer41 = new wxFlexGridSizer(30, 2, 0, 0); - itemFlexGridSizer41->AddGrowableCol(1); - itemBoxSizer39->Add(itemFlexGridSizer41, 0, wxALIGN_CENTER_VERTICAL, 5); + wxFlexGridSizer* itemFlexGridSizer38 = new wxFlexGridSizer(30, 2, 0, 0); + itemBoxSizer36->Add(itemFlexGridSizer38, 0, wxALIGN_CENTER_VERTICAL, 5); - wxStaticText* itemStaticText42 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Before a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemFlexGridSizer41->Add(itemStaticText42, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - - wxBoxSizer* itemBoxSizer43 = new wxBoxSizer(wxHORIZONTAL); - itemFlexGridSizer41->Add(itemBoxSizer43, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5); + wxStaticText* itemStaticText39 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Before a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemFlexGridSizer38->Add(itemStaticText39, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_spacingBefore = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 ); m_spacingBefore->SetHelpText(_("The spacing before the paragraph.")); if (wxRichTextIndentsSpacingPage::ShowToolTips()) m_spacingBefore->SetToolTip(_("The spacing before the paragraph.")); - itemBoxSizer43->Add(m_spacingBefore, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemFlexGridSizer38->Add(m_spacingBefore, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxStaticText* itemStaticText45 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&After a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemFlexGridSizer41->Add(itemStaticText45, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - - wxBoxSizer* itemBoxSizer46 = new wxBoxSizer(wxHORIZONTAL); - itemFlexGridSizer41->Add(itemBoxSizer46, 1, wxGROW|wxALIGN_CENTER_VERTICAL, 5); + wxStaticText* itemStaticText41 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&After a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemFlexGridSizer38->Add(itemStaticText41, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_spacingAfter = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 ); if (wxRichTextIndentsSpacingPage::ShowToolTips()) m_spacingAfter->SetToolTip(_("The spacing after the paragraph.")); - itemBoxSizer46->Add(m_spacingAfter, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemFlexGridSizer38->Add(m_spacingAfter, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxStaticText* itemStaticText48 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("L&ine spacing:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemFlexGridSizer41->Add(itemStaticText48, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - - wxBoxSizer* itemBoxSizer49 = new wxBoxSizer(wxHORIZONTAL); - itemFlexGridSizer41->Add(itemBoxSizer49, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5); + wxStaticText* itemStaticText43 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("L&ine spacing:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemFlexGridSizer38->Add(itemStaticText43, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); wxArrayString m_spacingLineStrings; + m_spacingLineStrings.Add(_("(none)")); m_spacingLineStrings.Add(_("Single")); m_spacingLineStrings.Add(_("1.1")); m_spacingLineStrings.Add(_("1.2")); @@ -324,12 +307,12 @@ void wxRichTextIndentsSpacingPage::CreateControls() m_spacingLineStrings.Add(_("1.8")); m_spacingLineStrings.Add(_("1.9")); m_spacingLineStrings.Add(_("2")); - m_spacingLine = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE, _("Single"), wxDefaultPosition, wxSize(90, -1), m_spacingLineStrings, wxCB_READONLY ); - m_spacingLine->SetStringSelection(_("Single")); + m_spacingLine = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE, _("(none)"), wxDefaultPosition, wxSize(85, -1), m_spacingLineStrings, wxCB_READONLY ); + m_spacingLine->SetStringSelection(_("(none)")); m_spacingLine->SetHelpText(_("The line spacing.")); if (wxRichTextIndentsSpacingPage::ShowToolTips()) m_spacingLine->SetToolTip(_("The line spacing.")); - itemBoxSizer49->Add(m_spacingLine, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemFlexGridSizer38->Add(m_spacingLine, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5); @@ -448,9 +431,9 @@ bool wxRichTextIndentsSpacingPage::TransferDataFromWindow() else attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_BEFORE)); - int spacingIndex = m_spacingLine->GetSelection(); + int spacingIndex = m_spacingLine->GetSelection() - 1; int lineSpacing = 0; - if (spacingIndex != -1) + if (spacingIndex > -1) lineSpacing = 10 + spacingIndex; if (lineSpacing == 0) @@ -459,8 +442,13 @@ bool wxRichTextIndentsSpacingPage::TransferDataFromWindow() attr->SetLineSpacing(lineSpacing); int outlineLevel = m_outlineLevelCtrl->GetSelection(); - if (outlineLevel != wxNOT_FOUND) - attr->SetOutlineLevel(outlineLevel); + if (outlineLevel == wxNOT_FOUND || outlineLevel == 0) + { + attr->SetOutlineLevel(-1); + attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_OUTLINE_LEVEL)); + } + else + attr->SetOutlineLevel(outlineLevel-1); return true; } @@ -536,14 +524,14 @@ bool wxRichTextIndentsSpacingPage::TransferDataToWindow() int lineSpacing = attr->GetLineSpacing(); if (lineSpacing >= 10 && lineSpacing <= 20) - index = lineSpacing - 10; + index = (lineSpacing - 10) + 1; else - index = -1; + index = 0; m_spacingLine->SetSelection(index); } else - m_spacingLine->SetSelection(-1); + m_spacingLine->SetSelection(0); if (attr->HasOutlineLevel()) { @@ -553,10 +541,10 @@ bool wxRichTextIndentsSpacingPage::TransferDataToWindow() if (outlineLevel > 9) outlineLevel = 9; - m_outlineLevelCtrl->SetSelection(outlineLevel); + m_outlineLevelCtrl->SetSelection(outlineLevel+1); } else - m_outlineLevelCtrl->SetSelection(-1); + m_outlineLevelCtrl->SetSelection(0); UpdatePreview(); diff --git a/src/richtext/richtextliststylepage.cpp b/src/richtext/richtextliststylepage.cpp index ec7a360cde..9f7710fe82 100644 --- a/src/richtext/richtextliststylepage.cpp +++ b/src/richtext/richtextliststylepage.cpp @@ -382,91 +382,88 @@ void wxRichTextListStylePage::CreateControls() wxStaticText* itemStaticText58 = new wxStaticText( itemPanel37, wxID_STATIC, _("&Left:"), wxDefaultPosition, wxDefaultSize, 0 ); itemFlexGridSizer57->Add(itemStaticText58, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxBoxSizer* itemBoxSizer59 = new wxBoxSizer(wxHORIZONTAL); - itemFlexGridSizer57->Add(itemBoxSizer59, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); m_indentLeft = new wxTextCtrl( itemPanel37, ID_RICHTEXTLISTSTYLEPAGE_INDENTLEFT, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 ); m_indentLeft->SetHelpText(_("The left indent.")); if (wxRichTextListStylePage::ShowToolTips()) m_indentLeft->SetToolTip(_("The left indent.")); - itemBoxSizer59->Add(m_indentLeft, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemFlexGridSizer57->Add(m_indentLeft, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxStaticText* itemStaticText61 = new wxStaticText( itemPanel37, wxID_STATIC, _("Left (&first line):"), wxDefaultPosition, wxDefaultSize, 0 ); - itemFlexGridSizer57->Add(itemStaticText61, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxStaticText* itemStaticText60 = new wxStaticText( itemPanel37, wxID_STATIC, _("Left (&first line):"), wxDefaultPosition, wxDefaultSize, 0 ); + itemFlexGridSizer57->Add(itemStaticText60, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxBoxSizer* itemBoxSizer62 = new wxBoxSizer(wxHORIZONTAL); - itemFlexGridSizer57->Add(itemBoxSizer62, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); m_indentLeftFirst = new wxTextCtrl( itemPanel37, ID_RICHTEXTLISTSTYLEPAGE_INDENTFIRSTLINE, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 ); m_indentLeftFirst->SetHelpText(_("The first line indent.")); if (wxRichTextListStylePage::ShowToolTips()) m_indentLeftFirst->SetToolTip(_("The first line indent.")); - itemBoxSizer62->Add(m_indentLeftFirst, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemFlexGridSizer57->Add(m_indentLeftFirst, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxStaticText* itemStaticText64 = new wxStaticText( itemPanel37, wxID_STATIC, _("&Right:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemFlexGridSizer57->Add(itemStaticText64, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxStaticText* itemStaticText62 = new wxStaticText( itemPanel37, wxID_STATIC, _("&Right:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemFlexGridSizer57->Add(itemStaticText62, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxBoxSizer* itemBoxSizer65 = new wxBoxSizer(wxHORIZONTAL); - itemFlexGridSizer57->Add(itemBoxSizer65, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); m_indentRight = new wxTextCtrl( itemPanel37, ID_RICHTEXTLISTSTYLEPAGE_INDENTRIGHT, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 ); m_indentRight->SetHelpText(_("The right indent.")); if (wxRichTextListStylePage::ShowToolTips()) m_indentRight->SetToolTip(_("The right indent.")); - itemBoxSizer65->Add(m_indentRight, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemFlexGridSizer57->Add(m_indentRight, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer39->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5); - wxStaticLine* itemStaticLine68 = new wxStaticLine( itemPanel37, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); - itemBoxSizer39->Add(itemStaticLine68, 0, wxGROW|wxTOP|wxBOTTOM, 5); + wxStaticLine* itemStaticLine65 = new wxStaticLine( itemPanel37, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); + itemBoxSizer39->Add(itemStaticLine65, 0, wxGROW|wxTOP|wxBOTTOM, 5); itemBoxSizer39->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5); - wxBoxSizer* itemBoxSizer70 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer39->Add(itemBoxSizer70, 0, wxGROW, 5); - wxStaticText* itemStaticText71 = new wxStaticText( itemPanel37, wxID_STATIC, _("&Spacing (tenths of a mm)"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer70->Add(itemStaticText71, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); + wxBoxSizer* itemBoxSizer67 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer39->Add(itemBoxSizer67, 0, wxGROW, 5); + wxStaticText* itemStaticText68 = new wxStaticText( itemPanel37, wxID_STATIC, _("&Spacing (tenths of a mm)"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer67->Add(itemStaticText68, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - wxBoxSizer* itemBoxSizer72 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer70->Add(itemBoxSizer72, 0, wxALIGN_LEFT|wxALL, 5); - itemBoxSizer72->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5); + wxBoxSizer* itemBoxSizer69 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer67->Add(itemBoxSizer69, 0, wxALIGN_LEFT|wxALL, 5); + itemBoxSizer69->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5); - wxFlexGridSizer* itemFlexGridSizer74 = new wxFlexGridSizer(0, 2, 0, 0); - itemBoxSizer72->Add(itemFlexGridSizer74, 0, wxALIGN_CENTER_VERTICAL, 5); - wxStaticText* itemStaticText75 = new wxStaticText( itemPanel37, wxID_STATIC, _("Before a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemFlexGridSizer74->Add(itemStaticText75, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxFlexGridSizer* itemFlexGridSizer71 = new wxFlexGridSizer(0, 2, 0, 0); + itemBoxSizer69->Add(itemFlexGridSizer71, 0, wxALIGN_CENTER_VERTICAL, 5); + wxStaticText* itemStaticText72 = new wxStaticText( itemPanel37, wxID_STATIC, _("Before a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemFlexGridSizer71->Add(itemStaticText72, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxBoxSizer* itemBoxSizer76 = new wxBoxSizer(wxHORIZONTAL); - itemFlexGridSizer74->Add(itemBoxSizer76, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); m_spacingBefore = new wxTextCtrl( itemPanel37, ID_RICHTEXTLISTSTYLEPAGE_SPACINGBEFORE, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 ); m_spacingBefore->SetHelpText(_("The spacing before the paragraph.")); if (wxRichTextListStylePage::ShowToolTips()) m_spacingBefore->SetToolTip(_("The spacing before the paragraph.")); - itemBoxSizer76->Add(m_spacingBefore, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemFlexGridSizer71->Add(m_spacingBefore, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxStaticText* itemStaticText78 = new wxStaticText( itemPanel37, wxID_STATIC, _("After a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemFlexGridSizer74->Add(itemStaticText78, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxStaticText* itemStaticText74 = new wxStaticText( itemPanel37, wxID_STATIC, _("After a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemFlexGridSizer71->Add(itemStaticText74, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxBoxSizer* itemBoxSizer79 = new wxBoxSizer(wxHORIZONTAL); - itemFlexGridSizer74->Add(itemBoxSizer79, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); m_spacingAfter = new wxTextCtrl( itemPanel37, ID_RICHTEXTLISTSTYLEPAGE_SPACINGAFTER, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 ); m_spacingAfter->SetHelpText(_("The spacing after the paragraph.")); if (wxRichTextListStylePage::ShowToolTips()) m_spacingAfter->SetToolTip(_("The spacing after the paragraph.")); - itemBoxSizer79->Add(m_spacingAfter, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemFlexGridSizer71->Add(m_spacingAfter, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxStaticText* itemStaticText81 = new wxStaticText( itemPanel37, wxID_STATIC, _("Line spacing:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemFlexGridSizer74->Add(itemStaticText81, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxStaticText* itemStaticText76 = new wxStaticText( itemPanel37, wxID_STATIC, _("Line spacing:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemFlexGridSizer71->Add(itemStaticText76, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxBoxSizer* itemBoxSizer82 = new wxBoxSizer(wxHORIZONTAL); - itemFlexGridSizer74->Add(itemBoxSizer82, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); wxArrayString m_spacingLineStrings; + m_spacingLineStrings.Add(_("(none)")); m_spacingLineStrings.Add(_("Single")); + m_spacingLineStrings.Add(_("1.1")); + m_spacingLineStrings.Add(_("1.2")); + m_spacingLineStrings.Add(_("1.3")); + m_spacingLineStrings.Add(_("1.4")); m_spacingLineStrings.Add(_("1.5")); + m_spacingLineStrings.Add(_("1.6")); + m_spacingLineStrings.Add(_("1.7")); + m_spacingLineStrings.Add(_("1.8")); + m_spacingLineStrings.Add(_("1.9")); m_spacingLineStrings.Add(_("2")); - m_spacingLine = new wxComboBox( itemPanel37, ID_RICHTEXTLISTSTYLEPAGE_LINESPACING, _("Single"), wxDefaultPosition, wxDefaultSize, m_spacingLineStrings, wxCB_READONLY ); - m_spacingLine->SetStringSelection(_("Single")); + m_spacingLine = new wxComboBox( itemPanel37, ID_RICHTEXTLISTSTYLEPAGE_LINESPACING, _("(none)"), wxDefaultPosition, wxSize(85, -1), m_spacingLineStrings, wxCB_READONLY ); + m_spacingLine->SetStringSelection(_("(none)")); m_spacingLine->SetHelpText(_("The line spacing.")); if (wxRichTextListStylePage::ShowToolTips()) m_spacingLine->SetToolTip(_("The line spacing.")); - itemBoxSizer82->Add(m_spacingLine, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemFlexGridSizer71->Add(m_spacingLine, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); itemNotebook9->AddPage(itemPanel37, _("Spacing")); @@ -631,14 +628,10 @@ bool wxRichTextListStylePage::TransferDataFromWindow() else attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_BEFORE)); - int spacingIndex = m_spacingLine->GetSelection(); + int spacingIndex = m_spacingLine->GetSelection() - 1; int lineSpacing = 0; - if (spacingIndex == 0) - lineSpacing = 10; - else if (spacingIndex == 1) - lineSpacing = 15; - else if (spacingIndex == 2) - lineSpacing = 20; + if (spacingIndex > -1) + lineSpacing = 10 + spacingIndex; if (lineSpacing == 0) attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_LINE_SPACING)); @@ -785,19 +778,15 @@ void wxRichTextListStylePage::DoTransferDataToWindow() int index = 0; int lineSpacing = attr->GetLineSpacing(); - if (lineSpacing == 10) - index = 0; - else if (lineSpacing == 15) - index = 1; - else if (lineSpacing == 20) - index = 2; + if (lineSpacing >= 10 && lineSpacing <= 20) + index = (lineSpacing - 10) + 1; else - index = -1; + index = 0; m_spacingLine->SetSelection(index); } else - m_spacingLine->SetSelection(-1); + m_spacingLine->SetSelection(0); /// BULLETS if (attr->HasBulletStyle()) From 5755acd77fbed26c681cef924013a2d99415ff6c Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 3 Aug 2011 15:46:43 +0000 Subject: [PATCH 26/52] Return sensible major and minor version numbers for Mac OS X git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68506 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 2 ++ src/osx/core/utilsexc_base.cpp | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 0d0b99255f..4023793277 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -455,6 +455,8 @@ All (GUI): OSX: - Implement wxRegion::Equal() (Dr.Acula). +- wxGetOsVersion() now returns more sensible version numbers, e.g. 10 and 6 + for OS X 10.6. GTK: diff --git a/src/osx/core/utilsexc_base.cpp b/src/osx/core/utilsexc_base.cpp index e1a8a61e0d..84f8a0e3a3 100644 --- a/src/osx/core/utilsexc_base.cpp +++ b/src/osx/core/utilsexc_base.cpp @@ -77,6 +77,19 @@ long UMAGetSystemVersion() // our OS version is the same in non GUI and GUI cases wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn) { + // This returns 10 and 6 for OS X 10.6, consistent with behaviour on + // other platforms. + SInt32 maj, min; + Gestalt(gestaltSystemVersionMajor, &maj); + Gestalt(gestaltSystemVersionMinor, &min); + + if ( majorVsn != NULL ) + *majorVsn = maj; + + if ( minorVsn != NULL ) + *minorVsn = min; + +#if 0 SInt32 theSystem; Gestalt(gestaltSystemVersion, &theSystem); @@ -85,7 +98,7 @@ wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn) if ( minorVsn != NULL ) *minorVsn = (theSystem & 0xFF); - +#endif return wxOS_MAC_OSX_DARWIN; } From 4c7d9d88b78b56e552f78f8eb3040264afcca5df Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 4 Aug 2011 12:31:44 +0000 Subject: [PATCH 27/52] Added Page Break control to spacing page git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68517 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/richtext/richtextindentspage.h | 2 + src/richtext/richtextdialogs.pjd | 73 ++++++++++++++++++++++- src/richtext/richtextindentspage.cpp | 12 ++++ 3 files changed, 86 insertions(+), 1 deletion(-) diff --git a/include/wx/richtext/richtextindentspage.h b/include/wx/richtext/richtextindentspage.h index 0e734dea80..eaebc469a4 100644 --- a/include/wx/richtext/richtextindentspage.h +++ b/include/wx/richtext/richtextindentspage.h @@ -141,6 +141,7 @@ public: wxTextCtrl* m_spacingBefore; wxTextCtrl* m_spacingAfter; wxComboBox* m_spacingLine; + wxCheckBox* m_pageBreakCtrl; wxRichTextCtrl* m_previewCtrl; /// Control identifiers enum { @@ -157,6 +158,7 @@ public: ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE = 10114, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER = 10116, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE = 10115, + ID_RICHTEXTINDENTSSPACINGPAGE_PAGEBREAK = 10106, ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL = 10109 }; ////@end wxRichTextIndentsSpacingPage member variables diff --git a/src/richtext/richtextdialogs.pjd b/src/richtext/richtextdialogs.pjd index 3df8163d19..fc0f92ab27 100644 --- a/src/richtext/richtextdialogs.pjd +++ b/src/richtext/richtextdialogs.pjd @@ -4329,7 +4329,7 @@ 0 0 "wbComboBoxProxy" - "wxEVT_COMMAND_COMBOBOX_SELECTED|OnSpacingLineSelected" + "wxEVT_COMMAND_COMBOBOX_SELECTED|OnSpacingLineSelected|||wxRichTextIndentsSpacingPage" "ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE" 10115 "" @@ -4386,6 +4386,69 @@ + + "wxCheckBox: ID_RICHTEXTINDENTSSPACINGPAGE_PAGEBREAK" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "wbCheckBoxProxy" + "ID_RICHTEXTINDENTSSPACINGPAGE_PAGEBREAK" + 10106 + "" + "wxCheckBox" + "wxCheckBox" + 1 + 0 + "" + "" + "m_pageBreakCtrl" + "&Page Break" + 0 + "Inserts a page break before the paragraph." + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + @@ -10382,6 +10445,14 @@ "wbBoxSizerProxy" "Vertical" "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 0 0 0 diff --git a/src/richtext/richtextindentspage.cpp b/src/richtext/richtextindentspage.cpp index 626de8d2d1..604476ae3e 100644 --- a/src/richtext/richtextindentspage.cpp +++ b/src/richtext/richtextindentspage.cpp @@ -92,6 +92,7 @@ void wxRichTextIndentsSpacingPage::Init() m_spacingBefore = NULL; m_spacingAfter = NULL; m_spacingLine = NULL; + m_pageBreakCtrl = NULL; m_previewCtrl = NULL; ////@end wxRichTextIndentsSpacingPage member initialisation @@ -314,6 +315,13 @@ void wxRichTextIndentsSpacingPage::CreateControls() m_spacingLine->SetToolTip(_("The line spacing.")); itemFlexGridSizer38->Add(m_spacingLine, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); + m_pageBreakCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_PAGEBREAK, _("&Page Break"), wxDefaultPosition, wxDefaultSize, 0 ); + m_pageBreakCtrl->SetValue(false); + m_pageBreakCtrl->SetHelpText(_("Inserts a page break before the paragraph.")); + if (wxRichTextIndentsSpacingPage::ShowToolTips()) + m_pageBreakCtrl->SetToolTip(_("Inserts a page break before the paragraph.")); + itemBoxSizer34->Add(m_pageBreakCtrl, 0, wxALIGN_LEFT|wxALL, 5); + itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5); m_previewCtrl = new wxRichTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 100), wxVSCROLL|wxTE_READONLY ); @@ -450,6 +458,8 @@ bool wxRichTextIndentsSpacingPage::TransferDataFromWindow() else attr->SetOutlineLevel(outlineLevel-1); + attr->SetPageBreak(m_pageBreakCtrl->GetValue()); + return true; } @@ -546,6 +556,8 @@ bool wxRichTextIndentsSpacingPage::TransferDataToWindow() else m_outlineLevelCtrl->SetSelection(0); + m_pageBreakCtrl->SetValue(attr->HasPageBreak()); + UpdatePreview(); m_dontUpdate = false; From 47e2f8816666a84e2b0073d9ca5f9cf4292de466 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 4 Aug 2011 13:19:57 +0000 Subject: [PATCH 28/52] Avoid unwanted line break in wxDataViewListModel::GetCount() docs. Using "i.e." in the brief Doxygen comment makes it end it after the second period and results in truncated brief description and an unwanted line break in the full description. Just avoid using periods for now inside the brief description. Maybe a better solution could be found in the future. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68519 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/wx/dataview.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index 8779ef96f9..f4d4fcd8f1 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -421,7 +421,7 @@ public: unsigned int col) const; /** - Returns the number of items (i.e. rows) in the list. + Returns the number of items (or rows) in the list. */ unsigned int GetCount() const; From 1df57a24e5f638a812c7099e1bb2822fabba248c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 4 Aug 2011 16:12:31 +0000 Subject: [PATCH 29/52] Use wxWindowMSW instead of wxWindow to fix wxUniv/MSW compilation. wxFindWindowAtPoint() only returns wxWindowMSW, not the derived wxWindow, in wxUniv build so assign its return value to wxWindowMSW to avoid compilation problems in it. Closes #12534. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68520 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 7535e4efeb..5e2e43a438 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -881,7 +881,7 @@ bool wxWindowMSW::SetCursor(const wxCursor& cursor) return false; } - const wxWindow* win = wxFindWindowAtPoint(wxPoint(pt.x, pt.y)); + const wxWindowMSW* win = wxFindWindowAtPoint(wxPoint(pt.x, pt.y)); if ( !win ) win = this; From eb2087c5e6776aea6795d6bcb7161eaf17ac6c9e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 4 Aug 2011 16:12:36 +0000 Subject: [PATCH 30/52] Compilation fixes for wxUSE_GEOMETRY==0 build. Add missing wxUSE_GEOMETRY checks to wxAffineMatrix2D-related code. Closes #13379. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68521 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/affinematrix2d.h | 6 ++++++ include/wx/affinematrix2dbase.h | 7 ++++++- src/common/affinematrix2d.cpp | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/wx/affinematrix2d.h b/include/wx/affinematrix2d.h index dfd4969614..cb94be4da1 100644 --- a/include/wx/affinematrix2d.h +++ b/include/wx/affinematrix2d.h @@ -10,6 +10,10 @@ #ifndef _WX_AFFINEMATRIX2D_H_ #define _WX_AFFINEMATRIX2D_H_ +#include "wx/defs.h" + +#if wxUSE_GEOMETRY + #include "wx/affinematrix2dbase.h" // A simple implementation of wxAffineMatrix2DBase interface done entirely in @@ -42,4 +46,6 @@ private: wxDouble m_11, m_12, m_21, m_22, m_tx, m_ty; }; +#endif // wxUSE_GEOMETRY + #endif // _WX_AFFINEMATRIX2D_H_ diff --git a/include/wx/affinematrix2dbase.h b/include/wx/affinematrix2dbase.h index 9a70402e53..30b3256500 100644 --- a/include/wx/affinematrix2dbase.h +++ b/include/wx/affinematrix2dbase.h @@ -11,6 +11,9 @@ #define _WX_AFFINEMATRIX2DBASE_H_ #include "wx/defs.h" + +#if wxUSE_GEOMETRY + #include "wx/geometry.h" struct wxMatrix2D @@ -37,7 +40,7 @@ class WXDLLIMPEXP_CORE wxAffineMatrix2DBase public: wxAffineMatrix2DBase() {} virtual ~wxAffineMatrix2DBase() {} - + // sets the matrix to the respective values virtual void Set(const wxMatrix2D& mat2D, const wxPoint2DDouble& tr) = 0; @@ -119,4 +122,6 @@ protected: wxPoint2DDouble DoTransformDistance(const wxPoint2DDouble& p) const = 0; }; +#endif // wxUSE_GEOMETRY + #endif // _WX_AFFINEMATRIX2DBASE_H_ diff --git a/src/common/affinematrix2d.cpp b/src/common/affinematrix2d.cpp index 977f6834ad..b4605d4e53 100644 --- a/src/common/affinematrix2d.cpp +++ b/src/common/affinematrix2d.cpp @@ -13,6 +13,8 @@ #pragma hdrstop #endif +#if wxUSE_GEOMETRY + #include "wx/affinematrix2d.h" #include "wx/math.h" @@ -177,3 +179,5 @@ bool wxAffineMatrix2D::IsIdentity() const m_21 == 0 && m_22 == 1 && m_tx == 0 && m_ty == 0; } + +#endif // wxUSE_GEOMETRY From 3fb39fd56c1ee6cb487b6bbfc308353e47a98475 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 4 Aug 2011 16:12:41 +0000 Subject: [PATCH 31/52] Add missing header for minimalistic builds not using PCH. wxWindow might not be fully declared in dcbase.cpp but we need its full declaration for wxDCImpl::InheritAttributes() so explicitly include wx/window.h -- while this is usually already included from somewhere else it might not be in minimal builds with a lot of features disabled. Closes #13380. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68522 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/dcbase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index d1e8ddea76..a8b4420651 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -35,6 +35,7 @@ #ifndef WX_PRECOMP #include "wx/math.h" #include "wx/module.h" + #include "wx/window.h" #endif #ifdef __WXMSW__ From 7112cdd1f3c4730391cf0a562f4d7dcee8676f07 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 4 Aug 2011 22:53:42 +0000 Subject: [PATCH 32/52] Add support for wxHELP button to wxMessageDialog. Implement support for wxHELP for wxMSW, wxGTK and wxOSX/Cocoa (at least when showing the message box from the main thread, there doesn't seem to be any way to show more than three buttons with CFUserNotificationDisplayAlert() so "Help" button is not supported when using it). This is useful not only on its own, i.e. to allow the user to ask for help, but also because it brings the total number of buttons supported by the message dialog to 4, meaning that more choices can be offered to the user (which is rarely, but not quite never, useful). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68537 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/generic/msgdlgg.h | 1 + include/wx/gtk/msgdlg.h | 1 + include/wx/msgdlg.h | 15 ++++++- include/wx/msw/private/msgdlg.h | 5 ++- include/wx/osx/msgdlg.h | 2 +- interface/wx/msgdlg.h | 28 ++++++++++-- samples/dialogs/dialogs.cpp | 35 ++++++++++++++- samples/dialogs/dialogs.h | 1 + src/common/utilscmn.cpp | 2 + src/generic/msgdlgg.cpp | 15 ++++++- src/gtk/msgdlg.cpp | 80 ++++++++++++++++++++------------- src/msw/msgdlg.cpp | 24 +++++++++- src/osx/cocoa/msgdlg.mm | 12 +++++ 14 files changed, 179 insertions(+), 43 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 4023793277..7e7620bf75 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -446,6 +446,7 @@ All (GUI): - Added documented, public wxNavigationEnabled<> class. - Added wxTextCtrl::PositionToCoords() (Navaneeth). +- Added support for wxHELP button to wxMessageDialog. - Support float, double and file name values in wxGenericValidator (troelsk). - Fix keyboard navigation in wxGrid with hidden columns (ivan_14_32). - Add wxDataViewEvent::IsEditCancelled() (Allonii). diff --git a/include/wx/generic/msgdlgg.h b/include/wx/generic/msgdlgg.h index f6583bd351..21db4aa32b 100644 --- a/include/wx/generic/msgdlgg.h +++ b/include/wx/generic/msgdlgg.h @@ -32,6 +32,7 @@ protected: void OnYes(wxCommandEvent& event); void OnNo(wxCommandEvent& event); + void OnHelp(wxCommandEvent& event); void OnCancel(wxCommandEvent& event); // can be overridden to provide more contents to the dialog diff --git a/include/wx/gtk/msgdlg.h b/include/wx/gtk/msgdlg.h index daab4caac9..8c0a7b095c 100644 --- a/include/wx/gtk/msgdlg.h +++ b/include/wx/gtk/msgdlg.h @@ -40,6 +40,7 @@ private: virtual wxString GetDefaultNoLabel() const; virtual wxString GetDefaultOKLabel() const; virtual wxString GetDefaultCancelLabel() const; + virtual wxString GetDefaultHelpLabel() const; // create the real GTK+ dialog: this is done from ShowModal() to allow // changing the message between constructing the dialog and showing it diff --git a/include/wx/msgdlg.h b/include/wx/msgdlg.h index ca96fc7ff9..c3e8d9af4f 100644 --- a/include/wx/msgdlg.h +++ b/include/wx/msgdlg.h @@ -177,10 +177,16 @@ public: return true; } + virtual bool SetHelpLabel(const ButtonLabel& help) + { + DoSetCustomLabel(m_help, help); + return true; + } + // test if any custom labels were set bool HasCustomLabels() const { - return !(m_ok.empty() && m_cancel.empty() && + return !(m_ok.empty() && m_cancel.empty() && m_help.empty() && m_yes.empty() && m_no.empty()); } @@ -195,6 +201,8 @@ public: { return m_ok.empty() ? GetDefaultOKLabel() : m_ok; } wxString GetCancelLabel() const { return m_cancel.empty() ? GetDefaultCancelLabel() : m_cancel; } + wxString GetHelpLabel() const + { return m_help.empty() ? GetDefaultHelpLabel() : m_help; } // based on message dialog style, returns exactly one of: wxICON_NONE, // wxICON_ERROR, wxICON_WARNING, wxICON_QUESTION, wxICON_INFORMATION @@ -250,6 +258,7 @@ protected: const wxString& GetCustomYesLabel() const { return m_yes; } const wxString& GetCustomNoLabel() const { return m_no; } const wxString& GetCustomOKLabel() const { return m_ok; } + const wxString& GetCustomHelpLabel() const { return m_help; } const wxString& GetCustomCancelLabel() const { return m_cancel; } private: @@ -259,13 +268,15 @@ private: virtual wxString GetDefaultNoLabel() const { return wxGetTranslation("No"); } virtual wxString GetDefaultOKLabel() const { return wxGetTranslation("OK"); } virtual wxString GetDefaultCancelLabel() const { return wxGetTranslation("Cancel"); } + virtual wxString GetDefaultHelpLabel() const { return wxGetTranslation("Help"); } // labels for the buttons, initially empty meaning that the defaults should // be used, use GetYes/No/OK/CancelLabel() to access them wxString m_yes, m_no, m_ok, - m_cancel; + m_cancel, + m_help; wxDECLARE_NO_COPY_CLASS(wxMessageDialogBase); }; diff --git a/include/wx/msw/private/msgdlg.h b/include/wx/msw/private/msgdlg.h index 5df01fc10d..45db8702e7 100644 --- a/include/wx/msw/private/msgdlg.h +++ b/include/wx/msw/private/msgdlg.h @@ -30,8 +30,10 @@ namespace wxMSWMessageDialog class wxMSWTaskDialogConfig { public: + enum { MAX_BUTTONS = 4 }; + wxMSWTaskDialogConfig() - : buttons(new TASKDIALOG_BUTTON[3]), + : buttons(new TASKDIALOG_BUTTON[MAX_BUTTONS]), parent(NULL), iconId(0), style(0), @@ -53,6 +55,7 @@ namespace wxMSWMessageDialog wxString btnNoLabel; wxString btnOKLabel; wxString btnCancelLabel; + wxString btnHelpLabel; // Will create a task dialog with it's paremeters for it's creation // stored in the provided TASKDIALOGCONFIG parameter. diff --git a/include/wx/osx/msgdlg.h b/include/wx/osx/msgdlg.h index cad3de35b7..9c3d38067d 100644 --- a/include/wx/osx/msgdlg.h +++ b/include/wx/osx/msgdlg.h @@ -43,7 +43,7 @@ protected: void* ConstructNSAlert(); #endif - int m_buttonId[3]; + int m_buttonId[4]; int m_buttonCount; #if wxOSX_USE_COCOA diff --git a/interface/wx/msgdlg.h b/interface/wx/msgdlg.h index 0448b04366..70aba8cca1 100644 --- a/interface/wx/msgdlg.h +++ b/interface/wx/msgdlg.h @@ -22,6 +22,12 @@ Puts Yes and No buttons in the message box. It is recommended to always use @c wxCANCEL with this style as otherwise the message box won't have a close button under wxMSW and the user will be forced to answer it. + @style{wxHELP} + Puts a Help button to the message box. This button can have special + appearance or be specially positioned if its label is not changed from + the default one. Notice that using this button is not supported when + showing a message box from non-main thread in wxOSX/Cocoa and it is not + supported in wxOSX/Carbon at all. @since 2.9.3. @style{wxNO_DEFAULT} Makes the "No" button default, can only be used with @c wxYES_NO. @style{wxCANCEL_DEFAULT} @@ -116,6 +122,19 @@ public: */ virtual void SetExtendedMessage(const wxString& extendedMessage); + /** + Sets the label for the Help button. + + Please see the remarks in SetYesNoLabels() documentation. + + Notice that changing the label of the help button resets its special + status (if any, this depends on the platform) and it will be treated + just like another button in this case. + + @since 2.9.3 + */ + virtual bool SetHelpLabel(const ButtonLabel& help); + /** Sets the message shown by the dialog. @@ -190,7 +209,8 @@ public: virtual bool SetYesNoLabels(const ButtonLabel& yes, const ButtonLabel& no); /** - Shows the dialog, returning one of wxID_OK, wxID_CANCEL, wxID_YES, wxID_NO. + Shows the dialog, returning one of wxID_OK, wxID_CANCEL, wxID_YES, + wxID_NO or wxID_HELP. Notice that this method returns the identifier of the button which was clicked unlike wxMessageBox() function. @@ -215,9 +235,9 @@ public: extended text and custom labels for the message box buttons, are not provided by this function but only by wxMessageDialog. - The return value is one of: @c wxYES, @c wxNO, @c wxCANCEL or @c wxOK - (notice that this return value is @b different from the return value of - wxMessageDialog::ShowModal()). + The return value is one of: @c wxYES, @c wxNO, @c wxCANCEL, @c wxOK or @c + wxHELP (notice that this return value is @b different from the return value + of wxMessageDialog::ShowModal()). For example: @code diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 335cc16ca2..14f1a80318 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -2669,6 +2669,7 @@ const TestMessageBoxDialog::BtnInfo TestMessageBoxDialog::ms_btnInfo[] = { wxNO, "&No" }, { wxOK, "&Ok" }, { wxCANCEL, "&Cancel" }, + { wxHELP, "&Help" }, }; BEGIN_EVENT_TABLE(TestMessageBoxDialog, wxDialog) @@ -2889,6 +2890,11 @@ void TestMessageBoxDialog::PrepareMessageDialog(wxMessageDialogBase &dlg) dlg.SetOKLabel(m_labels[Btn_Ok]->GetValue()); } } + + if ( style & wxHELP ) + { + dlg.SetHelpLabel(m_labels[Btn_Help]->GetValue()); + } } void TestMessageBoxDialog::OnApply(wxCommandEvent& WXUNUSED(event)) @@ -2896,7 +2902,34 @@ void TestMessageBoxDialog::OnApply(wxCommandEvent& WXUNUSED(event)) wxMessageDialog dlg(this, GetMessage(), "Test Message Box", GetStyle()); PrepareMessageDialog(dlg); - dlg.ShowModal(); + wxString btnName; + switch ( dlg.ShowModal() ) + { + case wxID_OK: + btnName = "OK"; + break; + + case wxID_CANCEL: + // Avoid the extra message box if the dialog was cancelled. + return; + + case wxID_YES: + btnName = "Yes"; + break; + + case wxID_NO: + btnName = "No"; + break; + + case wxID_HELP: + btnName = "Help"; + break; + + default: + btnName = "Unknown"; + } + + wxLogMessage("Dialog was closed with the \"%s\" button.", btnName); } void TestMessageBoxDialog::OnClose(wxCommandEvent& WXUNUSED(event)) diff --git a/samples/dialogs/dialogs.h b/samples/dialogs/dialogs.h index fbad49919a..61dd0f85aa 100644 --- a/samples/dialogs/dialogs.h +++ b/samples/dialogs/dialogs.h @@ -228,6 +228,7 @@ private: Btn_No, Btn_Ok, Btn_Cancel, + Btn_Help, Btn_Max }; diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 6e9a224e9d..4ff8dade7a 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -1361,6 +1361,8 @@ int wxMessageBox(const wxString& message, const wxString& caption, long style, return wxNO; case wxID_CANCEL: return wxCANCEL; + case wxID_HELP: + return wxHELP; } wxFAIL_MSG( wxT("unexpected return code from wxMessageDialog") ); diff --git a/src/generic/msgdlgg.cpp b/src/generic/msgdlgg.cpp index 3fd78a7269..c3dd7a8067 100644 --- a/src/generic/msgdlgg.cpp +++ b/src/generic/msgdlgg.cpp @@ -74,6 +74,7 @@ protected: BEGIN_EVENT_TABLE(wxGenericMessageDialog, wxDialog) EVT_BUTTON(wxID_YES, wxGenericMessageDialog::OnYes) EVT_BUTTON(wxID_NO, wxGenericMessageDialog::OnNo) + EVT_BUTTON(wxID_HELP, wxGenericMessageDialog::OnHelp) EVT_BUTTON(wxID_CANCEL, wxGenericMessageDialog::OnCancel) END_EVENT_TABLE() @@ -133,6 +134,13 @@ wxSizer *wxGenericMessageDialog::CreateMsgDlgButtonSizer() btnDef = yes; } + if ( m_dialogStyle & wxHELP ) + { + wxButton * const + help = new wxButton(this, wxID_HELP, GetCustomHelpLabel()); + sizerStd->AddButton(help); + } + if ( btnDef ) { btnDef->SetDefault(); @@ -148,7 +156,7 @@ wxSizer *wxGenericMessageDialog::CreateMsgDlgButtonSizer() // Use standard labels for all buttons return CreateSeparatedButtonSizer ( - m_dialogStyle & (wxOK | wxCANCEL | wxYES_NO | + m_dialogStyle & (wxOK | wxCANCEL | wxHELP | wxYES_NO | wxNO_DEFAULT | wxCANCEL_DEFAULT) ); } @@ -242,6 +250,11 @@ void wxGenericMessageDialog::OnNo(wxCommandEvent& WXUNUSED(event)) EndModal( wxID_NO ); } +void wxGenericMessageDialog::OnHelp(wxCommandEvent& WXUNUSED(event)) +{ + EndModal( wxID_HELP ); +} + void wxGenericMessageDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) { // Allow cancellation via ESC/Close button except if diff --git a/src/gtk/msgdlg.cpp b/src/gtk/msgdlg.cpp index d459602f0b..2b47ac27ef 100644 --- a/src/gtk/msgdlg.cpp +++ b/src/gtk/msgdlg.cpp @@ -74,6 +74,11 @@ wxString wxMessageDialog::GetDefaultCancelLabel() const return GTK_STOCK_CANCEL; } +wxString wxMessageDialog::GetDefaultHelpLabel() const +{ + return GTK_STOCK_HELP; +} + void wxMessageDialog::DoSetCustomLabel(wxString& var, const ButtonLabel& label) { int stockId = label.GetStockId(); @@ -135,16 +140,21 @@ void wxMessageDialog::GTKCreateMsgDialog() // when using custom labels, we have to add all the buttons ourselves if ( !HasCustomLabels() ) { - if ( m_dialogStyle & wxYES_NO ) + // "Help" button is not supported by predefined combinations so we + // always need to create the buttons manually when it's used. + if ( !(m_dialogStyle & wxHELP) ) { - if ( !(m_dialogStyle & wxCANCEL) ) - buttons = GTK_BUTTONS_YES_NO; - //else: no standard GTK_BUTTONS_YES_NO_CANCEL so leave as NONE - } - else if ( m_dialogStyle & wxOK ) - { - buttons = m_dialogStyle & wxCANCEL ? GTK_BUTTONS_OK_CANCEL - : GTK_BUTTONS_OK; + if ( m_dialogStyle & wxYES_NO ) + { + if ( !(m_dialogStyle & wxCANCEL) ) + buttons = GTK_BUTTONS_YES_NO; + //else: no standard GTK_BUTTONS_YES_NO_CANCEL so leave as NONE + } + else if ( m_dialogStyle & wxOK ) + { + buttons = m_dialogStyle & wxCANCEL ? GTK_BUTTONS_OK_CANCEL + : GTK_BUTTONS_OK; + } } } @@ -211,9 +221,16 @@ void wxMessageDialog::GTKCreateMsgDialog() const bool addButtons = buttons == GTK_BUTTONS_NONE; #endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON - if ( m_dialogStyle & wxYES_NO ) // Yes/No or Yes/No/Cancel dialog + + if ( addButtons ) { - if ( addButtons ) + if ( m_dialogStyle & wxHELP ) + { + gtk_dialog_add_button(dlg, wxGTK_CONV(GetHelpLabel()), + GTK_RESPONSE_HELP); + } + + if ( m_dialogStyle & wxYES_NO ) // Yes/No or Yes/No/Cancel dialog { // Add the buttons in the correct order which is, according to // http://library.gnome.org/devel/hig-book/stable/windows-alert.html.en @@ -233,32 +250,29 @@ void wxMessageDialog::GTKCreateMsgDialog() gtk_dialog_add_button(dlg, wxGTK_CONV(GetYesLabel()), GTK_RESPONSE_YES); } - - // it'd probably be harmless to call gtk_dialog_set_default_response() - // twice but why do it if we're going to change the default below - // anyhow - if ( !(m_dialogStyle & wxCANCEL_DEFAULT) ) + else // Ok or Ok/Cancel dialog { - gtk_dialog_set_default_response(dlg, - m_dialogStyle & wxNO_DEFAULT - ? GTK_RESPONSE_NO - : GTK_RESPONSE_YES); - } - } - else if ( addButtons ) // Ok or Ok/Cancel dialog - { - gtk_dialog_add_button(dlg, wxGTK_CONV(GetOKLabel()), GTK_RESPONSE_OK); - if ( m_dialogStyle & wxCANCEL ) - { - gtk_dialog_add_button(dlg, wxGTK_CONV(GetCancelLabel()), - GTK_RESPONSE_CANCEL); + gtk_dialog_add_button(dlg, wxGTK_CONV(GetOKLabel()), GTK_RESPONSE_OK); + if ( m_dialogStyle & wxCANCEL ) + { + gtk_dialog_add_button(dlg, wxGTK_CONV(GetCancelLabel()), + GTK_RESPONSE_CANCEL); + } } } + gint defaultButton; if ( m_dialogStyle & wxCANCEL_DEFAULT ) - { - gtk_dialog_set_default_response(dlg, GTK_RESPONSE_CANCEL); - } + defaultButton = GTK_RESPONSE_CANCEL; + else if ( m_dialogStyle & wxNO_DEFAULT ) + defaultButton = GTK_RESPONSE_NO; + else if ( m_dialogStyle & wxYES_NO ) + defaultButton = GTK_RESPONSE_YES; + else // No need to change the default value, whatever it is. + defaultButton = GTK_RESPONSE_NONE; + + if ( defaultButton != GTK_RESPONSE_NONE ) + gtk_dialog_set_default_response(dlg, defaultButton); } int wxMessageDialog::ShowModal() @@ -302,6 +316,8 @@ int wxMessageDialog::ShowModal() return wxID_YES; case GTK_RESPONSE_NO: return wxID_NO; + case GTK_RESPONSE_HELP: + return wxID_HELP; } } diff --git a/src/msw/msgdlg.cpp b/src/msw/msgdlg.cpp index 7c786e5141..b0118ae243 100644 --- a/src/msw/msgdlg.cpp +++ b/src/msw/msgdlg.cpp @@ -511,6 +511,11 @@ int wxMessageDialog::ShowMessageBox() } } + if ( wxStyle & wxHELP ) + { + msStyle |= MB_HELP; + } + // set the icon style switch ( GetEffectiveIcon() ) { @@ -630,7 +635,7 @@ void wxMessageDialog::DoCentre(int dir) #ifdef wxHAS_MSW_TASKDIALOG wxMSWTaskDialogConfig::wxMSWTaskDialogConfig(const wxMessageDialogBase& dlg) - : buttons(new TASKDIALOG_BUTTON[3]) + : buttons(new TASKDIALOG_BUTTON[MAX_BUTTONS]) { parent = dlg.GetParentForModalDialog(); caption = dlg.GetCaption(); @@ -665,6 +670,7 @@ wxMSWTaskDialogConfig::wxMSWTaskDialogConfig(const wxMessageDialogBase& dlg) btnNoLabel = dlg.GetNoLabel(); btnOKLabel = dlg.GetOKLabel(); btnCancelLabel = dlg.GetCancelLabel(); + btnHelpLabel = dlg.GetHelpLabel(); } void wxMSWTaskDialogConfig::MSWCommonTaskDialogInit(TASKDIALOGCONFIG &tdc) @@ -755,6 +761,15 @@ void wxMSWTaskDialogConfig::MSWCommonTaskDialogInit(TASKDIALOGCONFIG &tdc) AddTaskDialogButton(tdc, IDCANCEL, TDCBF_CANCEL_BUTTON, btnOKLabel); } } + + if ( style & wxHELP ) + { + // There is no support for "Help" button in the task dialog, it can + // only show "Retry" or "Close" ones. + useCustomLabels = true; + + AddTaskDialogButton(tdc, IDHELP, 0 /* not used */, btnHelpLabel); + } } void wxMSWTaskDialogConfig::AddTaskDialogButton(TASKDIALOGCONFIG &tdc, @@ -770,6 +785,10 @@ void wxMSWTaskDialogConfig::AddTaskDialogButton(TASKDIALOGCONFIG &tdc, tdBtn.nButtonID = btnCustomId; tdBtn.pszButtonText = customLabel.wx_str(); tdc.cButtons++; + + // We should never have more than 4 buttons currently as this is the + // maximal number of buttons supported by the message dialog. + wxASSERT_MSG( tdc.cButtons <= MAX_BUTTONS, wxT("Too many buttons") ); } else { @@ -839,6 +858,9 @@ int wxMSWMessageDialog::MSWTranslateReturnCode(int msAns) case IDNO: ans = wxID_NO; break; + case IDHELP: + ans = wxID_HELP; + break; } return ans; diff --git a/src/osx/cocoa/msgdlg.mm b/src/osx/cocoa/msgdlg.mm index ad44f55600..445a097caa 100644 --- a/src/osx/cocoa/msgdlg.mm +++ b/src/osx/cocoa/msgdlg.mm @@ -138,6 +138,8 @@ int wxMessageDialog::ShowModal() } } + wxASSERT_MSG( !(style & wxHELP), "wxHELP not supported in non-GUI thread" ); + CFOptionFlags exitButton; OSStatus err = CFUserNotificationDisplayAlert( 0, alertType, NULL, NULL, NULL, cfTitle, cfText, @@ -285,5 +287,15 @@ void* wxMessageDialog::ConstructNSAlert() } } + + if ( style & wxHELP ) + { + wxCFStringRef cfHelpString( GetHelpLabel(), GetFont().GetEncoding() ); + [alert addButtonWithTitle:cfHelpString.AsNSString()]; + m_buttonId[ m_buttonCount++ ] = wxID_HELP; + } + + wxASSERT_MSG( m_buttonCount <= WXSIZEOF(m_buttonId), "Too many buttons" ); + return alert; } From 59f495db65a7428e7397966e41cf7c0c7e5badb2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 5 Aug 2011 19:02:26 +0000 Subject: [PATCH 33/52] Implement wxFileType::GetOpenCommand() in wxOSX. This method used to work in 2.8 but was unimplemented in 2.9. Restore more or less the old implementation using the data that we already have in wxMimeTypesManager anyhow. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68563 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/osx/core/mimetype.h | 4 ++- src/osx/core/mimetype.cpp | 50 ++++++++++++++++++++++++++++++++-- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 7e7620bf75..92f145027f 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -456,6 +456,7 @@ All (GUI): OSX: - Implement wxRegion::Equal() (Dr.Acula). +- Implement wxFileType::GetOpenCommand(). - wxGetOsVersion() now returns more sensible version numbers, e.g. 10 and 6 for OS X 10.6. diff --git a/include/wx/osx/core/mimetype.h b/include/wx/osx/core/mimetype.h index 3fc642ee99..f0758e7df4 100644 --- a/include/wx/osx/core/mimetype.h +++ b/include/wx/osx/core/mimetype.h @@ -56,6 +56,7 @@ private: bool GetMimeTypes(const wxString& uti, wxArrayString& mimeTypes); bool GetIcon(const wxString& uti, wxIconLocation *iconLoc); bool GetDescription(const wxString& uti, wxString *desc); + bool GetApplication(const wxString& uti, wxString *command); // Structure to represent file types typedef struct FileTypeData @@ -63,6 +64,7 @@ private: wxArrayString extensions; wxArrayString mimeTypes; wxIconLocation iconLoc; + wxString application; wxString description; } FileTypeInfo; @@ -95,9 +97,9 @@ public: bool GetMimeTypes(wxArrayString& mimeTypes) const ; bool GetIcon(wxIconLocation *iconLoc) const ; bool GetDescription(wxString *desc) const ; + bool GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const; // These functions are only stubs on Mac OS X - bool GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const; bool GetPrintCommand(wxString *printCmd, const wxFileType::MessageParameters& params) const; size_t GetAllCommands(wxArrayString *verbs, wxArrayString *commands, const wxFileType::MessageParameters& params) const; bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = TRUE); diff --git a/src/osx/core/mimetype.cpp b/src/osx/core/mimetype.cpp index c2661e22b0..4910f30ad4 100644 --- a/src/osx/core/mimetype.cpp +++ b/src/osx/core/mimetype.cpp @@ -447,7 +447,11 @@ void wxMimeTypesManagerImpl::LoadDisplayDataForUti(const wxString& uti) if( !bundle ) return; - // Get a all the document type data in this bundle + // Also get the open command while we have the bundle + wxCFStringRef cfsAppPath(CFURLCopyFileSystemPath(appUrl, kCFURLPOSIXPathStyle)); + m_utiMap[ uti ].application = cfsAppPath.AsString(); + + // Get all the document type data in this bundle CFTypeRef docTypeData; docTypeData = CFBundleGetValueForInfoDictionaryKey( bundle, docTypesKey ); @@ -587,6 +591,19 @@ bool wxMimeTypesManagerImpl::GetDescription(const wxString& uti, wxString *desc) return true; } +bool wxMimeTypesManagerImpl::GetApplication(const wxString& uti, wxString *command) +{ + const UtiMap::const_iterator itr = m_utiMap.find( uti ); + + if( itr == m_utiMap.end() ) + { + command->clear(); + return false; + } + + *command = itr->second.application; + return true; +} ///////////////////////////////////////////////////////////////////////////// // The remaining functionality has not yet been implemented for OS X @@ -626,9 +643,36 @@ bool wxFileTypeImpl::GetDescription(wxString *desc) const return m_manager->GetDescription( m_uti, desc ); } -bool wxFileTypeImpl::GetOpenCommand(wxString *WXUNUSED(openCmd), const wxFileType::MessageParameters& WXUNUSED(params)) const +namespace { - return false; + +// Helper function for GetOpenCommand(): returns the string surrounded by +// (singly) quotes if it contains spaces. +wxString QuoteIfNecessary(const wxString& path) +{ + wxString result(path); + + if ( path.find(' ') != wxString::npos ) + { + result.insert(0, "'"); + result.append("'"); + } + + return result; +} + +} // anonymous namespace + +bool wxFileTypeImpl::GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const +{ + wxString application; + if ( !m_manager->GetApplication(m_uti, &application) ) + return false; + + *openCmd << QuoteIfNecessary(application) + << ' ' << QuoteIfNecessary(params.GetFileName()); + + return true; } bool wxFileTypeImpl::GetPrintCommand(wxString *WXUNUSED(printCmd), const wxFileType::MessageParameters& WXUNUSED(params)) const From 43d2d359ceafb66e30b7dd2684f79fe59d035f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 7 Aug 2011 17:29:41 +0000 Subject: [PATCH 34/52] Remove unused ItemList type from datavgen.cpp. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68580 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/datavgen.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index bdc389ad66..47d584dae3 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -416,8 +416,6 @@ int LINKAGEMODE wxGenericTreeModelItemCmp( void ** id1, void ** id2) WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SIZE_T(unsigned int, wxDataViewSelection, WXDLLIMPEXP_ADV); -WX_DECLARE_LIST(wxDataViewItem, ItemList); -WX_DEFINE_LIST(ItemList) class wxDataViewMainWindow: public wxWindow { From c3b0247de1ecad3188bf95cd6dca8a923b52a9d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 7 Aug 2011 17:29:44 +0000 Subject: [PATCH 35/52] wxDataViewSelection private type doesn't need to be exported. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68581 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/datavgen.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 47d584dae3..94268b33f5 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -414,8 +414,7 @@ int LINKAGEMODE wxGenericTreeModelItemCmp( void ** id1, void ** id2) // wxDataViewMainWindow //----------------------------------------------------------------------------- -WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SIZE_T(unsigned int, wxDataViewSelection, - WXDLLIMPEXP_ADV); +WX_DEFINE_SORTED_ARRAY_SIZE_T(unsigned int, wxDataViewSelection); class wxDataViewMainWindow: public wxWindow { From b625294905d48a52d1a3153fdc676561f239dee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 7 Aug 2011 17:29:47 +0000 Subject: [PATCH 36/52] Clean up wxDataViewMainWindow::ItemDeleted() a bit. Reuse shared code instead of duplicating it. No real changes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68582 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/datavgen.cpp | 87 +++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 46 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 94268b33f5..a355dd1527 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -2006,66 +2006,61 @@ bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent, (wxDataViewVirtualListModel*) GetOwner()->GetModel(); m_count = list_model->GetCount(); - if( m_currentRow > GetRowCount() ) - m_currentRow = m_count - 1; - // TODO: why empty the entire selection? m_selection.Empty(); - - UpdateDisplay(); - - return true; } - - wxDataViewTreeNode * node = FindNode(parent); - - // Notice that it is possible that the item being deleted is not in the - // tree at all, for example we could be deleting a never shown (because - // collapsed) item in a tree model. So it's not an error if we don't know - // about this item, just return without doing anything then. - if ( !node || node->GetChildren().Index(item.GetID()) == wxNOT_FOUND ) - return false; - - int sub = -1; - node->GetChildren().Remove( item.GetID() ); - // Manipolate selection - if( m_selection.GetCount() > 1 ) + else // general case { - m_selection.Empty(); - } - bool isContainer = false; - wxDataViewTreeNodes nds = node->GetNodes(); - for (size_t i = 0; i < nds.GetCount(); i ++) - { - if (nds[i]->GetItem() == item) + wxDataViewTreeNode * node = FindNode(parent); + + // Notice that it is possible that the item being deleted is not in the + // tree at all, for example we could be deleting a never shown (because + // collapsed) item in a tree model. So it's not an error if we don't know + // about this item, just return without doing anything then. + if ( !node || node->GetChildren().Index(item.GetID()) == wxNOT_FOUND ) + return false; + + int sub = -1; + node->GetChildren().Remove( item.GetID() ); + // Manipolate selection + if( m_selection.GetCount() > 1 ) { - isContainer = true; - break; + m_selection.Empty(); } - } - if( isContainer ) - { - wxDataViewTreeNode * n = NULL; - wxDataViewTreeNodes nodes = node->GetNodes(); - int len = nodes.GetCount(); - for( int i = 0; i < len; i ++) + bool isContainer = false; + wxDataViewTreeNodes nds = node->GetNodes(); + for (size_t i = 0; i < nds.GetCount(); i ++) { - if( nodes[i]->GetItem() == item ) + if (nds[i]->GetItem() == item) { - n = nodes[i]; + isContainer = true; break; } } + if( isContainer ) + { + wxDataViewTreeNode * n = NULL; + wxDataViewTreeNodes nodes = node->GetNodes(); + int len = nodes.GetCount(); + for( int i = 0; i < len; i ++) + { + if( nodes[i]->GetItem() == item ) + { + n = nodes[i]; + break; + } + } - wxCHECK_MSG( n != NULL, false, "item not found" ); + wxCHECK_MSG( n != NULL, false, "item not found" ); - node->GetNodes().Remove( n ); - sub -= n->GetSubTreeCount(); - ::DestroyTreeHelper(n); + node->GetNodes().Remove( n ); + sub -= n->GetSubTreeCount(); + ::DestroyTreeHelper(n); + } + // Make the row number invalid and get a new valid one when user call GetRowCount + m_count = -1; + node->ChangeSubTreeCount(sub); } - // Make the row number invalid and get a new valid one when user call GetRowCount - m_count = -1; - node->ChangeSubTreeCount(sub); // Change the current row to the last row if the current exceed the max row number if( m_currentRow > GetRowCount() ) From 8c7b8711566dd58878106b78f31f5b9e331432a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 7 Aug 2011 17:29:50 +0000 Subject: [PATCH 37/52] Use ChangeCurrentRow() in wxDataViewMainWindow::ItemDeleted(). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68583 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/datavgen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index a355dd1527..34ae5bc84e 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -2064,7 +2064,7 @@ bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent, // Change the current row to the last row if the current exceed the max row number if( m_currentRow > GetRowCount() ) - m_currentRow = m_count - 1; + ChangeCurrentRow(m_count - 1); UpdateDisplay(); From 5d0152c2b9c04a2822c9f3acf65819b02c43909e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 7 Aug 2011 19:31:52 +0000 Subject: [PATCH 38/52] Use 0 instead of NULL to avoid g++ warning. g++ (usefully) warns when assigning NULL to a non-pointer in wxGDIPlusRenderer. Just use 0 instead of NULL to avoid the warning. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68586 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index c1c7df147c..0bc8226142 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -1906,7 +1906,7 @@ void wxGDIPlusRenderer::Unload() if ( m_gditoken ) { GdiplusShutdown(m_gditoken); - m_gditoken = NULL; + m_gditoken = 0; } m_loaded = -1; // next Load() will try again } From 8a625e0bb9e7db0eb7e685f15680a6f5997ddcd1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 8 Aug 2011 08:33:19 +0000 Subject: [PATCH 39/52] Fix compilation with g++ 4.7 (prerelease). The workaround for a bug in g++ 3.5 breaks compilation with 4.7 which implements two-phase lookup correctly, so disable this workaround for 4.7 and later. We could probably even only enable it for 3.x but this doesn't really matter as previous 4.x releases don't have problems with this anyhow. Closes #13385. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68594 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/wxcrt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/wx/wxcrt.h b/include/wx/wxcrt.h index 2c5dd24b50..2dc22cd2a2 100644 --- a/include/wx/wxcrt.h +++ b/include/wx/wxcrt.h @@ -467,7 +467,7 @@ WX_STRCMP_FUNC(wxStricmp, wxCRT_StricmpA, wxCRT_StricmpW, wxStricmp_String) // forward-declare the template and implement it below WX_STRCMP_FUNC. OTOH, // this fails to compile with VC6, so don't do it for VC. It also causes // problems with GCC visibility in newer GCC versions. -#if !(defined(__VISUALC__) || wxCHECK_GCC_VERSION(3,5)) || defined(__clang__) +#if !(defined(__VISUALC__) || (wxCHECK_GCC_VERSION(3,5) && !wxCHECK_GCC_VERSION(4,7))) || defined(__clang__) #define wxNEEDS_DECL_BEFORE_TEMPLATE #endif From 960493053b4923a9c882fb54c195ea530de72da1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 8 Aug 2011 09:32:39 +0000 Subject: [PATCH 40/52] Added private wxMenu::MSWNewFromHMENU() method. Add a method allowing creation of a wxMenu object from a native menu handle. This will be used to implement access to the system menu in an upcoming commit but could also be useful for other purposes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68595 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/menu.h | 17 ++++++++++++++++- src/msw/menu.cpp | 25 ++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/include/wx/msw/menu.h b/include/wx/msw/menu.h index 4c5e95f5ad..3ea8404309 100644 --- a/include/wx/msw/menu.h +++ b/include/wx/msw/menu.h @@ -61,6 +61,14 @@ public: virtual void SetTitle(const wxString& title); + // MSW-only methods + // ---------------- + + // Create a new menu from the given native HMENU. Takes ownership of the + // menu handle and will delete it when this object is destroyed. + static wxMenu *MSWNewFromHMENU(WXHMENU hMenu) { return new wxMenu(hMenu); } + + // implementation only from now on // ------------------------------- @@ -120,7 +128,14 @@ protected: virtual wxMenuItem* DoRemove(wxMenuItem *item); private: - // common part of all ctors + // This constructor is private, use MSWNewFromHMENU() to use it. + wxMenu(WXHMENU hMenu); + + // Common part of all ctors, it doesn't create a new HMENU. + void InitNoCreate(); + + // Common part of all ctors except of the one above taking a native menu + // handler: calls InitNoCreate() and also creates a new menu. void Init(); // common part of Append/Insert (behaves as Append is pos == (size_t)-1) diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index c1accd90e2..fe8b4a51dd 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -260,7 +260,7 @@ inline bool IsGreaterThanStdSize(const wxBitmap& bmp) // --------------------------------------------------------------------------- // Construct a menu with optional title (then use append) -void wxMenu::Init() +void wxMenu::InitNoCreate() { m_radioData = NULL; m_doBreak = false; @@ -270,6 +270,11 @@ void wxMenu::Init() m_maxBitmapWidth = 0; m_maxAccelWidth = -1; #endif // wxUSE_OWNER_DRAWN +} + +void wxMenu::Init() +{ + InitNoCreate(); // create the menu m_hMenu = (WXHMENU)CreatePopupMenu(); @@ -287,6 +292,24 @@ void wxMenu::Init() } } +wxMenu::wxMenu(WXHMENU hMenu) +{ + InitNoCreate(); + + m_hMenu = hMenu; + + // Ensure that our internal idea of how many items we have corresponds to + // the real number of items in the menu. + // + // We could also retrieve the real labels of the items here but it doesn't + // seem to be worth the trouble. + const int numExistingItems = ::GetMenuItemCount(m_hMenu); + for ( int n = 0; n < numExistingItems; n++ ) + { + wxMenuBase::DoAppend(wxMenuItem::New(this, wxID_SEPARATOR)); + } +} + // The wxWindow destructor will take care of deleting the submenus. wxMenu::~wxMenu() { From ddae52629c7114da46bc6ac53874593d8eb965bd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 8 Aug 2011 09:32:42 +0000 Subject: [PATCH 41/52] Added wxTopLevelWindow::MSWGetSystemMenu() method. Also generate events corresponding to WM_SYSCOMMAND messages for the custom items of the system menu. Add a small snippet to test the new functionality to the dialogs sample. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68596 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/msw/toplevel.h | 17 ++++++++++ interface/wx/toplevel.h | 27 +++++++++++++++ samples/dialogs/dialogs.cpp | 18 ++++++++++ src/msw/toplevel.cpp | 65 +++++++++++++++++++++++++++++++++++-- 5 files changed, 126 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 92f145027f..d467990b48 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -467,6 +467,7 @@ GTK: MSW: - Added wxGCDC(wxEnhMetaFileDC) ctor (Marcin Wojdyr). +- Added wxTopLevelWindow::MSWGetSystemMenu(). 2.9.2: (released 2011-07-05) diff --git a/include/wx/msw/toplevel.h b/include/wx/msw/toplevel.h index 52905cc32a..39756b355b 100644 --- a/include/wx/msw/toplevel.h +++ b/include/wx/msw/toplevel.h @@ -77,6 +77,19 @@ public: virtual bool CanSetTransparent(); + // MSW-specific methods + // -------------------- + + // Return the menu representing the "system" menu of the window. You can + // call wxMenu::AppendWhatever() methods on it but removing items from it + // is in general not a good idea. + // + // The pointer returned by this method belongs to the window and will be + // deleted when the window itself is, do not delete it yourself. May return + // NULL if getting the system menu failed. + wxMenu *MSWGetSystemMenu() const; + + // implementation from now on // -------------------------- @@ -214,6 +227,10 @@ private: void* m_activateInfo; #endif + // The system menu: initially NULL but can be set (once) by + // MSWGetSystemMenu(). Owned by this window. + wxMenu *m_menuSystem; + DECLARE_EVENT_TABLE() wxDECLARE_NO_COPY_CLASS(wxTopLevelWindowMSW); }; diff --git a/interface/wx/toplevel.h b/interface/wx/toplevel.h index 55be716a7d..32e09f7e6f 100644 --- a/interface/wx/toplevel.h +++ b/interface/wx/toplevel.h @@ -262,6 +262,33 @@ public: */ virtual void Maximize(bool maximize = true); + /** + MSW-specific function for accessing the system menu. + + Returns a wxMenu pointer representing the system menu of the window + under MSW. The returned wxMenu may be used, if non-@c NULL, to add + extra items to the system menu. The usual @c wxEVT_COMMAND_MENU_SELECTED + events (that can be processed using @c EVT_MENU event table macro) will + then be generated for them. All the other wxMenu methods may be used as + well but notice that they won't allow you to access any standard system + menu items (e.g. they can't be deleted or modified in any way + currently). + + Notice that because of the native system limitations the identifiers of + the items added to the system menu must be multiples of 16, otherwise + no events will be generated for them. + + The returned pointer must @em not be deleted, it is owned by the window + and will be only deleted when the window itself is destroyed. + + This function is not available in the other ports by design, any + occurrences of it in the portable code must be guarded by @code #ifdef + __WXMSW__ @endcode preprocessor guards. + + @since 2.9.3 + */ + wxMenu *MSWGetSystemMenu() const; + /** Use a system-dependent way to attract users attention to the window when it is in background. diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 14f1a80318..eeeecdac1f 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -648,6 +648,24 @@ MyFrame::MyFrame(const wxString& title) // covers our entire client area to avoid jarring colour jumps SetOwnBackgroundColour(m_canvas->GetBackgroundColour()); #endif // wxUSE_INFOBAR + +#ifdef __WXMSW__ + // Test MSW-specific function allowing to access the "system" menu. + wxMenu * const menu = MSWGetSystemMenu(); + if ( menu ) + { + menu->AppendSeparator(); + + // The ids of the menu commands in MSW system menu must be multiple of + // 16 so we can't use DIALOGS_ABOUTDLG_SIMPLE here because it might not + // satisfy this condition and need to define and connect a separate id. + static const int DIALOGS_SYSTEM_ABOUT = 0x4010; + + menu->Append(DIALOGS_SYSTEM_ABOUT, "&About..."); + Connect(DIALOGS_SYSTEM_ABOUT, wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(MyFrame::ShowSimpleAboutDialog)); + } +#endif // __WXMSW__ } MyFrame::~MyFrame() diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 45ef33843b..856e761b39 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -141,6 +141,8 @@ void wxTopLevelWindowMSW::Init() m_activateInfo = (void*) info; #endif + + m_menuSystem = NULL; } WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const @@ -326,9 +328,9 @@ WXLRESULT wxTopLevelWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WX WXLRESULT rc = 0; bool processed = false; -#if defined(__SMARTPHONE__) || defined(__POCKETPC__) switch ( message ) { +#if defined(__SMARTPHONE__) || defined(__POCKETPC__) case WM_ACTIVATE: { SHACTIVATEINFO* info = (SHACTIVATEINFO*) m_activateInfo; @@ -355,8 +357,32 @@ WXLRESULT wxTopLevelWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WX } break; } +#endif // __SMARTPHONE__ || __POCKETPC__ + + case WM_SYSCOMMAND: + // We may need to generate events for the items added to the system + // menu if it had been created (and presumably modified). + if ( m_menuSystem ) + { + // From MSDN: + // + // ... the four low-order bits of the wParam parameter are + // used internally by the system. To obtain the correct + // result when testing the value of wParam, an application + // must combine the value 0xFFF0 with the wParam value by + // using the bitwise AND operator. + unsigned id = wParam & 0xfff0; + + // SC_SIZE is the first of the system-defined commands and we + // leave those to DefWindowProc(). + if ( id < SC_SIZE ) + { + if ( m_menuSystem->MSWCommand(0 /* unused anyhow */, id) ) + processed = true; + } + } + break; } -#endif if ( !processed ) rc = wxTopLevelWindowBase::MSWWindowProc(message, wParam, lParam); @@ -578,6 +604,8 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent, wxTopLevelWindowMSW::~wxTopLevelWindowMSW() { + delete m_menuSystem; + SendDestroyEvent(); #if defined(__SMARTPHONE__) || defined(__POCKETPC__) @@ -1226,6 +1254,39 @@ void wxTopLevelWindowMSW::RequestUserAttention(int flags) } } +wxMenu *wxTopLevelWindowMSW::MSWGetSystemMenu() const +{ + if ( !m_menuSystem ) + { + HMENU hmenu = ::GetSystemMenu(GetHwnd(), FALSE); + if ( !hmenu ) + { + wxLogLastError(wxT("GetSystemMenu()")); + return NULL; + } + + wxTopLevelWindowMSW * const + self = const_cast(this); + + self->m_menuSystem = wxMenu::MSWNewFromHMENU(hmenu); + + // We need to somehow associate this menu with this window to ensure + // that we get events from it. A natural idea would be to pretend that + // it's attached to our menu bar but this wouldn't work if we don't + // have any menu bar which is a common case for applications using + // custom items in the system menu (they mostly do it exactly because + // they don't have any other menus). + // + // So reuse the invoking window pointer instead, this is not exactly + // correct but doesn't seem to have any serious drawbacks. + m_menuSystem->SetInvokingWindow(self); + } + + return m_menuSystem; +} + +// ---------------------------------------------------------------------------- +// Transparency support // --------------------------------------------------------------------------- bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha) From 04675edfb19c0895d4a719431f79e11ef62ffb1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 8 Aug 2011 10:11:04 +0000 Subject: [PATCH 42/52] Remove selection methods taking int from generic wxDataViewCtrl. Current public API uses wxDataViewItem, this code dated back to 2.8. They were now protected instead of public, the code wasn't used anywhere and wasn't portable, it existed only in the generic version. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68597 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/dataview.h | 8 ----- src/generic/datavgen.cpp | 67 ----------------------------------- 2 files changed, 75 deletions(-) diff --git a/include/wx/generic/dataview.h b/include/wx/generic/dataview.h index f56f2a5ffc..6e728635de 100644 --- a/include/wx/generic/dataview.h +++ b/include/wx/generic/dataview.h @@ -190,14 +190,6 @@ public: virtual void StartEditor( const wxDataViewItem & item, unsigned int column ); protected: - virtual int GetSelections( wxArrayInt & sel ) const; - virtual void SetSelections( const wxArrayInt & sel ); - virtual void Select( int row ); - virtual void Unselect( int row ); - virtual bool IsSelected( int row ) const; - virtual void SelectRange( int from, int to ); - virtual void UnselectRange( int from, int to ); - virtual void EnsureVisible( int row, int column ); virtual wxDataViewItem GetItemByRow( unsigned int row ) const; diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 34ae5bc84e..76c7344fea 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -4498,73 +4498,6 @@ bool wxDataViewCtrl::IsSelected( const wxDataViewItem & item ) const return false; } -// Selection code with row number as parameter -int wxDataViewCtrl::GetSelections( wxArrayInt & sel ) const -{ - sel.Empty(); - wxDataViewSelection selection = m_clientArea->GetSelections(); - int len = selection.GetCount(); - for( int i = 0; i < len; i ++) - { - unsigned int row = selection[i]; - sel.Add( row ); - } - return len; -} - -void wxDataViewCtrl::SetSelections( const wxArrayInt & sel ) -{ - wxDataViewSelection selection(wxDataViewSelectionCmp); - int len = sel.GetCount(); - for( int i = 0; i < len; i ++ ) - { - int row = sel[i]; - if( row >= 0 ) - selection.Add( static_cast(row) ); - } - m_clientArea->SetSelections( selection ); -} - -void wxDataViewCtrl::Select( int row ) -{ - if( row >= 0 ) - { - if (m_clientArea->IsSingleSel()) - m_clientArea->SelectAllRows(false); - m_clientArea->SelectRow( row, true ); - } -} - -void wxDataViewCtrl::Unselect( int row ) -{ - if( row >= 0 ) - m_clientArea->SelectRow(row, false); -} - -bool wxDataViewCtrl::IsSelected( int row ) const -{ - if( row >= 0 ) - return m_clientArea->IsRowSelected(row); - return false; -} - -void wxDataViewCtrl::SelectRange( int from, int to ) -{ - wxArrayInt sel; - for( int i = from; i < to; i ++ ) - sel.Add( i ); - m_clientArea->Select(sel); -} - -void wxDataViewCtrl::UnselectRange( int from, int to ) -{ - wxDataViewSelection sel = m_clientArea->GetSelections(); - for( int i = from; i < to; i ++ ) - if( sel.Index( i ) != wxNOT_FOUND ) - sel.Remove( i ); - m_clientArea->SetSelections(sel); -} - void wxDataViewCtrl::SelectAll() { m_clientArea->SelectAllRows(true); From 373a4816d447cbf6da448e139cd577599c866e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 8 Aug 2011 10:23:19 +0000 Subject: [PATCH 43/52] Check for invalid items in generic wxDataViewCtrl::GetSelections(). This shouldn't normally happen, but if some bug causes it, detect it. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68598 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/datavgen.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 76c7344fea..4573c9bb78 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -4428,13 +4428,23 @@ int wxDataViewCtrl::GetSelections( wxDataViewItemArray & sel ) const { sel.Empty(); wxDataViewSelection selection = m_clientArea->GetSelections(); - int len = selection.GetCount(); - for( int i = 0; i < len; i ++) + + for ( wxDataViewSelection::const_iterator i = selection.begin(); + i != selection.end(); + ++i ) { - unsigned int row = selection[i]; - sel.Add( m_clientArea->GetItemByRow( row ) ); + wxDataViewItem item = m_clientArea->GetItemByRow(*i); + if ( item.IsOk() ) + { + sel.Add(item); + } + else + { + wxFAIL_MSG( "invalid item in selection - bad internal state" ); + } } - return len; + + return sel.size(); } void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel ) From 5d8d4b669a311a8b0c64939e82fc4d5bb6c36796 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 8 Aug 2011 15:15:50 +0000 Subject: [PATCH 44/52] Don't manually centre dialogs created with default position in wxMSW. We always centered the dialogs on the main display which was wrong if the parent window was on another one. Instead of fixing it, simply don't centre them at all and let Windows position them, there is no reason to change the default behaviour. Closes #13387. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68606 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/toplevel.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 856e761b39..495b865e52 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -439,25 +439,26 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate, } #endif // !__WXWINCE__ +#if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__) // move the dialog to its initial position without forcing repainting int x, y, w, h; (void)MSWGetCreateWindowCoords(pos, size, x, y, w, h); if ( x == (int)CW_USEDEFAULT ) { - // centre it on the screen - what else can we do? - wxSize sizeDpy = wxGetDisplaySize(); - - x = (sizeDpy.x - w) / 2; - y = (sizeDpy.y - h) / 2; + // Let the system position the window, just set its size. + ::SetWindowPos(GetHwnd(), 0, + 0, 0, w, h, + SWP_NOMOVE | SWP_NOZORDER); } - -#if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__) - if ( !::MoveWindow(GetHwnd(), x, y, w, h, FALSE) ) + else // Move the window to the desired location and set its size too. { - wxLogLastError(wxT("MoveWindow")); + if ( !::MoveWindow(GetHwnd(), x, y, w, h, FALSE) ) + { + wxLogLastError(wxT("MoveWindow")); + } } -#endif +#endif // !__WXWINCE__ if ( !title.empty() ) { From b86ac1efaa8861448e554b38796aeab7df669080 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 9 Aug 2011 11:25:09 +0000 Subject: [PATCH 45/52] No changes, just correct the helpview sample name in comment. "printing.cpp" was used for whatever reason. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68612 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/html/helpview/helpview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/html/helpview/helpview.cpp b/samples/html/helpview/helpview.cpp index f0fba2d056..6f62d33763 100644 --- a/samples/html/helpview/helpview.cpp +++ b/samples/html/helpview/helpview.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: printing.cpp +// Name: helpview.cpp // Purpose: wxHtml sample: help browser // Author: ? // Modified by: From eceb6af1586b7ec760bcbc1aca01ca59e4cd1711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 9 Aug 2011 11:35:32 +0000 Subject: [PATCH 46/52] Don't use iterators with wxDataViewSelection. They aren't implemented when using wx's homegrown sorted containers and adding support is probably more trouble than it's worth. Fixes #13388. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68613 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/datavgen.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 4573c9bb78..167c1149b8 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -4429,11 +4429,10 @@ int wxDataViewCtrl::GetSelections( wxDataViewItemArray & sel ) const sel.Empty(); wxDataViewSelection selection = m_clientArea->GetSelections(); - for ( wxDataViewSelection::const_iterator i = selection.begin(); - i != selection.end(); - ++i ) + const size_t len = selection.size(); + for ( size_t i = 0; i < len; i++ ) { - wxDataViewItem item = m_clientArea->GetItemByRow(*i); + wxDataViewItem item = m_clientArea->GetItemByRow(selection[i]); if ( item.IsOk() ) { sel.Add(item); From af9c02ce209c78a17bedf18ba8a4f955e70a8fd2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 9 Aug 2011 15:46:28 +0000 Subject: [PATCH 47/52] Don't reset wxTLW::m_iconized when hiding the window in wxMSW. Calling Hide() on an iconized window wrongly reset its m_iconized flag but hiding the window shouldn't affect it. Closes #13373. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68614 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/toplevel.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 495b865e52..9e068789c8 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -637,7 +637,13 @@ void wxTopLevelWindowMSW::DoShowWindow(int nShowCmd) { ::ShowWindow(GetHwnd(), nShowCmd); - m_iconized = nShowCmd == SW_MINIMIZE; + // Hiding the window doesn't change its iconized state. + if ( nShowCmd != SW_HIDE ) + { + // Otherwise restoring, maximizing or showing the window normally also + // makes it not iconized and only minimizing it does make it iconized. + m_iconized = nShowCmd == SW_MINIMIZE; + } } void wxTopLevelWindowMSW::ShowWithoutActivating() From ee7553e935502f77f7aed93221a449b982dee40d Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Tue, 9 Aug 2011 22:17:12 +0000 Subject: [PATCH 48/52] Added NSApplicationDelegate's openFiles for wxOSX-Cocoa. openFiles (available since OS X 10.3) replaces using the openFile method. It allows for more convenient handling of multiple drops and knowing in advance how much files/folders are dropped instead of openFile with which you only get to respond to a single file/folder drop at a time. By default openFiles calls the newly added MacOpenFiles which calls MacOpenFile multiple times, so ordinarily the behaviour is backwards compatible (both on wxOSX Cocoa and Carbon). The openFile instance method has been removed because it doesn't seem to be called anymore: neither when dropping a single file on the application in the dock or Finder nor when passed as a command-line argument. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68617 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/osx/app.h | 5 ++++- interface/wx/app.h | 29 ++++++++++++++++++++++++----- samples/mediaplayer/mediaplayer.cpp | 8 ++++---- src/osx/carbon/app.cpp | 17 +++++++++++++++-- src/osx/cocoa/utils.mm | 14 ++++++++++---- utils/helpview/src/helpview.cpp | 4 ++-- utils/helpview/src/helpview.h | 2 +- 8 files changed, 61 insertions(+), 19 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index d467990b48..51b18681d4 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -459,6 +459,7 @@ OSX: - Implement wxFileType::GetOpenCommand(). - wxGetOsVersion() now returns more sensible version numbers, e.g. 10 and 6 for OS X 10.6. +- Added wxApp::MacOpenFiles and deprecated wxApp::MacOpenFile. GTK: diff --git a/include/wx/osx/app.h b/include/wx/osx/app.h index 47315c6b62..011d0dd021 100644 --- a/include/wx/osx/app.h +++ b/include/wx/osx/app.h @@ -122,7 +122,10 @@ public: virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ; virtual short MacHandleAERApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ; #endif - // in response of an open-document apple event + // in response of an openFiles message with Cocoa and an + // open-document apple event with Carbon + virtual void MacOpenFiles(const wxArrayString &fileNames) ; + // called by MacOpenFiles for each file. virtual void MacOpenFile(const wxString &fileName) ; // in response of a get-url apple event virtual void MacOpenURL(const wxString &url) ; diff --git a/interface/wx/app.h b/interface/wx/app.h index f3530be291..d5badd57d1 100644 --- a/interface/wx/app.h +++ b/interface/wx/app.h @@ -569,7 +569,7 @@ public: Under Windows and Linux/Unix, you should parse the command line arguments and check for files to be opened when starting your - application. Under OS X, you need to override MacOpenFile() + application. Under OS X, you need to override MacOpenFiles() since command line arguments are used differently there. You may use the wxCmdLineParser to parse command line arguments. @@ -802,16 +802,35 @@ public: */ virtual void MacNewFile(); + /** + Called in response of an openFiles message with Cocoa, or an + "open-document" Apple event with Carbon. + + You need to override this method in order to open one or more document + files after the user double clicked on it or if the files and/or + folders were dropped on either the application in the dock or the + application icon in Finder. + + By default this method calls MacOpenFile for each file/folder. + + @onlyfor{wxosx} + + @since 2.9.3 + */ + virtual void MacOpenFiles(const wxArrayString& fileNames); + /** Called in response of an "open-document" Apple event. - You need to override this method in order to open a document file after the - user double clicked on it or if the document file was dropped on either the - running application or the application icon in Finder. + @deprecated + This function is kept mostly for backwards compatibility. Please + override wxApp::MacOpenFiles method instead in any new code. @onlyfor{wxosx} */ - virtual void MacOpenFile(const wxString& fileName); + wxDEPRECATED_BUT_USED_INTERNALLY( + virtual void MacOpenFile(const wxString& fileName) + ); /** Called in response of a "get-url" Apple event. diff --git a/samples/mediaplayer/mediaplayer.cpp b/samples/mediaplayer/mediaplayer.cpp index 1ca1da55f6..1d1698363e 100644 --- a/samples/mediaplayer/mediaplayer.cpp +++ b/samples/mediaplayer/mediaplayer.cpp @@ -143,7 +143,7 @@ class wxMediaPlayerApp : public wxApp { public: #ifdef __WXMAC__ - virtual void MacOpenFile(const wxString & fileName ); + virtual void MacOpenFiles(const wxArrayString & fileNames ); #endif virtual bool OnInit(); @@ -463,10 +463,10 @@ bool wxMediaPlayerApp::OnInit() #ifdef __WXMAC__ -void wxMediaPlayerApp::MacOpenFile(const wxString & fileName ) +void wxMediaPlayerApp::MacOpenFiles(const wxArrayString & fileNames ) { - // Called when a user drags a file over our app - m_frame->DoOpenFile(fileName, true /* new page */); + // Called when a user drags files over our app + m_frame->DoOpenFile(fileNames[0], true /* new page */); } #endif // __WXMAC__ diff --git a/src/osx/carbon/app.cpp b/src/osx/carbon/app.cpp index cf1e53b104..722f9cc2f8 100644 --- a/src/osx/carbon/app.cpp +++ b/src/osx/carbon/app.cpp @@ -130,7 +130,7 @@ pascal OSErr AEHandleGURL( const AppleEvent *event , AppleEvent *reply , SRefCon } -// AEODoc Calls MacOpenFile on each of the files passed +// AEODoc Calls MacOpenFiles with all of the files passed short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply)) { @@ -158,6 +158,7 @@ short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply)) wxString fName ; FSRef theRef ; + wxArrayString fileNames; for (i = 1; i <= itemsInList; i++) { AEGetNthPtr( @@ -165,9 +166,11 @@ short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply)) (Ptr)&theRef, sizeof(theRef), &actualSize); fName = wxMacFSRefToPath( &theRef ) ; - MacOpenFile(fName); + fileNames.Add(fName); } + MacOpenFiles(fileNames); + return noErr; } @@ -274,6 +277,16 @@ short wxApp::MacHandleAERApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNU // Support Routines linking the Mac...File Calls to the Document Manager //---------------------------------------------------------------------- +void wxApp::MacOpenFiles(const wxArrayString & fileNames ) +{ + size_t i; + const size_t fileCount = fileNames.GetCount(); + for (i = 0; i < fileCount; i++) + { + MacOpenFile(fileNames[i]); + } +} + void wxApp::MacOpenFile(const wxString & fileName ) { #if wxUSE_DOC_VIEW_ARCHITECTURE diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm index c7879d0e6b..cb71db77a3 100644 --- a/src/osx/cocoa/utils.mm +++ b/src/osx/cocoa/utils.mm @@ -55,12 +55,18 @@ void wxBell() wxUnusedVar(application); } -- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename +- (void)application:(NSApplication *)sender openFiles:(NSArray *)fileNames { wxUnusedVar(sender); - wxCFStringRef cf(wxCFRetain(filename)); - wxTheApp->MacOpenFile(cf.AsString()) ; - return YES; + wxArrayString fileList; + size_t i; + const size_t count = [fileNames count]; + for (i = 0; i < count; i++) + { + fileList.Add( wxCFStringRef::AsString([fileNames objectAtIndex:i]) ); + } + + wxTheApp->MacOpenFiles(fileList); } - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender diff --git a/utils/helpview/src/helpview.cpp b/utils/helpview/src/helpview.cpp index c774b628fa..ecd2a732f0 100644 --- a/utils/helpview/src/helpview.cpp +++ b/utils/helpview/src/helpview.cpp @@ -279,10 +279,10 @@ bool hvApp::OpenBook(wxHtmlHelpController* controller) #ifdef __WXMAC__ /// Respond to Apple Event for opening a document -void hvApp::MacOpenFile(const wxString& filename) +void hvApp::MacOpenFiles(const wxArrayString& fileNames) { wxBusyCursor bcur; - wxFileName fileName(filename); + wxFileName fileName(fileNames[0]); m_helpController->AddBook(fileName); m_helpController->DisplayContents(); } diff --git a/utils/helpview/src/helpview.h b/utils/helpview/src/helpview.h index 2d020e78cb..7b30b795f5 100644 --- a/utils/helpview/src/helpview.h +++ b/utils/helpview/src/helpview.h @@ -36,7 +36,7 @@ public: #ifdef __WXMAC__ /// Respond to Apple Event for opening a document - virtual void MacOpenFile(const wxString& filename); + virtual void MacOpenFiles(const wxArrayString& fileNames); #endif /// Prompt the user for a book to open From 3c6cc330820c37adbfa0929b1298911616a03ea7 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 10 Aug 2011 14:06:28 +0000 Subject: [PATCH 49/52] Added the ability to deselect attributes in the font dialog git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68619 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/richtext/richtextfontpage.h | 4 + src/richtext/richtextdialogs.pjd | 109 ++++++++---------- src/richtext/richtextfontpage.cpp | 150 +++++++++++++++++++------ 3 files changed, 169 insertions(+), 94 deletions(-) diff --git a/include/wx/richtext/richtextfontpage.h b/include/wx/richtext/richtextfontpage.h index 9123be10ea..4a0d851626 100644 --- a/include/wx/richtext/richtextfontpage.h +++ b/include/wx/richtext/richtextfontpage.h @@ -134,7 +134,9 @@ public: wxComboBox* m_styleCtrl; wxComboBox* m_weightCtrl; wxComboBox* m_underliningCtrl; + wxCheckBox* m_textColourLabel; wxRichTextColourSwatchCtrl* m_colourCtrl; + wxCheckBox* m_bgColourLabel; wxRichTextColourSwatchCtrl* m_bgColourCtrl; wxCheckBox* m_strikethroughCtrl; wxCheckBox* m_capitalsCtrl; @@ -151,7 +153,9 @@ public: ID_RICHTEXTFONTPAGE_STYLECTRL = 10007, ID_RICHTEXTFONTPAGE_WEIGHTCTRL = 10004, ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL = 10008, + ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL = 10015, ID_RICHTEXTFONTPAGE_COLOURCTRL = 10009, + ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL = 10016, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL = 10014, ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL = 10010, ID_RICHTEXTFONTPAGE_CAPSCTRL = 10011, diff --git a/src/richtext/richtextdialogs.pjd b/src/richtext/richtextdialogs.pjd index fc0f92ab27..804c0fa721 100644 --- a/src/richtext/richtextdialogs.pjd +++ b/src/richtext/richtextdialogs.pjd @@ -306,14 +306,6 @@ "wbBoxSizerProxy" "Vertical" "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 0 0 0 @@ -1442,36 +1434,30 @@ 0 "<Any platform>" - "wxStaticText: wxID_STATIC" + "wxCheckBox: ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL" "dialog-control-document" "" - "statictext" + "checkbox" 0 1 0 0 - "2/10/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 + "wbCheckBoxProxy" + "wxEVT_COMMAND_CHECKBOX_CLICKED|OnUnderliningCtrlSelected|NONE||wxRichTextFontPage" + "ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL" + 10015 "" - "wxStaticText" - "wxStaticText" + "wxCheckBox" + "wxCheckBox" 1 0 "" "" - "" + "m_textColourLabel" "&Colour:" - -1 + 0 "" "" - "" - "" - "" - 0 - 1 - "<Any platform>" "" "" "" @@ -1479,17 +1465,16 @@ "" "" "" - 0 + "" + "" + "" + 0 + 1 + "<Any platform>" 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 0 0 0 @@ -1498,7 +1483,7 @@ -1 -1 -1 - "Left" + "Centre" "Centre" 0 5 @@ -1609,35 +1594,30 @@ 0 "<Any platform>" - "wxStaticText: wxID_STATIC" + "wxCheckBox: ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL" "dialog-control-document" "" - "statictext" + "checkbox" 0 1 0 0 - "wbStaticTextProxy" - "wxID_STATIC" - 5105 + "wbCheckBoxProxy" + "wxEVT_COMMAND_CHECKBOX_CLICKED|OnUnderliningCtrlSelected|NONE||wxRichTextFontPage" + "ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL" + 10016 "" - "wxStaticText" - "wxStaticText" + "wxCheckBox" + "wxCheckBox" 1 0 "" "" - "" + "m_bgColourLabel" "&Bg colour:" - -1 + 0 "" "" - "" - "" - "" - 0 - 1 - "<Any platform>" "" "" "" @@ -1645,17 +1625,16 @@ "" "" "" - 0 + "" + "" + "" + 0 + 1 + "<Any platform>" 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 0 0 0 @@ -1664,7 +1643,7 @@ -1 -1 -1 - "Left" + "Centre" "Centre" 0 5 @@ -2229,6 +2208,14 @@ "wbBoxSizerProxy" "Vertical" "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 0 0 0 diff --git a/src/richtext/richtextfontpage.cpp b/src/richtext/richtextfontpage.cpp index 61f4bf5145..d8bfa690bb 100644 --- a/src/richtext/richtextfontpage.cpp +++ b/src/richtext/richtextfontpage.cpp @@ -39,6 +39,10 @@ BEGIN_EVENT_TABLE( wxRichTextFontPage, wxRichTextDialogPage ) EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, wxRichTextFontPage::OnUnderliningCtrlSelected ) + EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL, wxRichTextFontPage::OnUnderliningCtrlSelected ) + + EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL, wxRichTextFontPage::OnUnderliningCtrlSelected ) + EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL, wxRichTextFontPage::OnStrikethroughctrlClick ) EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_CAPSCTRL, wxRichTextFontPage::OnCapsctrlClick ) @@ -85,7 +89,9 @@ void wxRichTextFontPage::Init() m_styleCtrl = NULL; m_weightCtrl = NULL; m_underliningCtrl = NULL; + m_textColourLabel = NULL; m_colourCtrl = NULL; + m_bgColourLabel = NULL; m_bgColourCtrl = NULL; m_strikethroughCtrl = NULL; m_capitalsCtrl = NULL; @@ -216,8 +222,9 @@ void wxRichTextFontPage::CreateControls() wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxVERTICAL); itemBoxSizer13->Add(itemBoxSizer24, 0, wxGROW, 5); - wxStaticText* itemStaticText25 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Colour:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer24->Add(itemStaticText25, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); + m_textColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL, _("&Colour:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textColourLabel->SetValue(false); + itemBoxSizer24->Add(m_textColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5); m_colourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 ); m_colourCtrl->SetHelpText(_("Click to change the text colour.")); @@ -228,8 +235,9 @@ void wxRichTextFontPage::CreateControls() wxBoxSizer* itemBoxSizer27 = new wxBoxSizer(wxVERTICAL); itemBoxSizer13->Add(itemBoxSizer27, 0, wxGROW, 5); - wxStaticText* itemStaticText28 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Bg colour:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer27->Add(itemStaticText28, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); + m_bgColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL, _("&Bg colour:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_bgColourLabel->SetValue(false); + itemBoxSizer27->Add(m_bgColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5); m_bgColourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 ); m_bgColourCtrl->SetHelpText(_("Click to change the text background colour.")); @@ -280,12 +288,15 @@ void wxRichTextFontPage::CreateControls() m_faceListBox->UpdateFonts(); + m_styleCtrl->Append(_("(none)")); m_styleCtrl->Append(_("Regular")); m_styleCtrl->Append(_("Italic")); + m_weightCtrl->Append(_("(none)")); m_weightCtrl->Append(_("Regular")); m_weightCtrl->Append(_("Bold")); + m_underliningCtrl->Append(_("(none)")); m_underliningCtrl->Append(_("Not underlined")); m_underliningCtrl->Append(_("Underlined")); @@ -327,10 +338,10 @@ bool wxRichTextFontPage::TransferDataFromWindow() else attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_SIZE)); - if (m_styleCtrl->GetSelection() != wxNOT_FOUND) + if (m_styleCtrl->GetSelection() != wxNOT_FOUND && m_styleCtrl->GetSelection() != 0) { wxFontStyle style; - if (m_styleCtrl->GetStringSelection() == _("Italic")) + if (m_styleCtrl->GetSelection() == 2) style = wxFONTSTYLE_ITALIC; else style = wxFONTSTYLE_NORMAL; @@ -340,10 +351,10 @@ bool wxRichTextFontPage::TransferDataFromWindow() else attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_ITALIC)); - if (m_weightCtrl->GetSelection() != wxNOT_FOUND) + if (m_weightCtrl->GetSelection() != wxNOT_FOUND && m_weightCtrl->GetSelection() != 0) { wxFontWeight weight; - if (m_weightCtrl->GetStringSelection() == _("Bold")) + if (m_weightCtrl->GetSelection() == 2) weight = wxFONTWEIGHT_BOLD; else weight = wxFONTWEIGHT_NORMAL; @@ -353,10 +364,10 @@ bool wxRichTextFontPage::TransferDataFromWindow() else attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_WEIGHT)); - if (m_underliningCtrl->GetSelection() != wxNOT_FOUND) + if (m_underliningCtrl->GetSelection() != wxNOT_FOUND && m_underliningCtrl->GetSelection() != 0) { bool underlined; - if (m_underliningCtrl->GetStringSelection() == _("Underlined")) + if (m_underliningCtrl->GetSelection() == 2) underlined = true; else underlined = false; @@ -366,14 +377,14 @@ bool wxRichTextFontPage::TransferDataFromWindow() else attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_UNDERLINE)); - if (m_colourPresent) + if (m_textColourLabel->GetValue()) { attr->SetTextColour(m_colourCtrl->GetColour()); } else attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_TEXT_COLOUR)); - if (m_bgColourPresent) + if (m_bgColourLabel->GetValue()) { attr->SetBackgroundColour(m_bgColourCtrl->GetColour()); } @@ -456,50 +467,62 @@ bool wxRichTextFontPage::TransferDataToWindow() if (attr->HasFontWeight()) { if (attr->GetFontWeight() == wxBOLD) - m_weightCtrl->SetSelection(1); + m_weightCtrl->SetSelection(2); else - m_weightCtrl->SetSelection(0); + m_weightCtrl->SetSelection(1); } else { - m_weightCtrl->SetSelection(wxNOT_FOUND); + m_weightCtrl->SetSelection(0); } if (attr->HasFontItalic()) { if (attr->GetFontStyle() == wxITALIC) - m_styleCtrl->SetSelection(1); + m_styleCtrl->SetSelection(2); else - m_styleCtrl->SetSelection(0); + m_styleCtrl->SetSelection(1); } else { - m_styleCtrl->SetSelection(wxNOT_FOUND); + m_styleCtrl->SetSelection(0); } if (attr->HasFontUnderlined()) { if (attr->GetFontUnderlined()) - m_underliningCtrl->SetSelection(1); + m_underliningCtrl->SetSelection(2); else - m_underliningCtrl->SetSelection(0); + m_underliningCtrl->SetSelection(1); } else { - m_underliningCtrl->SetSelection(wxNOT_FOUND); + m_underliningCtrl->SetSelection(0); } if (attr->HasTextColour()) { m_colourCtrl->SetColour(attr->GetTextColour()); + m_textColourLabel->SetValue(true); m_colourPresent = true; } + else + { + m_colourCtrl->SetColour(*wxBLACK); + m_textColourLabel->SetValue(false); + } if (attr->HasBackgroundColour()) { m_bgColourCtrl->SetColour(attr->GetBackgroundColour()); + m_bgColourLabel->SetValue(true); m_bgColourPresent = true; } + else + { + m_bgColourCtrl->SetColour(*wxWHITE); + m_bgColourLabel->SetValue(false); + } if (attr->HasTextEffects()) { @@ -572,11 +595,30 @@ void wxRichTextFontPage::UpdatePreview() { wxRichTextAttr attr; - if (m_colourPresent) - m_previewCtrl->SetForegroundColour(m_colourCtrl->GetBackgroundColour()); + if (m_textColourLabel->GetValue()) + m_previewCtrl->SetForegroundColour(m_colourCtrl->GetColour()); + else + { + m_previewCtrl->SetForegroundColour(*wxBLACK); + if (!(m_colourCtrl->GetColour() == *wxBLACK)) + { + m_colourCtrl->SetColour(*wxBLACK); + m_colourCtrl->Refresh(); + } + } - if (m_bgColourPresent) - m_previewCtrl->SetBackgroundColour(m_bgColourCtrl->GetBackgroundColour()); + if (m_bgColourLabel->GetValue()) + m_previewCtrl->SetBackgroundColour(m_bgColourCtrl->GetColour()); + else + { + m_previewCtrl->SetBackgroundColour(*wxWHITE); + + if (!(m_bgColourCtrl->GetColour() == *wxWHITE)) + { + m_bgColourCtrl->SetColour(*wxWHITE); + m_bgColourCtrl->Refresh(); + } + } if (m_faceListBox->GetSelection() != wxNOT_FOUND) { @@ -592,10 +634,10 @@ void wxRichTextFontPage::UpdatePreview() attr.SetFontSize(sz); } - if (m_styleCtrl->GetSelection() != wxNOT_FOUND) + if (m_styleCtrl->GetSelection() != wxNOT_FOUND && m_styleCtrl->GetSelection() != 0) { wxFontStyle style; - if (m_styleCtrl->GetStringSelection() == _("Italic")) + if (m_styleCtrl->GetSelection() == 2) style = wxFONTSTYLE_ITALIC; else style = wxFONTSTYLE_NORMAL; @@ -603,10 +645,10 @@ void wxRichTextFontPage::UpdatePreview() attr.SetFontStyle(style); } - if (m_weightCtrl->GetSelection() != wxNOT_FOUND) + if (m_weightCtrl->GetSelection() != wxNOT_FOUND && m_weightCtrl->GetSelection() != 0) { wxFontWeight weight; - if (m_weightCtrl->GetStringSelection() == _("Bold")) + if (m_weightCtrl->GetSelection() == 2) weight = wxFONTWEIGHT_BOLD; else weight = wxFONTWEIGHT_NORMAL; @@ -614,10 +656,10 @@ void wxRichTextFontPage::UpdatePreview() attr.SetFontWeight(weight); } - if (m_underliningCtrl->GetSelection() != wxNOT_FOUND) + if (m_underliningCtrl->GetSelection() != wxNOT_FOUND && m_underliningCtrl->GetSelection() != 0) { bool underlined; - if (m_underliningCtrl->GetStringSelection() == _("Underlined")) + if (m_underliningCtrl->GetSelection() == 2) underlined = true; else underlined = false; @@ -740,11 +782,15 @@ void wxRichTextFontPage::OnSizeTextCtrlUpdated( wxCommandEvent& WXUNUSED(event) void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent& event ) { + bool oldDontUpdate = m_dontUpdate; m_dontUpdate = true; m_sizeTextCtrl->SetValue(event.GetString()); - m_dontUpdate = false; + m_dontUpdate = oldDontUpdate; + + if (m_dontUpdate) + return; UpdatePreview(); } @@ -755,11 +801,15 @@ void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent& event ) void wxRichTextFontPage::OnFaceListBoxSelected( wxCommandEvent& WXUNUSED(event) ) { + bool oldDontUpdate = m_dontUpdate; m_dontUpdate = true; m_faceTextCtrl->SetValue(m_faceListBox->GetFaceName(m_faceListBox->GetSelection())); - m_dontUpdate = false; + m_dontUpdate = oldDontUpdate; + + if (m_dontUpdate) + return; UpdatePreview(); } @@ -770,6 +820,9 @@ void wxRichTextFontPage::OnFaceListBoxSelected( wxCommandEvent& WXUNUSED(event) void wxRichTextFontPage::OnStyleCtrlSelected( wxCommandEvent& WXUNUSED(event) ) { + if (m_dontUpdate) + return; + UpdatePreview(); } @@ -780,6 +833,9 @@ void wxRichTextFontPage::OnStyleCtrlSelected( wxCommandEvent& WXUNUSED(event) ) void wxRichTextFontPage::OnUnderliningCtrlSelected( wxCommandEvent& WXUNUSED(event) ) { + if (m_dontUpdate) + return; + UpdatePreview(); } @@ -790,6 +846,9 @@ void wxRichTextFontPage::OnUnderliningCtrlSelected( wxCommandEvent& WXUNUSED(eve void wxRichTextFontPage::OnWeightCtrlSelected( wxCommandEvent& WXUNUSED(event) ) { + if (m_dontUpdate) + return; + UpdatePreview(); } @@ -800,6 +859,19 @@ void wxRichTextFontPage::OnColourClicked( wxCommandEvent& event ) else if (event.GetId() == m_bgColourCtrl->GetId()) m_bgColourPresent = true; + m_dontUpdate = true; + + if (event.GetId() == m_colourCtrl->GetId()) + { + m_textColourLabel->SetValue(true); + } + else if (event.GetId() == m_bgColourCtrl->GetId()) + { + m_bgColourLabel->SetValue(true); + } + + m_dontUpdate = false; + UpdatePreview(); } /*! @@ -808,6 +880,9 @@ void wxRichTextFontPage::OnColourClicked( wxCommandEvent& event ) void wxRichTextFontPage::OnStrikethroughctrlClick( wxCommandEvent& WXUNUSED(event) ) { + if (m_dontUpdate) + return; + UpdatePreview(); } @@ -817,6 +892,9 @@ void wxRichTextFontPage::OnStrikethroughctrlClick( wxCommandEvent& WXUNUSED(even void wxRichTextFontPage::OnCapsctrlClick( wxCommandEvent& WXUNUSED(event) ) { + if (m_dontUpdate) + return; + UpdatePreview(); } @@ -826,6 +904,9 @@ void wxRichTextFontPage::OnCapsctrlClick( wxCommandEvent& WXUNUSED(event) ) void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent& WXUNUSED(event) ) { + if (m_dontUpdate) + return; + if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED) m_subscriptCtrl->Set3StateValue( wxCHK_UNCHECKED ); @@ -838,6 +919,9 @@ void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent& WXU void wxRichTextFontPage::OnRichtextfontpageSubscriptClick( wxCommandEvent& WXUNUSED(event) ) { + if (m_dontUpdate) + return; + if ( m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED) m_superscriptCtrl->Set3StateValue( wxCHK_UNCHECKED ); From d5c4a81f2eb66d49cce640f05e5566681b31befb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 10 Aug 2011 15:21:22 +0000 Subject: [PATCH 50/52] Make the wxDataViewItem(void*) constructor explicit. Not having this as an implicit one made it possible to create wxDataViewItem from any pointer without realizing it, leading to hard to debug crashes later. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68621 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/dataview.h | 9 +++++---- interface/wx/dataview.h | 3 ++- src/common/datavcmn.cpp | 16 ++++++++-------- src/generic/datavgen.cpp | 4 ++-- src/gtk/dataview.cpp | 4 ++-- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/include/wx/dataview.h b/include/wx/dataview.h index be3ce240a8..87bfcf12e2 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -81,10 +81,11 @@ extern WXDLLIMPEXP_DATA_ADV(const char) wxDataViewCtrlNameStr[]; class WXDLLIMPEXP_ADV wxDataViewItem { public: - wxDataViewItem( void* id = NULL ) - { m_id = id; } - wxDataViewItem( const wxDataViewItem &item ) - { m_id = item.m_id; } + wxDataViewItem() : m_id(NULL) {} + wxDataViewItem(const wxDataViewItem &item) : m_id(item.m_id) {} + + wxEXPLICIT wxDataViewItem(void* id) : m_id(id) {} + bool IsOk() const { return m_id != NULL; } void* GetID() const { return m_id; } operator const void* () const { return m_id; } diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index f4d4fcd8f1..9c24be7d76 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -614,8 +614,9 @@ public: /** Constructor. */ - wxDataViewItem(void* id = NULL); + wxDataViewItem(); wxDataViewItem(const wxDataViewItem& item); + explicit wxDataViewItem(void* id); //@} /** diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 611d3b1d5a..c5540283fc 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -387,7 +387,7 @@ wxDataViewIndexListModel::wxDataViewIndexListModel( unsigned int initial_size ) // build initial index unsigned int i; for (i = 1; i < initial_size+1; i++) - m_hash.Add( wxUIntToPtr(i) ); + m_hash.Add( wxDataViewItem(wxUIntToPtr(i)) ); m_nextFreeID = initial_size + 1; } @@ -403,7 +403,7 @@ void wxDataViewIndexListModel::Reset( unsigned int new_size ) // build initial index unsigned int i; for (i = 1; i < new_size+1; i++) - m_hash.Add( wxUIntToPtr(i) ); + m_hash.Add( wxDataViewItem(wxUIntToPtr(i)) ); m_nextFreeID = new_size + 1; @@ -417,8 +417,8 @@ void wxDataViewIndexListModel::RowPrepended() unsigned int id = m_nextFreeID; m_nextFreeID++; - m_hash.Insert( wxUIntToPtr(id), 0 ); wxDataViewItem item( wxUIntToPtr(id) ); + m_hash.Insert( item, 0 ); ItemAdded( wxDataViewItem(0), item ); } @@ -430,8 +430,8 @@ void wxDataViewIndexListModel::RowInserted( unsigned int before ) unsigned int id = m_nextFreeID; m_nextFreeID++; - m_hash.Insert( wxUIntToPtr(id), before ); wxDataViewItem item( wxUIntToPtr(id) ); + m_hash.Insert( item, before ); ItemAdded( wxDataViewItem(0), item ); } @@ -440,8 +440,8 @@ void wxDataViewIndexListModel::RowAppended() unsigned int id = m_nextFreeID; m_nextFreeID++; - m_hash.Add( wxUIntToPtr(id) ); wxDataViewItem item( wxUIntToPtr(id) ); + m_hash.Add( item ); ItemAdded( wxDataViewItem(0), item ); } @@ -490,7 +490,7 @@ unsigned int wxDataViewIndexListModel::GetRow( const wxDataViewItem &item ) cons return wxPtrToUInt(item.GetID())-1; // assert for not found - return (unsigned int) m_hash.Index( item.GetID() ); + return (unsigned int) m_hash.Index( item ); } wxDataViewItem wxDataViewIndexListModel::GetItem( unsigned int row ) const @@ -2005,7 +2005,7 @@ wxDataViewItem wxDataViewTreeStore::GetNthChild( const wxDataViewItem& parent, u wxDataViewTreeStoreNodeList::compatibility_iterator node = parent_node->GetChildren().Item( pos ); if (node) - return node->GetData(); + return wxDataViewItem(node->GetData()); return wxDataViewItem(0); } @@ -2111,7 +2111,7 @@ void wxDataViewTreeStore::DeleteChildren( const wxDataViewItem& item ) void wxDataViewTreeStore::DeleteAllItems() { - DeleteChildren(m_root); + DeleteChildren(wxDataViewItem(m_root)); } void diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 167c1149b8..aaaa107c89 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -406,7 +406,7 @@ int LINKAGEMODE wxGenericTreeModelNodeCmp( wxDataViewTreeNode ** node1, int LINKAGEMODE wxGenericTreeModelItemCmp( void ** id1, void ** id2) { - return g_model->Compare( *id1, *id2, g_column, g_asending ); + return g_model->Compare( wxDataViewItem(*id1), wxDataViewItem(*id2), g_column, g_asending ); } @@ -2702,7 +2702,7 @@ public: if( node->GetNodes().GetCount() == 0) { int index = static_cast(row) - current - 1; - ret = node->GetChildren().Item( index ); + ret = wxDataViewItem(node->GetChildren().Item( index )); return DoJob::OK; } return DoJob::CONT; diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index e27c908000..ee2ea2b686 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -300,7 +300,7 @@ private: static int LINKAGEMODE wxGtkTreeModelChildCmp( void** id1, void** id2 ) { - int ret = gs_internal->GetDataViewModel()->Compare( *id1, *id2, + int ret = gs_internal->GetDataViewModel()->Compare( wxDataViewItem(*id1), wxDataViewItem(*id2), gs_internal->GetSortColumn(), (gs_internal->GetSortOrder() == GTK_SORT_ASCENDING) ); return ret; @@ -3334,7 +3334,7 @@ int wxGtkTreeModelChildWithPosCmp( const void* data1, const void* data2, const v static int LINKAGEMODE wxGtkTreeModelChildPtrCmp( void*** data1, void*** data2 ) { - return gs_internal->GetDataViewModel()->Compare( **data1, **data2, + return gs_internal->GetDataViewModel()->Compare( wxDataViewItem(**data1), wxDataViewItem(**data2), gs_internal->GetSortColumn(), (gs_internal->GetSortOrder() == GTK_SORT_ASCENDING) ); } From 57ab45460d6c309ae57f5686278a65472da4349b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 10 Aug 2011 15:24:19 +0000 Subject: [PATCH 51/52] Fix selection handling wxDataViewMainWindow::ItemDeleted(). The code to update m_selection was too aggressive in the virtual list case, when it simply cleared it, and broken for single-item selection in the general case. Fixed to recompute selection properly. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68622 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/datavgen.cpp | 110 ++++++++++++++++++++++++++++++--------- 1 file changed, 86 insertions(+), 24 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index aaaa107c89..ea10aece55 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -388,6 +388,21 @@ public: } } + // returns node corresponding to 'item' if its in m_nodes or NULL otherwise + wxDataViewTreeNode *FindItemAsNode(const wxDataViewItem& item) const + { + for ( wxDataViewTreeNodes::const_iterator i = m_nodes.begin(); + i != m_nodes.end(); + ++i ) + { + if( (*i)->GetItem() == item ) + return *i; + } + + return NULL; + } + + private: wxDataViewTreeNode *m_parent; wxDataViewTreeNodes m_nodes; @@ -2006,60 +2021,107 @@ bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent, (wxDataViewVirtualListModel*) GetOwner()->GetModel(); m_count = list_model->GetCount(); - // TODO: why empty the entire selection? - m_selection.Empty(); + if ( !m_selection.empty() ) + { + const int row = GetRowByItem(item); + + const size_t selCount = m_selection.size(); + for ( size_t i = 0; i < selCount; i++ ) + { + if ( m_selection[i] > (unsigned)row ) + m_selection[i]--; + } + + int itemRow = m_selection.Index(row); + if ( itemRow != wxNOT_FOUND ) + m_selection.RemoveAt(itemRow); + } + } else // general case { wxDataViewTreeNode * node = FindNode(parent); + int itemPosInNode = node ? node->GetChildren().Index(item.GetID()) : wxNOT_FOUND; // Notice that it is possible that the item being deleted is not in the // tree at all, for example we could be deleting a never shown (because // collapsed) item in a tree model. So it's not an error if we don't know // about this item, just return without doing anything then. - if ( !node || node->GetChildren().Index(item.GetID()) == wxNOT_FOUND ) + if ( !node || itemPosInNode == wxNOT_FOUND ) return false; - int sub = -1; - node->GetChildren().Remove( item.GetID() ); - // Manipolate selection - if( m_selection.GetCount() > 1 ) - { - m_selection.Empty(); - } bool isContainer = false; - wxDataViewTreeNodes nds = node->GetNodes(); + wxDataViewTreeNode *itemNode = NULL; + + const wxDataViewTreeNodes nds = node->GetNodes(); for (size_t i = 0; i < nds.GetCount(); i ++) { if (nds[i]->GetItem() == item) { isContainer = true; + itemNode = nds[i]; break; } } + + // Delete the item from wxDataViewTreeNode representation: + int itemsDeleted = 1; + node->GetChildren().Remove( item.GetID() ); + if( isContainer ) { - wxDataViewTreeNode * n = NULL; - wxDataViewTreeNodes nodes = node->GetNodes(); - int len = nodes.GetCount(); - for( int i = 0; i < len; i ++) - { - if( nodes[i]->GetItem() == item ) - { - n = nodes[i]; - break; - } - } + wxDataViewTreeNode *n = node->FindItemAsNode(item); wxCHECK_MSG( n != NULL, false, "item not found" ); node->GetNodes().Remove( n ); - sub -= n->GetSubTreeCount(); + itemsDeleted += n->GetSubTreeCount(); ::DestroyTreeHelper(n); } + // Make the row number invalid and get a new valid one when user call GetRowCount m_count = -1; - node->ChangeSubTreeCount(sub); + node->ChangeSubTreeCount(-itemsDeleted); + + // Update selection by removing 'item' and its entire children tree from the selection. + if ( !m_selection.empty() ) + { + // we can't call GetRowByItem() on 'item', as it's already deleted, so compute it from + // the parent ('node') and position in its list of children + int itemRow; + if ( itemPosInNode == 0 ) + { + // 1st child, row number is that of the parent node + 1 + itemRow = GetRowByItem(node->GetItem()) + 1; + } + else + { + // row number is that of the sibling above 'item' + its subtree if any + 1 + const wxDataViewItem sibling = wxDataViewItem(node->GetChildren()[itemPosInNode - 1]); + const wxDataViewTreeNode *siblingNode = node->FindItemAsNode(sibling); + + itemRow = GetRowByItem(sibling); + if ( siblingNode ) + itemRow += siblingNode->GetSubTreeCount(); + itemRow += 1; + } + + wxDataViewSelection newsel(wxDataViewSelectionCmp); + + for ( wxDataViewSelection::const_iterator i = m_selection.begin(); + i != m_selection.end(); + ++i ) + { + const int s = *i; + if ( s < itemRow ) + newsel.push_back(s); + else if ( s >= itemRow + itemsDeleted ) + newsel.push_back(s - itemsDeleted); + // else: deleted item, remove from selection + } + + m_selection = newsel; + } } // Change the current row to the last row if the current exceed the max row number From cbef7338c1c7763042704c74d5ee6f62c7e10733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 10 Aug 2011 15:24:25 +0000 Subject: [PATCH 52/52] Add some basic tests for wxDataViewCtrl selection handling. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68623 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/Makefile.in | 6 +- tests/controls/dataviewctrltest.cpp | 140 ++++++++++++++++++++++++++++ tests/makefile.bcc | 12 ++- tests/makefile.gcc | 12 ++- tests/makefile.vc | 12 ++- tests/makefile.wat | 12 ++- tests/test.bkl | 1 + tests/test_test_gui.dsp | 12 ++- tests/test_vc7_test_gui.vcproj | 9 +- tests/test_vc8_test_gui.vcproj | 12 ++- tests/test_vc9_test_gui.vcproj | 12 ++- 11 files changed, 208 insertions(+), 32 deletions(-) create mode 100644 tests/controls/dataviewctrltest.cpp diff --git a/tests/Makefile.in b/tests/Makefile.in index 61c235eaee..26ae782b00 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -46,7 +46,7 @@ wx_top_builddir = @wx_top_builddir@ DESTDIR = WX_RELEASE = 2.9 -WX_VERSION = $(WX_RELEASE).2 +WX_VERSION = $(WX_RELEASE).3 LIBDIRNAME = $(wx_top_builddir)/lib TEST_CXXFLAGS = $(__test_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \ $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \ @@ -166,6 +166,7 @@ TEST_GUI_OBJECTS = \ test_gui_choicebooktest.o \ test_gui_choicetest.o \ test_gui_comboboxtest.o \ + test_gui_dataviewctrltest.o \ test_gui_datepickerctrltest.o \ test_gui_frametest.o \ test_gui_gaugetest.o \ @@ -732,6 +733,9 @@ test_gui_choicetest.o: $(srcdir)/controls/choicetest.cpp $(TEST_GUI_ODEP) test_gui_comboboxtest.o: $(srcdir)/controls/comboboxtest.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/comboboxtest.cpp +test_gui_dataviewctrltest.o: $(srcdir)/controls/dataviewctrltest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/dataviewctrltest.cpp + test_gui_datepickerctrltest.o: $(srcdir)/controls/datepickerctrltest.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/datepickerctrltest.cpp diff --git a/tests/controls/dataviewctrltest.cpp b/tests/controls/dataviewctrltest.cpp new file mode 100644 index 0000000000..60d1a38270 --- /dev/null +++ b/tests/controls/dataviewctrltest.cpp @@ -0,0 +1,140 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/treectrltest.cpp +// Purpose: wxDataViewCtrl unit test +// Author: Vaclav Slavik +// Created: 2011-08-08 +// RCS-ID: $Id$ +// Copyright: (c) 2011 Vaclav Slavik +/////////////////////////////////////////////////////////////////////////////// + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#include "testprec.h" + +#if wxUSE_DATAVIEWCTRL + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/app.h" +#include "wx/dataview.h" + +#include "testableframe.h" + +// ---------------------------------------------------------------------------- +// test class +// ---------------------------------------------------------------------------- + +class DataViewCtrlTestCase : public CppUnit::TestCase +{ +public: + DataViewCtrlTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + CPPUNIT_TEST_SUITE( DataViewCtrlTestCase ); + CPPUNIT_TEST( DeleteSelected ); + CPPUNIT_TEST( DeleteNotSelected ); + CPPUNIT_TEST_SUITE_END(); + + void DeleteSelected(); + void DeleteNotSelected(); + + // the dataview control itself + wxDataViewTreeCtrl *m_dvc; + + // and some of its items + wxDataViewItem m_root, + m_child1, + m_child2, + m_grandchild; + + DECLARE_NO_COPY_CLASS(DataViewCtrlTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( DataViewCtrlTestCase ); + +// also include in its own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DataViewCtrlTestCase, "DataViewCtrlTestCase" ); + +// ---------------------------------------------------------------------------- +// test initialization +// ---------------------------------------------------------------------------- + +void DataViewCtrlTestCase::setUp() +{ + m_dvc = new wxDataViewTreeCtrl(wxTheApp->GetTopWindow(), + wxID_ANY, + wxDefaultPosition, + wxSize(400, 200), + wxDV_MULTIPLE); + + m_root = m_dvc->AppendContainer(wxDataViewItem(), "The root"); + m_child1 = m_dvc->AppendContainer(m_root, "child1"); + m_grandchild = m_dvc->AppendItem(m_child1, "grandchild"); + m_child2 = m_dvc->AppendItem(m_root, "child2"); + + m_dvc->SetSize(400, 200); + m_dvc->ExpandAncestors(m_root); + m_dvc->Refresh(); + m_dvc->Update(); +} + +void DataViewCtrlTestCase::tearDown() +{ + delete m_dvc; + m_dvc = NULL; + + m_root = + m_child1 = + m_child2 = + m_grandchild = wxDataViewItem(); +} + +// ---------------------------------------------------------------------------- +// the tests themselves +// ---------------------------------------------------------------------------- + +void DataViewCtrlTestCase::DeleteSelected() +{ + wxDataViewItemArray sel; + sel.push_back(m_child1); + sel.push_back(m_grandchild); + sel.push_back(m_child2); + m_dvc->SetSelections(sel); + + // delete a selected item + m_dvc->DeleteItem(m_child1); + + m_dvc->GetSelections(sel); + + // m_child1 and its children should be removed from the selection now + CPPUNIT_ASSERT( sel.size() == 1 ); + CPPUNIT_ASSERT( sel[0] == m_child2 ); +} + +void DataViewCtrlTestCase::DeleteNotSelected() +{ + wxDataViewItemArray sel; + sel.push_back(m_child1); + sel.push_back(m_grandchild); + m_dvc->SetSelections(sel); + + // delete unselected item + m_dvc->DeleteItem(m_child2); + + m_dvc->GetSelections(sel); + + // m_child1 and its children should be removed from the selection now + CPPUNIT_ASSERT( sel.size() == 2 ); + CPPUNIT_ASSERT( sel[0] == m_child1 ); + CPPUNIT_ASSERT( sel[1] == m_grandchild ); +} + +#endif //wxUSE_TREECTRL diff --git a/tests/makefile.bcc b/tests/makefile.bcc index 3f816730c2..812e939fae 100644 --- a/tests/makefile.bcc +++ b/tests/makefile.bcc @@ -151,7 +151,8 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_choicebooktest.obj \ $(OBJS)\test_gui_choicetest.obj \ $(OBJS)\test_gui_comboboxtest.obj \ - $(OBJS)\test_gui_datepickerctrltest.obj \ + $(OBJS)\test_gui_dataviewctrltest.obj \ + $(OBJS)\test_gui_datepickerctrltest.obj \ $(OBJS)\test_gui_frametest.obj \ $(OBJS)\test_gui_gaugetest.obj \ $(OBJS)\test_gui_gridtest.obj \ @@ -780,9 +781,12 @@ $(OBJS)\test_gui_choicetest.obj: .\controls\choicetest.cpp $(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp -$(OBJS)\test_gui_datepickerctrltest.obj: .\controls\datepickerctrltest.cpp - $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\datepickerctrltest.cpp - +$(OBJS)\test_gui_dataviewctrltest.obj: .\controls\dataviewctrltest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\dataviewctrltest.cpp + +$(OBJS)\test_gui_datepickerctrltest.obj: .\controls\datepickerctrltest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\datepickerctrltest.cpp + $(OBJS)\test_gui_frametest.obj: .\controls\frametest.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\frametest.cpp diff --git a/tests/makefile.gcc b/tests/makefile.gcc index 652df038ca..49ea23cddd 100644 --- a/tests/makefile.gcc +++ b/tests/makefile.gcc @@ -144,7 +144,8 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_choicebooktest.o \ $(OBJS)\test_gui_choicetest.o \ $(OBJS)\test_gui_comboboxtest.o \ - $(OBJS)\test_gui_datepickerctrltest.o \ + $(OBJS)\test_gui_dataviewctrltest.o \ + $(OBJS)\test_gui_datepickerctrltest.o \ $(OBJS)\test_gui_frametest.o \ $(OBJS)\test_gui_gaugetest.o \ $(OBJS)\test_gui_gridtest.o \ @@ -761,9 +762,12 @@ $(OBJS)\test_gui_choicetest.o: ./controls/choicetest.cpp $(OBJS)\test_gui_comboboxtest.o: ./controls/comboboxtest.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< -$(OBJS)\test_gui_datepickerctrltest.o: ./controls/datepickerctrltest.cpp - $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< - +$(OBJS)\test_gui_dataviewctrltest.o: ./controls/dataviewctrltest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_datepickerctrltest.o: ./controls/datepickerctrltest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\test_gui_frametest.o: ./controls/frametest.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< diff --git a/tests/makefile.vc b/tests/makefile.vc index a509e659ee..91f4734924 100644 --- a/tests/makefile.vc +++ b/tests/makefile.vc @@ -146,7 +146,8 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_choicebooktest.obj \ $(OBJS)\test_gui_choicetest.obj \ $(OBJS)\test_gui_comboboxtest.obj \ - $(OBJS)\test_gui_datepickerctrltest.obj \ + $(OBJS)\test_gui_dataviewctrltest.obj \ + $(OBJS)\test_gui_datepickerctrltest.obj \ $(OBJS)\test_gui_frametest.obj \ $(OBJS)\test_gui_gaugetest.obj \ $(OBJS)\test_gui_gridtest.obj \ @@ -906,9 +907,12 @@ $(OBJS)\test_gui_choicetest.obj: .\controls\choicetest.cpp $(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp -$(OBJS)\test_gui_datepickerctrltest.obj: .\controls\datepickerctrltest.cpp - $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\datepickerctrltest.cpp - +$(OBJS)\test_gui_dataviewctrltest.obj: .\controls\dataviewctrltest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\dataviewctrltest.cpp + +$(OBJS)\test_gui_datepickerctrltest.obj: .\controls\datepickerctrltest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\datepickerctrltest.cpp + $(OBJS)\test_gui_frametest.obj: .\controls\frametest.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\frametest.cpp diff --git a/tests/makefile.wat b/tests/makefile.wat index 12fca8172a..e566570d79 100644 --- a/tests/makefile.wat +++ b/tests/makefile.wat @@ -390,7 +390,8 @@ TEST_GUI_OBJECTS = & $(OBJS)\test_gui_choicebooktest.obj & $(OBJS)\test_gui_choicetest.obj & $(OBJS)\test_gui_comboboxtest.obj & - $(OBJS)\test_gui_datepickerctrltest.obj & + $(OBJS)\test_gui_dataviewctrltest.obj & + $(OBJS)\test_gui_datepickerctrltest.obj & $(OBJS)\test_gui_frametest.obj & $(OBJS)\test_gui_gaugetest.obj & $(OBJS)\test_gui_gridtest.obj & @@ -820,9 +821,12 @@ $(OBJS)\test_gui_choicetest.obj : .AUTODEPEND .\controls\choicetest.cpp $(OBJS)\test_gui_comboboxtest.obj : .AUTODEPEND .\controls\comboboxtest.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< -$(OBJS)\test_gui_datepickerctrltest.obj : .AUTODEPEND .\controls\datepickerctrltest.cpp - $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< - +$(OBJS)\test_gui_dataviewctrltest.obj : .AUTODEPEND .\controls\dataviewctrltest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_datepickerctrltest.obj : .AUTODEPEND .\controls\datepickerctrltest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + $(OBJS)\test_gui_frametest.obj : .AUTODEPEND .\controls\frametest.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< diff --git a/tests/test.bkl b/tests/test.bkl index 6530babbb1..344abee419 100644 --- a/tests/test.bkl +++ b/tests/test.bkl @@ -147,6 +147,7 @@ controls/choicebooktest.cpp controls/choicetest.cpp controls/comboboxtest.cpp + controls/dataviewctrltest.cpp controls/datepickerctrltest.cpp controls/frametest.cpp controls/gaugetest.cpp diff --git a/tests/test_test_gui.dsp b/tests/test_test_gui.dsp index 4ebfd62727..cd06b3663e 100644 --- a/tests/test_test_gui.dsp +++ b/tests/test_test_gui.dsp @@ -307,10 +307,14 @@ SOURCE=.\config\config.cpp # End Source File # Begin Source File -SOURCE=.\controls\datepickerctrltest.cpp -# End Source File -# Begin Source File - +SOURCE=.\controls\dataviewctrltest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\datepickerctrltest.cpp +# End Source File +# Begin Source File + SOURCE=.\dummy.cpp # ADD BASE CPP /Yc"testprec.h" # ADD CPP /Yc"testprec.h" diff --git a/tests/test_vc7_test_gui.vcproj b/tests/test_vc7_test_gui.vcproj index 344e7b1059..7bffd2876b 100644 --- a/tests/test_vc7_test_gui.vcproj +++ b/tests/test_vc7_test_gui.vcproj @@ -620,9 +620,12 @@ RelativePath=".\config\config.cpp"> - - + + + + diff --git a/tests/test_vc8_test_gui.vcproj b/tests/test_vc8_test_gui.vcproj index 978c1aa733..bdcc44289b 100644 --- a/tests/test_vc8_test_gui.vcproj +++ b/tests/test_vc8_test_gui.vcproj @@ -900,10 +900,14 @@ > - - + + + + - - + + + +