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
This commit is contained in:
@@ -27,7 +27,7 @@ class WXDLLEXPORT wxComboBox: public wxChoice
|
|||||||
DECLARE_DYNAMIC_CLASS(wxComboBox)
|
DECLARE_DYNAMIC_CLASS(wxComboBox)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxComboBox() {}
|
wxComboBox() { m_inSetSelection = false; }
|
||||||
~wxComboBox();
|
~wxComboBox();
|
||||||
|
|
||||||
inline wxComboBox(wxWindow *parent, wxWindowID id,
|
inline wxComboBox(wxWindow *parent, wxWindowID id,
|
||||||
@@ -39,6 +39,7 @@ public:
|
|||||||
const wxValidator& validator = wxDefaultValidator,
|
const wxValidator& validator = wxDefaultValidator,
|
||||||
const wxString& name = wxComboBoxNameStr)
|
const wxString& name = wxComboBoxNameStr)
|
||||||
{
|
{
|
||||||
|
m_inSetSelection = false;
|
||||||
Create(parent, id, value, pos, size, n, choices,
|
Create(parent, id, value, pos, size, n, choices,
|
||||||
style, validator, name);
|
style, validator, name);
|
||||||
}
|
}
|
||||||
@@ -94,6 +95,10 @@ protected:
|
|||||||
private:
|
private:
|
||||||
// only implemented for native combo box
|
// only implemented for native combo box
|
||||||
void AdjustDropDownListSize();
|
void AdjustDropDownListSize();
|
||||||
|
|
||||||
|
// implementation detail, should really be private
|
||||||
|
public:
|
||||||
|
bool m_inSetSelection;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -15,6 +15,10 @@
|
|||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
#include "X11/Xlib.h"
|
#include "X11/Xlib.h"
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxFont;
|
||||||
|
class WXDLLEXPORT wxWindow;
|
||||||
|
class WXDLLEXPORT wxSize;
|
||||||
|
|
||||||
#include "wx/x11/privx.h"
|
#include "wx/x11/privx.h"
|
||||||
|
|
||||||
// Put any private declarations here: native Motif types may be used because
|
// Put any private declarations here: native Motif types may be used because
|
||||||
|
@@ -337,7 +337,8 @@ MyFrame::MyFrame()
|
|||||||
|
|
||||||
wxMenuBar *menu_bar = new wxMenuBar();
|
wxMenuBar *menu_bar = new wxMenuBar();
|
||||||
menu_bar->Append(file_menu, _T("&File"));
|
menu_bar->Append(file_menu, _T("&File"));
|
||||||
|
|
||||||
|
SetIcon(wxICON(mondrian));
|
||||||
SetMenuBar( menu_bar );
|
SetMenuBar( menu_bar );
|
||||||
|
|
||||||
CreateStatusBar(2);
|
CreateStatusBar(2);
|
||||||
|
@@ -41,4 +41,4 @@ static char *mondrian_xpm[] = {
|
|||||||
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
||||||
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
||||||
" "
|
" "
|
||||||
};
|
};
|
||||||
|
@@ -37,7 +37,6 @@
|
|||||||
#include "wx/dynarray.h"
|
#include "wx/dynarray.h"
|
||||||
#include "wx/arrimpl.cpp"
|
#include "wx/arrimpl.cpp"
|
||||||
#include "wx/dcclient.h"
|
#include "wx/dcclient.h"
|
||||||
#include "wx/msgdlg.h"
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -33,8 +33,6 @@
|
|||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/dc.h"
|
#include "wx/dc.h"
|
||||||
#include "wx/app.h"
|
|
||||||
#include "wx/frame.h"
|
|
||||||
#include "wx/stattext.h"
|
#include "wx/stattext.h"
|
||||||
#include "wx/statbox.h"
|
#include "wx/statbox.h"
|
||||||
#include "wx/button.h"
|
#include "wx/button.h"
|
||||||
@@ -42,7 +40,6 @@
|
|||||||
#include "wx/textctrl.h"
|
#include "wx/textctrl.h"
|
||||||
#include "wx/radiobox.h"
|
#include "wx/radiobox.h"
|
||||||
#include "wx/filedlg.h"
|
#include "wx/filedlg.h"
|
||||||
#include "wx/choice.h"
|
|
||||||
#include "wx/combobox.h"
|
#include "wx/combobox.h"
|
||||||
#include "wx/intl.h"
|
#include "wx/intl.h"
|
||||||
#include "wx/sizer.h"
|
#include "wx/sizer.h"
|
||||||
@@ -506,7 +503,7 @@ bool wxGenericPrintSetupDialog::TransferDataFromWindow()
|
|||||||
int selectedItem = m_paperTypeChoice->GetSelection();
|
int selectedItem = m_paperTypeChoice->GetSelection();
|
||||||
if (selectedItem != -1)
|
if (selectedItem != -1)
|
||||||
{
|
{
|
||||||
wxPrintPaperType *paper = (wxPrintPaperType *)wxThePrintPaperDatabase->Nth(selectedItem)->Data();
|
wxPrintPaperType *paper = (wxPrintPaperType*)wxThePrintPaperDatabase->Item(selectedItem)->GetData();
|
||||||
if (paper != NULL)
|
if (paper != NULL)
|
||||||
m_printData.SetPaperId( paper->GetId());
|
m_printData.SetPaperId( paper->GetId());
|
||||||
}
|
}
|
||||||
@@ -772,7 +769,7 @@ bool wxGenericPageSetupDialog::TransferDataFromWindow()
|
|||||||
int selectedItem = m_paperTypeChoice->GetSelection();
|
int selectedItem = m_paperTypeChoice->GetSelection();
|
||||||
if (selectedItem != -1)
|
if (selectedItem != -1)
|
||||||
{
|
{
|
||||||
wxPrintPaperType *paper = (wxPrintPaperType *)wxThePrintPaperDatabase->Nth(selectedItem)->Data();
|
wxPrintPaperType *paper = (wxPrintPaperType*)wxThePrintPaperDatabase->Item(selectedItem)->GetData();
|
||||||
if ( paper )
|
if ( paper )
|
||||||
{
|
{
|
||||||
m_pageData.SetPaperSize(wxSize(paper->GetWidth()/10, paper->GetHeight()/10));
|
m_pageData.SetPaperSize(wxSize(paper->GetWidth()/10, paper->GetHeight()/10));
|
||||||
|
@@ -53,7 +53,7 @@
|
|||||||
// constants
|
// constants
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
static const int wxID_NEXT_TIP = -100; // whatever
|
static const int wxID_NEXT_TIP = 32000; // whatever
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// private classes
|
// private classes
|
||||||
|
@@ -179,8 +179,10 @@ void wxComboBox::SetValue(const wxString& value)
|
|||||||
{
|
{
|
||||||
m_inSetValue = true;
|
m_inSetValue = true;
|
||||||
|
|
||||||
|
// Fix crash; probably an OpenMotif bug
|
||||||
|
const char* val = value.c_str() ? value.c_str() : "";
|
||||||
XtVaSetValues( GetXmText(this),
|
XtVaSetValues( GetXmText(this),
|
||||||
XmNvalue, wxConstCast(value.c_str(), char),
|
XmNvalue, wxConstCast(val, char),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
m_inSetValue = false;
|
m_inSetValue = false;
|
||||||
@@ -229,6 +231,8 @@ void wxComboBox::Clear()
|
|||||||
|
|
||||||
void wxComboBox::SetSelection (int n)
|
void wxComboBox::SetSelection (int n)
|
||||||
{
|
{
|
||||||
|
m_inSetSelection = true;
|
||||||
|
|
||||||
#if wxCHECK_LESSTIF()
|
#if wxCHECK_LESSTIF()
|
||||||
XmListSelectPos (GetXmList(this), n + 1, false);
|
XmListSelectPos (GetXmList(this), n + 1, false);
|
||||||
SetValue(GetString(n));
|
SetValue(GetString(n));
|
||||||
@@ -241,6 +245,8 @@ void wxComboBox::SetSelection (int n)
|
|||||||
XmNselectedPosition, n,
|
XmNselectedPosition, n,
|
||||||
NULL );
|
NULL );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
m_inSetSelection = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxComboBox::GetSelection (void) const
|
int wxComboBox::GetSelection (void) const
|
||||||
@@ -326,6 +332,8 @@ void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData,
|
|||||||
{
|
{
|
||||||
wxComboBox *item = (wxComboBox *) clientData;
|
wxComboBox *item = (wxComboBox *) clientData;
|
||||||
|
|
||||||
|
if( item->m_inSetSelection ) return;
|
||||||
|
|
||||||
switch (cbs->reason)
|
switch (cbs->reason)
|
||||||
{
|
{
|
||||||
case XmCR_SELECT:
|
case XmCR_SELECT:
|
||||||
@@ -336,7 +344,7 @@ void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData,
|
|||||||
{
|
{
|
||||||
wxCommandEvent event (wxEVT_COMMAND_COMBOBOX_SELECTED,
|
wxCommandEvent event (wxEVT_COMMAND_COMBOBOX_SELECTED,
|
||||||
item->GetId());
|
item->GetId());
|
||||||
int idx = cbs->item_position - 1;
|
int idx = cbs->item_position;
|
||||||
event.m_commandInt = idx;
|
event.m_commandInt = idx;
|
||||||
event.m_commandString = item->GetString (idx);
|
event.m_commandString = item->GetString (idx);
|
||||||
if ( item->HasClientObjectData() )
|
if ( item->HasClientObjectData() )
|
||||||
@@ -345,7 +353,7 @@ void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData,
|
|||||||
event.SetClientData( item->GetClientData(idx) );
|
event.SetClientData( item->GetClientData(idx) );
|
||||||
event.m_extraLong = true;
|
event.m_extraLong = true;
|
||||||
event.SetEventObject(item);
|
event.SetEventObject(item);
|
||||||
item->ProcessCommand (event);
|
item->GetEventHandler()->ProcessEvent(event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XmCR_VALUE_CHANGED:
|
case XmCR_VALUE_CHANGED:
|
||||||
@@ -355,7 +363,7 @@ void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData,
|
|||||||
event.m_commandString = item->GetValue();
|
event.m_commandString = item->GetValue();
|
||||||
event.m_extraLong = true;
|
event.m_extraLong = true;
|
||||||
event.SetEventObject(item);
|
event.SetEventObject(item);
|
||||||
item->ProcessCommand (event);
|
item->GetEventHandler()->ProcessEvent(event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/list.h"
|
#include "wx/list.h"
|
||||||
|
#include "wx/window.h"
|
||||||
#if wxUSE_IMAGE
|
#if wxUSE_IMAGE
|
||||||
#include "wx/image.h"
|
#include "wx/image.h"
|
||||||
#endif
|
#endif
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include "wx/evtloop.h"
|
#include "wx/evtloop.h"
|
||||||
#include "wx/event.h"
|
#include "wx/event.h"
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
|
#include "wx/window.h"
|
||||||
|
|
||||||
#ifdef __VMS__
|
#ifdef __VMS__
|
||||||
#pragma message disable nosimpint
|
#pragma message disable nosimpint
|
||||||
@@ -443,7 +444,7 @@ static void wxInputCallback( XtPointer, int* fd, XtInputId* )
|
|||||||
|
|
||||||
static void wxBreakDispatch()
|
static void wxBreakDispatch()
|
||||||
{
|
{
|
||||||
char dummy;
|
char dummy = 0; // for valgrind
|
||||||
|
|
||||||
// check if wxWakeUpIdle has already been called
|
// check if wxWakeUpIdle has already been called
|
||||||
fd_set in;
|
fd_set in;
|
||||||
|
@@ -209,6 +209,7 @@ bool wxArrowButton::Create( wxSpinButton* parent, wxWindowID id,
|
|||||||
parentWidget,
|
parentWidget,
|
||||||
XmNarrowDirection, arrow_dir,
|
XmNarrowDirection, arrow_dir,
|
||||||
XmNborderWidth, 0,
|
XmNborderWidth, 0,
|
||||||
|
XmNshadowThickness, 0,
|
||||||
NULL );
|
NULL );
|
||||||
|
|
||||||
XtAddCallback( (Widget) m_mainWidget,
|
XtAddCallback( (Widget) m_mainWidget,
|
||||||
@@ -364,7 +365,7 @@ void wxSpinButton::Increment( int delta )
|
|||||||
|
|
||||||
wxSize wxSpinButton::DoGetBestSize() const
|
wxSize wxSpinButton::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
return IsVertical() ? wxSize( 24, 34 ) : wxSize( 34, 24 );
|
return IsVertical() ? wxSize( 20, 30 ) : wxSize( 30, 20 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attributes
|
// Attributes
|
||||||
|
Reference in New Issue
Block a user