Initial revision

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Karsten Ballüder
1998-05-20 14:01:55 +00:00
parent 1b66e7e5ab
commit c801d85f15
779 changed files with 172138 additions and 0 deletions

1
samples/mdi/Makefile Normal file
View File

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

26
samples/mdi/Makefile.in Normal file
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=test
# define library sources
BIN_SRC=\
mdi.cpp
#define library objects
BIN_OBJ=\
mdi.o
# additional things needed to link
BIN_LINK=
# additional things needed to compile
ADD_COMPILE=
# include the definitions now
include ../../../template.mak

BIN
samples/mdi/aiai.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

38
samples/mdi/aiai.xbm Normal file
View File

@@ -0,0 +1,38 @@
#define aiai_width 64
#define aiai_height 64
static char aiai_bits[] = {
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
0x11,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
0x44,0x44,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
0x11,0x11,0x11,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
0x44,0x44,0x44,0x44,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
0x11,0x11,0x11,0x11,0x11,0x44,0x44,0x44,0x42,0x44,0x44,0x44,0x44,0x44,0x44,
0x44,0x47,0x44,0x44,0x44,0x44,0x11,0x11,0x11,0x17,0x11,0x11,0x11,0x11,0x11,
0x11,0x91,0x1f,0x11,0x11,0x11,0x11,0x44,0x44,0xc4,0x4f,0x44,0x44,0x44,0x44,
0x44,0x44,0xc4,0x5f,0x44,0xf4,0x45,0x44,0x11,0x11,0xf1,0x1f,0x11,0xf9,0x13,
0x11,0x11,0x11,0xf1,0x3f,0x11,0xfd,0x13,0x11,0x44,0x44,0xf4,0x7f,0x44,0xfc,
0x47,0x44,0x44,0x44,0xf4,0x7f,0x44,0xfc,0x47,0x44,0x11,0x11,0xf9,0x7f,0x11,
0xf9,0x13,0x11,0x11,0x11,0xfd,0xff,0x11,0xf1,0x11,0x11,0x44,0x44,0xfc,0xff,
0x44,0x44,0x44,0x44,0x44,0x44,0xfe,0xff,0x45,0x44,0x44,0x44,0x11,0x11,0xff,
0xff,0x11,0xfd,0x13,0x11,0x11,0x11,0xff,0xff,0x13,0xfd,0x13,0x11,0x44,0xc4,
0xff,0xff,0x07,0xfc,0x43,0x44,0x44,0xff,0xff,0xf9,0xff,0xfd,0xfb,0xff,0x11,
0xc0,0xff,0x00,0x00,0xfc,0x03,0x00,0x11,0xc0,0x7f,0x00,0x00,0xfc,0x03,0x00,
0x04,0xe0,0x7f,0x00,0x00,0xfc,0x03,0x00,0xf4,0xf7,0xbf,0xff,0xff,0xfd,0xfb,
0x7f,0x01,0xf0,0x1f,0x00,0x00,0xfc,0x03,0x00,0x01,0xf8,0x1f,0x00,0x00,0xfc,
0x03,0x00,0x00,0xfc,0x0f,0x00,0x00,0xfc,0x03,0x40,0xfe,0xfd,0xef,0xff,0xff,
0xfd,0xfb,0x4f,0x00,0xfe,0x07,0x00,0x00,0xfc,0x03,0x10,0x00,0xfe,0x03,0x00,
0x00,0xfc,0x03,0x10,0x00,0xff,0x03,0x00,0x00,0xfc,0x03,0x44,0x7f,0xff,0x01,
0x00,0x00,0xfc,0xfb,0x44,0x91,0xff,0xff,0xff,0xff,0xff,0x13,0x11,0xd1,0xff,
0xff,0xff,0xff,0xff,0x13,0x11,0xe4,0xff,0xff,0xff,0xff,0xff,0x47,0x44,0xe4,
0xff,0xff,0xff,0xff,0xff,0x47,0x44,0xf1,0xff,0xff,0xff,0xff,0xff,0x13,0x11,
0xf1,0xff,0xff,0xff,0xff,0xff,0x13,0x11,0xfc,0xff,0xff,0xff,0xff,0xff,0x47,
0x44,0xfc,0xff,0xff,0xff,0xff,0xff,0x47,0x44,0x11,0x11,0x11,0x11,0x11,0x11,
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x10,0x11,0x44,0x44,0xc4,0x44,0x44,
0xc4,0x44,0x44,0x44,0x4e,0xc4,0x44,0x4e,0xc4,0x44,0x44,0x11,0x1f,0xd1,0x11,
0x1f,0xd1,0x11,0x11,0x91,0x31,0xd1,0x91,0x31,0xd1,0x11,0x11,0xc4,0x64,0xcc,
0xcc,0x64,0xcc,0x44,0x44,0x64,0xc4,0xcc,0x6c,0xc4,0xcc,0x44,0x44,0xf1,0xff,
0xd1,0xf1,0xff,0xd1,0x11,0x11,0xf9,0xff,0xd3,0xf9,0xff,0xd3,0x11,0x11,0x4c,
0x44,0xc6,0x4c,0x44,0xc6,0x44,0x44,0x4c,0x44,0xc6,0x4c,0x44,0xc6,0x44,0x44,
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
0x11,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
0x44,0x44};

