1. wxTimer change - now generates EVT_TIMER()

2. wxStatusBar reorganisation


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5848 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-02-05 01:57:38 +00:00
parent 85401ffe5c
commit ed79198695
18 changed files with 606 additions and 287 deletions

View File

@@ -69,8 +69,9 @@ extern const wxEventType wxEVT_COMMAND_TOOL_RCLICKED;
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;
@@ -283,6 +284,9 @@ const wxEventType wxEVT_COMMAND_SPINCTRL_UPDATED = wxEVT_FIRST + 18;
/* 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;

View File

@@ -1,53 +1,66 @@
/////////////////////////////////////////////////////////////////////////////
// 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);
}
~wxStatusBar();
~wxStatusBarGeneric();
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr);
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,
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);
@@ -56,20 +69,24 @@ public:
// 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();
@@ -78,8 +95,6 @@ public:
void OnSysColourChanged(wxSysColourChangedEvent& event);
protected:
int * m_statusWidths;
int m_nFields;
wxString * m_statusStrings;
int m_borderX;
int m_borderY;
@@ -87,8 +102,10 @@ protected:
wxPen m_mediumShadowPen;
wxPen m_hilightPen;
private:
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxStatusBarGeneric)
};
#endif
// __STATUSBRH_G__
// _WX_GENERIC_STATUSBR_H_

View File

@@ -1,10 +1,10 @@
/////////////////////////////////////////////////////////////////////////////
// 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
/////////////////////////////////////////////////////////////////////////////
@@ -22,7 +22,9 @@
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 );
@@ -31,6 +33,8 @@ public:
virtual bool IsRunning() const { return m_tag != -1; }
protected:
void Init();
int m_tag;
private:

View File

@@ -1,10 +1,10 @@
/////////////////////////////////////////////////////////////////////////////
// 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
/////////////////////////////////////////////////////////////////////////////
@@ -22,7 +22,9 @@
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 );
@@ -31,6 +33,8 @@ public:
virtual bool IsRunning() const { return m_tag != -1; }
protected:
void Init();
int m_tag;
private:

View File

@@ -226,6 +226,15 @@ inline void wxRGBToColour(wxColour& c, COLORREF rgb)
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);

View File

@@ -16,38 +16,57 @@
#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);
}
// create status line
bool Create(wxWindow *parent, wxWindowID id = -1, long style = wxST_SIZEGRIP);
bool Create(wxWindow *parent,
wxWindowID id = -1,
long style = wxST_SIZEGRIP,
const wxString& name = wxEmptyString);
// a status line can have several (<256) fields numbered from 0
virtual void SetFieldsCount(int number = 1, const int widths[] = NULL);
virtual ~wxStatusBar95();
// 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;
// a status line can have several (<256) fields numbered from 0
virtual void SetFieldsCount(int number = 1, const int *widths = NULL);
// set status line fields' widths
virtual void SetStatusWidths(int n, const int widths_field[]);
// 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;
// we're going to process WM_SIZE (of the parent window)
void OnSize(wxSizeEvent& event);
// set status line fields' widths
virtual void SetStatusWidths(int n, const int widths_field[]);
DECLARE_EVENT_TABLE()
// sets the minimal vertical size of the status bar
virtual void SetMinHeight(int height);
// get the position and size of the field's internal bounding rectangle
virtual bool GetFieldRect(int i, wxRect& rect) const;
// 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

View File

@@ -21,7 +21,9 @@ class WXDLLEXPORT wxTimer : public wxTimerBase
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);
@@ -30,6 +32,8 @@ public:
virtual bool IsRunning() const { return m_id != 0; }
protected:
void Init();
long m_id;
private:

View File

@@ -1,7 +1,92 @@
/////////////////////////////////////////////////////////////////////////////
// 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_

View File

@@ -1,12 +1,13 @@
/////////////////////////////////////////////////////////////////////////////
// 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_
@@ -19,6 +20,7 @@
#include "wx/setup.h"
#include "wx/object.h"
#include "wx/longlong.h"
#include "wx/event.h"
// ----------------------------------------------------------------------------
// wxTimer
@@ -28,7 +30,22 @@
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
// ----------------------
@@ -51,8 +68,9 @@ public:
// 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
// ------------
@@ -73,10 +91,20 @@ public:
#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__)
@@ -94,12 +122,39 @@ protected:
#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);
@@ -112,14 +167,14 @@ public:
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();
@@ -127,7 +182,6 @@ void WXDLLEXPORT wxStartTimer();
// -- DEPRECATED: use wxStopWatch instead
long WXDLLEXPORT wxGetElapsedTime(bool resetTimer = TRUE);
// ----------------------------------------------------------------------------
// global time functions
// ----------------------------------------------------------------------------