From cfb88c556939f86c26ab9b2ad944618231f16606 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sat, 12 Sep 1998 17:33:59 +0000 Subject: [PATCH] Added sashtest GTK makefiles (crashing bug to be solved); added typetest sample with simple wxVariant test; changed wxICON macro and used it in minimal.cpp to avoid #ifdefing. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@732 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/minimal/makefile.g95 | 20 +-- samples/minimal/makefile.nt | 2 +- samples/minimal/minimal.cpp | 20 +-- samples/sashtest/Makefile | 1 + samples/sashtest/Makefile.in | 26 +++ samples/typetest/Makefile | 1 + samples/typetest/Makefile.in | 26 +++ samples/typetest/makefile.b32 | 63 +++++++ samples/typetest/makefile.dos | 65 ++++++++ samples/typetest/makefile.g95 | 37 +++++ samples/typetest/makefile.nt | 64 ++++++++ samples/typetest/mondrian.ico | Bin 0 -> 766 bytes samples/typetest/mondrian.xpm | 44 +++++ samples/typetest/typetest.cpp | 299 ++++++++++++++++++++++++++++++++++ samples/typetest/typetest.def | 9 + samples/typetest/typetest.h | 67 ++++++++ samples/typetest/typetest.rc | 3 + 17 files changed, 725 insertions(+), 22 deletions(-) create mode 100644 samples/sashtest/Makefile create mode 100644 samples/sashtest/Makefile.in create mode 100644 samples/typetest/Makefile create mode 100644 samples/typetest/Makefile.in create mode 100644 samples/typetest/makefile.b32 create mode 100644 samples/typetest/makefile.dos create mode 100644 samples/typetest/makefile.g95 create mode 100644 samples/typetest/makefile.nt create mode 100644 samples/typetest/mondrian.ico create mode 100644 samples/typetest/mondrian.xpm create mode 100644 samples/typetest/typetest.cpp create mode 100644 samples/typetest/typetest.def create mode 100644 samples/typetest/typetest.h create mode 100644 samples/typetest/typetest.rc diff --git a/samples/minimal/makefile.g95 b/samples/minimal/makefile.g95 index 3f40760ddf..6ad1b1b2ad 100644 --- a/samples/minimal/makefile.g95 +++ b/samples/minimal/makefile.g95 @@ -7,7 +7,7 @@ # # "%W% %G%" # -# Makefile for conftest example (UNIX). +# Makefile for minimal example (UNIX). WXDIR = ../.. @@ -15,23 +15,23 @@ WXDIR = ../.. # this central makefile. include $(WXDIR)/src/makeg95.env -OBJECTS = $(OBJDIR)/conftest.$(OBJSUFF) $(OBJDIR)/conftest_resources.$(OBJSUFF) +OBJECTS = $(OBJDIR)/minimal.$(OBJSUFF) $(OBJDIR)/minimal_resources.$(OBJSUFF) -all: $(OBJDIR) conftest$(GUISUFFIX)$(EXESUFF) +all: $(OBJDIR) minimal$(GUISUFFIX)$(EXESUFF) wx: $(OBJDIR): mkdir $(OBJDIR) -conftest$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB) - $(CC) $(LDFLAGS) -o conftest$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS) +minimal$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB) + $(CC) $(LDFLAGS) -o minimal$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS) -$(OBJDIR)/conftest.$(OBJSUFF): conftest.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ conftest.$(SRCSUFF) +$(OBJDIR)/minimal.$(OBJSUFF): minimal.$(SRCSUFF) + $(CC) -c $(CPPFLAGS) -o $@ minimal.$(SRCSUFF) -$(OBJDIR)/conftest_resources.o: conftest.rc - $(RESCOMP) -i conftest.rc -o $(OBJDIR)/conftest_resources.o $(RESFLAGS) +$(OBJDIR)/minimal_resources.o: minimal.rc + $(RESCOMP) -i minimal.rc -o $(OBJDIR)/minimal_resources.o $(RESFLAGS) clean: - rm -f $(OBJECTS) conftest$(GUISUFFIX).exe core *.rsc *.res + rm -f $(OBJECTS) minimal$(GUISUFFIX).exe core *.rsc *.res diff --git a/samples/minimal/makefile.nt b/samples/minimal/makefile.nt index 276311e09c..0416630669 100644 --- a/samples/minimal/makefile.nt +++ b/samples/minimal/makefile.nt @@ -20,7 +20,7 @@ WXUSINGDLL=0 THISDIR = $(WXDIR)\samples\minimal PROGRAM=minimal - + OBJECTS = $(PROGRAM).obj $(PROGRAM): $(PROGRAM).exe diff --git a/samples/minimal/minimal.cpp b/samples/minimal/minimal.cpp index d0eca73819..e2cdcd941a 100644 --- a/samples/minimal/minimal.cpp +++ b/samples/minimal/minimal.cpp @@ -38,7 +38,8 @@ class MyApp: public wxApp // Define a new frame type class MyFrame: public wxFrame { public: - MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h); + MyFrame(wxFrame *parent, const wxString& title, + const wxPoint& pos, const wxSize& size); public: void OnQuit(wxCommandEvent& event); @@ -62,19 +63,15 @@ END_EVENT_TABLE() // Create a new application object IMPLEMENT_APP (MyApp) -// `Main program' equivalent, creating windows and returning main app frame +// `Main program' equivalent bool MyApp::OnInit(void) { // Create the main frame window - MyFrame *frame = new MyFrame((wxFrame *) NULL, (char *) "Minimal wxWindows App", 50, 50, 450, 340); + MyFrame *frame = new MyFrame((wxFrame *) NULL, "Minimal wxWindows App", + wxPoint(50, 50), wxSize(450, 340)); // Give it an icon -#ifdef __WXMSW__ - frame->SetIcon(wxIcon("mondrian")); -#endif -#ifdef __WXGTK__ - frame->SetIcon(wxIcon( mondrian_xpm )); -#endif + frame->SetIcon(wxICON(mondrian)); // Make a menubar wxMenu *file_menu = new wxMenu; @@ -99,8 +96,9 @@ bool MyApp::OnInit(void) } // My frame constructor -MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h): - wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h)) +MyFrame::MyFrame(wxFrame *parent, const wxString& title, + const wxPoint& pos, const wxSize& size): + wxFrame(parent, -1, title, pos, size) {} void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) ) diff --git a/samples/sashtest/Makefile b/samples/sashtest/Makefile new file mode 100644 index 0000000000..bccce53f76 --- /dev/null +++ b/samples/sashtest/Makefile @@ -0,0 +1 @@ +include ../../setup/general/makeapp diff --git a/samples/sashtest/Makefile.in b/samples/sashtest/Makefile.in new file mode 100644 index 0000000000..8199d27501 --- /dev/null +++ b/samples/sashtest/Makefile.in @@ -0,0 +1,26 @@ +# WXXT base directory +WXBASEDIR=@WXBASEDIR@ + +# set the OS type for compilation +OS=@OS@ +# compile a library only +RULE=bin + +# define library name +BIN_TARGET=sashtest +# define library sources +BIN_SRC=\ +sashtest.cpp + +#define library objects +BIN_OBJ=\ +sashtest.o + +# additional things needed to link +BIN_LINK= + +# additional things needed to compile +ADD_COMPILE= + +# include the definitions now +include ../../../template.mak diff --git a/samples/typetest/Makefile b/samples/typetest/Makefile new file mode 100644 index 0000000000..bccce53f76 --- /dev/null +++ b/samples/typetest/Makefile @@ -0,0 +1 @@ +include ../../setup/general/makeapp diff --git a/samples/typetest/Makefile.in b/samples/typetest/Makefile.in new file mode 100644 index 0000000000..6514d719b4 --- /dev/null +++ b/samples/typetest/Makefile.in @@ -0,0 +1,26 @@ +# WXXT base directory +WXBASEDIR=@WXBASEDIR@ + +# set the OS type for compilation +OS=@OS@ +# compile a library only +RULE=bin + +# define library name +BIN_TARGET=typetest +# define library sources +BIN_SRC=\ +typetest.cpp + +#define library objects +BIN_OBJ=\ +typetest.o + +# additional things needed to link +BIN_LINK= + +# additional things needed to compile +ADD_COMPILE= + +# include the definitions now +include ../../../template.mak diff --git a/samples/typetest/makefile.b32 b/samples/typetest/makefile.b32 new file mode 100644 index 0000000000..ac386695cc --- /dev/null +++ b/samples/typetest/makefile.b32 @@ -0,0 +1,63 @@ +# +# File: makefile.b32 +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: +# +# "%W% %G%" +# +# Makefile : Builds typetest example + +# WXWIN and BCCDIR are set by parent make + +WXDIR = $(WXWIN) +!include $(WXDIR)\src\makeb32.env + +WXLIBDIR = $(WXDIR)\lib +WXINC = $(WXDIR)\include\msw +WXLIB = $(WXLIBDIR)\wx32.lib +LIBS=$(WXLIB) cw32 import32 ole2w32 + +TARGET=typetest + +!if "$(FINAL)" == "0" +LINKFLAGS=/v /Tpe /L$(WXLIBDIR);$(BCCDIR)\lib +OPT = -Od +DEBUG_FLAGS= -v +!else +LINKFLAGS=/Tpe /L$(WXLIBDIR);$(BCCDIR)\lib +OPT = -Od +DEBUG_FLAGS = +!endif +CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) + +OBJECTS = typetest.obj + +$(TARGET).exe: $(OBJECTS) $(TARGET).res + tlink32 $(LINKFLAGS) @&&! +c0w32.obj $(OBJECTS) +$(TARGET) +nul +$(LIBS) +! + brc32 -K $(TARGET).res + +.$(SRCSUFF).obj: + bcc32 $(CPPFLAGS) -c {$< } + +.c.obj: + bcc32 $(CPPFLAGS) -P- -c {$< } + +typetest.obj: typetest.$(SRCSUFF) + +$(TARGET).res : $(TARGET).rc $(WXDIR)\include\wx\msw\wx.rc + brc32 -r /i$(BCCDIR)\include /i$(WXDIR)\include $(TARGET) + +clean: + -erase *.obj + -erase *.exe + -erase *.res + -erase *.map + -erase *.rws + diff --git a/samples/typetest/makefile.dos b/samples/typetest/makefile.dos new file mode 100644 index 0000000000..0c9debf866 --- /dev/null +++ b/samples/typetest/makefile.dos @@ -0,0 +1,65 @@ +# +# File: makefile.dos +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile : Builds typetest example (DOS). +# Use FINAL=1 argument to nmake to build final version with no debugging +# info + +WXDIR = $(WXWIN) + +!include $(WXDIR)\src\makemsc.env + +THISDIR = $(WXDIR)\samples\typetest + +!ifndef FINAL +FINAL=0 +!endif + +HEADERS = +SOURCES = typetest.$(SRCSUFF) +OBJECTS = typetest.obj + +all: typetest.exe + +wx: + cd $(WXDIR)\src\msw + nmake -f makefile.dos FINAL=$(FINAL) + cd $(THISDIR) + +wxclean: + cd $(WXDIR)\src\msw + nmake -f makefile.dos clean + cd $(THISDIR) + +typetest.exe: $(WXDIR)\src\msw\dummy.obj $(WXLIB) typetest.obj typetest.def typetest.res + link $(LINKFLAGS) @<< +typetest.obj $(WXDIR)\src\msw\dummy.obj, +typetest, +NUL, +$(LIBS), +typetest.def +; +<< + rc -K typetest.res + +typetest.obj: typetest.$(SRCSUFF) + cl @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +typetest.res : typetest.rc $(WXDIR)\include\wx\msw\wx.rc + rc -r /i$(WXDIR)\include typetest + +clean: + -erase *.obj + -erase *.exe + -erase *.res + -erase *.map + -erase *.sbr + -erase *.pdb diff --git a/samples/typetest/makefile.g95 b/samples/typetest/makefile.g95 new file mode 100644 index 0000000000..692a5095ad --- /dev/null +++ b/samples/typetest/makefile.g95 @@ -0,0 +1,37 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile for typetest example (UNIX). + +WXDIR = ../.. + +# All common UNIX compiler flags and options are now in +# this central makefile. +include $(WXDIR)/src/makeg95.env + +OBJECTS = $(OBJDIR)/typetest.$(OBJSUFF) $(OBJDIR)/typetest_resources.$(OBJSUFF) + +all: $(OBJDIR) typetest$(GUISUFFIX)$(EXESUFF) + +wx: + +$(OBJDIR): + mkdir $(OBJDIR) + +typetest$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB) + $(CC) $(LDFLAGS) -o typetest$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS) + +$(OBJDIR)/typetest.$(OBJSUFF): typetest.$(SRCSUFF) + $(CC) -c $(CPPFLAGS) -o $@ typetest.$(SRCSUFF) + +$(OBJDIR)/typetest_resources.o: typetest.rc + $(RESCOMP) -i typetest.rc -o $(OBJDIR)/typetest_resources.o $(RESFLAGS) + +clean: + rm -f $(OBJECTS) typetest$(GUISUFFIX).exe core *.rsc *.res diff --git a/samples/typetest/makefile.nt b/samples/typetest/makefile.nt new file mode 100644 index 0000000000..1835717c47 --- /dev/null +++ b/samples/typetest/makefile.nt @@ -0,0 +1,64 @@ +# +# File: makefile.nt +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile : Builds typetest example (MS VC++). +# Use FINAL=1 argument to nmake to build final version with no debugging +# info + +# Set WXDIR for your system +WXDIR = $(WXWIN) + +WXUSINGDLL=0 + +!include $(WXDIR)\src\ntwxwin.mak + +THISDIR = $(WXDIR)\samples\typetest +PROGRAM=typetest + +OBJECTS = $(PROGRAM).obj + +$(PROGRAM): $(PROGRAM).exe + +all: wx $(PROGRAM).exe + +wx: + cd $(WXDIR)\src\msw + nmake -f makefile.nt FINAL=$(FINAL) + cd $(THISDIR) + +wxclean: + cd $(WXDIR)\src\msw + nmake -f makefile.nt clean + cd $(THISDIR) + +$(PROGRAM).exe: $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(PROGRAM).res + $(link) @<< +-out:$(PROGRAM).exe +$(LINKFLAGS) +$(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res +$(LIBS) +<< + + +$(PROGRAM).obj: $(PROGRAM).$(SRCSUFF) $(DUMMYOBJ) + $(cc) @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc + $(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc + + +clean: + -erase *.obj + -erase *.exe + -erase *.res + -erase *.map + -erase *.sbr + -erase *.pdb diff --git a/samples/typetest/mondrian.ico b/samples/typetest/mondrian.ico new file mode 100644 index 0000000000000000000000000000000000000000..2310c5d275a87af295d5ea8dc79ea417a5e74c53 GIT binary patch literal 766 zcmZQzU<5)11px*Sc)`TLAO@s0fLH;D9e|jTfdxnc0ZSetIcon(wxICON(mondrian)); + + // Make a menubar + wxMenu *file_menu = new wxMenu; + + file_menu->Append(TYPES_ABOUT, "&About"); + file_menu->AppendSeparator(); + file_menu->Append(TYPES_DATE, "&Date test"); + file_menu->Append(TYPES_TIME, "&Time test"); + file_menu->Append(TYPES_VARIANT, "&Variant test"); + file_menu->AppendSeparator(); + file_menu->Append(TYPES_QUIT, "E&xit"); + wxMenuBar *menu_bar = new wxMenuBar; + menu_bar->Append(file_menu, "&File"); + frame->SetMenuBar(menu_bar); + + m_textCtrl = new wxTextCtrl(frame, -1, "", wxPoint(0, 0), wxDefaultSize, wxTE_MULTILINE); + + // Show the frame + frame->Show(TRUE); + + SetTopWindow(frame); + + return TRUE; +} + +void MyApp::DoTimeDemo(wxCommandEvent& event) +{ + wxTextCtrl& textCtrl = * GetTextCtrl(); + + textCtrl.Clear(); + cout << "\nTest class wxTime" << endl; + wxTime now; + textCtrl << "It is now " << (wxString) now << "\n"; +} + +void MyApp::DoDateDemo(wxCommandEvent& event) +{ + wxTextCtrl& textCtrl = * GetTextCtrl(); + + textCtrl.Clear(); + textCtrl << "\nTest class wxDate" << "\n"; + + // Various versions of the constructors + // and various output + + wxDate x(10,20,1962); + + textCtrl << x.FormatDate(wxFULL) << " (full)\n"; + + // constuctor with a string, just printing the day of the week + wxDate y("8/8/1988"); + + textCtrl << y.FormatDate(wxDAY) << " (just day)\n"; + + // constructor with a julian + wxDate z( 2450000L ); + textCtrl << z.FormatDate(wxFULL) << " (full)\n"; + + // using date addition and subtraction + wxDate a = x + 10; + textCtrl << a.FormatDate(wxFULL) << " (full)\n"; + a = a - 25; + textCtrl << a.FormatDate(wxEUROPEAN) << " (European)\n"; + + + // Using subtraction of two date objects + wxDate a1 = wxString("7/13/1991"); + wxDate a2 = a1 + 14; + textCtrl << (a1-a2) << "\n"; + textCtrl << (a2+=10) << "\n"; + + a1++; + textCtrl << "Tomorrow= " << a1.FormatDate(wxFULL) << "\n"; + + wxDate tmpDate1("08/01/1991"); + wxDate tmpDate2("07/14/1991"); + textCtrl << "a1 (7-14-91) < 8-01-91 ? ==> " << ((a1 < tmpDate1) ? "TRUE" : "FALSE") << "\n"; + textCtrl << "a1 (7-14-91) > 8-01-91 ? ==> " << ((a1 > tmpDate1) ? "TRUE" : "FALSE") << "\n"; + textCtrl << "a1 (7-14-91)== 7-14-91 ? ==> " << ((a1==tmpDate2) ? "TRUE" : "FALSE") << "\n"; + + wxDate a3 = a1; + textCtrl << "a1 (7-14-91)== a3 (7-14-91) ? ==> " << ((a1==a3) ? "TRUE" : "FALSE") << "\n"; + wxDate a4 = a1; + textCtrl << "a1 (7-14-91)== a4 (7-15-91) ? ==> " << ((a1==++a4) ? "TRUE" : "FALSE") << "\n"; + + wxDate a5 = wxString("today"); + textCtrl << "Today is: " << a5 << "\n"; + a4 = "TODAY"; + textCtrl << "Today (a4) is: " << a4 << "\n"; + + textCtrl << "Today + 4 is: " << (a4+=4) << "\n"; + a4 = "TODAY"; + textCtrl << "Today - 4 is: " << (a4-=4) << "\n"; + + textCtrl << "=========== Leap Year Test ===========\n"; + a1 = "1/15/1992"; + textCtrl << a1.FormatDate(wxFULL) << " " << ((a1.IsLeapYear()) ? "Leap" : "non-Leap"); + textCtrl << " " << "day of year: " << a1.GetDayOfYear() << "\n"; + + a1 = "2/16/1993"; + textCtrl << a1.FormatDate(wxFULL) << " " << ((a1.IsLeapYear()) ? "Leap" : "non-Leap"); + textCtrl << " " << "day of year: " << a1.GetDayOfYear() << "\n"; + + textCtrl << "================== string assignment test ====================\n"; + wxString date_string=a1; + textCtrl << "a1 as a string (s/b 2/16/1993) ==> " << date_string << "\n"; + + textCtrl << "================== SetFormat test ============================\n"; + a1.SetFormat(wxFULL); + textCtrl << "a1 (s/b FULL format) ==> " << a1 << "\n"; + a1.SetFormat(wxEUROPEAN); + textCtrl << "a1 (s/b EUROPEAN format) ==> " << a1 << "\n"; + + textCtrl << "================== SetOption test ============================\n"; + textCtrl << "Date abbreviation ON\n"; + + a1.SetOption(wxDATE_ABBR); + a1.SetFormat(wxMONTH); + textCtrl << "a1 (s/b MONTH format) ==> " << a1 << "\n"; + a1.SetFormat(wxDAY); + textCtrl << "a1 (s/b DAY format) ==> " << a1 << "\n"; + a1.SetFormat(wxFULL); + textCtrl << "a1 (s/b FULL format) ==> " << a1 << "\n"; + a1.SetFormat(wxEUROPEAN); + textCtrl << "a1 (s/b EUROPEAN format) ==> " << a1 << "\n"; + textCtrl << "Century suppression ON\n"; + a1.SetOption(wxNO_CENTURY); + a1.SetFormat(wxMDY); + textCtrl << "a1 (s/b MDY format) ==> " << a1 << "\n"; + textCtrl << "Century suppression OFF\n"; + a1.SetOption(wxNO_CENTURY,FALSE); + textCtrl << "a1 (s/b MDY format) ==> " << a1 << "\n"; + textCtrl << "Century suppression ON\n"; + a1.SetOption(wxNO_CENTURY); + textCtrl << "a1 (s/b MDY format) ==> " << a1 << "\n"; + a1.SetFormat(wxFULL); + textCtrl << "a1 (s/b FULL format) ==> " << a1 << "\n"; + + textCtrl << "\n=============== Version 4.0 Enhancement Test =================\n"; + + wxDate v4("11/26/1966"); + textCtrl << "\n---------- Set Stuff -----------\n"; + textCtrl << "First, 'Set' to today..." << "\n"; + textCtrl << "Before 'Set' => " << v4 << "\n"; + textCtrl << "After 'Set' => " << v4.Set() << "\n\n"; + + textCtrl << "Set to 11/26/66 => " << v4.Set(11,26,1966) << "\n"; + textCtrl << "Current Julian => " << v4.GetJulianDate() << "\n"; + textCtrl << "Set to Julian 2450000L => " << v4.Set(2450000L) << "\n"; + textCtrl << "See! => " << v4.GetJulianDate() << "\n"; + + textCtrl << "---------- Add Stuff -----------\n"; + textCtrl << "Start => " << v4 << "\n"; + textCtrl << "Add 4 Weeks => " << v4.AddWeeks(4) << "\n"; + textCtrl << "Sub 1 Month => " << v4.AddMonths(-1) << "\n"; + textCtrl << "Add 2 Years => " << v4.AddYears(2) << "\n"; + + textCtrl << "---------- Misc Stuff -----------\n"; + textCtrl << "The date aboves' day of the month is => " << v4.GetDay() << "\n"; + textCtrl << "There are " << v4.GetDaysInMonth() << " days in this month.\n"; + textCtrl << "The first day of this month lands on " << v4.GetFirstDayOfMonth() << "\n"; + textCtrl << "This day happens to be " << v4.GetDayOfWeekName() << "\n"; + textCtrl << "the " << v4.GetDayOfWeek() << " day of the week," << "\n"; + textCtrl << "on the " << v4.GetWeekOfYear() << " week of the year," << "\n"; + textCtrl << "on the " << v4.GetWeekOfMonth() << " week of the month, " << "\n"; + textCtrl << "(which is " << v4.GetMonthName() << ")\n"; + textCtrl << "the "<< v4.GetMonth() << "th month in the year.\n"; + textCtrl << "The year alone is " << v4.GetYear() << "\n"; + + textCtrl << "---------- First and Last Stuff -----------\n"; + v4.Set(); + textCtrl << "The first date of this month is " << v4.GetMonthStart() << "\n"; + textCtrl << "The last date of this month is " << v4.GetMonthEnd() << "\n"; + textCtrl << "The first date of this year is " << v4.GetYearStart() << "\n"; + textCtrl << "The last date of this year is " << v4.GetYearEnd() << "\n"; +} + +void MyApp::DoVariantDemo(wxCommandEvent& event) +{ + wxTextCtrl& textCtrl = * GetTextCtrl(); + + wxVariant var1 = "String value"; + textCtrl << "var1 = " << (wxString) var1 << "\n"; + + // Implicit conversion + wxString str = var1; + + var1 = 123.456; + textCtrl << "var1 = " << var1.GetReal() << "\n"; + + // Implicit conversion + double v = var1; + + var1 = 9876L; + textCtrl << "var1 = " << var1.GetLong() << "\n"; + + // Implicit conversion + long l = var1; + + wxStringList stringList; + stringList.Add("one"); stringList.Add("two"); stringList.Add("three"); + var1 = stringList; + textCtrl << "var1 = " << (wxString) var1 << "\n"; + + var1.ClearList(); + var1.Append(wxVariant(1.2345)); + var1.Append(wxVariant("hello")); + var1.Append(wxVariant(54321L)); + + textCtrl << "var1 = " << (wxString) var1 << "\n"; + + size_t n = var1.GetCount(); + size_t i; + for (i = (size_t) 0; i < n; i++) + { + textCtrl << "var1[" << (int) i << "] (type " << var1[i].GetType() << ") = " << (wxString) var1[i] << "\n"; + } +} + +BEGIN_EVENT_TABLE(MyFrame, wxFrame) + EVT_MENU(TYPES_QUIT, MyFrame::OnQuit) + EVT_MENU(TYPES_ABOUT, MyFrame::OnAbout) +END_EVENT_TABLE() + +// My frame constructor +MyFrame::MyFrame(wxFrame *parent, const wxString& title, + const wxPoint& pos, const wxSize& size): + wxFrame(parent, -1, title, pos, size) +{} + +void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) ) +{ + Close(TRUE); +} + +void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) ) +{ + wxMessageDialog dialog(this, "Tests various wxWindows types", + "About Types", wxYES_NO|wxCANCEL); + + dialog.ShowModal(); +} + + diff --git a/samples/typetest/typetest.def b/samples/typetest/typetest.def new file mode 100644 index 0000000000..ece630c311 --- /dev/null +++ b/samples/typetest/typetest.def @@ -0,0 +1,9 @@ + * Last change: JS 11 Sep 98 1:22 pm +NAME Typetest +DESCRIPTION 'Typetest wxWindows application' +EXETYPE WINDOWS +STUB 'WINSTUB.EXE' +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE MULTIPLE +HEAPSIZE 4048 +STACKSIZE 16000 diff --git a/samples/typetest/typetest.h b/samples/typetest/typetest.h new file mode 100644 index 0000000000..8cd87eac03 --- /dev/null +++ b/samples/typetest/typetest.h @@ -0,0 +1,67 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: typetest.h +// Purpose: Types wxWindows sample +// Author: Julian Smart +// Modified by: +// Created: 04/01/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma interface "typetest.h" +#endif + +#ifndef _WX_TYPETEST_H_ +#define _WX_TYPETEST_H_ + +// Define a new application type +class MyApp: public wxApp +{ +public: + bool OnInit(void); + + void DoDateDemo(wxCommandEvent& event); + void DoTimeDemo(wxCommandEvent& event); + void DoVariantDemo(wxCommandEvent& event); + + wxTextCtrl* GetTextCtrl() const { return m_textCtrl; } + +private: + wxTextCtrl* m_textCtrl; + +DECLARE_DYNAMIC_CLASS(MyApp) +DECLARE_EVENT_TABLE() +}; + +DECLARE_APP(MyApp) + +// Define a new frame type +class MyFrame: public wxFrame +{ +public: + MyFrame(wxFrame *parent, const wxString& title, + const wxPoint& pos, const wxSize& size); + +public: + void OnQuit(wxCommandEvent& event); + void OnAbout(wxCommandEvent& event); + bool OnClose(void) { return TRUE; } + + DECLARE_EVENT_TABLE() + +}; + +// ID for the menu commands +#define TYPES_QUIT wxID_EXIT +#define TYPES_TEXT 101 +#define TYPES_ABOUT 102 + +#define TYPES_DATE 103 +#define TYPES_TIME 104 +#define TYPES_VARIANT 105 + +#endif + // _WX_TYPETEST_H_ + diff --git a/samples/typetest/typetest.rc b/samples/typetest/typetest.rc new file mode 100644 index 0000000000..7655c62a4c --- /dev/null +++ b/samples/typetest/typetest.rc @@ -0,0 +1,3 @@ +mondrian ICON "mondrian.ico" +#include "wx/msw/wx.rc" + -- 2.45.2