minor changes a bit everywhere + a small wxLog change (Enable()/IsEnabled()

added) + wxTimer member vars are made protected again (but a friend decl
added for the callback)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@831 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1998-10-14 23:53:24 +00:00
parent 2d0a075d90
commit c085e33398
22 changed files with 457 additions and 543 deletions

View File

@@ -75,13 +75,20 @@ public:
// ctor // ctor
wxLog(); wxLog();
// these functions allow to completely disable all log messages
// is logging disabled now?
static bool IsEnabled() { return ms_doLog; }
// change the flag state, return the previous one
static bool EnableLogging(bool doIt = TRUE)
{ bool doLogOld = ms_doLog; ms_doLog = doIt; return doLogOld; }
// sink function // sink function
static void OnLog(wxLogLevel level, const char *szString) static void OnLog(wxLogLevel level, const char *szString)
{ {
wxLog *pLogger = GetActiveTarget(); if ( IsEnabled() ) {
if ( pLogger ) wxLog *pLogger = GetActiveTarget();
{ if ( pLogger )
pLogger->DoLog(level, szString); pLogger->DoLog(level, szString);
} }
} }
@@ -99,10 +106,8 @@ public:
// get current log target, will call wxApp::CreateLogTarget() to create one // get current log target, will call wxApp::CreateLogTarget() to create one
// if none exists // if none exists
static wxLog *GetActiveTarget(); static wxLog *GetActiveTarget();
// change log target, pLogger = NULL disables logging. if bNoFlashOld is true, // change log target, pLogger may be NULL
// the old log target isn't flashed which might lead to loss of messages! static wxLog *SetActiveTarget(wxLog *pLogger);
// returns the previous log target
static wxLog *SetActiveTarget(wxLog *pLogger, bool bNoFlashOld = FALSE);
// functions controlling the default wxLog behaviour // functions controlling the default wxLog behaviour
// verbose mode is activated by standard command-line '-verbose' option // verbose mode is activated by standard command-line '-verbose' option
@@ -151,6 +156,7 @@ private:
// static variables // static variables
// ---------------- // ----------------
static wxLog *ms_pLogger; // currently active log sink static wxLog *ms_pLogger; // currently active log sink
static bool ms_doLog; // FALSE => all logging disabled
static bool ms_bAutoCreate; // automatically create new log targets? static bool ms_bAutoCreate; // automatically create new log targets?
static wxTraceMask ms_ulTraceMask; // controls wxLogTrace behaviour static wxTraceMask ms_ulTraceMask; // controls wxLogTrace behaviour
}; };
@@ -293,12 +299,11 @@ void Foo() {
class WXDLLEXPORT wxLogNull class WXDLLEXPORT wxLogNull
{ {
public: public:
// ctor saves old log target, dtor restores it wxLogNull() { m_flagOld = wxLog::EnableLogging(FALSE); }
wxLogNull() { m_pPrevLogger = wxLog::SetActiveTarget((wxLog *)NULL, TRUE); } ~wxLogNull() { (void)wxLog::EnableLogging(m_flagOld); }
~wxLogNull() { (void)wxLog::SetActiveTarget(m_pPrevLogger); }
private: private:
wxLog *m_pPrevLogger; // old log target bool m_flagOld; // the previous value of the wxLog::ms_doLog
}; };
// ============================================================================ // ============================================================================

View File

@@ -57,7 +57,7 @@ class WXDLLEXPORT wxApp: public wxEvtHandler
void OnEndSession(wxCloseEvent& event); void OnEndSession(wxCloseEvent& event);
void OnQueryEndSession(wxCloseEvent& event); void OnQueryEndSession(wxCloseEvent& event);
// Generic // Generic
virtual bool OnInit() { return FALSE; }; virtual bool OnInit() { return FALSE; };
// No specific tasks to do here. // No specific tasks to do here.
@@ -67,6 +67,10 @@ class WXDLLEXPORT wxApp: public wxEvtHandler
virtual int OnRun() { return MainLoop(); }; virtual int OnRun() { return MainLoop(); };
virtual int OnExit() { return 0; } virtual int OnExit() { return 0; }
// called when a fatal exception occurs, this function should take care not
// to do anything which might provoke a nested exception!
virtual void OnFatalException() { }
inline void SetPrintMode(int mode) { m_printMode = mode; } inline void SetPrintMode(int mode) { m_printMode = mode; }
inline int GetPrintMode() const { return m_printMode; } inline int GetPrintMode() const { return m_printMode; }

View File

@@ -6,7 +6,7 @@
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PRIVATE_H_ #ifndef _WX_PRIVATE_H_
@@ -52,18 +52,18 @@ wxFont WXDLLEXPORT wxCreateFontFromLogFont(LOGFONT *logFont); // , bool createNe
# endif # endif
#endif #endif
#if !defined(APIENTRY) // NT defines APIENTRY, 3.x not #if !defined(APIENTRY) // NT defines APIENTRY, 3.x not
#define APIENTRY FAR PASCAL #define APIENTRY FAR PASCAL
#endif #endif
#ifdef __WIN32__ #ifdef __WIN32__
#define _EXPORT /**/ #define _EXPORT /**/
#else #else
#define _EXPORT _export #define _EXPORT _export
typedef signed short int SHORT ; typedef signed short int SHORT ;
#endif #endif
#if !defined(__WIN32__) // 3.x uses FARPROC for dialogs #if !defined(__WIN32__) // 3.x uses FARPROC for dialogs
#define DLGPROC FARPROC #define DLGPROC FARPROC
#endif #endif
@@ -104,7 +104,7 @@ VOID WINAPI ibAdjustWindowRect( HWND hWnd, LPRECT lprc ) ;
* Decide what window classes we're going to use * Decide what window classes we're going to use
* for this combination of CTl3D/FAFA settings * for this combination of CTl3D/FAFA settings
*/ */
#define STATIC_CLASS "STATIC" #define STATIC_CLASS "STATIC"
#define STATIC_FLAGS (SS_LEFT|WS_CHILD|WS_VISIBLE) #define STATIC_FLAGS (SS_LEFT|WS_CHILD|WS_VISIBLE)
#define CHECK_CLASS "BUTTON" #define CHECK_CLASS "BUTTON"
@@ -151,8 +151,15 @@ void WXDLLEXPORT wxAddControlHandle(WXHWND hWnd, wxWindow *item);
// Safely get the window text (i.e. without using fixed size buffer) // Safely get the window text (i.e. without using fixed size buffer)
extern wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd); extern wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd);
// Does this window style specify any border?
inline bool WXDLLEXPORT wxStyleHasBorder(long style)
{
return (style & (wxSIMPLE_BORDER | wxRAISED_BORDER |
wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0;
}
#if !defined(__WIN32__) && !defined(WS_EX_CLIENTEDGE) #if !defined(__WIN32__) && !defined(WS_EX_CLIENTEDGE)
#define WS_EX_CLIENTEDGE 0 #define WS_EX_CLIENTEDGE 0
#endif #endif
#endif #endif

View File

@@ -203,40 +203,12 @@ private:
wxRegKey(const wxRegKey& key); // not implemented wxRegKey(const wxRegKey& key); // not implemented
wxRegKey& operator=(const wxRegKey& key); // not implemented wxRegKey& operator=(const wxRegKey& key); // not implemented
WXHKEY m_hKey, // our handle WXHKEY m_hKey, // our handle
m_hRootKey; // handle of the top key (i.e. StdKey) m_hRootKey; // handle of the top key (i.e. StdKey)
wxString m_strKey; // key name (relative to m_hRootKey) wxString m_strKey; // key name (relative to m_hRootKey)
MUTABLE long m_dwLastError; // last error (0 if none) MUTABLE long m_dwLastError; // last error (0 if none)
}; };
// ----------------------------------------------------------------------------
// high level functions working with the registry
// ----------------------------------------------------------------------------
// file extensions and MIME types
// ------------------------------
// Look for and return the extension (with leading '.') which corresponds to
// MIME type strMimeType in pExt.
//
// Return value: true if MIME type was found, false otherwise
bool GetExtensionFromMimeType(wxString *pExt, const wxString& strMimeType);
// Look for MIME type of the given extension, return TRUE if found.
bool GetMimeTypeFromExtension(wxString *pMimeType, const wxString& strExt);
// Get file type from extension (it's not the same thing: for example, for
// the extension .txt the default file type is txtfile), return FALSE if not
// found.
bool GetFileTypeFromExtension(wxString *pFileType, const wxString& strExt);
// Get the default icon from file type
class wxIcon;
bool GetFileTypeIcon(wxIcon *pIcon, const wxString& strFileType);
// Get the description of files of this type
bool GetFileTypeDescription(wxString *pDesc, const wxString& strFileType);
#endif //_REGISTRY_H #endif //_REGISTRY_H

View File

@@ -79,7 +79,7 @@
#define wxUSE_SCROLLBAR 1 #define wxUSE_SCROLLBAR 1
// Define 1 to compile contributed wxScrollBar class // Define 1 to compile contributed wxScrollBar class
#define wxUSE_XPM_IN_X 1 #define wxUSE_XPM_IN_X 1
#define wxUSE_XPM_IN_MSW 0 #define wxUSE_XPM_IN_MSW 1
// Define 1 to support the XPM package in wxBitmap, // Define 1 to support the XPM package in wxBitmap,
// separated by platform. If 1, you must link in // separated by platform. If 1, you must link in
// the XPM library to your applications. // the XPM library to your applications.
@@ -90,7 +90,7 @@
#define wxUSE_IMAGE_LOADING_IN_MSW 1 #define wxUSE_IMAGE_LOADING_IN_MSW 1
// Use dynamic DIB loading/saving code in utils/dib under MSW. // Use dynamic DIB loading/saving code in utils/dib under MSW.
#define wxUSE_RESOURCE_LOADING_IN_MSW 0 #define wxUSE_RESOURCE_LOADING_IN_MSW 1
// Use dynamic icon/cursor loading/saving code // Use dynamic icon/cursor loading/saving code
// under MSW. // under MSW.
#define wxUSE_WX_RESOURCES 1 #define wxUSE_WX_RESOURCES 1
@@ -114,12 +114,12 @@
#define wxUSE_DYNAMIC_CLASSES 1 #define wxUSE_DYNAMIC_CLASSES 1
// If 1, enables provision of run-time type information. // If 1, enables provision of run-time type information.
// NOW MANDATORY: don't change. // NOW MANDATORY: don't change.
#define wxUSE_MEMORY_TRACING 1 #define wxUSE_MEMORY_TRACING 0
// If 1, enables debugging versions of wxObject::new and // If 1, enables debugging versions of wxObject::new and
// wxObject::delete *IF* WXDEBUG is also defined. // wxObject::delete *IF* WXDEBUG is also defined.
// WARNING: this code may not work with all architectures, especially // WARNING: this code may not work with all architectures, especially
// if alignment is an issue. // if alignment is an issue.
#define wxUSE_DEBUG_CONTEXT 1 #define wxUSE_DEBUG_CONTEXT 0
// If 1, enables wxDebugContext, for // If 1, enables wxDebugContext, for
// writing error messages to file, etc. // writing error messages to file, etc.
// If WXDEBUG is not defined, will still use // If WXDEBUG is not defined, will still use
@@ -128,7 +128,7 @@
// since you may well need to output // since you may well need to output
// an error log in a production // an error log in a production
// version (or non-debugging beta) // version (or non-debugging beta)
#define wxUSE_GLOBAL_MEMORY_OPERATORS 1 #define wxUSE_GLOBAL_MEMORY_OPERATORS 0
// In debug mode, cause new and delete to be redefined globally. // In debug mode, cause new and delete to be redefined globally.
// If this causes problems (e.g. link errors), set this to 0. // If this causes problems (e.g. link errors), set this to 0.
@@ -139,7 +139,7 @@
#define wxUSE_C_MAIN 0 #define wxUSE_C_MAIN 0
// Set to 1 to use main.c instead of main.cpp (UNIX only) // Set to 1 to use main.c instead of main.cpp (UNIX only)
#define wxUSE_ODBC 1 #define wxUSE_ODBC 0
// Define 1 to use ODBC classes // Define 1 to use ODBC classes
#define wxUSE_IOSTREAMH 1 #define wxUSE_IOSTREAMH 1
@@ -199,7 +199,7 @@
#define wxUSE_PENWINDOWS 0 #define wxUSE_PENWINDOWS 0
// Set to 1 to use PenWindows // Set to 1 to use PenWindows
#define wxUSE_OWNER_DRAWN 0 #define wxUSE_OWNER_DRAWN 1
// Owner-drawn menus and listboxes // Owner-drawn menus and listboxes
#define wxUSE_NATIVE_STATUSBAR 1 #define wxUSE_NATIVE_STATUSBAR 1

