From b0f73b670109edc96b6d8fdabec12eaf65b37cca Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 17 Jul 2010 14:55:45 +0000 Subject: [PATCH] Really set svn:eol-style property. The last commit used incorrect property name, remove the erroneous property and set the correct svn:eol-style one. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64996 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- BuildSVN.txt | 488 ++++++++++++++++---------------- docs/doxygen/wxwidgets.js | 156 +++++----- docs/tech/tn0024.txt | 110 +++---- misc/scripts/ctags.ignore | 80 +++--- samples/wrapsizer/wrapsizer.bkl | 24 +- src/os2/snglinst.cpp | 248 ++++++++-------- tests/controls/label.cpp | 426 ++++++++++++++-------------- 7 files changed, 766 insertions(+), 766 deletions(-) diff --git a/BuildSVN.txt b/BuildSVN.txt index 639487e558..06d5fd8b73 100644 --- a/BuildSVN.txt +++ b/BuildSVN.txt @@ -1,244 +1,244 @@ ------------------------------------------------------------------------- - How to build the sources from SVN ------------------------------------------------------------------------- - -Please use the install.txt files in docs/gtk, docs/msw, docs/motif, docs/mac -etc. alongside these instructions. - -I) Windows using plain makefiles ----------------------------------------- - -a) If using Microsoft Visual C++ 5.0 or 6.0 - -Ensure that the command-line compiler and tools (including -nmake) are installed and ready to run. Depending on your -installation there may be a batch file (commonly named VCVARS32.BAT) -that needs to be run to set correct environment variables and PATH entries. - -Continue with item c) below. - - -b) If using the MinGW or Cygwin compilers - -You can get MinGW from http://www.mingw.org/ - -Cygwin is available at http://www.cygwin.com/ - -If you are using Cygwin or MinGW together with the MSYS environment, you -can build the library using configure (see "Unix ports" and -"Windows using configure" below). You can also -build wxWidgets without configure using native makefile, but only with -MinGW. Using Cygwin together with Windows makefile is no longer supported. - -If building with MinGW without configure: - --> Set your path so that it includes the directory - where your compiler and tools reside - --> Make sure you have GNU Make installed. It must be Windows native version. - Download it from http://www.mingw.org, the executable will be called - mingw32-make.exe. - --> Modern version of MinGW is required; preferably MinGW 2.0 (with gcc3), - but MinGW with gcc-2.95.3 will suffice. If you are using 2.95, you will - have to change variable GCC_VERSION in config.gcc (see msw/install.txt - for details). - -If using configure, Unix instructions apply. - - -c) Build instructions - -Assuming that you installed the wxWidgets sources into c:\wxWidgets: - --> Copy c:\wxWidgets\include\wx\msw\setup0.h - to c:\wxWidgets\include\wx\msw\setup.h --> Edit c:\wxWidgets\include\wx\msw\setup.h to choose - the features you would like to compile wxWidgets with[out]. - - and std iostreams are disabled with - #define wxUSE_STD_IOSTREAM 0 - --> type: cd c:\wxWidgets\build\msw --> type: make -f makefile.gcc (if using GNU tools) -or type: nmake -f makefile.vc (if using MS VC++) -etc. - - See also docs/msw/install.txt for additional compilation options. - -d) Borland (including free command line tools) - Download tools from http://www.borland.com/downloads/ - - See docs/msw/install.txt for details; in brief: - --> type cd c:\wxWidgets\build\msw --> type make -f makefile.bcc - -You can customize many things in the build process, detailed description is -in docs/msw/install.txt. - - -II) Unix ports --------------- - -Building wxGTK or wxMotif completely without configure -won't ever work, but there is now a new makefile system -that works without libtool and automake, using only -configure to create what is needed. - -In order to create configure, you need to have the -GNU autoconf package (version > 2.54) installed -on your system and type run "autoconf" in the base -directory (or run the autogen.sh script in the same -directory, which just calls autoconf). Note that you usually don't -need to do this because configure is included in SVN. - -Set WXWIN environment variable to the base directory such -as ~/wxWidgets (this is actually not really needed). - --> type: export WXWIN=~/wxWidgets --> type: md mybuild --> type: cd mybuild --> type: ../configure --with-motif -or type: ../configure --with-gtk --> type: make --> type: su --> type: make install --> type: ldconfig --> type: exit - -Call configure with --disable-shared to create a static -library. Calling "make uninstall" will remove the installed -library and "make dist" will create a distribution (not -yet complete). - -III) Windows using configure ----------------------------------------- - -wxWidgets can be built on Windows using MSYS (see -http://www.mingw.org/), which is a POSIX build environment -for Windows. With MSYS you can just ./configure && make (see also VII, -Unix->Windows cross-compiling using configure). - -Of course, you can also build the library using plain makefiles (see -section I). - -V) MacOS X using configure and the Developer Tools ----------------------------------------- - -You need to have the Developer Tools installed. If this is not the case, -you will need to register at the Apple Developer web site (this is a free -registration) in order to download the Developer Tools installer. - -In order to create configure, you need to have the -GNU autoconf package (version >= 2.54) installed -on your system and type run "autoconf" in the base -directory (or run the autogen.sh script in the same -directory, which just calls autoconf). - --> type: mkdir macbuild --> type: cd macbuild --> type: ../configure --with-mac -or type: ../configure --> type: make - -VI) OS/2 ----------------------------------------- -No notes. - -VII) Unix->Windows cross-compiling using configure --------------------------------------------------- - -First you'll need a cross-compiler; linux glibc binaries of MinGW and -Cygwin (both based on egcs) can be found at -ftp://ftp.objsw.com/pub/crossgcc/linux-x-win32. Alternative binaries, -based on the latest MinGW release can be found at -http://members.telering.at/jessich/mingw/mingwcross/mingw_cross.html -Otherwise you can compile one yourself. - -[ A Note about Cygwin and MinGW: the main difference is that Cygwin -binaries are always linked against cygwin.dll. This dll encapsulates most -standard Unix C extensions, which is very handy if you're porting unix -software to windows. However, wxMSW doesn't need this, so MinGW is -preferable if you write portable C(++). ] - -You might want to build both Unix and Windows binaries in the same source -tree; to do this make subdirs for each e.g. unix and win32. If you've -already build wxWidgets in the main dir, do a 'make distclean' there, -otherwise configure will get confused. (In any case, read the section 'Unix -using configure' and make sure you're able to build a native wxWidgets -library; cross-compiling errors can be pretty obscure and you'll want to be -sure that your configure setup is basically sound.) - -To cross compile the windows library, do --> cd win32 -(or whatever you called it) -Now run configure. There are two ways to do this --> ../configure --host=i586-mingw32 --build=i586-linux --with-mingw -where --build= should read whatever platform you're building on. Configure -will notice that build and host platforms differ, and automatically prepend -i586-mingw32- to gcc, ar, ld, etc (make sure they're in the PATH!). -The other way to run configure is by specifying the names of the binaries -yourself: --> CC=i586-mingw32-gcc CXX=i586-mingw32-g++ RANLIB=i586-mingw32-ranlib \ - DLLTOOL=i586-mingw32-dlltool LD=i586-mingw32-ld NM=i586-mingw32-nm \ - ../configure --host=i586-mingw32 --with-mingw - -(all assuming you're using MinGW) -By default this will compile a DLL, if you want a static library, -specify --disable-shared. - -Type --> make -and wait, wait, wait. Don't leave the room, because the minute you do there -will be a compile error :-) - -NB: if you are using a very old compiler you risk to get quite a few warnings - about "ANSI C++ forbids implicit conversion from 'void *'" in all places - where va_arg macro is used. This is due to a bug in (some versions of) - MinGW headers which may be corrected by upgrading your compier, - otherwise you might edit the file - - ${install_prefix}/lib/gcc-lib/i586-mingw32/egcs-2.91.57/include/stdarg.h - - (instead of egcs-2.91.57 you may have something different), searching for - the lines - -/* Define __gnuc_va_list. */ - -#ifndef __GNUC_VA_LIST -#define __GNUC_VA_LIST -#if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX) || defined(__NetBSD__) -typedef char *__gnuc_va_list; -#else -typedef void *__gnuc_va_list; -#endif -#endif - - and adding "|| defined(_WIN32)" to the list of platforms on which - __gnuc_va_list is char *. - -If this is successful, you end up with a wx23_2.dll/libwx23_2.a in win32/lib -(or just libwx_msw.a if you opted for a static build). -Now try building the minimal sample: - --> cd samples/minimal --> make - -and run it with wine, for example (or copy to a Windows box) --> wine minimal.exe - -If all is well, do an install; from win32 --> make install - -Native and cross-compiled installations can co-exist peacefully -(as long as their widget sets differ), except for wx-config. You might -want to rename the cross-compiled one to i586-mingw32-wx-config, or something. - -Cross-compiling TODO: ---------------------- -- resource compiling must be done manually for now (should/can we link the -default wx resources into libwx_msw.a?) [ No we can't; the linker won't -link it in... you have to supply an object file ] -- static executables are HUGE -- there must be room for improvement. - +------------------------------------------------------------------------ + How to build the sources from SVN +------------------------------------------------------------------------ + +Please use the install.txt files in docs/gtk, docs/msw, docs/motif, docs/mac +etc. alongside these instructions. + +I) Windows using plain makefiles +---------------------------------------- + +a) If using Microsoft Visual C++ 5.0 or 6.0 + +Ensure that the command-line compiler and tools (including +nmake) are installed and ready to run. Depending on your +installation there may be a batch file (commonly named VCVARS32.BAT) +that needs to be run to set correct environment variables and PATH entries. + +Continue with item c) below. + + +b) If using the MinGW or Cygwin compilers + +You can get MinGW from http://www.mingw.org/ + +Cygwin is available at http://www.cygwin.com/ + +If you are using Cygwin or MinGW together with the MSYS environment, you +can build the library using configure (see "Unix ports" and +"Windows using configure" below). You can also +build wxWidgets without configure using native makefile, but only with +MinGW. Using Cygwin together with Windows makefile is no longer supported. + +If building with MinGW without configure: + +-> Set your path so that it includes the directory + where your compiler and tools reside + +-> Make sure you have GNU Make installed. It must be Windows native version. + Download it from http://www.mingw.org, the executable will be called + mingw32-make.exe. + +-> Modern version of MinGW is required; preferably MinGW 2.0 (with gcc3), + but MinGW with gcc-2.95.3 will suffice. If you are using 2.95, you will + have to change variable GCC_VERSION in config.gcc (see msw/install.txt + for details). + +If using configure, Unix instructions apply. + + +c) Build instructions + +Assuming that you installed the wxWidgets sources into c:\wxWidgets: + +-> Copy c:\wxWidgets\include\wx\msw\setup0.h + to c:\wxWidgets\include\wx\msw\setup.h +-> Edit c:\wxWidgets\include\wx\msw\setup.h to choose + the features you would like to compile wxWidgets with[out]. + + and std iostreams are disabled with + #define wxUSE_STD_IOSTREAM 0 + +-> type: cd c:\wxWidgets\build\msw +-> type: make -f makefile.gcc (if using GNU tools) +or type: nmake -f makefile.vc (if using MS VC++) +etc. + + See also docs/msw/install.txt for additional compilation options. + +d) Borland (including free command line tools) + Download tools from http://www.borland.com/downloads/ + + See docs/msw/install.txt for details; in brief: + +-> type cd c:\wxWidgets\build\msw +-> type make -f makefile.bcc + +You can customize many things in the build process, detailed description is +in docs/msw/install.txt. + + +II) Unix ports +-------------- + +Building wxGTK or wxMotif completely without configure +won't ever work, but there is now a new makefile system +that works without libtool and automake, using only +configure to create what is needed. + +In order to create configure, you need to have the +GNU autoconf package (version > 2.54) installed +on your system and type run "autoconf" in the base +directory (or run the autogen.sh script in the same +directory, which just calls autoconf). Note that you usually don't +need to do this because configure is included in SVN. + +Set WXWIN environment variable to the base directory such +as ~/wxWidgets (this is actually not really needed). + +-> type: export WXWIN=~/wxWidgets +-> type: md mybuild +-> type: cd mybuild +-> type: ../configure --with-motif +or type: ../configure --with-gtk +-> type: make +-> type: su +-> type: make install +-> type: ldconfig +-> type: exit + +Call configure with --disable-shared to create a static +library. Calling "make uninstall" will remove the installed +library and "make dist" will create a distribution (not +yet complete). + +III) Windows using configure +---------------------------------------- + +wxWidgets can be built on Windows using MSYS (see +http://www.mingw.org/), which is a POSIX build environment +for Windows. With MSYS you can just ./configure && make (see also VII, +Unix->Windows cross-compiling using configure). + +Of course, you can also build the library using plain makefiles (see +section I). + +V) MacOS X using configure and the Developer Tools +---------------------------------------- + +You need to have the Developer Tools installed. If this is not the case, +you will need to register at the Apple Developer web site (this is a free +registration) in order to download the Developer Tools installer. + +In order to create configure, you need to have the +GNU autoconf package (version >= 2.54) installed +on your system and type run "autoconf" in the base +directory (or run the autogen.sh script in the same +directory, which just calls autoconf). + +-> type: mkdir macbuild +-> type: cd macbuild +-> type: ../configure --with-mac +or type: ../configure +-> type: make + +VI) OS/2 +---------------------------------------- +No notes. + +VII) Unix->Windows cross-compiling using configure +-------------------------------------------------- + +First you'll need a cross-compiler; linux glibc binaries of MinGW and +Cygwin (both based on egcs) can be found at +ftp://ftp.objsw.com/pub/crossgcc/linux-x-win32. Alternative binaries, +based on the latest MinGW release can be found at +http://members.telering.at/jessich/mingw/mingwcross/mingw_cross.html +Otherwise you can compile one yourself. + +[ A Note about Cygwin and MinGW: the main difference is that Cygwin +binaries are always linked against cygwin.dll. This dll encapsulates most +standard Unix C extensions, which is very handy if you're porting unix +software to windows. However, wxMSW doesn't need this, so MinGW is +preferable if you write portable C(++). ] + +You might want to build both Unix and Windows binaries in the same source +tree; to do this make subdirs for each e.g. unix and win32. If you've +already build wxWidgets in the main dir, do a 'make distclean' there, +otherwise configure will get confused. (In any case, read the section 'Unix +using configure' and make sure you're able to build a native wxWidgets +library; cross-compiling errors can be pretty obscure and you'll want to be +sure that your configure setup is basically sound.) + +To cross compile the windows library, do +-> cd win32 +(or whatever you called it) +Now run configure. There are two ways to do this +-> ../configure --host=i586-mingw32 --build=i586-linux --with-mingw +where --build= should read whatever platform you're building on. Configure +will notice that build and host platforms differ, and automatically prepend +i586-mingw32- to gcc, ar, ld, etc (make sure they're in the PATH!). +The other way to run configure is by specifying the names of the binaries +yourself: +-> CC=i586-mingw32-gcc CXX=i586-mingw32-g++ RANLIB=i586-mingw32-ranlib \ + DLLTOOL=i586-mingw32-dlltool LD=i586-mingw32-ld NM=i586-mingw32-nm \ + ../configure --host=i586-mingw32 --with-mingw + +(all assuming you're using MinGW) +By default this will compile a DLL, if you want a static library, +specify --disable-shared. + +Type +-> make +and wait, wait, wait. Don't leave the room, because the minute you do there +will be a compile error :-) + +NB: if you are using a very old compiler you risk to get quite a few warnings + about "ANSI C++ forbids implicit conversion from 'void *'" in all places + where va_arg macro is used. This is due to a bug in (some versions of) + MinGW headers which may be corrected by upgrading your compier, + otherwise you might edit the file + + ${install_prefix}/lib/gcc-lib/i586-mingw32/egcs-2.91.57/include/stdarg.h + + (instead of egcs-2.91.57 you may have something different), searching for + the lines + +/* Define __gnuc_va_list. */ + +#ifndef __GNUC_VA_LIST +#define __GNUC_VA_LIST +#if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX) || defined(__NetBSD__) +typedef char *__gnuc_va_list; +#else +typedef void *__gnuc_va_list; +#endif +#endif + + and adding "|| defined(_WIN32)" to the list of platforms on which + __gnuc_va_list is char *. + +If this is successful, you end up with a wx23_2.dll/libwx23_2.a in win32/lib +(or just libwx_msw.a if you opted for a static build). +Now try building the minimal sample: + +-> cd samples/minimal +-> make + +and run it with wine, for example (or copy to a Windows box) +-> wine minimal.exe + +If all is well, do an install; from win32 +-> make install + +Native and cross-compiled installations can co-exist peacefully +(as long as their widget sets differ), except for wx-config. You might +want to rename the cross-compiled one to i586-mingw32-wx-config, or something. + +Cross-compiling TODO: +--------------------- +- resource compiling must be done manually for now (should/can we link the +default wx resources into libwx_msw.a?) [ No we can't; the linker won't +link it in... you have to supply an object file ] +- static executables are HUGE -- there must be room for improvement. + diff --git a/docs/doxygen/wxwidgets.js b/docs/doxygen/wxwidgets.js index 7bb9de9ab6..980f91959d 100644 --- a/docs/doxygen/wxwidgets.js +++ b/docs/doxygen/wxwidgets.js @@ -1,5 +1,5 @@ -/***************************************************************************** - ** Name: wxwidgets.js +/***************************************************************************** + ** Name: wxwidgets.js ** Purpose: The wxWidgets documentation javascript ** Author: Doxygen team ** RCS-ID: $Id$ @@ -7,79 +7,79 @@ *****************************************************************************/ // from w3schools -function getCookie(c_name) -{ - if (document.cookie.length>0) - { - c_start=document.cookie.indexOf(c_name + "="); - if (c_start!=-1) - { - c_start=c_start + c_name.length+1; - c_end=document.cookie.indexOf(";",c_start); - if (c_end==-1) c_end=document.cookie.length; - return unescape(document.cookie.substring(c_start,c_end)); - } - } - return ""; -} -// from w3schools -function setCookie(c_name,value,expiredays) -{ - var exdate=new Date(); - exdate.setDate(exdate.getDate()+expiredays); - document.cookie=c_name+ '=' +escape(value)+ - ((expiredays==null) ? '' : ';expires='+exdate.toGMTString()); -} - -// Reimplementation of changeDisplayState -function mychangeDisplayState( e ) -{ - var num=this.id.replace(/[^[0-9]/g,''); - var button=this.firstChild; - var sectionDiv=document.getElementById('dynsection'+num); - if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){ - sectionDiv.style.display='block'; - button.src='open.gif'; - }else{ - sectionDiv.style.display='none'; - button.src='closed.gif'; - } - - setCookie( 'sectionDiv.style.display', sectionDiv.style.display ); - -} - -window.onload = function myinitDynSections() -{ - var divs=document.getElementsByTagName('div'); - var sectionCounter=1; - for(var i=0;i0) + { + c_start=document.cookie.indexOf(c_name + "="); + if (c_start!=-1) + { + c_start=c_start + c_name.length+1; + c_end=document.cookie.indexOf(";",c_start); + if (c_end==-1) c_end=document.cookie.length; + return unescape(document.cookie.substring(c_start,c_end)); + } + } + return ""; +} +// from w3schools +function setCookie(c_name,value,expiredays) +{ + var exdate=new Date(); + exdate.setDate(exdate.getDate()+expiredays); + document.cookie=c_name+ '=' +escape(value)+ + ((expiredays==null) ? '' : ';expires='+exdate.toGMTString()); +} + +// Reimplementation of changeDisplayState +function mychangeDisplayState( e ) +{ + var num=this.id.replace(/[^[0-9]/g,''); + var button=this.firstChild; + var sectionDiv=document.getElementById('dynsection'+num); + if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){ + sectionDiv.style.display='block'; + button.src='open.gif'; + }else{ + sectionDiv.style.display='none'; + button.src='closed.gif'; + } + + setCookie( 'sectionDiv.style.display', sectionDiv.style.display ); + +} + +window.onload = function myinitDynSections() +{ + var divs=document.getElementsByTagName('div'); + var sectionCounter=1; + for(var i=0;i - - - - - - wrapsizer.cpp - core - base - - - + + + + + + + wrapsizer.cpp + core + base + + + diff --git a/src/os2/snglinst.cpp b/src/os2/snglinst.cpp index 20df07a4b2..fd03b774fd 100644 --- a/src/os2/snglinst.cpp +++ b/src/os2/snglinst.cpp @@ -1,9 +1,9 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: os2/snglinst.cpp -// Purpose: implements wxSingleInstanceChecker class for OS/2 using -// named mutexes -// Author: Vadim Zeitlin -// Modified by: Lauri Nurmi (modified for OS/2) +/////////////////////////////////////////////////////////////////////////////// +// Name: os2/snglinst.cpp +// Purpose: implements wxSingleInstanceChecker class for OS/2 using +// named mutexes +// Author: Vadim Zeitlin +// Modified by: Lauri Nurmi (modified for OS/2) // Created: 08.02.2009 // RCS-ID: $Id$ // Copyright: (c) 2001 Vadim Zeitlin @@ -11,122 +11,122 @@ /////////////////////////////////////////////////////////////////////////////// // ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_SNGLINST_CHECKER - -#ifndef WX_PRECOMP - #include "wx/string.h" - #include "wx/log.h" -#endif //WX_PRECOMP - -#include "wx/snglinst.h" - -#define INCL_DOSSEMAPHORES -#define INCL_DOSERRORS -#include - -#include "wx/os2/private.h" - -// ---------------------------------------------------------------------------- -// wxSingleInstanceCheckerImpl: the real implementation class -// ---------------------------------------------------------------------------- - -class WXDLLEXPORT wxSingleInstanceCheckerImpl -{ -public: - wxSingleInstanceCheckerImpl() - { - m_hMutex = NULL; - m_anotherRunning = false; - } - - bool Create(const wxString& name) - { - wxString semName; - semName.Printf(wxT("\\SEM32\\%s"), name.c_str()); - int rc = DosCreateMutexSem(semName.c_str(), &m_hMutex, DC_SEM_SHARED, 1); - - if ( rc == NO_ERROR ) { - m_anotherRunning = false; - return true; - } else if ( rc == ERROR_DUPLICATE_NAME ) { - m_anotherRunning = true; - return true; - } else { - m_anotherRunning = false; // we don't know for sure in this case - wxLogLastError(wxT("DosCreateMutexSem")); - return false; - } - } - - bool IsAnotherRunning() const - { - return m_anotherRunning; - } - - ~wxSingleInstanceCheckerImpl() - { - if ( m_hMutex ) - { - if ( !::DosCloseMutexSem(m_hMutex) ) - { - wxLogLastError(wxT("DosCloseMutexSem")); - } - } - } - -private: - // if true, creating the mutex either succeeded - // or we know it failed because another app is running. - bool m_anotherRunning; - - // the mutex handle, may be NULL - HMTX m_hMutex; - - DECLARE_NO_COPY_CLASS(wxSingleInstanceCheckerImpl) -}; - -// ============================================================================ -// wxSingleInstanceChecker implementation -// ============================================================================ - -bool wxSingleInstanceChecker::Create(const wxString& name, - const wxString& WXUNUSED(path)) -{ - wxASSERT_MSG( !m_impl, - wxT("calling wxSingleInstanceChecker::Create() twice?") ); - - // creating unnamed mutex doesn't have the same semantics! - wxASSERT_MSG( !name.empty(), wxT("mutex name can't be empty") ); - - m_impl = new wxSingleInstanceCheckerImpl; - - return m_impl->Create(name); -} - +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#if wxUSE_SNGLINST_CHECKER + +#ifndef WX_PRECOMP + #include "wx/string.h" + #include "wx/log.h" +#endif //WX_PRECOMP + +#include "wx/snglinst.h" + +#define INCL_DOSSEMAPHORES +#define INCL_DOSERRORS +#include + +#include "wx/os2/private.h" + +// ---------------------------------------------------------------------------- +// wxSingleInstanceCheckerImpl: the real implementation class +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxSingleInstanceCheckerImpl +{ +public: + wxSingleInstanceCheckerImpl() + { + m_hMutex = NULL; + m_anotherRunning = false; + } + + bool Create(const wxString& name) + { + wxString semName; + semName.Printf(wxT("\\SEM32\\%s"), name.c_str()); + int rc = DosCreateMutexSem(semName.c_str(), &m_hMutex, DC_SEM_SHARED, 1); + + if ( rc == NO_ERROR ) { + m_anotherRunning = false; + return true; + } else if ( rc == ERROR_DUPLICATE_NAME ) { + m_anotherRunning = true; + return true; + } else { + m_anotherRunning = false; // we don't know for sure in this case + wxLogLastError(wxT("DosCreateMutexSem")); + return false; + } + } + + bool IsAnotherRunning() const + { + return m_anotherRunning; + } + + ~wxSingleInstanceCheckerImpl() + { + if ( m_hMutex ) + { + if ( !::DosCloseMutexSem(m_hMutex) ) + { + wxLogLastError(wxT("DosCloseMutexSem")); + } + } + } + +private: + // if true, creating the mutex either succeeded + // or we know it failed because another app is running. + bool m_anotherRunning; + + // the mutex handle, may be NULL + HMTX m_hMutex; + + DECLARE_NO_COPY_CLASS(wxSingleInstanceCheckerImpl) +}; + +// ============================================================================ +// wxSingleInstanceChecker implementation +// ============================================================================ + +bool wxSingleInstanceChecker::Create(const wxString& name, + const wxString& WXUNUSED(path)) +{ + wxASSERT_MSG( !m_impl, + wxT("calling wxSingleInstanceChecker::Create() twice?") ); + + // creating unnamed mutex doesn't have the same semantics! + wxASSERT_MSG( !name.empty(), wxT("mutex name can't be empty") ); + + m_impl = new wxSingleInstanceCheckerImpl; + + return m_impl->Create(name); +} + bool wxSingleInstanceChecker::DoIsAnotherRunning() const -{ - wxCHECK_MSG( m_impl, false, wxT("must call Create() first") ); - - return m_impl->IsAnotherRunning(); -} - -wxSingleInstanceChecker::~wxSingleInstanceChecker() -{ - delete m_impl; -} - -#endif // wxUSE_SNGLINST_CHECKER +{ + wxCHECK_MSG( m_impl, false, wxT("must call Create() first") ); + + return m_impl->IsAnotherRunning(); +} + +wxSingleInstanceChecker::~wxSingleInstanceChecker() +{ + delete m_impl; +} + +#endif // wxUSE_SNGLINST_CHECKER diff --git a/tests/controls/label.cpp b/tests/controls/label.cpp index d9d2eebdeb..2cc8afccbb 100644 --- a/tests/controls/label.cpp +++ b/tests/controls/label.cpp @@ -1,213 +1,213 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: tests/controls/label.cpp -// Purpose: wxControl and wxStaticText label tests -// Author: Francesco Montorsi -// Created: 2010-3-21 -// RCS-ID: $Id$ -// Copyright: (c) 2010 Francesco Montorsi -/////////////////////////////////////////////////////////////////////////////// - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "testprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/app.h" -#endif // WX_PRECOMP - -#include "wx/control.h" -#include "wx/stattext.h" -#include "wx/checkbox.h" - -// ---------------------------------------------------------------------------- -// test class -// ---------------------------------------------------------------------------- - -class LabelTestCase : public CppUnit::TestCase -{ -public: - LabelTestCase() { } - - virtual void setUp(); - virtual void tearDown(); - -private: - CPPUNIT_TEST_SUITE( LabelTestCase ); - CPPUNIT_TEST( GetLabel ); - CPPUNIT_TEST( GetLabelText ); - CPPUNIT_TEST( Statics ); - CPPUNIT_TEST_SUITE_END(); - - void GetLabel(); - void GetLabelText(); - void Statics(); - - wxStaticText *m_st, *m_stWithMarkup; - - // we cannot test wxControl directly (it's abstract) so we rather test wxCheckBox - wxCheckBox *m_cb; - - DECLARE_NO_COPY_CLASS(LabelTestCase) -}; - -// register in the unnamed registry so that these tests are run by default -CPPUNIT_TEST_SUITE_REGISTRATION( LabelTestCase ); - -// also include in it's own registry so that these tests can be run alone -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( LabelTestCase, "LabelTestCase" ); - -// ---------------------------------------------------------------------------- -// test initialization -// ---------------------------------------------------------------------------- - -#define ORIGINAL_LABEL "original label" - -void LabelTestCase::setUp() -{ - m_st = new wxStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL); - m_stWithMarkup = new wxStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL, - wxDefaultPosition, wxDefaultSize, wxST_MARKUP); - - m_cb = new wxCheckBox(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL); - - CPPUNIT_ASSERT_EQUAL( ORIGINAL_LABEL, m_st->GetLabel() ); - CPPUNIT_ASSERT_EQUAL( ORIGINAL_LABEL, m_stWithMarkup->GetLabel() ); - CPPUNIT_ASSERT_EQUAL( ORIGINAL_LABEL, m_cb->GetLabel() ); -} - -void LabelTestCase::tearDown() -{ - wxDELETE(m_st); - wxDELETE(m_stWithMarkup); - wxDELETE(m_cb); -} - -// ---------------------------------------------------------------------------- -// the tests themselves -// ---------------------------------------------------------------------------- - -#define SET_LABEL(str) \ - m_st->SetLabel(str); \ - m_stWithMarkup->SetLabel(str); \ - m_cb->SetLabel(str); - -#define SET_LABEL_TEXT(str) \ - m_st->SetLabelText(str); \ - m_stWithMarkup->SetLabelText(str); \ - m_cb->SetLabelText(str); - -void LabelTestCase::GetLabel() -{ - const wxString testLabelArray[] = { - "label without mnemonics and markup", - "label with &mnemonic", - "label with some markup", - "label with some markup and &mnemonic", - }; - - // test calls to SetLabel() and then to GetLabel() - - for ( unsigned int s = 0; s < WXSIZEOF(testLabelArray); s++ ) - { - SET_LABEL(testLabelArray[s]); - - // GetLabel() should always return the string passed to SetLabel() - CPPUNIT_ASSERT_EQUAL( testLabelArray[s], m_st->GetLabel() ); - CPPUNIT_ASSERT_EQUAL( testLabelArray[s], m_stWithMarkup->GetLabel() ); - CPPUNIT_ASSERT_EQUAL( testLabelArray[s], m_cb->GetLabel() ); - } - - - // test calls to SetLabelText() and then to GetLabel() - - const wxString& testLabel = "label without mnemonics and markup"; - SET_LABEL_TEXT(testLabel); - CPPUNIT_ASSERT_EQUAL( testLabel, m_st->GetLabel() ); - CPPUNIT_ASSERT_EQUAL( testLabel, m_stWithMarkup->GetLabel() ); - CPPUNIT_ASSERT_EQUAL( testLabel, m_cb->GetLabel() ); - - const wxString& testLabel2 = "label with &mnemonic"; - const wxString& testLabelText2 = "label with &&mnemonic"; - SET_LABEL_TEXT(testLabel2); - CPPUNIT_ASSERT_EQUAL( testLabelText2, m_st->GetLabel() ); - CPPUNIT_ASSERT_EQUAL( "label with &mnemonic", m_stWithMarkup->GetLabel() ); - CPPUNIT_ASSERT_EQUAL( testLabelText2, m_cb->GetLabel() ); - - const wxString& testLabel3 = "label with some markup"; - SET_LABEL_TEXT(testLabel3); - CPPUNIT_ASSERT_EQUAL( testLabel3, m_st->GetLabel() ); - CPPUNIT_ASSERT_EQUAL( "label with <span foreground='blue'>some</span> <b>markup</b>", m_stWithMarkup->GetLabel() ); - CPPUNIT_ASSERT_EQUAL( testLabel3, m_cb->GetLabel() ); - - const wxString& testLabel4 = "label with some markup and &mnemonic"; - const wxString& testLabelText4 = "label with some markup and &&mnemonic"; - SET_LABEL_TEXT(testLabel4); - CPPUNIT_ASSERT_EQUAL( testLabelText4, m_st->GetLabel() ); - CPPUNIT_ASSERT_EQUAL( "label with <span foreground='blue'>some</span> <b>markup</b> and &mnemonic", m_stWithMarkup->GetLabel() ); - CPPUNIT_ASSERT_EQUAL( testLabelText4, m_cb->GetLabel() ); -} - -void LabelTestCase::GetLabelText() -{ - // test calls to SetLabel() and then to GetLabelText() - - const wxString& testLabel = "label without mnemonics and markup"; - SET_LABEL(testLabel); - CPPUNIT_ASSERT_EQUAL( testLabel, m_st->GetLabelText() ); - CPPUNIT_ASSERT_EQUAL( testLabel, m_stWithMarkup->GetLabelText() ); - CPPUNIT_ASSERT_EQUAL( testLabel, m_cb->GetLabelText() ); - - const wxString& testLabel2 = "label with &mnemonic"; - const wxString& testLabelText2 = "label with mnemonic"; - SET_LABEL(testLabel2); - CPPUNIT_ASSERT_EQUAL( testLabelText2, m_st->GetLabelText() ); - CPPUNIT_ASSERT_EQUAL( testLabelText2, m_stWithMarkup->GetLabelText() ); - CPPUNIT_ASSERT_EQUAL( testLabelText2, m_cb->GetLabelText() ); - - const wxString& testLabel3 = "label with some markup"; - SET_LABEL(testLabel3); - CPPUNIT_ASSERT_EQUAL( testLabel3, m_st->GetLabelText() ); - CPPUNIT_ASSERT_EQUAL( "label with some markup", m_stWithMarkup->GetLabelText() ); - CPPUNIT_ASSERT_EQUAL( testLabel3, m_cb->GetLabelText() ); - - const wxString& testLabel4 = "label with some markup and &mnemonic"; - const wxString& testLabelText4 = "label with some markup and mnemonic"; - SET_LABEL(testLabel4); - CPPUNIT_ASSERT_EQUAL( testLabelText4, m_st->GetLabelText() ); - CPPUNIT_ASSERT_EQUAL( "label with some markup and mnemonic", m_stWithMarkup->GetLabelText() ); - CPPUNIT_ASSERT_EQUAL( testLabelText4, m_cb->GetLabelText() ); - - - const wxString testLabelArray[] = { - "label without mnemonics and markup", - "label with &mnemonic", - "label with some markup", - "label with some markup and &mnemonic", - }; - - // test calls to SetLabelText() and then to GetLabelText() - - for ( unsigned int s = 0; s < WXSIZEOF(testLabelArray); s++ ) - { - SET_LABEL_TEXT(testLabelArray[s]); - - // GetLabelText() should always return the string passed to SetLabelText() - CPPUNIT_ASSERT_EQUAL( testLabelArray[s], m_st->GetLabelText() ); - CPPUNIT_ASSERT_EQUAL( testLabelArray[s], m_stWithMarkup->GetLabelText() ); - CPPUNIT_ASSERT_EQUAL( testLabelArray[s], m_cb->GetLabelText() ); - } -} - -void LabelTestCase::Statics() -{ - CPPUNIT_ASSERT_EQUAL( "mnemonic", wxControl::RemoveMnemonics("&mnemonic") ); - CPPUNIT_ASSERT_EQUAL( "&mnemonic", wxControl::RemoveMnemonics("&&mnemonic") ); - CPPUNIT_ASSERT_EQUAL( "&mnemonic", wxControl::RemoveMnemonics("&&&mnemonic") ); - CPPUNIT_ASSERT_EQUAL( "", wxStaticText::RemoveMarkup("") ); -} +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/label.cpp +// Purpose: wxControl and wxStaticText label tests +// Author: Francesco Montorsi +// Created: 2010-3-21 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Francesco Montorsi +/////////////////////////////////////////////////////////////////////////////// + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#include "testprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" +#endif // WX_PRECOMP + +#include "wx/control.h" +#include "wx/stattext.h" +#include "wx/checkbox.h" + +// ---------------------------------------------------------------------------- +// test class +// ---------------------------------------------------------------------------- + +class LabelTestCase : public CppUnit::TestCase +{ +public: + LabelTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + CPPUNIT_TEST_SUITE( LabelTestCase ); + CPPUNIT_TEST( GetLabel ); + CPPUNIT_TEST( GetLabelText ); + CPPUNIT_TEST( Statics ); + CPPUNIT_TEST_SUITE_END(); + + void GetLabel(); + void GetLabelText(); + void Statics(); + + wxStaticText *m_st, *m_stWithMarkup; + + // we cannot test wxControl directly (it's abstract) so we rather test wxCheckBox + wxCheckBox *m_cb; + + DECLARE_NO_COPY_CLASS(LabelTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( LabelTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( LabelTestCase, "LabelTestCase" ); + +// ---------------------------------------------------------------------------- +// test initialization +// ---------------------------------------------------------------------------- + +#define ORIGINAL_LABEL "original label" + +void LabelTestCase::setUp() +{ + m_st = new wxStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL); + m_stWithMarkup = new wxStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL, + wxDefaultPosition, wxDefaultSize, wxST_MARKUP); + + m_cb = new wxCheckBox(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL); + + CPPUNIT_ASSERT_EQUAL( ORIGINAL_LABEL, m_st->GetLabel() ); + CPPUNIT_ASSERT_EQUAL( ORIGINAL_LABEL, m_stWithMarkup->GetLabel() ); + CPPUNIT_ASSERT_EQUAL( ORIGINAL_LABEL, m_cb->GetLabel() ); +} + +void LabelTestCase::tearDown() +{ + wxDELETE(m_st); + wxDELETE(m_stWithMarkup); + wxDELETE(m_cb); +} + +// ---------------------------------------------------------------------------- +// the tests themselves +// ---------------------------------------------------------------------------- + +#define SET_LABEL(str) \ + m_st->SetLabel(str); \ + m_stWithMarkup->SetLabel(str); \ + m_cb->SetLabel(str); + +#define SET_LABEL_TEXT(str) \ + m_st->SetLabelText(str); \ + m_stWithMarkup->SetLabelText(str); \ + m_cb->SetLabelText(str); + +void LabelTestCase::GetLabel() +{ + const wxString testLabelArray[] = { + "label without mnemonics and markup", + "label with &mnemonic", + "label with some markup", + "label with some markup and &mnemonic", + }; + + // test calls to SetLabel() and then to GetLabel() + + for ( unsigned int s = 0; s < WXSIZEOF(testLabelArray); s++ ) + { + SET_LABEL(testLabelArray[s]); + + // GetLabel() should always return the string passed to SetLabel() + CPPUNIT_ASSERT_EQUAL( testLabelArray[s], m_st->GetLabel() ); + CPPUNIT_ASSERT_EQUAL( testLabelArray[s], m_stWithMarkup->GetLabel() ); + CPPUNIT_ASSERT_EQUAL( testLabelArray[s], m_cb->GetLabel() ); + } + + + // test calls to SetLabelText() and then to GetLabel() + + const wxString& testLabel = "label without mnemonics and markup"; + SET_LABEL_TEXT(testLabel); + CPPUNIT_ASSERT_EQUAL( testLabel, m_st->GetLabel() ); + CPPUNIT_ASSERT_EQUAL( testLabel, m_stWithMarkup->GetLabel() ); + CPPUNIT_ASSERT_EQUAL( testLabel, m_cb->GetLabel() ); + + const wxString& testLabel2 = "label with &mnemonic"; + const wxString& testLabelText2 = "label with &&mnemonic"; + SET_LABEL_TEXT(testLabel2); + CPPUNIT_ASSERT_EQUAL( testLabelText2, m_st->GetLabel() ); + CPPUNIT_ASSERT_EQUAL( "label with &mnemonic", m_stWithMarkup->GetLabel() ); + CPPUNIT_ASSERT_EQUAL( testLabelText2, m_cb->GetLabel() ); + + const wxString& testLabel3 = "label with some markup"; + SET_LABEL_TEXT(testLabel3); + CPPUNIT_ASSERT_EQUAL( testLabel3, m_st->GetLabel() ); + CPPUNIT_ASSERT_EQUAL( "label with <span foreground='blue'>some</span> <b>markup</b>", m_stWithMarkup->GetLabel() ); + CPPUNIT_ASSERT_EQUAL( testLabel3, m_cb->GetLabel() ); + + const wxString& testLabel4 = "label with some markup and &mnemonic"; + const wxString& testLabelText4 = "label with some markup and &&mnemonic"; + SET_LABEL_TEXT(testLabel4); + CPPUNIT_ASSERT_EQUAL( testLabelText4, m_st->GetLabel() ); + CPPUNIT_ASSERT_EQUAL( "label with <span foreground='blue'>some</span> <b>markup</b> and &mnemonic", m_stWithMarkup->GetLabel() ); + CPPUNIT_ASSERT_EQUAL( testLabelText4, m_cb->GetLabel() ); +} + +void LabelTestCase::GetLabelText() +{ + // test calls to SetLabel() and then to GetLabelText() + + const wxString& testLabel = "label without mnemonics and markup"; + SET_LABEL(testLabel); + CPPUNIT_ASSERT_EQUAL( testLabel, m_st->GetLabelText() ); + CPPUNIT_ASSERT_EQUAL( testLabel, m_stWithMarkup->GetLabelText() ); + CPPUNIT_ASSERT_EQUAL( testLabel, m_cb->GetLabelText() ); + + const wxString& testLabel2 = "label with &mnemonic"; + const wxString& testLabelText2 = "label with mnemonic"; + SET_LABEL(testLabel2); + CPPUNIT_ASSERT_EQUAL( testLabelText2, m_st->GetLabelText() ); + CPPUNIT_ASSERT_EQUAL( testLabelText2, m_stWithMarkup->GetLabelText() ); + CPPUNIT_ASSERT_EQUAL( testLabelText2, m_cb->GetLabelText() ); + + const wxString& testLabel3 = "label with some markup"; + SET_LABEL(testLabel3); + CPPUNIT_ASSERT_EQUAL( testLabel3, m_st->GetLabelText() ); + CPPUNIT_ASSERT_EQUAL( "label with some markup", m_stWithMarkup->GetLabelText() ); + CPPUNIT_ASSERT_EQUAL( testLabel3, m_cb->GetLabelText() ); + + const wxString& testLabel4 = "label with some markup and &mnemonic"; + const wxString& testLabelText4 = "label with some markup and mnemonic"; + SET_LABEL(testLabel4); + CPPUNIT_ASSERT_EQUAL( testLabelText4, m_st->GetLabelText() ); + CPPUNIT_ASSERT_EQUAL( "label with some markup and mnemonic", m_stWithMarkup->GetLabelText() ); + CPPUNIT_ASSERT_EQUAL( testLabelText4, m_cb->GetLabelText() ); + + + const wxString testLabelArray[] = { + "label without mnemonics and markup", + "label with &mnemonic", + "label with some markup", + "label with some markup and &mnemonic", + }; + + // test calls to SetLabelText() and then to GetLabelText() + + for ( unsigned int s = 0; s < WXSIZEOF(testLabelArray); s++ ) + { + SET_LABEL_TEXT(testLabelArray[s]); + + // GetLabelText() should always return the string passed to SetLabelText() + CPPUNIT_ASSERT_EQUAL( testLabelArray[s], m_st->GetLabelText() ); + CPPUNIT_ASSERT_EQUAL( testLabelArray[s], m_stWithMarkup->GetLabelText() ); + CPPUNIT_ASSERT_EQUAL( testLabelArray[s], m_cb->GetLabelText() ); + } +} + +void LabelTestCase::Statics() +{ + CPPUNIT_ASSERT_EQUAL( "mnemonic", wxControl::RemoveMnemonics("&mnemonic") ); + CPPUNIT_ASSERT_EQUAL( "&mnemonic", wxControl::RemoveMnemonics("&&mnemonic") ); + CPPUNIT_ASSERT_EQUAL( "&mnemonic", wxControl::RemoveMnemonics("&&&mnemonic") ); + CPPUNIT_ASSERT_EQUAL( "", wxStaticText::RemoveMarkup("") ); +} -- 2.47.2