From 6c8a980fc412792e64256724e02e9d387ee38e21 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 22 Oct 1999 18:00:39 +0000 Subject: [PATCH] 1. sorted wxListBox and wxComboBox seem to work under wxGTK 2. to support this, new class wxControlWithItems added (ctrlsub.h/cpp) and the controls sample modified to test it git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4141 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile.in | 14 ++++- distrib/msw/tmake/filelist.txt | 1 + include/wx/choice.h | 84 ++++----------------------- include/wx/ctrlsub.h | 98 ++++++++++++++++++++++++++++++++ include/wx/gtk/choice.h | 21 ++----- include/wx/gtk/listbox.h | 8 +-- include/wx/gtk1/choice.h | 21 ++----- include/wx/gtk1/listbox.h | 8 +-- include/wx/listbox.h | 84 +++++---------------------- include/wx/msw/choice.h | 9 +-- include/wx/msw/listbox.h | 8 +-- samples/controls/controls.cpp | 101 ++++++++++++++++++++++++++------- src/common/choiccmn.cpp | 75 ++++-------------------- src/common/ctrlsub.cpp | 94 ++++++++++++++++++++++++++++++ src/common/lboxcmn.cpp | 65 ++------------------- src/gtk/choice.cpp | 50 +++++++++++----- src/gtk/listbox.cpp | 100 ++++++++++++++++---------------- src/gtk1/choice.cpp | 50 +++++++++++----- src/gtk1/listbox.cpp | 100 ++++++++++++++++---------------- src/msw/choice.cpp | 38 ++++++++++--- src/msw/listbox.cpp | 36 +++++++++--- src/msw/makefile.b32 | 5 +- src/msw/makefile.bcc | 5 +- src/msw/makefile.dos | 8 ++- src/msw/makefile.g95 | 57 +++++++++++++------ src/msw/makefile.sc | 3 +- src/msw/makefile.vc | 3 +- src/msw/makefile.wat | 6 +- 28 files changed, 657 insertions(+), 495 deletions(-) create mode 100644 include/wx/ctrlsub.h create mode 100644 src/common/ctrlsub.cpp diff --git a/Makefile.in b/Makefile.in index c5ee81b384..3a0bc3c7bf 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,5 @@ # -# 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! # @@ -691,6 +691,7 @@ GTK_COMMONOBJS = \ cmndata.o \ config.o \ ctrlcmn.o \ + ctrlsub.o \ date.o \ datstrm.o \ db.o \ @@ -730,6 +731,7 @@ GTK_COMMONOBJS = \ intl.o \ ipcbase.o \ layout.o \ + lboxcmn.o \ list.o \ log.o \ memory.o \ @@ -783,6 +785,7 @@ GTK_COMMONDEPS = \ cmndata.d \ config.d \ ctrlcmn.d \ + ctrlsub.d \ date.d \ datstrm.d \ db.d \ @@ -822,6 +825,7 @@ GTK_COMMONDEPS = \ intl.d \ ipcbase.d \ layout.d \ + lboxcmn.d \ list.d \ log.d \ memory.d \ @@ -1071,6 +1075,7 @@ MOTIF_COMMONOBJS = \ cmndata.o \ config.o \ ctrlcmn.o \ + ctrlsub.o \ date.o \ datstrm.o \ db.o \ @@ -1110,6 +1115,7 @@ MOTIF_COMMONOBJS = \ intl.o \ ipcbase.o \ layout.o \ + lboxcmn.o \ list.o \ log.o \ memory.o \ @@ -1164,6 +1170,7 @@ MOTIF_COMMONDEPS = \ cmndata.d \ config.d \ ctrlcmn.d \ + ctrlsub.d \ date.d \ datstrm.d \ db.d \ @@ -1203,6 +1210,7 @@ MOTIF_COMMONDEPS = \ intl.d \ ipcbase.d \ layout.d \ + lboxcmn.d \ list.d \ log.d \ memory.d \ @@ -1413,6 +1421,7 @@ MSW_COMMONOBJS = \ cmndata.o \ config.o \ ctrlcmn.o \ + ctrlsub.o \ date.o \ datstrm.o \ db.o \ @@ -1452,6 +1461,7 @@ MSW_COMMONOBJS = \ intl.o \ ipcbase.o \ layout.o \ + lboxcmn.o \ list.o \ log.o \ memory.o \ @@ -1506,6 +1516,7 @@ MSW_COMMONDEPS = \ cmndata.d \ config.d \ ctrlcmn.d \ + ctrlsub.d \ date.d \ datstrm.d \ db.d \ @@ -1545,6 +1556,7 @@ MSW_COMMONDEPS = \ intl.d \ ipcbase.d \ layout.d \ + lboxcmn.d \ list.d \ log.d \ memory.d \ diff --git a/distrib/msw/tmake/filelist.txt b/distrib/msw/tmake/filelist.txt index 8dceb25bc8..522a7118a6 100644 --- a/distrib/msw/tmake/filelist.txt +++ b/distrib/msw/tmake/filelist.txt @@ -98,6 +98,7 @@ cmndata.cpp C clipcmn.cpp C config.cpp C B ctrlcmn.cpp C +ctrlsub.cpp C date.cpp C B datstrm.cpp C db.cpp C diff --git a/include/wx/choice.h b/include/wx/choice.h index 50d3b73f03..b0d2a70770 100644 --- a/include/wx/choice.h +++ b/include/wx/choice.h @@ -20,7 +20,7 @@ #pragma interface "choicebase.h" #endif -#include "wx/control.h" // the base class +#include "wx/ctrlsub.h" // the base class // ---------------------------------------------------------------------------- // global data @@ -32,88 +32,26 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxChoiceNameStr; // 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); + }; // ---------------------------------------------------------------------------- diff --git a/include/wx/ctrlsub.h b/include/wx/ctrlsub.h new file mode 100644 index 0000000000..b785bea964 --- /dev/null +++ b/include/wx/ctrlsub.h @@ -0,0 +1,98 @@ +///////////////////////////////////////////////////////////////////////////// +// 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_ + + diff --git a/include/wx/gtk/choice.h b/include/wx/gtk/choice.h index ba5528bbfc..a58c6bb583 100644 --- a/include/wx/gtk/choice.h +++ b/include/wx/gtk/choice.h @@ -51,8 +51,9 @@ public: 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 @@ -65,20 +66,10 @@ public: 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() diff --git a/include/wx/gtk/listbox.h b/include/wx/gtk/listbox.h index a13b937e09..10b0107526 100644 --- a/include/wx/gtk/listbox.h +++ b/include/wx/gtk/listbox.h @@ -69,10 +69,10 @@ public: 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 diff --git a/include/wx/gtk1/choice.h b/include/wx/gtk1/choice.h index ba5528bbfc..a58c6bb583 100644 --- a/include/wx/gtk1/choice.h +++ b/include/wx/gtk1/choice.h @@ -51,8 +51,9 @@ public: 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 @@ -65,20 +66,10 @@ public: 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() diff --git a/include/wx/gtk1/listbox.h b/include/wx/gtk1/listbox.h index a13b937e09..10b0107526 100644 --- a/include/wx/gtk1/listbox.h +++ b/include/wx/gtk1/listbox.h @@ -69,10 +69,10 @@ public: 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 diff --git a/include/wx/listbox.h b/include/wx/listbox.h index 62aee761eb..92c7bf7c08 100644 --- a/include/wx/listbox.h +++ b/include/wx/listbox.h @@ -6,7 +6,7 @@ // Created: 22.10.99 // RCS-ID: $Id$ // Copyright: (c) wxWindows team -// Licence: wxWindows licence +// Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// #ifndef _WX_LISTBOX_H_BASE_ @@ -24,7 +24,7 @@ #if wxUSE_LISTBOX -#include "wx/control.h" // base class +#include "wx/ctrlsub.h" // base class // forward declarations are enough here class WXDLLEXPORT wxArrayInt; @@ -40,21 +40,11 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxListBoxNameStr; // 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); } @@ -71,57 +61,30 @@ public: 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 @@ -130,29 +93,10 @@ protected: { 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; }; // ---------------------------------------------------------------------------- diff --git a/include/wx/msw/choice.h b/include/wx/msw/choice.h index 5e5db6054e..c098da4a0b 100644 --- a/include/wx/msw/choice.h +++ b/include/wx/msw/choice.h @@ -60,16 +60,17 @@ public: 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(); diff --git a/include/wx/msw/listbox.h b/include/wx/msw/listbox.h index 93238f7792..c702b8c1b7 100644 --- a/include/wx/msw/listbox.h +++ b/include/wx/msw/listbox.h @@ -82,10 +82,10 @@ public: 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 diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 22ad149720..e38e0b2eb5 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -104,7 +104,8 @@ public: void OnShowProgress( wxCommandEvent &event ); #endif // wxUSE_SPINBUTTON - wxListBox *m_listbox; + wxListBox *m_listbox, + *m_listboxSorted; wxChoice *m_choice, *m_choiceSorted; wxComboBox *m_combo; @@ -152,9 +153,12 @@ private: }; //---------------------------------------------------------------------- -// main() +// other //---------------------------------------------------------------------- +static void SetControlClientData(const char *name, + wxControlWithItems *control); + IMPLEMENT_APP(MyApp) //---------------------------------------------------------------------- @@ -226,6 +230,7 @@ const int ID_LISTBOX_APPEND = 134; 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; @@ -268,6 +273,7 @@ EVT_SIZE ( MyPanel::OnSize) 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) @@ -385,11 +391,17 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) #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" ); @@ -400,12 +412,12 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) (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" ); @@ -416,6 +428,10 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) 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) ); @@ -603,12 +619,24 @@ void MyPanel::OnPageChanged( wxNotebookEvent &event ) 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 ) @@ -633,39 +661,48 @@ void MyPanel::OnListBoxButtons( 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; } @@ -674,14 +711,24 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event ) 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 ) @@ -1039,3 +1086,17 @@ void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(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)); + } +} diff --git a/src/common/choiccmn.cpp b/src/common/choiccmn.cpp index 09e5d443d5..2e0e59eb66 100644 --- a/src/common/choiccmn.cpp +++ b/src/common/choiccmn.cpp @@ -30,7 +30,6 @@ #ifndef WX_PRECOMP #include "wx/choice.h" - #include "wx/log.h" #endif // ============================================================================ @@ -38,80 +37,26 @@ // ============================================================================ // ---------------------------------------------------------------------------- -// 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); } - - diff --git a/src/common/ctrlsub.cpp b/src/common/ctrlsub.cpp new file mode 100644 index 0000000000..09cff4de8e --- /dev/null +++ b/src/common/ctrlsub.cpp @@ -0,0 +1,94 @@ +/////////////////////////////////////////////////////////////////////////////// +// 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); +} + diff --git a/src/common/lboxcmn.cpp b/src/common/lboxcmn.cpp index 8525ef8104..78cf5a377b 100644 --- a/src/common/lboxcmn.cpp +++ b/src/common/lboxcmn.cpp @@ -6,7 +6,7 @@ // Created: 22.10.99 // RCS-ID: $Id$ // Copyright: (c) wxWindows team -// Licence: wxWindows licence +// Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -67,21 +67,11 @@ void wxListBoxBase::Set(int nItems, const wxString* items, void **clientData) // 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); @@ -89,51 +79,15 @@ bool wxListBoxBase::SetStringSelection(const wxString& s, bool 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); @@ -142,10 +96,3 @@ void wxListBoxBase::SetFirstItem(const wxString& s) DoSetFirstItem(n); } - -void wxListBoxBase::Command(wxCommandEvent & event) -{ - SetSelection(event.m_commandInt, event.m_extraLong); - (void)ProcessEvent(event); -} - diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index 9e209bf95f..e1868bbd1c 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -46,9 +46,17 @@ static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice * 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); } @@ -134,32 +142,32 @@ int wxChoice::DoAppend( const wxString &item ) 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; @@ -167,13 +175,13 @@ void wxChoice::DoSetClientObject( int n, wxClientData* clientData ) 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(); } @@ -186,8 +194,18 @@ void wxChoice::Clear() 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 + // and not wxList 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 ) @@ -246,6 +264,13 @@ int wxChoice::GetSelection() const 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") ); @@ -372,8 +397,7 @@ size_t wxChoice::AppendHelper(GtkWidget *menu, const wxString& item) } else { - // can't use Insert() :-( - m_clientList.Append( (wxObject*) NULL ); + m_clientList.Insert( (wxObject*) NULL ); } } else diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index c09dca4977..82b5bb21c0 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -102,25 +102,28 @@ gtk_listbox_button_release_callback( GtkWidget * WXUNUSED(widget), 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; } @@ -213,14 +216,18 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox 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 { @@ -229,8 +236,6 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox event.m_commandInt = n; - event.SetEventObject( listbox ); - listbox->GetEventHandler()->ProcessEvent( event ); } @@ -317,8 +322,6 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id, for (int i = 0; i < n; i++) { - m_clientData.Append((wxObject *)NULL); - DoAppend(choices[i]); #if 0 @@ -431,7 +434,6 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) // remove the old items wxArrayString deletedLabels; - wxArrayPtrVoid deletedData; #if wxUSE_CHECKLISTBOX wxArrayInt deletedChecks; #endif @@ -446,9 +448,6 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) 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 ) @@ -458,33 +457,28 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) #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 ) @@ -617,32 +611,32 @@ void wxListBox::DoSetItems( const wxArrayString& items, // 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; @@ -650,13 +644,13 @@ void wxListBox::DoSetClientObject( int n, wxClientData* clientData ) 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(); } @@ -667,8 +661,18 @@ void wxListBox::Clear() 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 + // and not wxList 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 ) diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index 9e209bf95f..e1868bbd1c 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -46,9 +46,17 @@ static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice * 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); } @@ -134,32 +142,32 @@ int wxChoice::DoAppend( const wxString &item ) 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; @@ -167,13 +175,13 @@ void wxChoice::DoSetClientObject( int n, wxClientData* clientData ) 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(); } @@ -186,8 +194,18 @@ void wxChoice::Clear() 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 + // and not wxList 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 ) @@ -246,6 +264,13 @@ int wxChoice::GetSelection() const 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") ); @@ -372,8 +397,7 @@ size_t wxChoice::AppendHelper(GtkWidget *menu, const wxString& item) } else { - // can't use Insert() :-( - m_clientList.Append( (wxObject*) NULL ); + m_clientList.Insert( (wxObject*) NULL ); } } else diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index c09dca4977..82b5bb21c0 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -102,25 +102,28 @@ gtk_listbox_button_release_callback( GtkWidget * WXUNUSED(widget), 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; } @@ -213,14 +216,18 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox 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 { @@ -229,8 +236,6 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox event.m_commandInt = n; - event.SetEventObject( listbox ); - listbox->GetEventHandler()->ProcessEvent( event ); } @@ -317,8 +322,6 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id, for (int i = 0; i < n; i++) { - m_clientData.Append((wxObject *)NULL); - DoAppend(choices[i]); #if 0 @@ -431,7 +434,6 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) // remove the old items wxArrayString deletedLabels; - wxArrayPtrVoid deletedData; #if wxUSE_CHECKLISTBOX wxArrayInt deletedChecks; #endif @@ -446,9 +448,6 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) 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 ) @@ -458,33 +457,28 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) #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 ) @@ -617,32 +611,32 @@ void wxListBox::DoSetItems( const wxArrayString& items, // 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; @@ -650,13 +644,13 @@ void wxListBox::DoSetClientObject( int n, wxClientData* clientData ) 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(); } @@ -667,8 +661,18 @@ void wxListBox::Clear() 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 + // and not wxList 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 ) diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index d157992171..ee3e511515 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -104,11 +104,25 @@ void wxChoice::Delete(int n) { 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); } @@ -157,10 +171,20 @@ int wxChoice::FindString(const wxString& s) const #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 ) { @@ -176,7 +200,7 @@ wxString wxChoice::GetString(int n) const // 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 ) { @@ -184,7 +208,7 @@ void wxChoice::DoSetClientData( int n, void* clientData ) } } -void* wxChoice::DoGetClientData( int n ) const +void* wxChoice::DoGetItemClientData( int n ) const { LPARAM rc = SendMessage(GetHwnd(), CB_GETITEMDATA, n, 0); if ( rc == CB_ERR ) @@ -198,14 +222,14 @@ void* wxChoice::DoGetClientData( int n ) const 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); } // ---------------------------------------------------------------------------- diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 3d23429617..06aae2979a 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -261,6 +261,16 @@ void wxListBox::Delete(int 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--; @@ -343,8 +353,6 @@ int wxListBox::FindString(const wxString& s) const void wxListBox::Clear() { - ListBox_ResetContent(GetHwnd()); - #if wxUSE_OWNER_DRAWN size_t uiCount = m_aItems.Count(); while ( uiCount-- != 0 ) { @@ -352,7 +360,17 @@ void wxListBox::Clear() } 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(); @@ -381,12 +399,12 @@ bool wxListBox::IsSelected(int N) const 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") ); @@ -394,12 +412,12 @@ void *wxListBox::DoGetClientData(int n) const 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") ); diff --git a/src/msw/makefile.b32 b/src/msw/makefile.b32 index dae062836b..29370be468 100644 --- a/src/msw/makefile.b32 +++ b/src/msw/makefile.b32 @@ -1,6 +1,6 @@ -# 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! # @@ -115,6 +115,7 @@ COMMONOBJS = \ $(MSWDIR)\cmndata.obj \ $(MSWDIR)\config.obj \ $(MSWDIR)\ctrlcmn.obj \ + $(MSWDIR)\ctrlsub.obj \ $(MSWDIR)\date.obj \ $(MSWDIR)\datstrm.obj \ $(MSWDIR)\db.obj \ @@ -541,6 +542,8 @@ $(MSWDIR)\config.obj: $(COMMDIR)\config.$(SRCSUFF) $(MSWDIR)\ctrlcmn.obj: $(COMMDIR)\ctrlcmn.$(SRCSUFF) +$(MSWDIR)\ctrlsub.obj: $(COMMDIR)\ctrlsub.$(SRCSUFF) + $(MSWDIR)\date.obj: $(COMMDIR)\date.$(SRCSUFF) $(MSWDIR)\datstrm.obj: $(COMMDIR)\datstrm.$(SRCSUFF) diff --git a/src/msw/makefile.bcc b/src/msw/makefile.bcc index 7e6ebc43c0..9882c1ab03 100644 --- a/src/msw/makefile.bcc +++ b/src/msw/makefile.bcc @@ -1,6 +1,6 @@ -# 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! # @@ -106,6 +106,7 @@ COMMONOBJS = \ $(MSWDIR)\cmndata.obj \ $(MSWDIR)\config.obj \ $(MSWDIR)\ctrlcmn.obj \ + $(MSWDIR)\ctrlsub.obj \ $(MSWDIR)\date.obj \ $(MSWDIR)\datstrm.obj \ $(MSWDIR)\db.obj \ @@ -449,6 +450,8 @@ $(MSWDIR)\config.obj: $(COMMDIR)\config.$(SRCSUFF) $(MSWDIR)\ctrlcmn.obj: $(COMMDIR)\ctrlcmn.$(SRCSUFF) +$(MSWDIR)\ctrlsub.obj: $(COMMDIR)\ctrlsub.$(SRCSUFF) + $(MSWDIR)\date.obj: $(COMMDIR)\date.$(SRCSUFF) $(MSWDIR)\datstrm.obj: $(COMMDIR)\datstrm.$(SRCSUFF) diff --git a/src/msw/makefile.dos b/src/msw/makefile.dos index 07543540fa..94e781a7dd 100644 --- a/src/msw/makefile.dos +++ b/src/msw/makefile.dos @@ -1,6 +1,6 @@ -# 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! # @@ -93,6 +93,7 @@ COMMONOBJS = \ $(COMMDIR)\cmndata.obj \ $(COMMDIR)\config.obj \ $(COMMDIR)\ctrlcmn.obj \ + $(COMMDIR)\ctrlsub.obj \ $(COMMDIR)\date.obj \ $(COMMDIR)\datstrm.obj \ $(COMMDIR)\db.obj \ @@ -711,6 +712,11 @@ $(COMMDIR)/ctrlcmn.obj: $*.$(SRCSUFF) $(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) diff --git a/src/msw/makefile.g95 b/src/msw/makefile.g95 index d1288c154e..932f95baa3 100644 --- a/src/msw/makefile.g95 +++ b/src/msw/makefile.g95 @@ -1,4 +1,4 @@ -# 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! # @@ -65,6 +65,7 @@ COMMONOBJS = \ $(COMMDIR)/cmndata.$(OBJSUFF) \ $(COMMDIR)/config.$(OBJSUFF) \ $(COMMDIR)/ctrlcmn.$(OBJSUFF) \ + $(COMMDIR)/ctrlsub.$(OBJSUFF) \ $(COMMDIR)/date.$(OBJSUFF) \ $(COMMDIR)/datstrm.$(OBJSUFF) \ $(COMMDIR)/db.$(OBJSUFF) \ @@ -258,6 +259,15 @@ MSWOBJS = \ $(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) \ @@ -353,7 +363,20 @@ XPMOBJECTS = $(XPMDIR)/crbuffri.o\ $(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) @@ -403,21 +426,21 @@ $(COMMDIR)/lex_yy.c: $(COMMDIR)/doslex.c # 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 diff --git a/src/msw/makefile.sc b/src/msw/makefile.sc index 2fa7566512..4ab10e6849 100644 --- a/src/msw/makefile.sc +++ b/src/msw/makefile.sc @@ -1,6 +1,6 @@ -# 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 @@ -54,6 +54,7 @@ COMMONOBJS = \ $(COMMDIR)\cmndata.obj \ $(COMMDIR)\config.obj \ $(COMMDIR)\ctrlcmn.obj \ + $(COMMDIR)\ctrlsub.obj \ $(COMMDIR)\date.obj \ $(COMMDIR)\datstrm.obj \ $(COMMDIR)\db.obj \ diff --git a/src/msw/makefile.vc b/src/msw/makefile.vc index 3be0732d9e..7d9ab75738 100644 --- a/src/msw/makefile.vc +++ b/src/msw/makefile.vc @@ -1,4 +1,4 @@ -# 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 @@ -132,6 +132,7 @@ COMMONOBJS = \ ..\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 \ diff --git a/src/msw/makefile.wat b/src/msw/makefile.wat index 21a1e94d59..328166092d 100644 --- a/src/msw/makefile.wat +++ b/src/msw/makefile.wat @@ -1,6 +1,6 @@ -# 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 @@ -81,6 +81,7 @@ COMMONOBJS = & cmndata.obj & config.obj & ctrlcmn.obj & + ctrlsub.obj & date.obj & datstrm.obj & db.obj & @@ -579,6 +580,9 @@ config.obj: $(COMMDIR)\config.cpp ctrlcmn.obj: $(COMMDIR)\ctrlcmn.cpp *$(CCC) $(CPPFLAGS) $(IFLAGS) $< +ctrlsub.obj: $(COMMDIR)\ctrlsub.cpp + *$(CCC) $(CPPFLAGS) $(IFLAGS) $< + date.obj: $(COMMDIR)\date.cpp *$(CCC) $(CPPFLAGS) $(IFLAGS) $< -- 2.45.2