added test for wxPopupTransientWindow.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31761 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
ddc90a8d52
commit
98d5b42b4a
176
samples/popup/Makefile.in
Normal file
176
samples/popup/Makefile.in
Normal file
@ -0,0 +1,176 @@
|
||||
# =========================================================================
|
||||
# This makefile was generated by
|
||||
# Bakefile 0.1.4 (http://bakefile.sourceforge.net)
|
||||
# Do not modify, all changes will be overwritten!
|
||||
# =========================================================================
|
||||
|
||||
|
||||
@MAKE_SET@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
INSTALL = @INSTALL@
|
||||
EXEEXT = @EXEEXT@
|
||||
RESCOMP = @RESCOMP@
|
||||
SETFILE = @SETFILE@
|
||||
NM = @NM@
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
LDFLAGS_GUI = @LDFLAGS_GUI@
|
||||
CXX = @CXX@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
WX_LIB_FLAVOUR = @WX_LIB_FLAVOUR@
|
||||
TOOLKIT = @TOOLKIT@
|
||||
TOOLKIT_LOWERCASE = @TOOLKIT_LOWERCASE@
|
||||
TOOLKIT_VERSION = @TOOLKIT_VERSION@
|
||||
TOOLCHAIN_NAME = @TOOLCHAIN_NAME@
|
||||
EXTRALIBS = @EXTRALIBS@
|
||||
EXTRALIBS_GUI = @EXTRALIBS_GUI@
|
||||
HOST_SUFFIX = @HOST_SUFFIX@
|
||||
SAMPLES_RPATH_FLAG = @SAMPLES_RPATH_FLAG@
|
||||
SAMPLES_RPATH_POSTLINK = @SAMPLES_RPATH_POSTLINK@
|
||||
|
||||
### Variables: ###
|
||||
|
||||
DESTDIR =
|
||||
WX_RELEASE = 2.5
|
||||
WX_VERSION = $(WX_RELEASE).3
|
||||
LIBDIRNAME = $(top_builddir)lib
|
||||
MINIMAL_CXXFLAGS = -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) -I$(srcdir) \
|
||||
$(__DLLFLAG_p) -I$(srcdir)/../../samples $(CPPFLAGS) $(CXXFLAGS)
|
||||
MINIMAL_OBJECTS = \
|
||||
$(__minimal___win32rc) \
|
||||
$(__minimal_os2_lib_res) \
|
||||
minimal_minimal.o
|
||||
|
||||
### Conditionally set variables: ###
|
||||
|
||||
@COND_DEPS_TRACKING_0@CXXC = $(CXX)
|
||||
@COND_DEPS_TRACKING_1@CXXC = $(top_builddir)./bk-deps $(CXX)
|
||||
@COND_USE_GUI_0@PORTNAME = base
|
||||
@COND_USE_GUI_1@PORTNAME = $(TOOLKIT_LOWERCASE)$(TOOLKIT_VERSION)
|
||||
@COND_TOOLKIT_MAC@WXBASEPORT = _carbon
|
||||
@COND_BUILD_DEBUG_DEBUG_FLAG_DEFAULT@WXDEBUGFLAG = d
|
||||
@COND_DEBUG_FLAG_1@WXDEBUGFLAG = d
|
||||
@COND_UNICODE_1@WXUNICODEFLAG = u
|
||||
@COND_WXUNIV_1@WXUNIVNAME = univ
|
||||
@COND_MONOLITHIC_0@EXTRALIBS_FOR_BASE = $(EXTRALIBS)
|
||||
@COND_MONOLITHIC_1@EXTRALIBS_FOR_BASE = $(EXTRALIBS) $(EXTRALIBS_GUI)
|
||||
@COND_MONOLITHIC_0@EXTRALIBS_FOR_GUI = $(EXTRALIBS_GUI)
|
||||
@COND_MONOLITHIC_1@EXTRALIBS_FOR_GUI =
|
||||
@COND_PLATFORM_MAC_1@__minimal___mac_setfilecmd = \
|
||||
@COND_PLATFORM_MAC_1@ $(SETFILE) -a C minimal$(EXEEXT)
|
||||
@COND_PLATFORM_MAC_1@__minimal___mac_rezcmd = $(__MACOSX_RESOURCES_p_1)
|
||||
@COND_WXUNIV_1@__WXUNIV_DEFINE_p = -D__WXUNIVERSAL__
|
||||
@COND_WXUNIV_1@__WXUNIV_DEFINE_p_1 = -d __WXUNIVERSAL__
|
||||
@COND_WXUNIV_1@__WXUNIV_DEFINE_p_2 = --define __WXUNIVERSAL__
|
||||
@COND_SHARED_1@__DLLFLAG_p = -DWXUSINGDLL
|
||||
@COND_SHARED_1@__DLLFLAG_p_1 = -d WXUSINGDLL
|
||||
@COND_SHARED_1@__DLLFLAG_p_2 = --define WXUSINGDLL
|
||||
COND_PLATFORM_OS2_1___minimal___os2_emxbindcmd = $(NM) minimal$(EXEEXT) | if \
|
||||
grep -q pmwin.763 ; then emxbind -ep minimal$(EXEEXT) ; fi
|
||||
@COND_PLATFORM_OS2_1@__minimal___os2_emxbindcmd = $(COND_PLATFORM_OS2_1___minimal___os2_emxbindcmd)
|
||||
@COND_PLATFORM_WIN32_1@__minimal___win32rc = minimal_sample_rc.o
|
||||
@COND_PLATFORM_OS2_1@__minimal_os2_lib_res = \
|
||||
@COND_PLATFORM_OS2_1@ $(top_srcdir)/include/wx/os2/wx.res
|
||||
@COND_PLATFORM_MACOSX_1@__minimal_bundle___depname = minimal_bundle
|
||||
@COND_TOOLKIT_COCOA@____minimal_BUNDLE_TGT_REF_DEP = \
|
||||
@COND_TOOLKIT_COCOA@ minimal.app/Contents/PkgInfo
|
||||
@COND_TOOLKIT_MAC@____minimal_BUNDLE_TGT_REF_DEP = \
|
||||
@COND_TOOLKIT_MAC@ minimal.app/Contents/PkgInfo
|
||||
COND_MONOLITHIC_0___WXLIB_CORE_p = \
|
||||
-lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_MONOLITHIC_0@__WXLIB_CORE_p = $(COND_MONOLITHIC_0___WXLIB_CORE_p)
|
||||
COND_MONOLITHIC_0___WXLIB_BASE_p = \
|
||||
-lwx_base$(WXBASEPORT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_MONOLITHIC_0@__WXLIB_BASE_p = $(COND_MONOLITHIC_0___WXLIB_BASE_p)
|
||||
COND_MONOLITHIC_1___WXLIB_MONO_p = \
|
||||
-lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_MONOLITHIC_1@__WXLIB_MONO_p = $(COND_MONOLITHIC_1___WXLIB_MONO_p)
|
||||
@COND_USE_GUI_1_WXUSE_LIBTIFF_BUILTIN@__LIB_TIFF_p \
|
||||
@COND_USE_GUI_1_WXUSE_LIBTIFF_BUILTIN@ = \
|
||||
@COND_USE_GUI_1_WXUSE_LIBTIFF_BUILTIN@ -lwxtiff$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_USE_GUI_1_WXUSE_LIBJPEG_BUILTIN@__LIB_JPEG_p \
|
||||
@COND_USE_GUI_1_WXUSE_LIBJPEG_BUILTIN@ = \
|
||||
@COND_USE_GUI_1_WXUSE_LIBJPEG_BUILTIN@ -lwxjpeg$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_USE_GUI_1_WXUSE_LIBPNG_BUILTIN@__LIB_PNG_p \
|
||||
@COND_USE_GUI_1_WXUSE_LIBPNG_BUILTIN@ = \
|
||||
@COND_USE_GUI_1_WXUSE_LIBPNG_BUILTIN@ -lwxpng$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_WXUSE_ZLIB_BUILTIN@__LIB_ZLIB_p = \
|
||||
@COND_WXUSE_ZLIB_BUILTIN@ -lwxzlib$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_WXUSE_ODBC_BUILTIN@__LIB_ODBC_p = \
|
||||
@COND_WXUSE_ODBC_BUILTIN@ -lwxodbc$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
COND_WXUSE_REGEX_BUILTIN___LIB_REGEX_p = \
|
||||
-lwxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_WXUSE_REGEX_BUILTIN@__LIB_REGEX_p = $(COND_WXUSE_REGEX_BUILTIN___LIB_REGEX_p)
|
||||
@COND_WXUSE_EXPAT_BUILTIN@__LIB_EXPAT_p = \
|
||||
@COND_WXUSE_EXPAT_BUILTIN@ -lwxexpat$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
COND_TOOLKIT_MAC___MACOSX_RESOURCES_p_1 = $(RESCOMP) -d __DARWIN__ -t APPL -d \
|
||||
__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_1) -i $(srcdir) $(__DLLFLAG_p_1) -i \
|
||||
$(srcdir)/../../samples -i $(top_srcdir)/include -o minimal$(EXEEXT) Carbon.r \
|
||||
$(LIBDIRNAME)/libwx_$(TOOLCHAIN_NAME).3.r sample.r
|
||||
@COND_TOOLKIT_MAC@__MACOSX_RESOURCES_p_1 = $(COND_TOOLKIT_MAC___MACOSX_RESOURCES_p_1)
|
||||
|
||||
### Targets: ###
|
||||
|
||||
all: minimal$(EXEEXT) $(__minimal_bundle___depname)
|
||||
|
||||
install: all
|
||||
|
||||
uninstall:
|
||||
|
||||
install-strip: install
|
||||
|
||||
clean:
|
||||
rm -rf ./.deps ./.pch
|
||||
rm -f ./*.o
|
||||
rm -f minimal$(EXEEXT)
|
||||
rm -rf minimal.app
|
||||
|
||||
distclean: clean
|
||||
rm -f configure config.cache config.log config.status bk-deps bk-make-pch shared-ld-sh Makefile
|
||||
|
||||
minimal$(EXEEXT): $(MINIMAL_OBJECTS) $(__minimal___win32rc)
|
||||
$(CXX) -o $@ $(MINIMAL_OBJECTS) $(LDFLAGS) -L$(LIBDIRNAME) $(LDFLAGS_GUI) $(SAMPLES_RPATH_FLAG) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(__LIB_ZLIB_p) $(__LIB_ODBC_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(EXTRALIBS_FOR_GUI)
|
||||
$(__minimal___mac_rezcmd)
|
||||
$(__minimal___mac_setfilecmd)
|
||||
$(__minimal___os2_emxbindcmd)
|
||||
$(SAMPLES_RPATH_POSTLINK)
|
||||
|
||||
minimal.app/Contents/PkgInfo: minimal$(EXEEXT) $(top_srcdir)/src/mac/carbon/Info.plist.in $(LIBDIRNAME)/libwx_$(TOOLCHAIN_NAME).3.rsrc $(top_srcdir)/src/mac/carbon/wxmac.icns
|
||||
mkdir -p minimal.app/Contents
|
||||
mkdir -p minimal.app/Contents/MacOS
|
||||
mkdir -p minimal.app/Contents/Resources
|
||||
|
||||
|
||||
sed -e "s/IDENTIFIER/`echo $(srcdir) | sed -e 's,\.\./,,g' | sed -e 's,/,.,g'`/" \
|
||||
-e "s/EXECUTABLE/minimal/" \
|
||||
-e "s/VERSION/$(WX_VERSION)/" \
|
||||
$(top_srcdir)/src/mac/carbon/Info.plist.in >minimal.app/Contents/Info.plist
|
||||
|
||||
|
||||
echo -n "APPL????" >minimal.app/Contents/PkgInfo
|
||||
|
||||
|
||||
ln -f minimal$(EXEEXT) minimal.app/Contents/MacOS/minimal
|
||||
|
||||
|
||||
cp -f $(LIBDIRNAME)/libwx_$(TOOLCHAIN_NAME).3.rsrc minimal.app/Contents/Resources/minimal.rsrc
|
||||
cp -f $(top_srcdir)/src/mac/carbon/wxmac.icns minimal.app/Contents/Resources/wxmac.icns
|
||||
|
||||
@COND_PLATFORM_MACOSX_1@minimal_bundle: $(____minimal_BUNDLE_TGT_REF_DEP)
|
||||
|
||||
minimal_sample_rc.o: $(srcdir)/../../samples/sample.rc
|
||||
$(RESCOMP) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_2) --include-dir $(srcdir) $(__DLLFLAG_p_2) --include-dir $(srcdir)/../../samples --include-dir $(top_srcdir)/include
|
||||
|
||||
minimal_minimal.o: $(srcdir)/minimal.cpp
|
||||
$(CXXC) -c -o $@ $(MINIMAL_CXXFLAGS) $<
|
||||
|
||||
|
||||
# Include dependency info, if present:
|
||||
@IF_GNU_MAKE@-include .deps/*.d
|
||||
|
||||
.PHONY: all install uninstall clean distclean minimal_bundle
|
314
samples/popup/minimal.cpp
Normal file
314
samples/popup/minimal.cpp
Normal file
@ -0,0 +1,314 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: minimal.cpp
|
||||
// Purpose: Popup wxWidgets sample
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
// for all others, include the necessary headers (this file is usually all you
|
||||
// need because it includes almost all "standard" wxWidgets headers)
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "wx/popupwin.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// resources
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// the application icon (under Windows and OS/2 it is in resources and even
|
||||
// though we could still include the XPM here it would be unused)
|
||||
#if !defined(__WXMSW__) && !defined(__WXPM__)
|
||||
#include "../sample.xpm"
|
||||
#endif
|
||||
|
||||
class SimpleTransientPopup: public wxPopupTransientWindow
|
||||
{
|
||||
public:
|
||||
SimpleTransientPopup( wxWindow *parent );
|
||||
virtual ~SimpleTransientPopup();
|
||||
|
||||
void OnDismiss();
|
||||
|
||||
private:
|
||||
wxPanel *m_panel;
|
||||
|
||||
private:
|
||||
void OnMouse( wxMouseEvent &event );
|
||||
void OnSize( wxSizeEvent &event );
|
||||
void OnSetFocus( wxFocusEvent &event );
|
||||
void OnKillFocus( wxFocusEvent &event );
|
||||
|
||||
private:
|
||||
DECLARE_CLASS(SimpleTransientPopup)
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// SimpleTransientPopup
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(SimpleTransientPopup,wxPopupTransientWindow)
|
||||
|
||||
BEGIN_EVENT_TABLE(SimpleTransientPopup,wxPopupTransientWindow)
|
||||
EVT_MOUSE_EVENTS( SimpleTransientPopup::OnMouse )
|
||||
EVT_SIZE( SimpleTransientPopup::OnSize )
|
||||
EVT_SET_FOCUS( SimpleTransientPopup::OnSetFocus )
|
||||
EVT_KILL_FOCUS( SimpleTransientPopup::OnKillFocus )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
SimpleTransientPopup::SimpleTransientPopup( wxWindow *parent ) :
|
||||
wxPopupTransientWindow( parent )
|
||||
{
|
||||
m_panel = new wxPanel( this, -1 );
|
||||
m_panel->SetBackgroundColour( *wxLIGHT_GREY );
|
||||
wxStaticText *text = new wxStaticText( m_panel, -1,
|
||||
wxT("wx.PopupTransientWindow is a\n")
|
||||
wxT("wx.PopupWindow which disappears\n")
|
||||
wxT("automatically when the user\n")
|
||||
wxT("clicks the mouse outside it or if it\n")
|
||||
wxT("(or its first child) loses focus in \n")
|
||||
wxT("any other way."), wxPoint( 10,10) );
|
||||
wxSize size = text->GetBestSize();
|
||||
m_panel->SetSize( size.x+20, size.y+20 );
|
||||
SetClientSize( size.x+20, size.y+20 );
|
||||
}
|
||||
|
||||
SimpleTransientPopup::~SimpleTransientPopup()
|
||||
{
|
||||
}
|
||||
|
||||
void SimpleTransientPopup::OnDismiss()
|
||||
{
|
||||
}
|
||||
|
||||
void SimpleTransientPopup::OnSize(wxSizeEvent &event)
|
||||
{
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void SimpleTransientPopup::OnSetFocus(wxFocusEvent &event)
|
||||
{
|
||||
}
|
||||
|
||||
void SimpleTransientPopup::OnKillFocus(wxFocusEvent &event)
|
||||
{
|
||||
}
|
||||
|
||||
void SimpleTransientPopup::OnMouse(wxMouseEvent &event)
|
||||
{
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private classes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class MyApp : public wxApp
|
||||
{
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
};
|
||||
|
||||
class MyDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
MyDialog(const wxString& title);
|
||||
|
||||
void OnStartSimplePopup(wxCommandEvent& event);
|
||||
void OnStartComplexPopup(wxCommandEvent& event);
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
class MyFrame : public wxFrame
|
||||
{
|
||||
public:
|
||||
MyFrame(const wxString& title);
|
||||
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
void OnTestDialog(wxCommandEvent& event);
|
||||
void OnStartSimplePopup(wxCommandEvent& event);
|
||||
void OnStartComplexPopup(wxCommandEvent& event);
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// IDs for the controls and the menu commands
|
||||
enum
|
||||
{
|
||||
Minimal_Quit = wxID_EXIT,
|
||||
Minimal_About = wxID_ABOUT,
|
||||
Minimal_TestDialog,
|
||||
Minimal_StartSimplePopup,
|
||||
Minimal_StartComplexPopup,
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event tables and other macros for wxWidgets
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
// 'Main program' equivalent: the program execution "starts" here
|
||||
bool MyApp::OnInit()
|
||||
{
|
||||
// create the main application window
|
||||
MyFrame *frame = new MyFrame(_T("Popup wxWidgets App"));
|
||||
|
||||
// and show it (the frames, unlike simple controls, are not shown when
|
||||
// created initially)
|
||||
frame->Show(true);
|
||||
|
||||
// success: wxApp::OnRun() will be called which will enter the main message
|
||||
// loop and the application will run. If we returned false here, the
|
||||
// application would exit immediately.
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// main frame
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
|
||||
EVT_MENU(Minimal_About, MyFrame::OnAbout)
|
||||
EVT_MENU(Minimal_TestDialog, MyFrame::OnTestDialog)
|
||||
EVT_BUTTON(Minimal_StartSimplePopup, MyFrame::OnStartSimplePopup)
|
||||
EVT_BUTTON(Minimal_StartComplexPopup, MyFrame::OnStartComplexPopup)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MyFrame::MyFrame(const wxString& title)
|
||||
: wxFrame(NULL, wxID_ANY, title)
|
||||
{
|
||||
SetIcon(wxICON(sample));
|
||||
|
||||
#if wxUSE_MENUS
|
||||
wxMenu *menuFile = new wxMenu;
|
||||
|
||||
// the "About" item should be in the help menu
|
||||
wxMenu *helpMenu = new wxMenu;
|
||||
helpMenu->Append(Minimal_About, _T("&About...\tF1"), _T("Show about dialog"));
|
||||
|
||||
menuFile->Append(Minimal_TestDialog, _T("&Test dialog\tAlt-T"), _T("Test dialog"));
|
||||
menuFile->Append(Minimal_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));
|
||||
|
||||
// now append the freshly created menu to the menu bar...
|
||||
wxMenuBar *menuBar = new wxMenuBar();
|
||||
menuBar->Append(menuFile, _T("&File"));
|
||||
menuBar->Append(helpMenu, _T("&Help"));
|
||||
|
||||
// ... and attach this menu bar to the frame
|
||||
SetMenuBar(menuBar);
|
||||
#endif // wxUSE_MENUS
|
||||
|
||||
new wxButton( this, Minimal_StartSimplePopup, wxT("Show simple popup"), wxPoint(20,20) );
|
||||
new wxButton( this, Minimal_StartComplexPopup, wxT("Show complex popup"), wxPoint(20,120) );
|
||||
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
// create a status bar just for fun (by default with 1 pane only)
|
||||
CreateStatusBar(2);
|
||||
SetStatusText(_T("Welcome to wxWidgets!"));
|
||||
#endif // wxUSE_STATUSBAR
|
||||
}
|
||||
|
||||
// event handlers
|
||||
|
||||
void MyFrame::OnStartSimplePopup(wxCommandEvent& event)
|
||||
{
|
||||
SimpleTransientPopup* popup = new SimpleTransientPopup( this );
|
||||
wxWindow *btn = (wxWindow*) event.GetEventObject();
|
||||
wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
|
||||
wxSize sz = btn->GetSize();
|
||||
popup->Position( pos, sz );
|
||||
popup->Popup();
|
||||
}
|
||||
|
||||
void MyFrame::OnStartComplexPopup(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
}
|
||||
|
||||
void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
MyDialog dialog( wxT("Test") );
|
||||
dialog.ShowModal();
|
||||
}
|
||||
|
||||
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
// true is to force the frame to close
|
||||
Close(true);
|
||||
}
|
||||
|
||||
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _T("This is the About dialog of the popup sample.\n")
|
||||
_T("Welcome to %s"), wxVERSION_STRING);
|
||||
|
||||
wxMessageBox(msg, _T("About Popup"), wxOK | wxICON_INFORMATION, this);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test dialog
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
|
||||
EVT_BUTTON(Minimal_StartSimplePopup, MyDialog::OnStartSimplePopup)
|
||||
EVT_BUTTON(Minimal_StartComplexPopup, MyDialog::OnStartComplexPopup)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MyDialog::MyDialog(const wxString& title)
|
||||
: wxDialog(NULL, wxID_ANY, title, wxPoint(50,50), wxSize(400,300))
|
||||
{
|
||||
|
||||
new wxButton( this, Minimal_StartSimplePopup, wxT("Show simple popup"), wxPoint(20,20) );
|
||||
new wxButton( this, Minimal_StartComplexPopup, wxT("Show complex popup"), wxPoint(20,80) );
|
||||
|
||||
new wxButton( this, wxID_OK, wxT("OK"), wxPoint(20,200) );
|
||||
}
|
||||
|
||||
void MyDialog::OnStartSimplePopup(wxCommandEvent& event)
|
||||
{
|
||||
SimpleTransientPopup* popup = new SimpleTransientPopup( this );
|
||||
wxWindow *btn = (wxWindow*) event.GetEventObject();
|
||||
wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
|
||||
wxSize sz = btn->GetSize();
|
||||
popup->Position( pos, sz );
|
||||
popup->Popup();
|
||||
}
|
||||
|
||||
void MyDialog::OnStartComplexPopup(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
}
|
||||
|
@ -59,6 +59,7 @@
|
||||
<subproject id="opengl" template="sub"/>
|
||||
<subproject id="ownerdrw" template="sub"/>
|
||||
<subproject id="png" template="sub"/>
|
||||
<subproject id="popup" template="sub"/>
|
||||
<subproject id="printing" template="sub"/>
|
||||
<subproject id="propsize" template="sub"/>
|
||||
<subproject id="regtest" template="sub"/>
|
||||
|
Loading…
Reference in New Issue
Block a user