extern const wxEventType wxEVT_COMMAND_TOOL_ENTER;
extern const wxEventType wxEVT_COMMAND_SPINCTRL_UPDATED;
-/* Sockets send events, too */
+/* Sockets and timers send events, too */
extern const wxEventType wxEVT_SOCKET;
+extern const wxEventType wxEVT_TIMER;
/* Mouse event types */
extern const wxEventType wxEVT_LEFT_DOWN;
/* Sockets send events, too */
const wxEventType wxEVT_SOCKET = wxEVT_FIRST + 50;
+/* And timers do as well */
+const wxEventType wxEVT_TIMER = wxEVT_FIRST + 80;
+
/* Mouse event types */
const wxEventType wxEVT_LEFT_DOWN = wxEVT_FIRST + 100;
const wxEventType wxEVT_LEFT_UP = wxEVT_FIRST + 101;
/////////////////////////////////////////////////////////////////////////////
-// Name: statusbr.h
-// Purpose: wxStatusBar class
+// Name: wx/generic/statusbr.h
+// Purpose: wxStatusBarGeneric class
// Author: Julian Smart
-// Modified by:
+// Modified by: VZ at 05.02.00 to derive from wxStatusBarBase
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
-#ifndef __STATUSBRH_G__
-#define __STATUSBRH_G__
+#ifndef _WX_GENERIC_STATUSBR_H_
+#define _WX_GENERIC_STATUSBR_H_
#ifdef __GNUG__
#pragma interface "statusbr.h"
#endif
-#include "wx/window.h"
#include "wx/pen.h"
#include "wx/font.h"
WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
-class WXDLLEXPORT wxStatusBar: public wxWindow
+class WXDLLEXPORT wxStatusBarGeneric : public wxStatusBarBase
{
- DECLARE_DYNAMIC_CLASS(wxStatusBar)
-
public:
- wxStatusBar(void);
- inline wxStatusBar(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxPanelNameStr)
+ wxStatusBarGeneric();
+ wxStatusBarGeneric(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = 0,
+ const wxString& name = wxPanelNameStr)
{
Create(parent, id, pos, size, style, name);
}
+ wxStatusBarGeneric(wxWindow *parent,
+ wxWindowID id,
+ long style,
+ const wxString& name = wxPanelNameStr)
+ {
+ Create(parent, id, style, name);
+ }
+
+ ~wxStatusBarGeneric();
- ~wxStatusBar();
+ bool Create(wxWindow *parent, wxWindowID id,
+ const wxPoint& WXUNUSED(pos) = wxDefaultPosition,
+ const wxSize& WXUNUSED(size) = wxDefaultSize,
+ long style = 0,
+ const wxString& name = wxPanelNameStr)
+ {
+ return Create(parent, id, style, name);
+ }
bool Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxPanelNameStr);
+ long style = 0,
+ const wxString& name = wxPanelNameStr);
// Create status line
- virtual void SetFieldsCount(int number=1, const int widths[] = (const int *) NULL);
- inline int GetFieldsCount() const { return m_nFields; }
+ virtual void SetFieldsCount(int number = 1,
+ const int *widths = (const int *) NULL);
+ int GetFieldsCount() const { return m_nFields; }
// Set status line text
virtual void SetStatusText(const wxString& text, int number = 0);
// Set status line widths
virtual void SetStatusWidths(int n, const int widths_field[]);
- virtual void DrawFieldText(wxDC& dc, int i);
- virtual void DrawField(wxDC& dc, int i);
-
// Get the position and size of the field's internal bounding rectangle
virtual bool GetFieldRect(int i, wxRect& rect) const;
- inline int GetBorderX() const { return m_borderX; }
- inline int GetBorderY() const { return m_borderY; }
- inline void SetBorderX(int x);
- inline void SetBorderY(int y);
+ // sets the minimal vertical size of the status bar
+ virtual void SetMinHeight(int height);
+
+ virtual int GetBorderX() const { return m_borderX; }
+ virtual int GetBorderY() const { return m_borderY; }
////////////////////////////////////////////////////////////////////////
// Implementation
+ virtual void DrawFieldText(wxDC& dc, int i);
+ virtual void DrawField(wxDC& dc, int i);
+
+ void SetBorderX(int x);
+ void SetBorderY(int y);
+
void OnPaint(wxPaintEvent& event);
virtual void InitColours();
void OnSysColourChanged(wxSysColourChangedEvent& event);
protected:
- int * m_statusWidths;
- int m_nFields;
wxString * m_statusStrings;
int m_borderX;
int m_borderY;
wxPen m_mediumShadowPen;
wxPen m_hilightPen;
+private:
DECLARE_EVENT_TABLE()
+ DECLARE_DYNAMIC_CLASS(wxStatusBarGeneric)
};
#endif
- // __STATUSBRH_G__
+ // _WX_GENERIC_STATUSBR_H_
/////////////////////////////////////////////////////////////////////////////
-// Name: timer.h
+// Name: wx/gtk/timer.h
// Purpose:
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
class wxTimer : public wxTimerBase
{
public:
- wxTimer();
+ wxTimer() { Init(); }
+ wxTimer(wxEvtHandler *owner, int id = -1) : wxTimerBase(owner, id)
+ { Init(); }
~wxTimer();
virtual bool Start( int millisecs = -1, bool oneShot = FALSE );
virtual bool IsRunning() const { return m_tag != -1; }
protected:
+ void Init();
+
int m_tag;
private:
/////////////////////////////////////////////////////////////////////////////
-// Name: timer.h
+// Name: wx/gtk/timer.h
// Purpose:
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
class wxTimer : public wxTimerBase
{
public:
- wxTimer();
+ wxTimer() { Init(); }
+ wxTimer(wxEvtHandler *owner, int id = -1) : wxTimerBase(owner, id)
+ { Init(); }
~wxTimer();
virtual bool Start( int millisecs = -1, bool oneShot = FALSE );
virtual bool IsRunning() const { return m_tag != -1; }
protected:
+ void Init();
+
int m_tag;
private:
c.Set(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb));
}
+// copy Windows RECT to our wxRect
+inline void wxCopyRECTToRect(const RECT& r, wxRect& rect)
+{
+ rect.y = r.top;
+ rect.x = r.left;
+ rect.width = r.right - r.left;
+ rect.height = r.bottom - r.top;
+}
+
// translations between HIMETRIC units (which OLE likes) and pixels (which are
// liked by all the others) - implemented in msw/utilsexc.cpp
extern void HIMETRICToPixel(LONG *x, LONG *y);
#pragma interface "statbr95.h"
#endif
-#if wxUSE_NATIVE_STATUSBAR
+#if wxUSE_NATIVE_STATUSBAR
-class WXDLLEXPORT wxStatusBar95 : public wxStatusBar
+class WXDLLEXPORT wxStatusBar95 : public wxStatusBarBase
{
- DECLARE_DYNAMIC_CLASS(wxStatusBar95);
-
public:
- // ctors
- wxStatusBar95();
- wxStatusBar95(wxWindow *parent, wxWindowID id = -1, long style = wxST_SIZEGRIP);
+ // ctors and such
+ wxStatusBar95();
+ wxStatusBar95(wxWindow *parent,
+ wxWindowID id = -1,
+ long style = wxST_SIZEGRIP,
+ const wxString& name = wxEmptyString)
+ {
+ (void)Create(parent, id, style, name);
+ }
+
+ bool Create(wxWindow *parent,
+ wxWindowID id = -1,
+ long style = wxST_SIZEGRIP,
+ const wxString& name = wxEmptyString);
+
+ virtual ~wxStatusBar95();
- // create status line
- bool Create(wxWindow *parent, wxWindowID id = -1, long style = wxST_SIZEGRIP);
+ // a status line can have several (<256) fields numbered from 0
+ virtual void SetFieldsCount(int number = 1, const int *widths = NULL);
- // a status line can have several (<256) fields numbered from 0
- virtual void SetFieldsCount(int number = 1, const int widths[] = NULL);
+ // each field of status line has it's own text
+ virtual void SetStatusText(const wxString& text, int number = 0);
+ virtual wxString GetStatusText(int number = 0) const;
- // each field of status line has it's own text
- virtual void SetStatusText(const wxString& text, int number = 0);
- virtual wxString GetStatusText(int number = 0) const;
+ // set status line fields' widths
+ virtual void SetStatusWidths(int n, const int widths_field[]);
- // set status line fields' widths
- virtual void SetStatusWidths(int n, const int widths_field[]);
+ // sets the minimal vertical size of the status bar
+ virtual void SetMinHeight(int height);
- // we're going to process WM_SIZE (of the parent window)
- void OnSize(wxSizeEvent& event);
+ // get the position and size of the field's internal bounding rectangle
+ virtual bool GetFieldRect(int i, wxRect& rect) const;
- DECLARE_EVENT_TABLE()
+ // get the border size
+ virtual int GetBorderX() const;
+ virtual int GetBorderY() const;
+
+ void OnSize(wxSizeEvent& event);
protected:
- void CopyFieldsWidth(const int widths[]);
- void SetFieldsWidth();
+ void CopyFieldsWidth(const int widths[]);
+ void SetFieldsWidth();
+
+private:
+ DECLARE_EVENT_TABLE()
+ DECLARE_DYNAMIC_CLASS(wxStatusBar95);
};
#endif // wxUSE_NATIVE_STATUSBAR
friend void wxProcessTimer(wxTimer& timer);
public:
- wxTimer();
+ wxTimer() { Init(); }
+ wxTimer(wxEvtHandler *owner, int id = -1) : wxTimerBase(owner, id)
+ { Init(); }
~wxTimer();
virtual bool Start(int milliseconds = -1, bool oneShot = FALSE);
virtual bool IsRunning() const { return m_id != 0; }
protected:
+ void Init();
+
long m_id;
private:
+/////////////////////////////////////////////////////////////////////////////
+// Name: wx/statusbr.h
+// Purpose: wxStatusBar class interface
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 05.02.00
+// RCS-ID: $Id$
+// Copyright: (c) wxWindows team
+// Licence: wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
#ifndef _WX_STATUSBR_H_BASE_
#define _WX_STATUSBR_H_BASE_
-#include "wx/generic/statusbr.h"
+#include "wx/window.h"
+
+// ----------------------------------------------------------------------------
+// wxStatusBar: a window near the bottom of the frame used for status info
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxStatusBarBase : public wxWindow
+{
+public:
+ wxStatusBarBase() { m_statusWidths = NULL; }
+
+ // get/set the number of fields
+ virtual void SetFieldsCount(int number = 1,
+ const int *widths = (const int *) NULL) = 0;
+ int GetFieldsCount() const { return m_nFields; }
+
+ // get/set the text of the given field
+ virtual void SetStatusText(const wxString& text, int number = 0) = 0;
+ virtual wxString GetStatusText(int number = 0) const = 0;
+
+ // set status line widths (n should be the same as field count)
+ virtual void SetStatusWidths(int n, const int widths[]) = 0;
+
+ // Get the position and size of the field's internal bounding rectangle
+ virtual bool GetFieldRect(int i, wxRect& rect) const = 0;
+
+ // sets the minimal vertical size of the status bar
+ virtual void SetMinHeight(int height) = 0;
+
+ // get the dimensions of the horizontal and vertical borders
+ virtual int GetBorderX() const = 0;
+ virtual int GetBorderY() const = 0;
+
+protected:
+ int m_nFields; // the current number of fields
+ int *m_statusWidths; // the width (if !NULL) of the fields
+};
+
+#if defined(__WIN32__) && wxUSE_NATIVE_STATUSBAR
+ #include "wx/msw/statbr95.h"
+
+ typedef wxStatusBar95 wxStatusBarReal;
+#else
+ #include "wx/generic/statusbr.h"
+
+ typedef wxStatusBarGeneric wxStatusBarReal;
+#endif
+
+// we can't just typedef wxStatusBar to be one of 95/Generic because we should
+// be able to forward declare it (done in several places) and because wxWin
+// RTTI wouldn't work then
+class wxStatusBar : public wxStatusBarReal
+{
+public:
+ wxStatusBar() { }
+ wxStatusBar(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& WXUNUSED(pos) = wxDefaultPosition,
+ const wxSize& WXUNUSED(size) = wxDefaultSize,
+ long style = 0,
+ const wxString& name = wxPanelNameStr)
+ {
+ Create(parent, id, style, name);
+ }
+ wxStatusBar(wxWindow *parent,
+ wxWindowID id,
+ long style,
+ const wxString& name = wxPanelNameStr)
+ {
+ Create(parent, id, style, name);
+ }
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxStatusBar)
+};
#endif
// _WX_STATUSBR_H_BASE_
/////////////////////////////////////////////////////////////////////////////
// Name: wx/timer.h
-// Purpose: wxTimer class and global time-related functions
-// Author: Julian Smart
-// Modified by:
+// Purpose: wxTimer, wxStopWatch and global time-related functions
+// Author: Julian Smart (wxTimer), Sylvain Bougnoux (wxStopWatch)
+// Modified by: Vadim Zeitlin (wxTimerBase)
+// Guillermo Rodriguez (global clean up)
// Created: 04/01/98
// RCS-ID: $Id$
-// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Copyright: (c) wxWindows team
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TIMER_H_BASE_
#include "wx/setup.h"
#include "wx/object.h"
#include "wx/longlong.h"
+#include "wx/event.h"
// ----------------------------------------------------------------------------
// wxTimer
class WXDLLEXPORT wxTimerBase : public wxObject
{
public:
- wxTimerBase() { m_oneShot = FALSE; m_milli = 0; }
+ // ctors and initializers
+ // ----------------------
+
+ // default: if you don't call SetOwner(), your only chance to get timer
+ // notifications is to override Notify() in the derived class
+ wxTimerBase() { Init(); SetOwner(NULL); }
+
+ // ctor which allows to avoid having to override Notify() in the derived
+ // class: the owner will get timer notifications which can be handled with
+ // EVT_TIMER
+ wxTimerBase(wxEvtHandler *owner, int id = -1)
+ { Init(); SetOwner(owner, -1); }
+
+ // same as ctor above
+ void SetOwner(wxEvtHandler *owner, int id = -1)
+ { m_owner = owner; m_idTimer = id; }
// working with the timer
// ----------------------
// stop the timer
virtual void Stop() = 0;
- // override this in your wxTimer-derived class
- virtual void Notify() = 0;
+ // override this in your wxTimer-derived class if you want to process timer
+ // messages in it, use non default ctor or SetOwner() otherwise
+ virtual void Notify();
// getting info
// ------------
#endif // WXWIN_COMPATIBILITY_2
protected:
+ // common part of all ctors
+ void Init() { m_oneShot = FALSE; m_milli = 0; }
+
+ wxEvtHandler *m_owner;
+ int m_idTimer;
+
int m_milli; // the timer interval
bool m_oneShot; // TRUE if one shot
};
+// ----------------------------------------------------------------------------
+// wxTimer itself
+// ----------------------------------------------------------------------------
+
#if defined(__WXMSW__)
#include "wx/msw/timer.h"
#elif defined(__WXMOTIF__)
#endif
// ----------------------------------------------------------------------------
-// wxStopWatch
+// wxTimerEvent
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxTimerEvent : public wxEvent
+{
+public:
+ wxTimerEvent(int id = 0, int interval = 0) : wxEvent(id)
+ {
+ m_eventType = wxEVT_TIMER;
+
+ m_interval = interval;
+ }
+
+ // accessors
+ int GetInterval() const { return m_interval; }
+
+private:
+ int m_interval;
+
+ DECLARE_DYNAMIC_CLASS(wxTimerEvent)
+};
+
+typedef void (wxEvtHandler::*wxTimerEventFunction)(wxTimerEvent&);
+
+#define EVT_TIMER(id, func) { wxEVT_TIMER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTimerEventFunction) & func, NULL},
+
+// ----------------------------------------------------------------------------
+// wxStopWatch: measure time intervals with up to 1ms resolution
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxStopWatch
{
-public:
+public:
// ctor starts the stop watch
wxStopWatch() { Start(); }
void Start(long t = 0);
protected:
// returns the elapsed time since t0
long GetElapsedTime() const;
-
+
private:
wxLongLong m_t0; // the time of the last Start()
long m_pause; // the time of the last Pause() or 0
};
-// Starts a global timer
+// Starts a global timer
// -- DEPRECATED: use wxStopWatch instead
void WXDLLEXPORT wxStartTimer();
// -- DEPRECATED: use wxStopWatch instead
long WXDLLEXPORT wxGetElapsedTime(bool resetTimer = TRUE);
-
// ----------------------------------------------------------------------------
// global time functions
// ----------------------------------------------------------------------------
wxWindowID id,
const wxString& name)
{
- wxStatusBar *statusBar = new wxStatusBar(this, id,
- wxPoint(0, 0), wxSize(100, 20),
- style, name);
+ wxStatusBar *statusBar = new wxStatusBar(this, id, style, name);
// Set the height according to the font and the border size
wxClientDC dc(statusBar);
dc.SetFont(statusBar->GetFont());
- long y;
+ wxCoord y;
dc.GetTextExtent( "X", NULL, &y );
int height = (int)( (11*y)/10 + 2*statusBar->GetBorderY());
- statusBar->SetSize( -1, -1, 100, height );
+ statusBar->SetSize( -1, -1, -1, height );
statusBar->SetFieldsCount(number);
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// (c) 1999 Guillermo Rodriguez <guille@iies.es>
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
#include <sys/timeb.h>
#endif
+// ----------------------------------------------------------------------------
+// wxWin macros
+// ----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxTimerEvent, wxEvent)
+
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
#endif
#endif // HAVE_GETTIMEOFDAY
+// ----------------------------------------------------------------------------
+// prototypes
+// ----------------------------------------------------------------------------
+
+wxLongLong wxGetLocalTimeMillis();
+
// ============================================================================
// implementation
// ============================================================================
-wxLongLong wxGetLocalTimeMillis();
+// ----------------------------------------------------------------------------
+// wxTimerBase
+// ----------------------------------------------------------------------------
+
+void wxTimerBase::Notify()
+{
+ // the base class version generates an event if it has owner - which it
+ // should because otherwise nobody can process timer events
+ wxCHECK_RET( m_owner, _T("wxTimer::Notify() should be overridden.") );
+
+ wxTimerEvent event(m_idTimer, m_milli);
+ (void)m_owner->ProcessEvent(event);
+}
// ----------------------------------------------------------------------------
// wxStopWatch
/////////////////////////////////////////////////////////////////////////////
-// Name: statusbr.cpp
-// Purpose: wxStatusBar class implementation
+// Name: generic/statusbr.cpp
+// Purpose: wxStatusBarGeneric class implementation
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma hdrstop
#endif
+//#if !defined(__WIN32__) || !wxUSE_NATIVE_STATUSBAR
+
#ifndef WX_PRECOMP
#include "wx/setup.h"
#include "wx/frame.h"
#include "wx/msw/winundef.h"
#endif
-IMPLEMENT_DYNAMIC_CLASS(wxStatusBar, wxWindow)
+IMPLEMENT_DYNAMIC_CLASS(wxStatusBarGeneric, wxWindow)
+
+#if !defined(__WIN32__) || !wxUSE_NATIVE_STATUSBAR
+ IMPLEMENT_DYNAMIC_CLASS(wxStatusBar, wxStatusBarGeneric)
+#endif // Win32 && wxUSE_NATIVE_STATUSBAR
-BEGIN_EVENT_TABLE(wxStatusBar, wxWindow)
- EVT_PAINT(wxStatusBar::OnPaint)
- EVT_SYS_COLOUR_CHANGED(wxStatusBar::OnSysColourChanged)
+BEGIN_EVENT_TABLE(wxStatusBarGeneric, wxWindow)
+ EVT_PAINT(wxStatusBarGeneric::OnPaint)
+ EVT_SYS_COLOUR_CHANGED(wxStatusBarGeneric::OnSysColourChanged)
END_EVENT_TABLE()
// Default status border dimensions
#define wxTHICK_LINE_BORDER 2
#define wxTHICK_LINE_WIDTH 1
-wxStatusBar::wxStatusBar(void)
+wxStatusBarGeneric::wxStatusBarGeneric()
{
m_statusWidths = (int *) NULL;
m_statusStrings = (wxString *) NULL;
m_borderY = wxTHICK_LINE_BORDER;
}
-wxStatusBar::~wxStatusBar(void)
+wxStatusBarGeneric::~wxStatusBarGeneric()
{
# ifdef __WXMSW__
SetFont(wxNullFont);
delete[] m_statusStrings;
}
-bool wxStatusBar::Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
+bool wxStatusBarGeneric::Create(wxWindow *parent,
+ wxWindowID id,
+ long style,
+ const wxString& name)
{
m_statusWidths = (int *) NULL;
m_statusStrings = (wxString *) NULL;
m_borderX = wxTHICK_LINE_BORDER;
m_borderY = wxTHICK_LINE_BORDER;
- bool success = wxWindow::Create(parent, id, pos, size, style | wxTAB_TRAVERSAL, name);
+ bool success = wxWindow::Create(parent, id,
+ wxDefaultPosition, wxDefaultSize,
+ style | wxTAB_TRAVERSAL, name);
// Don't wish this to be found as a child
#ifndef __WXMAC__
return success;
}
-void wxStatusBar::SetFieldsCount(int number, const int widths[])
+void wxStatusBarGeneric::SetFieldsCount(int number, const int widths[])
{
m_nFields = number;
for (i = 0; i < number; i++)
m_statusStrings[i] = "";
- if ( widths )
- SetStatusWidths(number, widths);
+ if ( widths )
+ SetStatusWidths(number, widths);
}
-void wxStatusBar::SetStatusText(const wxString& text, int number)
+void wxStatusBarGeneric::SetStatusText(const wxString& text, int number)
{
if ((number < 0) || (number >= m_nFields))
return;
m_statusStrings[number] = text;
Refresh();
-
-#ifdef __WXMSW__
- // For some reason, this can cause major GDI problems - graphics
- // all over the place. E.g. in print previewing.
-// ::UpdateWindow((HWND) GetHWND());
-#endif
}
-wxString wxStatusBar::GetStatusText(int n) const
+wxString wxStatusBarGeneric::GetStatusText(int n) const
{
- if ((n < 0) || (n >= m_nFields))
- return wxString("");
- else
+ wxCHECK_MSG( (n >= 0) && (n < m_nFields), wxEmptyString,
+ _T("invalid status bar field index") );
+
return m_statusStrings[n];
}
-void wxStatusBar::SetStatusWidths(int n, const int widths_field[])
+void wxStatusBarGeneric::SetStatusWidths(int n, const int widths_field[])
{
// only set status widths, when n == number of statuswindows
if (n == m_nFields)
}
}
-void wxStatusBar::OnPaint(wxPaintEvent& WXUNUSED(event) )
+void wxStatusBarGeneric::OnPaint(wxPaintEvent& WXUNUSED(event) )
{
wxPaintDC dc(this);
# endif // MSW
}
-void wxStatusBar::DrawFieldText(wxDC& dc, int i)
+void wxStatusBarGeneric::DrawFieldText(wxDC& dc, int i)
{
int leftMargin = 2;
int xpos = rect.x + leftMargin;
int ypos = (int) (((rect.height - y) / 2 ) + rect.y + 0.5) ;
-
+
#if defined( __WXGTK__ ) || defined(__WXMAC__)
xpos++;
ypos++;
dc.DestroyClippingRegion();
}
-void wxStatusBar::DrawField(wxDC& dc, int i)
+void wxStatusBarGeneric::DrawField(wxDC& dc, int i)
{
wxRect rect;
GetFieldRect(i, rect);
}
// Get the position and size of the field's internal bounding rectangle
-bool wxStatusBar::GetFieldRect(int n, wxRect& rect) const
+bool wxStatusBarGeneric::GetFieldRect(int n, wxRect& rect) const
{
- if ((n < 0) || (n >= m_nFields))
- return FALSE;
+ wxCHECK_MSG( (n >= 0) && (n < m_nFields), FALSE,
+ _T("invalid status bar field index") );
int width, height;
GetClientSize(&width, &height);
}
// Initialize colours
-void wxStatusBar::InitColours(void)
+void wxStatusBarGeneric::InitColours()
{
// Shadow colours
#if defined(__WIN95__)
}
// Responds to colour changes, and passes event on to children.
-void wxStatusBar::OnSysColourChanged(wxSysColourChangedEvent& event)
+void wxStatusBarGeneric::OnSysColourChanged(wxSysColourChangedEvent& event)
{
InitColours();
Refresh();
wxWindow::OnSysColourChanged(event);
}
+void wxStatusBarGeneric::SetMinHeight(int height)
+{
+ // check that this min height is not less than minimal height for the
+ // current font
+ wxClientDC dc(this);
+ wxCoord y;
+ dc.GetTextExtent( _T("X"), NULL, &y );
+
+ if ( height > (11*y)/10 )
+ {
+ SetSize(-1, -1, -1, height + 2*m_borderY);
+ }
+}
+
+//#endif // Win32 && wxUSE_NATIVE_STATUSBAR
/////////////////////////////////////////////////////////////////////////////
-// Name: timer.cpp
+// Name: gtk/timer.cpp
// Purpose:
// Author: Robert Roebling
// Id: $Id$
return TRUE;
}
-wxTimer::wxTimer()
+void wxTimer::Init()
{
m_tag = -1;
m_milli = 1000;
- m_oneShot = FALSE;
}
wxTimer::~wxTimer()
/////////////////////////////////////////////////////////////////////////////
-// Name: timer.cpp
+// Name: gtk/timer.cpp
// Purpose:
// Author: Robert Roebling
// Id: $Id$
return TRUE;
}
-wxTimer::wxTimer()
+void wxTimer::Init()
{
m_tag = -1;
m_milli = 1000;
- m_oneShot = FALSE;
}
wxTimer::~wxTimer()
{
m_logicalFunction = function;
- SetRop((WXHDC) m_hDC);
+ SetRop(m_hDC);
}
void wxDC::SetRop(WXHDC dc)
{
- if (!dc || m_logicalFunction < 0)
+ if ( !dc || m_logicalFunction < 0 )
return;
- int c_rop;
-
+ int rop;
+
switch (m_logicalFunction)
{
- case wxXOR: c_rop = R2_XORPEN; break;
- case wxINVERT: c_rop = R2_NOT; break;
- case wxOR_REVERSE: c_rop = R2_MERGEPENNOT; break;
- case wxAND_REVERSE: c_rop = R2_MASKPENNOT; break;
- case wxCLEAR: c_rop = R2_WHITE; break;
- case wxSET: c_rop = R2_BLACK; break;
- case wxOR_INVERT: c_rop = R2_MERGENOTPEN; break;
- case wxAND: c_rop = R2_MASKPEN; break;
- case wxOR: c_rop = R2_MERGEPEN; break;
- case wxEQUIV: c_rop = R2_NOTXORPEN; break;
- case wxNAND: c_rop = R2_NOTMASKPEN; break;
- case wxAND_INVERT: c_rop = R2_MASKNOTPEN; break;
- case wxCOPY: c_rop = R2_COPYPEN; break;
- case wxNO_OP: c_rop = R2_NOP; break;
- case wxSRC_INVERT: c_rop = R2_NOTCOPYPEN; break;
- case wxNOR: c_rop = R2_NOTMERGEPEN; break;
+ case wxXOR: rop = R2_XORPEN; break;
+ case wxINVERT: rop = R2_NOT; break;
+ case wxOR_REVERSE: rop = R2_MERGEPENNOT; break;
+ case wxAND_REVERSE: rop = R2_MASKPENNOT; break;
+ case wxCLEAR: rop = R2_WHITE; break;
+ case wxSET: rop = R2_BLACK; break;
+ case wxOR_INVERT: rop = R2_MERGENOTPEN; break;
+ case wxAND: rop = R2_MASKPEN; break;
+ case wxOR: rop = R2_MERGEPEN; break;
+ case wxEQUIV: rop = R2_NOTXORPEN; break;
+ case wxNAND: rop = R2_NOTMASKPEN; break;
+ case wxAND_INVERT: rop = R2_MASKNOTPEN; break;
+ case wxCOPY: rop = R2_COPYPEN; break;
+ case wxNO_OP: rop = R2_NOP; break;
+ case wxSRC_INVERT: rop = R2_NOTCOPYPEN; break;
+ case wxNOR: rop = R2_NOTMERGEPEN; break;
default:
- {
wxFAIL_MSG( wxT("unsupported logical function") );
- break;
- }
+ return;
}
- SetROP2((HDC) dc, c_rop);
+
+ SetROP2(GetHdc(), rop);
}
bool wxDC::StartDoc(const wxString& message)
DWORD dwRop = SRCCOPY;
switch (rop)
{
- case wxXOR: dwRop = SRCINVERT; break;
- case wxINVERT: dwRop = DSTINVERT; break;
- case wxOR_REVERSE: dwRop = 0x00DD0228; break;
- case wxAND_REVERSE: dwRop = SRCERASE; break;
- case wxCLEAR: dwRop = BLACKNESS; break;
- case wxSET: dwRop = WHITENESS; break;
- case wxOR_INVERT: dwRop = MERGEPAINT; break;
- case wxAND: dwRop = SRCAND; break;
- case wxOR: dwRop = SRCPAINT; break;
- case wxEQUIV: dwRop = 0x00990066; break;
- case wxNAND: dwRop = 0x007700E6; break;
- case wxAND_INVERT: dwRop = 0x00220326; break;
- case wxCOPY: dwRop = SRCCOPY; break;
- case wxNO_OP: dwRop = 0x00AA0029; break;
- case wxSRC_INVERT: dwRop = NOTSRCCOPY; break;
+ case wxXOR: dwRop = SRCINVERT; break;
+ case wxINVERT: dwRop = DSTINVERT; break;
+ case wxOR_REVERSE: dwRop = 0x00DD0228; break;
+ case wxAND_REVERSE: dwRop = SRCERASE; break;
+ case wxCLEAR: dwRop = BLACKNESS; break;
+ case wxSET: dwRop = WHITENESS; break;
+ case wxOR_INVERT: dwRop = MERGEPAINT; break;
+ case wxAND: dwRop = SRCAND; break;
+ case wxOR: dwRop = SRCPAINT; break;
+ case wxEQUIV: dwRop = 0x00990066; break;
+ case wxNAND: dwRop = 0x007700E6; break;
+ case wxAND_INVERT: dwRop = 0x00220326; break;
+ case wxCOPY: dwRop = SRCCOPY; break;
+ case wxNO_OP: dwRop = 0x00AA0029; break;
+ case wxSRC_INVERT: dwRop = NOTSRCCOPY; break;
case wxNOR: dwRop = NOTSRCCOPY; break;
default:
- {
wxFAIL_MSG( wxT("unsupported logical function") );
- break;
- }
+ return FALSE;
}
#if wxUSE_STATUSBAR
#include "wx/statusbr.h"
-
- #if wxUSE_NATIVE_STATUSBAR
- #include "wx/msw/statbr95.h"
- #endif
+ #include "wx/generic/statusbr.h"
#endif // wxUSE_STATUSBAR
#if wxUSE_TOOLBAR
#if wxUSE_NATIVE_STATUSBAR
if ( UsesNativeStatusBar() )
{
- statusBar = new wxStatusBar95(this, id, style);
+ statusBar = (wxStatusBar *)new wxStatusBar95(this, id, style);
statusBar->SetFieldsCount(number);
}
else
#endif
{
- statusBar = wxFrameBase::OnCreateStatusBar(number, style, id, name);
+ statusBar = (wxStatusBar *)new wxStatusBarGeneric(this, id, style, name);
+
+ // Set the height according to the font and the border size
+ wxClientDC dc(statusBar);
+ dc.SetFont(statusBar->GetFont());
+
+ wxCoord y;
+ dc.GetTextExtent(_T("X"), NULL, &y );
+
+ int height = (int)( (11*y)/10 + 2*statusBar->GetBorderY());
+
+ statusBar->SetSize(-1, -1, -1, height);
+
+ statusBar->SetFieldsCount(number);
}
return statusBar;
void wxFrame::PositionStatusBar()
{
- // native status bar positions itself
- if ( m_frameStatusBar
+ if ( !m_frameStatusBar )
+ return;
+
+ // native status bar positions itself, but we must forward the WM_SIZE
+ // messages to it
#if wxUSE_NATIVE_STATUSBAR
- && !m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95))
-#endif
- )
+ wxStatusBar95 *sb = wxDynamicCast(m_frameStatusBar, wxStatusBar95);
+ if ( sb )
+ {
+ wxSizeEvent event(GetSize(), sb->GetId());
+ event.SetEventObject(sb);
+
+ sb->GetEventHandler()->ProcessEvent(event);
+ }
+ else
+#endif // wxUSE_NATIVE_STATUSBAR
{
int w, h;
GetClientSize(&w, &h);
if ( !m_iconized )
{
- // forward WM_SIZE to status bar control
-#if wxUSE_NATIVE_STATUSBAR
- if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)))
- {
- wxSizeEvent event(wxSize(x, y), m_frameStatusBar->GetId());
- event.SetEventObject( m_frameStatusBar );
-
- ((wxStatusBar95 *)m_frameStatusBar)->OnSize(event);
- }
-#endif // wxUSE_NATIVE_STATUSBAR
-
PositionStatusBar();
PositionToolBar();
// Name: msw/statbr95.cpp
// Purpose: native implementation of wxStatusBar
// Author: Vadim Zeitlin
-// Modified by:
+// Modified by:
// Created: 04.04.98
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
#include "wx/dcclient.h"
#endif
-#ifdef __WIN95__
+#if defined(__WIN95__) && wxUSE_NATIVE_STATUSBAR
#include "wx/log.h"
-#include "wx/generic/statusbr.h"
-#include "wx/msw/statbr95.h"
+#include "wx/statusbr.h"
#include "wx/msw/private.h"
#include <windowsx.h>
#include <commctrl.h>
#endif
-#if wxUSE_NATIVE_STATUSBAR
+// ----------------------------------------------------------------------------
+// wxWindows macros
+// ----------------------------------------------------------------------------
- IMPLEMENT_DYNAMIC_CLASS(wxStatusBar95, wxStatusBar);
+IMPLEMENT_DYNAMIC_CLASS(wxStatusBar95, wxWindow);
+IMPLEMENT_DYNAMIC_CLASS(wxStatusBar, wxStatusBar95)
- BEGIN_EVENT_TABLE(wxStatusBar95, wxStatusBar)
+BEGIN_EVENT_TABLE(wxStatusBar95, wxWindow)
EVT_SIZE(wxStatusBar95::OnSize)
- END_EVENT_TABLE()
-
+END_EVENT_TABLE()
// ----------------------------------------------------------------------------
// macros
#define StatusBar_GetTextLen(h, n) LOWORD(SendMessage(h, SB_GETTEXTLENGTH, (WPARAM)n, 0))
#define StatusBar_GetText(h, n, s) LOWORD(SendMessage(h, SB_GETTEXT, (WPARAM)n, (LPARAM)(LPTSTR)s))
-#define hwnd ((HWND)m_hWnd)
+// ----------------------------------------------------------------------------
+//
+// ----------------------------------------------------------------------------
+
+static WNDPROC gs_wndprocStatBar = NULL;
+
+LRESULT APIENTRY wxStatusBarProc(HWND hwnd,
+ UINT message,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ if ( message == WM_COMMAND )
+ {
+ wxStatusBar95 *sb = (wxStatusBar95 *)GetWindowLong(hwnd, GWL_USERDATA);
+ sb->MSWWindowProc(message, wParam, lParam);
+ }
+
+ return ::CallWindowProc(gs_wndprocStatBar, hwnd, message, wParam, lParam);
+}
// ============================================================================
// implementation
m_windowId = 0;
}
-wxStatusBar95::wxStatusBar95(wxWindow *parent, wxWindowID id, long style)
+bool wxStatusBar95::Create(wxWindow *parent,
+ wxWindowID id,
+ long style,
+ const wxString& name)
{
- Create(parent, id, style);
-}
+ SetName(name);
+ SetParent(parent);
+
+ if (id == -1)
+ m_windowId = NewControlId();
+ else
+ m_windowId = id;
+
+ DWORD wstyle = WS_CHILD | WS_VISIBLE;
+ if ( style & wxST_SIZEGRIP )
+ wstyle |= SBARS_SIZEGRIP;
+
+ m_hWnd = (WXHWND)CreateStatusWindow(wstyle,
+ wxEmptyString,
+ GetHwndOf(parent),
+ m_windowId);
+ if ( m_hWnd == 0 )
+ {
+ wxLogSysError(_("Failed to create a status bar."));
+
+ return FALSE;
+ }
-bool wxStatusBar95::Create(wxWindow *parent, wxWindowID id, long style)
-{
- SetParent(parent);
-
- if (id == -1)
- m_windowId = NewControlId();
- else
- m_windowId = id;
-
- DWORD wstyle = WS_CHILD | WS_VISIBLE;
- if ( style & wxST_SIZEGRIP )
- wstyle |= SBARS_SIZEGRIP;
-
- m_hWnd = (WXHWND)CreateStatusWindow(wstyle,
- wxT(""),
- (HWND)parent->GetHWND(),
- m_windowId);
- if ( m_hWnd == 0 ) {
- wxLogSysError(wxT("can't create status bar window"));
- return FALSE;
- }
+ // for some reason, subclassing in the usual way doesn't work at all - many
+ // strange things start happening (status bar is not positioned correctly,
+ // all methods fail...)
+ // SubclassWin(m_hWnd);
+
+ // but we want to process the messages from it still, so must subclass it
+ gs_wndprocStatBar = (WNDPROC)GetWindowLong(GetHwnd(), GWL_WNDPROC);
+ SetWindowLong(GetHwnd(), GWL_WNDPROC, (LONG)wxStatusBarProc);
+ SetWindowLong(GetHwnd(), GWL_USERDATA, (LONG)this);
- // this doesn't work: display problems (white 1-2 pixel borders...)
- // SubclassWin(m_hWnd);
+ return TRUE;
+}
- return TRUE;
+wxStatusBar95::~wxStatusBar95()
+{
+ delete [] m_statusWidths;
}
void wxStatusBar95::CopyFieldsWidth(const int widths[])
void wxStatusBar95::SetFieldsCount(int nFields, const int widths[])
{
- wxASSERT( (nFields > 0) && (nFields < 255) );
+ // this is Windows limitation
+ wxASSERT_MSG( (nFields > 0) && (nFields < 255), _T("too many fields") );
m_nFields = nFields;
void wxStatusBar95::SetStatusWidths(int n, const int widths[])
{
- // @@ I don't understand what this function is for...
- wxASSERT( n == m_nFields );
+ wxASSERT_MSG( n == m_nFields, _T("field number mismatch") );
CopyFieldsWidth(widths);
SetFieldsWidth();
if ( !m_nFields )
return;
- int *pWidths = new int[m_nFields];
+ int aBorders[3];
+ SendMessage(GetHwnd(), SB_GETBORDERS, 0, (LPARAM)aBorders);
- int nWindowWidth, y;
- GetClientSize(&nWindowWidth, &y);
+ int extraWidth = aBorders[2]; // space between fields
- if ( m_statusWidths == NULL ) {
- // default: all fields have the same width
- int nWidth = nWindowWidth / m_nFields;
- for ( int i = 0; i < m_nFields; i++ )
- pWidths[i] = (i + 1) * nWidth;
- }
- else {
- // -1 doesn't mean the same thing for wxWindows and Win32, recalc
- int nTotalWidth = 0,
- nVarCount = 0,
- i;
- for ( i = 0; i < m_nFields; i++ ) {
- if ( m_statusWidths[i] == -1 )
- nVarCount++;
- else
- nTotalWidth += m_statusWidths[i];
- }
+ int *pWidths = new int[m_nFields];
- if ( nVarCount == 0 ) {
- // wrong! at least one field must be of variable width
- wxFAIL;
+ int nWindowWidth, y;
+ GetClientSize(&nWindowWidth, &y);
- nVarCount++;
+ if ( m_statusWidths == NULL ) {
+ // default: all fields have the same width
+ int nWidth = nWindowWidth / m_nFields;
+ for ( int i = 0; i < m_nFields; i++ )
+ pWidths[i] = (i + 1) * nWidth;
}
-
- int nVarWidth = (nWindowWidth - nTotalWidth) / nVarCount;
-
- // do fill the array
- int nCurPos = 0;
- for ( i = 0; i < m_nFields; i++ ) {
- if ( m_statusWidths[i] == -1 )
- nCurPos += nVarWidth;
- else
- nCurPos += m_statusWidths[i];
- pWidths[i] = nCurPos;
+ else {
+ // -1 doesn't mean the same thing for wxWindows and Win32, recalc
+ int nTotalWidth = 0,
+ nVarCount = 0,
+ i;
+ for ( i = 0; i < m_nFields; i++ ) {
+ if ( m_statusWidths[i] == -1 )
+ nVarCount++;
+ else
+ nTotalWidth += m_statusWidths[i] + extraWidth;
+ }
+
+ if ( nVarCount == 0 ) {
+ wxFAIL_MSG( _T("at least one field must be of variable width") );
+
+ nVarCount++;
+ }
+
+ int nVarWidth = (nWindowWidth - nTotalWidth) / nVarCount;
+
+ // do fill the array
+ int nCurPos = 0;
+ for ( i = 0; i < m_nFields; i++ ) {
+ if ( m_statusWidths[i] == -1 )
+ nCurPos += nVarWidth;
+ else
+ nCurPos += m_statusWidths[i] + extraWidth;
+ pWidths[i] = nCurPos;
+ }
}
- }
- if ( !StatusBar_SetParts(hwnd, m_nFields, pWidths) ) {
- wxLogLastError(wxT("StatusBar_SetParts"));
- }
+ if ( !StatusBar_SetParts(GetHwnd(), m_nFields, pWidths) ) {
+ wxLogLastError(wxT("StatusBar_SetParts"));
+ }
- delete [] pWidths;
+ delete [] pWidths;
}
void wxStatusBar95::SetStatusText(const wxString& strText, int nField)
{
- if ( !StatusBar_SetText(hwnd, nField, strText) ) {
+ wxCHECK_RET( (nField >= 0) && (nField < m_nFields),
+ _T("invalid statusbar field index") );
+
+ if ( !StatusBar_SetText(GetHwnd(), nField, strText) ) {
wxLogLastError(wxT("StatusBar_SetText"));
}
}
wxString wxStatusBar95::GetStatusText(int nField) const
{
- wxASSERT( (nField > -1) && (nField < m_nFields) );
+ wxCHECK_MSG( (nField >= 0) && (nField < m_nFields), wxEmptyString,
+ _T("invalid statusbar field index") );
- wxString str(wxT(""));
- int len = StatusBar_GetTextLen(hwnd, nField);
+ wxString str;
+ int len = StatusBar_GetTextLen(GetHwnd(), nField);
if (len > 0)
{
- StatusBar_GetText(hwnd, nField, str.GetWriteBuf(len));
- str.UngetWriteBuf();
+ StatusBar_GetText(GetHwnd(), nField, str.GetWriteBuf(len));
+ str.UngetWriteBuf();
}
return str;
}
+int wxStatusBar95::GetBorderX() const
+{
+ int aBorders[3];
+ SendMessage(GetHwnd(), SB_GETBORDERS, 0, (LPARAM)aBorders);
+
+ return aBorders[0];
+}
+
+int wxStatusBar95::GetBorderY() const
+{
+ int aBorders[3];
+ SendMessage(GetHwnd(), SB_GETBORDERS, 0, (LPARAM)aBorders);
+
+ return aBorders[1];
+}
+
+void wxStatusBar95::SetMinHeight(int height)
+{
+ SendMessage(GetHwnd(), SB_SETMINHEIGHT, height + 2*GetBorderY(), 0);
+
+ // have to send a (dummy) WM_SIZE to redraw it now
+ SendMessage(GetHwnd(), WM_SIZE, 0, 0);
+}
+
+bool wxStatusBar95::GetFieldRect(int i, wxRect& rect) const
+{
+ wxCHECK_MSG( (i >= 0) && (i < m_nFields), FALSE,
+ _T("invalid statusbar field index") );
+
+ RECT r;
+ if ( !::SendMessage(GetHwnd(), SB_GETRECT, i, (LPARAM)&r) )
+ {
+ wxLogLastError("SendMessage(SB_GETRECT)");
+ }
+
+ wxCopyRECTToRect(r, rect);
+
+ return TRUE;
+}
+
void wxStatusBar95::OnSize(wxSizeEvent& event)
{
- FORWARD_WM_SIZE(hwnd, SIZE_RESTORED, event.GetSize().x, event.GetSize().y,
+ FORWARD_WM_SIZE(GetHwnd(), SIZE_RESTORED,
+ event.GetSize().x, event.GetSize().y,
SendMessage);
// adjust fields widths to the new size
SetFieldsWidth();
}
-#endif // wxUSE_NATIVE_STATUSBAR
+#endif // __WIN95__ && wxUSE_NATIVE_STATUSBAR
-#else
- #error "wxStatusBar95 is only available under Windows 95 and later."
-#endif // __WIN95__
-
#define _EXPORT _export
#endif
- IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
+IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
// ============================================================================
// implementation
// wxTimer class
// ----------------------------------------------------------------------------
-wxTimer::wxTimer()
+void wxTimer::Init()
{
m_id = 0;
}