// ctor
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
static void OnLog(wxLogLevel level, const char *szString)
{
- wxLog *pLogger = GetActiveTarget();
- if ( pLogger )
- {
- pLogger->DoLog(level, szString);
+ if ( IsEnabled() ) {
+ wxLog *pLogger = GetActiveTarget();
+ if ( pLogger )
+ pLogger->DoLog(level, szString);
}
}
// get current log target, will call wxApp::CreateLogTarget() to create one
// if none exists
static wxLog *GetActiveTarget();
- // change log target, pLogger = NULL disables logging. if bNoFlashOld is true,
- // the old log target isn't flashed which might lead to loss of messages!
- // returns the previous log target
- static wxLog *SetActiveTarget(wxLog *pLogger, bool bNoFlashOld = FALSE);
+ // change log target, pLogger may be NULL
+ static wxLog *SetActiveTarget(wxLog *pLogger);
// functions controlling the default wxLog behaviour
// verbose mode is activated by standard command-line '-verbose' option
// static variables
// ----------------
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 wxTraceMask ms_ulTraceMask; // controls wxLogTrace behaviour
};
class WXDLLEXPORT wxLogNull
{
public:
- // ctor saves old log target, dtor restores it
- wxLogNull() { m_pPrevLogger = wxLog::SetActiveTarget((wxLog *)NULL, TRUE); }
- ~wxLogNull() { (void)wxLog::SetActiveTarget(m_pPrevLogger); }
+ wxLogNull() { m_flagOld = wxLog::EnableLogging(FALSE); }
+ ~wxLogNull() { (void)wxLog::EnableLogging(m_flagOld); }
private:
- wxLog *m_pPrevLogger; // old log target
+ bool m_flagOld; // the previous value of the wxLog::ms_doLog
};
// ============================================================================
void OnEndSession(wxCloseEvent& event);
void OnQueryEndSession(wxCloseEvent& event);
-// Generic
+ // Generic
virtual bool OnInit() { return FALSE; };
// No specific tasks to do here.
virtual int OnRun() { return MainLoop(); };
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 int GetPrintMode() const { return m_printMode; }
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PRIVATE_H_
# endif
#endif
-#if !defined(APIENTRY) // NT defines APIENTRY, 3.x not
+#if !defined(APIENTRY) // NT defines APIENTRY, 3.x not
#define APIENTRY FAR PASCAL
#endif
-
+
#ifdef __WIN32__
#define _EXPORT /**/
#else
#define _EXPORT _export
typedef signed short int SHORT ;
#endif
-
-#if !defined(__WIN32__) // 3.x uses FARPROC for dialogs
+
+#if !defined(__WIN32__) // 3.x uses FARPROC for dialogs
#define DLGPROC FARPROC
#endif
* Decide what window classes we're going to use
* for this combination of CTl3D/FAFA settings
*/
-
+
#define STATIC_CLASS "STATIC"
#define STATIC_FLAGS (SS_LEFT|WS_CHILD|WS_VISIBLE)
#define CHECK_CLASS "BUTTON"
// Safely get the window text (i.e. without using fixed size buffer)
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)
-#define WS_EX_CLIENTEDGE 0
+ #define WS_EX_CLIENTEDGE 0
#endif
#endif
wxRegKey(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)
wxString m_strKey; // key name (relative to m_hRootKey)
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
#define wxUSE_SCROLLBAR 1
// Define 1 to compile contributed wxScrollBar class
#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,
// separated by platform. If 1, you must link in
// the XPM library to your applications.
#define wxUSE_IMAGE_LOADING_IN_MSW 1
// 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
// under MSW.
#define wxUSE_WX_RESOURCES 1
#define wxUSE_DYNAMIC_CLASSES 1
// If 1, enables provision of run-time type information.
// NOW MANDATORY: don't change.
-#define wxUSE_MEMORY_TRACING 1
+#define wxUSE_MEMORY_TRACING 0
// If 1, enables debugging versions of wxObject::new and
// wxObject::delete *IF* WXDEBUG is also defined.
// WARNING: this code may not work with all architectures, especially
// if alignment is an issue.
-#define wxUSE_DEBUG_CONTEXT 1
+#define wxUSE_DEBUG_CONTEXT 0
// If 1, enables wxDebugContext, for
// writing error messages to file, etc.
// If WXDEBUG is not defined, will still use
// since you may well need to output
// an error log in a production
// 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.
// If this causes problems (e.g. link errors), set this to 0.
#define wxUSE_C_MAIN 0
// 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 wxUSE_IOSTREAMH 1
#define wxUSE_PENWINDOWS 0
// Set to 1 to use PenWindows
-#define wxUSE_OWNER_DRAWN 0
+#define wxUSE_OWNER_DRAWN 1
// Owner-drawn menus and listboxes
#define wxUSE_NATIVE_STATUSBAR 1
class WXDLLEXPORT wxTimer : public wxObject
{
+friend void wxProcessTimer(wxTimer& timer);
+
public:
wxTimer();
~wxTimer();
int Interval() const { return milli; };
bool OneShot() const { return oneShot; }
-public:
+protected:
bool oneShot ;
int milli ;
int lastMilli ;
// Default Icons
//
-wxDEFAULT_FRAME ICON "wx/msw/std.ico"
-wxDEFAULT_MDIPARENTFRAME ICON "wx/msw/mdi.ico"
-wxDEFAULT_MDICHILDFRAME ICON "wx/msw/child.ico"
+//wxDEFAULT_FRAME ICON "wx/msw/std.ico"
+//wxDEFAULT_MDIPARENTFRAME ICON "wx/msw/mdi.ico"
+//wxDEFAULT_MDICHILDFRAME ICON "wx/msw/child.ico"
//////////////////////////////////////////////////////////////////////////////
//
ms_pLogger = wxTheApp->CreateLogTarget();
#endif
+ s_bInGetActiveTarget = FALSE;
+
// do nothing if it fails - what can we do?
}
}
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) && !bNoFlashOld ) {
+ if ( ms_pLogger != NULL ) {
+ // flush the old messages before changing because otherwise they might
+ // get lost later if this target is not restored
ms_pLogger->Flush();
}
wxLog *pOldLogger = ms_pLogger;
ms_pLogger = pLogger;
+
return pOldLogger;
}
pText->WriteText(szString);
pText->WriteText("\n"); // "\n" ok here (_not_ "\r\n")
- // ensure that the line can be seen
- // @@@ TODO
+ // TODO ensure that the line can be seen
}
wxFrame *wxLogWindow::GetFrame() const
void wxLogWindow::OnFrameDelete(wxFrame *WXUNUSED(frame))
{
- m_pLogFrame = (wxLogFrame *) NULL;
+ m_pLogFrame = (wxLogFrame *)NULL;
}
wxLogWindow::~wxLogWindow()
{
+ delete m_pOldLog;
+
// may be NULL if log frame already auto destroyed itself
delete m_pLogFrame;
}
// static variables
// ----------------------------------------------------------------------------
wxLog *wxLog::ms_pLogger = (wxLog *) NULL;
+bool wxLog::ms_doLog = TRUE;
bool wxLog::ms_bAutoCreate = TRUE;
wxTraceMask wxLog::ms_ulTraceMask = (wxTraceMask)0;
if ( s_bInAssert ) {
// He-e-e-e-elp!! we're trapped in endless loop
Trap();
+
+ return;
}
s_bInAssert = TRUE;
#endif
// use debug CRT functions for memory leak detections in VC++
-/* This still doesn't work for me, Vadim.
#if defined(__WXDEBUG__) && defined(_MSC_VER)
// VC++ uses this macro as debug/release mode indicator
#ifndef _DEBUG
#include <crtdbg.h>
#endif
-*/
extern char *wxBuffer;
extern char *wxOsVersion;
{
wxBuffer = new char[1500];
-/*
#if defined(__WXDEBUG__) && defined(_MSC_VER)
// do check for memory leaks on program exit
// (another useful flag is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free
// deallocated memory which may be used to simulate low-memory condition)
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
#endif // debug build under MS VC++
-*/
#if (WXDEBUG && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
#if defined(_WINDLL)
int count = 0;
// Get application name
- char name[500];
+ char name[260]; // 260 is MAX_PATH value from windef.h
::GetModuleFileName(wxhInstance, name, WXSIZEOF(name));
// GNUWIN32 already fills in the first arg with the application name.
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
- if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)))
+ if ( want3D || wxStyleHasBorder(m_windowStyle) )
msStyle |= WS_BORDER;
m_hWnd = (WXHWND)CreateWindowEx(exStyle, "BUTTON", Label,
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
- int n, const wxString choices[],
- long style,
+ int n, const wxString choices[],
+ long style,
const wxValidator& validator,
const wxString& name)
{
m_windowStyle = style;
if ( id == -1 )
- m_windowId = (int)NewControlId();
+ m_windowId = (int)NewControlId();
else
- m_windowId = id;
+ m_windowId = id;
int x = pos.x;
int y = pos.y;
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
- if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
+ if ( want3D || wxStyleHasBorder(m_windowStyle) )
msStyle |= WS_BORDER;
- HWND wx_combo = CreateWindowEx(exStyle, "COMBOBOX", NULL,
+ m_hWnd = (WXHWND)::CreateWindowEx(exStyle, "COMBOBOX", NULL,
msStyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL);
+
+ wxCHECK_MSG( m_hWnd, FALSE, "Failed to create combobox" );
+
/*
#if CTL3D
if (want3D)
#endif
*/
- m_hWnd = (WXHWND) wx_combo;
-
// Subclass again for purposes of dialog editing mode
- SubclassWin((WXHWND) wx_combo);
+ SubclassWin(m_hWnd);
SetFont(* parent->GetFont());
int 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);
}
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)
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
}
bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
- const wxString& value,
- const wxPoint& pos,
- const wxSize& size,
- int n, const wxString choices[],
- long style,
- const wxValidator& validator,
- const wxString& name)
+ const wxString& value,
+ const wxPoint& pos,
+ const wxSize& size,
+ int n, const wxString choices[],
+ long style,
+ const wxValidator& validator,
+ const wxString& name)
{
SetName(name);
SetValidator(validator);
m_windowStyle = style;
if ( id == -1 )
- m_windowId = (int)NewControlId();
+ m_windowId = (int)NewControlId();
else
- m_windowId = id;
+ m_windowId = id;
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
- long msStyle = WS_CHILD | WS_HSCROLL | WS_VSCROLL
- | WS_TABSTOP | WS_VISIBLE | CBS_NOINTEGRALHEIGHT;
+ long msStyle = WS_CHILD | WS_HSCROLL | WS_VSCROLL |
+ WS_TABSTOP | WS_VISIBLE | CBS_NOINTEGRALHEIGHT;
+
if (m_windowStyle & wxCB_READONLY)
msStyle |= CBS_DROPDOWNLIST;
- else if (m_windowStyle & wxCB_SIMPLE) // A list (shown always) and edit control
- msStyle |= CBS_SIMPLE;
+ else if (m_windowStyle & wxCB_SIMPLE)
+ msStyle |= CBS_SIMPLE; // A list (shown always) and edit control
else
msStyle |= CBS_DROPDOWN;
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
- if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
+ if ( want3D || wxStyleHasBorder(m_windowStyle) )
msStyle |= WS_BORDER;
- HWND wx_combo = CreateWindowEx(exStyle, "COMBOBOX", NULL,
+ m_hWnd = (WXHWND)::CreateWindowEx(exStyle, "COMBOBOX", NULL,
msStyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL);
+
+ wxCHECK_MSG( m_hWnd, FALSE, "Failed to create combobox" );
+
/*
#if CTL3D
if (want3D)
#endif
*/
- m_hWnd = (WXHWND)wx_combo;
-
// Subclass again for purposes of dialog editing mode
- SubclassWin((WXHWND)wx_combo);
+ SubclassWin(m_hWnd);
SetFont(* parent->GetFont());
int 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);
- if ( value != "" )
- SetWindowText(wx_combo, (const char *)value);
+ if ( !value.IsEmpty() )
+ {
+ SetValue(value);
+ }
return TRUE;
}
// Don't call Begin/EndPaint if it's already been called:
// for example, if calling a base class OnPaint.
-WXHDC wxPaintDC::ms_PaintHDC = 0;
-size_t wxPaintDC::ms_PaintCount = 0; // count of ms_PaintHDC usage
+WXHDC wxPaintDC::ms_PaintHDC = 0;
+size_t wxPaintDC::ms_PaintCount = 0; // count of ms_PaintHDC usage
wxPaintDC::wxPaintDC(wxWindow *canvas)
{
m_hDC = NULL;
ms_PaintHDC = NULL;
}
- //else: ms_PaintHDC still in use
+ else { }//: ms_PaintHDC still in use
}
}
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
- if ( want3D || (m_windowStyle & wxSIMPLE_BORDER)
- || (m_windowStyle & wxRAISED_BORDER)
- || (m_windowStyle & wxSUNKEN_BORDER)
- || (m_windowStyle & wxDOUBLE_BORDER) ) {
+ if ( want3D || wxStyleHasBorder(m_windowStyle) )
+ {
wstyle |= WS_BORDER;
}
- HWND wx_list = CreateWindowEx(exStyle, "LISTBOX", NULL,
+ m_hWnd = (WXHWND)::CreateWindowEx(exStyle, "LISTBOX", NULL,
wstyle | WS_CHILD,
0, 0, 0, 0,
(HWND)parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL);
- m_hWnd = (WXHWND)wx_list;
+ wxCHECK_MSG( m_hWnd, FALSE, "Failed to create listbox" );
#if CTL3D
if (want3D)
{
- Ctl3dSubclassCtl(wx_list);
+ Ctl3dSubclassCtl(hwnd);
m_useCtl3D = TRUE;
}
#endif
// Subclass again to catch messages
- SubclassWin((WXHWND)wx_list);
+ SubclassWin(m_hWnd);
size_t 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
wxOwnerDrawn *pNewItem = CreateItem(ui);
pNewItem->SetName(choices[ui]);
m_aItems.Add(pNewItem);
- ListBox_SetItemData(wx_list, ui, pNewItem);
+ ListBox_SetItemData(hwnd, ui, pNewItem);
}
}
#endif
- if ((m_windowStyle & wxLB_MULTIPLE) == 0)
- SendMessage(wx_list, LB_SETCURSEL, 0, 0);
+ if ( (m_windowStyle & wxLB_MULTIPLE) == 0 )
+ SendMessage(hwnd, LB_SETCURSEL, 0, 0);
SetFont(* parent->GetFont());
SetSize(x, y, width, height);
- ShowWindow(wx_list, SW_SHOW);
+ Show(TRUE);
return TRUE;
}
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
- if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
+ if ( want3D || wxStyleHasBorder(m_windowStyle) )
wstyle |= WS_BORDER;
wstyle |= LVS_SHAREIMAGELISTS;
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
- if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)))
+ if ( want3D || wxStyleHasBorder(m_windowStyle) )
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() ;
+ m_hWnd = (WXHWND)::CreateWindowEx
+ (
+ (DWORD)exStyle,
+ GROUP_CLASS,
+ title,
+ msStyle,
+ 0, 0, 0, 0,
+ the_handle,
+ (HMENU)m_windowId,
+ wxGetInstance(),
+ NULL
+ );
+
#if CTL3D
if (want3D)
{
- Ctl3dSubclassCtl((HWND) m_hWnd);
- m_useCtl3D = TRUE;
+ Ctl3dSubclassCtl((HWND)m_hWnd);
+ m_useCtl3D = TRUE;
}
#endif
if (want3D)
{
Ctl3dSubclassCtl((HWND) m_hWnd);
- m_useCtl3D = TRUE;
+ m_useCtl3D = TRUE;
}
#endif
if (GetFont())
WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
- if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)))
+ if ( want3D || wxStyleHasBorder(m_windowStyle) )
msStyle |= WS_BORDER;
m_hWnd = (WXHWND) CreateWindowEx((DWORD) exStyle, GROUP_CLASS, (title == "" ? NULL : (const char *)title),
if (want3D)
{
Ctl3dSubclassCtl((HWND) m_hWnd);
- m_useCtl3D = TRUE;
+ m_useCtl3D = TRUE;
}
#endif
if (want3D)
{
Ctl3dSubclassCtl((HWND) m_hWnd);
- m_useCtl3D = TRUE;
+ m_useCtl3D = TRUE;
}
#endif
m_subControls.Append((wxObject *)newId);
}
WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
- WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+ WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
#if CTL3D
if ( m_useCtl3D )
bool wxRadioBox::ContainsHWND(WXHWND hWnd) const
{
- int i;
+ int i;
for (i = 0; i < Number(); i++)
if (GetRadioButtons()[i] == hWnd)
return TRUE;
- return FALSE;
+ return FALSE;
}
void wxRadioBox::Command (wxCommandEvent & event)
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 yPos = HIWORD(lParam); // vertical position of cursor
return (long)HTCLIENT;
}
- return wxControl::MSWWindowProc(nMsg, wParam, lParam);
+ return wxControl::MSWWindowProc(nMsg, wParam, lParam);
}
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#endif
bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
- const wxString& label,
+ const wxString& label,
const wxPoint& pos,
const wxSize& size, long style,
const wxValidator& validator,
SetForegroundColour(parent->GetForegroundColour());
if ( id == -1 )
- m_windowId = (int)NewControlId();
+ m_windowId = (int)NewControlId();
else
- m_windowId = id;
+ m_windowId = id;
int x = pos.x;
int y = pos.y;
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
- if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)))
+ if ( want3D || wxStyleHasBorder(m_windowStyle) )
msStyle |= WS_BORDER;
m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const char *)label,
msStyle,0,0,0,0,
(HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
+
+ wxCHECK_MSG( m_hWnd, FALSE, "Failed to create radiobutton" );
+
#if CTL3D
if (want3D)
{
Ctl3dSubclassCtl((HWND) m_hWnd);
- m_useCtl3D = TRUE;
+ m_useCtl3D = TRUE;
}
#endif
}
WXHBRUSH wxRadioButton::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
- WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+ WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
#if CTL3D
if ( m_useCtl3D )
// Not implemented
#if 0
bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id,
- const wxBitmap *bitmap,
+ const wxBitmap *bitmap,
const wxPoint& pos,
const wxSize& size, long style,
const wxValidator& validator,
SetForegroundColour(parent->GetForegroundColour());
if ( id == -1 )
- m_windowId = (int)NewControlId();
+ m_windowId = (int)NewControlId();
else
- m_windowId = id;
+ m_windowId = id;
int x = pos.x;
int y = pos.y;
m_hWnd = (WXHWND) CreateWindowEx(MakeExtendedStyle(m_windowStyle), RADIO_CLASS, "toggle",
msStyle,0,0,0,0,
(HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
+
+ wxCHECK_MSG( m_hWnd, "Failed to create radio button", FALSE );
+
#if CTL3D
if (!(GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS))
{
Ctl3dSubclassCtl((HWND) GetHWND());
- m_useCtl3D = TRUE;
+ m_useCtl3D = TRUE;
}
#endif
if ( !str.IsEmpty() && str.Last() == REG_SEPARATOR )
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;
-}
-
-
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
SetForegroundColour(parent->GetForegroundColour()) ;
if ( id == -1 )
- m_windowId = (int)NewControlId();
+ m_windowId = (int)NewControlId();
else
- m_windowId = id;
+ m_windowId = id;
int x = pos.x;
int y = pos.y;
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
- if ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
+ if ( wxStyleHasBorder(m_windowStyle) )
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,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL);
+ wxCHECK_MSG( m_hWnd, FALSE, "Failed to create static ctrl" );
+
#if CTL3D
/*
if (!(GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS))
*/
#endif
- m_hWnd = (WXHWND)static_item;
-
- SubclassWin((WXHWND)static_item);
+ SubclassWin(m_hWnd);
SetFont(* parent->GetFont());
SetSize(x, y, width, height);
+
return TRUE;
}
}
WXHBRUSH wxStaticText::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
- WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+ WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
/*
#if CTL3D
if ( m_useCtl3D )
{
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
-
+
if (hbrush != (HBRUSH) 0)
return hbrush;
else
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
- EVT_CHAR(wxTextCtrl::OnChar)
- EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
- EVT_ERASE_BACKGROUND(wxTextCtrl::OnEraseBackground)
+ EVT_CHAR(wxTextCtrl::OnChar)
+ EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
+ EVT_ERASE_BACKGROUND(wxTextCtrl::OnEraseBackground)
END_EVENT_TABLE()
#endif
}
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
- const wxString& value,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
+ const wxString& value,
+ const wxPoint& pos,
+ const wxSize& size, long style,
+ const wxValidator& validator,
+ const wxString& name)
{
m_fileName = "";
SetName(name);
SetForegroundColour(parent->GetForegroundColour()) ;
if ( id == -1 )
- m_windowId = (int)NewControlId();
+ m_windowId = (int)NewControlId();
else
- m_windowId = id;
+ m_windowId = id;
int x = pos.x;
int y = pos.y;
// m_globalHandle = (WXHGLOBAL) GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT,
// 256L);
#endif
+
long msStyle = ES_LEFT | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
if (m_windowStyle & wxTE_MULTILINE)
- msStyle |= ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL ; // WS_BORDER
+ msStyle |= ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL ; // WS_BORDER
else
msStyle |= ES_AUTOHSCROLL ;
char *windowClass = "EDIT";
#if defined(__WIN95__)
if ( m_windowStyle & wxTE_MULTILINE )
-#else
- if ( FALSE )
-#endif
{
- msStyle |= ES_AUTOVSCROLL;
- m_isRich = TRUE;
- windowClass = "RichEdit" ;
+ msStyle |= ES_AUTOVSCROLL;
+ m_isRich = TRUE;
+ windowClass = "RichEdit" ;
}
else
- m_isRich = FALSE;
+#endif
+ m_isRich = FALSE;
bool want3D;
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
if (m_windowStyle & wxSIMPLE_BORDER)
{
windowClass = "EDIT";
- m_isRich = FALSE;
+ m_isRich = FALSE;
}
#endif
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
- if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
+ if ( want3D || wxStyleHasBorder(m_windowStyle) )
msStyle |= WS_BORDER;
- HWND edit = CreateWindowEx(exStyle, windowClass, NULL,
+ m_hWnd = (WXHWND)::CreateWindowEx(exStyle, windowClass, NULL,
msStyle,
0, 0, 0, 0, (HWND) ((wxWindow*)parent)->GetHWND(), (HMENU)m_windowId,
m_globalHandle ? (HINSTANCE) m_globalHandle : wxGetInstance(), NULL);
+ wxCHECK_MSG( m_hWnd, FALSE, "Failed to create text ctrl" );
+
#if CTL3D
if ( want3D )
{
- Ctl3dSubclassCtl(edit);
- m_useCtl3D = TRUE;
+ Ctl3dSubclassCtl((HWND)m_hWnd);
+ m_useCtl3D = TRUE;
}
#endif
- m_hWnd = (WXHWND)edit;
-
#if defined(__WIN95__)
if (m_isRich)
{
- // Have to enable events
- ::SendMessage(edit, EM_SETEVENTMASK, 0, ENM_CHANGE | ENM_DROPFILES | ENM_SELCHANGE | ENM_UPDATE);
+ // Have to enable events
+ ::SendMessage((HWND)m_hWnd, EM_SETEVENTMASK, 0,
+ ENM_CHANGE | ENM_DROPFILES | ENM_SELCHANGE | ENM_UPDATE);
}
#endif
if ( parent->GetFont() && parent->GetFont()->Ok() )
{
- SetFont(* parent->GetFont());
+ SetFont(* parent->GetFont());
}
else
{
- SetFont(wxSystemSettings::GetSystemFont(wxSYS_SYSTEM_FONT));
+ SetFont(wxSystemSettings::GetSystemFont(wxSYS_SYSTEM_FONT));
}
SetSize(x, y, width, height);
// Causes a crash for Symantec C++ and WIN32 for some reason
#if !(defined(__SC__) && defined(__WIN32__))
- if (value != "")
- SetWindowText(edit, (const char *)value);
+ if ( !value.IsEmpty() )
+ {
+ SetValue(value);
+ }
#endif
return TRUE;
// Make sure the window style (etc.) reflects the HWND style (roughly)
void wxTextCtrl::AdoptAttributesFromHWND(void)
{
- wxWindow::AdoptAttributesFromHWND();
+ wxWindow::AdoptAttributesFromHWND();
- HWND hWnd = (HWND) GetHWND();
- long style = GetWindowLong((HWND) hWnd, GWL_STYLE);
+ HWND hWnd = (HWND) GetHWND();
+ long style = GetWindowLong((HWND) hWnd, GWL_STYLE);
char buf[256];
#ifndef __WIN32__
- GetClassName((HWND) hWnd, buf, 256);
+ GetClassName((HWND) hWnd, buf, 256);
#else
#ifdef UNICODE
- GetClassNameW((HWND) hWnd, buf, 256);
+ GetClassNameW((HWND) hWnd, buf, 256);
#else
- GetClassNameA((HWND) hWnd, buf, 256);
+ GetClassNameA((HWND) hWnd, buf, 256);
#endif
#endif
- wxString str(buf);
- str.UpperCase();
-
- if (str == "EDIT")
- m_isRich = FALSE;
- else
- m_isRich = TRUE;
-
- if (style & ES_MULTILINE)
- m_windowStyle |= wxTE_MULTILINE;
- if (style & ES_PASSWORD)
- m_windowStyle |= wxTE_PASSWORD;
- if (style & ES_READONLY)
- m_windowStyle |= wxTE_READONLY;
- if (style & ES_WANTRETURN)
- m_windowStyle |= wxTE_PROCESS_ENTER;
+ wxString str(buf);
+ str.UpperCase();
+
+ if (str == "EDIT")
+ m_isRich = FALSE;
+ else
+ m_isRich = TRUE;
+
+ if (style & ES_MULTILINE)
+ m_windowStyle |= wxTE_MULTILINE;
+ if (style & ES_PASSWORD)
+ m_windowStyle |= wxTE_PASSWORD;
+ if (style & ES_READONLY)
+ m_windowStyle |= wxTE_READONLY;
+ if (style & ES_WANTRETURN)
+ m_windowStyle |= wxTE_PROCESS_ENTER;
}
void wxTextCtrl::SetupColours(void)
GetWindowText((HWND) GetHWND(), s, length+1);
wxString str(s);
delete[] s;
- return str;
+ return str;
}
void wxTextCtrl::SetValue(const wxString& value)
while (!input.eof() && input.peek() != EOF)
{
input.getline(wxBuffer, 500);
- int len = strlen(wxBuffer);
- wxBuffer[len] = 13;
- wxBuffer[len+1] = 10;
- wxBuffer[len+2] = 0;
- strcpy(tmp_buffer+pos, wxBuffer);
- pos += strlen(wxBuffer);
- no_lines++;
+ int len = strlen(wxBuffer);
+ wxBuffer[len] = 13;
+ wxBuffer[len+1] = 10;
+ wxBuffer[len+2] = 0;
+ strcpy(tmp_buffer+pos, wxBuffer);
+ pos += strlen(wxBuffer);
+ no_lines++;
}
// SendMessage((HWND) GetHWND(), WM_SETTEXT, 0, (LPARAM)tmp_buffer);
ofstream output((char*) (const char*) theFile);
if (output.bad())
- return FALSE;
+ return FALSE;
// This will only save 64K max
unsigned long nbytes = SendMessage((HWND) GetHWND(), WM_GETTEXTLENGTH, 0, 0);
SendMessage((HWND) GetHWND(), WM_GETTEXT, (WPARAM)(nbytes+1), (LPARAM)tmp_buffer);
char *pstr = tmp_buffer;
- // Convert \r\n to just \n
- while (*pstr)
- {
- if (*pstr != '\r')
- output << *pstr;
- pstr++;
- }
+ // Convert \r\n to just \n
+ while (*pstr)
+ {
+ if (*pstr != '\r')
+ output << *pstr;
+ pstr++;
+ }
farfree(tmp_buffer);
SendMessage((HWND) GetHWND(), EM_SETMODIFY, FALSE, 0L);
*(WORD *)wxBuffer = 512;
int noChars = (int)SendMessage(hWnd, EM_GETLINE, (WPARAM)lineNo, (LPARAM)wxBuffer);
wxBuffer[noChars] = 0;
- return wxString(wxBuffer);
+ return wxString(wxBuffer);
}
/*
}
WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
- WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+ WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
#if CTL3D
if ( m_useCtl3D )
void wxTextCtrl::OnChar(wxKeyEvent& event)
{
- if ( (event.KeyCode() == WXK_RETURN) && (m_windowStyle & wxPROCESS_ENTER))
- {
- wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
- event.SetEventObject( this );
- if ( GetEventHandler()->ProcessEvent(event) )
+ if ( (event.KeyCode() == WXK_RETURN) && (m_windowStyle & wxPROCESS_ENTER))
+ {
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
+ event.SetEventObject( this );
+ if ( GetEventHandler()->ProcessEvent(event) )
return;
- }
+ }
else if ( event.KeyCode() == WXK_TAB ) {
wxNavigationKeyEvent event;
event.SetDirection(!(::GetKeyState(VK_SHIFT) & 0x100));
#if defined(__WIN95__)
bool wxTextCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
{
- wxCommandEvent event(0, m_windowId);
- int eventType = 0;
- NMHDR *hdr1 = (NMHDR *) lParam;
- switch ( hdr1->code )
- {
- // Insert case code here
- default :
- return wxControl::MSWNotify(wParam, lParam);
- break;
- }
-
- event.SetEventObject( this );
- event.SetEventType(eventType);
-
- if ( !ProcessEvent(event) )
- return FALSE;
-
- return TRUE;
+ wxCommandEvent event(0, m_windowId);
+ int eventType = 0;
+ NMHDR *hdr1 = (NMHDR *) lParam;
+ switch ( hdr1->code )
+ {
+ // Insert case code here
+ default :
+ return wxControl::MSWNotify(wParam, lParam);
+ break;
+ }
+
+ event.SetEventObject( this );
+ event.SetEventType(eventType);
+
+ if ( !ProcessEvent(event) )
+ return FALSE;
+
+ return TRUE;
}
#endif
#endif
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
#ifdef __GNUG__
-#pragma implementation "timer.h"
+ #pragma implementation "timer.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#ifndef WX_PRECOMP
-#include "wx/setup.h"
-#include "wx/list.h"
-#include "wx/app.h"
+ #include "wx/setup.h"
+ #include "wx/list.h"
+ #include "wx/app.h"
#endif
+#include "wx/intl.h"
+#include "wx/log.h"
+
#include "wx/timer.h"
#include "wx/msw/private.h"
#include <sys/types.h>
#if !defined(__SC__) && !defined(__GNUWIN32__)
-#include <sys/timeb.h>
-#endif
-#ifdef __WIN32__
-#define _EXPORT /**/
-#else
-#define _EXPORT _export
+ #include <sys/timeb.h>
#endif
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
wxList wxTimerList(wxKEY_INTEGER);
UINT WINAPI _EXPORT wxTimerProc(HWND hwnd, WORD, int idTimer, DWORD);
+// ----------------------------------------------------------------------------
+// macros
+// ----------------------------------------------------------------------------
+
+#ifdef __WIN32__
+ #define _EXPORT /**/
+#else
+ #define _EXPORT _export
+#endif
+
#if !USE_SHARED_LIBRARY
-IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
+ IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
#endif
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxTimer class
+// ----------------------------------------------------------------------------
wxTimer::wxTimer(void)
{
- milli = 0 ;
- lastMilli = -1 ;
- id = 0;
+ milli = 0 ;
+ lastMilli = -1 ;
+ id = 0;
}
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 ;
- if (milliseconds < 0)
- milliseconds = lastMilli;
-
- if (milliseconds <= 0)
- return FALSE;
-
- lastMilli = milli = milliseconds;
-
- wxTimerList.DeleteObject(this);
- TIMERPROC wxTimerProcInst = (TIMERPROC) MakeProcInstance((FARPROC)wxTimerProc,
- wxGetInstance());
-
- id = SetTimer(NULL, (UINT)(id ? id : 1), (UINT)milliseconds, wxTimerProcInst);
- if (id > 0)
- {
- wxTimerList.Append(id, this);
- return TRUE;
- }
- else return FALSE;
+ oneShot = mode ;
+ if (milliseconds < 0)
+ milliseconds = lastMilli;
+
+ wxCHECK_MSG( milliseconds > 0, FALSE, "invalid value for timer timeour" );
+
+ lastMilli = milli = milliseconds;
+
+ wxTimerList.DeleteObject(this);
+ TIMERPROC wxTimerProcInst = (TIMERPROC)
+ MakeProcInstance((FARPROC)wxTimerProc, wxGetInstance());
+
+ id = SetTimer(NULL, (UINT)(id ? id : 1),
+ (UINT)milliseconds, wxTimerProcInst);
+ if (id > 0)
+ {
+ wxTimerList.Append(id, this);
+
+ return TRUE;
+ }
+ else
+ {
+ wxLogSysError(_("Couldn't create a timer"));
+
+ return FALSE;
+ }
}
void wxTimer::Stop(void)
{
- if (id) {
- KillTimer(NULL, (UINT)id);
- wxTimerList.DeleteObject(this); /* @@@@ */
- }
- id = 0 ;
- milli = 0 ;
+ if (id) {
+ KillTimer(NULL, (UINT)id);
+ wxTimerList.DeleteObject(this); /* @@@@ */
+ }
+ id = 0 ;
+ milli = 0 ;
}
-UINT WINAPI _EXPORT wxTimerProc(HWND WXUNUSED(hwnd), WORD, int idTimer, DWORD)
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+static void wxProcessTimer(wxTimer& timer)
{
- 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;
+ // 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)
+{
+ wxNode *node = wxTimerList.Find((long)idTimer);
+
+ wxCHECK_MSG( node, 0, "bogus timer id in wxTimerProc" );
+
+ wxProcessTimer(*(wxTimer *)node->Data());
+
+ return 0;
+}
if (m_sizerParent)
m_sizerParent->RemoveChild((wxWindow *)this);
#endif
-
+
// wxWnd
MSWDetachWindowMenu();
m_globalHandle = 0;
}
#endif
-
+
delete m_children;
m_children = NULL;
if ( m_windowValidator )
delete m_windowValidator;
- // Restore old Window proc, if required
+ // Restore old Window proc, if required
// and remove hWnd <-> wxWindow association
UnsubclassWin();
}
#if wxUSE_DRAG_AND_DROP
m_pDropTarget = NULL;
#endif
-
+
// MSW-specific
m_hWnd = 0;
m_winEnabled = TRUE;
HWND hWnd = (HWND) GetHWND();
HDC dc = ::GetDC(hWnd);
- HFONT fnt = 0;
+ HFONT fnt = 0;
HFONT was = 0;
if (fontToUse && fontToUse->Ok())
{
GetTextExtentPoint(dc, (const char *)string, (int)string.Length(), &sizeRect);
GetTextMetrics(dc, &tm);
- if (fontToUse && fnt && was)
+ if (fontToUse && fnt && was)
SelectObject(dc,was) ;
ReleaseDC(hWnd, dc);
wxLogTrace(wxTraceMessages, "Processing %s(%lx, %lx)",
wxGetMessageName(message), wParam, lParam);
#endif // WXDEBUG
-
+
HWND hWnd = (HWND)m_hWnd;
switch (message)
else return MSWDefWindowProc(message, wParam, lParam );
break;
}
-
+
case WM_SIZE:
{
int width = LOWORD(lParam);
MSWOnSize(width, height, wParam);
break;
}
-
+
case WM_MOVE:
{
wxMoveEvent event(wxPoint(LOWORD(lParam), HIWORD(lParam)),
MSWOnWindowPosChanging((void *)lParam);
break;
}
-
+
case WM_RBUTTONDOWN:
{
int x = (DIMENSION_TYPE) LOWORD(lParam);
return MSWOnMeasureItem((int)wParam, (WXMEASUREITEMSTRUCT *)lParam);
break;
}
-
+
case WM_KEYDOWN:
// we consider these message "not interesting"
if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
return 1L;
break;
}
-
+
case WM_GETMINMAXINFO:
{
MINMAXINFO *info = (MINMAXINFO *)lParam;
return MSWDefWindowProc(message, wParam, lParam );
break;
}
-
+
case WM_GETDLGCODE:
return MSWGetDlgCode();
m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent,
(DLGPROC)dlgproc);
#endif
-
+
if (m_hWnd == 0)
MessageBox(NULL, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
"wxWindows Error", MB_ICONEXCLAMATION | MB_OK);
m_pDropTarget = NULL;
}
#endif
-
+
return TRUE;
}
NMHDR *hdr = (NMHDR *)lParam;
HWND hWnd = (HWND)hdr->hwndFrom;
wxWindow *win = wxFindWinFromHandle((WXHWND) hWnd);
-
+
if ( win )
return win->MSWNotify(wParam, lParam);
else
}
return FALSE;
-
+
#endif
return FALSE;
}
#if WXDEBUG > 1
wxDebugMsg("wxWindow::MSWOnActivate %d\n", handle);
#endif
-
+
wxActivateEvent event(wxEVT_ACTIVATE, ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)),
m_windowId);
event.SetEventObject(this);
if (m_caretShown)
::ShowCaret((HWND) GetHWND());
}
-
+
wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId);
event.SetEventObject(this);
if (!GetEventHandler()->ProcessEvent(event))
{
::DestroyCaret();
}
-
+
wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId);
event.SetEventObject(this);
if (!GetEventHandler()->ProcessEvent(event))
#if WXDEBUG > 1
wxDebugMsg("wxWindow::MSWOnDropFiles %d\n", m_hWnd);
#endif
-
+
HDROP hFilesInfo = (HDROP) wParam;
POINT dropPoint;
DragQueryPoint(hFilesInfo, (LPPOINT) &dropPoint);
);
}
#endif // owner-drawn menus
-
+
wxWindow *item = FindItem(id);
#if wxUSE_DYNAMIC_CLASSES
if (item && item->IsKindOf(CLASSINFO(wxControl)))
wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData);
wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
- return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth,
+ return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth,
&pMeasureStruct->itemHeight);
}
#endif // owner-drawn menus
-
+
wxWindow *item = FindItem(id);
#if wxUSE_DYNAMIC_CLASSES
if (item && item->IsKindOf(CLASSINFO(wxControl)))
event.m_eventObject = win;
win->GetEventHandler()->ProcessEvent(event2);
}
-
+
node = node->Next();
}
}
// Ignore 'fake' events (perhaps generated as a result of a separate real event)
if (m_lastMsg == 0)
return 0;
-
+
#ifdef __WXDEBUG__
wxLogTrace(wxTraceMessages, "Forwarding %s to DefWindowProc.",
wxGetMessageName(m_lastMsg));
#endif // WXDEBUG
-
+
return this->MSWDefWindowProc(m_lastMsg, m_lastWParam, m_lastLParam);
}
m_updateRegion = wxRegion(updateRect.left, updateRect.top,
updateRect.right - updateRect.left, updateRect.bottom - updateRect.top);
#endif
-
+
wxPaintEvent event(m_windowId);
event.SetEventObject(this);
if (!GetEventHandler()->ProcessEvent(event))
sprintf(buf, "Looking for item %d...\n", id);
wxDebugMsg(buf);
#endif
-
+
wxWindow *item = FindItem(id);
if (item)
{
change = wxJOY_BUTTON3;
if (flags & JOY_BUTTON4CHG)
change = wxJOY_BUTTON4;
-
+
if (flags & JOY_BUTTON1)
buttons |= wxJOY_BUTTON1;
if (flags & JOY_BUTTON2)
buttons |= wxJOY_BUTTON3;
if (flags & JOY_BUTTON4)
buttons |= wxJOY_BUTTON4;
-
+
wxJoystickEvent event(wxEVT_JOY_BUTTON_DOWN, buttons, joystick, change);
event.SetPosition(wxPoint(x, y));
event.SetEventObject(this);
-
+
GetEventHandler()->ProcessEvent(event);
}
change = wxJOY_BUTTON3;
if (flags & JOY_BUTTON4CHG)
change = wxJOY_BUTTON4;
-
+
if (flags & JOY_BUTTON1)
buttons |= wxJOY_BUTTON1;
if (flags & JOY_BUTTON2)
buttons |= wxJOY_BUTTON3;
if (flags & JOY_BUTTON4)
buttons |= wxJOY_BUTTON4;
-
+
wxJoystickEvent event(wxEVT_JOY_BUTTON_UP, buttons, joystick, change);
event.SetPosition(wxPoint(x, y));
event.SetEventObject(this);
-
+
GetEventHandler()->ProcessEvent(event);
}
buttons |= wxJOY_BUTTON3;
if (flags & JOY_BUTTON4)
buttons |= wxJOY_BUTTON4;
-
+
wxJoystickEvent event(wxEVT_JOY_MOVE, buttons, joystick, 0);
event.SetPosition(wxPoint(x, y));
event.SetEventObject(this);
-
+
GetEventHandler()->ProcessEvent(event);
}
buttons |= wxJOY_BUTTON3;
if (flags & JOY_BUTTON4)
buttons |= wxJOY_BUTTON4;
-
+
wxJoystickEvent event(wxEVT_JOY_ZMOVE, buttons, joystick, 0);
event.SetZPosition(z);
event.SetEventObject(this);
-
+
GetEventHandler()->ProcessEvent(event);
}
return;
break;
}
-
+
if (!GetEventHandler()->ProcessEvent(event))
Default();
}
// Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
// pixel coordinates, relatives to the canvas -- So, we first need to
// substract origin of the window, then convert to screen position
-
+
int x = x_pos; int y = y_pos;
RECT rect;
GetWindowRect ((HWND) GetHWND(), &rect);
-
+
x += rect.left;
y += rect.top;
-
+
SetCursorPos (x, y);
}
bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC)
{
wxDC dc ;
-
+
dc.SetHDC(pDC);
dc.SetWindow(this);
dc.BeginDrawing();
-
+
wxEraseEvent event(m_windowId, &dc);
event.m_eventObject = this;
if (!GetEventHandler()->ProcessEvent(event))
dc.EndDrawing();
dc.SelectOldObjects(pDC);
}
-
+
dc.SetHDC((WXHDC) NULL);
return TRUE;
}
void wxWindow::SetScrollRange(int orient, int range, bool refresh)
{
#if defined(__WIN95__)
-
+
int range1 = range;
// Try to adjust the range to cope with page size > 1
// October 10th: new range concept.
maxPos += pageSize;
#endif
-
+
return maxPos;
}
else
int oldRange = range - thumbVisible ;
SetScrollRange(orient, oldRange, FALSE);
-
+
SetScrollPos(orient, pos, refresh);
*/
#if defined(__WIN95__)
rect2.right = rect->x + rect->width;
rect2.bottom = rect->y + rect->height;
}
-
+
if ( rect )
::ScrollWindow((HWND) GetHWND(), dx, dy, &rect2, NULL);
else
void wxWindow::UnsubclassWin(void)
{
wxRemoveHandleAssociation(this);
-
+
// Restore old Window proc
if ((HWND) GetHWND())
{
WXDWORD exStyle = 0;
if ( style & wxTRANSPARENT_WINDOW )
exStyle |= WS_EX_TRANSPARENT ;
-
+
if ( !eliminateBorders )
{
if ( style & wxSUNKEN_BORDER )
if ( *want3D )
nativeBorder = FALSE;
#endif
-
+
DWORD exStyle = MakeExtendedStyle(m_windowStyle, !nativeBorder);
// If we want 3D, but haven't specified a border here,
(m_windowStyle & wxSTATIC_BORDER) || (m_windowStyle & wxSIMPLE_BORDER) ))
exStyle |= defaultBorderStyle; // WS_EX_CLIENTEDGE ;
#endif
-
+
return exStyle;
}
return;
}
}
-
+
bool isVirtual;
int id = wxCharCodeWXToMSW((int)event.KeyCode(), &isVirtual);
-
+
if ( id == -1 )
id= m_lastWParam;
-
+
if ( !event.ControlDown() )
(void) MSWDefWindowProc(m_lastMsg, (WPARAM) id, m_lastLParam);
}
wxMessageBox("Application Error", "Could not transfer data to window", wxOK|wxICON_EXCLAMATION);
return FALSE;
}
-
+
node = node->Next();
}
return TRUE;
{
return FALSE;
}
-
+
node = node->Next();
}
return TRUE;
{
return FALSE;
}
-
+
node = node->Next();
}
return TRUE;
event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
}
event.m_eventObject = lbox;
-
+
lbox->ProcessCommand(event);
-
+
if (event.m_commandString)
delete[] event.m_commandString;
return;
maxX = wx + ww;
if ( wy + wh > maxY )
maxY = wy + wh;
-
+
node = node->Next();
}
SetClientSize(maxX + 5, maxY + 5);
if ( m_windowValidator )
delete m_windowValidator;
m_windowValidator = validator.Clone();
-
+
if ( m_windowValidator )
m_windowValidator->SetWindow(this) ;
}
{
if ( GetId() == id)
return this;
-
+
wxNode *node = GetChildren()->First();
while ( node )
{
{
if ( GetName() == name)
return this;
-
+
wxNode *node = GetChildren()->First();
while ( node )
{
// Bugfix begin
if (vert_units)
y_pages = (int)(v_height/vert_units) - y_page;
-
+
#ifdef __WXMSW__
int y = 0;
#else
{
// Generate a LEAVE event
m_mouseInWindow = FALSE;
-
+
int state = 0;
if (::GetKeyState(VK_SHIFT) != 0)
state |= MK_SHIFT;
if (::GetKeyState(VK_CONTROL) != 0)
state |= MK_CONTROL;
-
+
// Unfortunately the mouse button and keyboard state may have changed
// by the time the OnIdle function is called, so 'state' may be
// meaningless.
-
+
MSWOnMouseLeave(pt.x, pt.y, state);
}
}
case 0x0046: return "WM_WINDOWPOSCHANGING";
case 0x0047: return "WM_WINDOWPOSCHANGED";
case 0x0048: return "WM_POWER";
-
+
#ifdef __WIN32__
case 0x004A: return "WM_COPYDATA";
case 0x004B: return "WM_CANCELJOURNAL";
case 0x007F: return "WM_GETICON";
case 0x0080: return "WM_SETICON";
#endif //WIN32
-
+
case 0x0081: return "WM_NCCREATE";
case 0x0082: return "WM_NCDESTROY";
case 0x0083: return "WM_NCCALCSIZE";
case 0x0106: return "WM_SYSCHAR";
case 0x0107: return "WM_SYSDEADCHAR";
case 0x0108: return "WM_KEYLAST";
-
+
#ifdef __WIN32__
case 0x010D: return "WM_IME_STARTCOMPOSITION";
case 0x010E: return "WM_IME_ENDCOMPOSITION";
case 0x010F: return "WM_IME_COMPOSITION";
#endif //WIN32
-
+
case 0x0110: return "WM_INITDIALOG";
case 0x0111: return "WM_COMMAND";
case 0x0112: return "WM_SYSCOMMAND";
case 0x0210: return "WM_PARENTNOTIFY";
case 0x0211: return "WM_ENTERMENULOOP";
case 0x0212: return "WM_EXITMENULOOP";
-
+
#ifdef __WIN32__
case 0x0213: return "WM_NEXTMENU";
case 0x0214: return "WM_SIZING";
case 0x0218: return "WM_POWERBROADCAST";
case 0x0219: return "WM_DEVICECHANGE";
#endif //WIN32
-
+
case 0x0220: return "WM_MDICREATE";
case 0x0221: return "WM_MDIDESTROY";
case 0x0222: return "WM_MDIACTIVATE";
case 0x0229: return "WM_MDIGETACTIVE";
case 0x0230: return "WM_MDISETMENU";
case 0x0233: return "WM_DROPFILES";
-
+
#ifdef __WIN32__
case 0x0281: return "WM_IME_SETCONTEXT";
case 0x0282: return "WM_IME_NOTIFY";
case 0x0290: return "WM_IME_KEYDOWN";
case 0x0291: return "WM_IME_KEYUP";
#endif //WIN32
-
+
case 0x0300: return "WM_CUT";
case 0x0301: return "WM_COPY";
case 0x0302: return "WM_PASTE";
case 0x030F: return "WM_QUERYNEWPALETTE";
case 0x0310: return "WM_PALETTEISCHANGING";
case 0x0311: return "WM_PALETTECHANGED";
-
+
#ifdef __WIN32__
// common controls messages - although they're not strictly speaking
// standard, it's nice to decode them nevertheless
case 0x1000 + 63: return "LVM_GETHOTCURSOR";
case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
case 0x1000 + 65: return "LVM_SETWORKAREA";
-
+
// tree view
case 0x1100 + 0: return "TVM_INSERTITEMA";
case 0x1100 + 50: return "TVM_INSERTITEMW";
case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
case 0x1100 + 24: return "TVM_SETTOOLTIPS";
case 0x1100 + 25: return "TVM_GETTOOLTIPS";
-
+
// header
case 0x1200 + 0: return "HDM_GETITEMCOUNT";
case 0x1200 + 1: return "HDM_INSERTITEMA";
case 0x1200 + 17: return "HDM_GETORDERARRAY";
case 0x1200 + 18: return "HDM_SETORDERARRAY";
case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
-
+
// tab control
case 0x1300 + 2: return "TCM_GETIMAGELIST";
case 0x1300 + 3: return "TCM_SETIMAGELIST";
case 0x1300 + 48: return "TCM_SETCURFOCUS";
case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
case 0x1300 + 50: return "TCM_DESELECTALL";
-
+
// toolbar
case WM_USER+1: return "TB_ENABLEBUTTON";
case WM_USER+2: return "TB_CHECKBUTTON";
case WM_USER+60: return "TB_SETMAXTEXTROWS";
case WM_USER+61: return "TB_GETTEXTROWS";
case WM_USER+41: return "TB_GETBITMAPFLAGS";
-
+
#endif //WIN32
-
+
default:
static char s_szBuf[128];
sprintf(s_szBuf, "<unknown message = %d>", message);
return s_szBuf;
}
}
-#endif //WXDEBUG
\ No newline at end of file
+#endif //WXDEBUG