From: Václav Slavík Date: Mon, 31 Jul 2000 22:03:49 +0000 (+0000) Subject: added wxListBox handling X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/4b0ca8b999417137b955e6e837ee331a9b6107eb added wxListBox handling git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7905 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/contrib/include/wx/xml/xh_all.h b/contrib/include/wx/xml/xh_all.h index 3e5803facf..59b6f362de 100644 --- a/contrib/include/wx/xml/xh_all.h +++ b/contrib/include/wx/xml/xh_all.h @@ -33,5 +33,6 @@ #include "wx/xml/xh_stbmp.h" #include "wx/xml/xh_notbk.h" #include "wx/xml/xh_text.h" +#include "wx/xml/xh_listb.h" #endif // _WX_XMLRES_H_ diff --git a/contrib/include/wx/xml/xh_listb.h b/contrib/include/wx/xml/xh_listb.h new file mode 100644 index 0000000000..637d264efa --- /dev/null +++ b/contrib/include/wx/xml/xh_listb.h @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_listb.h +// Purpose: XML resource handler for wxListbox +// Author: Bob Mitchell & Vaclav Slavik +// Created: 2000/07/29 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell & Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_LISTB_H_ +#define _WX_XH_LISTB_H_ + +#ifdef __GNUG__ +#pragma interface "xh_listb.h" +#endif + +#include "wx/xml/xmlres.h" + +#if wxUSE_LISTBOX + +class WXDLLEXPORT wxListBoxXmlHandler : public wxXmlResourceHandler +{ + public: + wxListBoxXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); + private: + bool m_InsideBox; + wxArrayString strList; +}; + +#endif + +#endif // _WX_XH_LISTB_H_ diff --git a/contrib/src/xml/Makefile.in b/contrib/src/xml/Makefile.in index 67b1fa3cce..c893889804 100644 --- a/contrib/src/xml/Makefile.in +++ b/contrib/src/xml/Makefile.in @@ -16,14 +16,14 @@ HEADER_SUBDIR=xml HEADERS=xh_all.h xh_bttn.h xh_chckb.h xh_chckl.h xh_choic.h xh_combo.h \ xh_dlg.h xh_gauge.h xh_html.h xh_menu.h xh_notbk.h xh_panel.h \ xh_radbt.h xh_radbx.h xh_sizer.h xh_slidr.h xh_spin.h xh_stbmp.h \ - xh_sttxt.h xh_text.h xml.h xmlio.h xmlres.h + xh_sttxt.h xh_text.h xh_listb.h xml.h xmlio.h xmlres.h OBJECTS=xml.o xmlbin.o xmlbinz.o xmlpars.o xmlres.o xmlrsall.o \ xh_bttn.o xh_chckb.o xh_chckl.o xh_choic.o xh_combo.o xh_dlg.o \ xh_gauge.o xh_html.o xh_menu.o xh_notbk.o xh_panel.o xh_radbt.o \ xh_radbx.o xh_sizer.o xh_slidr.o xh_spin.o xh_stbmp.o xh_sttxt.o \ - xh_text.o \ + xh_text.o xh_listb.o \ APPEXTRADEFS=-I$(top_srcdir)/contrib/include diff --git a/contrib/src/xml/makefile.b32 b/contrib/src/xml/makefile.b32 index 9701f12217..e36bbc6cbb 100644 --- a/contrib/src/xml/makefile.b32 +++ b/contrib/src/xml/makefile.b32 @@ -17,7 +17,7 @@ OBJECTS=xml.obj xmlbin.obj xmlbinz.obj xmlpars.obj xmlres.obj xmlrsall.obj \ xh_bttn.obj xh_chckb.obj xh_chckl.obj xh_choic.obj xh_combo.obj xh_dlg.obj \ xh_gauge.obj xh_html.obj xh_menu.obj xh_notbk.obj xh_panel.obj xh_radbt.obj \ xh_radbx.obj xh_sizer.obj xh_slidr.obj xh_spin.obj xh_stbmp.obj xh_sttxt.obj \ - xh_text.obj + xh_text.obj xh_listb.obj !include $(WXDIR)\src\makelib.b32 diff --git a/contrib/src/xml/makefile.g95 b/contrib/src/xml/makefile.g95 index 7e3d300c67..6c85194de7 100644 --- a/contrib/src/xml/makefile.g95 +++ b/contrib/src/xml/makefile.g95 @@ -16,7 +16,7 @@ OBJECTS=xml.o xmlbin.o xmlbinz.o xmlpars.o xmlres.o xmlrsall.o \ xh_bttn.o xh_chckb.o xh_chckl.o xh_choic.o xh_combo.o xh_dlg.o \ xh_gauge.o xh_html.o xh_menu.o xh_notbk.o xh_panel.o xh_radbt.o \ xh_radbx.o xh_sizer.o xh_slidr.o xh_spin.o xh_stbmp.o xh_sttxt.o \ - xh_text.o + xh_text.o xh_listb.o include $(WXDIR)/src/makelib.g95 diff --git a/contrib/src/xml/makefile.vc b/contrib/src/xml/makefile.vc index a5602916b3..e3efd28424 100644 --- a/contrib/src/xml/makefile.vc +++ b/contrib/src/xml/makefile.vc @@ -37,7 +37,7 @@ OBJECTS=$(D)\xml.obj $(D)\xmlbin.obj $(D)\xmlbinz.obj $(D)\xmlpars.obj $(D)\xmlr $(D)\xh_bttn.obj $(D)\xh_chckb.obj $(D)\xh_chckl.obj $(D)\xh_choic.obj $(D)\xh_combo.obj $(D)\xh_dlg.obj \ $(D)\xh_gauge.obj $(D)\xh_html.obj $(D)\xh_menu.obj $(D)\xh_notbk.obj $(D)\xh_panel.obj $(D)\xh_radbt.obj \ $(D)\xh_radbx.obj $(D)\xh_sizer.obj $(D)\xh_slidr.obj $(D)\xh_spin.obj $(D)\xh_stbmp.obj $(D)\xh_sttxt.obj \ - $(D)\xh_text.obj + $(D)\xh_text.obj $(D)\xh_listb.obj !include $(WXDIR)\src\makelib.vc diff --git a/contrib/src/xml/makefile.wat b/contrib/src/xml/makefile.wat index 7b6b2e43df..d321dac6de 100644 --- a/contrib/src/xml/makefile.wat +++ b/contrib/src/xml/makefile.wat @@ -16,7 +16,7 @@ OBJECTS=xml.obj xmlbin.obj xmlbinz.obj xmlpars.obj xmlres.obj xmlrsall.obj & xh_bttn.obj xh_chckb.obj xh_chckl.obj xh_choic.obj xh_combo.obj xh_dlg.obj & xh_gauge.obj xh_html.obj xh_menu.obj xh_notbk.obj xh_panel.obj xh_radbt.obj & xh_radbx.obj xh_sizer.obj xh_slidr.obj xh_spin.obj xh_stbmp.obj xh_sttxt.obj & - xh_text.obj + xh_text.obj xh_listb.obj all: $(WXXMLLIB) diff --git a/contrib/src/xml/wxXMLVC.dsp b/contrib/src/xml/wxXMLVC.dsp index df2108db74..ad219f5493 100644 --- a/contrib/src/xml/wxXMLVC.dsp +++ b/contrib/src/xml/wxXMLVC.dsp @@ -160,6 +160,10 @@ SOURCE=.\xh_text.cpp # End Source File # Begin Source File +SOURCE=.\xh_listb.cpp +# End Source File +# Begin Source File + SOURCE=.\xml.cpp # End Source File # Begin Source File diff --git a/contrib/src/xml/xh_listb.cpp b/contrib/src/xml/xh_listb.cpp new file mode 100644 index 0000000000..d9d2a54089 --- /dev/null +++ b/contrib/src/xml/xh_listb.cpp @@ -0,0 +1,102 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_listb.cpp +// Purpose: XML resource for wxListBox +// Author: Bob Mitchell & Vaclav Slavik +// Created: 2000/07/29 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_listb.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_listb.h" +#include "wx/listbox.h" + +wxListBoxXmlHandler::wxListBoxXmlHandler() +: wxXmlResourceHandler() , m_InsideBox(FALSE) +{ + ADD_STYLE(wxLB_SINGLE); + ADD_STYLE(wxLB_MULTIPLE); + ADD_STYLE(wxLB_EXTENDED); + ADD_STYLE(wxLB_HSCROLL); + ADD_STYLE(wxLB_ALWAYS_SB); + ADD_STYLE(wxLB_NEEDED_SB); + ADD_STYLE(wxLB_SORT); +} + +wxObject *wxListBoxXmlHandler::DoCreateResource() +{ + if( m_Node->GetName() == _T("listbox")) + { + // find the selection + long selection = GetLong( _T("selection"), -1 ); + + // need to build the list of strings from children + m_InsideBox = TRUE; + CreateChildren( NULL, TRUE /* only this handler */, + GetParamNode(_T("content"))); + wxString *strings = (wxString *) NULL; + if( strList.GetCount() > 0 ) + { + strings = new wxString[strList.GetCount()]; + int count = strList.GetCount(); + for( int i = 0; i < count; i++ ) + strings[i]=strList[i]; + } + + + wxListBox *control = new wxListBox(m_ParentAsWindow, + GetID(), + GetPosition(), GetSize(), + strList.GetCount(), + strings, + GetStyle(), + wxDefaultValidator, + GetName() + ); + + if( selection != -1 ) + control->SetSelection( selection ); + + SetupWindow(control); + + if( strings != NULL ) + delete [] strings; + strList.Clear(); // dump the strings + + return control; + } + else + { + // on the inside now. + // handle Label + + // add to the list + strList.Add( GetNodeContent(m_Node) ); + + return NULL; + } + +} + + + +bool wxListBoxXmlHandler::CanHandle(wxXmlNode *node) +{ + return( node->GetName() == _T("listbox") || + ( m_InsideBox && + node->GetName() == _T("item" )) + ); +} + + diff --git a/contrib/src/xml/xmlrsall.cpp b/contrib/src/xml/xmlrsall.cpp index d28ee9bb14..5e5bda02e4 100644 --- a/contrib/src/xml/xmlrsall.cpp +++ b/contrib/src/xml/xmlrsall.cpp @@ -63,4 +63,7 @@ void wxXmlResource::InitAllHandlers() AddHandler(new wxNotebookXmlHandler); #endif AddHandler(new wxTextCtrlXmlHandler); +#if wxUSE_LISTBOX + AddHandler(new wxListBoxXmlHandler); +#endif } diff --git a/contrib/utils/wxrcedit/Makefile.in b/contrib/utils/wxrcedit/Makefile.in index 6301d766d5..cf0c68ef86 100644 --- a/contrib/utils/wxrcedit/Makefile.in +++ b/contrib/utils/wxrcedit/Makefile.in @@ -46,10 +46,11 @@ DATAFILES = \ df/statictext.df \ df/textctrl.df \ df/toolbar_item.df \ - df/window.df + df/window.df \ + df/listbox.df -APPEXTRALIBS=$(top_builddir)/lib/libwxxml.@WX_TARGET_LIBRARY_TYPE@ +APPEXTRALIBS=-lwxxml APPEXTRADEFS=-I$(top_srcdir)/contrib/include include $(top_builddir)/src/makeprog.env diff --git a/contrib/utils/wxrcedit/df/listbox.df b/contrib/utils/wxrcedit/df/listbox.df new file mode 100644 index 0000000000..4ee817c384 --- /dev/null +++ b/contrib/utils/wxrcedit/df/listbox.df @@ -0,0 +1,5 @@ +node listbox +var style of flags wxLB_SINGLE,wxLB_MULTIPLE,wxLB_EXTENDED,wxLB_HSCROLL,wxLB_ALWAYS_SB,wxLB_NEEDED_SB,wxLB_SORT +var selection of integer +var content of not_implemented +derived from control