diff --git a/distrib/msw/generic.rsp b/distrib/msw/generic.rsp index 91194a8388..30d1095f0b 100644 --- a/distrib/msw/generic.rsp +++ b/distrib/msw/generic.rsp @@ -25,6 +25,7 @@ distrib/msw/*.bat distrib/msw/*.cpp distrib/msw/*.txt distrib/msw/tardist +distrib/msw/tarwxmotif distrib/msw/tmake/*.t distrib/msw/tmake/Makefile distrib/msw/tmake/filelist.txt diff --git a/distrib/msw/tardist b/distrib/msw/tardist index 72b1df566e..9896e06500 100644 --- a/distrib/msw/tardist +++ b/distrib/msw/tardist @@ -3,6 +3,7 @@ # Supply a source (e.g. ~/wx2) and destination (e.g. ~/wx2/deliver) init="" +WXVER=2.1.16 if [ $1 = "" ] then exit @@ -24,56 +25,55 @@ cd $1 echo Removing backup files... rm *~ */*~ */*/*~ */*/*/*~ */*/*/*/*~ -rm -f $2/wx200*.tgz +rm -f $2/wx${WXVER}*.tgz rm -f $2/tex2rtf2.tgz rm -f $2/ogl3.tgz -rm -f $2/treedraw.tar.gz -rm -f $2/glcanvas.tar.gz rm -f $2/jpeg.tgz +rm -f $2/tiff.tgz echo Tarring... ### Generic ls `cat $1/distrib/msw/generic.rsp $1/distrib/msw/makefile.rsp` > /tmp/wxgen.txt -tar cvf $2/wx200gen.tar -T /tmp/wxgen.txt -gzip $2/wx200gen.tar -mv $2/wx200gen.tar.gz $2/wx200gen.tgz +tar cvf $2/wx${WXVER}gen.tar -T /tmp/wxgen.txt +gzip $2/wx${WXVER}gen.tar +mv $2/wx${WXVER}gen.tar.gz $2/wx${WXVER}gen.tgz ### wxGTK ls `cat $1/distrib/msw/generic.rsp $1/distrib/msw/gtk.rsp $1/distrib/msw/makefile.rsp` > /tmp/wxgtk.txt -tar cvf $2/wx200gtk.tar -T /tmp/wxgtk.txt -gzip $2/wx200gtk.tar -mv $2/wx200gtk.tar.gz $2/wx200gtk.tgz +tar cvf $2/wx${WXVER}gtk.tar -T /tmp/wxgtk.txt +gzip $2/wx${WXVER}gtk.tar +mv $2/wx${WXVER}gtk.tar.gz $2/wx${WXVER}gtk.tgz ### wxMotif ls `cat $1/distrib/msw/generic.rsp $1/distrib/msw/motif.rsp $1/distrib/msw/makefile.rsp` > /tmp/wxmotif.txt -tar cvf $2/wx200mot.tar -T /tmp/wxmotif.txt -gzip $2/wx200mot.tar -mv $2/wx200mot.tar.gz $2/wx200mot.tgz +tar cvf $2/wx${WXVER}mot.tar -T /tmp/wxmotif.txt +gzip $2/wx${WXVER}mot.tar +mv $2/wx${WXVER}mot.tar.gz $2/wx${WXVER}mot.tgz ### Doc sources ls `cat $1/distrib/msw/docsrc.rsp` > /tmp/docsrc.txt -tar cvf $2/wx200doc.tar -T /tmp/docsrc.txt -gzip $2/wx200doc.tar -mv $2/wx200doc.tar.gz $2/wx200doc.tgz +tar cvf $2/wx${WXVER}doc.tar -T /tmp/docsrc.txt +gzip $2/wx${WXVER}doc.tar +mv $2/wx${WXVER}doc.tar.gz $2/wx${WXVER}doc.tgz ### HTML docs ls `cat $1/distrib/msw/wx_html.rsp` > /tmp/html.txt -tar cvf $2/wx200htm.tar -T /tmp/html.txt -gzip $2/wx200htm.tar -mv $2/wx200htm.tar.gz $2/wx200htm.tgz +tar cvf $2/wx${WXVER}htm.tar -T /tmp/html.txt +gzip $2/wx${WXVER}htm.tar +mv $2/wx${WXVER}htm.tar.gz $2/wx${WXVER}htm.tgz ### PDF docs ls `cat $1/distrib/msw/wx_pdf.rsp` > /tmp/pdf.txt -tar cvf $2/wx200pdf.tar -T /tmp/pdf.txt -gzip $2/wx200pdf.tar -mv $2/wx200pdf.tar.gz $2/wx200pdf.tgz +tar cvf $2/wx${WXVER}pdf.tar -T /tmp/pdf.txt +gzip $2/wx${WXVER}pdf.tar +mv $2/wx${WXVER}pdf.tar.gz $2/wx${WXVER}pdf.tgz ### Stubs files ls `cat $1/distrib/msw/stubs.rsp` > /tmp/stubs.txt -tar cvf $2/wx200stubs.tar -T /tmp/stubs.txt -gzip $2/wx200stubs.tar -mv $2/wx200stubs.tar.gz $2/wx200stubs.tgz +tar cvf $2/wx${WXVER}stubs.tar -T /tmp/stubs.txt +gzip $2/wx${WXVER}stubs.tar +mv $2/wx${WXVER}stubs.tar.gz $2/wx${WXVER}stubs.tgz ### Tex2RTF ls `cat $1/distrib/msw/tex2rtf.rsp` > /tmp/tex2rtf.txt @@ -87,22 +87,16 @@ tar cvf $2/ogl3.tar -T /tmp/ogl.txt gzip $2/ogl3.tar mv $2/ogl3.tar.gz $2/ogl3.tgz -### wxGLCanvas -ls `cat $1/distrib/msw/glcanvas.rsp` > /tmp/glcanvas.txt -tar cvf $2/glcanvas.tar -T /tmp/glcanvas.txt -gzip $2/glcanvas.tar -mv $2/glcanvas.tar.gz $2/glcanvas.tgz - -### wxTreeLayout -ls `cat $1/distrib/msw/wxtree.rsp` > /tmp/wxtree.txt -tar cvf $2/treedraw.tar -T /tmp/wxtree.txt -gzip $2/treedraw.tar -mv $2/treedraw.tar.gz $2/treedraw.tgz - ### JPEG ls `cat $1/distrib/msw/jpeg.rsp` > /tmp/jpeg.txt tar cvf $2/jpeg.tar -T /tmp/jpeg.txt gzip $2/jpeg.tar mv $2/jpeg.tar.gz $2/jpeg.tgz +### TIFF +ls `cat $1/distrib/msw/tiff.rsp` > /tmp/tiff.txt +tar cvf $2/tiff.tar -T /tmp/tiff.txt +gzip $2/tiff.tar +mv $2/tiff.tar.gz $2/tiff.tgz + echo Done! diff --git a/distrib/msw/tarwxmotif b/distrib/msw/tarwxmotif new file mode 100644 index 0000000000..9180511448 --- /dev/null +++ b/distrib/msw/tarwxmotif @@ -0,0 +1,91 @@ +#!/bin/sh +# tardist: make up a tar.gz distribution of wxWindows 2 +# Supply a source (e.g. ~/wx2) and destination (e.g. ~/wx2/deliver) + +init="" +WXVER=2.1.16 +if [ $1 = "" ] +then + exit +fi + +if [ $2 = "" ] +then + exit +fi + +echo About to archive wxWindows: +echo From $1 +echo To $2 +echo CTRL-C if this is not correct. +read dummy + +cd $1 + +echo Removing backup files... +rm *~ */*~ */*/*~ */*/*/*~ */*/*/*/*~ + +rm -f $2/wxMotif-${WXVER}*.tgz +rm -f $2/wxWindows*.tgz +rm -f $2/tex2rtf2.tgz +rm -f $2/ogl3.tgz +rm -f $2/jpeg.tgz +rm -f $2/tiff.tgz + +echo Tarring... + +### wxMotif +ls `cat $1/distrib/msw/generic.rsp $1/distrib/msw/motif.rsp $1/distrib/msw/makefile.rsp $1/distrib/msw/jpeg.rsp $1/distrib/msw/tiff.rsp` > /tmp/wxmotif.txt +tar cvf $2/wxMotif-${WXVER}.tar -T /tmp/wxmotif.txt +gzip $2/wxMotif-${WXVER}.tar +mv $2/wxMotif-${WXVER}.tar.gz $2/wxMotif-${WXVER}.tgz + +### HTML docs +ls `cat $1/distrib/msw/wx_html.rsp` > /tmp/html.txt +tar cvf $2/wxWindows-${WXVER}-htm.tar -T /tmp/html.txt +gzip $2/wxWindows-${WXVER}-htm.tar +mv $2/wxWindows-${WXVER}-htm.tar.gz $2/wxWindows-${WXVER}-htm.tgz + +### HTB (wxHTML Help) docs +ls `cat $1/distrib/msw/wx_htb.rsp` > /tmp/htb.txt +tar cvf $2/wxWindows-${WXVER}-htb.tar -T /tmp/htb.txt +gzip $2/wxWindows-${WXVER}-htb.tar +mv $2/wxWindows-${WXVER}-htb.tar.gz $2/wxWindows-${WXVER}-htb.tgz + +### PDF docs +ls `cat $1/distrib/msw/wx_pdf.rsp` > /tmp/pdf.txt +tar cvf $2/wxWindows-${WXVER}-pdf.tar -T /tmp/pdf.txt +gzip $2/wxWindows-${WXVER}-pdf.tar +mv $2/wxWindows-${WXVER}-pdf.tar.gz $2/wxWindows-${WXVER}-pdf.tgz + +### Stubs files +#ls `cat $1/distrib/msw/stubs.rsp` > /tmp/stubs.txt +#tar cvf $2/wxWindows-${WXVER}-stubs.tar -T /tmp/stubs.txt +#gzip $2/wxWindows-${WXVER}-stubs.tar +#mv $2/wxWindows-${WXVER}-stubs.tar.gz $2/wxWindows-${WXVER}-stubs.tgz + +### Tex2RTF +ls `cat $1/distrib/msw/tex2rtf.rsp` > /tmp/tex2rtf.txt +tar cvf $2/tex2rtf2.tar -T /tmp/tex2rtf.txt +gzip $2/tex2rtf2.tar +mv $2/tex2rtf2.tar.gz $2/tex2rtf2.tgz + +### OGL +ls `cat $1/distrib/msw/ogl.rsp` > /tmp/ogl.txt +tar cvf $2/ogl3.tar -T /tmp/ogl.txt +gzip $2/ogl3.tar +mv $2/ogl3.tar.gz $2/ogl3.tgz + +### JPEG +#ls `cat $1/distrib/msw/jpeg.rsp` > /tmp/jpeg.txt +#tar cvf $2/jpeg.tar -T /tmp/jpeg.txt +#gzip $2/jpeg.tar +#mv $2/jpeg.tar.gz $2/jpeg.tgz + +### TIFF +#ls `cat $1/distrib/msw/tiff.rsp` > /tmp/tiff.txt +#tar cvf $2/tiff.tar -T /tmp/tiff.txt +#gzip $2/tiff.tar +#mv $2/tiff.tar.gz $2/tiff.tgz + +echo Done! diff --git a/distrib/msw/zipdist.bat b/distrib/msw/zipdist.bat index 0cd9e01fc9..2f6136270a 100755 --- a/distrib/msw/zipdist.bat +++ b/distrib/msw/zipdist.bat @@ -104,7 +104,6 @@ copy %src\docs\msw\install.txt %dest\install_msw.txt copy %src\docs\motif\install.txt %dest\install_motif.txt copy %src\docs\gtk\install.txt %dest\install_gtk.txt copy %src\docs\readme.txt %dest -copy %src\docs\release.txt %dest copy %src\docs\motif\makewxmotif %dest copy %src\docs\gtk\makewxgtk %dest diff --git a/docs/msw/bc_ide.txt b/docs/msw/bc_ide.txt index d0e0e59b7f..3c09566734 100644 --- a/docs/msw/bc_ide.txt +++ b/docs/msw/bc_ide.txt @@ -1,13 +1,13 @@ Readme for wxWindows 2.0 Ide-files First release Feb. 1999, detlev@reymann-online.de -1. What you can do with this IDE files +1. What you can do with the BC++ IDE files 2. Where to install the files 3. How to modify them for your own needs 4. How to create IDE files for your own wxWindows-programs -1. What you can do with this IDE files -====================================== +1. What you can do with the IDE files +===================================== There are two IDE files. src\bc32.ide should help you to create the wxWindows libraries from within the Ide of Borlands @@ -40,14 +40,14 @@ $inherit-macro (Julian found the trick), this should work. To add a new sample to samples\bc32.ide, follow these steps: -a. Choose Project->New target... and type in e.g. +1. Choose Project->New target... and type in e.g. samples\newsample. Press OK. -b. Static, no OWL, MFC or class libraries. Check Multithread +2. Static, no OWL, MFC or class libraries. Check Multithread on. Press OK. -c. Right-click on the new node, choose Add node... and add +3. Right-click on the new node, choose Add node... and add ..\lib\wx32.lib and ..\lib\xpm.lib. Add any other source files you require. -d. Right-click on the new node, choose Edit Local Options.. and +4. Right-click on the new node, choose Edit Local Options.. and add in Directories, specify the following: Include: $inherit;.\newsample @@ -59,22 +59,21 @@ d. Right-click on the new node, choose Edit Local Options.. and 4. How to create IDE files for your own wxWindows-programs ========================================================== -I think you are familiar with the necessary options for your own -program. So I will only describe what is neccessary to link -yout program with the wxWindows library. If you want to create -an IDE file for your own wxWindows program, create a new project -from the menu file->new->project. Deactivate all the -standard-options, the only three thing that should be activated is -"static" for the libraries, if you want to use the library -produced with the library-ide, the checkbox OLE (you can -leave this checkbox unchecked, but then you have to add the -library \bc5\lib\ole2w32.lib to your project), and the -Multithread checkbox. You have to add -the include-path of wxWindows to the include-path in the -options-dialog (options->project->directories->include). The -result should be something like: -path_of_my_program;\bc5\include;\wxwin2\include; Then you have -to add the libraries to the project. Open the project-view and -activate your program. Then right-click and choose "add" and -select the wxWindows library (e.g. \wxwin\lib\wx32.lib). Also -add the xpm library. +If you want to create an IDE file for your own wxWindows program, +please follow these steps. + +1. Create a new project from the menu file->new->project. +2. Deactivate all the standard-options, the only three things + that should be activated are "static" for the libraries, + the checkbox OLE (you can leave this checkbox unchecked, + but then you have to add the library \bc5\lib\ole2w32.lib + to your project), and the Multithread checkbox. +3. Add the include-path of wxWindows to the include-path in the + options-dialog (options->project->directories->include). The + result should be something like: + path_of_my_program;\bc5\include;\wxwin2\include; +4. Add the libraries to the project. Open the project-view and + activate your program. Then right-click and choose "add" and + select the wxWindows library (e.g. \wxwin\lib\wx32.lib). Also + add the xpm library. + diff --git a/docs/msw/install.txt b/docs/msw/install.txt index 6b5c22016c..4042c18a47 100644 --- a/docs/msw/install.txt +++ b/docs/msw/install.txt @@ -305,10 +305,25 @@ of how to create your own project files. Borland C++Builder compilation ------------------------------ -C++Builder compilation is the same as for Borland C++ above. +1. Build the wxWindows libraries using the Borland make utility as + specified in the section called "Borland C++ 4.5/5.0 compilation" + above. (C++ Builder includes a stand-alone C++ compiler. For example, + C++ Builder 4.0 comes with C++ 5.4.) -Tested with C++Builder 1.0 and 3.0. Only makefiles are currently -supplied. +2. Create a template .bpr (project) file for new Borland/wxWindows, + being sure to make the following settings: + + a) 32 bit compiler + b) Defines: __WXMSW__;__WIN95__ + c) Data alignment=byte + d) Include path: \libs\wx2\include + +To use this template project file, just add the wxWindows libraries to +the project along with your own source files. If you need to run one or +two wx source files in the debugger, include them explicitly in your BCB +project and they will get linked in in preference to any files in the +lib; just make sure that your include path finds all the wx include +files. Watcom C++ 10.6/11 compilation --------------------------- diff --git a/include/wx/motif/choice.h b/include/wx/motif/choice.h index 5171d41fe9..df445f9e9b 100644 --- a/include/wx/motif/choice.h +++ b/include/wx/motif/choice.h @@ -96,6 +96,8 @@ protected: WXWidget* m_widgetList ; WXWidget m_formWidget; wxStringList m_stringList; + wxList m_clientList; // contains the client data for the items + virtual void DoSetSize(int x, int y, int width, int height, diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 74d691d57e..848aa072c4 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -599,10 +599,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_choiceSorted = new wxChoice( panel, ID_CHOICE_SORTED, wxPoint(10,70), wxSize(120,-1), 5, choices, wxCB_SORT ); -#ifndef __WXMOTIF__ SetControlClientData("choice", m_choice); SetControlClientData("choice", m_choiceSorted); -#endif m_choice->SetSelection(2); m_choice->SetBackgroundColour( "red" ); diff --git a/samples/resource/resource.cpp b/samples/resource/resource.cpp index 588b3873ff..ab0405be9b 100644 --- a/samples/resource/resource.cpp +++ b/samples/resource/resource.cpp @@ -113,8 +113,10 @@ bool MyApp::OnInit(void) MyApp::~MyApp() { +#if defined(__WXMSW__) delete dialog1; delete menu1; +#endif } BEGIN_EVENT_TABLE(MyPanel, wxPanel) diff --git a/samples/rotate/rotate.cpp b/samples/rotate/rotate.cpp index 5ab6b68b92..a5fb9b378c 100644 --- a/samples/rotate/rotate.cpp +++ b/samples/rotate/rotate.cpp @@ -43,6 +43,19 @@ private: }; +class MyCanvas: public wxScrolledWindow +{ +public: + MyCanvas(wxWindow* parent); + + void OnMouseLeftUp (wxMouseEvent & event); + void OnMouseRightUp (wxMouseEvent & event); + +private: + + DECLARE_EVENT_TABLE() +}; + class MyFrame: public wxFrame { public: @@ -50,10 +63,7 @@ public: void OnQuit (wxCommandEvent &); void OnAngle(wxCommandEvent &); - void OnMouseLeftUp (wxMouseEvent & event); - void OnMouseRightUp (wxMouseEvent & event); -private: double m_angle; DECLARE_EVENT_TABLE() @@ -65,16 +75,18 @@ enum ID_Angle }; +BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) + EVT_LEFT_UP (MyCanvas::OnMouseLeftUp) + EVT_RIGHT_UP (MyCanvas::OnMouseRightUp) +END_EVENT_TABLE() + BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU (ID_Quit, MyFrame::OnQuit) EVT_MENU (ID_Angle, MyFrame::OnAngle) - EVT_LEFT_UP (MyFrame::OnMouseLeftUp) - EVT_RIGHT_UP (MyFrame::OnMouseRightUp) END_EVENT_TABLE() IMPLEMENT_APP(MyApp) - bool MyApp::OnInit() { m_image = wxImage("kclub.bmp", wxBITMAP_TYPE_BMP); @@ -92,8 +104,6 @@ bool MyApp::OnInit() MyFrame *frame = new MyFrame ("wxWindows rotate sample", wxPoint(20,20), wxSize(600,450)); - frame->SetBackgroundColour (wxColour (0,80,60)); - frame->Clear(); frame->Show (TRUE); SetTopWindow (frame); return TRUE; @@ -104,6 +114,8 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) { m_angle = 0.1; + new MyCanvas(this); + wxMenu *menuFile = new wxMenu; menuFile->Append (ID_Angle, "Set &angle\tCtrl-A"); menuFile->AppendSeparator(); @@ -132,13 +144,21 @@ void MyFrame::OnQuit (wxCommandEvent &) Close (TRUE); } +MyCanvas::MyCanvas(wxWindow* parent): + wxScrolledWindow(parent, -1) +{ + SetBackgroundColour (wxColour (0,80,60)); + Clear(); +} // Rotate with interpolation and with offset correction -void MyFrame::OnMouseLeftUp (wxMouseEvent & event) +void MyCanvas::OnMouseLeftUp (wxMouseEvent & event) { + MyFrame* frame = (MyFrame*) GetParent(); + wxPoint offset; const wxImage& img = wxGetApp().GetImage(); - wxImage img2 = img.Rotate(m_angle, wxPoint(img.GetWidth()/2, img.GetHeight()/2), TRUE, &offset); + wxImage img2 = img.Rotate(frame->m_angle, wxPoint(img.GetWidth()/2, img.GetHeight()/2), TRUE, &offset); wxBitmap bmp = img2.ConvertToBitmap (); @@ -147,10 +167,12 @@ void MyFrame::OnMouseLeftUp (wxMouseEvent & event) } // without interpolation, and without offset correction -void MyFrame::OnMouseRightUp (wxMouseEvent & event) +void MyCanvas::OnMouseRightUp (wxMouseEvent & event) { + MyFrame* frame = (MyFrame*) GetParent(); + const wxImage& img = wxGetApp().GetImage(); - wxImage img2 = img.Rotate(m_angle, wxPoint(img.GetWidth()/2, img.GetHeight()/2), FALSE); + wxImage img2 = img.Rotate(frame->m_angle, wxPoint(img.GetWidth()/2, img.GetHeight()/2), FALSE); wxBitmap bmp = img2.ConvertToBitmap (); diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index 9e22acab10..0448ca924c 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -1262,7 +1262,7 @@ void wxPostScriptDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y ) XLOG2DEV(x), YLOG2DEV(uy), m_underlineThickness, XLOG2DEV(x + text_w), YLOG2DEV(uy) ); - for (int i = 0; i < 100; i++) + for (i = 0; i < 100; i++) if (buffer[i] == ',') buffer[i] = '.'; fprintf( m_pstream, buffer ); } @@ -1391,7 +1391,7 @@ void wxPostScriptDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord XLOG2DEV(x), YLOG2DEV(uy), m_underlineThickness, XLOG2DEV(x + w), YLOG2DEV(uy) ); - for (int i = 0; i < 100; i++) + for (i = 0; i < 100; i++) if (buffer[i] == ',') buffer[i] = '.'; fprintf( m_pstream, buffer ); } diff --git a/src/motif/choice.cpp b/src/motif/choice.cpp index 45a2430847..b805a5dabf 100644 --- a/src/motif/choice.cpp +++ b/src/motif/choice.cpp @@ -189,32 +189,37 @@ void wxChoice::Append(const wxString& item) for (i = 0; i < m_noStrings; i++) new_widgetList[i] = m_widgetList[i]; - new_widgetList[m_noStrings] = (WXWidget) w; + new_widgetList[m_noStrings] = (WXWidget) w; - if (m_widgetList) - delete[] m_widgetList; - m_widgetList = new_widgetList; + if (m_widgetList) + delete[] m_widgetList; + m_widgetList = new_widgetList; - char mnem = wxFindMnemonic ((char*) (const char*) item); - if (mnem != 0) - XtVaSetValues (w, XmNmnemonic, mnem, NULL); + char mnem = wxFindMnemonic ((char*) (const char*) item); + if (mnem != 0) + XtVaSetValues (w, XmNmnemonic, mnem, NULL); - XtAddCallback (w, XmNactivateCallback, (XtCallbackProc) wxChoiceCallback, (XtPointer) this); + XtAddCallback (w, XmNactivateCallback, (XtCallbackProc) wxChoiceCallback, (XtPointer) this); - if (m_noStrings == 0 && m_buttonWidget) - { - XtVaSetValues ((Widget) m_buttonWidget, XmNmenuHistory, w, NULL); - Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget); - XmString text = XmStringCreateSimple ((char*) (const char*) item); - XtVaSetValues (label, - XmNlabelString, text, - NULL); - XmStringFree (text); - } - wxNode *node = m_stringList.Add (item); - XtVaSetValues (w, XmNuserData, node->Data (), NULL); + if (m_noStrings == 0 && m_buttonWidget) + { + XtVaSetValues ((Widget) m_buttonWidget, XmNmenuHistory, w, NULL); + Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget); + XmString text = XmStringCreateSimple ((char*) (const char*) item); + XtVaSetValues (label, + XmNlabelString, text, + NULL); + XmStringFree (text); + } + wxNode *node = m_stringList.Add (item); + XtVaSetValues (w, XmNuserData, node->Data (), NULL); - m_noStrings ++; + if (m_noStrings == 0) + m_clientList.Append((wxObject*) NULL); + else + m_clientList.Insert( m_clientList.Item(m_noStrings-1), + (wxObject*) NULL ); + m_noStrings ++; } void wxChoice::Delete(int WXUNUSED(n)) @@ -243,6 +248,21 @@ void wxChoice::Clear() m_widgetList = (WXWidget*) NULL; if (m_buttonWidget) XtVaSetValues ((Widget) m_buttonWidget, XmNmenuHistory, (Widget) NULL, NULL); + + 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(); + m_noStrings = 0; } @@ -524,26 +544,40 @@ void wxChoice::DoSetFirstItem(int WXUNUSED(n)) wxFAIL_MSG( wxT("wxChoice::DoSetFirstItem not implemented") ); } -void wxChoice::DoSetItemClientData(int WXUNUSED(n), void* WXUNUSED(clientData)) +void wxChoice::DoSetItemClientData(int n, void* clientData) { - wxFAIL_MSG( wxT("wxChoice::DoSetItemClientData not implemented") ); + wxNode *node = m_clientList.Nth( n ); + wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetItemClientData") ); + + node->SetData( (wxObject*) clientData ); } -void* wxChoice::DoGetItemClientData(int WXUNUSED(n)) const +void* wxChoice::DoGetItemClientData(int n) const { - wxFAIL_MSG( wxT("wxChoice::DoGetItemClientData not implemented") ); - return (void*) NULL; + wxNode *node = m_clientList.Nth( n ); + wxCHECK_MSG( node, NULL, wxT("invalid index in wxChoice::DoGetItemClientData") ); + + return node->Data(); } -void wxChoice::DoSetItemClientObject(int WXUNUSED(n), wxClientData* WXUNUSED(clientData)) +void wxChoice::DoSetItemClientObject(int n, wxClientData* clientData) { - wxFAIL_MSG( wxT("wxChoice::DoSetItemClientObject not implemented") ); + wxNode *node = m_clientList.Nth( n ); + wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetItemClientObject") ); + + wxClientData *cd = (wxClientData*) node->Data(); + delete cd; + + node->SetData( (wxObject*) clientData ); } -wxClientData* wxChoice::DoGetItemClientObject(int WXUNUSED(n)) const +wxClientData* wxChoice::DoGetItemClientObject(int n) const { - wxFAIL_MSG( wxT("wxChoice::DoGetItemClientObject not implemented") ); - return (wxClientData*) NULL; + wxNode *node = m_clientList.Nth( n ); + wxCHECK_MSG( node, (wxClientData *)NULL, + wxT("invalid index in wxChoice::DoGetItemClientObject") ); + + return (wxClientData*) node->Data(); } void wxChoice::Select(int n) diff --git a/src/motif/combobox.cpp b/src/motif/combobox.cpp index 6794324428..d1c470999e 100644 --- a/src/motif/combobox.cpp +++ b/src/motif/combobox.cpp @@ -67,11 +67,6 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, XmNstaticList, ((style & wxCB_SIMPLE) == wxCB_SIMPLE), NULL); - XtAddCallback (buttonWidget, XmNselectionCallback, (XtCallbackProc) wxComboBoxCallback, - (XtPointer) this); - XtAddCallback (buttonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxComboBoxCallback, - (XtPointer) this); - int i; for (i = 0; i < n; i++) { @@ -91,6 +86,11 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, m_font = parent->GetFont(); ChangeFont(FALSE); + XtAddCallback (buttonWidget, XmNselectionCallback, (XtCallbackProc) wxComboBoxCallback, + (XtPointer) this); + XtAddCallback (buttonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxComboBoxCallback, + (XtPointer) this); + SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); @@ -151,6 +151,16 @@ void wxComboBox::Delete(int n) delete[] (char *)node->Data(); delete node; } + node = m_clientList.Nth( n ); + if (node) + { + if ( HasClientObjectData() ) + { + delete (wxClientData *)node->Data(); + } + delete node; + } + m_noStrings--; } @@ -158,6 +168,21 @@ void wxComboBox::Clear() { XmComboBoxDeleteAllItems((Widget) m_mainWidget); m_stringList.Clear(); + + 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(); + m_noStrings = 0; } void wxComboBox::SetSelection (int n)