added bakefile presets for creation of user makefiles
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31612 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
31
build/bakefiles/wxpresets/presets/wx.bkl
Normal file
31
build/bakefiles/wxpresets/presets/wx.bkl
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" ?>
|
||||||
|
<!-- $Id$ -->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Presents for building wxWidgets applications.
|
||||||
|
|
||||||
|
FIXME: docs
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
<makefile>
|
||||||
|
|
||||||
|
<!-- this is just a wrapper that includes the real implementation: -->
|
||||||
|
|
||||||
|
<set var="__wx_included_impl">0</set>
|
||||||
|
|
||||||
|
<if cond="FORMAT in ['autoconf','gnu']">
|
||||||
|
<include file="wx_unix.bkl"/>
|
||||||
|
<set var="__wx_included_impl">1</set>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if cond="FORMAT!='autoconf' and PLATFORM_WIN32=='1'">
|
||||||
|
<include file="wx_win32.bkl"/>
|
||||||
|
<set var="__wx_included_impl">1</set>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if cond="__wx_included_impl=='0'">
|
||||||
|
<error>This format is not (yet) supported by wx preset.</error>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
</makefile>
|
85
build/bakefiles/wxpresets/presets/wx_unix.bkl
Normal file
85
build/bakefiles/wxpresets/presets/wx_unix.bkl
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
<?xml version="1.0" ?>
|
||||||
|
<!-- $Id$ -->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Presents for building wxWidgets applications using Autoconf or GNU toosets.
|
||||||
|
See wx.bkl for platform-independent notes.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
Options WX_CPPFLAGS, WX_CFLAGS, WX_CXXFLAGS, WX_LIBS are defined.
|
||||||
|
|
||||||
|
|
||||||
|
Format-specific notes:
|
||||||
|
|
||||||
|
* autoconf:
|
||||||
|
Beware that you have to use AM_OPTIONS_WXCONFIG and
|
||||||
|
AM_PATH_WXCONFIG in your configure.in!
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
<makefile>
|
||||||
|
|
||||||
|
<!-- ============================================================== -->
|
||||||
|
<!-- Autoconf -->
|
||||||
|
<!-- ============================================================== -->
|
||||||
|
|
||||||
|
<if cond="FORMAT=='autoconf'">
|
||||||
|
<!-- Autoconf backend is simplicity itself thanks to wx-config... -->
|
||||||
|
<option name="WX_CFLAGS"/>
|
||||||
|
<option name="WX_CXXFLAGS"/>
|
||||||
|
<option name="WX_CPPFLAGS"/>
|
||||||
|
<option name="WX_LIBS"/>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<!-- ============================================================== -->
|
||||||
|
<!-- GNU makefiles for Unix -->
|
||||||
|
<!-- ============================================================== -->
|
||||||
|
|
||||||
|
<if cond="FORMAT=='gnu'">
|
||||||
|
<option name="WX_CONFIG">
|
||||||
|
<default-value>wx-config</default-value>
|
||||||
|
<description>Location and arguments of wx-config script</description>
|
||||||
|
</option>
|
||||||
|
<option name="WX_CFLAGS">
|
||||||
|
<default-value>`$(DOLLAR)(WX_CONFIG) --cflags`</default-value>
|
||||||
|
<description>C flags to use with wxWidgets code</description>
|
||||||
|
</option>
|
||||||
|
<option name="WX_CXXFLAGS">
|
||||||
|
<default-value>`$(DOLLAR)(WX_CONFIG) --cxxflags`</default-value>
|
||||||
|
<description>C++ flags to use with wxWidgets code</description>
|
||||||
|
</option>
|
||||||
|
<option name="WX_CPPFLAGS">
|
||||||
|
<default-value>`$(DOLLAR)(WX_CONFIG) --cppflags`</default-value>
|
||||||
|
<description>C preprocessor flags to use with wxWidgets code</description>
|
||||||
|
</option>
|
||||||
|
<option name="WX_LIBS">
|
||||||
|
<default-value>`$(DOLLAR)(WX_CONFIG) --libs`</default-value>
|
||||||
|
<description>wxWidgets libraries to link against</description>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<!-- we need this but the trick used in default-values above
|
||||||
|
prevents bakefile from detecting it: -->
|
||||||
|
<set var="FORMAT_OUTPUT_VARIABLES" append="1">WX_CONFIG</set>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<!-- ============================================================== -->
|
||||||
|
<!-- Common code -->
|
||||||
|
<!-- ============================================================== -->
|
||||||
|
|
||||||
|
<if cond="FORMAT not in ['gnu','autoconf']">
|
||||||
|
<error>
|
||||||
|
Don't include presets/wx_unix.bkl directly, use presets/wx.bkl.
|
||||||
|
</error>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<template id="wx">
|
||||||
|
<cxxflags>$(WX_CXXFLAGS)</cxxflags>
|
||||||
|
<cflags>$(WX_CFLAGS)</cflags>
|
||||||
|
<ldlibs>$(WX_LIBS)</ldlibs>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- not used together with wx-config: -->
|
||||||
|
<define-tag name="wx-lib" rules="exe,dll,module"/>
|
||||||
|
|
||||||
|
</makefile>
|
232
build/bakefiles/wxpresets/presets/wx_win32.bkl
Normal file
232
build/bakefiles/wxpresets/presets/wx_win32.bkl
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
<?xml version="1.0" ?>
|
||||||
|
<!-- $Id$ -->
|
||||||
|
|
||||||
|
<!-- Original source: http://wiki.wxwidgets.org/wiki.pl?Bakefile -->
|
||||||
|
<!-- Modified by: Francesco Montorsi <frm@users.sourceforge.net> -->
|
||||||
|
<!-- Vaclav Slavik <vslavik@fastmail.fm> to better fit
|
||||||
|
into Bakefile's presets -->
|
||||||
|
<!-- Creation date: 6/9/2004 -->
|
||||||
|
<!-- Last revision: 22/1/2005 off-CVS -->
|
||||||
|
<!-- $Id$ -->
|
||||||
|
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
FIXME: this template has (at least) the following bugs:
|
||||||
|
|
||||||
|
* it's MSW-only, the port is assumed to be wxMSW unconditionally
|
||||||
|
|
||||||
|
* multiple wx configurations (CFG variable set when building the
|
||||||
|
library) are not supported
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- makefile tag signifies the beginning of the bakefile -->
|
||||||
|
<makefile>
|
||||||
|
|
||||||
|
<requires version="0.1.5"/>
|
||||||
|
|
||||||
|
<!-- OPTIONS -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- These are essentially the configurations you -->
|
||||||
|
<!-- want in bakefile. -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- In MSVC these are the different build -->
|
||||||
|
<!-- configurations you can have (in the build menu), -->
|
||||||
|
<!-- and in autoconf is enabled with enable-xxx=xx. -->
|
||||||
|
<!-- For other compilers a seperate configuration -->
|
||||||
|
<!-- file is created (such as config.gcc on gcc) -->
|
||||||
|
<!-- which has several options a user can modify. -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- Note that the above only happens if an option -->
|
||||||
|
<!-- is not constant, i.e. if it cannot be determined -->
|
||||||
|
<!-- by bakefile itself. -->
|
||||||
|
|
||||||
|
<!-- The directory where wxWidgets is installed: -->
|
||||||
|
<option name="WX_DIR" category="path">
|
||||||
|
<default-value>$(DOLLAR)(WXWIN)</default-value>
|
||||||
|
<description>
|
||||||
|
The directory where wxWidgets library is installed
|
||||||
|
</description>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<!-- This is a standard option that determines -->
|
||||||
|
<!-- whether the user wants to build this library as -->
|
||||||
|
<!-- a dll or as a static library. -->
|
||||||
|
<option name="WX_SHARED">
|
||||||
|
<values>0,1</values>
|
||||||
|
<values-description>,DLL</values-description>
|
||||||
|
<default-value>0</default-value>
|
||||||
|
<description>
|
||||||
|
Use DLL build of wx library to use?
|
||||||
|
</description>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<!-- Configuration for building the bakefile with -->
|
||||||
|
<!-- unicode strings or not (unicode or ansi). -->
|
||||||
|
<option name="WX_UNICODE">
|
||||||
|
<values>0,1</values>
|
||||||
|
<values-description>,Unicode</values-description>
|
||||||
|
<default-value>0</default-value>
|
||||||
|
<description>
|
||||||
|
Compile Unicode build of wxWidgets?
|
||||||
|
</description>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<option name="WX_DEBUG">
|
||||||
|
<values>0,1</values>
|
||||||
|
<values-description>,Debug</values-description>
|
||||||
|
<default-value>1</default-value>
|
||||||
|
<description>
|
||||||
|
Use debug build of wxWidgets (define __WXDEBUG__)?
|
||||||
|
</description>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<option name="WX_VERSION">
|
||||||
|
<default-value>25</default-value>
|
||||||
|
<description>
|
||||||
|
Version of the wx library to build against.
|
||||||
|
</description>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<!-- HELPER VARIABLES -->
|
||||||
|
<!-- -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- The unicode define we want. By default bakefile -->
|
||||||
|
<!-- makes variables an empty string, so if unicode -->
|
||||||
|
<!-- is not defined $(UNICODE_DEFINE) would expand -->
|
||||||
|
<!-- to nothing (literally). -->
|
||||||
|
<set var="WXUNICODE_DEFINE">
|
||||||
|
<if cond="WX_UNICODE=='1'">_UNICODE</if>
|
||||||
|
</set>
|
||||||
|
|
||||||
|
<!-- The debug define we need with win32 compilers -->
|
||||||
|
<!-- (on Linux, the wx-config program is used). -->
|
||||||
|
<set var="WXDEBUG_DEFINE">
|
||||||
|
<if cond="WX_DEBUG=='1'">__WXDEBUG__</if>
|
||||||
|
</set>
|
||||||
|
|
||||||
|
<!-- These are handy ways of dealing with the -->
|
||||||
|
<!-- extensions in the library names of the -->
|
||||||
|
<!-- wxWindows library. -->
|
||||||
|
<set var="WXLIBPOSTFIX">
|
||||||
|
<if cond="WX_DEBUG=='1' and WX_UNICODE=='1'">ud</if>
|
||||||
|
<if cond="WX_DEBUG=='1' and WX_UNICODE=='0'">d</if>
|
||||||
|
<if cond="WX_DEBUG=='0' and WX_UNICODE=='1'">u</if>
|
||||||
|
</set>
|
||||||
|
<set var="WXSUBLIBPOSTFIX">
|
||||||
|
<if cond="WX_DEBUG=='1' and WX_UNICODE=='0'">d</if>
|
||||||
|
</set>
|
||||||
|
|
||||||
|
<set var="WXLIBPATH">
|
||||||
|
<if cond="WX_SHARED=='0'">$(DIRSEP)lib$(DIRSEP)$(COMPILER)_lib</if>
|
||||||
|
<if cond="WX_SHARED=='1'">$(DIRSEP)lib$(DIRSEP)$(COMPILER)_dll</if>
|
||||||
|
</set>
|
||||||
|
|
||||||
|
<set var="WXLIBINCLUDE">$(WXLIBPATH)$(DIRSEP)msw$(WXLIBPOSTFIX)</set>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- WX TEMPLATE -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- While not required, templates make your -->
|
||||||
|
<!-- bakefiles much more readable. Templates, in -->
|
||||||
|
<!-- essence, are abstract classes like c++. -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- Your build targets "inherit" the template, -->
|
||||||
|
<!-- along with the info associated with the template -->
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<!-- wxWidgets LIBRARY/APP TEMPLATE -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- The "base class" of all our build targets -->
|
||||||
|
<!-- This links with the appropriate native -->
|
||||||
|
<!-- libraries required by the platform, the libaries -->
|
||||||
|
<!-- we want for our stuff, and the wxWindows libs. -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- this tag is used to include wx libraries: -->
|
||||||
|
<define-tag name="wx-lib" rules="exe,dll,module">
|
||||||
|
<if cond="value=='base'">
|
||||||
|
<sys-lib>wxbase$(WX_VERSION)$(WXLIBPOSTFIX)</sys-lib>
|
||||||
|
</if>
|
||||||
|
<if cond="value in ['net','xml']">
|
||||||
|
<sys-lib>wxbase$(WX_VERSION)$(WXLIBPOSTFIX)_$(value)</sys-lib>
|
||||||
|
</if>
|
||||||
|
<if cond="value not in ['base','net','xml']">
|
||||||
|
<sys-lib>wxmsw$(WX_VERSION)$(WXLIBPOSTFIX)_$(value)</sys-lib>
|
||||||
|
</if>
|
||||||
|
</define-tag>
|
||||||
|
|
||||||
|
<!-- just a placeholder to mark the place where <wx-lib> will be placed,
|
||||||
|
thanks to the order precedence declaration below it: -->
|
||||||
|
<define-tag name="__wx-libs-point" rules="exe,dll,module"/>
|
||||||
|
<tag-info name="wx-lib"
|
||||||
|
position="before:__wx-libs-point"/>
|
||||||
|
|
||||||
|
|
||||||
|
<template id="wx">
|
||||||
|
<!-- MISCELLANEOUS -->
|
||||||
|
<if cond="FORMAT=='mingw'">
|
||||||
|
<define>HAVE_W32API_H</define>
|
||||||
|
<ldflags>-mthreads</ldflags>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<define>$(WXUNICODE_DEFINE)</define>
|
||||||
|
<define>$(WXDEBUG_DEFINE)</define>
|
||||||
|
<define>__WXMSW__</define>
|
||||||
|
|
||||||
|
<include>$(WX_DIR)$(WXLIBINCLUDE)</include>
|
||||||
|
<include>$(WX_DIR)/include</include>
|
||||||
|
|
||||||
|
<lib-path>$(WX_DIR)$(WXLIBPATH)</lib-path>
|
||||||
|
|
||||||
|
<!-- wx libs must come before 3rd party and sys libs, this is
|
||||||
|
the place where the hack explained above is carried on: -->
|
||||||
|
<__wx-libs-point/>
|
||||||
|
|
||||||
|
<!-- wx 3rd party libs, always use them: -->
|
||||||
|
<sys-lib>wxtiff$(WXSUBLIBPOSTFIX)</sys-lib>
|
||||||
|
<sys-lib>wxjpeg$(WXSUBLIBPOSTFIX)</sys-lib>
|
||||||
|
<sys-lib>wxpng$(WXSUBLIBPOSTFIX)</sys-lib>
|
||||||
|
<sys-lib>wxzlib$(WXSUBLIBPOSTFIX)</sys-lib>
|
||||||
|
<!-- For regex we won't use the WXSUBLIBPOSTIX postfix:
|
||||||
|
unliked tiff, jpeg, png, zlib, expat, when building
|
||||||
|
in Unicode mode, the "u" suffix is appended to regex -->
|
||||||
|
<sys-lib>wxregex$(WXLIBPOSTFIX)</sys-lib>
|
||||||
|
<sys-lib>wxexpat$(WXSUBLIBPOSTFIX)</sys-lib>
|
||||||
|
|
||||||
|
<!-- link-in system libs that wx depends on: -->
|
||||||
|
<!-- If on borland, we don't need to do much -->
|
||||||
|
<if cond="FORMAT=='borland'">
|
||||||
|
<sys-lib>ole2w32</sys-lib>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<!-- Non-borland, on the other hand... -->
|
||||||
|
<if cond="FORMAT!='borland'">
|
||||||
|
<sys-lib>kernel32</sys-lib>
|
||||||
|
<sys-lib>user32</sys-lib>
|
||||||
|
<sys-lib>gdi32</sys-lib>
|
||||||
|
<sys-lib>comdlg32</sys-lib>
|
||||||
|
<sys-lib>winspool</sys-lib>
|
||||||
|
<sys-lib>winmm</sys-lib>
|
||||||
|
<sys-lib>shell32</sys-lib>
|
||||||
|
<sys-lib>comctl32</sys-lib>
|
||||||
|
<sys-lib>ole32</sys-lib>
|
||||||
|
<sys-lib>oleaut32</sys-lib>
|
||||||
|
<sys-lib>uuid</sys-lib>
|
||||||
|
<sys-lib>rpcrt4</sys-lib>
|
||||||
|
<sys-lib>advapi32</sys-lib>
|
||||||
|
<sys-lib>wsock32</sys-lib>
|
||||||
|
<sys-lib>odbc32</sys-lib>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<!-- Libs common to both borland and MSVC -->
|
||||||
|
<if cond="FORMAT=='msvc' or FORMAT=='msvc6prj' or FORMAT=='borland'">
|
||||||
|
<sys-lib>oleacc</sys-lib>
|
||||||
|
</if>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</makefile>
|
48
build/bakefiles/wxpresets/sample/configure.in
Normal file
48
build/bakefiles/wxpresets/sample/configure.in
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
|
AC_PREREQ(2.59)
|
||||||
|
|
||||||
|
AC_INIT([minimal],[1.2.5],[vslavik@fastmail.fm])
|
||||||
|
|
||||||
|
AC_CONFIG_SRCDIR([minimal.cpp])
|
||||||
|
|
||||||
|
AC_CANONICAL_BUILD
|
||||||
|
AC_CANONICAL_HOST
|
||||||
|
AC_CANONICAL_TARGET
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AM_OPTIONS_WXCONFIG
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dnl Checks for programs.
|
||||||
|
AC_PROG_AWK
|
||||||
|
AC_PROG_INSTALL
|
||||||
|
AC_PROG_LN_S
|
||||||
|
AC_PROG_RANLIB
|
||||||
|
AC_PROG_CC
|
||||||
|
AC_PROG_CXX
|
||||||
|
AC_PROG_CXXCPP
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AM_PATH_WXCONFIG(2.4.1, WXFOUND=1)
|
||||||
|
|
||||||
|
if test "$WXFOUND" != 1; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
Please check that wx-config is in path, the directory
|
||||||
|
where wxWindows libraries are installed (returned by
|
||||||
|
'wx-config --libs' command) is in LD_LIBRARY_PATH or
|
||||||
|
equivalent variable and wxWindows is version 2.4.0 or above.
|
||||||
|
])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_BAKEFILE
|
||||||
|
|
||||||
|
|
||||||
|
AC_CONFIG_FILES([
|
||||||
|
Makefile
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_OUTPUT
|
19
build/bakefiles/wxpresets/sample/minimal.bkl
Normal file
19
build/bakefiles/wxpresets/sample/minimal.bkl
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" ?>
|
||||||
|
<!-- $Id$ -->
|
||||||
|
|
||||||
|
<makefile>
|
||||||
|
|
||||||
|
<include file="presets/wx.bkl"/>
|
||||||
|
|
||||||
|
<exe id="minimal" template="wx">
|
||||||
|
<app-type>gui</app-type>
|
||||||
|
<debug-info>on</debug-info>
|
||||||
|
<runtime-libs>dynamic</runtime-libs>
|
||||||
|
|
||||||
|
<sources>minimal.cpp</sources>
|
||||||
|
|
||||||
|
<wx-lib>core</wx-lib>
|
||||||
|
<wx-lib>base</wx-lib>
|
||||||
|
</exe>
|
||||||
|
|
||||||
|
</makefile>
|
182
build/bakefiles/wxpresets/sample/minimal.cpp
Normal file
182
build/bakefiles/wxpresets/sample/minimal.cpp
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: minimal.cpp
|
||||||
|
// Purpose: Minimal wxWindows 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" wxWindows headers)
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/wx.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// resources
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// private classes
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Define a new application type, each program should derive a class from wxApp
|
||||||
|
class MyApp : public wxApp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// override base class virtuals
|
||||||
|
// ----------------------------
|
||||||
|
|
||||||
|
// this one is called on application startup and is a good place for the app
|
||||||
|
// initialization (doing it here and not in the ctor allows to have an error
|
||||||
|
// return: if OnInit() returns false, the application terminates)
|
||||||
|
virtual bool OnInit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Define a new frame type: this is going to be our main frame
|
||||||
|
class MyFrame : public wxFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// ctor(s)
|
||||||
|
MyFrame(const wxString& title);
|
||||||
|
|
||||||
|
// event handlers (these functions should _not_ be virtual)
|
||||||
|
void OnQuit(wxCommandEvent& event);
|
||||||
|
void OnAbout(wxCommandEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// any class wishing to process wxWindows events must use this macro
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// constants
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// IDs for the controls and the menu commands
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
// menu items
|
||||||
|
Minimal_Quit = wxID_EXIT,
|
||||||
|
|
||||||
|
// it is important for the id corresponding to the "About" command to have
|
||||||
|
// this standard value as otherwise it won't be handled properly under Mac
|
||||||
|
// (where it is special and put into the "Apple" menu)
|
||||||
|
Minimal_About = wxID_ABOUT
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// event tables and other macros for wxWindows
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// the event tables connect the wxWindows events with the functions (event
|
||||||
|
// handlers) which process them. It can be also done at run-time, but for the
|
||||||
|
// simple menu events like this the static method is much simpler.
|
||||||
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||||
|
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
|
||||||
|
EVT_MENU(Minimal_About, MyFrame::OnAbout)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
// Create a new application object: this macro will allow wxWindows to create
|
||||||
|
// the application object during program execution (it's better than using a
|
||||||
|
// static object for many reasons) and also implements the accessor function
|
||||||
|
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
|
||||||
|
// not wxApp)
|
||||||
|
IMPLEMENT_APP(MyApp)
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// the application class
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// 'Main program' equivalent: the program execution "starts" here
|
||||||
|
bool MyApp::OnInit()
|
||||||
|
{
|
||||||
|
// create the main application window
|
||||||
|
MyFrame *frame = new MyFrame(_T("Minimal wxWindows 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
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// frame constructor
|
||||||
|
MyFrame::MyFrame(const wxString& title)
|
||||||
|
: wxFrame(NULL, wxID_ANY, title)
|
||||||
|
{
|
||||||
|
// set the frame icon
|
||||||
|
|
||||||
|
#if wxUSE_MENUS
|
||||||
|
// create a menu bar
|
||||||
|
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_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
|
||||||
|
|
||||||
|
#if wxUSE_STATUSBAR
|
||||||
|
// create a status bar just for fun (by default with 1 pane only)
|
||||||
|
CreateStatusBar(2);
|
||||||
|
SetStatusText(_T("Welcome to wxWindows!"));
|
||||||
|
#endif // wxUSE_STATUSBAR
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// event handlers
|
||||||
|
|
||||||
|
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 minimal sample.\n")
|
||||||
|
_T("Welcome to %s"), wxVERSION_STRING);
|
||||||
|
|
||||||
|
wxMessageBox(msg, _T("About Minimal"), wxOK | wxICON_INFORMATION, this);
|
||||||
|
}
|
Reference in New Issue
Block a user