#
-# This file was automatically generated by tmake at 15:16, 1999/10/21
+# This file was automatically generated by tmake at 18:37, 1999/10/22
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
#
cmndata.o \
config.o \
ctrlcmn.o \
+ ctrlsub.o \
date.o \
datstrm.o \
db.o \
intl.o \
ipcbase.o \
layout.o \
+ lboxcmn.o \
list.o \
log.o \
memory.o \
cmndata.d \
config.d \
ctrlcmn.d \
+ ctrlsub.d \
date.d \
datstrm.d \
db.d \
intl.d \
ipcbase.d \
layout.d \
+ lboxcmn.d \
list.d \
log.d \
memory.d \
cmndata.o \
config.o \
ctrlcmn.o \
+ ctrlsub.o \
date.o \
datstrm.o \
db.o \
intl.o \
ipcbase.o \
layout.o \
+ lboxcmn.o \
list.o \
log.o \
memory.o \
cmndata.d \
config.d \
ctrlcmn.d \
+ ctrlsub.d \
date.d \
datstrm.d \
db.d \
intl.d \
ipcbase.d \
layout.d \
+ lboxcmn.d \
list.d \
log.d \
memory.d \
cmndata.o \
config.o \
ctrlcmn.o \
+ ctrlsub.o \
date.o \
datstrm.o \
db.o \
intl.o \
ipcbase.o \
layout.o \
+ lboxcmn.o \
list.o \
log.o \
memory.o \
cmndata.d \
config.d \
ctrlcmn.d \
+ ctrlsub.d \
date.d \
datstrm.d \
db.d \
intl.d \
ipcbase.d \
layout.d \
+ lboxcmn.d \
list.d \
log.d \
memory.d \
clipcmn.cpp C
config.cpp C B
ctrlcmn.cpp C
+ctrlsub.cpp C
date.cpp C B
datstrm.cpp C
db.cpp C
#pragma interface "choicebase.h"
#endif
-#include "wx/control.h" // the base class
+#include "wx/ctrlsub.h" // the base class
// ----------------------------------------------------------------------------
// global data
// wxChoice allows to select one of a non-modifiable list of strings
// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxChoiceBase : public wxControl
+class WXDLLEXPORT wxChoiceBase : public wxControlWithItems
{
public:
- // ctor
- wxChoiceBase() { m_clientDataItemsType = ClientData_None; }
-
- // add a new item to the list
- // no client data
- void Append(const wxString& item) { DoAppend(item); }
- // with client data which belongs to the caller
- void Append(const wxString &item, void* clientData)
- { int n = DoAppend(item); SetClientData(n, clientData); }
- // with client data which will be deleted by the control
- void Append(const wxString &item, wxClientData* clientData)
- { int n = DoAppend(item); SetClientObject(n, clientData); }
-
- // delete items from the list
- // one item
- virtual void Delete(int n) = 0;
- // all of them
- virtual void Clear() = 0;
-
- // selection (at most one item may be selected in wxChoice)
- // get the index of currently selected item or -1
- virtual int GetSelection() const = 0;
- // get the text of the currently selected item or empty string
- virtual wxString GetStringSelection() const;
-
- // set selectionto current item
- virtual void SetSelection(int n) = 0;
- // set selection to the current item, returns TRUE if ok
- virtual bool SetStringSelection(const wxString& sel);
+ // all generic methods are in wxControlWithItems
- // accessors to the list of strings
- // get the number of items in the list of strings
- virtual int GetCount() const = 0;
+ // single selection logic
+ virtual void SetSelection(int n) = 0;
+ virtual bool SetStringSelection(const wxString& s);
- // find string in the list, return wxNOT_FOUND if not found
- virtual int FindString(const wxString& s) const = 0;
- // get the string with the specified index
- virtual wxString GetString(int n) const = 0;
+ // don't override this
+ virtual void Select(int n) { SetSelection(n); }
// set/get the number of columns in the control (as they're not supporte on
// most platforms, they do nothing by default)
virtual void SetColumns(int WXUNUSED(n) = 1 ) { }
virtual int GetColumns() const { return 1 ; }
- // client data
- // untyped (isn't deleted by the control)
- void SetClientData( int n, void* clientData );
- void* GetClientData( int n ) const;
- // typed (is owned and deleted by the control)
- void SetClientObject( int n, wxClientData* clientData );
- wxClientData* GetClientObject( int n ) const;
-
- // emulate selecting the item event.GetInt() from the control
- virtual void Command(wxCommandEvent &event);
-
- // deprecated functions, heer for backwards compatibility only
- int Number() const { return GetCount(); }
-
-protected:
- // pure virtuals to implement in the derived classes
- virtual int DoAppend(const wxString& item) = 0;
-
- virtual void DoSetClientData( int n, void* clientData ) = 0;
- virtual void* DoGetClientData( int n ) const = 0;
- virtual void DoSetClientObject( int n, wxClientData* clientData ) = 0;
- virtual wxClientData* DoGetClientObject( int n ) const = 0;
-
- // the above pure virtuals hide these virtuals in wxWindowBase
- virtual void DoSetClientData(void* clientData )
- { wxWindowBase::DoSetClientData(clientData); };
- virtual void* DoGetClientData() const
- { return(wxWindowBase::DoGetClientData()); };
- virtual void DoSetClientObject( wxClientData* clientData )
- { wxWindowBase::DoSetClientObject(clientData); };
- virtual wxClientData* DoGetClientObject() const
- { return(wxWindowBase::DoGetClientObject()); };
-
- // the type of the client data for the items
- wxClientDataType m_clientDataItemsType;
+ // emulate selecting the item event.GetInt()
+ void Command(wxCommandEvent& event);
+
};
// ----------------------------------------------------------------------------
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: wx/ctrlsub.h (read: "wxConTRoL with SUBitems")
+// Purpose: wxControlWithItems interface
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 22.10.99
+// RCS-ID: $Id$
+// Copyright: (c) wxWindows team
+// Licence: wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_CTRLSUB_H_BASE_
+#define _WX_CTRLSUB_H_BASE_
+
+#ifdef __GNUG__
+ #pragma interface "controlwithitems.h"
+#endif
+
+#include "wx/control.h" // base class
+
+// ----------------------------------------------------------------------------
+// wxControlWithItems defines an interface which is implemented by all controls
+// which have string subitems each of which may be selected.
+//
+// Examples: wxListBox, wxCheckListBox, wxChoice and wxComboBox
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxControlWithItems : public wxControl
+{
+public:
+ wxControlWithItems() { m_clientDataItemsType = ClientData_None; }
+
+ // adding items
+ // ------------
+
+ void Append(const wxString& item)
+ { DoAppend(item); }
+ void Append(const wxString& item, void *clientData)
+ { int n = DoAppend(item); SetClientData(n, clientData); }
+ void Append(const wxString& item, wxClientData *clientData)
+ { int n = DoAppend(item); SetClientObject(n, clientData); }
+
+ // deleting items
+ // --------------
+
+ virtual void Clear() = 0;
+ virtual void Delete(int n) = 0;
+
+ // accessing strings
+ // -----------------
+
+ virtual int GetCount() const = 0;
+ virtual wxString GetString(int n) const = 0;
+ virtual void SetString(int n, const wxString& s) = 0;
+ virtual int FindString(const wxString& s) const = 0;
+
+ // selection
+ // ---------
+
+ virtual void Select(int n) = 0;
+ virtual int GetSelection() const = 0;
+
+ wxString GetStringSelection() const;
+
+ // misc
+ // ----
+
+ // client data stuff
+ void SetClientData(int n, void* clientData);
+ void* GetClientData(int n) const;
+
+ void SetClientObject(int n, wxClientData* clientData);
+ wxClientData* GetClientObject(int n) const;
+
+ bool HasClientObjectData() const
+ { return m_clientDataItemsType == ClientData_Object; }
+ bool HasClientUntypedData() const
+ { return m_clientDataItemsType == ClientData_Void; }
+
+ // compatibility - these functions are deprecated, use the new ones
+ // instead
+ int Number() const { return GetCount(); }
+
+protected:
+ virtual int DoAppend(const wxString& item) = 0;
+
+ virtual void DoSetItemClientData(int n, void* clientData) = 0;
+ virtual void* DoGetItemClientData(int n) const = 0;
+ virtual void DoSetItemClientObject(int n, wxClientData* clientData) = 0;
+ virtual wxClientData* DoGetItemClientObject(int n) const = 0;
+
+ // the type of the client data for the items
+ wxClientDataType m_clientDataItemsType;
+};
+
+#endif // _WX_CTRLSUB_H_BASE_
+
+
void SetSelection( int n );
virtual int GetCount() const;
- int FindString( const wxString &string ) const;
+ int FindString( const wxString& string ) const;
wxString GetString( int n ) const;
+ void SetString( int n, const wxString& string );
// implementation
wxList m_clientList; // contains the client data for the items
protected:
virtual int DoAppend(const wxString& item);
- virtual void DoSetClientData( int n, void* clientData );
- virtual void* DoGetClientData( int n ) const;
- virtual void DoSetClientObject( int n, wxClientData* clientData );
- virtual wxClientData* DoGetClientObject( int n ) const;
-
- // the above virtuals hide these virtuals in wxChoiceBase
- virtual void DoSetClientData(void* clientData )
- { wxWindowBase::DoSetClientData(clientData); };
- virtual void* DoGetClientData() const
- { return(wxWindowBase::DoGetClientData()); };
- virtual void DoSetClientObject( wxClientData* clientData )
- { wxWindowBase::DoSetClientObject(clientData); };
- virtual wxClientData* DoGetClientObject() const
- { return(wxWindowBase::DoGetClientObject()); };
+ virtual void DoSetItemClientData( int n, void* clientData );
+ virtual void* DoGetItemClientData( int n ) const;
+ virtual void DoSetItemClientObject( int n, wxClientData* clientData );
+ virtual wxClientData* DoGetItemClientObject( int n ) const;
private:
// common part of Create() and DoAppend()
virtual void DoSetFirstItem(int n);
- virtual void DoSetClientData(int n, void* clientData);
- virtual void* DoGetClientData(int n) const;
- virtual void DoSetClientObject(int n, wxClientData* clientData);
- virtual wxClientData* DoGetClientObject(int n) const;
+ virtual void DoSetItemClientData(int n, void* clientData);
+ virtual void* DoGetItemClientData(int n) const;
+ virtual void DoSetItemClientObject(int n, wxClientData* clientData);
+ virtual wxClientData* DoGetItemClientObject(int n) const;
// implementation from now on
void SetSelection( int n );
virtual int GetCount() const;
- int FindString( const wxString &string ) const;
+ int FindString( const wxString& string ) const;
wxString GetString( int n ) const;
+ void SetString( int n, const wxString& string );
// implementation
wxList m_clientList; // contains the client data for the items
protected:
virtual int DoAppend(const wxString& item);
- virtual void DoSetClientData( int n, void* clientData );
- virtual void* DoGetClientData( int n ) const;
- virtual void DoSetClientObject( int n, wxClientData* clientData );
- virtual wxClientData* DoGetClientObject( int n ) const;
-
- // the above virtuals hide these virtuals in wxChoiceBase
- virtual void DoSetClientData(void* clientData )
- { wxWindowBase::DoSetClientData(clientData); };
- virtual void* DoGetClientData() const
- { return(wxWindowBase::DoGetClientData()); };
- virtual void DoSetClientObject( wxClientData* clientData )
- { wxWindowBase::DoSetClientObject(clientData); };
- virtual wxClientData* DoGetClientObject() const
- { return(wxWindowBase::DoGetClientObject()); };
+ virtual void DoSetItemClientData( int n, void* clientData );
+ virtual void* DoGetItemClientData( int n ) const;
+ virtual void DoSetItemClientObject( int n, wxClientData* clientData );
+ virtual wxClientData* DoGetItemClientObject( int n ) const;
private:
// common part of Create() and DoAppend()
virtual void DoSetFirstItem(int n);
- virtual void DoSetClientData(int n, void* clientData);
- virtual void* DoGetClientData(int n) const;
- virtual void DoSetClientObject(int n, wxClientData* clientData);
- virtual wxClientData* DoGetClientObject(int n) const;
+ virtual void DoSetItemClientData(int n, void* clientData);
+ virtual void* DoGetItemClientData(int n) const;
+ virtual void DoSetItemClientObject(int n, wxClientData* clientData);
+ virtual wxClientData* DoGetItemClientObject(int n) const;
// implementation from now on
// Created: 22.10.99
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
-// Licence: wxWindows licence
+// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_LISTBOX_H_BASE_
#if wxUSE_LISTBOX
-#include "wx/control.h" // base class
+#include "wx/ctrlsub.h" // base class
// forward declarations are enough here
class WXDLLEXPORT wxArrayInt;
// wxListBox interface is defined by the class wxListBoxBase
// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxListBoxBase : public wxControl
+class WXDLLEXPORT wxListBoxBase : public wxControlWithItems
{
public:
- // ctor
- wxListBoxBase() { m_clientDataItemsType = ClientData_None; }
-
- // adding items
- // ------------
-
- void Append(const wxString& item)
- { DoAppend(item); }
- void Append(const wxString& item, void *clientData)
- { int n = DoAppend(item); SetClientData(n, clientData); }
- void Append(const wxString& item, wxClientData *clientData)
- { int n = DoAppend(item); SetClientObject(n, clientData); }
+ // all generic methods are in wxControlWithItems, except for the following
+ // ones which are not yet implemented by wxChoice/wxCombobox
void Insert(const wxString& item, int pos)
{ DoInsert(item, pos); }
void Set(const wxArrayString& items, void **clientData = NULL)
{ DoSetItems(items, clientData); }
- // deleting items
- // --------------
-
- virtual void Clear() = 0;
- virtual void Delete(int n) = 0;
-
- // accessing strings
- // -----------------
-
- virtual int GetCount() const = 0;
- virtual wxString GetString(int n) const = 0;
- virtual void SetString(int n, const wxString& s) = 0;
- virtual int FindString(const wxString& s) const = 0;
-
- // selection
- // ---------
-
+ // multiple selection logic
virtual bool IsSelected(int n) const = 0;
virtual void SetSelection(int n, bool select = TRUE) = 0;
- void Select(int n) { SetSelection(n, TRUE); }
+ virtual void Select(int n) { SetSelection(n, TRUE); }
void Deselect(int n) { SetSelection(n, FALSE); }
- virtual int GetSelection() const = 0;
- virtual int GetSelections(wxArrayInt& aSelections) const = 0;
-
- bool SetStringSelection(const wxString& s, bool select = TRUE);
- wxString GetStringSelection() const;
-
- // misc
- // ----
+ virtual bool SetStringSelection(const wxString& s, bool select = TRUE);
- // client data stuff
- void SetClientData( int n, void* clientData );
- void* GetClientData( int n ) const;
-
- void SetClientObject( int n, wxClientData* clientData );
- wxClientData* GetClientObject( int n ) const;
+ // works for single as well as multiple selection listboxes (unlike
+ // GetSelection which only works for listboxes with single selection)
+ virtual int GetSelections(wxArrayInt& aSelections) const = 0;
// Set the specified item at the first visible item or scroll to max
// range.
void SetFirstItem(int n) { DoSetFirstItem(n); }
void SetFirstItem(const wxString& s);
- // emulate selecting or deselecting (depending on event.GetExtraLong())
- // the item event.GetInt() from the control
- virtual void Command(wxCommandEvent &event);
+ // emulate selecting or deselecting the item event.GetInt() (depending on
+ // event.GetExtraLong())
+ void Command(wxCommandEvent& event);
// compatibility - these functions are deprecated, use the new ones
// instead
bool Selected(int n) const { return IsSelected(n); }
- int Number() const { return GetCount(); }
protected:
// NB: due to wxGTK implementation details, DoInsert() is implemented
{ InsertItems(1, &item, pos); }
// to be implemented in derived classes
- virtual int DoAppend(const wxString& item) = 0;
virtual void DoInsertItems(const wxArrayString& items, int pos) = 0;
virtual void DoSetItems(const wxArrayString& items, void **clientData) = 0;
virtual void DoSetFirstItem(int n) = 0;
-
- virtual void DoSetClientData(int n, void* clientData) = 0;
- virtual void* DoGetClientData(int n) const = 0;
- virtual void DoSetClientObject(int n, wxClientData* clientData) = 0;
- virtual wxClientData* DoGetClientObject(int n) const = 0;
-
- // the above pure virtuals hide these virtuals in wxWindowBase
- virtual void DoSetClientData(void* clientData )
- { wxWindowBase::DoSetClientData(clientData); };
- virtual void* DoGetClientData() const
- { return(wxWindowBase::DoGetClientData()); };
- virtual void DoSetClientObject( wxClientData* clientData )
- { wxWindowBase::DoSetClientObject(clientData); };
- virtual wxClientData* DoGetClientObject() const
- { return(wxWindowBase::DoGetClientObject()); };
-
- // the type of the client data for the items
- wxClientDataType m_clientDataItemsType;
};
// ----------------------------------------------------------------------------
virtual int FindString(const wxString& s) const;
virtual wxString GetString(int n) const;
+ virtual void SetString(int n, const wxString& s);
// MSW only
virtual bool MSWCommand(WXUINT param, WXWORD id);
long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
protected:
- virtual void DoSetClientData( int n, void* clientData );
- virtual void* DoGetClientData( int n ) const;
- virtual void DoSetClientObject( int n, wxClientData* clientData );
- virtual wxClientData* DoGetClientObject( int n ) const;
+ virtual void DoSetItemClientData( int n, void* clientData );
+ virtual void* DoGetItemClientData( int n ) const;
+ virtual void DoSetItemClientObject( int n, wxClientData* clientData );
+ virtual wxClientData* DoGetItemClientObject( int n ) const;
// MSW implementation
virtual wxSize DoGetBestSize();
virtual void DoSetFirstItem(int n);
- virtual void DoSetClientData(int n, void* clientData);
- virtual void* DoGetClientData(int n) const;
- virtual void DoSetClientObject(int n, wxClientData* clientData);
- virtual wxClientData* DoGetClientObject(int n) const;
+ virtual void DoSetItemClientData(int n, void* clientData);
+ virtual void* DoGetItemClientData(int n) const;
+ virtual void DoSetItemClientObject(int n, wxClientData* clientData);
+ virtual wxClientData* DoGetItemClientObject(int n) const;
// wxCheckListBox support
#if wxUSE_OWNER_DRAWN
void OnShowProgress( wxCommandEvent &event );
#endif // wxUSE_SPINBUTTON
- wxListBox *m_listbox;
+ wxListBox *m_listbox,
+ *m_listboxSorted;
wxChoice *m_choice,
*m_choiceSorted;
wxComboBox *m_combo;
};
//----------------------------------------------------------------------
-// main()
+// other
//----------------------------------------------------------------------
+static void SetControlClientData(const char *name,
+ wxControlWithItems *control);
+
IMPLEMENT_APP(MyApp)
//----------------------------------------------------------------------
const int ID_LISTBOX_DELETE = 135;
const int ID_LISTBOX_FONT = 136;
const int ID_LISTBOX_ENABLE = 137;
+const int ID_LISTBOX_SORTED = 138;
const int ID_CHOICE = 120;
const int ID_CHOICE_SEL_NUM = 121;
EVT_NOTEBOOK_PAGE_CHANGING(ID_NOTEBOOK, MyPanel::OnPageChanging)
EVT_NOTEBOOK_PAGE_CHANGED(ID_NOTEBOOK, MyPanel::OnPageChanged)
EVT_LISTBOX (ID_LISTBOX, MyPanel::OnListBox)
+EVT_LISTBOX (ID_LISTBOX_SORTED, MyPanel::OnListBox)
EVT_LISTBOX_DCLICK(ID_LISTBOX, MyPanel::OnListBoxDoubleClick)
EVT_BUTTON (ID_LISTBOX_SEL_NUM, MyPanel::OnListBoxButtons)
EVT_BUTTON (ID_LISTBOX_SEL_STR, MyPanel::OnListBoxButtons)
#endif
- wxButton *button = (wxButton*) NULL; /* who did this ? */
- wxPanel *panel = (wxPanel*) NULL;
+ wxPanel *panel = new wxPanel(m_notebook);
+ m_listbox = new wxListBox( panel, ID_LISTBOX,
+ wxPoint(10,10), wxSize(120,70),
+ 5, choices, wxLB_ALWAYS_SB );
+ m_listboxSorted = new wxListBox( panel, ID_LISTBOX_SORTED,
+ wxPoint(10,90), wxSize(120,70),
+ 5, choices, wxLB_SORT );
+
+ SetControlClientData("listbox", m_listbox);
+ SetControlClientData("listbox", m_listboxSorted);
- panel = new wxPanel(m_notebook);
- m_listbox = new wxListBox( panel, ID_LISTBOX, wxPoint(10,10), wxSize(120,70), 5, choices, wxLB_ALWAYS_SB );
m_listbox->SetCursor(*wxCROSS_CURSOR);
#if wxUSE_TOOLTIPS
m_listbox->SetToolTip( "This is a list box" );
(void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
- button = new wxButton( panel, ID_LISTBOX_FONT, "Set &Italic font", wxPoint(340,130), wxSize(140,30) );
+ wxButton *button = new wxButton( panel, ID_LISTBOX_FONT, "Set &Italic font", wxPoint(340,130), wxSize(140,30) );
#if wxUSE_TOOLTIPS
button->SetToolTip( "Press here to set italic font" );
#endif // wxUSE_TOOLTIPS
- m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, "&Disable", wxPoint(20,130) );
+ m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, "&Disable", wxPoint(20,170) );
m_checkbox->SetValue(FALSE);
#if wxUSE_TOOLTIPS
m_checkbox->SetToolTip( "Click here to disable the listbox" );
m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 5, choices );
m_choiceSorted = new wxChoice( panel, ID_CHOICE_SORTED, wxPoint(10,70), wxSize(120,-1),
5, choices, wxCB_SORT );
+
+ SetControlClientData("choice", m_choice);
+ SetControlClientData("choice", m_choiceSorted);
+
m_choice->SetSelection(2);
m_choice->SetBackgroundColour( "red" );
(void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
void MyPanel::OnListBox( wxCommandEvent &event )
{
- m_text->AppendText( "ListBox event selection string is: " );
+ wxListBox *listbox = event.GetId() == ID_LISTBOX ? m_listbox
+ : m_listboxSorted;
+
+ m_text->AppendText( "ListBox event selection string is: '" );
m_text->AppendText( event.GetString() );
- m_text->AppendText( "\n" );
- m_text->AppendText( "ListBox control selection string is: " );
- m_text->AppendText( m_listbox->GetStringSelection() );
- m_text->AppendText( "\n" );
+ m_text->AppendText( "'\n" );
+ m_text->AppendText( "ListBox control selection string is: '" );
+ m_text->AppendText( listbox->GetStringSelection() );
+ m_text->AppendText( "'\n" );
+
+ wxStringClientData *obj = ((wxStringClientData *)event.GetClientObject());
+ m_text->AppendText( "ListBox event client data string is: '" );
+ m_text->AppendText( obj ? obj->GetData() : wxString("none"));
+ m_text->AppendText( "'\n" );
+ m_text->AppendText( "ListBox control client data string is: '" );
+ obj = (wxStringClientData *)listbox->GetClientObject(listbox->GetSelection());
+ m_text->AppendText( obj ? obj->GetData() : wxString("none"));
+ m_text->AppendText( "'\n" );
}
void MyPanel::OnListBoxDoubleClick( wxCommandEvent &event )
cb->SetToolTip( "Click to disable listbox" );
#endif // wxUSE_TOOLTIPS
m_listbox->Enable( event.GetInt() == 0 );
+ m_listboxSorted->Enable( event.GetInt() == 0 );
break;
}
case ID_LISTBOX_SEL_NUM:
{
m_listbox->SetSelection( 2 );
+ m_listboxSorted->SetSelection( 2 );
m_lbSelectThis->WarpPointer( 40, 14 );
break;
}
case ID_LISTBOX_SEL_STR:
{
m_listbox->SetStringSelection( "This" );
+ m_listboxSorted->SetStringSelection( "This" );
m_lbSelectNum->WarpPointer( 40, 14 );
break;
}
case ID_LISTBOX_CLEAR:
{
m_listbox->Clear();
+ m_listboxSorted->Clear();
break;
}
case ID_LISTBOX_APPEND:
{
m_listbox->Append( "Hi!" );
+ m_listboxSorted->Append( "Hi!" );
break;
}
case ID_LISTBOX_DELETE:
{
- int idx = m_listbox->GetSelection();
+ int idx;
+ idx = m_listbox->GetSelection();
m_listbox->Delete( idx );
+ idx = m_listboxSorted->GetSelection();
+ m_listboxSorted->Delete( idx );
break;
}
case ID_LISTBOX_FONT:
{
m_listbox->SetFont( *wxITALIC_FONT );
+ m_listboxSorted->SetFont( *wxITALIC_FONT );
m_checkbox->SetFont( *wxITALIC_FONT );
break;
}
void MyPanel::OnChoice( wxCommandEvent &event )
{
- m_text->AppendText( "Choice event selection string is: " );
+ wxChoice *choice = event.GetId() == ID_CHOICE ? m_choice
+ : m_choiceSorted;
+
+ m_text->AppendText( "Choice event selection string is: '" );
m_text->AppendText( event.GetString() );
- m_text->AppendText( "\n" );
+ m_text->AppendText( "'\n" );
m_text->AppendText( "Choice control selection string is: '" );
- m_text->AppendText( m_choice->GetStringSelection() );
- m_text->AppendText( "' (for unsorted control)\nand '" );
- m_text->AppendText( m_choiceSorted->GetStringSelection() );
- m_text->AppendText( "' (for sorted control)\n" );
+ m_text->AppendText( choice->GetStringSelection() );
+ m_text->AppendText( "'\n" );
+
+ wxStringClientData *obj = ((wxStringClientData *)event.GetClientObject());
+ m_text->AppendText( "Choice event client data string is: '" );
+ m_text->AppendText( obj ? obj->GetData() : wxString("none"));
+ m_text->AppendText( "'\n" );
+ m_text->AppendText( "Choice control client data string is: '" );
+ obj = (wxStringClientData *)choice->GetClientObject(choice->GetSelection());
+ m_text->AppendText( obj ? obj->GetData() : wxString("none"));
+ m_text->AppendText( "'\n" );
}
void MyPanel::OnChoiceButtons( wxCommandEvent &event )
SetStatusText(msg);
}
}
+
+static void SetControlClientData(const char *name,
+ wxControlWithItems *control)
+{
+ size_t count = control->GetCount();
+ for ( size_t n = 0; n < count; n++ )
+ {
+ wxString s;
+ s.Printf("%s client data for '%s'",
+ name, control->GetString(n).c_str());
+
+ control->SetClientObject(n, new wxStringClientData(s));
+ }
+}
#ifndef WX_PRECOMP
#include "wx/choice.h"
- #include "wx/log.h"
#endif
// ============================================================================
// ============================================================================
// ----------------------------------------------------------------------------
-// events
+// selection
// ----------------------------------------------------------------------------
-void wxChoiceBase::Command(wxCommandEvent &event)
+bool wxChoiceBase::SetStringSelection(const wxString& s)
{
- SetSelection(event.GetInt());
- (void)ProcessEvent(event);
-}
-
-// ----------------------------------------------------------------------------
-// string selection management
-// ----------------------------------------------------------------------------
-
-wxString wxChoiceBase::GetStringSelection() const
-{
- int sel = GetSelection();
- wxString str;
- wxCHECK_MSG( sel != wxNOT_FOUND, str, wxT("no selection, hence no string") );
+ int sel = FindString(s);
+ wxCHECK_MSG( sel != -1, FALSE,
+ wxT("invalid string in wxChoice::SetStringSelection") );
- str = GetString(sel);
- return str;
-}
-
-bool wxChoiceBase::SetStringSelection(const wxString& sel)
-{
- int selIndex = FindString(sel);
- wxCHECK_MSG( selIndex != wxNOT_FOUND, FALSE,
- wxT("can't set selection to string not in the control") );
-
- SetSelection(selIndex);
+ Select(sel);
return TRUE;
}
// ----------------------------------------------------------------------------
-// client data
+// misc
// ----------------------------------------------------------------------------
-void wxChoiceBase::SetClientObject(int n, wxClientData *data)
-{
- wxASSERT_MSG( m_clientDataItemsType != ClientData_Void,
- wxT("can't have both object and void client data") );
-
- wxClientData *clientDataOld = DoGetClientObject(n);
- if ( clientDataOld )
- delete clientDataOld;
-
- DoSetClientObject(n, data);
- m_clientDataItemsType = ClientData_Object;
-}
-
-wxClientData *wxChoiceBase::GetClientObject(int n) const
-{
- wxASSERT_MSG( m_clientDataItemsType == ClientData_Object,
- wxT("this window doesn't have object client data") );
-
- return DoGetClientObject(n);
-}
-
-void wxChoiceBase::SetClientData(int n, void *data)
-{
- wxASSERT_MSG( m_clientDataItemsType != ClientData_Object,
- wxT("can't have both object and void client data") );
-
- DoSetClientData(n, data);
- m_clientDataItemsType = ClientData_Void;
-}
-
-void *wxChoiceBase::GetClientData(int n) const
+void wxChoiceBase::Command(wxCommandEvent& event)
{
- wxASSERT_MSG( m_clientDataItemsType == ClientData_Void,
- wxT("this window doesn't have void client data") );
-
- return DoGetClientData(n);
+ SetSelection(event.m_commandInt);
+ (void)ProcessEvent(event);
}
-
-
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: common/ctrlsub.cpp
+// Purpose: wxControlWithItems implementation
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 22.10.99
+// RCS-ID: $Id$
+// Copyright: (c) wxWindows team
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#ifdef __GNUG__
+ #pragma implementation "controlwithitems.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/ctrlsub.h"
+#endif
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// selection
+// ----------------------------------------------------------------------------
+
+wxString wxControlWithItems::GetStringSelection() const
+{
+ wxString s;
+ int sel = GetSelection();
+ if ( sel != -1 )
+ s = GetString(sel);
+
+ return s;
+}
+
+// ----------------------------------------------------------------------------
+// client data
+// ----------------------------------------------------------------------------
+
+void wxControlWithItems::SetClientObject(int n, wxClientData *data)
+{
+ wxASSERT_MSG( m_clientDataItemsType != ClientData_Void,
+ wxT("can't have both object and void client data") );
+
+ wxClientData *clientDataOld = DoGetItemClientObject(n);
+ if ( clientDataOld )
+ delete clientDataOld;
+
+ DoSetItemClientObject(n, data);
+ m_clientDataItemsType = ClientData_Object;
+}
+
+wxClientData *wxControlWithItems::GetClientObject(int n) const
+{
+ wxASSERT_MSG( m_clientDataItemsType == ClientData_Object,
+ wxT("this window doesn't have object client data") );
+
+ return DoGetItemClientObject(n);
+}
+
+void wxControlWithItems::SetClientData(int n, void *data)
+{
+ wxASSERT_MSG( m_clientDataItemsType != ClientData_Object,
+ wxT("can't have both object and void client data") );
+
+ DoSetItemClientData(n, data);
+ m_clientDataItemsType = ClientData_Void;
+}
+
+void *wxControlWithItems::GetClientData(int n) const
+{
+ wxASSERT_MSG( m_clientDataItemsType == ClientData_Void,
+ wxT("this window doesn't have void client data") );
+
+ return DoGetItemClientData(n);
+}
+
// Created: 22.10.99
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
-// Licence: wxWindows licence
+// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// selection
// ----------------------------------------------------------------------------
-wxString wxListBoxBase::GetStringSelection () const
-{
- wxString s;
- int sel = GetSelection();
- if ( sel != -1 )
- s = GetString(sel);
-
- return s;
-}
-
bool wxListBoxBase::SetStringSelection(const wxString& s, bool select)
{
int sel = FindString(s);
wxCHECK_MSG( sel != -1, FALSE,
- wxT("invalid string in wxListBox::SetStringSelection") );
+ wxT("invalid string in SetStringSelection") );
SetSelection(sel, select);
}
// ----------------------------------------------------------------------------
-// client data
+// misc
// ----------------------------------------------------------------------------
-void wxListBoxBase::SetClientObject(int n, wxClientData *data)
-{
- wxASSERT_MSG( m_clientDataItemsType != ClientData_Void,
- wxT("can't have both object and void client data") );
-
- wxClientData *clientDataOld = DoGetClientObject(n);
- if ( clientDataOld )
- delete clientDataOld;
-
- DoSetClientObject(n, data);
- m_clientDataItemsType = ClientData_Object;
-}
-
-wxClientData *wxListBoxBase::GetClientObject(int n) const
-{
- wxASSERT_MSG( m_clientDataItemsType == ClientData_Object,
- wxT("this window doesn't have object client data") );
-
- return DoGetClientObject(n);
-}
-
-void wxListBoxBase::SetClientData(int n, void *data)
+void wxListBoxBase::Command(wxCommandEvent& event)
{
- wxASSERT_MSG( m_clientDataItemsType != ClientData_Object,
- wxT("can't have both object and void client data") );
-
- DoSetClientData(n, data);
- m_clientDataItemsType = ClientData_Void;
-}
-
-void *wxListBoxBase::GetClientData(int n) const
-{
- wxASSERT_MSG( m_clientDataItemsType == ClientData_Void,
- wxT("this window doesn't have void client data") );
-
- return DoGetClientData(n);
+ SetSelection(event.m_commandInt, event.m_extraLong);
+ (void)ProcessEvent(event);
}
-// ----------------------------------------------------------------------------
-// misc
-// ----------------------------------------------------------------------------
-
void wxListBoxBase::SetFirstItem(const wxString& s)
{
int n = FindString(s);
DoSetFirstItem(n);
}
-
-void wxListBoxBase::Command(wxCommandEvent & event)
-{
- SetSelection(event.m_commandInt, event.m_extraLong);
- (void)ProcessEvent(event);
-}
-
if (g_blockEventsOnDrag) return;
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() );
- event.SetInt( choice->GetSelection() );
+ int n = choice->GetSelection();
+
+ event.SetInt( n );
event.SetString( choice->GetStringSelection() );
event.SetEventObject(choice);
+
+ if ( choice->HasClientObjectData() )
+ event.SetClientObject( choice->GetClientObject(n) );
+ else if ( choice->HasClientUntypedData() )
+ event.SetClientData( choice->GetClientData(n) );
+
choice->GetEventHandler()->ProcessEvent(event);
}
return AppendHelper(menu, item);
}
-void wxChoice::DoSetClientData( int n, void* clientData )
+void wxChoice::DoSetItemClientData( int n, void* clientData )
{
wxCHECK_RET( m_widget != NULL, wxT("invalid choice control") );
wxNode *node = m_clientList.Nth( n );
- wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetClientData") );
+ wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetItemClientData") );
node->SetData( (wxObject*) clientData );
}
-void* wxChoice::DoGetClientData( int n ) const
+void* wxChoice::DoGetItemClientData( int n ) const
{
wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid choice control") );
wxNode *node = m_clientList.Nth( n );
- wxCHECK_MSG( node, NULL, wxT("invalid index in wxChoice::DoGetClientData") );
+ wxCHECK_MSG( node, NULL, wxT("invalid index in wxChoice::DoGetItemClientData") );
return node->Data();
}
-void wxChoice::DoSetClientObject( int n, wxClientData* clientData )
+void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, wxT("invalid choice control") );
wxNode *node = m_clientList.Nth( n );
- wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetClientObject") );
+ wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetItemClientObject") );
wxClientData *cd = (wxClientData*) node->Data();
delete cd;
node->SetData( (wxObject*) clientData );
}
-wxClientData* wxChoice::DoGetClientObject( int n ) const
+wxClientData* wxChoice::DoGetItemClientObject( int n ) const
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid choice control") );
wxNode *node = m_clientList.Nth( n );
wxCHECK_MSG( node, (wxClientData *)NULL,
- wxT("invalid index in wxChoice::DoGetClientObject") );
+ wxT("invalid index in wxChoice::DoGetItemClientObject") );
return (wxClientData*) node->Data();
}
GtkWidget *menu = gtk_menu_new();
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
- if ( m_clientDataItemsType == ClientData_Object )
- m_clientList.DeleteContents(TRUE);
+ if ( HasClientObjectData() )
+ {
+ // destroy the data (due to Robert's idea of using wxList<wxObject>
+ // and not wxList<wxClientData> we can't just say
+ // m_clientList.DeleteContents(TRUE) - this would crash!
+ wxNode *node = m_clientList.First();
+ while ( node )
+ {
+ delete (wxClientData *)node->Data();
+ node = node->Next();
+ }
+ }
m_clientList.Clear();
if ( m_strings )
return -1;
}
+void wxChoice::SetString( int WXUNUSED(n), const wxString& WXUNUSED(string) )
+{
+ wxCHECK_RET( m_widget != NULL, wxT("invalid choice") );
+
+ wxFAIL_MSG(wxT("not implemented"));
+}
+
wxString wxChoice::GetString( int n ) const
{
wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid choice") );
}
else
{
- // can't use Insert() :-(
- m_clientList.Append( (wxObject*) NULL );
+ m_clientList.Insert( (wxObject*) NULL );
}
}
else
if (!g_hasDoubleClicked) return FALSE;
- wxCommandEvent event( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, listbox->GetId() );
- event.SetEventObject( listbox );
+ wxCommandEvent event( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, listbox->GetId() );
+ event.SetEventObject( listbox );
- wxArrayInt aSelections;
- int count = listbox->GetSelections(aSelections);
- if ( count > 0 )
- {
- event.m_commandInt = aSelections[0] ;
- event.m_clientData = listbox->GetClientData( event.m_commandInt );
- wxString str(listbox->GetString(event.m_commandInt));
- if (!str.IsEmpty()) event.m_commandString = str;
- }
- else
- {
- event.m_commandInt = -1 ;
- event.m_commandString.Empty();
- }
+ wxArrayInt aSelections;
+ int n, count = listbox->GetSelections(aSelections);
+ if ( count > 0 )
+ {
+ n = aSelections[0];
+ if ( listbox->HasClientObjectData() )
+ event.SetClientObject( listbox->GetClientObject(n) );
+ else if ( listbox->HasClientUntypedData() )
+ event.SetClientData( listbox->GetClientData(n) );
+ event.SetString( listbox->GetString(n) );
+ }
+ else
+ {
+ n = -1;
+ }
- listbox->GetEventHandler()->ProcessEvent( event );
+ event.m_commandInt = n;
+
+ listbox->GetEventHandler()->ProcessEvent( event );
return FALSE;
}
if (g_blockEventsOnDrag) return;
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() );
+ event.SetEventObject( listbox );
wxArrayInt aSelections;
int n, count = listbox->GetSelections(aSelections);
if ( count > 0 )
{
n = aSelections[0];
- event.m_clientData = listbox->m_clientData.Item(n);
- event.m_commandString = listbox->GetString(n);
+ if ( listbox->HasClientObjectData() )
+ event.SetClientObject( listbox->GetClientObject(n) );
+ else if ( listbox->HasClientUntypedData() )
+ event.SetClientData( listbox->GetClientData(n) );
+ event.SetString( listbox->GetString(n) );
}
else
{
event.m_commandInt = n;
- event.SetEventObject( listbox );
-
listbox->GetEventHandler()->ProcessEvent( event );
}
for (int i = 0; i < n; i++)
{
- m_clientData.Append((wxObject *)NULL);
-
DoAppend(choices[i]);
#if 0
// remove the old items
wxArrayString deletedLabels;
- wxArrayPtrVoid deletedData;
#if wxUSE_CHECKLISTBOX
wxArrayInt deletedChecks;
#endif
wxString str(GET_REAL_LABEL(label->label),*wxConvCurrent);
deletedLabels.Add(str);
- // save data
- deletedData.Add(m_clientData.Item(n));
-
#if wxUSE_CHECKLISTBOX
// save check state
if ( m_hasCheckBoxes )
#endif // wxUSE_CHECKLISTBOX
}
- // don't delete contents, the data will be reappended soon
- m_clientData.Clear();
-
size_t nDeletedCount = n;
gtk_list_clear_items( m_list, pos, length );
// now append the new items
+ wxNode *node = m_clientData.Item(pos);
for ( n = 0; n < nItems; n++ )
{
AppendWithoutSorting(items[n]);
- m_clientData.Append((wxObject *)NULL);
+ // make sure we have the correct number of items in this list
+ m_clientData.Insert(node, (wxObject *)NULL);
}
// and append the old items too
- pos += nItems; // now the indices are shifter
+ pos += nItems; // now the indices are shifted
for ( n = 0; n < nDeletedCount; n++ )
{
AppendWithoutSorting(deletedLabels[n]);
- m_clientData.Append((wxObject *)NULL);
-
- if ( m_clientDataItemsType == ClientData_Object )
- SetClientObject(n, (wxClientData *)deletedData[n]);
- else if ( m_clientDataItemsType == ClientData_Void )
- SetClientData(n, deletedData[n]);
+ // the data is already correct - the indices have been rearranged in
+ // such manner that we now correspond to the same node as before
#if wxUSE_CHECKLISTBOX
if ( m_hasCheckBoxes )
// client data
// ----------------------------------------------------------------------------
-void wxListBox::DoSetClientData( int n, void* clientData )
+void wxListBox::DoSetItemClientData( int n, void* clientData )
{
wxCHECK_RET( m_widget != NULL, wxT("invalid listbox control") );
wxNode *node = m_clientData.Nth( n );
- wxCHECK_RET( node, wxT("invalid index in wxListBox::DoSetClientData") );
+ wxCHECK_RET( node, wxT("invalid index in wxListBox::DoSetItemClientData") );
node->SetData( (wxObject*) clientData );
}
-void* wxListBox::DoGetClientData( int n ) const
+void* wxListBox::DoGetItemClientData( int n ) const
{
wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid listbox control") );
wxNode *node = m_clientData.Nth( n );
- wxCHECK_MSG( node, NULL, wxT("invalid index in wxListBox::DoGetClientData") );
+ wxCHECK_MSG( node, NULL, wxT("invalid index in wxListBox::DoGetItemClientData") );
return node->Data();
}
-void wxListBox::DoSetClientObject( int n, wxClientData* clientData )
+void wxListBox::DoSetItemClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, wxT("invalid listbox control") );
wxNode *node = m_clientData.Nth( n );
- wxCHECK_RET( node, wxT("invalid index in wxListBox::DoSetClientObject") );
+ wxCHECK_RET( node, wxT("invalid index in wxListBox::DoSetItemClientObject") );
wxClientData *cd = (wxClientData*) node->Data();
delete cd;
node->SetData( (wxObject*) clientData );
}
-wxClientData* wxListBox::DoGetClientObject( int n ) const
+wxClientData* wxListBox::DoGetItemClientObject( int n ) const
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid listbox control") );
wxNode *node = m_clientData.Nth( n );
wxCHECK_MSG( node, (wxClientData *)NULL,
- wxT("invalid index in wxListBox::DoGetClientObject") );
+ wxT("invalid index in wxListBox::DoGetItemClientObject") );
return (wxClientData*) node->Data();
}
gtk_list_clear_items( m_list, 0, Number() );
- if ( m_clientDataItemsType == ClientData_Object )
- m_clientData.DeleteContents(TRUE);
+ if ( HasClientObjectData() )
+ {
+ // destroy the data (due to Robert's idea of using wxList<wxObject>
+ // and not wxList<wxClientData> we can't just say
+ // m_clientList.DeleteContents(TRUE) - this would crash!
+ wxNode *node = m_clientData.First();
+ while ( node )
+ {
+ delete (wxClientData *)node->Data();
+ node = node->Next();
+ }
+ }
m_clientData.Clear();
if ( m_strings )
if (g_blockEventsOnDrag) return;
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() );
- event.SetInt( choice->GetSelection() );
+ int n = choice->GetSelection();
+
+ event.SetInt( n );
event.SetString( choice->GetStringSelection() );
event.SetEventObject(choice);
+
+ if ( choice->HasClientObjectData() )
+ event.SetClientObject( choice->GetClientObject(n) );
+ else if ( choice->HasClientUntypedData() )
+ event.SetClientData( choice->GetClientData(n) );
+
choice->GetEventHandler()->ProcessEvent(event);
}
return AppendHelper(menu, item);
}
-void wxChoice::DoSetClientData( int n, void* clientData )
+void wxChoice::DoSetItemClientData( int n, void* clientData )
{
wxCHECK_RET( m_widget != NULL, wxT("invalid choice control") );
wxNode *node = m_clientList.Nth( n );
- wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetClientData") );
+ wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetItemClientData") );
node->SetData( (wxObject*) clientData );
}
-void* wxChoice::DoGetClientData( int n ) const
+void* wxChoice::DoGetItemClientData( int n ) const
{
wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid choice control") );
wxNode *node = m_clientList.Nth( n );
- wxCHECK_MSG( node, NULL, wxT("invalid index in wxChoice::DoGetClientData") );
+ wxCHECK_MSG( node, NULL, wxT("invalid index in wxChoice::DoGetItemClientData") );
return node->Data();
}
-void wxChoice::DoSetClientObject( int n, wxClientData* clientData )
+void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, wxT("invalid choice control") );
wxNode *node = m_clientList.Nth( n );
- wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetClientObject") );
+ wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetItemClientObject") );
wxClientData *cd = (wxClientData*) node->Data();
delete cd;
node->SetData( (wxObject*) clientData );
}
-wxClientData* wxChoice::DoGetClientObject( int n ) const
+wxClientData* wxChoice::DoGetItemClientObject( int n ) const
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid choice control") );
wxNode *node = m_clientList.Nth( n );
wxCHECK_MSG( node, (wxClientData *)NULL,
- wxT("invalid index in wxChoice::DoGetClientObject") );
+ wxT("invalid index in wxChoice::DoGetItemClientObject") );
return (wxClientData*) node->Data();
}
GtkWidget *menu = gtk_menu_new();
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
- if ( m_clientDataItemsType == ClientData_Object )
- m_clientList.DeleteContents(TRUE);
+ if ( HasClientObjectData() )
+ {
+ // destroy the data (due to Robert's idea of using wxList<wxObject>
+ // and not wxList<wxClientData> we can't just say
+ // m_clientList.DeleteContents(TRUE) - this would crash!
+ wxNode *node = m_clientList.First();
+ while ( node )
+ {
+ delete (wxClientData *)node->Data();
+ node = node->Next();
+ }
+ }
m_clientList.Clear();
if ( m_strings )
return -1;
}
+void wxChoice::SetString( int WXUNUSED(n), const wxString& WXUNUSED(string) )
+{
+ wxCHECK_RET( m_widget != NULL, wxT("invalid choice") );
+
+ wxFAIL_MSG(wxT("not implemented"));
+}
+
wxString wxChoice::GetString( int n ) const
{
wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid choice") );
}
else
{
- // can't use Insert() :-(
- m_clientList.Append( (wxObject*) NULL );
+ m_clientList.Insert( (wxObject*) NULL );
}
}
else
if (!g_hasDoubleClicked) return FALSE;
- wxCommandEvent event( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, listbox->GetId() );
- event.SetEventObject( listbox );
+ wxCommandEvent event( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, listbox->GetId() );
+ event.SetEventObject( listbox );
- wxArrayInt aSelections;
- int count = listbox->GetSelections(aSelections);
- if ( count > 0 )
- {
- event.m_commandInt = aSelections[0] ;
- event.m_clientData = listbox->GetClientData( event.m_commandInt );
- wxString str(listbox->GetString(event.m_commandInt));
- if (!str.IsEmpty()) event.m_commandString = str;
- }
- else
- {
- event.m_commandInt = -1 ;
- event.m_commandString.Empty();
- }
+ wxArrayInt aSelections;
+ int n, count = listbox->GetSelections(aSelections);
+ if ( count > 0 )
+ {
+ n = aSelections[0];
+ if ( listbox->HasClientObjectData() )
+ event.SetClientObject( listbox->GetClientObject(n) );
+ else if ( listbox->HasClientUntypedData() )
+ event.SetClientData( listbox->GetClientData(n) );
+ event.SetString( listbox->GetString(n) );
+ }
+ else
+ {
+ n = -1;
+ }
- listbox->GetEventHandler()->ProcessEvent( event );
+ event.m_commandInt = n;
+
+ listbox->GetEventHandler()->ProcessEvent( event );
return FALSE;
}
if (g_blockEventsOnDrag) return;
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() );
+ event.SetEventObject( listbox );
wxArrayInt aSelections;
int n, count = listbox->GetSelections(aSelections);
if ( count > 0 )
{
n = aSelections[0];
- event.m_clientData = listbox->m_clientData.Item(n);
- event.m_commandString = listbox->GetString(n);
+ if ( listbox->HasClientObjectData() )
+ event.SetClientObject( listbox->GetClientObject(n) );
+ else if ( listbox->HasClientUntypedData() )
+ event.SetClientData( listbox->GetClientData(n) );
+ event.SetString( listbox->GetString(n) );
}
else
{
event.m_commandInt = n;
- event.SetEventObject( listbox );
-
listbox->GetEventHandler()->ProcessEvent( event );
}
for (int i = 0; i < n; i++)
{
- m_clientData.Append((wxObject *)NULL);
-
DoAppend(choices[i]);
#if 0
// remove the old items
wxArrayString deletedLabels;
- wxArrayPtrVoid deletedData;
#if wxUSE_CHECKLISTBOX
wxArrayInt deletedChecks;
#endif
wxString str(GET_REAL_LABEL(label->label),*wxConvCurrent);
deletedLabels.Add(str);
- // save data
- deletedData.Add(m_clientData.Item(n));
-
#if wxUSE_CHECKLISTBOX
// save check state
if ( m_hasCheckBoxes )
#endif // wxUSE_CHECKLISTBOX
}
- // don't delete contents, the data will be reappended soon
- m_clientData.Clear();
-
size_t nDeletedCount = n;
gtk_list_clear_items( m_list, pos, length );
// now append the new items
+ wxNode *node = m_clientData.Item(pos);
for ( n = 0; n < nItems; n++ )
{
AppendWithoutSorting(items[n]);
- m_clientData.Append((wxObject *)NULL);
+ // make sure we have the correct number of items in this list
+ m_clientData.Insert(node, (wxObject *)NULL);
}
// and append the old items too
- pos += nItems; // now the indices are shifter
+ pos += nItems; // now the indices are shifted
for ( n = 0; n < nDeletedCount; n++ )
{
AppendWithoutSorting(deletedLabels[n]);
- m_clientData.Append((wxObject *)NULL);
-
- if ( m_clientDataItemsType == ClientData_Object )
- SetClientObject(n, (wxClientData *)deletedData[n]);
- else if ( m_clientDataItemsType == ClientData_Void )
- SetClientData(n, deletedData[n]);
+ // the data is already correct - the indices have been rearranged in
+ // such manner that we now correspond to the same node as before
#if wxUSE_CHECKLISTBOX
if ( m_hasCheckBoxes )
// client data
// ----------------------------------------------------------------------------
-void wxListBox::DoSetClientData( int n, void* clientData )
+void wxListBox::DoSetItemClientData( int n, void* clientData )
{
wxCHECK_RET( m_widget != NULL, wxT("invalid listbox control") );
wxNode *node = m_clientData.Nth( n );
- wxCHECK_RET( node, wxT("invalid index in wxListBox::DoSetClientData") );
+ wxCHECK_RET( node, wxT("invalid index in wxListBox::DoSetItemClientData") );
node->SetData( (wxObject*) clientData );
}
-void* wxListBox::DoGetClientData( int n ) const
+void* wxListBox::DoGetItemClientData( int n ) const
{
wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid listbox control") );
wxNode *node = m_clientData.Nth( n );
- wxCHECK_MSG( node, NULL, wxT("invalid index in wxListBox::DoGetClientData") );
+ wxCHECK_MSG( node, NULL, wxT("invalid index in wxListBox::DoGetItemClientData") );
return node->Data();
}
-void wxListBox::DoSetClientObject( int n, wxClientData* clientData )
+void wxListBox::DoSetItemClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, wxT("invalid listbox control") );
wxNode *node = m_clientData.Nth( n );
- wxCHECK_RET( node, wxT("invalid index in wxListBox::DoSetClientObject") );
+ wxCHECK_RET( node, wxT("invalid index in wxListBox::DoSetItemClientObject") );
wxClientData *cd = (wxClientData*) node->Data();
delete cd;
node->SetData( (wxObject*) clientData );
}
-wxClientData* wxListBox::DoGetClientObject( int n ) const
+wxClientData* wxListBox::DoGetItemClientObject( int n ) const
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid listbox control") );
wxNode *node = m_clientData.Nth( n );
wxCHECK_MSG( node, (wxClientData *)NULL,
- wxT("invalid index in wxListBox::DoGetClientObject") );
+ wxT("invalid index in wxListBox::DoGetItemClientObject") );
return (wxClientData*) node->Data();
}
gtk_list_clear_items( m_list, 0, Number() );
- if ( m_clientDataItemsType == ClientData_Object )
- m_clientData.DeleteContents(TRUE);
+ if ( HasClientObjectData() )
+ {
+ // destroy the data (due to Robert's idea of using wxList<wxObject>
+ // and not wxList<wxClientData> we can't just say
+ // m_clientList.DeleteContents(TRUE) - this would crash!
+ wxNode *node = m_clientData.First();
+ while ( node )
+ {
+ delete (wxClientData *)node->Data();
+ node = node->Next();
+ }
+ }
m_clientData.Clear();
if ( m_strings )
{
wxCHECK_RET( n < GetCount(), wxT("invalid item index in wxChoice::Delete") );
+ if ( HasClientObjectData() )
+ {
+ delete GetClientObject(n);
+ }
+
SendMessage(GetHwnd(), CB_DELETESTRING, n, 0);
}
void wxChoice::Clear()
{
+ if ( HasClientObjectData() )
+ {
+ size_t count = GetCount();
+ for ( size_t n = 0; n < count; n++ )
+ {
+ delete GetClientObject(n);
+ }
+ }
+
SendMessage(GetHwnd(), CB_RESETCONTENT, 0, 0);
}
#endif // Watcom/!Watcom
}
+void wxChoice::SetString(int n, const wxString& s)
+{
+ wxFAIL_MSG(wxT("not implemented"));
+
+#if 0 // should do this, but no Insert() so far
+ Delete(n);
+ Insert(n + 1, s);
+#endif
+}
+
wxString wxChoice::GetString(int n) const
{
size_t len = (size_t)::SendMessage(GetHwnd(), CB_GETLBTEXTLEN, n, 0);
- wxString str = "";
+ wxString str;
if (len) {
if ( ::SendMessage(GetHwnd(), CB_GETLBTEXT, n,
(LPARAM)str.GetWriteBuf(len)) == CB_ERR ) {
// client data
// ----------------------------------------------------------------------------
-void wxChoice::DoSetClientData( int n, void* clientData )
+void wxChoice::DoSetItemClientData( int n, void* clientData )
{
if ( SendMessage(GetHwnd(), CB_SETITEMDATA, n, (LPARAM)clientData) == CB_ERR )
{
}
}
-void* wxChoice::DoGetClientData( int n ) const
+void* wxChoice::DoGetItemClientData( int n ) const
{
LPARAM rc = SendMessage(GetHwnd(), CB_GETITEMDATA, n, 0);
if ( rc == CB_ERR )
return (void *)rc;
}
-void wxChoice::DoSetClientObject( int n, wxClientData* clientData )
+void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData )
{
- DoSetClientData(n, clientData);
+ DoSetItemClientData(n, clientData);
}
-wxClientData* wxChoice::DoGetClientObject( int n ) const
+wxClientData* wxChoice::DoGetItemClientObject( int n ) const
{
- return (wxClientData *)DoGetClientData(n);
+ return (wxClientData *)DoGetItemClientData(n);
}
// ----------------------------------------------------------------------------
wxCHECK_RET( N >= 0 && N < m_noItems,
wxT("invalid index in wxListBox::Delete") );
+#if wxUSE_OWNER_DRAWN
+ delete m_aItems[N];
+ m_aItems.Remove(N);
+#else // !wxUSE_OWNER_DRAWN
+ if ( HasClientObjectData() )
+ {
+ delete GetClientObject(N);
+ }
+#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
+
SendMessage(GetHwnd(), LB_DELETESTRING, N, 0);
m_noItems--;
void wxListBox::Clear()
{
- ListBox_ResetContent(GetHwnd());
-
#if wxUSE_OWNER_DRAWN
size_t uiCount = m_aItems.Count();
while ( uiCount-- != 0 ) {
}
m_aItems.Clear();
-#endif // wxUSE_OWNER_DRAWN
+#else // !wxUSE_OWNER_DRAWN
+ if ( HasClientObjectData() )
+ {
+ for ( size_t n = 0; n < (size_t)m_noItems; n++ )
+ {
+ delete GetClientObject(n);
+ }
+ }
+#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
+
+ ListBox_ResetContent(GetHwnd());
m_noItems = 0;
SetHorizontalExtent();
return SendMessage(GetHwnd(), LB_GETSEL, N, 0) == 0 ? FALSE : TRUE;
}
-wxClientData* wxListBox::DoGetClientObject(int n) const
+wxClientData* wxListBox::DoGetItemClientObject(int n) const
{
- return (wxClientData *)DoGetClientData(n);
+ return (wxClientData *)DoGetItemClientData(n);
}
-void *wxListBox::DoGetClientData(int n) const
+void *wxListBox::DoGetItemClientData(int n) const
{
wxCHECK_MSG( n >= 0 && n < m_noItems, NULL,
wxT("invalid index in wxListBox::GetClientData") );
return (void *)SendMessage(GetHwnd(), LB_GETITEMDATA, n, 0);
}
-void wxListBox::DoSetClientObject(int n, wxClientData* clientData)
+void wxListBox::DoSetItemClientObject(int n, wxClientData* clientData)
{
- DoSetClientData(n, clientData);
+ DoSetItemClientData(n, clientData);
}
-void wxListBox::DoSetClientData(int n, void *clientData)
+void wxListBox::DoSetItemClientData(int n, void *clientData)
{
wxCHECK_RET( n >= 0 && n < m_noItems,
wxT("invalid index in wxListBox::SetClientData") );
-# This file was automatically generated by tmake at 16:37, 1999/10/22
+# This file was automatically generated by tmake at 18:37, 1999/10/22
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T!
#
$(MSWDIR)\cmndata.obj \
$(MSWDIR)\config.obj \
$(MSWDIR)\ctrlcmn.obj \
+ $(MSWDIR)\ctrlsub.obj \
$(MSWDIR)\date.obj \
$(MSWDIR)\datstrm.obj \
$(MSWDIR)\db.obj \
$(MSWDIR)\ctrlcmn.obj: $(COMMDIR)\ctrlcmn.$(SRCSUFF)
+$(MSWDIR)\ctrlsub.obj: $(COMMDIR)\ctrlsub.$(SRCSUFF)
+
$(MSWDIR)\date.obj: $(COMMDIR)\date.$(SRCSUFF)
$(MSWDIR)\datstrm.obj: $(COMMDIR)\datstrm.$(SRCSUFF)
-# This file was automatically generated by tmake at 16:37, 1999/10/22
+# This file was automatically generated by tmake at 18:37, 1999/10/22
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T!
#
$(MSWDIR)\cmndata.obj \
$(MSWDIR)\config.obj \
$(MSWDIR)\ctrlcmn.obj \
+ $(MSWDIR)\ctrlsub.obj \
$(MSWDIR)\date.obj \
$(MSWDIR)\datstrm.obj \
$(MSWDIR)\db.obj \
$(MSWDIR)\ctrlcmn.obj: $(COMMDIR)\ctrlcmn.$(SRCSUFF)
+$(MSWDIR)\ctrlsub.obj: $(COMMDIR)\ctrlsub.$(SRCSUFF)
+
$(MSWDIR)\date.obj: $(COMMDIR)\date.$(SRCSUFF)
$(MSWDIR)\datstrm.obj: $(COMMDIR)\datstrm.$(SRCSUFF)
-# This file was automatically generated by tmake at 16:37, 1999/10/22
+# This file was automatically generated by tmake at 18:37, 1999/10/22
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T!
#
$(COMMDIR)\cmndata.obj \
$(COMMDIR)\config.obj \
$(COMMDIR)\ctrlcmn.obj \
+ $(COMMDIR)\ctrlsub.obj \
$(COMMDIR)\date.obj \
$(COMMDIR)\datstrm.obj \
$(COMMDIR)\db.obj \
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
<<
+$(COMMDIR)/ctrlsub.obj: $*.$(SRCSUFF)
+ cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
$(COMMDIR)/date.obj: $*.$(SRCSUFF)
cl @<<
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
-# This file was automatically generated by tmake at 16:37, 1999/10/22
+# This file was automatically generated by tmake at 18:37, 1999/10/22
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T!
#
$(COMMDIR)/cmndata.$(OBJSUFF) \
$(COMMDIR)/config.$(OBJSUFF) \
$(COMMDIR)/ctrlcmn.$(OBJSUFF) \
+ $(COMMDIR)/ctrlsub.$(OBJSUFF) \
$(COMMDIR)/date.$(OBJSUFF) \
$(COMMDIR)/datstrm.$(OBJSUFF) \
$(COMMDIR)/db.$(OBJSUFF) \
$(MSWDIR)/window.$(OBJSUFF) \
$(MSWDIR)/xpmhand.$(OBJSUFF)
+ADVANCEDOBJS = \
+ $(COMMDIR)/odbc.$(OBJSUFF) \
+ $(MSWDIR)/ole/automtn.$(OBJSUFF) \
+ $(MSWDIR)/ole/dataobj.$(OBJSUFF) \
+ $(MSWDIR)/ole/dropsrc.$(OBJSUFF) \
+ $(MSWDIR)/ole/droptgt.$(OBJSUFF) \
+ $(MSWDIR)/ole/oleutils.$(OBJSUFF) \
+ $(MSWDIR)/ole/uuid.$(OBJSUFF)
+
ZLIBOBJS = \
$(ZLIBDIR)/adler32.$(OBJSUFF) \
$(ZLIBDIR)/compress.$(OBJSUFF) \
$(XPMDIR)/wrffrp.o $(XPMDIR)/wrffri.o
OBJECTS = $(MSWOBJS) $(COMMONOBJS) $(GENERICOBJS) $(HTMLOBJS) \
+ $(JPEGOBJS) $(PNGOBJS) $(ZLIBOBJS) # $(ADVANCEDOBJS) # $(XPMOBJECTS)
+
+ifeq ($(MINGW32),1)
+ ifeq ($(MINGW32VERSION),2.95)
+ OBJECTS = $(MSWOBJS) $(COMMONOBJS) $(GENERICOBJS) $(HTMLOBJS) \
+ $(JPEGOBJS) $(PNGOBJS) $(ZLIBOBJS) $(ADVANCEDOBJS) # $(XPMOBJECTS)
+ else
+ OBJECTS = $(MSWOBJS) $(COMMONOBJS) $(GENERICOBJS) $(HTMLOBJS) \
+ $(JPEGOBJS) $(PNGOBJS) $(ZLIBOBJS) # $(XPMOBJECTS)
+ endif
+else
+ OBJECTS = $(MSWOBJS) $(COMMONOBJS) $(GENERICOBJS) $(HTMLOBJS) \
$(JPEGOBJS) $(PNGOBJS) $(ZLIBOBJS) # $(XPMOBJECTS)
+endif
all: $(OBJECTS) $(WXLIB)
# mv y.tab.c $(COMMDIR)/y_tab.c
clean:
- -erase *.o
- -erase *.bak
- -erase core
- -erase ..\common\y_tab.c
- -erase ..\common\lex_yy.c
- -erase ..\common\*.o
- -erase ..\common\*.bak
- -erase ..\generic\*.o
- -erase ..\generic\*.bak
- -erase ..\html\*.o
- -erase ..\png\*.o
- -erase ..\png\*.bak
- -erase ..\zlib\*.o
- -erase ..\zlib\*.bak
- -erase ..\jpeg\*.o
- -erase ..\..\lib\libwx.a
+ rm -f *.o
+ rm -f *.bak
+ rm -f core
+ rm -f ..\common\y_tab.c
+ rm -f ..\common\lex_yy.c
+ rm -f ..\common\*.o
+ rm -f ..\common\*.bak
+ rm -f ..\generic\*.o
+ rm -f ..\generic\*.bak
+ rm -f ..\html\*.o
+ rm -f ..\png\*.o
+ rm -f ..\png\*.bak
+ rm -f ..\zlib\*.o
+ rm -f ..\zlib\*.bak
+ rm -f ..\jpeg\*.o
+ rm -f ..\..\lib\libwx.a
cleanall: clean
-# This file was automatically generated by tmake at 16:37, 1999/10/22
+# This file was automatically generated by tmake at 18:37, 1999/10/22
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T!
# Symantec C++ makefile for the msw objects
$(COMMDIR)\cmndata.obj \
$(COMMDIR)\config.obj \
$(COMMDIR)\ctrlcmn.obj \
+ $(COMMDIR)\ctrlsub.obj \
$(COMMDIR)\date.obj \
$(COMMDIR)\datstrm.obj \
$(COMMDIR)\db.obj \
-# This file was automatically generated by tmake at 16:37, 1999/10/22
+# This file was automatically generated by tmake at 18:37, 1999/10/22
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T!
# File: makefile.vc
..\common\$D\cmndata.obj \
..\common\$D\config.obj \
..\common\$D\ctrlcmn.obj \
+ ..\common\$D\ctrlsub.obj \
..\common\$D\date.obj \
..\common\$D\datstrm.obj \
..\common\$D\db.obj \
-# This file was automatically generated by tmake at 16:37, 1999/10/22
+# This file was automatically generated by tmake at 18:37, 1999/10/22
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T!
#!/binb/wmake.exe
cmndata.obj &
config.obj &
ctrlcmn.obj &
+ ctrlsub.obj &
date.obj &
datstrm.obj &
db.obj &
ctrlcmn.obj: $(COMMDIR)\ctrlcmn.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
+ctrlsub.obj: $(COMMDIR)\ctrlsub.cpp
+ *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
+
date.obj: $(COMMDIR)\date.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<