BIN
samples/mdi/chart.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

64
samples/mdi/makefile.b32 Normal file
View File

@@ -0,0 +1,64 @@
#
# File: makefile.b32
# Author: Patrick Halke
# Created: 1995
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile : Builds 32bit MDI example.
# WXWIN and BCCDIR are set by parent make
WXDIR = $(WXWIN)
!include $(WXDIR)\src\makeb32.env
WXLIBDIR = $(WXDIR)\lib
WXLIB = $(WXLIBDIR)\wx32.lib
LIBS=$(WXLIB) cw32 import32
TARGET=mdi
!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 = mdi.obj
$(TARGET).exe: $(OBJECTS) $(TARGET).def $(TARGET).res
tlink32 $(LINKFLAGS) @&&!
c0w32.obj $(OBJECTS)
$(TARGET)
nul
$(LIBS)
$(TARGET).def
!
brc32 -K $(TARGET).res
.$(SRCSUFF).obj:
bcc32 $(CPPFLAGS) -c {$< }
.c.obj:
bcc32 $(CPPFLAGS) -P- -c {$< }
mdi.obj: mdi.$(SRCSUFF) mdi.h
$(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

75
samples/mdi/makefile.bcc Normal file
View File

@@ -0,0 +1,75 @@
#
# File: makefile.bcc
# Author: Julian Smart
# Created: 1993
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile : Builds mdi example (DOS).
!if "$(BCCDIR)" == ""
!error You must define the BCCDIR variable in autoexec.bat, e.g. BCCDIR=d:\bc4
!endif
!if "$(WXWIN)" == ""
!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
!endif
!ifndef FINAL
FINAL=0
!endif
WXDIR = $(WXWIN)
!include $(WXDIR)\src\makebcc.env
THISDIR = $(WXDIR)\samples\mdi
WXLIB = $(WXDIR)\lib\wx.lib
LIBS=$(WXLIB) mathwl cwl import
INC=-I$(WXDIR)\include\base -I$(WXDIR)\include\msw
CFG=$(WXDIR)\src\wxwin.cfg
!if "$(FINAL)" == "0"
LINKFLAGS=/v/Vt /Twe /L$(WXDIR)\lib;$(BCCDIR)\lib
OPT = -Od
DEBUG_FLAGS= -v
!else
LINKFLAGS=/Twe /L$(WXDIR)\lib;$(BCCDIR)\lib
OPT = -O2
DEBUG_FLAGS =
!endif
CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG)
HEADERS = mdi.h
SOURCES = mdi.$(SRCSUFF)
OBJECTS = mdi.obj
mdi: mdi.exe
all: mdi.exe
mdi.exe: $(WXLIB) mdi.obj mdi.def mdi.res
tlink $(LINKFLAGS) @&&!
c0wl.obj mdi.obj
mdi
nul
$(LIBS)
mdi.def
!
rc -30 -K mdi.res
.$(SRCSUFF).obj:
bcc $(CPPFLAGS) -c {$< }
mdi.obj: mdi.$(SRCSUFF)
mdi.res : mdi.rc $(WXDIR)\include\msw\wx.rc
rc -r /i$(BCCDIR)\include /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa mdi
clean:
-erase *.obj
-erase *.exe
-erase *.res
-erase *.map
-erase *.rws

