1998-05-20 14:12:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: private.h
|
1999-05-13 21:21:04 +00:00
|
|
|
// Purpose: Private declarations: as this header is only included by
|
2004-05-23 14:56:36 +00:00
|
|
|
// wxWidgets itself, it may contain identifiers which don't start
|
1999-05-13 21:21:04 +00:00
|
|
|
// with "wx".
|
1998-05-20 14:12:05 +00:00
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
1998-08-07 23:52:45 +00:00
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:12:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-07 23:52:45 +00:00
|
|
|
#ifndef _WX_PRIVATE_H_
|
|
|
|
#define _WX_PRIVATE_H_
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2003-07-15 18:52:32 +00:00
|
|
|
#include "wx/msw/wrapwin.h"
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2001-06-29 10:58:59 +00:00
|
|
|
#ifdef __WXMICROWIN__
|
2001-10-07 22:17:24 +00:00
|
|
|
// Extra prototypes and symbols not defined by MicroWindows
|
|
|
|
#include "wx/msw/microwin.h"
|
2001-06-29 10:58:59 +00:00
|
|
|
#endif
|
|
|
|
|
2002-02-17 23:29:25 +00:00
|
|
|
// Include fixes for MSLU:
|
|
|
|
#include "wx/msw/mslu.h"
|
|
|
|
|
2001-09-28 07:00:13 +00:00
|
|
|
#include "wx/log.h"
|
|
|
|
|
1999-05-13 21:21:04 +00:00
|
|
|
class WXDLLEXPORT wxFont;
|
1999-06-13 22:54:04 +00:00
|
|
|
class WXDLLEXPORT wxWindow;
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-05-19 00:53:27 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// private constants
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Conversion
|
|
|
|
static const double METRIC_CONVERSION_CONSTANT = 0.0393700787;
|
|
|
|
|
|
|
|
// Scaling factors for various unit conversions
|
|
|
|
static const double mm2inches = (METRIC_CONVERSION_CONSTANT);
|
|
|
|
static const double inches2mm = (1/METRIC_CONVERSION_CONSTANT);
|
|
|
|
|
|
|
|
static const double mm2twips = (METRIC_CONVERSION_CONSTANT*1440);
|
|
|
|
static const double twips2mm = (1/(METRIC_CONVERSION_CONSTANT*1440));
|
|
|
|
|
|
|
|
static const double mm2pt = (METRIC_CONVERSION_CONSTANT*72);
|
|
|
|
static const double pt2mm = (1/(METRIC_CONVERSION_CONSTANT*72));
|
|
|
|
|
2004-09-27 10:58:32 +00:00
|
|
|
// 260 was taken from windef.h
|
|
|
|
#ifndef MAX_PATH
|
|
|
|
#define MAX_PATH 260
|
|
|
|
#endif
|
|
|
|
|
1999-05-13 21:21:04 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// standard icons from the resources
|
|
|
|
// ---------------------------------------------------------------------------
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-11-27 22:57:06 +00:00
|
|
|
#if wxUSE_GUI
|
|
|
|
|
1998-05-20 14:12:05 +00:00
|
|
|
WXDLLEXPORT_DATA(extern HICON) wxSTD_FRAME_ICON;
|
|
|
|
WXDLLEXPORT_DATA(extern HICON) wxSTD_MDIPARENTFRAME_ICON;
|
|
|
|
WXDLLEXPORT_DATA(extern HICON) wxSTD_MDICHILDFRAME_ICON;
|
|
|
|
WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_FRAME_ICON;
|
|
|
|
WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_MDIPARENTFRAME_ICON;
|
|
|
|
WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_MDICHILDFRAME_ICON;
|
|
|
|
WXDLLEXPORT_DATA(extern HFONT) wxSTATUS_LINE_FONT;
|
|
|
|
|
1999-11-27 22:57:06 +00:00
|
|
|
#endif // wxUSE_GUI
|
|
|
|
|
1999-05-13 21:21:04 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
1999-11-06 00:43:31 +00:00
|
|
|
// define things missing from some compilers' headers
|
1999-05-13 21:21:04 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
1999-06-08 20:56:50 +00:00
|
|
|
|
2003-07-10 21:14:50 +00:00
|
|
|
#if defined(__WXWINCE__) || (defined(__GNUWIN32__) && !wxUSE_NORLANDER_HEADERS)
|
1999-11-07 18:34:36 +00:00
|
|
|
#ifndef ZeroMemory
|
1999-11-06 00:43:31 +00:00
|
|
|
inline void ZeroMemory(void *buf, size_t len) { memset(buf, 0, len); }
|
1999-11-07 18:34:36 +00:00
|
|
|
#endif
|
1999-11-06 00:43:31 +00:00
|
|
|
#endif // old mingw32
|
|
|
|
|
|
|
|
// this defines a CASTWNDPROC macro which casts a pointer to the type of a
|
|
|
|
// window proc
|
2003-07-10 21:14:50 +00:00
|
|
|
#if defined(STRICT) || defined(__GNUC__)
|
2001-08-25 20:12:58 +00:00
|
|
|
typedef WNDPROC WndProcCast;
|
2000-02-11 13:29:43 +00:00
|
|
|
#else
|
2001-08-25 20:12:58 +00:00
|
|
|
typedef FARPROC WndProcCast;
|
|
|
|
#endif
|
|
|
|
|
2002-12-09 11:01:50 +00:00
|
|
|
|
2001-08-25 20:12:58 +00:00
|
|
|
#define CASTWNDPROC (WndProcCast)
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2003-08-14 11:00:38 +00:00
|
|
|
|
2003-08-14 10:01:49 +00:00
|
|
|
|
1999-05-13 21:21:04 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// some stuff for old Windows versions (FIXME: what does it do here??)
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
1998-10-14 23:53:24 +00:00
|
|
|
#if !defined(APIENTRY) // NT defines APIENTRY, 3.x not
|
1999-05-13 21:21:04 +00:00
|
|
|
#define APIENTRY FAR PASCAL
|
1998-05-20 14:12:05 +00:00
|
|
|
#endif
|
1998-10-14 23:53:24 +00:00
|
|
|
|
1998-05-20 14:12:05 +00:00
|
|
|
#ifdef __WIN32__
|
1999-05-13 21:21:04 +00:00
|
|
|
#define _EXPORT
|
1998-05-20 14:12:05 +00:00
|
|
|
#else
|
1999-05-13 21:21:04 +00:00
|
|
|
#define _EXPORT _export
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __WIN32__
|
|
|
|
typedef signed short int SHORT;
|
1998-05-20 14:12:05 +00:00
|
|
|
#endif
|
1998-10-14 23:53:24 +00:00
|
|
|
|
|
|
|
#if !defined(__WIN32__) // 3.x uses FARPROC for dialogs
|
1999-06-14 07:12:16 +00:00
|
|
|
#ifndef STRICT
|
1999-05-13 21:21:04 +00:00
|
|
|
#define DLGPROC FARPROC
|
1998-05-20 14:12:05 +00:00
|
|
|
#endif
|
1999-06-14 07:12:16 +00:00
|
|
|
#endif
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1998-09-25 13:28:52 +00:00
|
|
|
#if wxUSE_PENWIN
|
1999-05-10 00:42:57 +00:00
|
|
|
WXDLLEXPORT void wxRegisterPenWin();
|
|
|
|
WXDLLEXPORT void wxCleanUpPenWin();
|
|
|
|
WXDLLEXPORT void wxEnablePenAppHooks (bool hook);
|
|
|
|
#endif // wxUSE_PENWIN
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1998-09-25 13:28:52 +00:00
|
|
|
#if wxUSE_ITSY_BITSY
|
1999-05-13 21:21:04 +00:00
|
|
|
#define IBS_HORZCAPTION 0x4000L
|
|
|
|
#define IBS_VERTCAPTION 0x8000L
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-05-13 21:21:04 +00:00
|
|
|
UINT WINAPI ibGetCaptionSize( HWND hWnd ) ;
|
|
|
|
UINT WINAPI ibSetCaptionSize( HWND hWnd, UINT nSize ) ;
|
|
|
|
LRESULT WINAPI ibDefWindowProc( HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam ) ;
|
|
|
|
VOID WINAPI ibAdjustWindowRect( HWND hWnd, LPRECT lprc ) ;
|
|
|
|
#endif // wxUSE_ITSY_BITSY
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-02-02 12:37:14 +00:00
|
|
|
#if wxUSE_CTL3D
|
1999-05-13 21:21:04 +00:00
|
|
|
#include "wx/msw/ctl3d/ctl3d.h"
|
|
|
|
#endif // wxUSE_CTL3D
|
1998-05-20 14:12:05 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Decide what window classes we're going to use
|
|
|
|
* for this combination of CTl3D/FAFA settings
|
|
|
|
*/
|
1998-10-14 23:53:24 +00:00
|
|
|
|
1999-10-08 14:35:56 +00:00
|
|
|
#define STATIC_CLASS wxT("STATIC")
|
1998-05-20 14:12:05 +00:00
|
|
|
#define STATIC_FLAGS (SS_LEFT|WS_CHILD|WS_VISIBLE)
|
1999-10-08 14:35:56 +00:00
|
|
|
#define CHECK_CLASS wxT("BUTTON")
|
1998-05-20 14:12:05 +00:00
|
|
|
#define CHECK_FLAGS (BS_AUTOCHECKBOX|WS_TABSTOP|WS_CHILD)
|
2004-08-31 12:38:46 +00:00
|
|
|
#define CHECK_IS_FAFA FALSE
|
1999-10-08 14:35:56 +00:00
|
|
|
#define RADIO_CLASS wxT("BUTTON")
|
1998-05-20 14:12:05 +00:00
|
|
|
#define RADIO_FLAGS (BS_AUTORADIOBUTTON|WS_CHILD|WS_VISIBLE)
|
|
|
|
#define RADIO_SIZE 20
|
2004-08-31 12:38:46 +00:00
|
|
|
#define RADIO_IS_FAFA FALSE
|
1998-05-20 14:12:05 +00:00
|
|
|
#define PURE_WINDOWS
|
1999-10-08 14:35:56 +00:00
|
|
|
#define GROUP_CLASS wxT("BUTTON")
|
1998-05-20 14:12:05 +00:00
|
|
|
#define GROUP_FLAGS (BS_GROUPBOX|WS_CHILD|WS_VISIBLE)
|
|
|
|
|
|
|
|
/*
|
|
|
|
#define BITCHECK_FLAGS (FB_BITMAP|FC_BUTTONDRAW|FC_DEFAULT|WS_VISIBLE)
|
|
|
|
#define BITRADIO_FLAGS (FC_BUTTONDRAW|FB_BITMAP|FC_RADIO|WS_CHILD|WS_VISIBLE)
|
|
|
|
*/
|
|
|
|
|
1999-05-13 21:21:04 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// misc macros
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
1998-05-20 14:12:05 +00:00
|
|
|
#define MEANING_CHARACTER '0'
|
2000-01-03 18:51:22 +00:00
|
|
|
#define DEFAULT_ITEM_WIDTH 100
|
1998-05-20 14:12:05 +00:00
|
|
|
#define DEFAULT_ITEM_HEIGHT 80
|
1998-09-20 21:13:46 +00:00
|
|
|
|
|
|
|
// Scale font to get edit control height
|
2000-07-15 19:51:35 +00:00
|
|
|
//#define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (3*(cy)/2)
|
|
|
|
#define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (cy+8)
|
1998-05-20 14:12:05 +00:00
|
|
|
|
|
|
|
// Generic subclass proc, for panel item moving/sizing and intercept
|
|
|
|
// EDIT control VK_RETURN messages
|
|
|
|
extern LONG APIENTRY _EXPORT
|
|
|
|
wxSubclassedGenericControlProc(WXHWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
|
|
|
|
|
1999-11-06 00:43:31 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// useful macros and functions
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// a wrapper macro for ZeroMemory()
|
2001-06-29 10:58:59 +00:00
|
|
|
#if defined(__WIN32__) && !defined(__WXMICROWIN__)
|
1999-11-06 00:43:31 +00:00
|
|
|
#define wxZeroMemory(obj) ::ZeroMemory(&obj, sizeof(obj))
|
1999-11-06 17:12:10 +00:00
|
|
|
#else
|
|
|
|
#define wxZeroMemory(obj) memset((void*) & obj, 0, sizeof(obj))
|
|
|
|
#endif
|
1999-11-06 00:43:31 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
#if wxUSE_GUI
|
|
|
|
|
1999-11-07 18:34:36 +00:00
|
|
|
#include <wx/gdicmn.h>
|
2003-02-10 21:07:36 +00:00
|
|
|
#include <wx/colour.h>
|
1999-11-07 18:34:36 +00:00
|
|
|
|
1999-11-06 00:43:31 +00:00
|
|
|
// make conversion from wxColour and COLORREF a bit less painful
|
|
|
|
inline COLORREF wxColourToRGB(const wxColour& c)
|
2002-02-23 21:55:27 +00:00
|
|
|
{
|
|
|
|
return RGB(c.Red(), c.Green(), c.Blue());
|
|
|
|
}
|
|
|
|
|
|
|
|
inline COLORREF wxColourToPalRGB(const wxColour& c)
|
1999-11-06 00:43:31 +00:00
|
|
|
{
|
2001-10-17 22:25:56 +00:00
|
|
|
return PALETTERGB(c.Red(), c.Green(), c.Blue());
|
1999-11-06 00:43:31 +00:00
|
|
|
}
|
|
|
|
|
2002-01-28 01:40:24 +00:00
|
|
|
inline wxColour wxRGBToColour(COLORREF rgb)
|
|
|
|
{
|
|
|
|
return wxColour(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb));
|
|
|
|
}
|
|
|
|
|
1999-11-06 00:43:31 +00:00
|
|
|
inline void wxRGBToColour(wxColour& c, COLORREF rgb)
|
|
|
|
{
|
|
|
|
c.Set(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb));
|
|
|
|
}
|
|
|
|
|
2002-01-13 23:04:11 +00:00
|
|
|
// get the standard colour map for some standard colours - see comment in this
|
|
|
|
// function to understand why is it needed and when should it be used
|
|
|
|
//
|
|
|
|
// it returns a wxCOLORMAP (can't use COLORMAP itself here as comctl32.dll
|
|
|
|
// might be not included/available) array of size wxSTD_COLOUR_MAX
|
|
|
|
//
|
|
|
|
// NB: if you change these colours, update wxBITMAP_STD_COLOURS in the
|
|
|
|
// resources as well: it must have the same number of pixels!
|
|
|
|
enum wxSTD_COLOUR
|
|
|
|
{
|
|
|
|
wxSTD_COL_BTNTEXT,
|
|
|
|
wxSTD_COL_BTNSHADOW,
|
|
|
|
wxSTD_COL_BTNFACE,
|
|
|
|
wxSTD_COL_BTNHIGHLIGHT,
|
2004-10-02 16:12:15 +00:00
|
|
|
wxSTD_COL_MAX
|
2002-01-13 23:04:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct WXDLLEXPORT wxCOLORMAP
|
|
|
|
{
|
|
|
|
COLORREF from, to;
|
|
|
|
};
|
|
|
|
|
|
|
|
// this function is implemented in src/msw/window.cpp
|
|
|
|
extern wxCOLORMAP *wxGetStdColourMap();
|
|
|
|
|
2000-02-05 01:57:38 +00:00
|
|
|
// copy Windows RECT to our wxRect
|
|
|
|
inline void wxCopyRECTToRect(const RECT& r, wxRect& rect)
|
|
|
|
{
|
|
|
|
rect.y = r.top;
|
|
|
|
rect.x = r.left;
|
|
|
|
rect.width = r.right - r.left;
|
|
|
|
rect.height = r.bottom - r.top;
|
|
|
|
}
|
|
|
|
|
2000-01-13 23:39:48 +00:00
|
|
|
// translations between HIMETRIC units (which OLE likes) and pixels (which are
|
|
|
|
// liked by all the others) - implemented in msw/utilsexc.cpp
|
|
|
|
extern void HIMETRICToPixel(LONG *x, LONG *y);
|
|
|
|
extern void PixelToHIMETRIC(LONG *x, LONG *y);
|
|
|
|
|
2004-05-23 14:56:36 +00:00
|
|
|
// Windows convention of the mask is opposed to the wxWidgets one, so we need
|
2000-01-21 21:38:51 +00:00
|
|
|
// to invert the mask each time we pass one/get one to/from Windows
|
|
|
|
extern HBITMAP wxInvertMask(HBITMAP hbmpMask, int w = 0, int h = 0);
|
|
|
|
|
2003-03-22 23:47:06 +00:00
|
|
|
// Creates an icon or cursor depending from a bitmap
|
|
|
|
//
|
|
|
|
// The bitmap must be valid and it should have a mask. If it doesn't, a default
|
|
|
|
// mask is created using light grey as the transparent colour.
|
|
|
|
extern HICON wxBitmapToHICON(const wxBitmap& bmp);
|
|
|
|
|
|
|
|
// Same requirments as above apply and the bitmap must also have the correct
|
|
|
|
// size.
|
|
|
|
extern
|
|
|
|
HCURSOR wxBitmapToHCURSOR(const wxBitmap& bmp, int hotSpotX, int hotSpotY);
|
|
|
|
|
2000-01-23 23:23:46 +00:00
|
|
|
// get (x, y) from DWORD - notice that HI/LOWORD can *not* be used because they
|
|
|
|
// will fail on system with multiple monitors where the coords may be negative
|
|
|
|
//
|
|
|
|
// these macros are standard now (Win98) but some older headers don't have them
|
|
|
|
#ifndef GET_X_LPARAM
|
|
|
|
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
|
|
|
|
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
|
|
|
|
#endif // GET_X_LPARAM
|
|
|
|
|
2000-03-02 00:58:11 +00:00
|
|
|
// get the current state of SHIFT/CTRL keys
|
2000-03-04 22:54:41 +00:00
|
|
|
inline bool wxIsShiftDown()
|
2000-03-02 00:58:11 +00:00
|
|
|
{
|
2003-05-21 18:43:03 +00:00
|
|
|
// return (::GetKeyState(VK_SHIFT) & 0x100) != 0;
|
|
|
|
// Returns different negative values on WinME and WinNT,
|
|
|
|
// so simply test for negative value.
|
|
|
|
return ::GetKeyState(VK_SHIFT) < 0;
|
2000-03-02 00:58:11 +00:00
|
|
|
}
|
|
|
|
|
2000-03-04 22:54:41 +00:00
|
|
|
inline bool wxIsCtrlDown()
|
2000-03-02 00:58:11 +00:00
|
|
|
{
|
2003-05-21 18:43:03 +00:00
|
|
|
// return (::GetKeyState(VK_CONTROL) & 0x100) != 0;
|
|
|
|
// Returns different negative values on WinME and WinNT,
|
|
|
|
// so simply test for negative value.
|
|
|
|
return ::GetKeyState(VK_CONTROL) < 0;
|
2000-03-02 00:58:11 +00:00
|
|
|
}
|
|
|
|
|
2001-09-24 00:34:14 +00:00
|
|
|
// wrapper around GetWindowRect() and GetClientRect() APIs doing error checking
|
|
|
|
// for Win32
|
|
|
|
inline RECT wxGetWindowRect(HWND hwnd)
|
|
|
|
{
|
|
|
|
RECT rect;
|
2004-03-28 13:10:14 +00:00
|
|
|
|
2001-09-24 00:34:14 +00:00
|
|
|
if ( !::GetWindowRect(hwnd, &rect) )
|
|
|
|
{
|
|
|
|
wxLogLastError(_T("GetWindowRect"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline RECT wxGetClientRect(HWND hwnd)
|
|
|
|
{
|
|
|
|
RECT rect;
|
2004-03-28 13:10:14 +00:00
|
|
|
|
2001-09-24 00:34:14 +00:00
|
|
|
if ( !::GetClientRect(hwnd, &rect) )
|
|
|
|
{
|
|
|
|
wxLogLastError(_T("GetClientRect"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
1999-11-24 12:30:56 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// small helper classes
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2003-05-11 22:43:28 +00:00
|
|
|
// a template to make initializing Windows styructs less painful: it zeroes all
|
|
|
|
// the struct fields and also sets cbSize member to the correct value (and so
|
|
|
|
// can be only used with structures which have this member...)
|
|
|
|
template <class T>
|
|
|
|
struct WinStruct : public T
|
|
|
|
{
|
|
|
|
WinStruct()
|
|
|
|
{
|
2003-05-11 23:25:14 +00:00
|
|
|
::ZeroMemory(this, sizeof(T));
|
2004-06-09 22:01:54 +00:00
|
|
|
|
|
|
|
// explicit qualification is required here for this to be valid C++
|
2004-05-31 21:50:16 +00:00
|
|
|
this->cbSize = sizeof(T);
|
2003-05-11 22:43:28 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-11-24 12:30:56 +00:00
|
|
|
// create an instance of this class and use it as the HDC for screen, will
|
|
|
|
// automatically release the DC going out of scope
|
|
|
|
class ScreenHDC
|
|
|
|
{
|
|
|
|
public:
|
2001-12-30 22:35:14 +00:00
|
|
|
ScreenHDC() { m_hdc = ::GetDC(NULL); }
|
|
|
|
~ScreenHDC() { ::ReleaseDC(NULL, m_hdc); }
|
|
|
|
|
|
|
|
operator HDC() const { return m_hdc; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
HDC m_hdc;
|
2003-01-02 23:38:11 +00:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(ScreenHDC)
|
2001-12-30 22:35:14 +00:00
|
|
|
};
|
|
|
|
|
2004-06-30 15:44:11 +00:00
|
|
|
// the same as ScreenHDC but for window DCs
|
|
|
|
class WindowHDC
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WindowHDC(HWND hwnd) { m_hdc = ::GetDC(m_hwnd = hwnd); }
|
|
|
|
~WindowHDC() { ::ReleaseDC(m_hwnd, m_hdc); }
|
|
|
|
|
|
|
|
operator HDC() const { return m_hdc; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
HWND m_hwnd;
|
|
|
|
HDC m_hdc;
|
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(WindowHDC)
|
|
|
|
};
|
|
|
|
|
2003-03-24 22:32:56 +00:00
|
|
|
// the same as ScreenHDC but for memory DCs: creates the HDC compatible with
|
|
|
|
// the given one (screen by default) in ctor and destroys it in dtor
|
2001-12-30 22:35:14 +00:00
|
|
|
class MemoryHDC
|
|
|
|
{
|
|
|
|
public:
|
2003-03-24 22:48:54 +00:00
|
|
|
MemoryHDC(HDC hdc = 0) { m_hdc = ::CreateCompatibleDC(hdc); }
|
2003-03-24 22:32:56 +00:00
|
|
|
~MemoryHDC() { ::DeleteDC(m_hdc); }
|
2001-12-30 22:35:14 +00:00
|
|
|
|
|
|
|
operator HDC() const { return m_hdc; }
|
1999-11-24 12:30:56 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
HDC m_hdc;
|
2003-01-02 23:38:11 +00:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(MemoryHDC)
|
1999-11-24 12:30:56 +00:00
|
|
|
};
|
|
|
|
|
2001-12-30 22:35:14 +00:00
|
|
|
// a class which selects a GDI object into a DC in its ctor and deselects in
|
|
|
|
// dtor
|
|
|
|
class SelectInHDC
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SelectInHDC(HDC hdc, HGDIOBJ hgdiobj) : m_hdc(hdc)
|
|
|
|
{ m_hgdiobj = ::SelectObject(hdc, hgdiobj); }
|
|
|
|
|
|
|
|
~SelectInHDC() { ::SelectObject(m_hdc, m_hgdiobj); }
|
|
|
|
|
|
|
|
// return true if the object was successfully selected
|
|
|
|
operator bool() const { return m_hgdiobj != 0; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
HDC m_hdc;
|
|
|
|
HGDIOBJ m_hgdiobj;
|
2003-01-02 23:38:11 +00:00
|
|
|
|
2003-03-23 20:36:51 +00:00
|
|
|
DECLARE_NO_COPY_CLASS(SelectInHDC)
|
|
|
|
};
|
|
|
|
|
2004-11-19 16:47:51 +00:00
|
|
|
// a class for temporary bitmaps
|
|
|
|
class CompatibleBitmap
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CompatibleBitmap(HDC hdc, int w, int h)
|
|
|
|
{
|
|
|
|
m_hbmp = ::CreateCompatibleBitmap(hdc, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
~CompatibleBitmap()
|
|
|
|
{
|
|
|
|
if ( m_hbmp )
|
|
|
|
::DeleteObject(m_hbmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
operator HBITMAP() const { return m_hbmp; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
HBITMAP m_hbmp;
|
|
|
|
};
|
|
|
|
|
2003-03-23 20:36:51 +00:00
|
|
|
// when working with global pointers (which is unfortunately still necessary
|
|
|
|
// sometimes, e.g. for clipboard) it is important to unlock them exactly as
|
|
|
|
// many times as we lock them which just asks for using a "smart lock" class
|
2003-04-13 21:58:59 +00:00
|
|
|
class GlobalPtr
|
2003-03-23 20:36:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2003-04-13 21:58:59 +00:00
|
|
|
GlobalPtr(HGLOBAL hGlobal) : m_hGlobal(hGlobal)
|
2003-03-23 20:36:51 +00:00
|
|
|
{
|
2004-04-04 13:02:56 +00:00
|
|
|
m_ptr = GlobalLock(hGlobal);
|
2003-03-23 20:36:51 +00:00
|
|
|
if ( !m_ptr )
|
|
|
|
{
|
|
|
|
wxLogLastError(_T("GlobalLock"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-13 21:58:59 +00:00
|
|
|
~GlobalPtr()
|
2003-03-23 20:36:51 +00:00
|
|
|
{
|
2004-04-04 13:02:56 +00:00
|
|
|
if ( !GlobalUnlock(m_hGlobal) )
|
2003-03-23 20:36:51 +00:00
|
|
|
{
|
|
|
|
#ifdef __WXDEBUG__
|
|
|
|
// this might happen simply because the block became unlocked
|
|
|
|
DWORD dwLastError = ::GetLastError();
|
|
|
|
if ( dwLastError != NO_ERROR )
|
|
|
|
{
|
|
|
|
wxLogApiError(_T("GlobalUnlock"), dwLastError);
|
|
|
|
}
|
|
|
|
#endif // __WXDEBUG__
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
operator void *() const { return m_ptr; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
HGLOBAL m_hGlobal;
|
|
|
|
void *m_ptr;
|
|
|
|
|
2003-04-13 21:58:59 +00:00
|
|
|
DECLARE_NO_COPY_CLASS(GlobalPtr)
|
2001-12-30 22:35:14 +00:00
|
|
|
};
|
|
|
|
|
1999-05-13 21:21:04 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
1999-05-19 00:53:27 +00:00
|
|
|
// macros to make casting between WXFOO and FOO a bit easier: the GetFoo()
|
1999-06-28 21:39:49 +00:00
|
|
|
// returns Foo cast to the Windows type for oruselves, while GetFooOf() takes
|
|
|
|
// an argument which should be a pointer or reference to the object of the
|
|
|
|
// corresponding class (this depends on the macro)
|
1999-05-13 21:21:04 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#define GetHwnd() ((HWND)GetHWND())
|
1999-06-28 21:39:49 +00:00
|
|
|
#define GetHwndOf(win) ((HWND)((win)->GetHWND()))
|
|
|
|
// old name
|
|
|
|
#define GetWinHwnd GetHwndOf
|
1999-05-13 21:21:04 +00:00
|
|
|
|
|
|
|
#define GetHdc() ((HDC)GetHDC())
|
1999-06-28 21:39:49 +00:00
|
|
|
#define GetHdcOf(dc) ((HDC)(dc).GetHDC())
|
1999-05-13 21:21:04 +00:00
|
|
|
|
1999-11-06 00:43:31 +00:00
|
|
|
#define GetHbitmap() ((HBITMAP)GetHBITMAP())
|
|
|
|
#define GetHbitmapOf(bmp) ((HBITMAP)(bmp).GetHBITMAP())
|
|
|
|
|
1999-05-19 00:53:27 +00:00
|
|
|
#define GetHicon() ((HICON)GetHICON())
|
1999-06-28 21:39:49 +00:00
|
|
|
#define GetHiconOf(icon) ((HICON)(icon).GetHICON())
|
1999-05-19 00:53:27 +00:00
|
|
|
|
1999-05-13 21:21:04 +00:00
|
|
|
#define GetHaccel() ((HACCEL)GetHACCEL())
|
1999-06-28 21:39:49 +00:00
|
|
|
#define GetHaccelOf(table) ((HACCEL)((table).GetHACCEL()))
|
|
|
|
|
2004-02-08 14:27:56 +00:00
|
|
|
#define GetHbrush() ((HPEN)GetResourceHandle())
|
|
|
|
#define GetHbrushOf(brush) ((HPEN)(brush).GetResourceHandle())
|
|
|
|
|
1999-06-28 21:39:49 +00:00
|
|
|
#define GetHmenu() ((HMENU)GetHMenu())
|
|
|
|
#define GetHmenuOf(menu) ((HMENU)menu->GetHMenu())
|
1999-05-13 21:21:04 +00:00
|
|
|
|
2000-02-25 23:49:41 +00:00
|
|
|
#define GetHcursor() ((HCURSOR)GetHCURSOR())
|
|
|
|
#define GetHcursorOf(cursor) ((HCURSOR)(cursor).GetHCURSOR())
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
#define GetHfont() ((HFONT)GetHFONT())
|
|
|
|
#define GetHfontOf(font) ((HFONT)(font).GetHFONT())
|
|
|
|
|
2001-11-25 00:21:19 +00:00
|
|
|
#define GetHpalette() ((HPALETTE)GetHPALETTE())
|
2002-02-08 00:18:10 +00:00
|
|
|
#define GetHpaletteOf(pal) ((HPALETTE)(pal).GetHPALETTE())
|
2001-11-25 00:21:19 +00:00
|
|
|
|
2004-02-08 13:54:43 +00:00
|
|
|
#define GetHpen() ((HPEN)GetResourceHandle())
|
|
|
|
#define GetHpenOf(pen) ((HPEN)(pen).GetResourceHandle())
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
#define GetHrgn() ((HRGN)GetHRGN())
|
|
|
|
#define GetHrgnOf(rgn) ((HRGN)(rgn).GetHRGN())
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
#endif // wxUSE_GUI
|
|
|
|
|
1999-05-13 21:21:04 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// global data
|
|
|
|
// ---------------------------------------------------------------------------
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_DATA_BASE(extern HINSTANCE) wxhInstance;
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-05-13 21:21:04 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// global functions
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
1999-09-17 22:24:28 +00:00
|
|
|
extern "C"
|
|
|
|
{
|
2003-07-04 13:00:07 +00:00
|
|
|
WXDLLIMPEXP_BASE HINSTANCE wxGetInstance();
|
1999-09-17 22:24:28 +00:00
|
|
|
}
|
|
|
|
|
2003-07-04 13:00:07 +00:00
|
|
|
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
|
1999-05-13 21:21:04 +00:00
|
|
|
|
2004-09-27 10:58:32 +00:00
|
|
|
// return the full name of the program file
|
|
|
|
inline wxString wxGetFullModuleName()
|
|
|
|
{
|
|
|
|
wxString fullname;
|
|
|
|
if ( !::GetModuleFileName
|
|
|
|
(
|
|
|
|
(HMODULE)wxGetInstance(),
|
|
|
|
wxStringBuffer(fullname, MAX_PATH),
|
|
|
|
MAX_PATH
|
|
|
|
) )
|
|
|
|
{
|
|
|
|
wxLogLastError(_T("GetModuleFileName"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return fullname;
|
|
|
|
}
|
|
|
|
|
1999-11-27 22:57:06 +00:00
|
|
|
#if wxUSE_GUI
|
|
|
|
|
2000-02-25 23:49:41 +00:00
|
|
|
// cursor stuff
|
|
|
|
extern HCURSOR wxGetCurrentBusyCursor(); // from msw/utils.cpp
|
|
|
|
extern const wxCursor *wxGetGlobalCursor(); // from msw/cursor.cpp
|
|
|
|
|
2004-06-24 14:25:47 +00:00
|
|
|
WXDLLEXPORT void wxGetCharSize(WXHWND wnd, int *x, int *y, const wxFont& the_font);
|
1999-11-06 00:43:31 +00:00
|
|
|
WXDLLEXPORT void wxFillLogFont(LOGFONT *logFont, const wxFont *font);
|
|
|
|
WXDLLEXPORT wxFont wxCreateFontFromLogFont(const LOGFONT *logFont);
|
2000-07-15 19:51:35 +00:00
|
|
|
WXDLLEXPORT wxFontEncoding wxGetFontEncFromCharSet(int charset);
|
1999-05-13 21:21:04 +00:00
|
|
|
|
|
|
|
WXDLLEXPORT void wxSliderEvent(WXHWND control, WXWORD wParam, WXWORD pos);
|
|
|
|
WXDLLEXPORT void wxScrollBarEvent(WXHWND hbar, WXWORD wParam, WXWORD pos);
|
|
|
|
|
|
|
|
// Find maximum size of window/rectangle
|
|
|
|
WXDLLEXPORT extern void wxFindMaxSize(WXHWND hwnd, RECT *rect);
|
|
|
|
|
1998-09-20 21:13:46 +00:00
|
|
|
// Safely get the window text (i.e. without using fixed size buffer)
|
1998-11-22 22:32:53 +00:00
|
|
|
WXDLLEXPORT extern wxString wxGetWindowText(WXHWND hWnd);
|
1998-09-20 21:13:46 +00:00
|
|
|
|
1999-05-10 00:42:57 +00:00
|
|
|
// get the window class name
|
|
|
|
WXDLLEXPORT extern wxString wxGetWindowClass(WXHWND hWnd);
|
|
|
|
|
1999-05-19 00:53:27 +00:00
|
|
|
// get the window id (should be unsigned, hence this is not wxWindowID which
|
|
|
|
// is, for mainly historical reasons, signed)
|
|
|
|
WXDLLEXPORT extern WXWORD wxGetWindowId(WXHWND hWnd);
|
1999-05-10 00:42:57 +00:00
|
|
|
|
2002-09-02 00:32:30 +00:00
|
|
|
// check if hWnd's WNDPROC is wndProc. Return true if yes, false if they are
|
|
|
|
// different
|
|
|
|
WXDLLEXPORT extern bool wxCheckWindowWndProc(WXHWND hWnd, WXFARPROC wndProc);
|
2001-12-17 00:28:31 +00:00
|
|
|
|
1998-10-14 23:53:24 +00:00
|
|
|
// Does this window style specify any border?
|
1998-11-22 22:32:53 +00:00
|
|
|
inline bool wxStyleHasBorder(long style)
|
1998-10-14 23:53:24 +00:00
|
|
|
{
|
2001-09-24 00:34:14 +00:00
|
|
|
return (style & (wxSIMPLE_BORDER | wxRAISED_BORDER |
|
|
|
|
wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0;
|
1998-10-14 23:53:24 +00:00
|
|
|
}
|
|
|
|
|
2002-09-02 00:32:30 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// functions mapping HWND to wxWindow
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// this function simply checks whether the given hWnd corresponds to a wxWindow
|
|
|
|
// and returns either that window if it does or NULL otherwise
|
|
|
|
WXDLLEXPORT extern wxWindow* wxFindWinFromHandle(WXHWND hWnd);
|
|
|
|
|
|
|
|
// find the window for HWND which is part of some wxWindow, i.e. unlike
|
|
|
|
// wxFindWinFromHandle() above it will also work for "sub controls" of a
|
|
|
|
// wxWindow.
|
2000-01-23 23:23:46 +00:00
|
|
|
//
|
2002-09-02 00:32:30 +00:00
|
|
|
// returns the wxWindow corresponding to the given HWND or NULL.
|
|
|
|
WXDLLEXPORT extern wxWindow *wxGetWindowFromHWND(WXHWND hwnd);
|
2000-01-23 23:23:46 +00:00
|
|
|
|
2002-07-15 18:29:52 +00:00
|
|
|
// Get the size of an icon
|
2002-09-02 00:32:30 +00:00
|
|
|
WXDLLEXPORT extern wxSize wxGetHiconSize(HICON hicon);
|
2002-07-15 18:29:52 +00:00
|
|
|
|
2003-07-11 21:43:57 +00:00
|
|
|
// Lines are drawn differently for WinCE and regular WIN32
|
|
|
|
WXDLLEXPORT void wxDrawLine(HDC hdc, int x1, int y1, int x2, int y2);
|
|
|
|
|
2004-02-10 12:56:25 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// 32/64 bit helpers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifdef __WIN64__
|
|
|
|
|
|
|
|
inline void *wxGetWindowProc(HWND hwnd)
|
|
|
|
{
|
|
|
|
return (void *)::GetWindowLongPtr(hwnd, GWLP_WNDPROC);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void *wxGetWindowUserData(HWND hwnd)
|
|
|
|
{
|
|
|
|
return (void *)::GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline WNDPROC wxSetWindowProc(HWND hwnd, WNDPROC func)
|
|
|
|
{
|
|
|
|
return (WNDPROC)::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)func);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void *wxSetWindowUserData(HWND hwnd, void *data)
|
|
|
|
{
|
|
|
|
return (void *)::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else // __WIN32__
|
|
|
|
|
2004-09-28 21:16:57 +00:00
|
|
|
#ifdef __VISUALC__
|
|
|
|
// strangely enough, VC++ 7.1 gives warnings about 32 -> 64 bit conversions
|
|
|
|
// in the functions below, even in spite of the explicit casts
|
|
|
|
#pragma warning(disable:4311)
|
|
|
|
#pragma warning(disable:4312)
|
|
|
|
#endif
|
|
|
|
|
2004-02-10 12:56:25 +00:00
|
|
|
inline void *wxGetWindowProc(HWND hwnd)
|
|
|
|
{
|
|
|
|
return (void *)::GetWindowLong(hwnd, GWL_WNDPROC);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void *wxGetWindowUserData(HWND hwnd)
|
|
|
|
{
|
|
|
|
return (void *)::GetWindowLong(hwnd, GWL_USERDATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline WNDPROC wxSetWindowProc(HWND hwnd, WNDPROC func)
|
|
|
|
{
|
|
|
|
return (WNDPROC)::SetWindowLong(hwnd, GWL_WNDPROC, (LONG)func);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void *wxSetWindowUserData(HWND hwnd, void *data)
|
|
|
|
{
|
|
|
|
return (void *)::SetWindowLong(hwnd, GWL_USERDATA, (LONG)data);
|
|
|
|
}
|
|
|
|
|
2004-09-28 21:16:57 +00:00
|
|
|
#ifdef __VISUALC__
|
|
|
|
#pragma warning(default:4311)
|
|
|
|
#pragma warning(default:4312)
|
|
|
|
#endif
|
|
|
|
|
2004-02-10 12:56:25 +00:00
|
|
|
#endif // __WIN64__/__WIN32__
|
|
|
|
|
1999-11-27 22:57:06 +00:00
|
|
|
#endif // wxUSE_GUI
|
|
|
|
|
1998-05-20 14:12:05 +00:00
|
|
|
#endif
|
1998-08-07 23:52:45 +00:00
|
|
|
// _WX_PRIVATE_H_
|