added wxListBox handling

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7905 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2000-07-31 22:03:49 +00:00
parent f6fb552e5d
commit 4b0ca8b999
12 changed files with 159 additions and 8 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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 <item>Label</item>
// 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" ))
);
}

View File

@@ -63,4 +63,7 @@ void wxXmlResource::InitAllHandlers()
AddHandler(new wxNotebookXmlHandler);
#endif
AddHandler(new wxTextCtrlXmlHandler);
#if wxUSE_LISTBOX
AddHandler(new wxListBoxXmlHandler);
#endif
}

View File

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

View File

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