63
samples/mdi/makefile.dos Normal file
View File

@@ -0,0 +1,63 @@
#
# File: makefile.dos
# Author: Julian Smart
# Created: 1993
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile : Builds mdi 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\mdi
INC=/I$(WXDIR)\include
HEADERS = mdi.h
SOURCES = mdi.$(SRCSUFF)
OBJECTS = mdi.obj
all: mdi.exe
wx:
cd $(WXDIR)\src\msw
nmake -f makefile.dos
cd $(THISDIR)
wxclean:
cd $(WXDIR)\src\msw
nmake -f makefile.dos clean
cd $(THISDIR)
mdi.exe: $(WXDIR)\src\msw\dummy.obj $(WXLIB) mdi.obj mdi.def mdi.res
link $(LINKFLAGS) @<<
$(WXDIR)\src\msw\dummy.obj mdi.obj,
mdi,
NUL,
$(LIBS),
mdi.def
;
<<
rc -K mdi.res
mdi.obj: mdi.h mdi.$(SRCSUFF)
cl @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
<<
mdi.res : mdi.rc $(WXDIR)\include\wx\msw\wx.rc
rc -r /i$(WXDIR)\include mdi
clean:
-erase *.obj
-erase *.exe
-erase *.res
-erase *.map
-erase *.sbr
-erase *.pdb

35
samples/mdi/makefile.g95 Normal file
View File

@@ -0,0 +1,35 @@
#
# File: makefile.unx
# Author: Julian Smart
# Created: 1993
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile for mdi example (UNIX).
WXDIR = ../..
# All common UNIX compiler flags and options are now in
# this central makefile.
include $(WXDIR)/src/makeg95.env
OBJECTS = $(OBJDIR)/mdi.$(OBJSUFF) $(OBJDIR)/mdi_resources.$(OBJSUFF)
all: $(OBJDIR) mdi.exe
$(OBJDIR):
mkdir $(OBJDIR)
mdi.exe: $(OBJECTS) $(WXLIB)
$(CC) $(LDFLAGS) -o mdi.exe $(OBJECTS) $(LDLIBS)
$(OBJDIR)/mdi.$(OBJSUFF): mdi.$(SRCSUFF) mdi.h
$(CC) -c $(CPPFLAGS) -o $@ mdi.$(SRCSUFF)
$(OBJDIR)/mdi_resources.o: mdi.rc
$(RESCOMP) -i mdi.rc -o $(OBJDIR)/mdi_resources.o $(RESFLAGS)
clean:
rm -f $(OBJECTS) mdi$(GUISUFFIX).exe core *.res *.rsc

63
samples/mdi/makefile.nt Normal file
View File

@@ -0,0 +1,63 @@
#
# File: makefile.nt
# Author: Julian Smart
# Created: 1993
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile : Builds mdi 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\mdi
PROGRAM=mdi
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

36
samples/mdi/makefile.sc Normal file
View File

