From: Ron Lee Date: Tue, 14 Mar 2000 18:20:11 +0000 (+0000) Subject: renamed proplist sample X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/30b641919c57447b3f63f9db7170d933a6516869?ds=inline renamed proplist sample git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6703 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/proplist/Makefile.in b/samples/proplist/Makefile.in index 113c8bacdf..d55ad0cd7c 100644 --- a/samples/proplist/Makefile.in +++ b/samples/proplist/Makefile.in @@ -1,19 +1,11 @@ -# -# File: makefile.unx -# Author: Julian Smart -# Created: 1998 -# Updated: -# Copyright: (c) 1998 Julian Smart -# -# "%W% %G%" -# -# Makefile for proplist example (UNIX). +# Purpose: makefile for proplist example (UNIX). +# Created: 2000-03-15 top_srcdir = @top_srcdir@/.. top_builddir = ../.. program_dir = samples/proplist -PROGRAM=test +PROGRAM=proplist OBJECTS=$(PROGRAM).o diff --git a/samples/proplist/makefile.b32 b/samples/proplist/makefile.b32 index 95ddc80d76..9e35c97943 100644 --- a/samples/proplist/makefile.b32 +++ b/samples/proplist/makefile.b32 @@ -1,15 +1,9 @@ -# -# File: makefile.b32 -# Author: Julian Smart -# Created: 1999 -# Updated: -# Copyright: -# -# Makefile : Builds sample for 32-bit BC++ +# Purpose: makefile for proplist example (BC++ 32bit) +# Created: 2000-03-15 WXDIR = $(WXWIN) -TARGET=test +TARGET=proplist OBJECTS = $(TARGET).obj !include $(WXDIR)\src\makeprog.b32 diff --git a/samples/proplist/makefile.bcc b/samples/proplist/makefile.bcc index 669f01905a..db25470c8c 100644 --- a/samples/proplist/makefile.bcc +++ b/samples/proplist/makefile.bcc @@ -1,10 +1,5 @@ -# -# File: makefile.bcc -# Author: Julian Smart -# Created: 1998 -# Updated: -# -# Builds a BC++ 16-bit sample +# Purpose: makefile for proplist example (BC++ 16bit) +# Created: 2000-03-15 !if "$(WXWIN)" == "" !error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx @@ -12,7 +7,7 @@ WXDIR = $(WXWIN) -TARGET=test +TARGET=proplist OBJECTS=$(TARGET).obj !include $(WXDIR)\src\makeprog.bcc diff --git a/samples/proplist/makefile.dos b/samples/proplist/makefile.dos index 983ef2da8b..e580af0985 100644 --- a/samples/proplist/makefile.dos +++ b/samples/proplist/makefile.dos @@ -1,16 +1,9 @@ -# -# File: makefile.dos -# Author: Julian Smart -# Created: 1998 -# Updated: -# -# Makefile : Builds 16-bit sample, VC++ 1.5 -# Use FINAL=1 argument to nmake to build final version with no debugging -# info +# Purpose: makefile for proplist example (VC++ 1.5x) +# Created: 2000-03-15 WXDIR = $(WXWIN) -TARGET=test +TARGET=proplist OBJECTS=$(TARGET).obj !include $(WXDIR)\src\makeprog.msc diff --git a/samples/proplist/makefile.g95 b/samples/proplist/makefile.g95 index b4a920f047..5489c858c7 100644 --- a/samples/proplist/makefile.g95 +++ b/samples/proplist/makefile.g95 @@ -1,16 +1,10 @@ -# -# File: makefile.g95 -# Author: Julian Smart -# Created: 1999 -# Updated: -# Copyright: (c) Julian Smart, 1999 -# -# Makefile for wxWindows sample (Cygwin/Mingw32). +# Purpose: makefile for proplist example (Cygwin/Mingw32) +# Created: #03.01.00 WXDIR = ../.. -TARGET=test +TARGET=proplist OBJECTS = $(TARGET).o -include $(WXDIR)/src/makeprog.g95 +include $(WXDIR)\src\makeprog.g95 diff --git a/samples/proplist/makefile.vc b/samples/proplist/makefile.vc index 4ada748eda..4cb42439fc 100644 --- a/samples/proplist/makefile.vc +++ b/samples/proplist/makefile.vc @@ -1,17 +1,10 @@ -# -# File: makefile.vc -# Author: Julian Smart -# Created: 1999 -# Updated: -# Copyright: (c) Julian Smart -# -# Makefile : Builds sample (VC++, WIN32) -# Use FINAL=1 argument to nmake to build final version with no debug info. +# Purpose: makefile for proplist example (VC++ 32bit) +# Created: 2000-03-15 # Set WXDIR for your system WXDIR = $(WXWIN) -PROGRAM=test +PROGRAM=proplist OBJECTS = $(PROGRAM).obj !include $(WXDIR)\src\makeprog.vc diff --git a/samples/proplist/makefile.wat b/samples/proplist/makefile.wat index 81a83e42a9..b2a02cf03d 100644 --- a/samples/proplist/makefile.wat +++ b/samples/proplist/makefile.wat @@ -1,13 +1,9 @@ -# -# Makefile for WATCOM -# -# Created by Julian Smart, January 1999 -# -# +# Purpose: makefile for proplist example (Watcom) +# Created: 2000-03-15 WXDIR = $(%WXWIN) -PROGRAM = test +PROGRAM = proplist OBJECTS = $(PROGRAM).obj !include $(WXDIR)\src\makeprog.wat diff --git a/samples/proplist/proplist.cpp b/samples/proplist/proplist.cpp new file mode 100644 index 0000000000..85bbfc9298 --- /dev/null +++ b/samples/proplist/proplist.cpp @@ -0,0 +1,400 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: proplist.cpp +// Purpose: Property sheet test implementation +// Author: Julian Smart +// Modified by: +// Created: 04/01/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "proplist.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +#include "proplist.h" + +IMPLEMENT_APP(MyApp) + +wxPropertyValidatorRegistry myListValidatorRegistry; +wxPropertyValidatorRegistry myFormValidatorRegistry; + +MyApp::MyApp(void) +{ + m_childWindow = NULL; + m_mainFrame = NULL; +} + +bool MyApp::OnInit(void) +{ + RegisterValidators(); + + // Create the main frame window + m_mainFrame = new MyFrame(NULL, "wxPropertySheet Demo", wxPoint(0, 0), wxSize(300, 400), wxDEFAULT_FRAME_STYLE); + + // Make a menubar + wxMenu *file_menu = new wxMenu; + file_menu->Append(PROPERTY_TEST_DIALOG_LIST, "Test property list &dialog..."); + file_menu->Append(PROPERTY_TEST_FRAME_LIST, "Test property list &frame..."); + file_menu->AppendSeparator(); + file_menu->Append(PROPERTY_TEST_DIALOG_FORM, "Test property form d&ialog..."); + file_menu->Append(PROPERTY_TEST_FRAME_FORM, "Test property form f&rame..."); + file_menu->AppendSeparator(); + file_menu->Append(PROPERTY_QUIT, "E&xit"); + + wxMenu *help_menu = new wxMenu; + help_menu->Append(PROPERTY_ABOUT, "&About"); + + wxMenuBar *menu_bar = new wxMenuBar; + + menu_bar->Append(file_menu, "&File"); + menu_bar->Append(help_menu, "&Help"); + + // Associate the menu bar with the frame + m_mainFrame->SetMenuBar(menu_bar); + + m_mainFrame->Centre(wxBOTH); + m_mainFrame->Show(TRUE); + + SetTopWindow(m_mainFrame); + + return TRUE; +} + +BEGIN_EVENT_TABLE(MyFrame, wxFrame) + EVT_CLOSE(MyFrame::OnCloseWindow) + EVT_MENU(PROPERTY_QUIT, MyFrame::OnQuit) + EVT_MENU(PROPERTY_ABOUT, MyFrame::OnAbout) + EVT_MENU(PROPERTY_TEST_DIALOG_LIST, MyFrame::OnDialogList) + EVT_MENU(PROPERTY_TEST_FRAME_LIST, MyFrame::OnFrameList) + EVT_MENU(PROPERTY_TEST_DIALOG_FORM, MyFrame::OnDialogForm) + EVT_MENU(PROPERTY_TEST_FRAME_FORM, MyFrame::OnFrameForm) +END_EVENT_TABLE() + +// Define my frame constructor +MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size, long type): + wxFrame(frame, -1, title, pos, size, type) +{ +} + +// Define the behaviour for the frame closing +// - must delete all frames except for the main one. +void MyFrame::OnCloseWindow(wxCloseEvent& event) +{ + if (wxGetApp().m_childWindow) + { + wxGetApp().m_childWindow->Close(TRUE); + } + + Destroy(); +} + +void MyFrame::OnQuit(wxCommandEvent& event) +{ + Close(TRUE); +} + +void MyFrame::OnDialogList(wxCommandEvent& event) +{ + wxGetApp().PropertyListTest(TRUE); +} + +void MyFrame::OnFrameList(wxCommandEvent& event) +{ + wxGetApp().PropertyListTest(FALSE); +} + +void MyFrame::OnDialogForm(wxCommandEvent& event) +{ + wxGetApp().PropertyFormTest(TRUE); +} + +void MyFrame::OnFrameForm(wxCommandEvent& event) +{ + wxGetApp().PropertyFormTest(FALSE); +} + +void MyFrame::OnAbout(wxCommandEvent& event) +{ + (void)wxMessageBox("Property Classes Demo\nAuthor: Julian Smart", "About Property Classes Test"); +} + +void MyApp::RegisterValidators(void) +{ + myListValidatorRegistry.RegisterValidator((wxString)"real", new wxRealListValidator); + myListValidatorRegistry.RegisterValidator((wxString)"string", new wxStringListValidator); + myListValidatorRegistry.RegisterValidator((wxString)"integer", new wxIntegerListValidator); + myListValidatorRegistry.RegisterValidator((wxString)"bool", new wxBoolListValidator); + myListValidatorRegistry.RegisterValidator((wxString)"stringlist", new wxListOfStringsListValidator); + + myFormValidatorRegistry.RegisterValidator((wxString)"real", new wxRealFormValidator); + myFormValidatorRegistry.RegisterValidator((wxString)"string", new wxStringFormValidator); + myFormValidatorRegistry.RegisterValidator((wxString)"integer", new wxIntegerFormValidator); + myFormValidatorRegistry.RegisterValidator((wxString)"bool", new wxBoolFormValidator); +} + +void MyApp::PropertyListTest(bool useDialog) +{ + if (m_childWindow) + return; + + wxPropertySheet *sheet = new wxPropertySheet; + + sheet->AddProperty(new wxProperty("fred", 1.0, "real")); + sheet->AddProperty(new wxProperty("tough choice", (bool)TRUE, "bool")); + sheet->AddProperty(new wxProperty("ian", (long)45, "integer", new wxIntegerListValidator(-50, 50))); + sheet->AddProperty(new wxProperty("bill", 25.0, "real", new wxRealListValidator(0.0, 100.0))); + sheet->AddProperty(new wxProperty("julian", "one", "string")); + sheet->AddProperty(new wxProperty("bitmap", "none", "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"))); + wxStringList *strings = new wxStringList("one", "two", "three", NULL); + sheet->AddProperty(new wxProperty("constrained", "one", "string", new wxStringListValidator(strings))); + + wxStringList *strings2 = new wxStringList("earth", "fire", "wind", "water", NULL); + sheet->AddProperty(new wxProperty("string list", strings2, "stringlist")); + + wxPropertyListView *view = + new wxPropertyListView(NULL, + wxPROP_BUTTON_OK | wxPROP_BUTTON_CANCEL | + wxPROP_BUTTON_CHECK_CROSS|wxPROP_DYNAMIC_VALUE_FIELD|wxPROP_PULLDOWN|wxPROP_SHOWVALUES); + + wxDialog *propDialog = NULL; + wxPropertyListFrame *propFrame = NULL; + if (useDialog) + { + propDialog = new PropListDialog(view, NULL, "Property Sheet Test", + wxPoint(-1, -1), wxSize(400, 500), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODELESS); + m_childWindow = propDialog; + } + else + { + propFrame = new PropListFrame(view, NULL, "Property Sheet Test", wxPoint(-1, -1), wxSize(400, 500)); + m_childWindow = propFrame; + } + + view->AddRegistry(&myListValidatorRegistry); + + if (useDialog) + { + view->ShowView(sheet, propDialog); + propDialog->Centre(wxBOTH); + propDialog->Show(TRUE); + } + else + { + propFrame->Initialize(); + view->ShowView(sheet, propFrame->GetPropertyPanel()); + + propFrame->Centre(wxBOTH); + propFrame->Show(TRUE); + } +} + +void MyApp::PropertyFormTest(bool useDialog) +{ + if (m_childWindow) + return; + + wxPropertySheet *sheet = new wxPropertySheet; + + sheet->AddProperty(new wxProperty("fred", 25.0, "real", new wxRealFormValidator(0.0, 100.0))); + sheet->AddProperty(new wxProperty("tough choice", (bool)TRUE, "bool")); + sheet->AddProperty(new wxProperty("ian", (long)45, "integer", new wxIntegerFormValidator(-50, 50))); + sheet->AddProperty(new wxProperty("julian", "one", "string")); + wxStringList *strings = new wxStringList("one", "two", "three", NULL); + sheet->AddProperty(new wxProperty("constrained", "one", "string", new wxStringFormValidator(strings))); + + wxPropertyFormView *view = new wxPropertyFormView(NULL); + + wxDialog *propDialog = NULL; + wxPropertyFormFrame *propFrame = NULL; + if (useDialog) + { + propDialog = new PropFormDialog(view, NULL, "Property Form Test", + wxPoint(-1, -1), wxSize(380, 250), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL); + m_childWindow = propDialog; + } + else + { + propFrame = new PropFormFrame(view, NULL, "Property Form Test", wxPoint(-1, + -1), wxSize(380, 250)); + propFrame->Initialize(); + m_childWindow = propFrame; + } + + wxPanel *panel = propDialog ? propDialog : propFrame->GetPropertyPanel(); + wxLayoutConstraints* c; + +#if 0 + if (!propDialog) + { + c = new wxLayoutConstraints; + c->left.SameAs(m_childWindow, wxLeft, 4); + c->right.SameAs(m_childWindow, wxRight, 4); + c->top.SameAs(m_childWindow, wxTop, 4); + c->bottom.SameAs(m_childWindow, wxBottom, 40); + + panel->SetConstraints(c); + } +#endif + + // Add items to the panel + wxButton *okButton = new wxButton(panel, wxID_OK, "OK", wxPoint(-1, -1), + wxSize(80, 26), 0, wxDefaultValidator, "ok"); + wxButton *cancelButton = new wxButton(panel, wxID_CANCEL, "Cancel", wxPoint(-1, -1), + wxSize(80, 26), 0, wxDefaultValidator, "cancel"); + wxButton *updateButton = new wxButton(panel, wxID_PROP_UPDATE, "Update", wxPoint(-1, -1), + wxSize(80, 26), 0, wxDefaultValidator, "update"); + wxButton *revertButton = new wxButton(panel, wxID_PROP_REVERT, "Revert", wxPoint(-1, -1), + wxSize(80, 26), 0, wxDefaultValidator, "revert"); + + c = new wxLayoutConstraints; + c->right.SameAs(panel, wxRight, 4); + c->bottom.SameAs(panel, wxBottom, 4); + c->height.AsIs(); + c->width.AsIs(); + revertButton->SetConstraints(c); + + c = new wxLayoutConstraints; + c->right.SameAs(revertButton, wxLeft, 4); + c->bottom.SameAs(panel, wxBottom, 4); + c->height.AsIs(); + c->width.AsIs(); + updateButton->SetConstraints(c); + + c = new wxLayoutConstraints; + c->right.SameAs(updateButton, wxLeft, 4); + c->bottom.SameAs(panel, wxBottom, 4); + c->height.AsIs(); + c->width.AsIs(); + cancelButton->SetConstraints(c); + + c = new wxLayoutConstraints; + c->right.SameAs(cancelButton, wxLeft, 4); + c->bottom.SameAs(panel, wxBottom, 4); + c->height.AsIs(); + c->width.AsIs(); + okButton->SetConstraints(c); + + // The name of this text item matches the "fred" property + wxTextCtrl *text = new wxTextCtrl(panel, -1, "Fred", wxPoint(-1, -1), wxSize( + 200, -1), 0, wxDefaultValidator, "fred"); + + c = new wxLayoutConstraints; + c->left.SameAs(panel, wxLeft, 4); + c->top.SameAs(panel, wxTop, 4); + c->height.AsIs(); + c->width.AsIs(); + text->SetConstraints(c); + + wxCheckBox *checkBox = new wxCheckBox(panel, -1, "Yes or no", wxPoint(-1, -1), + wxSize(-1, -1), 0, wxDefaultValidator, "tough choice"); + + c = new wxLayoutConstraints; + c->left.SameAs(text, wxRight, 20); + c->top.SameAs(panel, wxTop, 4); + c->height.AsIs(); + c->width.AsIs(); + checkBox->SetConstraints(c); + + wxSlider *slider = new wxSlider(panel, -1, -50, 50, 150, wxPoint(-1, -1), + wxSize(200,10), 0, wxDefaultValidator, "ian"); + + c = new wxLayoutConstraints; + c->left.SameAs(panel, wxLeft, 4); + c->top.SameAs(text, wxBottom, 10); + c->height.AsIs(); + c->width.AsIs(); + slider->SetConstraints(c); + + wxListBox *listBox = new wxListBox(panel, -1, wxPoint(-1, -1), wxSize(200, 100), + 0, NULL, 0, wxDefaultValidator, "constrained"); + + c = new wxLayoutConstraints; + c->left.SameAs(panel, wxLeft, 4); + c->top.SameAs(slider, wxBottom, 10); + c->height.AsIs(); + c->width.AsIs(); + listBox->SetConstraints(c); + + view->AddRegistry(&myFormValidatorRegistry); + + panel->SetAutoLayout(TRUE); + + view->ShowView(sheet, panel); + view->AssociateNames(); + view->TransferToDialog(); + + if (useDialog) { + propDialog->Layout(); + propDialog->Centre(wxBOTH); + propDialog->Show(TRUE); + } else { + // panel->Layout(); + propFrame->Centre(wxBOTH); + propFrame->Show(TRUE); + } +} + +BEGIN_EVENT_TABLE(PropListFrame, wxPropertyListFrame) + EVT_CLOSE(PropListFrame::OnCloseWindow) +END_EVENT_TABLE() + +void PropListFrame::OnCloseWindow(wxCloseEvent& event) +{ + wxGetApp().m_childWindow = NULL; + + wxPropertyListFrame::OnCloseWindow(event); +} + +BEGIN_EVENT_TABLE(PropListDialog, wxPropertyListDialog) + EVT_CLOSE(PropListDialog::OnCloseWindow) +END_EVENT_TABLE() + +void PropListDialog::OnCloseWindow(wxCloseEvent& event) +{ + wxGetApp().m_childWindow = NULL; + + wxPropertyListDialog::OnCloseWindow(event); +} + +BEGIN_EVENT_TABLE(PropFormFrame, wxPropertyFormFrame) + EVT_CLOSE(PropFormFrame::OnCloseWindow) + EVT_SIZE(PropFormFrame::OnSize) +END_EVENT_TABLE() + +void PropFormFrame::OnCloseWindow(wxCloseEvent& event) +{ + wxGetApp().m_childWindow = NULL; + + wxPropertyFormFrame::OnCloseWindow(event); +} + +void PropFormFrame::OnSize(wxSizeEvent& event) +{ + wxPropertyFormFrame::OnSize(event); + GetPropertyPanel()->Layout(); +} + +BEGIN_EVENT_TABLE(PropFormDialog, wxPropertyFormDialog) + EVT_CLOSE(PropFormDialog::OnCloseWindow) +END_EVENT_TABLE() + +void PropFormDialog::OnCloseWindow(wxCloseEvent& event) +{ + wxGetApp().m_childWindow = NULL; + + wxPropertyFormDialog::OnCloseWindow(event); +} + diff --git a/samples/proplist/proplist.def b/samples/proplist/proplist.def new file mode 100644 index 0000000000..b5cbde33a9 --- /dev/null +++ b/samples/proplist/proplist.def @@ -0,0 +1,8 @@ +NAME Proplist +DESCRIPTION 'wxProperty test' +EXETYPE WINDOWS +STUB 'WINSTUB.EXE' +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE MULTIPLE +HEAPSIZE 1024 +STACKSIZE 8192 diff --git a/samples/proplist/proplist.h b/samples/proplist/proplist.h new file mode 100644 index 0000000000..356681fab9 --- /dev/null +++ b/samples/proplist/proplist.h @@ -0,0 +1,128 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: proplist.h +// Purpose: Property sheet sample +// Author: Julian Smart +// Modified by: +// Created: 04/01/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma interface "proplist.h" +#endif + +#ifndef _PROPTEST_H_ +#define _PROPTEST_H_ + +#include "wx/proplist.h" +#include "wx/propform.h" + +class MyChild; + +// Define a new application +class MyFrame; +class MyApp: public wxApp +{ +public: + MyApp(void); + bool OnInit(void); + + void RegisterValidators(void); + void PropertyListTest(bool useDialog); + void PropertyFormTest(bool useDialog); + + MyFrame* m_mainFrame; + wxWindow* m_childWindow; +}; + +DECLARE_APP(MyApp) + +// Define a new frame +class MyFrame: public wxFrame +{ + public: + MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size, long type); + + void OnCloseWindow(wxCloseEvent& event); + void OnQuit(wxCommandEvent& event); + void OnDialogList(wxCommandEvent& event); + void OnFrameList(wxCommandEvent& event); + void OnDialogForm(wxCommandEvent& event); + void OnFrameForm(wxCommandEvent& event); + void OnAbout(wxCommandEvent& event); + +DECLARE_EVENT_TABLE() +}; + +class PropListFrame: public wxPropertyListFrame +{ +public: + PropListFrame(wxPropertyListView *v, wxFrame *parent, const wxString& title, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"): + wxPropertyListFrame(v, parent, title, pos, size, style, name) + { + } + + void OnCloseWindow(wxCloseEvent& event); + + DECLARE_EVENT_TABLE() +}; + +class PropListDialog: public wxPropertyListDialog +{ +public: + PropListDialog(wxPropertyListView *v, wxWindow *parent, const wxString& title, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE, const wxString& name = "dialogBox"): + wxPropertyListDialog(v, parent, title, pos, size, style, name) + { + } + + void OnCloseWindow(wxCloseEvent& event); + + DECLARE_EVENT_TABLE() +}; + +class PropFormFrame: public wxPropertyFormFrame +{ +public: + PropFormFrame(wxPropertyFormView *v, wxFrame *parent, const wxString& title, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"): + wxPropertyFormFrame(v, parent, title, pos, size, style, name) + { + } + + void OnCloseWindow(wxCloseEvent& event); + void OnSize(wxSizeEvent& event); + + DECLARE_EVENT_TABLE() +}; + +class PropFormDialog: public wxPropertyFormDialog +{ +public: + PropFormDialog(wxPropertyFormView *v, wxWindow *parent, const wxString& title, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE, const wxString& name = "dialogBox"): + wxPropertyFormDialog(v, parent, title, pos, size, style, name) + { + } + + void OnCloseWindow(wxCloseEvent& event); + + DECLARE_EVENT_TABLE() +}; + +#define PROPERTY_QUIT 1 +#define PROPERTY_ABOUT 2 +#define PROPERTY_TEST_DIALOG_LIST 3 +#define PROPERTY_TEST_FRAME_LIST 4 +#define PROPERTY_TEST_DIALOG_FORM 5 +#define PROPERTY_TEST_FRAME_FORM 6 + +#endif + diff --git a/samples/proplist/proplist.rc b/samples/proplist/proplist.rc new file mode 100644 index 0000000000..82f8ad6857 --- /dev/null +++ b/samples/proplist/proplist.rc @@ -0,0 +1,5 @@ +//tick_bmp BITMAP "tick.bmp" +//cross_bmp BITMAP "cross.bmp" + +#include "wx/msw/wx.rc" + diff --git a/samples/proplist/test.cpp b/samples/proplist/test.cpp deleted file mode 100644 index a63a1e0425..0000000000 --- a/samples/proplist/test.cpp +++ /dev/null @@ -1,400 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: test.cpp -// Purpose: Property sheet test implementation -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation "test.h" -#endif - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/wx.h" -#endif - -#include "test.h" - -IMPLEMENT_APP(MyApp) - -wxPropertyValidatorRegistry myListValidatorRegistry; -wxPropertyValidatorRegistry myFormValidatorRegistry; - -MyApp::MyApp(void) -{ - m_childWindow = NULL; - m_mainFrame = NULL; -} - -bool MyApp::OnInit(void) -{ - RegisterValidators(); - - // Create the main frame window - m_mainFrame = new MyFrame(NULL, "wxPropertySheet Demo", wxPoint(0, 0), wxSize(300, 400), wxDEFAULT_FRAME_STYLE); - - // Make a menubar - wxMenu *file_menu = new wxMenu; - file_menu->Append(PROPERTY_TEST_DIALOG_LIST, "Test property list &dialog..."); - file_menu->Append(PROPERTY_TEST_FRAME_LIST, "Test property list &frame..."); - file_menu->AppendSeparator(); - file_menu->Append(PROPERTY_TEST_DIALOG_FORM, "Test property form d&ialog..."); - file_menu->Append(PROPERTY_TEST_FRAME_FORM, "Test property form f&rame..."); - file_menu->AppendSeparator(); - file_menu->Append(PROPERTY_QUIT, "E&xit"); - - wxMenu *help_menu = new wxMenu; - help_menu->Append(PROPERTY_ABOUT, "&About"); - - wxMenuBar *menu_bar = new wxMenuBar; - - menu_bar->Append(file_menu, "&File"); - menu_bar->Append(help_menu, "&Help"); - - // Associate the menu bar with the frame - m_mainFrame->SetMenuBar(menu_bar); - - m_mainFrame->Centre(wxBOTH); - m_mainFrame->Show(TRUE); - - SetTopWindow(m_mainFrame); - - return TRUE; -} - -BEGIN_EVENT_TABLE(MyFrame, wxFrame) - EVT_CLOSE(MyFrame::OnCloseWindow) - EVT_MENU(PROPERTY_QUIT, MyFrame::OnQuit) - EVT_MENU(PROPERTY_ABOUT, MyFrame::OnAbout) - EVT_MENU(PROPERTY_TEST_DIALOG_LIST, MyFrame::OnDialogList) - EVT_MENU(PROPERTY_TEST_FRAME_LIST, MyFrame::OnFrameList) - EVT_MENU(PROPERTY_TEST_DIALOG_FORM, MyFrame::OnDialogForm) - EVT_MENU(PROPERTY_TEST_FRAME_FORM, MyFrame::OnFrameForm) -END_EVENT_TABLE() - -// Define my frame constructor -MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size, long type): - wxFrame(frame, -1, title, pos, size, type) -{ -} - -// Define the behaviour for the frame closing -// - must delete all frames except for the main one. -void MyFrame::OnCloseWindow(wxCloseEvent& event) -{ - if (wxGetApp().m_childWindow) - { - wxGetApp().m_childWindow->Close(TRUE); - } - - Destroy(); -} - -void MyFrame::OnQuit(wxCommandEvent& event) -{ - Close(TRUE); -} - -void MyFrame::OnDialogList(wxCommandEvent& event) -{ - wxGetApp().PropertyListTest(TRUE); -} - -void MyFrame::OnFrameList(wxCommandEvent& event) -{ - wxGetApp().PropertyListTest(FALSE); -} - -void MyFrame::OnDialogForm(wxCommandEvent& event) -{ - wxGetApp().PropertyFormTest(TRUE); -} - -void MyFrame::OnFrameForm(wxCommandEvent& event) -{ - wxGetApp().PropertyFormTest(FALSE); -} - -void MyFrame::OnAbout(wxCommandEvent& event) -{ - (void)wxMessageBox("Property Classes Demo\nAuthor: Julian Smart", "About Property Classes Test"); -} - -void MyApp::RegisterValidators(void) -{ - myListValidatorRegistry.RegisterValidator((wxString)"real", new wxRealListValidator); - myListValidatorRegistry.RegisterValidator((wxString)"string", new wxStringListValidator); - myListValidatorRegistry.RegisterValidator((wxString)"integer", new wxIntegerListValidator); - myListValidatorRegistry.RegisterValidator((wxString)"bool", new wxBoolListValidator); - myListValidatorRegistry.RegisterValidator((wxString)"stringlist", new wxListOfStringsListValidator); - - myFormValidatorRegistry.RegisterValidator((wxString)"real", new wxRealFormValidator); - myFormValidatorRegistry.RegisterValidator((wxString)"string", new wxStringFormValidator); - myFormValidatorRegistry.RegisterValidator((wxString)"integer", new wxIntegerFormValidator); - myFormValidatorRegistry.RegisterValidator((wxString)"bool", new wxBoolFormValidator); -} - -void MyApp::PropertyListTest(bool useDialog) -{ - if (m_childWindow) - return; - - wxPropertySheet *sheet = new wxPropertySheet; - - sheet->AddProperty(new wxProperty("fred", 1.0, "real")); - sheet->AddProperty(new wxProperty("tough choice", (bool)TRUE, "bool")); - sheet->AddProperty(new wxProperty("ian", (long)45, "integer", new wxIntegerListValidator(-50, 50))); - sheet->AddProperty(new wxProperty("bill", 25.0, "real", new wxRealListValidator(0.0, 100.0))); - sheet->AddProperty(new wxProperty("julian", "one", "string")); - sheet->AddProperty(new wxProperty("bitmap", "none", "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"))); - wxStringList *strings = new wxStringList("one", "two", "three", NULL); - sheet->AddProperty(new wxProperty("constrained", "one", "string", new wxStringListValidator(strings))); - - wxStringList *strings2 = new wxStringList("earth", "fire", "wind", "water", NULL); - sheet->AddProperty(new wxProperty("string list", strings2, "stringlist")); - - wxPropertyListView *view = - new wxPropertyListView(NULL, - wxPROP_BUTTON_OK | wxPROP_BUTTON_CANCEL | - wxPROP_BUTTON_CHECK_CROSS|wxPROP_DYNAMIC_VALUE_FIELD|wxPROP_PULLDOWN|wxPROP_SHOWVALUES); - - wxDialog *propDialog = NULL; - wxPropertyListFrame *propFrame = NULL; - if (useDialog) - { - propDialog = new PropListDialog(view, NULL, "Property Sheet Test", - wxPoint(-1, -1), wxSize(400, 500), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODELESS); - m_childWindow = propDialog; - } - else - { - propFrame = new PropListFrame(view, NULL, "Property Sheet Test", wxPoint(-1, -1), wxSize(400, 500)); - m_childWindow = propFrame; - } - - view->AddRegistry(&myListValidatorRegistry); - - if (useDialog) - { - view->ShowView(sheet, propDialog); - propDialog->Centre(wxBOTH); - propDialog->Show(TRUE); - } - else - { - propFrame->Initialize(); - view->ShowView(sheet, propFrame->GetPropertyPanel()); - - propFrame->Centre(wxBOTH); - propFrame->Show(TRUE); - } -} - -void MyApp::PropertyFormTest(bool useDialog) -{ - if (m_childWindow) - return; - - wxPropertySheet *sheet = new wxPropertySheet; - - sheet->AddProperty(new wxProperty("fred", 25.0, "real", new wxRealFormValidator(0.0, 100.0))); - sheet->AddProperty(new wxProperty("tough choice", (bool)TRUE, "bool")); - sheet->AddProperty(new wxProperty("ian", (long)45, "integer", new wxIntegerFormValidator(-50, 50))); - sheet->AddProperty(new wxProperty("julian", "one", "string")); - wxStringList *strings = new wxStringList("one", "two", "three", NULL); - sheet->AddProperty(new wxProperty("constrained", "one", "string", new wxStringFormValidator(strings))); - - wxPropertyFormView *view = new wxPropertyFormView(NULL); - - wxDialog *propDialog = NULL; - wxPropertyFormFrame *propFrame = NULL; - if (useDialog) - { - propDialog = new PropFormDialog(view, NULL, "Property Form Test", - wxPoint(-1, -1), wxSize(380, 250), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL); - m_childWindow = propDialog; - } - else - { - propFrame = new PropFormFrame(view, NULL, "Property Form Test", wxPoint(-1, - -1), wxSize(380, 250)); - propFrame->Initialize(); - m_childWindow = propFrame; - } - - wxPanel *panel = propDialog ? propDialog : propFrame->GetPropertyPanel(); - wxLayoutConstraints* c; - -#if 0 - if (!propDialog) - { - c = new wxLayoutConstraints; - c->left.SameAs(m_childWindow, wxLeft, 4); - c->right.SameAs(m_childWindow, wxRight, 4); - c->top.SameAs(m_childWindow, wxTop, 4); - c->bottom.SameAs(m_childWindow, wxBottom, 40); - - panel->SetConstraints(c); - } -#endif - - // Add items to the panel - wxButton *okButton = new wxButton(panel, wxID_OK, "OK", wxPoint(-1, -1), - wxSize(80, 26), 0, wxDefaultValidator, "ok"); - wxButton *cancelButton = new wxButton(panel, wxID_CANCEL, "Cancel", wxPoint(-1, -1), - wxSize(80, 26), 0, wxDefaultValidator, "cancel"); - wxButton *updateButton = new wxButton(panel, wxID_PROP_UPDATE, "Update", wxPoint(-1, -1), - wxSize(80, 26), 0, wxDefaultValidator, "update"); - wxButton *revertButton = new wxButton(panel, wxID_PROP_REVERT, "Revert", wxPoint(-1, -1), - wxSize(80, 26), 0, wxDefaultValidator, "revert"); - - c = new wxLayoutConstraints; - c->right.SameAs(panel, wxRight, 4); - c->bottom.SameAs(panel, wxBottom, 4); - c->height.AsIs(); - c->width.AsIs(); - revertButton->SetConstraints(c); - - c = new wxLayoutConstraints; - c->right.SameAs(revertButton, wxLeft, 4); - c->bottom.SameAs(panel, wxBottom, 4); - c->height.AsIs(); - c->width.AsIs(); - updateButton->SetConstraints(c); - - c = new wxLayoutConstraints; - c->right.SameAs(updateButton, wxLeft, 4); - c->bottom.SameAs(panel, wxBottom, 4); - c->height.AsIs(); - c->width.AsIs(); - cancelButton->SetConstraints(c); - - c = new wxLayoutConstraints; - c->right.SameAs(cancelButton, wxLeft, 4); - c->bottom.SameAs(panel, wxBottom, 4); - c->height.AsIs(); - c->width.AsIs(); - okButton->SetConstraints(c); - - // The name of this text item matches the "fred" property - wxTextCtrl *text = new wxTextCtrl(panel, -1, "Fred", wxPoint(-1, -1), wxSize( - 200, -1), 0, wxDefaultValidator, "fred"); - - c = new wxLayoutConstraints; - c->left.SameAs(panel, wxLeft, 4); - c->top.SameAs(panel, wxTop, 4); - c->height.AsIs(); - c->width.AsIs(); - text->SetConstraints(c); - - wxCheckBox *checkBox = new wxCheckBox(panel, -1, "Yes or no", wxPoint(-1, -1), - wxSize(-1, -1), 0, wxDefaultValidator, "tough choice"); - - c = new wxLayoutConstraints; - c->left.SameAs(text, wxRight, 20); - c->top.SameAs(panel, wxTop, 4); - c->height.AsIs(); - c->width.AsIs(); - checkBox->SetConstraints(c); - - wxSlider *slider = new wxSlider(panel, -1, -50, 50, 150, wxPoint(-1, -1), - wxSize(200,10), 0, wxDefaultValidator, "ian"); - - c = new wxLayoutConstraints; - c->left.SameAs(panel, wxLeft, 4); - c->top.SameAs(text, wxBottom, 10); - c->height.AsIs(); - c->width.AsIs(); - slider->SetConstraints(c); - - wxListBox *listBox = new wxListBox(panel, -1, wxPoint(-1, -1), wxSize(200, 100), - 0, NULL, 0, wxDefaultValidator, "constrained"); - - c = new wxLayoutConstraints; - c->left.SameAs(panel, wxLeft, 4); - c->top.SameAs(slider, wxBottom, 10); - c->height.AsIs(); - c->width.AsIs(); - listBox->SetConstraints(c); - - view->AddRegistry(&myFormValidatorRegistry); - - panel->SetAutoLayout(TRUE); - - view->ShowView(sheet, panel); - view->AssociateNames(); - view->TransferToDialog(); - - if (useDialog) { - propDialog->Layout(); - propDialog->Centre(wxBOTH); - propDialog->Show(TRUE); - } else { - // panel->Layout(); - propFrame->Centre(wxBOTH); - propFrame->Show(TRUE); - } -} - -BEGIN_EVENT_TABLE(PropListFrame, wxPropertyListFrame) - EVT_CLOSE(PropListFrame::OnCloseWindow) -END_EVENT_TABLE() - -void PropListFrame::OnCloseWindow(wxCloseEvent& event) -{ - wxGetApp().m_childWindow = NULL; - - wxPropertyListFrame::OnCloseWindow(event); -} - -BEGIN_EVENT_TABLE(PropListDialog, wxPropertyListDialog) - EVT_CLOSE(PropListDialog::OnCloseWindow) -END_EVENT_TABLE() - -void PropListDialog::OnCloseWindow(wxCloseEvent& event) -{ - wxGetApp().m_childWindow = NULL; - - wxPropertyListDialog::OnCloseWindow(event); -} - -BEGIN_EVENT_TABLE(PropFormFrame, wxPropertyFormFrame) - EVT_CLOSE(PropFormFrame::OnCloseWindow) - EVT_SIZE(PropFormFrame::OnSize) -END_EVENT_TABLE() - -void PropFormFrame::OnCloseWindow(wxCloseEvent& event) -{ - wxGetApp().m_childWindow = NULL; - - wxPropertyFormFrame::OnCloseWindow(event); -} - -void PropFormFrame::OnSize(wxSizeEvent& event) -{ - wxPropertyFormFrame::OnSize(event); - GetPropertyPanel()->Layout(); -} - -BEGIN_EVENT_TABLE(PropFormDialog, wxPropertyFormDialog) - EVT_CLOSE(PropFormDialog::OnCloseWindow) -END_EVENT_TABLE() - -void PropFormDialog::OnCloseWindow(wxCloseEvent& event) -{ - wxGetApp().m_childWindow = NULL; - - wxPropertyFormDialog::OnCloseWindow(event); -} - diff --git a/samples/proplist/test.def b/samples/proplist/test.def deleted file mode 100644 index d94e329083..0000000000 --- a/samples/proplist/test.def +++ /dev/null @@ -1,8 +0,0 @@ -NAME TEST -DESCRIPTION 'wxProperty test' -EXETYPE WINDOWS -STUB 'WINSTUB.EXE' -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE MULTIPLE -HEAPSIZE 1024 -STACKSIZE 8192 diff --git a/samples/proplist/test.h b/samples/proplist/test.h deleted file mode 100644 index 5c0e34b0bd..0000000000 --- a/samples/proplist/test.h +++ /dev/null @@ -1,128 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: test.h -// Purpose: Property sheet sample -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma interface "test.h" -#endif - -#ifndef _PROPTEST_H_ -#define _PROPTEST_H_ - -#include "wx/proplist.h" -#include "wx/propform.h" - -class MyChild; - -// Define a new application -class MyFrame; -class MyApp: public wxApp -{ -public: - MyApp(void); - bool OnInit(void); - - void RegisterValidators(void); - void PropertyListTest(bool useDialog); - void PropertyFormTest(bool useDialog); - - MyFrame* m_mainFrame; - wxWindow* m_childWindow; -}; - -DECLARE_APP(MyApp) - -// Define a new frame -class MyFrame: public wxFrame -{ - public: - MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size, long type); - - void OnCloseWindow(wxCloseEvent& event); - void OnQuit(wxCommandEvent& event); - void OnDialogList(wxCommandEvent& event); - void OnFrameList(wxCommandEvent& event); - void OnDialogForm(wxCommandEvent& event); - void OnFrameForm(wxCommandEvent& event); - void OnAbout(wxCommandEvent& event); - -DECLARE_EVENT_TABLE() -}; - -class PropListFrame: public wxPropertyListFrame -{ -public: - PropListFrame(wxPropertyListView *v, wxFrame *parent, const wxString& title, - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"): - wxPropertyListFrame(v, parent, title, pos, size, style, name) - { - } - - void OnCloseWindow(wxCloseEvent& event); - - DECLARE_EVENT_TABLE() -}; - -class PropListDialog: public wxPropertyListDialog -{ -public: - PropListDialog(wxPropertyListView *v, wxWindow *parent, const wxString& title, - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, const wxString& name = "dialogBox"): - wxPropertyListDialog(v, parent, title, pos, size, style, name) - { - } - - void OnCloseWindow(wxCloseEvent& event); - - DECLARE_EVENT_TABLE() -}; - -class PropFormFrame: public wxPropertyFormFrame -{ -public: - PropFormFrame(wxPropertyFormView *v, wxFrame *parent, const wxString& title, - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"): - wxPropertyFormFrame(v, parent, title, pos, size, style, name) - { - } - - void OnCloseWindow(wxCloseEvent& event); - void OnSize(wxSizeEvent& event); - - DECLARE_EVENT_TABLE() -}; - -class PropFormDialog: public wxPropertyFormDialog -{ -public: - PropFormDialog(wxPropertyFormView *v, wxWindow *parent, const wxString& title, - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, const wxString& name = "dialogBox"): - wxPropertyFormDialog(v, parent, title, pos, size, style, name) - { - } - - void OnCloseWindow(wxCloseEvent& event); - - DECLARE_EVENT_TABLE() -}; - -#define PROPERTY_QUIT 1 -#define PROPERTY_ABOUT 2 -#define PROPERTY_TEST_DIALOG_LIST 3 -#define PROPERTY_TEST_FRAME_LIST 4 -#define PROPERTY_TEST_DIALOG_FORM 5 -#define PROPERTY_TEST_FRAME_FORM 6 - -#endif - diff --git a/samples/proplist/test.rc b/samples/proplist/test.rc deleted file mode 100644 index 82f8ad6857..0000000000 --- a/samples/proplist/test.rc +++ /dev/null @@ -1,5 +0,0 @@ -//tick_bmp BITMAP "tick.bmp" -//cross_bmp BITMAP "cross.bmp" - -#include "wx/msw/wx.rc" -