Created new, simplified toolbar sample; removed other toolbar samples.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@326 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 1998-07-23 14:39:46 +00:00
parent 73e7daa02e
commit 14d1ccd89d
24 changed files with 810 additions and 16 deletions

View File

@ -26,9 +26,7 @@ all:
cd $(WXDIR)/samples/minimal; make -f makefile.g95
cd $(WXDIR)/samples/layout; make -f makefile.g95
cd $(WXDIR)/samples/printing; make -f makefile.g95
cd $(WXDIR)/samples/tbarsmpl; make -f makefile.g95
cd $(WXDIR)/samples/tbar95; make -f makefile.g95
cd $(WXDIR)/samples/tbarmsw; make -f makefile.g95
cd $(WXDIR)/samples/toolbar; make -f makefile.g95
cd $(WXDIR)/samples/dialogs; make -f makefile.g95
cd $(WXDIR)/samples/docview; make -f makefile.g95
cd $(WXDIR)/samples/controls; make -f makefile.g95
@ -48,9 +46,7 @@ clean:
cd $(WXDIR)/samples/minimal; make -f makefile.g95 clean
cd $(WXDIR)/samples/layout; make -f makefile.g95 clean
cd $(WXDIR)/samples/printing; make -f makefile.g95 clean
cd $(WXDIR)/samples/tbarsmpl; make -f makefile.g95 clean
cd $(WXDIR)/samples/tbarmsw; make -f makefile.g95 clean
cd $(WXDIR)/samples/tbar95; make -f makefile.g95 clean
cd $(WXDIR)/samples/toolbar; make -f makefile.g95 clean
cd $(WXDIR)/samples/dialogs; make -f makefile.g95 clean
cd $(WXDIR)/samples/resource; make -f makefile.g95 clean
cd $(WXDIR)/samples/listctrl; make -f makefile.g95 clean

View File

@ -42,11 +42,7 @@ all:
nmake -f makefile.nt DEBUG_FLAGS=$(DEBUG_FLAGS) LINK_DEBUG_FLAGS=$(LINK_DEBUG_FLAGS)
cd $(WXDIR)\samples\printing
nmake -f makefile.nt DEBUG_FLAGS=$(DEBUG_FLAGS) LINK_DEBUG_FLAGS=$(LINK_DEBUG_FLAGS)
cd $(WXDIR)\samples\tbarsmpl
nmake -f makefile.nt DEBUG_FLAGS=$(DEBUG_FLAGS) LINK_DEBUG_FLAGS=$(LINK_DEBUG_FLAGS)
cd $(WXDIR)\samples\tbar95
nmake -f makefile.nt DEBUG_FLAGS=$(DEBUG_FLAGS) LINK_DEBUG_FLAGS=$(LINK_DEBUG_FLAGS)
cd $(WXDIR)\samples\tbarmsw
cd $(WXDIR)\samples\toolbar
nmake -f makefile.nt DEBUG_FLAGS=$(DEBUG_FLAGS) LINK_DEBUG_FLAGS=$(LINK_DEBUG_FLAGS)
cd $(WXDIR)\samples\dialogs
nmake -f makefile.nt DEBUG_FLAGS=$(DEBUG_FLAGS) LINK_DEBUG_FLAGS=$(LINK_DEBUG_FLAGS)
@ -106,11 +102,7 @@ clean:
nmake -f makefile.nt clean
cd $(WXDIR)\samples\printing
nmake -f makefile.nt clean
cd $(WXDIR)\samples\tbarsmpl
nmake -f makefile.nt clean
cd $(WXDIR)\samples\tbarmsw
nmake -f makefile.nt clean
cd $(WXDIR)\samples\tbar95
cd $(WXDIR)\samples\toolbar
nmake -f makefile.nt clean
cd $(WXDIR)\samples\dialogs
nmake -f makefile.nt clean

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

View File