@@ -0,0 +1,36 @@
# Symantec C++ makefile for mdi example
# NOTE that peripheral libraries are now dealt in main wxWindows makefile.
WXDIR = $(WXWIN)
!include $(WXDIR)\src\makesc.env
WXLIB = $(WXDIR)\lib\wx.lib
INCDIR = $(WXDIR)\include
MSWINC = $(INCDIR)\msw
BASEINC = $(INCDIR)\base
CC=sc
RC=rc
CFLAGS = -o -ml -W -Dwx_msw
LDFLAGS = -ml -W
INCLUDE=$(BASEINC);$(MSWINC)
LIBS=$(WXLIB) libw.lib commdlg.lib shell.lib
.$(SRCSUFF).obj:
*$(CC) -c $(CFLAGS) -I$(INCLUDE) $<
.rc.res:
*$(RC) -r -I$(INCLUDE) $<
mdi.exe: mdi.obj mdi.def mdi.res
*$(CC) $(LDFLAGS) -o$@ mdi.obj mdi.def $(LIBS)
*$(RC) -k mdi.res
clean:
-del *.obj
-del *.exe
-del *.res
-del *.map
-del *.rws

55
samples/mdi/makefile.unx Normal file
View File

@@ -0,0 +1,55 @@
#
# File: makefile.unx
# Author: Julian Smart
# Created: 1993
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile for mdi example (UNIX).
WXDIR = ../..
# All common UNIX compiler flags and options are now in
# this central makefile.
include $(WXDIR)/src/make.env
OBJECTS = $(OBJDIR)/mdi.$(OBJSUFF)
.SUFFIXES:
all: $(OBJDIR) mdi$(GUISUFFIX)
wx:
# cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx
motif:
$(MAKE) -f makefile.unx GUISUFFIX=_motif GUI=-Dwx_motif GUISUFFIX=_motif OPT='$(OPT)' LDLIBS='$(MOTIFLDLIBS)' OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' XVIEW_LINK=
xview:
$(MAKE) -f makefile.unx GUI=-Dwx_xview GUISUFFIX=_ol CC=$(CC) OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)'
hp:
$(MAKE) -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_hp CC=CC DEBUG='$(DEBUG)' WARN='-w' \
XINCLUDE='$(HPXINCLUDE)' XLIB='$(HPXLIB)' XVIEW_LINK='' LDLIBS='$(HPLDLIBS)'
$(OBJDIR):
mkdir $(OBJDIR)
mdi$(GUISUFFIX): $(OBJDIR)/mdi.$(OBJSUFF) $(WXLIB)
$(CC) $(LDFLAGS) -o mdi$(GUISUFFIX) $(OBJDIR)/mdi.$(OBJSUFF) $(XVIEW_LINK) $(LDLIBS)
$(OBJDIR)/mdi.$(OBJSUFF): mdi.$(SRCSUFF) mdi.h
$(CC) -c $(CPPFLAGS) -o $@ mdi.$(SRCSUFF)
clean_motif:
$(MAKE) -f makefile.unx GUISUFFIX=_motif cleanany
clean_ol:
$(MAKE) -f makefile.unx GUISUFFIX=_ol cleanany
clean_hp:
$(MAKE) -f makefile.unx GUISUFFIX=_hp cleanany
cleanany:
rm -f $(OBJECTS) mdi$(GUISUFFIX) core

38
samples/mdi/makefile.vms Normal file
View File

@@ -0,0 +1,38 @@
#************************************************************************
# Makefile for MDI under VMS
# by Stefan Hammes
# (incomplete) update history:
# 11.04.95
#************************************************************************
#************************************************************************
# Definition section
# (cave: definitions and includes must begin with ',')
#************************************************************************
APPOPTS =
APPDEFS =
APPINCS =
#************************************************************************
# Module section
#************************************************************************
# Name of main module
MAIN = mdi
# Object modules of the application.
OBJS = mdi.obj
OBJLIST =mdi.obj
.include [--.src]makevms.env
# main dependency
$(MAIN).exe : $(OBJS)
$(LINK) $(LINKFLAGS) /exec=$(MAIN).exe $(OBJLIST),$(WXLIB)/lib,$(OPTSFILE)/option
- purge *.exe
#************************************************************************
# Header file depedencies following
#************************************************************************

