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:
Mattia Barbon
2003-03-26 22:20:59 +00:00
parent 6789bce964
commit d8d1818419
11 changed files with 33 additions and 16 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -338,6 +338,7 @@ MyFrame::MyFrame()
wxMenuBar *menu_bar = new wxMenuBar();
menu_bar->Append(file_menu, _T("&File"));
SetIcon(wxICON(mondrian));
SetMenuBar( menu_bar );
CreateStatusBar(2);

View File

@@ -37,7 +37,6 @@
#include "wx/dynarray.h"
#include "wx/arrimpl.cpp"
#include "wx/dcclient.h"
#include "wx/msgdlg.h"
// ----------------------------------------------------------------------------

View File

@@ -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));

View File

@@ -53,7 +53,7 @@
// constants
// ----------------------------------------------------------------------------
static const int wxID_NEXT_TIP = -100; // whatever
static const int wxID_NEXT_TIP = 32000; // whatever
// ----------------------------------------------------------------------------
// private classes

View File

@@ -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:

View File

@@ -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

View File

@@ -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;

View File

@@ -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