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,12 +75,19 @@ 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)
{ {
if ( IsEnabled() ) {
wxLog *pLogger = GetActiveTarget(); wxLog *pLogger = GetActiveTarget();
if ( pLogger ) 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

@@ -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

@@ -151,6 +151,13 @@ 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

View File

@@ -210,33 +210,5 @@ private:
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
@@ -799,6 +802,8 @@ void wxLogWindow::OnFrameDelete(wxFrame *WXUNUSED(frame))
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

@@ -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);

View File

@@ -86,12 +86,13 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
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

@@ -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

@@ -125,17 +125,24 @@ 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), HWND the_handle = (HWND) parent->GetHWND() ;
m_hWnd = (WXHWND)::CreateWindowEx
(
(DWORD)exStyle,
GROUP_CLASS,
title,
msStyle, msStyle,
0, 0, 0, 0, 0, 0, 0, 0,
(HWND) parent->GetHWND(), (HMENU) m_windowId, wxGetInstance(), NULL) ; the_handle,
(HMENU)m_windowId,
HWND the_handle = (HWND) parent->GetHWND() ; wxGetInstance(),
NULL
);
#if CTL3D #if CTL3D
if (want3D) if (want3D)
@@ -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),

View File

@@ -72,13 +72,15 @@ 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)
{ {
@@ -211,6 +213,9 @@ 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))
{ {

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

@@ -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;
} }

View File

@@ -129,6 +129,7 @@ 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
@@ -146,15 +147,13 @@ 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
#endif
m_isRich = FALSE; m_isRich = FALSE;
bool want3D; bool want3D;
@@ -172,30 +171,30 @@ bool wxTextCtrl::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 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
@@ -214,8 +213,10 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
// 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;

View File

@@ -9,6 +9,14 @@
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "timer.h" #pragma implementation "timer.h"
#endif #endif
@@ -26,6 +34,9 @@
#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"
@@ -35,19 +46,35 @@
#if !defined(__SC__) && !defined(__GNUWIN32__) #if !defined(__SC__) && !defined(__GNUWIN32__)
#include <sys/timeb.h> #include <sys/timeb.h>
#endif #endif
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
wxList wxTimerList(wxKEY_INTEGER);
UINT WINAPI _EXPORT wxTimerProc(HWND hwnd, WORD, int idTimer, DWORD);
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
#ifdef __WIN32__ #ifdef __WIN32__
#define _EXPORT /**/ #define _EXPORT /**/
#else #else
#define _EXPORT _export #define _EXPORT _export
#endif #endif
wxList wxTimerList(wxKEY_INTEGER);
UINT WINAPI _EXPORT wxTimerProc(HWND hwnd, WORD, int idTimer, DWORD);
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
#endif #endif
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// wxTimer class
// ----------------------------------------------------------------------------
wxTimer::wxTimer(void) wxTimer::wxTimer(void)
{ {
milli = 0 ; milli = 0 ;
@@ -68,22 +95,28 @@ bool wxTimer::Start(int milliseconds,bool 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),
(UINT)milliseconds, wxTimerProcInst);
if (id > 0) if (id > 0)
{ {
wxTimerList.Append(id, this); wxTimerList.Append(id, this);
return TRUE; return TRUE;
} }
else return FALSE; else
{
wxLogSysError(_("Couldn't create a timer"));
return FALSE;
}
} }
void wxTimer::Stop(void) void wxTimer::Stop(void)
@@ -96,18 +129,28 @@ void wxTimer::Stop(void)
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)
{ wxCHECK_MSG( node, 0, "bogus timer id in wxTimerProc" );
wxTimer *timer = (wxTimer *)node->Data();
if (timer->id==0) wxProcessTimer(*(wxTimer *)node->Data());
return(0) ; // Avoid to process spurious timer events
if (timer->oneShot)
timer->Stop() ;
timer->Notify();
}
return 0; return 0;
} }