View File

@@ -20,6 +20,8 @@
class WXDLLEXPORT wxTimer : public wxObject class WXDLLEXPORT wxTimer : public wxObject
{ {
friend void wxProcessTimer(wxTimer& timer);
public: public:
wxTimer(); wxTimer();
~wxTimer(); ~wxTimer();
@@ -34,7 +36,7 @@ public:
int Interval() const { return milli; }; int Interval() const { return milli; };
bool OneShot() const { return oneShot; } bool OneShot() const { return oneShot; }
public: protected:
bool oneShot ; bool oneShot ;
int milli ; int milli ;
int lastMilli ; int lastMilli ;

View File

@@ -96,9 +96,9 @@ WXCURSOR_BLANK CURSOR DISCARDABLE "wx/msw/blank.cur"
// Default Icons // Default Icons
// //
wxDEFAULT_FRAME ICON "wx/msw/std.ico" //wxDEFAULT_FRAME ICON "wx/msw/std.ico"
wxDEFAULT_MDIPARENTFRAME ICON "wx/msw/mdi.ico" //wxDEFAULT_MDIPARENTFRAME ICON "wx/msw/mdi.ico"
wxDEFAULT_MDICHILDFRAME ICON "wx/msw/child.ico" //wxDEFAULT_MDICHILDFRAME ICON "wx/msw/child.ico"
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// //

View File

@@ -258,6 +258,8 @@ wxLog *wxLog::GetActiveTarget()
ms_pLogger = wxTheApp->CreateLogTarget(); ms_pLogger = wxTheApp->CreateLogTarget();
#endif #endif
s_bInGetActiveTarget = FALSE;
// do nothing if it fails - what can we do? // do nothing if it fails - what can we do?
} }
} }
@@ -265,15 +267,17 @@ wxLog *wxLog::GetActiveTarget()
return ms_pLogger; return ms_pLogger;
} }
wxLog *wxLog::SetActiveTarget(wxLog *pLogger, bool bNoFlashOld) wxLog *wxLog::SetActiveTarget(wxLog *pLogger)
{ {
// flush the old messages before changing if ( ms_pLogger != NULL ) {
if ( (ms_pLogger != NULL) && !bNoFlashOld ) { // flush the old messages before changing because otherwise they might
// get lost later if this target is not restored
ms_pLogger->Flush(); ms_pLogger->Flush();
} }
wxLog *pOldLogger = ms_pLogger; wxLog *pOldLogger = ms_pLogger;
ms_pLogger = pLogger; ms_pLogger = pLogger;
return pOldLogger; return pOldLogger;
} }
@@ -779,8 +783,7 @@ void wxLogWindow::DoLogString(const char *szString)
pText->WriteText(szString); pText->WriteText(szString);
pText->WriteText("\n"); // "\n" ok here (_not_ "\r\n") pText->WriteText("\n"); // "\n" ok here (_not_ "\r\n")
// ensure that the line can be seen // TODO ensure that the line can be seen
// @@@ TODO
} }
wxFrame *wxLogWindow::GetFrame() const wxFrame *wxLogWindow::GetFrame() const
@@ -794,11 +797,13 @@ void wxLogWindow::OnFrameCreate(wxFrame *WXUNUSED(frame))
void wxLogWindow::OnFrameDelete(wxFrame *WXUNUSED(frame)) void wxLogWindow::OnFrameDelete(wxFrame *WXUNUSED(frame))
{ {
m_pLogFrame = (wxLogFrame *) NULL; m_pLogFrame = (wxLogFrame *)NULL;
} }
wxLogWindow::~wxLogWindow() wxLogWindow::~wxLogWindow()
{ {
delete m_pOldLog;
// may be NULL if log frame already auto destroyed itself // may be NULL if log frame already auto destroyed itself
delete m_pLogFrame; delete m_pLogFrame;
} }
@@ -813,6 +818,7 @@ wxLogWindow::~wxLogWindow()
// static variables // static variables
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxLog *wxLog::ms_pLogger = (wxLog *) NULL; wxLog *wxLog::ms_pLogger = (wxLog *) NULL;
bool wxLog::ms_doLog = TRUE;
bool wxLog::ms_bAutoCreate = TRUE; bool wxLog::ms_bAutoCreate = TRUE;
wxTraceMask wxLog::ms_ulTraceMask = (wxTraceMask)0; wxTraceMask wxLog::ms_ulTraceMask = (wxTraceMask)0;
@@ -941,6 +947,8 @@ void wxOnAssert(const char *szFile, int nLine, const char *szMsg)
if ( s_bInAssert ) { if ( s_bInAssert ) {
// He-e-e-e-elp!! we're trapped in endless loop // He-e-e-e-elp!! we're trapped in endless loop
Trap(); Trap();
return;
} }
s_bInAssert = TRUE; s_bInAssert = TRUE;

View File

@@ -51,7 +51,6 @@
#endif #endif
// use debug CRT functions for memory leak detections in VC++ // use debug CRT functions for memory leak detections in VC++
/* This still doesn't work for me, Vadim.
#if defined(__WXDEBUG__) && defined(_MSC_VER) #if defined(__WXDEBUG__) && defined(_MSC_VER)
// VC++ uses this macro as debug/release mode indicator // VC++ uses this macro as debug/release mode indicator
#ifndef _DEBUG #ifndef _DEBUG
@@ -60,7 +59,6 @@
#include <crtdbg.h> #include <crtdbg.h>
#endif #endif
*/
extern char *wxBuffer; extern char *wxBuffer;
extern char *wxOsVersion; extern char *wxOsVersion;
@@ -114,14 +112,12 @@ bool wxApp::Initialize()
{ {
wxBuffer = new char[1500]; wxBuffer = new char[1500];
/*
#if defined(__WXDEBUG__) && defined(_MSC_VER) #if defined(__WXDEBUG__) && defined(_MSC_VER)
// do check for memory leaks on program exit // do check for memory leaks on program exit
// (another useful flag is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free // (another useful flag is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free
// deallocated memory which may be used to simulate low-memory condition) // deallocated memory which may be used to simulate low-memory condition)
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
#endif // debug build under MS VC++ #endif // debug build under MS VC++
*/
#if (WXDEBUG && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT #if (WXDEBUG && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
#if defined(_WINDLL) #if defined(_WINDLL)
@@ -352,7 +348,7 @@ void wxApp::ConvertToStandardCommandArgs(char* lpCmdLine)
int count = 0; int count = 0;
// Get application name // Get application name
char name[500]; char name[260]; // 260 is MAX_PATH value from windef.h
::GetModuleFileName(wxhInstance, name, WXSIZEOF(name)); ::GetModuleFileName(wxhInstance, name, WXSIZEOF(name));
// GNUWIN32 already fills in the first arg with the application name. // GNUWIN32 already fills in the first arg with the application name.

View File

@@ -83,8 +83,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
// Even with extended styles, need to combine with WS_BORDER // Even with extended styles, need to combine with WS_BORDER
// for them to look right. // for them to look right.
if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || if ( want3D || wxStyleHasBorder(m_windowStyle) )
(m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)))
msStyle |= WS_BORDER; msStyle |= WS_BORDER;
m_hWnd = (WXHWND)CreateWindowEx(exStyle, "BUTTON", Label, m_hWnd = (WXHWND)CreateWindowEx(exStyle, "BUTTON", Label,

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -48,8 +48,8 @@ bool wxChoice::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
bool wxChoice::Create(wxWindow *parent, wxWindowID id, bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
int n, const wxString choices[], int n, const wxString choices[],
long style, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
@@ -63,9 +63,9 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
m_windowStyle = style; m_windowStyle = style;
if ( id == -1 ) if ( id == -1 )
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
else else
m_windowId = id; m_windowId = id;
int x = pos.x; int x = pos.x;
int y = pos.y; int y = pos.y;
@@ -82,14 +82,16 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
// Even with extended styles, need to combine with WS_BORDER // Even with extended styles, need to combine with WS_BORDER
// for them to look right. // for them to look right.
if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || if ( want3D || wxStyleHasBorder(m_windowStyle) )
(m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
msStyle |= WS_BORDER; msStyle |= WS_BORDER;
HWND wx_combo = CreateWindowEx(exStyle, "COMBOBOX", NULL, m_hWnd = (WXHWND)::CreateWindowEx(exStyle, "COMBOBOX", NULL,
msStyle, msStyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL); wxGetInstance(), NULL);
wxCHECK_MSG( m_hWnd, FALSE, "Failed to create combobox" );
/* /*
#if CTL3D #if CTL3D
if (want3D) if (want3D)
@@ -100,17 +102,17 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
#endif #endif
*/ */
m_hWnd = (WXHWND) wx_combo;
// Subclass again for purposes of dialog editing mode // Subclass again for purposes of dialog editing mode
SubclassWin((WXHWND) wx_combo); SubclassWin(m_hWnd);
SetFont(* parent->GetFont()); SetFont(* parent->GetFont());
int i; int i;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
SendMessage(wx_combo, CB_INSERTSTRING, i, (LONG)(const char *)choices[i]); {
SendMessage(wx_combo, CB_SETCURSEL, i, 0); Append(choices[i]);
}
SetSelection(n);
SetSize(x, y, width, height); SetSize(x, y, width, height);
@@ -266,9 +268,9 @@ void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
} }
WXHBRUSH wxChoice::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, WXHBRUSH wxChoice::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam) WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{ {
return 0; return 0;
} }
long wxChoice::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) long wxChoice::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)

View File

@@ -6,7 +6,7 @@
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -59,13 +59,13 @@ bool wxComboBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
} }
bool wxComboBox::Create(wxWindow *parent, wxWindowID id, bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
const wxString& value, const wxString& value,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
int n, const wxString choices[], int n, const wxString choices[],
long style, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
SetName(name); SetName(name);
SetValidator(validator); SetValidator(validator);
@@ -77,21 +77,22 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
m_windowStyle = style; m_windowStyle = style;
if ( id == -1 ) if ( id == -1 )
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
else else
m_windowId = id; m_windowId = id;
int x = pos.x; int x = pos.x;
int y = pos.y; int y = pos.y;
int width = size.x; int width = size.x;
int height = size.y; int height = size.y;
long msStyle = WS_CHILD | WS_HSCROLL | WS_VSCROLL long msStyle = WS_CHILD | WS_HSCROLL | WS_VSCROLL |
| WS_TABSTOP | WS_VISIBLE | CBS_NOINTEGRALHEIGHT; WS_TABSTOP | WS_VISIBLE | CBS_NOINTEGRALHEIGHT;
if (m_windowStyle & wxCB_READONLY) if (m_windowStyle & wxCB_READONLY)
msStyle |= CBS_DROPDOWNLIST; msStyle |= CBS_DROPDOWNLIST;
else if (m_windowStyle & wxCB_SIMPLE) // A list (shown always) and edit control else if (m_windowStyle & wxCB_SIMPLE)
msStyle |= CBS_SIMPLE; msStyle |= CBS_SIMPLE; // A list (shown always) and edit control
else else
msStyle |= CBS_DROPDOWN; msStyle |= CBS_DROPDOWN;
@@ -103,14 +104,16 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
// Even with extended styles, need to combine with WS_BORDER // Even with extended styles, need to combine with WS_BORDER
// for them to look right. // for them to look right.
if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || if ( want3D || wxStyleHasBorder(m_windowStyle) )
(m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
msStyle |= WS_BORDER; msStyle |= WS_BORDER;
HWND wx_combo = CreateWindowEx(exStyle, "COMBOBOX", NULL, m_hWnd = (WXHWND)::CreateWindowEx(exStyle, "COMBOBOX", NULL,
msStyle, msStyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL); wxGetInstance(), NULL);
wxCHECK_MSG( m_hWnd, FALSE, "Failed to create combobox" );
/* /*
#if CTL3D #if CTL3D
if (want3D) if (want3D)
@@ -121,20 +124,23 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
#endif #endif
*/ */
m_hWnd = (WXHWND)wx_combo;
// Subclass again for purposes of dialog editing mode // Subclass again for purposes of dialog editing mode
SubclassWin((WXHWND)wx_combo); SubclassWin(m_hWnd);
SetFont(* parent->GetFont()); SetFont(* parent->GetFont());
int i; int i;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
SendMessage(wx_combo, CB_INSERTSTRING, i, (LONG)(const char *)choices[i]); {
SendMessage(wx_combo, CB_SETCURSEL, i, 0); Append(choices[i]);
}
SetSelection(i);
SetSize(x, y, width, height); SetSize(x, y, width, height);
if ( value != "" ) if ( !value.IsEmpty() )
SetWindowText(wx_combo, (const char *)value); {
SetValue(value);
}
return TRUE; return TRUE;
} }

