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
This commit is contained in:
Julian Smart
1998-09-12 17:33:59 +00:00
parent 8cb50e4b46
commit cfb88c5569
17 changed files with 725 additions and 22 deletions

View File

@@ -7,7 +7,7 @@
# #
# "%W% %G%" # "%W% %G%"
# #
# Makefile for conftest example (UNIX). # Makefile for minimal example (UNIX).
WXDIR = ../.. WXDIR = ../..
@@ -15,23 +15,23 @@ WXDIR = ../..
# this central makefile. # this central makefile.
include $(WXDIR)/src/makeg95.env 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: wx:
$(OBJDIR): $(OBJDIR):
mkdir $(OBJDIR) mkdir $(OBJDIR)
conftest$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB) minimal$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB)
$(CC) $(LDFLAGS) -o conftest$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS) $(CC) $(LDFLAGS) -o minimal$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS)
$(OBJDIR)/conftest.$(OBJSUFF): conftest.$(SRCSUFF) $(OBJDIR)/minimal.$(OBJSUFF): minimal.$(SRCSUFF)
$(CC) -c $(CPPFLAGS) -o $@ conftest.$(SRCSUFF) $(CC) -c $(CPPFLAGS) -o $@ minimal.$(SRCSUFF)
$(OBJDIR)/conftest_resources.o: conftest.rc $(OBJDIR)/minimal_resources.o: minimal.rc
$(RESCOMP) -i conftest.rc -o $(OBJDIR)/conftest_resources.o $(RESFLAGS) $(RESCOMP) -i minimal.rc -o $(OBJDIR)/minimal_resources.o $(RESFLAGS)
clean: clean:
rm -f $(OBJECTS) conftest$(GUISUFFIX).exe core *.rsc *.res rm -f $(OBJECTS) minimal$(GUISUFFIX).exe core *.rsc *.res

View File

@@ -20,7 +20,7 @@ WXUSINGDLL=0
THISDIR = $(WXDIR)\samples\minimal THISDIR = $(WXDIR)\samples\minimal
PROGRAM=minimal PROGRAM=minimal
OBJECTS = $(PROGRAM).obj OBJECTS = $(PROGRAM).obj
$(PROGRAM): $(PROGRAM).exe $(PROGRAM): $(PROGRAM).exe

View File

@@ -38,7 +38,8 @@ class MyApp: public wxApp
// Define a new frame type // Define a new frame type
class MyFrame: public wxFrame class MyFrame: public wxFrame
{ public: { 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: public:
void OnQuit(wxCommandEvent& event); void OnQuit(wxCommandEvent& event);
@@ -62,19 +63,15 @@ END_EVENT_TABLE()
// Create a new application object // Create a new application object
IMPLEMENT_APP (MyApp) IMPLEMENT_APP (MyApp)
// `Main program' equivalent, creating windows and returning main app frame // `Main program' equivalent
bool MyApp::OnInit(void) bool MyApp::OnInit(void)
{ {
// Create the main frame window // 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 // Give it an icon
#ifdef __WXMSW__ frame->SetIcon(wxICON(mondrian));
frame->SetIcon(wxIcon("mondrian"));
#endif
#ifdef __WXGTK__
frame->SetIcon(wxIcon( mondrian_xpm ));
#endif
// Make a menubar // Make a menubar
wxMenu *file_menu = new wxMenu; wxMenu *file_menu = new wxMenu;
@@ -99,8 +96,9 @@ bool MyApp::OnInit(void)
} }
// My frame constructor // My frame constructor
MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h): MyFrame::MyFrame(wxFrame *parent, const wxString& title,
wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h)) const wxPoint& pos, const wxSize& size):
wxFrame(parent, -1, title, pos, size)
{} {}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) ) void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )

View File

@@ -0,0 +1 @@
include ../../setup/general/makeapp

View File

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

View File

@@ -0,0 +1 @@
include ../../setup/general/makeapp

View File

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

View File

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

View File

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

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

View File

@@ -0,0 +1,44 @@
/* XPM */
static char *mondrian_xpm[] = {
/* columns rows colors chars-per-pixel */
"32 32 6 1",
" c Black",
". c Blue",
"X c #00bf00",
"o c Red",
"O c Yellow",
"+ c Gray100",
/* pixels */
" ",
" oooooo +++++++++++++++++++++++ ",
" oooooo +++++++++++++++++++++++ ",
" oooooo +++++++++++++++++++++++ ",
" oooooo +++++++++++++++++++++++ ",
" oooooo +++++++++++++++++++++++ ",
" oooooo +++++++++++++++++++++++ ",
" oooooo +++++++++++++++++++++++ ",
" ",
" ++++++ ++++++++++++++++++ .... ",
" ++++++ ++++++++++++++++++ .... ",
" ++++++ ++++++++++++++++++ .... ",
" ++++++ ++++++++++++++++++ .... ",
" ++++++ ++++++++++++++++++ .... ",
" ++++++ ++++++++++++++++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++ ",
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
" "
};

View File

@@ -0,0 +1,299 @@
/////////////////////////////////////////////////////////////////////////////
// Name: typetest.cpp
// Purpose: Types wxWindows sample
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "typetest.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 "wx/time.h"
#include "wx/date.h"
#include "wx/variant.h"
#include "typetest.h"
#ifdef __WXGTK__
#include "mondrian.xpm"
#endif
// Create a new application object
IMPLEMENT_APP (MyApp)
IMPLEMENT_DYNAMIC_CLASS (MyApp, wxApp)
BEGIN_EVENT_TABLE(MyApp, wxApp)
EVT_MENU(TYPES_DATE, MyApp::DoDateDemo)
EVT_MENU(TYPES_TIME, MyApp::DoTimeDemo)
EVT_MENU(TYPES_VARIANT, MyApp::DoVariantDemo)
END_EVENT_TABLE()
bool MyApp::OnInit(void)
{
// Create the main frame window
MyFrame *frame = new MyFrame((wxFrame *) NULL, "wxWindows Types Demo",
wxPoint(50, 50), wxSize(450, 340));
// Give it an icon
frame->SetIcon(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();
}

View File

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

View File

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

View File

@@ -0,0 +1,3 @@
mondrian ICON "mondrian.ico"
#include "wx/msw/wx.rc"