43
samples/mdi/makefile.wat Normal file
View File

@@ -0,0 +1,43 @@
#
# Makefile for WATCOM
#
# Created by D.Chubraev, chubraev@iem.ee.ethz.ch
# 8 Nov 1994
#
WXDIR = ..\..
!include $(WXDIR)\src\makewat.env
WXLIB = $(WXDIR)\lib
NAME = mdi
LNK = $(name).lnk
OBJS = $(name).obj
all: $(name).exe
$(name).exe : $(OBJS) $(name).res $(LNK) $(WXLIB)\wx$(LEVEL).lib
wlink @$(LNK)
$(BINDCOMMAND) $(name).res
$(name).res : $(name).rc $(WXDIR)\include\msw\wx.rc
$(RC) $(RESFLAGS1) $(name).rc
$(LNK) : makefile.wat
%create $(LNK)
@%append $(LNK) debug all
@%append $(LNK) system $(LINKOPTION)
@%append $(LNK) $(MINDATA)
@%append $(LNK) $(MAXDATA)
@%append $(LNK) $(STACK)
@%append $(LNK) name $(name)
@%append $(LNK) file $(WXLIB)\wx$(LEVEL).lib
@for %i in ($(EXTRALIBS)) do @%append $(LNK) file %i
@for %i in ($(OBJS)) do @%append $(LNK) file %i
thing: .SYMBOLIC
echo $(WATLIBDIR)
clean: .SYMBOLIC
-erase *.obj *.bak *.err *.pch *.lib *.lnk *.res *.exe *.rex

381
samples/mdi/mdi.cpp Normal file
View File