View File

@@ -99,8 +99,8 @@ static PAINTSTRUCT g_paintStruct;
// Don't call Begin/EndPaint if it's already been called: // Don't call Begin/EndPaint if it's already been called:
// for example, if calling a base class OnPaint. // for example, if calling a base class OnPaint.
WXHDC wxPaintDC::ms_PaintHDC = 0; WXHDC wxPaintDC::ms_PaintHDC = 0;
size_t wxPaintDC::ms_PaintCount = 0; // count of ms_PaintHDC usage size_t wxPaintDC::ms_PaintCount = 0; // count of ms_PaintHDC usage
wxPaintDC::wxPaintDC(wxWindow *canvas) wxPaintDC::wxPaintDC(wxWindow *canvas)
{ {
@@ -132,7 +132,7 @@ wxPaintDC::~wxPaintDC()
m_hDC = NULL; m_hDC = NULL;
ms_PaintHDC = NULL; ms_PaintHDC = NULL;
} }
//else: ms_PaintHDC still in use else { }//: ms_PaintHDC still in use
} }
} }

View File

@@ -198,35 +198,33 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
// Even with extended styles, need to combine with WS_BORDER // Even with extended styles, need to combine with WS_BORDER
// for them to look right. // for them to look right.
if ( want3D || (m_windowStyle & wxSIMPLE_BORDER) if ( want3D || wxStyleHasBorder(m_windowStyle) )
|| (m_windowStyle & wxRAISED_BORDER) {
|| (m_windowStyle & wxSUNKEN_BORDER)
|| (m_windowStyle & wxDOUBLE_BORDER) ) {
wstyle |= WS_BORDER; wstyle |= WS_BORDER;
} }
HWND wx_list = CreateWindowEx(exStyle, "LISTBOX", NULL, m_hWnd = (WXHWND)::CreateWindowEx(exStyle, "LISTBOX", NULL,
wstyle | WS_CHILD, wstyle | WS_CHILD,
0, 0, 0, 0, 0, 0, 0, 0,
(HWND)parent->GetHWND(), (HMENU)m_windowId, (HWND)parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL); wxGetInstance(), NULL);
m_hWnd = (WXHWND)wx_list; wxCHECK_MSG( m_hWnd, FALSE, "Failed to create listbox" );
#if CTL3D #if CTL3D
if (want3D) if (want3D)
{ {
Ctl3dSubclassCtl(wx_list); Ctl3dSubclassCtl(hwnd);
m_useCtl3D = TRUE; m_useCtl3D = TRUE;
} }
#endif #endif
// Subclass again to catch messages // Subclass again to catch messages
SubclassWin((WXHWND)wx_list); SubclassWin(m_hWnd);
size_t ui; size_t ui;
for (ui = 0; ui < (size_t)n; ui++) { for (ui = 0; ui < (size_t)n; ui++) {
SendMessage(wx_list, LB_ADDSTRING, 0, (LPARAM)(const char *)choices[ui]); Append(choices[ui]);
} }
#if wxUSE_OWNER_DRAWN #if wxUSE_OWNER_DRAWN
@@ -236,19 +234,19 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
wxOwnerDrawn *pNewItem = CreateItem(ui); wxOwnerDrawn *pNewItem = CreateItem(ui);
pNewItem->SetName(choices[ui]); pNewItem->SetName(choices[ui]);
m_aItems.Add(pNewItem); m_aItems.Add(pNewItem);
ListBox_SetItemData(wx_list, ui, pNewItem); ListBox_SetItemData(hwnd, ui, pNewItem);
} }
} }
#endif #endif
if ((m_windowStyle & wxLB_MULTIPLE) == 0) if ( (m_windowStyle & wxLB_MULTIPLE) == 0 )
SendMessage(wx_list, LB_SETCURSEL, 0, 0); SendMessage(hwnd, LB_SETCURSEL, 0, 0);
SetFont(* parent->GetFont()); SetFont(* parent->GetFont());
SetSize(x, y, width, height); SetSize(x, y, width, height);
ShowWindow(wx_list, SW_SHOW); Show(TRUE);
return TRUE; return TRUE;
} }

View File