@ -0,0 +1,63 @@
#
# File: makefile.b32
# Author: Patrick Halke
# Created: 1995
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile : Builds 32bit buttonbar 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=test
!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 = test.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 {$< }
test.obj: test.$(SRCSUFF) test.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

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 wxButtonbar sample
!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
# Change WXDIR to wherever wxWindows is found
WXDIR = $(WXWIN)
!include $(WXDIR)\src\makebcc.env
WXLIB = $(WXDIR)\lib\wx.lib
WXINC = $(WXDIR)\include
CFG=$(WXDIR)\src\wxwin.cfg
BUTTNBARDIR = $(WXDIR)\samples\toolbar
THISDIR = $(BUTTNBARDIR)
INC=
LIBS=$(WXLIB) mathwl cwl import
!ifndef FINAL
FINAL=0
!endif
!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) $(INC) @$(CFG)
CFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG)
OBJECTS = test.obj
all: test.exe
.$(SRCSUFF).obj:
bcc $(CPPFLAGS) -c {$< }
test.res : test.rc $(WXDIR)\include\msw\wx.rc
rc /i$(BCCDIR)\include /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa -r test
test.exe: test.obj test.def test.res
tlink $(LINKFLAGS) @&&!
c0wl.obj test.obj
test
nul
$(LIBS)
test.def
!
rc -K test.res
clean:
-erase *.obj
-erase *.exe

View File

@ -0,0 +1,87 @@
#
# File: makefile.dos
# Author: Julian Smart
# Created: 1993
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile : Builds wxToolbar sample
# Use FINAL=1 argument to nmake to build final version with no debugging
# info
# Set WXDIR for your system
WXDIR = $(WXWIN)
!include $(WXDIR)\src\makemsc.env
BBARDIR = $(WXDIR)\samples\toolbar
INC = /I$(WXDIR)\include\base /I$(WXDIR)\include\msw
THISDIR = $(BBARDIR)
!ifndef FINAL
FINAL=0
!endif
# Default is to output RTF for WinHelp
!ifndef WINHELP
WINHELP=-winhelp
!endif
# Set this to nothing if using MS C++ 7
ZOPTION=/Z7
!if "$(FINAL)" == "0"
CPPFLAGS=/AL /Gt8 /W3 /Zi $(ZOPTION) /G2sw /Od /YuWX_PREC.H $(INC) /Dwx_msw /Fp$(WXDIR)\src\msw\wx.pch
CFLAGS=/AL /Gt8 /W3 /Zi $(ZOPTION) /G2sw /Od $(INC) /Dwx_msw
LINKFLAGS=/NOD /CO /SEG:512 /ONERROR:NOEXE
!else
CPPFLAGS=/AL /Gt8 /W3 /G2sw /Os /YuWX_PREC.H $(INC) /Dwx_msw /Fp$(WXDIR)\src\msw\wx.pch
CFLAGS=/AL /Gt8 /W3 /Zi $(ZOPTION) /G2sw /Od $(INC) /Dwx_msw
LINKFLAGS=/NOD /SEG:512 /ONERROR:NOEXE
!endif
OBJECTS = test.obj
all: test.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)
test.exe: $(WXDIR)\src\msw\dummy.obj $(WXLIB) test.obj test.def test.res
link $(LINKFLAGS) @<<
$(WXDIR)\src\msw\dummy.obj test.obj,
test,
NUL,
$(LIBS),
test.def
;
<<
rc -30 -K test.res
test.obj: test.h test.$(SRCSUFF)
cl @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
<<
test.res : test.rc $(WXDIR)\include\msw\wx.rc
rc -r /dFAFA_LIB /i$(WXDIR)\contrib\fafa /i$(WXDIR)\include\msw test
clean:
-erase *.obj
-erase *.exe
-erase *.res
-erase *.map
-erase *.sbr
-erase *.pdb

View File

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

View File