@@ -0,0 +1,381 @@
/////////////////////////////////////////////////////////////////////////////
// Name: mdi.cpp
// Purpose: MDI sample
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
// 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"
#include "wx/mdi.h"
#endif
#ifdef __WINDOWS__
#include <wx/tbar95.h>
#endif
#include "mdi.h"
MyFrame *frame = NULL;
wxList my_children;
IMPLEMENT_APP(MyApp)
// For drawing lines in a canvas
long xpos = -1;
long ypos = -1;
int winNumber = 1;
// Initialise this in OnInit, not statically
bool MyApp::OnInit(void)
{
// Create the main frame window
frame = new MyFrame(NULL, -1, "MDI Demo", wxPoint(0, 0), wxSize(500, 400),
wxDEFAULT_FRAME | wxHSCROLL | wxVSCROLL);
// Give it an icon (this is ignored in MDI mode: uses resources)
#ifdef __WINDOWS__
frame->SetIcon(wxIcon("mdi_icn"));
#endif
#ifdef __X__
frame->SetIcon(wxIcon("aiai.xbm"));
#endif
// Make a menubar
wxMenu *file_menu = new wxMenu;
file_menu->Append(MDI_NEW_WINDOW, "&New window");
file_menu->Append(MDI_QUIT, "&Exit");
wxMenu *help_menu = new wxMenu;
help_menu->Append(MDI_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
frame->SetMenuBar(menu_bar);
frame->CreateStatusBar();
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
EVT_MENU(MDI_QUIT, MyFrame::OnQuit)
EVT_MENU(MDI_ABOUT, MyFrame::OnAbout)
EVT_MENU(MDI_NEW_WINDOW, MyFrame::OnNewWindow)
EVT_SIZE(MyFrame::OnSize)
END_EVENT_TABLE()
// Define my frame constructor
MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size,
const long style):
wxMDIParentFrame(parent, id, title, pos, size, style)
{
textWindow = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE|wxSUNKEN_BORDER);
textWindow->SetValue("A help window");
#ifdef __WINDOWS__
toolBar = new TestRibbon(this, 0, 0, 100, 30, wxNO_BORDER, wxVERTICAL, 1);
SetToolBar(toolBar);
#endif
}
void MyFrame::OnQuit(wxCommandEvent& event)
{
Close(TRUE);
}
void MyFrame::OnAbout(wxCommandEvent& event)
{
(void)wxMessageBox("wxWindows 2.0 MDI Demo\nAuthor: Julian Smart (c) 1997\nUsage: mdi.exe", "About MDI Demo");
}
void MyFrame::OnNewWindow(wxCommandEvent& event)
{
// Make another frame, containing a canvas
MyChild *subframe = new MyChild(frame, "Canvas Frame", wxPoint(10, 10), wxSize(300, 300),
wxDEFAULT_FRAME);
char titleBuf[100];
sprintf(titleBuf, "Canvas Frame %d", winNumber);
subframe->SetTitle(titleBuf);
winNumber ++;
// Give it an icon (this is ignored in MDI mode: uses resources)
#ifdef __WINDOWS__
subframe->SetIcon(wxIcon("chrt_icn"));
#endif
#ifdef __X__
subframe->SetIcon(wxIcon("aiai.xbm"));
#endif
// Give it a status line
subframe->CreateStatusBar();
// Make a menubar
wxMenu *file_menu = new wxMenu;
file_menu->Append(MDI_NEW_WINDOW, "&New window");
file_menu->Append(MDI_CHILD_QUIT, "&Close child");
file_menu->Append(MDI_QUIT, "&Exit");
wxMenu *option_menu = new wxMenu;
// Dummy option
option_menu->Append(MDI_REFRESH, "&Refresh picture");
wxMenu *help_menu = new wxMenu;
help_menu->Append(MDI_ABOUT, "&About");
wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, "&File");
menu_bar->Append(option_menu, "&Options");
menu_bar->Append(help_menu, "&Help");
// Associate the menu bar with the frame
subframe->SetMenuBar(menu_bar);
int width, height;
subframe->GetClientSize(&width, &height);
MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height));
canvas->SetCursor(wxCursor(wxCURSOR_PENCIL));
subframe->canvas = canvas;
// Give it scrollbars
canvas->SetScrollbars(20, 20, 50, 50);
subframe->Show(TRUE);
}
BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
EVT_MOUSE_EVENTS(MyCanvas::OnEvent)
END_EVENT_TABLE()
// Define a constructor for my canvas
MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size):
wxScrolledWindow(parent, -1, pos, size, wxSUNKEN_BORDER)
{
}
// Define the repainting behaviour
void MyCanvas::OnDraw(wxDC& dc)
{
dc.SetFont(*wxSWISS_FONT);
dc.SetPen(*wxGREEN_PEN);
dc.DrawLine(0, 0, 200, 200);
dc.DrawLine(200, 0, 0, 200);
dc.SetBrush(*wxCYAN_BRUSH);
dc.SetPen(*wxRED_PEN);
dc.DrawRectangle(100, 100, 100, 50);
dc.DrawRoundedRectangle(150, 150, 100, 50, 20);
dc.DrawEllipse(250, 250, 100, 50);
dc.DrawSpline(50, 200, 50, 100, 200, 10);
dc.DrawLine(50, 230, 200, 230);
dc.DrawText("This is a test string", 50, 230);
}
// This implements a tiny doodling program! Drag the mouse using
// the left button.
void MyCanvas::OnEvent(wxMouseEvent& event)
{
wxClientDC dc(this);
PrepareDC(dc);
wxPoint pt(event.GetLogicalPosition(dc));
if (xpos > -1 && ypos > -1 && event.Dragging())
{
dc.SetPen(*wxBLACK_PEN);
dc.DrawLine(xpos, ypos, pt.x, pt.y);
}
xpos = pt.x;
ypos = pt.y;
}
// Define the behaviour for the frame closing
// - must delete all frames except for the main one.
bool MyFrame::OnClose(void)
{
// Must delete children
wxNode *node = my_children.First();
while (node)
{
MyChild *child = (MyChild *)node->Data();
wxNode *next = node->Next();
child->OnClose();
delete child;
node = next;
}
return TRUE;
}
void MyFrame::OnSize(wxSizeEvent& event)
{
int w, h;
GetClientSize(&w, &h);
int tw = 0;
int th = 0;
#ifdef __WINDOWS__
wxWindow* tbar = GetToolBar();
if (tbar)
{
tbar->GetSize(&tw, &th);
tbar->SetSize(w, th);
}
#endif
textWindow->SetSize(0, th, 200, h-th);
GetClientWindow()->SetSize(200, th, w - 200, h-th);
}
// Note that MDI_NEW_WINDOW and MDI_ABOUT commands get passed
// to the parent window for processing, so no need to
// duplicate event handlers here.
BEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame)
EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit)
END_EVENT_TABLE()
MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size,
const long style):
wxMDIChildFrame(parent, -1, title, pos, size, style)
{
canvas = NULL;
my_children.Append(this);
}
MyChild::~MyChild(void)
{
my_children.DeleteObject(this);
}
void MyChild::OnQuit(wxCommandEvent& event)
{
Close(TRUE);
}
void MyChild::OnActivate(wxActivateEvent& event)
{
if (event.GetActive() && canvas)
canvas->SetFocus();
}
bool MyChild::OnClose(void)
{
return TRUE;
}
#ifdef __WINDOWS__
BEGIN_EVENT_TABLE(TestRibbon, wxToolBar95)
EVT_PAINT(TestRibbon::OnPaint)
END_EVENT_TABLE()
TestRibbon::TestRibbon(wxFrame *frame, int x, int y, int w, int h,
long style, int direction, int RowsOrColumns):
wxToolBar95(frame, -1, wxPoint(x, y), wxSize(w, h), style, direction, RowsOrColumns)
{
wxBitmap* bitmaps[8];
bitmaps[0] = new wxBitmap("icon1", wxBITMAP_TYPE_RESOURCE);
bitmaps[1] = new wxBitmap("icon2", wxBITMAP_TYPE_RESOURCE);
bitmaps[2] = new wxBitmap("icon3", wxBITMAP_TYPE_RESOURCE);
bitmaps[3] = new wxBitmap("icon4", wxBITMAP_TYPE_RESOURCE);
bitmaps[4] = new wxBitmap("icon5", wxBITMAP_TYPE_RESOURCE);
bitmaps[5] = new wxBitmap("icon6", wxBITMAP_TYPE_RESOURCE);
bitmaps[6] = new wxBitmap("icon7", wxBITMAP_TYPE_RESOURCE);
bitmaps[7] = new wxBitmap("icon8", wxBITMAP_TYPE_RESOURCE);
#ifdef __WINDOWS__
int width = 24;
#else
int width = 16;
#endif
int offX = 5;
int currentX = 5;
AddTool(0, bitmaps[0], wxNullBitmap, FALSE, (float)currentX, -1, NULL, "New file");
currentX += width + 5;
AddTool(1, bitmaps[1], wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Open file");
currentX += width + 5;
AddTool(2, bitmaps[2], wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Save file");
currentX += width + 5;
AddSeparator();
AddTool(3, bitmaps[3], wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Copy");
currentX += width + 5;
AddTool(4, bitmaps[4], wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Cut");
currentX += width + 5;
AddTool(5, bitmaps[5], wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Paste");
currentX += width + 5;
AddSeparator();
AddTool(6, bitmaps[6], wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Print");
currentX += width + 5;
AddSeparator();
AddTool(7, bitmaps[7], wxNullBitmap, TRUE, currentX, -1, NULL, "Help");
CreateTools();
int i;
for (i = 0; i < 8; i++)
delete bitmaps[i];
}
bool TestRibbon::OnLeftClick(int toolIndex, bool toggled)
{
char buf[200];
sprintf(buf, "Clicked on tool %d", toolIndex);
frame->SetStatusText(buf);
return TRUE;
}
void TestRibbon::OnMouseEnter(int toolIndex)
{
char buf[200];
if (toolIndex > -1)
{
sprintf(buf, "This is tool number %d", toolIndex);
frame->SetStatusText(buf);
}
else frame->SetStatusText("");
}
void TestRibbon::OnPaint(wxPaintEvent& event)
{
wxToolBar95::OnPaint(event);
wxPaintDC dc(this);
int w, h;
GetSize(&w, &h);
dc.SetPen(wxBLACK_PEN);
dc.SetBrush(wxTRANSPARENT_BRUSH);
dc.DrawLine(0, h-1, w, h-1);
}
#endif

8
samples/mdi/mdi.def Normal file
View File

@@ -0,0 +1,8 @@
NAME Mdi
DESCRIPTION 'MDI/SDI Test Program'
EXETYPE WINDOWS
STUB 'WINSTUB.EXE'
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
HEAPSIZE 6000
STACKSIZE 48000

82
samples/mdi/mdi.h Normal file
View File

@@ -0,0 +1,82 @@
/////////////////////////////////////////////////////////////////////////////
// Name: mdi.cpp
// Purpose: MDI sample
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
// Define a new application
class MyApp: public wxApp
{
public:
bool OnInit(void);
};
class MyCanvas: public wxScrolledWindow
{
public:
MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size);
virtual void OnDraw(wxDC& dc);
void OnEvent(wxMouseEvent& event);
DECLARE_EVENT_TABLE()
};
#ifdef __WINDOWS__
class TestRibbon: public wxToolBar95
{
public:
TestRibbon(wxFrame *frame, int x = 0, int y = 0, int w = -1, int h = -1,
long style = wxNO_BORDER, int direction = wxVERTICAL, int RowsOrColumns = 2);
bool OnLeftClick(int toolIndex, bool toggled);
void OnMouseEnter(int toolIndex);
void OnPaint(wxPaintEvent& event);
DECLARE_EVENT_TABLE()
};
#endif
// Define a new frame
class MyFrame: public wxMDIParentFrame
{
public:
wxTextCtrl *textWindow;
#ifdef __WINDOWS__
TestRibbon* toolBar;
#endif
MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
bool OnClose(void);
void OnSize(wxSizeEvent& event);
void OnAbout(wxCommandEvent& event);
void OnNewWindow(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
class MyChild: public wxMDIChildFrame
{
public:
MyCanvas *canvas;
MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
~MyChild(void);
bool OnClose(void);
void OnActivate(wxActivateEvent& event);
void OnQuit(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
#define MDI_QUIT 1
#define MDI_NEW_WINDOW 2
#define MDI_REFRESH 3
#define MDI_CHILD_QUIT 4
#define MDI_ABOUT 5

BIN
samples/mdi/mdi.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

24
samples/mdi/mdi.rc Normal file
View File

@@ -0,0 +1,24 @@
aaaa ICON "mondrian.ico"
/* Useful if PROVIDE_DEFAULT_ICONS is set in wx_setup.h */
#define IHaveMDIParentIcon
#define IHaveMDIChildIcon
wxSTD_MDIPARENTFRAME ICON "mondrian.ico"
wxSTD_MDICHILDFRAME ICON "chart.ico"
mdi_icn ICON "mondrian.ico"
chrt_icn ICON "chart.ico"
icon1 BITMAP "bitmaps/new.bmp"
icon2 BITMAP "bitmaps/open.bmp"
icon3 BITMAP "bitmaps/save.bmp"
icon4 BITMAP "bitmaps/copy.bmp"
icon5 BITMAP "bitmaps/cut.bmp"
icon6 BITMAP "bitmaps/paste.bmp"
icon7 BITMAP "bitmaps/print.bmp"
icon8 BITMAP "bitmaps/help.bmp"
#include "wx/msw/wx.rc"

BIN
samples/mdi/mondrian.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B