@@ -97,8 +97,7 @@ bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, con
// Even with extended styles, need to combine with WS_BORDER // Even with extended styles, need to combine with WS_BORDER
// for them to look right. // for them to look right.
if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || if ( want3D || wxStyleHasBorder(m_windowStyle) )
(m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
wstyle |= WS_BORDER; wstyle |= WS_BORDER;
wstyle |= LVS_SHAREIMAGELISTS; wstyle |= LVS_SHAREIMAGELISTS;

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -125,23 +125,30 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
WXDWORD exStyle = Determine3DEffects(0, &want3D) ; WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
// Even with extended styles, need to combine with WS_BORDER // Even with extended styles, need to combine with WS_BORDER
// for them to look right. // for them to look right.
if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || if ( want3D || wxStyleHasBorder(m_windowStyle) )
(m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)))
msStyle |= WS_BORDER; msStyle |= WS_BORDER;
m_hWnd = (WXHWND) CreateWindowEx((DWORD) exStyle, GROUP_CLASS, (title == "" ? NULL : (const char *)title),
msStyle,
0,0,0,0,
(HWND) parent->GetHWND(), (HMENU) m_windowId, wxGetInstance(), NULL) ;
HWND the_handle = (HWND) parent->GetHWND() ; HWND the_handle = (HWND) parent->GetHWND() ;
m_hWnd = (WXHWND)::CreateWindowEx
(
(DWORD)exStyle,
GROUP_CLASS,
title,
msStyle,
0, 0, 0, 0,
the_handle,
(HMENU)m_windowId,
wxGetInstance(),
NULL
);
#if CTL3D #if CTL3D
if (want3D) if (want3D)
{ {
Ctl3dSubclassCtl((HWND) m_hWnd); Ctl3dSubclassCtl((HWND)m_hWnd);
m_useCtl3D = TRUE; m_useCtl3D = TRUE;
} }
#endif #endif
@@ -171,7 +178,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
if (want3D) if (want3D)
{ {
Ctl3dSubclassCtl((HWND) m_hWnd); Ctl3dSubclassCtl((HWND) m_hWnd);
m_useCtl3D = TRUE; m_useCtl3D = TRUE;
} }
#endif #endif
if (GetFont()) if (GetFont())
@@ -235,8 +242,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
WXDWORD exStyle = Determine3DEffects(0, &want3D) ; WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
// Even with extended styles, need to combine with WS_BORDER // Even with extended styles, need to combine with WS_BORDER
// for them to look right. // for them to look right.
if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || if ( want3D || wxStyleHasBorder(m_windowStyle) )
(m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)))
msStyle |= WS_BORDER; msStyle |= WS_BORDER;
m_hWnd = (WXHWND) CreateWindowEx((DWORD) exStyle, GROUP_CLASS, (title == "" ? NULL : (const char *)title), m_hWnd = (WXHWND) CreateWindowEx((DWORD) exStyle, GROUP_CLASS, (title == "" ? NULL : (const char *)title),
@@ -250,7 +256,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
if (want3D) if (want3D)
{ {
Ctl3dSubclassCtl((HWND) m_hWnd); Ctl3dSubclassCtl((HWND) m_hWnd);
m_useCtl3D = TRUE; m_useCtl3D = TRUE;
} }
#endif #endif
@@ -283,7 +289,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
if (want3D) if (want3D)
{ {
Ctl3dSubclassCtl((HWND) m_hWnd); Ctl3dSubclassCtl((HWND) m_hWnd);
m_useCtl3D = TRUE; m_useCtl3D = TRUE;
} }
#endif #endif
m_subControls.Append((wxObject *)newId); m_subControls.Append((wxObject *)newId);
@@ -651,7 +657,7 @@ void wxRadioBox::Show(int item, bool show)
} }
WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam) WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{ {
#if CTL3D #if CTL3D
if ( m_useCtl3D ) if ( m_useCtl3D )
@@ -701,11 +707,11 @@ bool wxRadioBox::SetStringSelection (const wxString& s)
bool wxRadioBox::ContainsHWND(WXHWND hWnd) const bool wxRadioBox::ContainsHWND(WXHWND hWnd) const
{ {
int i; int i;
for (i = 0; i < Number(); i++) for (i = 0; i < Number(); i++)
if (GetRadioButtons()[i] == hWnd) if (GetRadioButtons()[i] == hWnd)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
void wxRadioBox::Command (wxCommandEvent & event) void wxRadioBox::Command (wxCommandEvent & event)
@@ -716,7 +722,7 @@ void wxRadioBox::Command (wxCommandEvent & event)
long wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) long wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{ {
if (nMsg == WM_NCHITTEST) if (nMsg == WM_NCHITTEST)
{ {
int xPos = LOWORD(lParam); // horizontal position of cursor int xPos = LOWORD(lParam); // horizontal position of cursor
int yPos = HIWORD(lParam); // vertical position of cursor int yPos = HIWORD(lParam); // vertical position of cursor
@@ -729,6 +735,6 @@ long wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
return (long)HTCLIENT; return (long)HTCLIENT;
} }
return wxControl::MSWWindowProc(nMsg, wParam, lParam); return wxControl::MSWWindowProc(nMsg, wParam, lParam);
} }

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -34,7 +34,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
#endif #endif
bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
const wxString& label, const wxString& label,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& validator,
@@ -49,9 +49,9 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
SetForegroundColour(parent->GetForegroundColour()); SetForegroundColour(parent->GetForegroundColour());
if ( id == -1 ) if ( id == -1 )
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
else else
m_windowId = id; m_windowId = id;
int x = pos.x; int x = pos.x;
int y = pos.y; int y = pos.y;
@@ -72,18 +72,20 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
// Even with extended styles, need to combine with WS_BORDER // Even with extended styles, need to combine with WS_BORDER
// for them to look right. // for them to look right.
if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || if ( want3D || wxStyleHasBorder(m_windowStyle) )
(m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)))
msStyle |= WS_BORDER; msStyle |= WS_BORDER;
m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const char *)label, m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const char *)label,
msStyle,0,0,0,0, msStyle,0,0,0,0,
(HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL); (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
wxCHECK_MSG( m_hWnd, FALSE, "Failed to create radiobutton" );
#if CTL3D #if CTL3D
if (want3D) if (want3D)
{ {
Ctl3dSubclassCtl((HWND) m_hWnd); Ctl3dSubclassCtl((HWND) m_hWnd);
m_useCtl3D = TRUE; m_useCtl3D = TRUE;
} }
#endif #endif
@@ -141,7 +143,7 @@ bool wxRadioButton::GetValue(void) const
} }
WXHBRUSH wxRadioButton::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, WXHBRUSH wxRadioButton::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam) WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{ {
#if CTL3D #if CTL3D
if ( m_useCtl3D ) if ( m_useCtl3D )
@@ -177,7 +179,7 @@ void wxRadioButton::Command (wxCommandEvent & event)
// Not implemented // Not implemented
#if 0 #if 0
bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id, bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id,
const wxBitmap *bitmap, const wxBitmap *bitmap,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& validator,
@@ -191,9 +193,9 @@ bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id,
SetForegroundColour(parent->GetForegroundColour()); SetForegroundColour(parent->GetForegroundColour());
if ( id == -1 ) if ( id == -1 )
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
else else
m_windowId = id; m_windowId = id;
int x = pos.x; int x = pos.x;
int y = pos.y; int y = pos.y;
@@ -211,11 +213,14 @@ bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id,
m_hWnd = (WXHWND) CreateWindowEx(MakeExtendedStyle(m_windowStyle), RADIO_CLASS, "toggle", m_hWnd = (WXHWND) CreateWindowEx(MakeExtendedStyle(m_windowStyle), RADIO_CLASS, "toggle",
msStyle,0,0,0,0, msStyle,0,0,0,0,
(HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL); (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
wxCHECK_MSG( m_hWnd, "Failed to create radio button", FALSE );
#if CTL3D #if CTL3D
if (!(GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS)) if (!(GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS))
{ {
Ctl3dSubclassCtl((HWND) GetHWND()); Ctl3dSubclassCtl((HWND) GetHWND());
m_useCtl3D = TRUE; m_useCtl3D = TRUE;
} }
#endif #endif

View File

@@ -801,142 +801,3 @@ void RemoveTrailingSeparator(wxString& str)
if ( !str.IsEmpty() && str.Last() == REG_SEPARATOR ) if ( !str.IsEmpty() && str.Last() == REG_SEPARATOR )
str.Truncate(str.Len() - 1); str.Truncate(str.Len() - 1);
} }
// ============================================================================
// global public functions
// ============================================================================
bool GetExtensionFromMimeType(wxString *pExt, const wxString& strMimeType)
{
// @@@ VZ: I don't know of any official documentation which mentions this
// location, but as a matter of fact IE uses it, so why not we?
static const char *szMimeDbase = "MIME\\Database\\Content Type\\";
wxString strKey = szMimeDbase;
strKey << strMimeType;
// suppress possible error messages
wxLogNull nolog;
wxRegKey key(wxRegKey::HKCR, strKey);
if ( key.Open() ) {
if ( key.QueryValue("Extension", *pExt) )
return TRUE;
}
// no such MIME type or no extension for it
return FALSE;
}
bool GetMimeTypeFromExtension(wxString *pMimeType, const wxString& strExt)
{
wxCHECK( !strExt.IsEmpty(), FALSE );
// add the leading point if necessary
wxString str;
if ( strExt[0] != '.' ) {
str = '.';
}
str << strExt;
// suppress possible error messages
wxLogNull nolog;
wxRegKey key(wxRegKey::HKCR, str);
if ( key.Open() ) {
if ( key.QueryValue("Content Type", *pMimeType) )
return TRUE;
}
// no such extension or no content-type
return FALSE;
}
bool GetFileTypeFromExtension(wxString *pFileType, const wxString& strExt)
{
wxCHECK( !strExt.IsEmpty(), FALSE );
// add the leading point if necessary
wxString str;
if ( strExt[0] != '.' ) {
str = '.';
}
str << strExt;
// suppress possible error messages
wxLogNull nolog;
wxRegKey key(wxRegKey::HKCR, str);
if ( key.Open() ) {
if ( key.QueryValue("", *pFileType) ) // it's the default value of the key
return TRUE;
}
// no such extension or no value
return FALSE;
}
bool GetFileTypeIcon(wxIcon *pIcon, const wxString& strFileType)
{
wxCHECK( !strFileType.IsEmpty(), FALSE );
wxString strIconKey;
strIconKey << strFileType << REG_SEPARATOR << "DefaultIcon";
// suppress possible error messages
wxLogNull nolog;
wxRegKey key(wxRegKey::HKCR, strIconKey);
if ( key.Open() ) {
wxString strIcon;
if ( key.QueryValue("", strIcon) ) { // it's the default value of the key
// the format is the following: <full path to file>, <icon index>
// NB: icon index may be negative as well as positive and the full path
// may contain the environment variables inside '%'
wxString strFullPath = strIcon.Before(','),
strIndex = strIcon.Right(',');
// index may be omitted, in which case Before(',') is empty and
// Right(',') is the whole string
if ( strFullPath.IsEmpty() ) {
strFullPath = strIndex;
strIndex = "0";
}
wxString strExpPath = wxExpandEnvVars(strFullPath);
int nIndex = atoi(strIndex);
HICON hIcon = ExtractIcon(GetModuleHandle(NULL), strExpPath, nIndex);
switch ( (int)hIcon ) {
case 0: // means no icons were found
case 1: // means no such file or it wasn't a DLL/EXE/OCX/ICO/...
wxLogDebug("incorrect registry entry '%s': no such icon.",
GetFullName(&key));
break;
default:
pIcon->SetHICON((WXHICON)hIcon);
return TRUE;
}
}
}
// no such file type or no value or incorrect icon entry
return FALSE;
}
bool GetFileTypeDescription(wxString *pDesc, const wxString& strFileType)
{
wxCHECK( !strFileType.IsEmpty(), FALSE );
// suppress possible error messages
wxLogNull nolog;
wxRegKey key(wxRegKey::HKCR, strFileType);
if ( key.Open() ) {
if ( key.QueryValue("", *pDesc) ) // it's the default value of the key
return TRUE;
}
// no such file type or no value
return FALSE;
}

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -46,9 +46,9 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
SetForegroundColour(parent->GetForegroundColour()) ; SetForegroundColour(parent->GetForegroundColour()) ;
if ( id == -1 ) if ( id == -1 )
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
else else
m_windowId = id; m_windowId = id;
int x = pos.x; int x = pos.x;
int y = pos.y; int y = pos.y;
@@ -67,15 +67,16 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
// Even with extended styles, need to combine with WS_BORDER // Even with extended styles, need to combine with WS_BORDER
// for them to look right. // for them to look right.
if ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || if ( wxStyleHasBorder(m_windowStyle) )
(m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
msStyle |= WS_BORDER; msStyle |= WS_BORDER;
HWND static_item = CreateWindowEx(MakeExtendedStyle(m_windowStyle), "STATIC", (const char *)label, m_hWnd = (WXHWND)::CreateWindowEx(MakeExtendedStyle(m_windowStyle), "STATIC", (const char *)label,
msStyle, msStyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL); wxGetInstance(), NULL);
wxCHECK_MSG( m_hWnd, FALSE, "Failed to create static ctrl" );
#if CTL3D #if CTL3D
/* /*
if (!(GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS)) if (!(GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS))
@@ -83,12 +84,11 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
*/ */
#endif #endif
m_hWnd = (WXHWND)static_item; SubclassWin(m_hWnd);
SubclassWin((WXHWND)static_item);
SetFont(* parent->GetFont()); SetFont(* parent->GetFont());
SetSize(x, y, width, height); SetSize(x, y, width, height);
return TRUE; return TRUE;
} }
@@ -166,14 +166,14 @@ void wxStaticText::SetLabel(const wxString& label)
} }
WXHBRUSH wxStaticText::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, WXHBRUSH wxStaticText::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam) WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{ {
/* /*
#if CTL3D #if CTL3D
if ( m_useCtl3D ) if ( m_useCtl3D )
{ {
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam); HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
if (hbrush != (HBRUSH) 0) if (hbrush != (HBRUSH) 0)
return hbrush; return hbrush;
else else

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -67,9 +67,9 @@
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
EVT_CHAR(wxTextCtrl::OnChar) EVT_CHAR(wxTextCtrl::OnChar)
EVT_DROP_FILES(wxTextCtrl::OnDropFiles) EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
EVT_ERASE_BACKGROUND(wxTextCtrl::OnEraseBackground) EVT_ERASE_BACKGROUND(wxTextCtrl::OnEraseBackground)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif #endif
@@ -85,11 +85,11 @@ wxTextCtrl::wxTextCtrl(void)
} }
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
const wxString& value, const wxString& value,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_fileName = ""; m_fileName = "";
SetName(name); SetName(name);
@@ -106,9 +106,9 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
SetForegroundColour(parent->GetForegroundColour()) ; SetForegroundColour(parent->GetForegroundColour()) ;
if ( id == -1 ) if ( id == -1 )
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
else else
m_windowId = id; m_windowId = id;
int x = pos.x; int x = pos.x;
int y = pos.y; int y = pos.y;
@@ -129,9 +129,10 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
// m_globalHandle = (WXHGLOBAL) GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, // m_globalHandle = (WXHGLOBAL) GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT,
// 256L); // 256L);
#endif #endif
long msStyle = ES_LEFT | WS_VISIBLE | WS_CHILD | WS_TABSTOP; long msStyle = ES_LEFT | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
if (m_windowStyle & wxTE_MULTILINE) if (m_windowStyle & wxTE_MULTILINE)
msStyle |= ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL ; // WS_BORDER msStyle |= ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL ; // WS_BORDER
else else
msStyle |= ES_AUTOHSCROLL ; msStyle |= ES_AUTOHSCROLL ;
@@ -146,16 +147,14 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
char *windowClass = "EDIT"; char *windowClass = "EDIT";
#if defined(__WIN95__) #if defined(__WIN95__)
if ( m_windowStyle & wxTE_MULTILINE ) if ( m_windowStyle & wxTE_MULTILINE )
#else
if ( FALSE )
#endif
{ {
msStyle |= ES_AUTOVSCROLL; msStyle |= ES_AUTOVSCROLL;
m_isRich = TRUE; m_isRich = TRUE;
windowClass = "RichEdit" ; windowClass = "RichEdit" ;
} }
else else
m_isRich = FALSE; #endif
m_isRich = FALSE;
bool want3D; bool want3D;
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ; WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
@@ -166,36 +165,36 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
if (m_windowStyle & wxSIMPLE_BORDER) if (m_windowStyle & wxSIMPLE_BORDER)
{ {
windowClass = "EDIT"; windowClass = "EDIT";
m_isRich = FALSE; m_isRich = FALSE;
} }
#endif #endif
// Even with extended styles, need to combine with WS_BORDER // Even with extended styles, need to combine with WS_BORDER
// for them to look right. // for them to look right.
if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || if ( want3D || wxStyleHasBorder(m_windowStyle) )
(m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
msStyle |= WS_BORDER; msStyle |= WS_BORDER;
HWND edit = CreateWindowEx(exStyle, windowClass, NULL, m_hWnd = (WXHWND)::CreateWindowEx(exStyle, windowClass, NULL,
msStyle, msStyle,
0, 0, 0, 0, (HWND) ((wxWindow*)parent)->GetHWND(), (HMENU)m_windowId, 0, 0, 0, 0, (HWND) ((wxWindow*)parent)->GetHWND(), (HMENU)m_windowId,
m_globalHandle ? (HINSTANCE) m_globalHandle : wxGetInstance(), NULL); m_globalHandle ? (HINSTANCE) m_globalHandle : wxGetInstance(), NULL);
wxCHECK_MSG( m_hWnd, FALSE, "Failed to create text ctrl" );
#if CTL3D #if CTL3D
if ( want3D ) if ( want3D )
{ {
Ctl3dSubclassCtl(edit); Ctl3dSubclassCtl((HWND)m_hWnd);
m_useCtl3D = TRUE; m_useCtl3D = TRUE;
} }
#endif #endif
m_hWnd = (WXHWND)edit;
#if defined(__WIN95__) #if defined(__WIN95__)
if (m_isRich) if (m_isRich)
{ {
// Have to enable events // Have to enable events
::SendMessage(edit, EM_SETEVENTMASK, 0, ENM_CHANGE | ENM_DROPFILES | ENM_SELCHANGE | ENM_UPDATE); ::SendMessage((HWND)m_hWnd, EM_SETEVENTMASK, 0,
ENM_CHANGE | ENM_DROPFILES | ENM_SELCHANGE | ENM_UPDATE);
} }
#endif #endif
@@ -203,19 +202,21 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
if ( parent->GetFont() && parent->GetFont()->Ok() ) if ( parent->GetFont() && parent->GetFont()->Ok() )
{ {
SetFont(* parent->GetFont()); SetFont(* parent->GetFont());
} }
else else
{ {
SetFont(wxSystemSettings::GetSystemFont(wxSYS_SYSTEM_FONT)); SetFont(wxSystemSettings::GetSystemFont(wxSYS_SYSTEM_FONT));
} }
SetSize(x, y, width, height); SetSize(x, y, width, height);
// Causes a crash for Symantec C++ and WIN32 for some reason // Causes a crash for Symantec C++ and WIN32 for some reason
#if !(defined(__SC__) && defined(__WIN32__)) #if !(defined(__SC__) && defined(__WIN32__))
if (value != "") if ( !value.IsEmpty() )
SetWindowText(edit, (const char *)value); {
SetValue(value);
}
#endif #endif
return TRUE; return TRUE;
@@ -224,39 +225,39 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
// Make sure the window style (etc.) reflects the HWND style (roughly) // Make sure the window style (etc.) reflects the HWND style (roughly)
void wxTextCtrl::AdoptAttributesFromHWND(void) void wxTextCtrl::AdoptAttributesFromHWND(void)
{ {
wxWindow::AdoptAttributesFromHWND(); wxWindow::AdoptAttributesFromHWND();
HWND hWnd = (HWND) GetHWND(); HWND hWnd = (HWND) GetHWND();
long style = GetWindowLong((HWND) hWnd, GWL_STYLE); long style = GetWindowLong((HWND) hWnd, GWL_STYLE);
char buf[256]; char buf[256];
#ifndef __WIN32__ #ifndef __WIN32__
GetClassName((HWND) hWnd, buf, 256); GetClassName((HWND) hWnd, buf, 256);
#else #else
#ifdef UNICODE #ifdef UNICODE
GetClassNameW((HWND) hWnd, buf, 256); GetClassNameW((HWND) hWnd, buf, 256);
#else #else
GetClassNameA((HWND) hWnd, buf, 256); GetClassNameA((HWND) hWnd, buf, 256);
#endif #endif
#endif #endif
wxString str(buf); wxString str(buf);
str.UpperCase(); str.UpperCase();
if (str == "EDIT") if (str == "EDIT")
m_isRich = FALSE; m_isRich = FALSE;
else else
m_isRich = TRUE; m_isRich = TRUE;
if (style & ES_MULTILINE) if (style & ES_MULTILINE)
m_windowStyle |= wxTE_MULTILINE; m_windowStyle |= wxTE_MULTILINE;
if (style & ES_PASSWORD) if (style & ES_PASSWORD)
m_windowStyle |= wxTE_PASSWORD; m_windowStyle |= wxTE_PASSWORD;
if (style & ES_READONLY) if (style & ES_READONLY)
m_windowStyle |= wxTE_READONLY; m_windowStyle |= wxTE_READONLY;
if (style & ES_WANTRETURN) if (style & ES_WANTRETURN)
m_windowStyle |= wxTE_PROCESS_ENTER; m_windowStyle |= wxTE_PROCESS_ENTER;
} }
void wxTextCtrl::SetupColours(void) void wxTextCtrl::SetupColours(void)
@@ -272,7 +273,7 @@ wxString wxTextCtrl::GetValue(void) const
GetWindowText((HWND) GetHWND(), s, length+1); GetWindowText((HWND) GetHWND(), s, length+1);
wxString str(s); wxString str(s);
delete[] s; delete[] s;
return str; return str;
} }
void wxTextCtrl::SetValue(const wxString& value) void wxTextCtrl::SetValue(const wxString& value)
@@ -539,13 +540,13 @@ bool wxTextCtrl::LoadFile(const wxString& file)
while (!input.eof() && input.peek() != EOF) while (!input.eof() && input.peek() != EOF)
{ {
input.getline(wxBuffer, 500); input.getline(wxBuffer, 500);
int len = strlen(wxBuffer); int len = strlen(wxBuffer);
wxBuffer[len] = 13; wxBuffer[len] = 13;
wxBuffer[len+1] = 10; wxBuffer[len+1] = 10;
wxBuffer[len+2] = 0; wxBuffer[len+2] = 0;
strcpy(tmp_buffer+pos, wxBuffer); strcpy(tmp_buffer+pos, wxBuffer);
pos += strlen(wxBuffer); pos += strlen(wxBuffer);
no_lines++; no_lines++;
} }
// SendMessage((HWND) GetHWND(), WM_SETTEXT, 0, (LPARAM)tmp_buffer); // SendMessage((HWND) GetHWND(), WM_SETTEXT, 0, (LPARAM)tmp_buffer);
@@ -571,7 +572,7 @@ bool wxTextCtrl::SaveFile(const wxString& file)
ofstream output((char*) (const char*) theFile); ofstream output((char*) (const char*) theFile);
if (output.bad()) if (output.bad())
return FALSE; return FALSE;
// This will only save 64K max // This will only save 64K max
unsigned long nbytes = SendMessage((HWND) GetHWND(), WM_GETTEXTLENGTH, 0, 0); unsigned long nbytes = SendMessage((HWND) GetHWND(), WM_GETTEXTLENGTH, 0, 0);
@@ -579,13 +580,13 @@ bool wxTextCtrl::SaveFile(const wxString& file)
SendMessage((HWND) GetHWND(), WM_GETTEXT, (WPARAM)(nbytes+1), (LPARAM)tmp_buffer); SendMessage((HWND) GetHWND(), WM_GETTEXT, (WPARAM)(nbytes+1), (LPARAM)tmp_buffer);
char *pstr = tmp_buffer; char *pstr = tmp_buffer;
// Convert \r\n to just \n // Convert \r\n to just \n
while (*pstr) while (*pstr)
{ {
if (*pstr != '\r') if (*pstr != '\r')
output << *pstr; output << *pstr;
pstr++; pstr++;
} }
farfree(tmp_buffer); farfree(tmp_buffer);
SendMessage((HWND) GetHWND(), EM_SETMODIFY, FALSE, 0L); SendMessage((HWND) GetHWND(), EM_SETMODIFY, FALSE, 0L);
@@ -709,7 +710,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
*(WORD *)wxBuffer = 512; *(WORD *)wxBuffer = 512;
int noChars = (int)SendMessage(hWnd, EM_GETLINE, (WPARAM)lineNo, (LPARAM)wxBuffer); int noChars = (int)SendMessage(hWnd, EM_GETLINE, (WPARAM)lineNo, (LPARAM)wxBuffer);
wxBuffer[noChars] = 0; wxBuffer[noChars] = 0;
return wxString(wxBuffer); return wxString(wxBuffer);
} }
/* /*
@@ -898,7 +899,7 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c)
} }
WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam) WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{ {
#if CTL3D #if CTL3D
if ( m_useCtl3D ) if ( m_useCtl3D )
@@ -927,13 +928,13 @@ WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
void wxTextCtrl::OnChar(wxKeyEvent& event) void wxTextCtrl::OnChar(wxKeyEvent& event)
{ {
if ( (event.KeyCode() == WXK_RETURN) && (m_windowStyle & wxPROCESS_ENTER)) if ( (event.KeyCode() == WXK_RETURN) && (m_windowStyle & wxPROCESS_ENTER))
{ {
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
event.SetEventObject( this ); event.SetEventObject( this );
if ( GetEventHandler()->ProcessEvent(event) ) if ( GetEventHandler()->ProcessEvent(event) )
return; return;
} }
else if ( event.KeyCode() == WXK_TAB ) { else if ( event.KeyCode() == WXK_TAB ) {
wxNavigationKeyEvent event; wxNavigationKeyEvent event;
event.SetDirection(!(::GetKeyState(VK_SHIFT) & 0x100)); event.SetDirection(!(::GetKeyState(VK_SHIFT) & 0x100));
@@ -1059,24 +1060,24 @@ bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
#if defined(__WIN95__) #if defined(__WIN95__)
bool wxTextCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam) bool wxTextCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
{ {
wxCommandEvent event(0, m_windowId); wxCommandEvent event(0, m_windowId);
int eventType = 0; int eventType = 0;
NMHDR *hdr1 = (NMHDR *) lParam; NMHDR *hdr1 = (NMHDR *) lParam;
switch ( hdr1->code ) switch ( hdr1->code )
{ {
// Insert case code here // Insert case code here
default : default :
return wxControl::MSWNotify(wParam, lParam); return wxControl::MSWNotify(wParam, lParam);
break; break;
} }
event.SetEventObject( this ); event.SetEventObject( this );
event.SetEventType(eventType); event.SetEventType(eventType);
if ( !ProcessEvent(event) ) if ( !ProcessEvent(event) )
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
#endif #endif
#endif #endif

View File

@@ -9,23 +9,34 @@
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "timer.h" #pragma implementation "timer.h"
#endif #endif
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma hdrstop #pragma hdrstop
#endif #endif
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/setup.h" #include "wx/setup.h"
#include "wx/list.h" #include "wx/list.h"
#include "wx/app.h" #include "wx/app.h"
#endif #endif
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/timer.h" #include "wx/timer.h"
#include "wx/msw/private.h" #include "wx/msw/private.h"
@@ -33,81 +44,113 @@
#include <sys/types.h> #include <sys/types.h>
#if !defined(__SC__) && !defined(__GNUWIN32__) #if !defined(__SC__) && !defined(__GNUWIN32__)
#include <sys/timeb.h> #include <sys/timeb.h>
#endif
#ifdef __WIN32__
#define _EXPORT /**/
#else
#define _EXPORT _export
#endif #endif
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
wxList wxTimerList(wxKEY_INTEGER); wxList wxTimerList(wxKEY_INTEGER);
UINT WINAPI _EXPORT wxTimerProc(HWND hwnd, WORD, int idTimer, DWORD); UINT WINAPI _EXPORT wxTimerProc(HWND hwnd, WORD, int idTimer, DWORD);
#if !USE_SHARED_LIBRARY // ----------------------------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) // macros
// ----------------------------------------------------------------------------
#ifdef __WIN32__
#define _EXPORT /**/
#else
#define _EXPORT _export
#endif #endif
#if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
#endif
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// wxTimer class
// ----------------------------------------------------------------------------
wxTimer::wxTimer(void) wxTimer::wxTimer(void)
{ {
milli = 0 ; milli = 0 ;
lastMilli = -1 ; lastMilli = -1 ;
id = 0; id = 0;
} }
wxTimer::~wxTimer(void) wxTimer::~wxTimer(void)
{ {
Stop(); Stop();
wxTimerList.DeleteObject(this); wxTimerList.DeleteObject(this);
} }
bool wxTimer::Start(int milliseconds,bool mode) bool wxTimer::Start(int milliseconds, bool mode)
{ {
oneShot = mode ; oneShot = mode ;
if (milliseconds < 0) if (milliseconds < 0)
milliseconds = lastMilli; milliseconds = lastMilli;
if (milliseconds <= 0) wxCHECK_MSG( milliseconds > 0, FALSE, "invalid value for timer timeour" );
return FALSE;
lastMilli = milli = milliseconds; lastMilli = milli = milliseconds;
wxTimerList.DeleteObject(this); wxTimerList.DeleteObject(this);
TIMERPROC wxTimerProcInst = (TIMERPROC) MakeProcInstance((FARPROC)wxTimerProc, TIMERPROC wxTimerProcInst = (TIMERPROC)
wxGetInstance()); MakeProcInstance((FARPROC)wxTimerProc, wxGetInstance());
id = SetTimer(NULL, (UINT)(id ? id : 1), (UINT)milliseconds, wxTimerProcInst); id = SetTimer(NULL, (UINT)(id ? id : 1),
if (id > 0) (UINT)milliseconds, wxTimerProcInst);
{ if (id > 0)
wxTimerList.Append(id, this); {
return TRUE; wxTimerList.Append(id, this);
}
else return FALSE; return TRUE;
}
else
{
wxLogSysError(_("Couldn't create a timer"));
return FALSE;
}
} }
void wxTimer::Stop(void) void wxTimer::Stop(void)
{ {
if (id) { if (id) {
KillTimer(NULL, (UINT)id); KillTimer(NULL, (UINT)id);
wxTimerList.DeleteObject(this); /* @@@@ */ wxTimerList.DeleteObject(this); /* @@@@ */
} }
id = 0 ; id = 0 ;
milli = 0 ; milli = 0 ;
}
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
static void wxProcessTimer(wxTimer& timer)
{
// Avoid to process spurious timer events
if ( timer.id == 0)
return;
if ( timer.oneShot )
timer.Stop();
timer.Notify();
} }
UINT WINAPI _EXPORT wxTimerProc(HWND WXUNUSED(hwnd), WORD, int idTimer, DWORD) UINT WINAPI _EXPORT wxTimerProc(HWND WXUNUSED(hwnd), WORD, int idTimer, DWORD)
{ {
wxNode *node = wxTimerList.Find((long)idTimer); wxNode *node = wxTimerList.Find((long)idTimer);
if (node)
{
wxTimer *timer = (wxTimer *)node->Data();
if (timer->id==0)
return(0) ; // Avoid to process spurious timer events
if (timer->oneShot)
timer->Stop() ;
timer->Notify();
}
return 0;
}
wxCHECK_MSG( node, 0, "bogus timer id in wxTimerProc" );
wxProcessTimer(*(wxTimer *)node->Data());
return 0;
}

View File

@@ -302,7 +302,7 @@ wxWindow::~wxWindow(void)
if (m_sizerParent) if (m_sizerParent)
m_sizerParent->RemoveChild((wxWindow *)this); m_sizerParent->RemoveChild((wxWindow *)this);
#endif #endif
// wxWnd // wxWnd
MSWDetachWindowMenu(); MSWDetachWindowMenu();
@@ -323,7 +323,7 @@ wxWindow::~wxWindow(void)
m_globalHandle = 0; m_globalHandle = 0;
} }
#endif #endif
delete m_children; delete m_children;
m_children = NULL; m_children = NULL;
@@ -340,7 +340,7 @@ wxWindow::~wxWindow(void)
if ( m_windowValidator ) if ( m_windowValidator )
delete m_windowValidator; delete m_windowValidator;
// Restore old Window proc, if required // Restore old Window proc, if required
// and remove hWnd <-> wxWindow association // and remove hWnd <-> wxWindow association
UnsubclassWin(); UnsubclassWin();
} }
@@ -381,7 +381,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
m_pDropTarget = NULL; m_pDropTarget = NULL;
#endif #endif
// MSW-specific // MSW-specific
m_hWnd = 0; m_hWnd = 0;
m_winEnabled = TRUE; m_winEnabled = TRUE;
@@ -827,7 +827,7 @@ void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
HWND hWnd = (HWND) GetHWND(); HWND hWnd = (HWND) GetHWND();
HDC dc = ::GetDC(hWnd); HDC dc = ::GetDC(hWnd);
HFONT fnt = 0; HFONT fnt = 0;
HFONT was = 0; HFONT was = 0;
if (fontToUse && fontToUse->Ok()) if (fontToUse && fontToUse->Ok())
{ {
@@ -840,7 +840,7 @@ void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
GetTextExtentPoint(dc, (const char *)string, (int)string.Length(), &sizeRect); GetTextExtentPoint(dc, (const char *)string, (int)string.Length(), &sizeRect);
GetTextMetrics(dc, &tm); GetTextMetrics(dc, &tm);
if (fontToUse && fnt && was) if (fontToUse && fnt && was)
SelectObject(dc,was) ; SelectObject(dc,was) ;
ReleaseDC(hWnd, dc); ReleaseDC(hWnd, dc);
@@ -954,7 +954,7 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
wxLogTrace(wxTraceMessages, "Processing %s(%lx, %lx)", wxLogTrace(wxTraceMessages, "Processing %s(%lx, %lx)",
wxGetMessageName(message), wParam, lParam); wxGetMessageName(message), wParam, lParam);
#endif // WXDEBUG #endif // WXDEBUG
HWND hWnd = (HWND)m_hWnd; HWND hWnd = (HWND)m_hWnd;
switch (message) switch (message)
@@ -1020,7 +1020,7 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
else return MSWDefWindowProc(message, wParam, lParam ); else return MSWDefWindowProc(message, wParam, lParam );
break; break;
} }
case WM_SIZE: case WM_SIZE:
{ {
int width = LOWORD(lParam); int width = LOWORD(lParam);
@@ -1028,7 +1028,7 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
MSWOnSize(width, height, wParam); MSWOnSize(width, height, wParam);
break; break;
} }
case WM_MOVE: case WM_MOVE:
{ {
wxMoveEvent event(wxPoint(LOWORD(lParam), HIWORD(lParam)), wxMoveEvent event(wxPoint(LOWORD(lParam), HIWORD(lParam)),
@@ -1044,7 +1044,7 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
MSWOnWindowPosChanging((void *)lParam); MSWOnWindowPosChanging((void *)lParam);
break; break;
} }
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
{ {
int x = (DIMENSION_TYPE) LOWORD(lParam); int x = (DIMENSION_TYPE) LOWORD(lParam);
@@ -1231,7 +1231,7 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
return MSWOnMeasureItem((int)wParam, (WXMEASUREITEMSTRUCT *)lParam); return MSWOnMeasureItem((int)wParam, (WXMEASUREITEMSTRUCT *)lParam);
break; break;
} }
case WM_KEYDOWN: case WM_KEYDOWN:
// we consider these message "not interesting" // we consider these message "not interesting"
if ( wParam == VK_SHIFT || wParam == VK_CONTROL ) if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
@@ -1435,7 +1435,7 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
return 1L; return 1L;
break; break;
} }
case WM_GETMINMAXINFO: case WM_GETMINMAXINFO:
{ {
MINMAXINFO *info = (MINMAXINFO *)lParam; MINMAXINFO *info = (MINMAXINFO *)lParam;
@@ -1450,7 +1450,7 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
return MSWDefWindowProc(message, wParam, lParam ); return MSWDefWindowProc(message, wParam, lParam );
break; break;
} }
case WM_GETDLGCODE: case WM_GETDLGCODE:
return MSWGetDlgCode(); return MSWGetDlgCode();
@@ -1544,7 +1544,7 @@ void wxWindow::MSWCreate(int id, wxWindow *parent, const char *wclass, wxWindow
m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent, m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent,
(DLGPROC)dlgproc); (DLGPROC)dlgproc);
#endif #endif
if (m_hWnd == 0) if (m_hWnd == 0)
MessageBox(NULL, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.", MessageBox(NULL, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
"wxWindows Error", MB_ICONEXCLAMATION | MB_OK); "wxWindows Error", MB_ICONEXCLAMATION | MB_OK);
@@ -1638,7 +1638,7 @@ bool wxWindow::MSWOnDestroy(void)
m_pDropTarget = NULL; m_pDropTarget = NULL;
} }
#endif #endif
return TRUE; return TRUE;
} }
@@ -1662,7 +1662,7 @@ bool wxWindow::MSWOnNotify(WXWPARAM wParam, WXLPARAM lParam)
NMHDR *hdr = (NMHDR *)lParam; NMHDR *hdr = (NMHDR *)lParam;
HWND hWnd = (HWND)hdr->hwndFrom; HWND hWnd = (HWND)hdr->hwndFrom;
wxWindow *win = wxFindWinFromHandle((WXHWND) hWnd); wxWindow *win = wxFindWinFromHandle((WXHWND) hWnd);
if ( win ) if ( win )
return win->MSWNotify(wParam, lParam); return win->MSWNotify(wParam, lParam);
else else
@@ -1680,7 +1680,7 @@ bool wxWindow::MSWOnNotify(WXWPARAM wParam, WXLPARAM lParam)
} }
return FALSE; return FALSE;
#endif #endif
return FALSE; return FALSE;
} }
@@ -1701,7 +1701,7 @@ bool wxWindow::MSWOnActivate(int state, bool WXUNUSED(minimized), WXHWND WXUNUSE
#if WXDEBUG > 1 #if WXDEBUG > 1
wxDebugMsg("wxWindow::MSWOnActivate %d\n", handle); wxDebugMsg("wxWindow::MSWOnActivate %d\n", handle);
#endif #endif
wxActivateEvent event(wxEVT_ACTIVATE, ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)), wxActivateEvent event(wxEVT_ACTIVATE, ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)),
m_windowId); m_windowId);
event.SetEventObject(this); event.SetEventObject(this);
@@ -1721,7 +1721,7 @@ bool wxWindow::MSWOnSetFocus(WXHWND WXUNUSED(hwnd))
if (m_caretShown) if (m_caretShown)
::ShowCaret((HWND) GetHWND()); ::ShowCaret((HWND) GetHWND());
} }
wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId); wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId);
event.SetEventObject(this); event.SetEventObject(this);
if (!GetEventHandler()->ProcessEvent(event)) if (!GetEventHandler()->ProcessEvent(event))
@@ -1739,7 +1739,7 @@ bool wxWindow::MSWOnKillFocus(WXHWND WXUNUSED(hwnd))
{ {
::DestroyCaret(); ::DestroyCaret();
} }
wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId); wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId);
event.SetEventObject(this); event.SetEventObject(this);
if (!GetEventHandler()->ProcessEvent(event)) if (!GetEventHandler()->ProcessEvent(event))
@@ -1752,7 +1752,7 @@ void wxWindow::MSWOnDropFiles(WXWPARAM wParam)
#if WXDEBUG > 1 #if WXDEBUG > 1
wxDebugMsg("wxWindow::MSWOnDropFiles %d\n", m_hWnd); wxDebugMsg("wxWindow::MSWOnDropFiles %d\n", m_hWnd);
#endif #endif
HDROP hFilesInfo = (HDROP) wParam; HDROP hFilesInfo = (HDROP) wParam;
POINT dropPoint; POINT dropPoint;
DragQueryPoint(hFilesInfo, (LPPOINT) &dropPoint); DragQueryPoint(hFilesInfo, (LPPOINT) &dropPoint);
@@ -1803,7 +1803,7 @@ bool wxWindow::MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct)
); );
} }
#endif // owner-drawn menus #endif // owner-drawn menus
wxWindow *item = FindItem(id); wxWindow *item = FindItem(id);
#if wxUSE_DYNAMIC_CLASSES #if wxUSE_DYNAMIC_CLASSES
if (item && item->IsKindOf(CLASSINFO(wxControl))) if (item && item->IsKindOf(CLASSINFO(wxControl)))
@@ -1823,11 +1823,11 @@ bool wxWindow::MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct)
wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData); wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData);
wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth, return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth,
&pMeasureStruct->itemHeight); &pMeasureStruct->itemHeight);
} }
#endif // owner-drawn menus #endif // owner-drawn menus
wxWindow *item = FindItem(id); wxWindow *item = FindItem(id);
#if wxUSE_DYNAMIC_CLASSES #if wxUSE_DYNAMIC_CLASSES
if (item && item->IsKindOf(CLASSINFO(wxControl))) if (item && item->IsKindOf(CLASSINFO(wxControl)))
@@ -1920,7 +1920,7 @@ void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
event.m_eventObject = win; event.m_eventObject = win;
win->GetEventHandler()->ProcessEvent(event2); win->GetEventHandler()->ProcessEvent(event2);
} }
node = node->Next(); node = node->Next();
} }
} }
@@ -1938,12 +1938,12 @@ long wxWindow::Default()
// Ignore 'fake' events (perhaps generated as a result of a separate real event) // Ignore 'fake' events (perhaps generated as a result of a separate real event)
if (m_lastMsg == 0) if (m_lastMsg == 0)
return 0; return 0;
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
wxLogTrace(wxTraceMessages, "Forwarding %s to DefWindowProc.", wxLogTrace(wxTraceMessages, "Forwarding %s to DefWindowProc.",
wxGetMessageName(m_lastMsg)); wxGetMessageName(m_lastMsg));
#endif // WXDEBUG #endif // WXDEBUG
return this->MSWDefWindowProc(m_lastMsg, m_lastWParam, m_lastLParam); return this->MSWDefWindowProc(m_lastMsg, m_lastWParam, m_lastLParam);
} }
@@ -2065,7 +2065,7 @@ bool wxWindow::MSWOnPaint(void)
m_updateRegion = wxRegion(updateRect.left, updateRect.top, m_updateRegion = wxRegion(updateRect.left, updateRect.top,
updateRect.right - updateRect.left, updateRect.bottom - updateRect.top); updateRect.right - updateRect.left, updateRect.bottom - updateRect.top);
#endif #endif
wxPaintEvent event(m_windowId); wxPaintEvent event(m_windowId);
event.SetEventObject(this); event.SetEventObject(this);
if (!GetEventHandler()->ProcessEvent(event)) if (!GetEventHandler()->ProcessEvent(event))
@@ -2117,7 +2117,7 @@ bool wxWindow::MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control)
sprintf(buf, "Looking for item %d...\n", id); sprintf(buf, "Looking for item %d...\n", id);
wxDebugMsg(buf); wxDebugMsg(buf);
#endif #endif
wxWindow *item = FindItem(id); wxWindow *item = FindItem(id);
if (item) if (item)
{ {
@@ -2506,7 +2506,7 @@ void wxWindow::MSWOnJoyDown(int joystick, int x, int y, WXUINT flags)
change = wxJOY_BUTTON3; change = wxJOY_BUTTON3;
if (flags & JOY_BUTTON4CHG) if (flags & JOY_BUTTON4CHG)
change = wxJOY_BUTTON4; change = wxJOY_BUTTON4;
if (flags & JOY_BUTTON1) if (flags & JOY_BUTTON1)
buttons |= wxJOY_BUTTON1; buttons |= wxJOY_BUTTON1;
if (flags & JOY_BUTTON2) if (flags & JOY_BUTTON2)
@@ -2515,11 +2515,11 @@ void wxWindow::MSWOnJoyDown(int joystick, int x, int y, WXUINT flags)
buttons |= wxJOY_BUTTON3; buttons |= wxJOY_BUTTON3;
if (flags & JOY_BUTTON4) if (flags & JOY_BUTTON4)
buttons |= wxJOY_BUTTON4; buttons |= wxJOY_BUTTON4;
wxJoystickEvent event(wxEVT_JOY_BUTTON_DOWN, buttons, joystick, change); wxJoystickEvent event(wxEVT_JOY_BUTTON_DOWN, buttons, joystick, change);
event.SetPosition(wxPoint(x, y)); event.SetPosition(wxPoint(x, y));
event.SetEventObject(this); event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
} }
@@ -2535,7 +2535,7 @@ void wxWindow::MSWOnJoyUp(int joystick, int x, int y, WXUINT flags)
change = wxJOY_BUTTON3; change = wxJOY_BUTTON3;
if (flags & JOY_BUTTON4CHG) if (flags & JOY_BUTTON4CHG)
change = wxJOY_BUTTON4; change = wxJOY_BUTTON4;
if (flags & JOY_BUTTON1) if (flags & JOY_BUTTON1)
buttons |= wxJOY_BUTTON1; buttons |= wxJOY_BUTTON1;
if (flags & JOY_BUTTON2) if (flags & JOY_BUTTON2)
@@ -2544,11 +2544,11 @@ void wxWindow::MSWOnJoyUp(int joystick, int x, int y, WXUINT flags)
buttons |= wxJOY_BUTTON3; buttons |= wxJOY_BUTTON3;
if (flags & JOY_BUTTON4) if (flags & JOY_BUTTON4)
buttons |= wxJOY_BUTTON4; buttons |= wxJOY_BUTTON4;
wxJoystickEvent event(wxEVT_JOY_BUTTON_UP, buttons, joystick, change); wxJoystickEvent event(wxEVT_JOY_BUTTON_UP, buttons, joystick, change);
event.SetPosition(wxPoint(x, y)); event.SetPosition(wxPoint(x, y));
event.SetEventObject(this); event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
} }
@@ -2563,11 +2563,11 @@ void wxWindow::MSWOnJoyMove(int joystick, int x, int y, WXUINT flags)
buttons |= wxJOY_BUTTON3; buttons |= wxJOY_BUTTON3;
if (flags & JOY_BUTTON4) if (flags & JOY_BUTTON4)
buttons |= wxJOY_BUTTON4; buttons |= wxJOY_BUTTON4;
wxJoystickEvent event(wxEVT_JOY_MOVE, buttons, joystick, 0); wxJoystickEvent event(wxEVT_JOY_MOVE, buttons, joystick, 0);
event.SetPosition(wxPoint(x, y)); event.SetPosition(wxPoint(x, y));
event.SetEventObject(this); event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
} }
@@ -2582,11 +2582,11 @@ void wxWindow::MSWOnJoyZMove(int joystick, int z, WXUINT flags)
buttons |= wxJOY_BUTTON3; buttons |= wxJOY_BUTTON3;
if (flags & JOY_BUTTON4) if (flags & JOY_BUTTON4)
buttons |= wxJOY_BUTTON4; buttons |= wxJOY_BUTTON4;
wxJoystickEvent event(wxEVT_JOY_ZMOVE, buttons, joystick, 0); wxJoystickEvent event(wxEVT_JOY_ZMOVE, buttons, joystick, 0);
event.SetZPosition(z); event.SetZPosition(z);
event.SetEventObject(this); event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
} }
@@ -2640,7 +2640,7 @@ void wxWindow::MSWOnVScroll(WXWORD wParam, WXWORD pos, WXHWND control)
return; return;
break; break;
} }
if (!GetEventHandler()->ProcessEvent(event)) if (!GetEventHandler()->ProcessEvent(event))
Default(); Default();
} }
@@ -3086,14 +3086,14 @@ void wxWindow::WarpPointer (int x_pos, int y_pos)
// Move the pointer to (x_pos,y_pos) coordinates. They are expressed in // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
// pixel coordinates, relatives to the canvas -- So, we first need to // pixel coordinates, relatives to the canvas -- So, we first need to
// substract origin of the window, then convert to screen position // substract origin of the window, then convert to screen position
int x = x_pos; int y = y_pos; int x = x_pos; int y = y_pos;
RECT rect; RECT rect;
GetWindowRect ((HWND) GetHWND(), &rect); GetWindowRect ((HWND) GetHWND(), &rect);
x += rect.left; x += rect.left;
y += rect.top; y += rect.top;
SetCursorPos (x, y); SetCursorPos (x, y);
} }
@@ -3104,11 +3104,11 @@ void wxWindow::MSWDeviceToLogical (float *x, float *y) const
bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC) bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC)
{ {
wxDC dc ; wxDC dc ;
dc.SetHDC(pDC); dc.SetHDC(pDC);
dc.SetWindow(this); dc.SetWindow(this);
dc.BeginDrawing(); dc.BeginDrawing();
wxEraseEvent event(m_windowId, &dc); wxEraseEvent event(m_windowId, &dc);
event.m_eventObject = this; event.m_eventObject = this;
if (!GetEventHandler()->ProcessEvent(event)) if (!GetEventHandler()->ProcessEvent(event))
@@ -3122,7 +3122,7 @@ bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC)
dc.EndDrawing(); dc.EndDrawing();
dc.SelectOldObjects(pDC); dc.SelectOldObjects(pDC);
} }
dc.SetHDC((WXHDC) NULL); dc.SetHDC((WXHDC) NULL);
return TRUE; return TRUE;
} }
@@ -3155,7 +3155,7 @@ void wxWindow::OnEraseBackground(wxEraseEvent& event)
void wxWindow::SetScrollRange(int orient, int range, bool refresh) void wxWindow::SetScrollRange(int orient, int range, bool refresh)
{ {
#if defined(__WIN95__) #if defined(__WIN95__)
int range1 = range; int range1 = range;
// Try to adjust the range to cope with page size > 1 // Try to adjust the range to cope with page size > 1
@@ -3315,7 +3315,7 @@ int wxWindow::GetScrollRange(int orient) const
// October 10th: new range concept. // October 10th: new range concept.
maxPos += pageSize; maxPos += pageSize;
#endif #endif
return maxPos; return maxPos;
} }
else else
@@ -3373,7 +3373,7 @@ SetScrollPage(orient, thumbVisible, FALSE);
int oldRange = range - thumbVisible ; int oldRange = range - thumbVisible ;
SetScrollRange(orient, oldRange, FALSE); SetScrollRange(orient, oldRange, FALSE);
SetScrollPos(orient, pos, refresh); SetScrollPos(orient, pos, refresh);
*/ */
#if defined(__WIN95__) #if defined(__WIN95__)
@@ -3439,7 +3439,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRectangle *rect)
rect2.right = rect->x + rect->width; rect2.right = rect->x + rect->width;
rect2.bottom = rect->y + rect->height; rect2.bottom = rect->y + rect->height;
} }
if ( rect ) if ( rect )
::ScrollWindow((HWND) GetHWND(), dx, dy, &rect2, NULL); ::ScrollWindow((HWND) GetHWND(), dx, dy, &rect2, NULL);
else else
@@ -3475,7 +3475,7 @@ void wxWindow::SubclassWin(WXHWND hWnd)
void wxWindow::UnsubclassWin(void) void wxWindow::UnsubclassWin(void)
{ {
wxRemoveHandleAssociation(this); wxRemoveHandleAssociation(this);
// Restore old Window proc // Restore old Window proc
if ((HWND) GetHWND()) if ((HWND) GetHWND())
{ {
@@ -3494,7 +3494,7 @@ WXDWORD wxWindow::MakeExtendedStyle(long style, bool eliminateBorders)
WXDWORD exStyle = 0; WXDWORD exStyle = 0;
if ( style & wxTRANSPARENT_WINDOW ) if ( style & wxTRANSPARENT_WINDOW )
exStyle |= WS_EX_TRANSPARENT ; exStyle |= WS_EX_TRANSPARENT ;
if ( !eliminateBorders ) if ( !eliminateBorders )
{ {
if ( style & wxSUNKEN_BORDER ) if ( style & wxSUNKEN_BORDER )
@@ -3554,7 +3554,7 @@ WXDWORD wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D)
if ( *want3D ) if ( *want3D )
nativeBorder = FALSE; nativeBorder = FALSE;
#endif #endif
DWORD exStyle = MakeExtendedStyle(m_windowStyle, !nativeBorder); DWORD exStyle = MakeExtendedStyle(m_windowStyle, !nativeBorder);
// If we want 3D, but haven't specified a border here, // If we want 3D, but haven't specified a border here,
@@ -3565,7 +3565,7 @@ WXDWORD wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D)
(m_windowStyle & wxSTATIC_BORDER) || (m_windowStyle & wxSIMPLE_BORDER) )) (m_windowStyle & wxSTATIC_BORDER) || (m_windowStyle & wxSIMPLE_BORDER) ))
exStyle |= defaultBorderStyle; // WS_EX_CLIENTEDGE ; exStyle |= defaultBorderStyle; // WS_EX_CLIENTEDGE ;
#endif #endif
return exStyle; return exStyle;
} }
@@ -3579,13 +3579,13 @@ void wxWindow::OnChar(wxKeyEvent& event)
return; return;
} }
} }
bool isVirtual; bool isVirtual;
int id = wxCharCodeWXToMSW((int)event.KeyCode(), &isVirtual); int id = wxCharCodeWXToMSW((int)event.KeyCode(), &isVirtual);
if ( id == -1 ) if ( id == -1 )
id= m_lastWParam; id= m_lastWParam;
if ( !event.ControlDown() ) if ( !event.ControlDown() )
(void) MSWDefWindowProc(m_lastMsg, (WPARAM) id, m_lastLParam); (void) MSWDefWindowProc(m_lastMsg, (WPARAM) id, m_lastLParam);
} }
@@ -3621,7 +3621,7 @@ bool wxWindow::TransferDataToWindow(void)
wxMessageBox("Application Error", "Could not transfer data to window", wxOK|wxICON_EXCLAMATION); wxMessageBox("Application Error", "Could not transfer data to window", wxOK|wxICON_EXCLAMATION);
return FALSE; return FALSE;
} }
node = node->Next(); node = node->Next();
} }
return TRUE; return TRUE;
@@ -3639,7 +3639,7 @@ bool wxWindow::TransferDataFromWindow(void)
{ {
return FALSE; return FALSE;
} }
node = node->Next(); node = node->Next();
} }
return TRUE; return TRUE;
@@ -3655,7 +3655,7 @@ bool wxWindow::Validate(void)
{ {
return FALSE; return FALSE;
} }
node = node->Next(); node = node->Next();
} }
return TRUE; return TRUE;
@@ -4187,9 +4187,9 @@ void wxWindow::OnDefaultAction(wxControl *initiatingItem)
event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt); event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
} }
event.m_eventObject = lbox; event.m_eventObject = lbox;
lbox->ProcessCommand(event); lbox->ProcessCommand(event);
if (event.m_commandString) if (event.m_commandString)
delete[] event.m_commandString; delete[] event.m_commandString;
return; return;
@@ -4229,7 +4229,7 @@ void wxWindow::Fit(void)
maxX = wx + ww; maxX = wx + ww;
if ( wy + wh > maxY ) if ( wy + wh > maxY )
maxY = wy + wh; maxY = wy + wh;
node = node->Next(); node = node->Next();
} }
SetClientSize(maxX + 5, maxY + 5); SetClientSize(maxX + 5, maxY + 5);
@@ -4240,7 +4240,7 @@ void wxWindow::SetValidator(const wxValidator& validator)
if ( m_windowValidator ) if ( m_windowValidator )
delete m_windowValidator; delete m_windowValidator;
m_windowValidator = validator.Clone(); m_windowValidator = validator.Clone();
if ( m_windowValidator ) if ( m_windowValidator )
m_windowValidator->SetWindow(this) ; m_windowValidator->SetWindow(this) ;
} }
@@ -4250,7 +4250,7 @@ wxWindow *wxWindow::FindWindow(long id)
{ {
if ( GetId() == id) if ( GetId() == id)
return this; return this;
wxNode *node = GetChildren()->First(); wxNode *node = GetChildren()->First();
while ( node ) while ( node )
{ {
@@ -4267,7 +4267,7 @@ wxWindow *wxWindow::FindWindow(const wxString& name)
{ {
if ( GetName() == name) if ( GetName() == name)
return this; return this;
wxNode *node = GetChildren()->First(); wxNode *node = GetChildren()->First();
while ( node ) while ( node )
{ {
@@ -4303,7 +4303,7 @@ int y_pages = 0;
// Bugfix begin // Bugfix begin
if (vert_units) if (vert_units)
y_pages = (int)(v_height/vert_units) - y_page; y_pages = (int)(v_height/vert_units) - y_page;
#ifdef __WXMSW__ #ifdef __WXMSW__
int y = 0; int y = 0;
#else #else
@@ -4400,17 +4400,17 @@ void wxWindow::OnIdle(wxIdleEvent& event)
{ {
// Generate a LEAVE event // Generate a LEAVE event
m_mouseInWindow = FALSE; m_mouseInWindow = FALSE;
int state = 0; int state = 0;
if (::GetKeyState(VK_SHIFT) != 0) if (::GetKeyState(VK_SHIFT) != 0)
state |= MK_SHIFT; state |= MK_SHIFT;
if (::GetKeyState(VK_CONTROL) != 0) if (::GetKeyState(VK_CONTROL) != 0)
state |= MK_CONTROL; state |= MK_CONTROL;
// Unfortunately the mouse button and keyboard state may have changed // Unfortunately the mouse button and keyboard state may have changed
// by the time the OnIdle function is called, so 'state' may be // by the time the OnIdle function is called, so 'state' may be
// meaningless. // meaningless.
MSWOnMouseLeave(pt.x, pt.y, state); MSWOnMouseLeave(pt.x, pt.y, state);
} }
} }
@@ -4518,7 +4518,7 @@ const char *wxGetMessageName(int message)
case 0x0046: return "WM_WINDOWPOSCHANGING"; case 0x0046: return "WM_WINDOWPOSCHANGING";
case 0x0047: return "WM_WINDOWPOSCHANGED"; case 0x0047: return "WM_WINDOWPOSCHANGED";
case 0x0048: return "WM_POWER"; case 0x0048: return "WM_POWER";
#ifdef __WIN32__ #ifdef __WIN32__
case 0x004A: return "WM_COPYDATA"; case 0x004A: return "WM_COPYDATA";
case 0x004B: return "WM_CANCELJOURNAL"; case 0x004B: return "WM_CANCELJOURNAL";
@@ -4536,7 +4536,7 @@ const char *wxGetMessageName(int message)
case 0x007F: return "WM_GETICON"; case 0x007F: return "WM_GETICON";
case 0x0080: return "WM_SETICON"; case 0x0080: return "WM_SETICON";
#endif //WIN32 #endif //WIN32
case 0x0081: return "WM_NCCREATE"; case 0x0081: return "WM_NCCREATE";
case 0x0082: return "WM_NCDESTROY"; case 0x0082: return "WM_NCDESTROY";
case 0x0083: return "WM_NCCALCSIZE"; case 0x0083: return "WM_NCCALCSIZE";
@@ -4563,13 +4563,13 @@ const char *wxGetMessageName(int message)
case 0x0106: return "WM_SYSCHAR"; case 0x0106: return "WM_SYSCHAR";
case 0x0107: return "WM_SYSDEADCHAR"; case 0x0107: return "WM_SYSDEADCHAR";
case 0x0108: return "WM_KEYLAST"; case 0x0108: return "WM_KEYLAST";
#ifdef __WIN32__ #ifdef __WIN32__
case 0x010D: return "WM_IME_STARTCOMPOSITION"; case 0x010D: return "WM_IME_STARTCOMPOSITION";
case 0x010E: return "WM_IME_ENDCOMPOSITION"; case 0x010E: return "WM_IME_ENDCOMPOSITION";
case 0x010F: return "WM_IME_COMPOSITION"; case 0x010F: return "WM_IME_COMPOSITION";
#endif //WIN32 #endif //WIN32
case 0x0110: return "WM_INITDIALOG"; case 0x0110: return "WM_INITDIALOG";
case 0x0111: return "WM_COMMAND"; case 0x0111: return "WM_COMMAND";
case 0x0112: return "WM_SYSCOMMAND"; case 0x0112: return "WM_SYSCOMMAND";
@@ -4594,7 +4594,7 @@ const char *wxGetMessageName(int message)
case 0x0210: return "WM_PARENTNOTIFY"; case 0x0210: return "WM_PARENTNOTIFY";
case 0x0211: return "WM_ENTERMENULOOP"; case 0x0211: return "WM_ENTERMENULOOP";
case 0x0212: return "WM_EXITMENULOOP"; case 0x0212: return "WM_EXITMENULOOP";
#ifdef __WIN32__ #ifdef __WIN32__
case 0x0213: return "WM_NEXTMENU"; case 0x0213: return "WM_NEXTMENU";
case 0x0214: return "WM_SIZING"; case 0x0214: return "WM_SIZING";
@@ -4603,7 +4603,7 @@ const char *wxGetMessageName(int message)
case 0x0218: return "WM_POWERBROADCAST"; case 0x0218: return "WM_POWERBROADCAST";
case 0x0219: return "WM_DEVICECHANGE"; case 0x0219: return "WM_DEVICECHANGE";
#endif //WIN32 #endif //WIN32
case 0x0220: return "WM_MDICREATE"; case 0x0220: return "WM_MDICREATE";
case 0x0221: return "WM_MDIDESTROY"; case 0x0221: return "WM_MDIDESTROY";
case 0x0222: return "WM_MDIACTIVATE"; case 0x0222: return "WM_MDIACTIVATE";
@@ -4616,7 +4616,7 @@ const char *wxGetMessageName(int message)
case 0x0229: return "WM_MDIGETACTIVE"; case 0x0229: return "WM_MDIGETACTIVE";
case 0x0230: return "WM_MDISETMENU"; case 0x0230: return "WM_MDISETMENU";
case 0x0233: return "WM_DROPFILES"; case 0x0233: return "WM_DROPFILES";
#ifdef __WIN32__ #ifdef __WIN32__
case 0x0281: return "WM_IME_SETCONTEXT"; case 0x0281: return "WM_IME_SETCONTEXT";
case 0x0282: return "WM_IME_NOTIFY"; case 0x0282: return "WM_IME_NOTIFY";
@@ -4627,7 +4627,7 @@ const char *wxGetMessageName(int message)
case 0x0290: return "WM_IME_KEYDOWN"; case 0x0290: return "WM_IME_KEYDOWN";
case 0x0291: return "WM_IME_KEYUP"; case 0x0291: return "WM_IME_KEYUP";
#endif //WIN32 #endif //WIN32
case 0x0300: return "WM_CUT"; case 0x0300: return "WM_CUT";
case 0x0301: return "WM_COPY"; case 0x0301: return "WM_COPY";
case 0x0302: return "WM_PASTE"; case 0x0302: return "WM_PASTE";
@@ -4646,7 +4646,7 @@ const char *wxGetMessageName(int message)
case 0x030F: return "WM_QUERYNEWPALETTE"; case 0x030F: return "WM_QUERYNEWPALETTE";
case 0x0310: return "WM_PALETTEISCHANGING"; case 0x0310: return "WM_PALETTEISCHANGING";
case 0x0311: return "WM_PALETTECHANGED"; case 0x0311: return "WM_PALETTECHANGED";
#ifdef __WIN32__ #ifdef __WIN32__
// common controls messages - although they're not strictly speaking // common controls messages - although they're not strictly speaking
// standard, it's nice to decode them nevertheless // standard, it's nice to decode them nevertheless
@@ -4729,7 +4729,7 @@ const char *wxGetMessageName(int message)
case 0x1000 + 63: return "LVM_GETHOTCURSOR"; case 0x1000 + 63: return "LVM_GETHOTCURSOR";
case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT"; case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
case 0x1000 + 65: return "LVM_SETWORKAREA"; case 0x1000 + 65: return "LVM_SETWORKAREA";
// tree view // tree view
case 0x1100 + 0: return "TVM_INSERTITEMA"; case 0x1100 + 0: return "TVM_INSERTITEMA";
case 0x1100 + 50: return "TVM_INSERTITEMW"; case 0x1100 + 50: return "TVM_INSERTITEMW";
@@ -4761,7 +4761,7 @@ const char *wxGetMessageName(int message)
case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW"; case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
case 0x1100 + 24: return "TVM_SETTOOLTIPS"; case 0x1100 + 24: return "TVM_SETTOOLTIPS";
case 0x1100 + 25: return "TVM_GETTOOLTIPS"; case 0x1100 + 25: return "TVM_GETTOOLTIPS";
// header // header
case 0x1200 + 0: return "HDM_GETITEMCOUNT"; case 0x1200 + 0: return "HDM_GETITEMCOUNT";
case 0x1200 + 1: return "HDM_INSERTITEMA"; case 0x1200 + 1: return "HDM_INSERTITEMA";
@@ -4781,7 +4781,7 @@ const char *wxGetMessageName(int message)
case 0x1200 + 17: return "HDM_GETORDERARRAY"; case 0x1200 + 17: return "HDM_GETORDERARRAY";
case 0x1200 + 18: return "HDM_SETORDERARRAY"; case 0x1200 + 18: return "HDM_SETORDERARRAY";
case 0x1200 + 19: return "HDM_SETHOTDIVIDER"; case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
// tab control // tab control
case 0x1300 + 2: return "TCM_GETIMAGELIST"; case 0x1300 + 2: return "TCM_GETIMAGELIST";
case 0x1300 + 3: return "TCM_SETIMAGELIST"; case 0x1300 + 3: return "TCM_SETIMAGELIST";
@@ -4810,7 +4810,7 @@ const char *wxGetMessageName(int message)
case 0x1300 + 48: return "TCM_SETCURFOCUS"; case 0x1300 + 48: return "TCM_SETCURFOCUS";
case 0x1300 + 49: return "TCM_SETMINTABWIDTH"; case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
case 0x1300 + 50: return "TCM_DESELECTALL"; case 0x1300 + 50: return "TCM_DESELECTALL";
// toolbar // toolbar
case WM_USER+1: return "TB_ENABLEBUTTON"; case WM_USER+1: return "TB_ENABLEBUTTON";
case WM_USER+2: return "TB_CHECKBUTTON"; case WM_USER+2: return "TB_CHECKBUTTON";
@@ -4868,13 +4868,13 @@ const char *wxGetMessageName(int message)
case WM_USER+60: return "TB_SETMAXTEXTROWS"; case WM_USER+60: return "TB_SETMAXTEXTROWS";
case WM_USER+61: return "TB_GETTEXTROWS"; case WM_USER+61: return "TB_GETTEXTROWS";
case WM_USER+41: return "TB_GETBITMAPFLAGS"; case WM_USER+41: return "TB_GETBITMAPFLAGS";
#endif //WIN32 #endif //WIN32
default: default:
static char s_szBuf[128]; static char s_szBuf[128];
sprintf(s_szBuf, "<unknown message = %d>", message); sprintf(s_szBuf, "<unknown message = %d>", message);
return s_szBuf; return s_szBuf;
} }
} }
#endif //WXDEBUG #endif //WXDEBUG