@ -0,0 +1,62 @@
#
# File: makefile.nt
# Author: Julian Smart
# Created: 1993
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile : Builds buttnbar example (MS VC++).
# Use FINAL=1 argument to nmake to build final version with no debugging
# info
# Set WXDIR for your system
WXDIR = $(WXWIN)
!include $(WXDIR)\src\ntwxwin.mak
THISDIR = $(WXDIR)\samples\toolbar
PROGRAM=test
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).h $(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 *.sbr
-erase *.exe
-erase *.res
-erase *.map
-erase *.pdb

View File

@ -0,0 +1,42 @@
# Symantec C++ makefile for the buttonbar library
WXDIR = $(WXWIN)
!include $(WXDIR)\src\makesc.env
WXLIB = $(WXDIR)\lib\wx.lib
INCDIR = $(WXDIR)\include
MSWINC = $(INCDIR)\msw
BASEINC = $(INCDIR)\base
BUTTNBARDIR = $(WXDIR)\samples\buttnbar
# Default is to output RTF for WinHelp
WINHELP=-winhelp
CC=sc
RC=rc
CFLAGS = -o -ml -W -Dwx_msw
LDFLAGS = -ml -W
INCLUDE=$(BASEINC);$(MSWINC)
LIBS=$(WXLIB) libw.lib commdlg.lib shell.lib
all: test.exe
.$(SRCSUFF).obj:
*$(CC) -c $(CFLAGS) -I$(INCLUDE) $<
.rc.res:
*$(RC) -r -I$(INCLUDE) $<
test.exe: test.obj test.def test.res
*$(CC) $(LDFLAGS) -o$@ test.obj test.def $(LIBS)
*$(RC) -k test.res
clean:
-del *.obj
-del *.exe
-del *.res
-del *.map

View File

@ -0,0 +1,80 @@
#
# File: makefile.unx
# Author: Julian Smart
# Created: 1993
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile for wxToolBar example (UNIX).
# Change the WXDIR directory, and CPPFLAGS and LDFLAGS, for your system.
WXDIR = ../..
# All common UNIX compiler flags and options are now in
# this central makefile.
include $(WXDIR)/src/make.env
TOOLBARDIR = $(WXDIR)/samples/toolbar
OBJECTS = $(OBJDIR)/wx_bbar.$(OBJSUFF)
TESTOBJECTS = $(OBJDIR)/test.$(OBJSUFF)
TESTPROGRAM = $(TOOLBARDIR)/test$(GUISUFFIX)
LDFLAGS = $(XLIB) -L$(WXDIR)/lib
XVIEWLDLIBS = -lwx_ol -lxview -lolgx -lX11 -lm $(COMPLIBS)
MOTIFLDLIBS = -lwx_motif -lXm -lXt -lX11 -lm $(COMPLIBS)
HPLDLIBS = -lwx_hp -lXm -lXt -lX11 -lm $(HPCOMPLIBS)
# Default
LDLIBS=$(XVIEWLDLIBS)
all: $(OBJDIR) $(TESTPROGRAM)
demo: $(TESTPROGRAM)
.SUFFIXES:
wx:
cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx GUI=$(GUI)
motif:
cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx motif OPT='$(OPT)'
$(MAKE) -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_motif OPT='$(OPT)' LDLIBS='$(MOTIFLDLIBS)' XVIEW_LINK=
demo_motif:
$(MAKE) -f makefile.unx all demo GUI=-Dwx_motif GUISUFFIX=_motif OPT='$(OPT)' LDLIBS='$(MOTIFLDLIBS)' XVIEW_LINK=
xview:
cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx xview OPT='$(OPT)'
$(MAKE) -f makefile.unx GUI=-Dwx_xview OPT='$(OPT)'
demo_ol:
$(MAKE) -f makefile.unx all demo GUI=-Dwx_xview OPT='$(OPT)'
hp:
$(MAKE) -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_hp CC=CC DEBUG='$(DEBUG)' OPT='' WARN='-w' \
XINCLUDE='$(HPXINCLUDE)' XLIB='$(HPXLIB)' XVIEW_LINK='' CCLEX='cc' \
LDLIBS='$(HPLDLIBS)'
$(OBJDIR):
mkdir $(OBJDIR)
$(OBJDIR)/test.$(OBJSUFF): test.h test.$(SRCSUFF)
$(CC) -c $(CPPFLAGS) -o $@ test.$(SRCSUFF)
$(TESTPROGRAM): $(OBJDIR)/test.$(OBJSUFF) $(WXLIB)
$(CC) $(LDFLAGS) -o test$(GUISUFFIX) $(OBJDIR)/test.$(OBJSUFF) $(XVIEW_LINK) $(LDLIBS)
cleaneach:
rm -f $(OBJECTS) test$(GUISUFFIX) $(OBJDIR)/test.$(OBJSUFF) core
clean_motif:
$(MAKE) -f makefile.unx GUISUFFIX=_motif cleaneach
clean_ol:
$(MAKE) -f makefile.unx GUISUFFIX=_ol cleaneach
clean_hp:
$(MAKE) -f makefile.unx GUISUFFIX=_hp cleaneach

View File

@ -0,0 +1,49 @@
#
# 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 = test
LNK = $(name).lnk
OBJS = $(name).obj
THISDIR = $(WXDIR)\samples\buttnbar
all: $(name).exe
wx: .SYMBOLIC
cd $(WXDIR)\src\msw
wmake -f makefile.wat all
cd $(THISDIR)
$(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

234
samples/toolbar/test.cpp Normal file
View File

@ -0,0 +1,234 @@
/////////////////////////////////////////////////////////////////////////////
// Name: test.cpp
// Purpose: wxToolBar sample
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// 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/toolbar.h"
#include "test.h"
IMPLEMENT_APP(MyApp)
#ifdef __X__
// TODO: include XBM or XPM icons for X apps
#endif
// The `main program' equivalent, creating the windows and returning the
// main frame
bool MyApp::OnInit(void)
{
// Create the main frame window
MyFrame* frame = new MyFrame(NULL, -1, "wxToolBar Sample", wxPoint(100, 100), wxSize(450, 300));
// Give it a status line
frame->CreateStatusBar();
// Give it an icon
#ifdef __WXMSW__
frame->SetIcon(wxIcon("mondrian"));
#endif
#ifdef __X__
frame->SetIcon(wxIcon("mondrian.xbm"));
#endif
// Make a menubar
wxMenu *fileMenu = new wxMenu;
fileMenu->Append(TEST_QUIT, "E&xit");
wxMenu *helpMenu = new wxMenu;
helpMenu->Append(TEST_ABOUT, "&About");
wxMenuBar* menuBar = new wxMenuBar;
menuBar->Append(fileMenu, "&File");
menuBar->Append(helpMenu, "&Help");
// Associate the menu bar with the frame
frame->SetMenuBar(menuBar);
// Create the toolbar
TestToolBar* toolRibbon = new TestToolBar(frame, -1, wxPoint(0, 0), wxSize(100, 30),
wxNO_BORDER|wxTB_FLAT, wxVERTICAL, 1);
toolRibbon->SetMargins(5, 5);
// Tell the frame about it
frame->SetToolBar(toolRibbon);
// Force a resize, just in case.
frame->OnSize(wxSizeEvent(wxSize(-1, -1), frame->GetId()));
frame->Show(TRUE);
frame->SetStatusText("Hello, wxWindows");
SetTopWindow(frame);
return TRUE;
}
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(TEST_QUIT, MyFrame::OnQuit)
EVT_MENU(TEST_ABOUT, MyFrame::OnAbout)
EVT_MENU_HIGHLIGHT_ALL(MyFrame::OnMenuHighlight)
EVT_CLOSE(MyFrame::OnCloseWindow)
END_EVENT_TABLE()
// Define my frame constructor
MyFrame::MyFrame(wxFrame* parent, wxWindowID id, const wxString& title, const wxPoint& pos,
const wxSize& size, long style):
wxFrame(parent, id, title, pos, size, style)
{
m_textWindow = new wxTextCtrl(this, -1, "", wxPoint(0, 0), wxSize(-1, -1), wxTE_MULTILINE);
}
void MyFrame::OnQuit(wxCommandEvent& event)
{
Close(TRUE);
}
void MyFrame::OnAbout(wxCommandEvent& event)
{
(void)wxMessageBox("wxWindows wxToolBar demo\n", "About wxToolBar");
}
// Intercept menu item selection - only has an effect in Windows
void MyFrame::OnMenuHighlight(wxMenuEvent& event)
{
char *msg = NULL;
switch (event.GetMenuId())
{
case TEST_QUIT:
msg = "Quit program";
break;
case -1:
msg = "";
break;
}
if (msg)
SetStatusText(msg);
}
// Define the behaviour for the frame closing
// - must delete all frames except for the main one.
void MyFrame::OnCloseWindow(wxCloseEvent& event)
{
Destroy();
}
BEGIN_EVENT_TABLE(TestToolBar, wxToolBar95)
EVT_PAINT(TestToolBar::OnPaint)
END_EVENT_TABLE()
TestToolBar::TestToolBar(wxFrame* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, int direction, int RowsOrColumns):
wxToolBar(parent, id, pos, size, style, direction, RowsOrColumns)
{
// Set up toolbar
wxBitmap* toolBarBitmaps[8];
#ifdef __WXMSW__
toolBarBitmaps[0] = new wxBitmap("icon1");
toolBarBitmaps[1] = new wxBitmap("icon2");
toolBarBitmaps[2] = new wxBitmap("icon3");
toolBarBitmaps[3] = new wxBitmap("icon4");
toolBarBitmaps[4] = new wxBitmap("icon5");
toolBarBitmaps[5] = new wxBitmap("icon6");
toolBarBitmaps[6] = new wxBitmap("icon7");
toolBarBitmaps[7] = new wxBitmap("icon8");
#endif
#ifdef __X__
// TODO
toolBarBitmaps[0] = new wxBitmap(...);
toolBarBitmaps[1] = new wxBitmap(...);
toolBarBitmaps[2] = new wxBitmap(...);
toolBarBitmaps[3] = new wxBitmap(...);
toolBarBitmaps[4] = new wxBitmap(...);
toolBarBitmaps[5] = new wxBitmap(...);
toolBarBitmaps[6] = new wxBitmap(...);
toolBarBitmaps[7] = new wxBitmap(...);
#endif
#ifdef __WXMSW__
int width = 24;
#else
int width = 16;
#endif
int offX = 5;
int currentX = 5;
AddTool(0, *(toolBarBitmaps[0]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "New file");
currentX += width + 5;
AddTool(1, *(toolBarBitmaps[1]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Open file");
currentX += width + 5;
AddTool(2, *(toolBarBitmaps[2]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Save file");
currentX += width + 5;
AddSeparator();
AddTool(3, *(toolBarBitmaps[3]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Copy");
currentX += width + 5;
AddTool(4, *(toolBarBitmaps[4]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Cut");
currentX += width + 5;
AddTool(5, *(toolBarBitmaps[5]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Paste");
currentX += width + 5;
AddSeparator();
AddTool(6, *(toolBarBitmaps[6]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Print");
currentX += width + 5;
AddSeparator();
AddTool(7, *(toolBarBitmaps[7]), wxNullBitmap, TRUE, currentX, -1, NULL, "Help");
CreateTools();
// Can delete the bitmaps since they're reference counted
int i;
for (i = 0; i < 8; i++)
delete toolBarBitmaps[i];
}
bool TestToolBar::OnLeftClick(int toolIndex, bool toggled)
{
char buf[200];
sprintf(buf, "Clicked on tool %d", toolIndex);
((wxFrame*) GetParent())->SetStatusText(buf);
return TRUE;
}
void TestToolBar::OnMouseEnter(int toolIndex)
{
char buf[200];
if (toolIndex > -1)
{
sprintf(buf, "This is tool number %d", toolIndex);
((wxFrame*)GetParent())->SetStatusText(buf);
}
else ((wxFrame*)GetParent())->SetStatusText("");
}
void TestToolBar::OnPaint(wxPaintEvent& event)
{
wxToolBar::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);
}

8
samples/toolbar/test.def Normal file
View File

@ -0,0 +1,8 @@
NAME ToolTest
DESCRIPTION 'wxToolBar Sample'
EXETYPE WINDOWS
STUB 'WINSTUB.EXE'
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
HEAPSIZE 1024
STACKSIZE 8192

53
samples/toolbar/test.h Normal file
View File

@ -0,0 +1,53 @@
/////////////////////////////////////////////////////////////////////////////
// Name: test.h
// Purpose: wxToolBar sample
// Author: Julian Smart
// Modified by:
// Created: 23/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// Define a new application
class MyApp: public wxApp
{
public:
bool OnInit(void);
};
// Define a new frame
class MyFrame: public wxFrame
{
public:
MyFrame(wxFrame *parent, wxWindowID id = -1, const wxString& title = "wxToolBar Sample",
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE);
void OnCloseWindow(wxCloseEvent& event);
void OnMenuHighlight(wxMenuEvent& event);
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
private:
wxTextCtrl* m_textWindow;
DECLARE_EVENT_TABLE()
};
class TestToolBar: public wxToolBar
{
public:
TestToolBar(wxFrame *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
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()
};
#define TEST_QUIT 100
#define TEST_ABOUT 101

13
samples/toolbar/test.rc Normal file
View File

@ -0,0 +1,13 @@
mondrian ICON "mondrian.ico"
#include "wx/msw/wx.rc"
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"