*** empty log message ***
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
BIN
samples/checklst/bell.bmp
Normal file
BIN
samples/checklst/bell.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 370 B |
185
samples/checklst/checklst.cpp
Normal file
185
samples/checklst/checklst.cpp
Normal file
@@ -0,0 +1,185 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: checklst.cpp
|
||||
// Purpose: wxCheckListBox sample
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 13.11.97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// headers & declarations
|
||||
// ============================================================================
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "wx/ownerdrw.h"
|
||||
#include "wx/menuitem.h"
|
||||
#include "wx/msw/checklst.h"
|
||||
|
||||
// Define a new application type
|
||||
class CheckListBoxApp: public wxApp
|
||||
{
|
||||
public:
|
||||
bool OnInit();
|
||||
};
|
||||
|
||||
// Define a new frame type
|
||||
class CheckListBoxFrame : public wxFrame
|
||||
{
|
||||
public:
|
||||
// ctor & dtor
|
||||
CheckListBoxFrame(wxFrame *frame, char *title, int x, int y, int w, int h);
|
||||
~CheckListBoxFrame();
|
||||
|
||||
// notifications
|
||||
void OnQuit (wxCommandEvent& event);
|
||||
void OnAbout (wxCommandEvent& event);
|
||||
void OnListboxSelect (wxCommandEvent& event);
|
||||
void OnCheckboxToggle (wxCommandEvent& event);
|
||||
void OnListboxDblClick (wxCommandEvent& event);
|
||||
bool OnClose () { return TRUE; }
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
private:
|
||||
wxCheckListBox *m_pListBox;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
Menu_Quit = 1,
|
||||
Control_First = 1000,
|
||||
Control_Listbox, Control_Listbox2,
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(CheckListBoxFrame, wxFrame)
|
||||
EVT_MENU(Menu_Quit, CheckListBoxFrame::OnQuit)
|
||||
EVT_LISTBOX(Control_Listbox, CheckListBoxFrame::OnListboxSelect)
|
||||
EVT_CHECKLISTBOX(Control_Listbox, CheckListBoxFrame::OnCheckboxToggle)
|
||||
EVT_COMMAND(Control_Listbox, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,
|
||||
CheckListBoxFrame::OnListboxDblClick)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_APP(CheckListBoxApp);
|
||||
|
||||
// init our app: create windows
|
||||
bool CheckListBoxApp::OnInit(void)
|
||||
{
|
||||
CheckListBoxFrame *pFrame = new CheckListBoxFrame(NULL, "wxWindows Ownerdraw Sample",
|
||||
50, 50, 450, 320);
|
||||
SetTopWindow(pFrame);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// main frame constructor
|
||||
CheckListBoxFrame::CheckListBoxFrame(wxFrame *frame, char *title, int x, int y, int w, int h)
|
||||
: wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
|
||||
{
|
||||
// set the icon
|
||||
SetIcon(wxIcon("mondrian"));
|
||||
|
||||
// Make a menubar
|
||||
wxMenu *file_menu = new wxMenu;
|
||||
|
||||
// construct submenu
|
||||
file_menu->Append(Menu_Quit, "E&xit");
|
||||
|
||||
wxMenuBar *menu_bar = new wxMenuBar;
|
||||
menu_bar->Append(file_menu, "&File");
|
||||
SetMenuBar(menu_bar);
|
||||
|
||||
// make a panel with some controls
|
||||
wxPanel *pPanel = new wxPanel(this, -1, wxPoint(0, 0),
|
||||
wxSize(400, 200), wxTAB_TRAVERSAL);
|
||||
|
||||
// check list box
|
||||
static const char* aszChoices[] = { "Hello", "world", "and",
|
||||
"goodbye", "cruel", "world",
|
||||
"-------", "owner-drawn", "listbox" };
|
||||
|
||||
wxString *astrChoices = new wxString[WXSIZEOF(aszChoices)];
|
||||
uint ui;
|
||||
for ( ui = 0; ui < WXSIZEOF(aszChoices); ui++ )
|
||||
astrChoices[ui] = aszChoices[ui];
|
||||
|
||||
m_pListBox = new wxCheckListBox
|
||||
(
|
||||
pPanel, // parent
|
||||
Control_Listbox, // control id
|
||||
wxPoint(10, 10), // listbox poistion
|
||||
wxSize(400, 200), // listbox size
|
||||
WXSIZEOF(aszChoices), // number of strings
|
||||
astrChoices // array of strings
|
||||
);
|
||||
|
||||
delete [] astrChoices;
|
||||
|
||||
for ( ui = 0; ui < WXSIZEOF(aszChoices); ui += 2 ) {
|
||||
m_pListBox->GetItem(ui)->SetBackColor(wxColor(200, 200, 200));
|
||||
}
|
||||
|
||||
m_pListBox->Check(2);
|
||||
|
||||
// create the status line
|
||||
const int widths[] = { -1, 60 };
|
||||
CreateStatusBar(2);
|
||||
SetStatusWidths(2, widths);
|
||||
SetStatusText("no selection", 0);
|
||||
|
||||
Show(TRUE);
|
||||
}
|
||||
|
||||
CheckListBoxFrame::~CheckListBoxFrame()
|
||||
{
|
||||
}
|
||||
|
||||
void CheckListBoxFrame::OnQuit(wxCommandEvent& event)
|
||||
{
|
||||
Close(TRUE);
|
||||
}
|
||||
|
||||
void CheckListBoxFrame::OnAbout(wxCommandEvent& event)
|
||||
{
|
||||
wxMessageDialog dialog(this, "Demo of wxCheckListBox control\n"
|
||||
"About wxCheckListBox", wxYES_NO | wxCANCEL);
|
||||
dialog.ShowModal();
|
||||
}
|
||||
|
||||
void CheckListBoxFrame::OnListboxSelect(wxCommandEvent& event)
|
||||
{
|
||||
wxString strSelection;
|
||||
uint nSel = event.GetSelection();
|
||||
strSelection.sprintf("item %d selected (%schecked)", nSel,
|
||||
m_pListBox->IsChecked(nSel) ? "" : "not ");
|
||||
SetStatusText(strSelection);
|
||||
}
|
||||
|
||||
void CheckListBoxFrame::OnListboxDblClick(wxCommandEvent& event)
|
||||
{
|
||||
wxString strSelection;
|
||||
strSelection.sprintf("item %d double clicked", m_pListBox->GetSelection());
|
||||
wxMessageDialog dialog(this, strSelection);
|
||||
dialog.ShowModal();
|
||||
}
|
||||
|
||||
void CheckListBoxFrame::OnCheckboxToggle(wxCommandEvent& event)
|
||||
{
|
||||
wxString strSelection;
|
||||
uint nItem = event.GetInt();
|
||||
strSelection.sprintf("item %d was %schecked", nItem,
|
||||
m_pListBox->IsChecked(nItem) ? "" : "un");
|
||||
SetStatusText(strSelection);
|
||||
}
|
8
samples/checklst/checklst.def
Normal file
8
samples/checklst/checklst.def
Normal file
@@ -0,0 +1,8 @@
|
||||
NAME CHECKLST
|
||||
DESCRIPTION 'wxCheckListBox sample'
|
||||
EXETYPE WINDOWS
|
||||
STUB 'WINSTUB.EXE'
|
||||
CODE PRELOAD MOVEABLE DISCARDABLE
|
||||
DATA PRELOAD MOVEABLE MULTIPLE
|
||||
HEAPSIZE 4048
|
||||
STACKSIZE 16000
|
6
samples/checklst/checklst.rc
Normal file
6
samples/checklst/checklst.rc
Normal file
@@ -0,0 +1,6 @@
|
||||
mondrian ICON "mondrian.ico"
|
||||
bell BITMAP "bell.bmp"
|
||||
sound BITMAP "sound.bmp"
|
||||
nosound BITMAP "nosound.bmp"
|
||||
#include "wx/msw/wx.rc"
|
||||
|
64
samples/checklst/makefile.b32
Normal file
64
samples/checklst/makefile.b32
Normal file
@@ -0,0 +1,64 @@
|
||||
#
|
||||
# File: makefile.bcc
|
||||
# Author: Julian Smart
|
||||
# Created: 1993
|
||||
# Updated:
|
||||
# Copyright: (c) 1993, AIAI, University of Edinburgh
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile : Builds checklst example (DOS).
|
||||
|
||||
# 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
|
||||
|
||||
TARGET=checklst
|
||||
|
||||
!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 = checklst.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 {$< }
|
||||
|
||||
checklst.obj: checklst.$(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
|
||||
|
65
samples/checklst/makefile.dos
Normal file
65
samples/checklst/makefile.dos
Normal 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 checklst 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\checklst
|
||||
|
||||
!ifndef FINAL
|
||||
FINAL=0
|
||||
!endif
|
||||
|
||||
HEADERS =
|
||||
SOURCES = checklst.$(SRCSUFF)
|
||||
OBJECTS = checklst.obj
|
||||
|
||||
all: checklst.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)
|
||||
|
||||
checklst.exe: $(WXDIR)\src\msw\dummy.obj $(WXLIB) checklst.obj checklst.def checklst.res
|
||||
link $(LINKFLAGS) @<<
|
||||
checklst.obj $(WXDIR)\src\msw\dummy.obj,
|
||||
checklst,
|
||||
NUL,
|
||||
$(LIBS),
|
||||
checklst.def
|
||||
;
|
||||
<<
|
||||
rc -K checklst.res
|
||||
|
||||
checklst.obj: checklst.$(SRCSUFF)
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
checklst.res : checklst.rc $(WXDIR)\include\wx\msw\wx.rc
|
||||
rc -r /i$(WXDIR)\include checklst
|
||||
|
||||
clean:
|
||||
-erase *.obj
|
||||
-erase *.exe
|
||||
-erase *.res
|
||||
-erase *.map
|
||||
-erase *.sbr
|
||||
-erase *.pdb
|
37
samples/checklst/makefile.g95
Normal file
37
samples/checklst/makefile.g95
Normal 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 checklst example (UNIX).
|
||||
|
||||
WXDIR = ../..
|
||||
|
||||
# All common UNIX compiler flags and options are now in
|
||||
# this central makefile.
|
||||
include $(WXDIR)/src/makeg95.env
|
||||
|
||||
OBJECTS = $(OBJDIR)/checklst.$(OBJSUFF) $(OBJDIR)/checklst_resources.$(OBJSUFF)
|
||||
|
||||
all: $(OBJDIR) checklst$(GUISUFFIX)$(EXESUFF)
|
||||
|
||||
wx:
|
||||
|
||||
$(OBJDIR):
|
||||
mkdir $(OBJDIR)
|
||||
|
||||
checklst$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB)
|
||||
$(CC) $(LDFLAGS) -o checklst$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS)
|
||||
|
||||
$(OBJDIR)/checklst.$(OBJSUFF): checklst.$(SRCSUFF)
|
||||
$(CC) -c $(CPPFLAGS) -o $@ checklst.$(SRCSUFF)
|
||||
|
||||
$(OBJDIR)/checklst_resources.o: checklst.rc
|
||||
$(RESCOMP) -i checklst.rc -o $(OBJDIR)/checklst_resources.o $(RESFLAGS)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJECTS) checklst$(GUISUFFIX).exe core *.rsc *.res
|
64
samples/checklst/makefile.nt
Normal file
64
samples/checklst/makefile.nt
Normal 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 checklst 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\checklst
|
||||
PROGRAM=checklst
|
||||
|
||||
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
|
BIN
samples/checklst/mondrian.ico
Normal file
BIN
samples/checklst/mondrian.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 766 B |
BIN
samples/checklst/nosound.bmp
Normal file
BIN
samples/checklst/nosound.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 370 B |
BIN
samples/checklst/sound.bmp
Normal file
BIN
samples/checklst/sound.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 370 B |
Reference in New Issue
Block a user