From d8d1818419134415331bfe9f6d4703a8f0742caa Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Wed, 26 Mar 2003 22:20:59 +0000 Subject: [PATCH] SetSelection must not send an event. Fixed an off by one index, and a crash (probably a Motif bug). Improved wxSpinButton appearance. Fixed some build warnings here and there in the samples, removed use of deprecated wxList methods in prntdlgg.cpp, fixed aot-of-range ID in tipdlg.cpp, fixed some errors detected by valgrind. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19825 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/motif/combobox.h | 7 ++++++- include/wx/motif/private.h | 4 ++++ samples/dragimag/dragimag.cpp | 3 ++- samples/propsize/mondrian.xpm | 2 +- src/common/treebase.cpp | 1 - src/generic/prntdlgg.cpp | 7 ++----- src/generic/tipdlg.cpp | 2 +- src/motif/combobox_native.cpp | 16 ++++++++++++---- src/motif/cursor.cpp | 1 + src/motif/evtloop.cpp | 3 ++- src/motif/spinbutt.cpp | 3 ++- 11 files changed, 33 insertions(+), 16 deletions(-) diff --git a/include/wx/motif/combobox.h b/include/wx/motif/combobox.h index 618756c345..20681ffb4f 100644 --- a/include/wx/motif/combobox.h +++ b/include/wx/motif/combobox.h @@ -27,7 +27,7 @@ class WXDLLEXPORT wxComboBox: public wxChoice DECLARE_DYNAMIC_CLASS(wxComboBox) public: - wxComboBox() {} + wxComboBox() { m_inSetSelection = false; } ~wxComboBox(); inline wxComboBox(wxWindow *parent, wxWindowID id, @@ -39,6 +39,7 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxComboBoxNameStr) { + m_inSetSelection = false; Create(parent, id, value, pos, size, n, choices, style, validator, name); } @@ -94,6 +95,10 @@ protected: private: // only implemented for native combo box void AdjustDropDownListSize(); + + // implementation detail, should really be private +public: + bool m_inSetSelection; }; #endif diff --git a/include/wx/motif/private.h b/include/wx/motif/private.h index f93dc7b81e..2f6270776c 100644 --- a/include/wx/motif/private.h +++ b/include/wx/motif/private.h @@ -15,6 +15,10 @@ #include "wx/defs.h" #include "X11/Xlib.h" +class WXDLLEXPORT wxFont; +class WXDLLEXPORT wxWindow; +class WXDLLEXPORT wxSize; + #include "wx/x11/privx.h" // Put any private declarations here: native Motif types may be used because diff --git a/samples/dragimag/dragimag.cpp b/samples/dragimag/dragimag.cpp index 0f68a70ff4..f1c9764ac6 100644 --- a/samples/dragimag/dragimag.cpp +++ b/samples/dragimag/dragimag.cpp @@ -337,7 +337,8 @@ MyFrame::MyFrame() wxMenuBar *menu_bar = new wxMenuBar(); menu_bar->Append(file_menu, _T("&File")); - + + SetIcon(wxICON(mondrian)); SetMenuBar( menu_bar ); CreateStatusBar(2); diff --git a/samples/propsize/mondrian.xpm b/samples/propsize/mondrian.xpm index 0d72d6803f..409b2cb2d8 100644 --- a/samples/propsize/mondrian.xpm +++ b/samples/propsize/mondrian.xpm @@ -41,4 +41,4 @@ static char *mondrian_xpm[] = { " ++++++ OOOOOOOOOOOO XXXXX ++++ ", " ++++++ OOOOOOOOOOOO XXXXX ++++ ", " " -}; \ No newline at end of file +}; diff --git a/src/common/treebase.cpp b/src/common/treebase.cpp index 6bf725823f..656da196ac 100644 --- a/src/common/treebase.cpp +++ b/src/common/treebase.cpp @@ -37,7 +37,6 @@ #include "wx/dynarray.h" #include "wx/arrimpl.cpp" #include "wx/dcclient.h" -#include "wx/msgdlg.h" // ---------------------------------------------------------------------------- diff --git a/src/generic/prntdlgg.cpp b/src/generic/prntdlgg.cpp index e7fef1cdae..df92048959 100644 --- a/src/generic/prntdlgg.cpp +++ b/src/generic/prntdlgg.cpp @@ -33,8 +33,6 @@ #ifndef WX_PRECOMP #include "wx/utils.h" #include "wx/dc.h" - #include "wx/app.h" - #include "wx/frame.h" #include "wx/stattext.h" #include "wx/statbox.h" #include "wx/button.h" @@ -42,7 +40,6 @@ #include "wx/textctrl.h" #include "wx/radiobox.h" #include "wx/filedlg.h" - #include "wx/choice.h" #include "wx/combobox.h" #include "wx/intl.h" #include "wx/sizer.h" @@ -506,7 +503,7 @@ bool wxGenericPrintSetupDialog::TransferDataFromWindow() int selectedItem = m_paperTypeChoice->GetSelection(); if (selectedItem != -1) { - wxPrintPaperType *paper = (wxPrintPaperType *)wxThePrintPaperDatabase->Nth(selectedItem)->Data(); + wxPrintPaperType *paper = (wxPrintPaperType*)wxThePrintPaperDatabase->Item(selectedItem)->GetData(); if (paper != NULL) m_printData.SetPaperId( paper->GetId()); } @@ -772,7 +769,7 @@ bool wxGenericPageSetupDialog::TransferDataFromWindow() int selectedItem = m_paperTypeChoice->GetSelection(); if (selectedItem != -1) { - wxPrintPaperType *paper = (wxPrintPaperType *)wxThePrintPaperDatabase->Nth(selectedItem)->Data(); + wxPrintPaperType *paper = (wxPrintPaperType*)wxThePrintPaperDatabase->Item(selectedItem)->GetData(); if ( paper ) { m_pageData.SetPaperSize(wxSize(paper->GetWidth()/10, paper->GetHeight()/10)); diff --git a/src/generic/tipdlg.cpp b/src/generic/tipdlg.cpp index bfb16d90ec..d9d19cd600 100644 --- a/src/generic/tipdlg.cpp +++ b/src/generic/tipdlg.cpp @@ -53,7 +53,7 @@ // constants // ---------------------------------------------------------------------------- -static const int wxID_NEXT_TIP = -100; // whatever +static const int wxID_NEXT_TIP = 32000; // whatever // ---------------------------------------------------------------------------- // private classes diff --git a/src/motif/combobox_native.cpp b/src/motif/combobox_native.cpp index 498ce2565f..846d4e10f3 100644 --- a/src/motif/combobox_native.cpp +++ b/src/motif/combobox_native.cpp @@ -179,8 +179,10 @@ void wxComboBox::SetValue(const wxString& value) { m_inSetValue = true; + // Fix crash; probably an OpenMotif bug + const char* val = value.c_str() ? value.c_str() : ""; XtVaSetValues( GetXmText(this), - XmNvalue, wxConstCast(value.c_str(), char), + XmNvalue, wxConstCast(val, char), NULL); m_inSetValue = false; @@ -229,6 +231,8 @@ void wxComboBox::Clear() void wxComboBox::SetSelection (int n) { + m_inSetSelection = true; + #if wxCHECK_LESSTIF() XmListSelectPos (GetXmList(this), n + 1, false); SetValue(GetString(n)); @@ -241,6 +245,8 @@ void wxComboBox::SetSelection (int n) XmNselectedPosition, n, NULL ); #endif + + m_inSetSelection = false; } int wxComboBox::GetSelection (void) const @@ -326,6 +332,8 @@ void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData, { wxComboBox *item = (wxComboBox *) clientData; + if( item->m_inSetSelection ) return; + switch (cbs->reason) { case XmCR_SELECT: @@ -336,7 +344,7 @@ void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData, { wxCommandEvent event (wxEVT_COMMAND_COMBOBOX_SELECTED, item->GetId()); - int idx = cbs->item_position - 1; + int idx = cbs->item_position; event.m_commandInt = idx; event.m_commandString = item->GetString (idx); if ( item->HasClientObjectData() ) @@ -345,7 +353,7 @@ void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData, event.SetClientData( item->GetClientData(idx) ); event.m_extraLong = true; event.SetEventObject(item); - item->ProcessCommand (event); + item->GetEventHandler()->ProcessEvent(event); break; } case XmCR_VALUE_CHANGED: @@ -355,7 +363,7 @@ void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData, event.m_commandString = item->GetValue(); event.m_extraLong = true; event.SetEventObject(item); - item->ProcessCommand (event); + item->GetEventHandler()->ProcessEvent(event); break; } default: diff --git a/src/motif/cursor.cpp b/src/motif/cursor.cpp index 0abb841b46..72425e23d8 100644 --- a/src/motif/cursor.cpp +++ b/src/motif/cursor.cpp @@ -17,6 +17,7 @@ #include "wx/app.h" #include "wx/utils.h" #include "wx/list.h" +#include "wx/window.h" #if wxUSE_IMAGE #include "wx/image.h" #endif diff --git a/src/motif/evtloop.cpp b/src/motif/evtloop.cpp index 217cbfa0ab..f5f5e000df 100644 --- a/src/motif/evtloop.cpp +++ b/src/motif/evtloop.cpp @@ -35,6 +35,7 @@ #include "wx/evtloop.h" #include "wx/event.h" #include "wx/app.h" +#include "wx/window.h" #ifdef __VMS__ #pragma message disable nosimpint @@ -443,7 +444,7 @@ static void wxInputCallback( XtPointer, int* fd, XtInputId* ) static void wxBreakDispatch() { - char dummy; + char dummy = 0; // for valgrind // check if wxWakeUpIdle has already been called fd_set in; diff --git a/src/motif/spinbutt.cpp b/src/motif/spinbutt.cpp index d48978ec07..99bebdfee0 100644 --- a/src/motif/spinbutt.cpp +++ b/src/motif/spinbutt.cpp @@ -209,6 +209,7 @@ bool wxArrowButton::Create( wxSpinButton* parent, wxWindowID id, parentWidget, XmNarrowDirection, arrow_dir, XmNborderWidth, 0, + XmNshadowThickness, 0, NULL ); XtAddCallback( (Widget) m_mainWidget, @@ -364,7 +365,7 @@ void wxSpinButton::Increment( int delta ) wxSize wxSpinButton::DoGetBestSize() const { - return IsVertical() ? wxSize( 24, 34 ) : wxSize( 34, 24 ); + return IsVertical() ? wxSize( 20, 30 ) : wxSize( 30, 20 ); } // Attributes -- 2.45.2