*** empty log message ***

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4043 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
1999-10-18 03:30:47 +00:00
parent 45bee2eea9
commit d90895ac11
28 changed files with 5800 additions and 1646 deletions

View File

@@ -30,6 +30,8 @@
// General features // General features
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#define wxUSE_NET_API 1 // Utilize OS/2's UPM netapi's
#define wxUSE_CONFIG 1 #define wxUSE_CONFIG 1
// Use wxConfig, with CreateConfig in wxApp // Use wxConfig, with CreateConfig in wxApp

View File

@@ -30,6 +30,8 @@
// General features // General features
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#define wxUSE_NET_API 1 // Utilize OS/2's UPM netapi's
#define wxUSE_CONFIG 1 #define wxUSE_CONFIG 1
// Use wxConfig, with CreateConfig in wxApp // Use wxConfig, with CreateConfig in wxApp

View File

@@ -1,11 +1,11 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: stattext.h // Name: stattext.h
// Purpose: wxStaticText class // Purpose: wxStaticText class
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/17/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -23,6 +23,7 @@ WXDLLEXPORT_DATA(extern const char*) wxStaticTextNameStr;
class WXDLLEXPORT wxStaticText: public wxControl class WXDLLEXPORT wxStaticText: public wxControl
{ {
DECLARE_DYNAMIC_CLASS(wxStaticText) DECLARE_DYNAMIC_CLASS(wxStaticText)
public: public:
inline wxStaticText() { } inline wxStaticText() { }
@@ -44,12 +45,18 @@ class WXDLLEXPORT wxStaticText: public wxControl
const wxString& name = wxStaticTextNameStr); const wxString& name = wxStaticTextNameStr);
// accessors // accessors
void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
void SetLabel(const wxString&); void SetLabel(const wxString&);
// operations // overriden base class virtuals
virtual void Command(wxCommandEvent& WXUNUSED(event)) {}; virtual bool AcceptsFocus() const { return FALSE; }
virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {};
// callbacks
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
virtual MRESULT OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
protected:
virtual wxSize DoGetBestSize();
}; };
#endif #endif

View File

@@ -2,31 +2,25 @@
// Name: statusbr.h // Name: statusbr.h
// Purpose: native implementation of wxStatusBar. Optional; can use generic // Purpose: native implementation of wxStatusBar. Optional; can use generic
// version instead. // version instead.
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/17/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_STATBAR_H_ #ifndef _WX_STATBAR_H_
#define _WX_STATBAR_H_ #define _WX_STATBAR_H_
#ifdef __GNUG__ class WXDLLEXPORT wxStatusBarPM : public wxStatusBar
#pragma interface "statbar.h"
#endif
#include "wx/generic/statusbr.h"
class WXDLLEXPORT wxStatusBarXX : public wxStatusBar
{ {
DECLARE_DYNAMIC_CLASS(wxStatusBarXX); DECLARE_DYNAMIC_CLASS(wxStatusBarPM);
public: public:
// ctors // ctors
wxStatusBarXX(); wxStatusBarPM();
wxStatusBarXX(wxWindow *parent, wxWindowID id = -1, long style = wxST_SIZEGRIP); wxStatusBarPM(wxWindow *parent, wxWindowID id = -1, long style = wxST_SIZEGRIP);
// create status line // 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);
@@ -50,4 +44,5 @@ protected:
void SetFieldsWidth(); void SetFieldsWidth();
}; };
#endif #endif // _WX_STATBAR_H_

View File

@@ -1,21 +1,17 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: tabctrl.h // Name: tabctrl.h
// Purpose: wxTabCtrl class // Purpose: wxTabCtrl class
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: ??/??/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TABCTRL_H_ #ifndef _WX_TABCTRL_H_
#define _WX_TABCTRL_H_ #define _WX_TABCTRL_H_
#ifdef __GNUG__
#pragma interface "tabctrl.h"
#endif
class wxImageList; class wxImageList;
/* /*
@@ -111,7 +107,10 @@ class WXDLLEXPORT wxTabCtrl: public wxControl
// Insert an item // Insert an item
bool InsertItem(int item, const wxString& text, int imageId = -1, void* data = NULL); bool InsertItem(int item, const wxString& text, int imageId = -1, void* data = NULL);
void Command(wxCommandEvent& event); virtual bool OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
// Responds to colour changes
void OnSysColourChanged(wxSysColourChangedEvent& event);
protected: protected:
wxImageList* m_imageList; wxImageList* m_imageList;

View File

@@ -2,48 +2,91 @@
// File: taskbar.h // File: taskbar.h
// Purpose: Defines wxTaskBarIcon class for manipulating icons on the // Purpose: Defines wxTaskBarIcon class for manipulating icons on the
// task bar. Optional. // task bar. Optional.
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/17/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
#ifndef _WX_TASKBAR_H_ #ifndef _WX_TASKBAR_H_
#define _WX_TASKBAR_H_ #define _WX_TASKBAR_H_
#ifdef __GNUG__ #include <wx/event.h>
#pragma interface "taskbar.h"
#endif
#include <wx/list.h> #include <wx/list.h>
#include <wx/icon.h> #include <wx/icon.h>
class wxTaskBarIcon: public wxObject class WXDLLEXPORT wxTaskBarIcon: public wxEvtHandler {
{ DECLARE_DYNAMIC_CLASS(wxTaskBarIcon)
public: public:
wxTaskBarIcon(); wxTaskBarIcon(void);
virtual ~wxTaskBarIcon(); virtual ~wxTaskBarIcon(void);
// Accessors // Accessors
inline WXHWND GetHWND() const { return m_hWnd; }
inline bool IsOK() const { return (m_hWnd != 0) ; }
inline bool IsIconInstalled() const { return m_iconAdded; }
// Operations // Operations
bool SetIcon(const wxIcon& icon, const wxString& tooltip = ""); bool SetIcon(const wxIcon& icon, const wxString& tooltip = "");
bool RemoveIcon(); bool RemoveIcon(void);
bool PopupMenu(wxMenu *menu); //, int x, int y);
// Overridables // Overridables
virtual void OnMouseMove(); virtual void OnMouseMove(wxEvent&);
virtual void OnLButtonDown(); virtual void OnLButtonDown(wxEvent&);
virtual void OnLButtonUp(); virtual void OnLButtonUp(wxEvent&);
virtual void OnRButtonDown(); virtual void OnRButtonDown(wxEvent&);
virtual void OnRButtonUp(); virtual void OnRButtonUp(wxEvent&);
virtual void OnLButtonDClick(); virtual void OnLButtonDClick(wxEvent&);
virtual void OnRButtonDClick(); virtual void OnRButtonDClick(wxEvent&);
// Implementation
static wxTaskBarIcon* FindObjectForHWND(WXHWND hWnd);
static void AddObject(wxTaskBarIcon* obj);
static void RemoveObject(wxTaskBarIcon* obj);
static bool RegisterWindowClass();
static WXHWND CreateTaskBarWindow();
MRESULT WindowProc( WXHWND hWnd, UINT msg, MPARAM wParam, MPARAM lParam );
// Data members // Data members
protected: protected:
WXHWND m_hWnd;
bool m_iconAdded;
static wxList sm_taskBarIcons;
static bool sm_registeredClass;
static unsigned int sm_taskbarMsg;
// non-virtual default event handlers to forward events to the virtuals
void _OnMouseMove(wxEvent&);
void _OnLButtonDown(wxEvent&);
void _OnLButtonUp(wxEvent&);
void _OnRButtonDown(wxEvent&);
void _OnRButtonUp(wxEvent&);
void _OnLButtonDClick(wxEvent&);
void _OnRButtonDClick(wxEvent&);
DECLARE_EVENT_TABLE()
}; };
const wxEventType wxEVT_TASKBAR_MOVE = wxEVT_FIRST + 1550;
const wxEventType wxEVT_TASKBAR_LEFT_DOWN = wxEVT_FIRST + 1551;
const wxEventType wxEVT_TASKBAR_LEFT_UP = wxEVT_FIRST + 1552;
const wxEventType wxEVT_TASKBAR_RIGHT_DOWN = wxEVT_FIRST + 1553;
const wxEventType wxEVT_TASKBAR_RIGHT_UP = wxEVT_FIRST + 1554;
const wxEventType wxEVT_TASKBAR_LEFT_DCLICK = wxEVT_FIRST + 1555;
const wxEventType wxEVT_TASKBAR_RIGHT_DCLICK = wxEVT_FIRST + 1556;
#define EVT_TASKBAR_MOVE(fn) { wxEVT_TASKBAR_MOVE, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
#define EVT_TASKBAR_LEFT_DOWN(fn) { wxEVT_TASKBAR_LEFT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
#define EVT_TASKBAR_LEFT_UP(fn) { wxEVT_TASKBAR_LEFT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
#define EVT_TASKBAR_RIGHT_DOWN(fn) { wxEVT_TASKBAR_RIGHT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
#define EVT_TASKBAR_RIGHT_UP(fn) { wxEVT_TASKBAR_RIGHT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
#define EVT_TASKBAR_LEFT_DCLICK(fn) { wxEVT_TASKBAR_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
#define EVT_TASKBAR_RIGHT_DCLICK(fn) { wxEVT_TASKBAR_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
#endif #endif
// _WX_TASKBAR_H_ // _TASKBAR_H_

View File

@@ -1,61 +1,31 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: textctrl.h // Name: textctrl.h
// Purpose: wxTextCtrl class // Purpose: wxTextCtrl class
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/17/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TEXTCTRL_H_ #ifndef _WX_TEXTCTRL_H_
#define _WX_TEXTCTRL_H_ #define _WX_TEXTCTRL_H_
#ifdef __GNUG__ class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase
#pragma interface "textctrl.h"
#endif
#include "wx/control.h"
#if wxUSE_IOSTREAMH
#include <iostream.h>
#else
#include <iostream>
#endif
WXDLLEXPORT_DATA(extern const char*) wxTextCtrlNameStr;
WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
// Single-line text item
class WXDLLEXPORT wxTextCtrl: public wxControl
// TODO Some platforms/compilers don't like inheritance from streambuf.
#if (defined(__BORLANDC__) && !defined(__WIN32__)) || defined(__MWERKS__)
#define NO_TEXT_WINDOW_STREAM
#endif
#ifndef NO_TEXT_WINDOW_STREAM
, public streambuf
#endif
{ {
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
public: public:
// creation // creation
// -------- // --------
wxTextCtrl(); wxTextCtrl();
inline wxTextCtrl(wxWindow *parent, wxWindowID id, wxTextCtrl(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString, const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxTextCtrlNameStr) const wxString& name = wxTextCtrlNameStr)
#ifndef NO_TEXT_WINDOW_STREAM
:streambuf()
#endif
{ {
Create(parent, id, value, pos, size, style, validator, name); Create(parent, id, value, pos, size, style, validator, name);
} }
@@ -63,12 +33,14 @@ public:
bool Create(wxWindow *parent, wxWindowID id, bool Create(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString, const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxTextCtrlNameStr); const wxString& name = wxTextCtrlNameStr);
// accessors // implement base class pure virtuals
// --------- // ----------------------------------
virtual wxString GetValue() const; virtual wxString GetValue() const;
virtual void SetValue(const wxString& value); virtual void SetValue(const wxString& value);
@@ -76,9 +48,38 @@ public:
virtual wxString GetLineText(long lineNo) const; virtual wxString GetLineText(long lineNo) const;
virtual int GetNumberOfLines() const; virtual int GetNumberOfLines() const;
virtual bool IsModified() const;
virtual bool IsEditable() const;
// If the return values from and to are the same, there is no selection.
virtual void GetSelection(long* from, long* to) const;
// operations // operations
// ---------- // ----------
virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
// editing
virtual void Clear();
virtual void Replace(long from, long to, const wxString& value);
virtual void Remove(long from, long to);
// load the controls contents from the file
virtual bool LoadFile(const wxString& file);
// clears the dirty flag
virtual void DiscardEdits();
// writing text inserts it at the current position, appending always
// inserts it at the end
virtual void WriteText(const wxString& text);
virtual void AppendText(const wxString& text);
// translate between the position (which is just an index in the text ctrl
// considering all its contents as a single strings) and (x, y) coordinates
// which represent column and line.
virtual long XYToPosition(long x, long y) const;
virtual bool PositionToXY(long pos, long *x, long *y) const;
virtual void ShowPosition(long pos);
// Clipboard operations // Clipboard operations
virtual void Copy(); virtual void Copy();
@@ -96,51 +97,34 @@ public:
virtual bool CanUndo() const; virtual bool CanUndo() const;
virtual bool CanRedo() const; virtual bool CanRedo() const;
// Insertion point
virtual void SetInsertionPoint(long pos); virtual void SetInsertionPoint(long pos);
virtual void SetInsertionPointEnd(); virtual void SetInsertionPointEnd();
virtual long GetInsertionPoint() const; virtual long GetInsertionPoint() const;
virtual long GetLastPosition() const; virtual long GetLastPosition() const;
virtual void Replace(long from, long to, const wxString& value);
virtual void Remove(long from, long to);
virtual void SetSelection(long from, long to); virtual void SetSelection(long from, long to);
virtual void SetEditable(bool editable); virtual void SetEditable(bool editable);
// If the return values from and to are the same, there is no // Implementation from now on
// selection. // --------------------------
virtual void GetSelection(long* from, long* to) const;
virtual bool IsEditable() const ;
// streambuf implementation virtual void Command(wxCommandEvent& event);
#ifndef NO_TEXT_WINDOW_STREAM virtual bool OS2Command(WXUINT param, WXWORD id);
int overflow(int i);
int sync();
int underflow();
#endif
wxTextCtrl& operator<<(const wxString& s); virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
wxTextCtrl& operator<<(int i); WXUINT message, WXWPARAM wParam,
wxTextCtrl& operator<<(long i); WXLPARAM lParam);
wxTextCtrl& operator<<(float f);
wxTextCtrl& operator<<(double d);
wxTextCtrl& operator<<(const char c);
virtual bool LoadFile(const wxString& file); virtual void AdoptAttributesFromHWND();
virtual bool SaveFile(const wxString& file); virtual void SetupColours();
virtual void WriteText(const wxString& text);
virtual void AppendText(const wxString& text);
virtual void DiscardEdits();
virtual bool IsModified() const;
virtual long XYToPosition(long x, long y) const ; virtual bool AcceptsFocus() const;
virtual void PositionToXY(long pos, long *x, long *y) const ;
virtual void ShowPosition(long pos);
virtual void Clear();
// callbacks // callbacks
// ---------
void OnDropFiles(wxDropFilesEvent& event); void OnDropFiles(wxDropFilesEvent& event);
// void OnChar(wxKeyEvent& event); // Process 'enter' if required void OnChar(wxKeyEvent& event); // Process 'enter' if required
// void OnEraseBackground(wxEraseEvent& event);
void OnCut(wxCommandEvent& event); void OnCut(wxCommandEvent& event);
void OnCopy(wxCommandEvent& event); void OnCopy(wxCommandEvent& event);
void OnPaste(wxCommandEvent& event); void OnPaste(wxCommandEvent& event);
@@ -153,14 +137,16 @@ public:
void OnUpdateUndo(wxUpdateUIEvent& event); void OnUpdateUndo(wxUpdateUIEvent& event);
void OnUpdateRedo(wxUpdateUIEvent& event); void OnUpdateRedo(wxUpdateUIEvent& event);
// Implementation
// --------------
virtual void Command(wxCommandEvent& event);
protected: protected:
wxString m_fileName; // call this to increase the size limit (will do nothing if the current
// limit is big enough)
void AdjustSpaceLimit();
virtual wxSize DoGetBestSize();
private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
}; };
#endif #endif

View File

@@ -1,25 +1,23 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: timer.h // Name: timer.h
// Purpose: wxTimer class // Purpose: wxTimer class
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/17/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TIMER_H_ #ifndef _WX_TIMER_H_
#define _WX_TIMER_H_ #define _WX_TIMER_H_
#ifdef __GNUG__
#pragma interface "timer.h"
#endif
#include "wx/object.h" #include "wx/object.h"
class WXDLLEXPORT wxTimer: public wxObject class WXDLLEXPORT wxTimer: public wxObject
{ {
friend void wxProcessTimer(wxTimer& timer);
public: public:
wxTimer(); wxTimer();
~wxTimer(); ~wxTimer();
@@ -31,32 +29,19 @@ public:
virtual void Notify() = 0; // Override this member virtual void Notify() = 0; // Override this member
// Returns the current interval time (0 if stop) // Returns the current interval time (0 if stop)
int Interval() const { return m_milli; }; int Interval() const { return milli; };
bool OneShot() const { return m_oneShot; } bool OneShot() const { return oneShot; }
protected: protected:
bool m_oneShot ; bool oneShot ;
int m_milli ; int milli ;
int m_lastMilli ; int lastMilli ;
long m_id; long id;
private: private:
DECLARE_ABSTRACT_CLASS(wxTimer) DECLARE_ABSTRACT_CLASS(wxTimer)
}; };
/* Note: these are implemented in common/timercmn.cpp, so need to implement them separately.
* But you may need to modify timercmn.cpp.
*/
// Timer functions (milliseconds)
void WXDLLEXPORT wxStartTimer();
// EXPERIMENTAL: comment this out if it doesn't compile.
bool WXDLLEXPORT wxGetLocalTime(long *timeZone, int *dstObserved);
// Get number of seconds since 00:00:00 GMT, Jan 1st 1970.
long WXDLLEXPORT wxGetCurrentTime();
#endif #endif
// _WX_TIMER_H_ // _WX_TIMER_H_

View File

@@ -1,24 +1,21 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: toolbar.h // Name: toolbar.h
// Purpose: wxToolBar class // Purpose: wxToolBar class
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/17/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TOOLBAR_H_ #ifndef _WX_TOOLBAR_H_
#define _WX_TOOLBAR_H_ #define _WX_TOOLBAR_H_
#ifdef __GNUG__ #if wxUSE_TOOLBAR
#pragma interface "toolbar.h"
#endif
#include "wx/tbarbase.h" #include "wx/tbarbase.h"
WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr;
class WXDLLEXPORT wxToolBar: public wxToolBarBase class WXDLLEXPORT wxToolBar: public wxToolBarBase
{ {
@@ -42,6 +39,9 @@ class WXDLLEXPORT wxToolBar: public wxToolBarBase
long style = wxNO_BORDER|wxTB_HORIZONTAL, long style = wxNO_BORDER|wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr); const wxString& name = wxToolBarNameStr);
// Call default behaviour
void OnMouseEvent(wxMouseEvent& event);
// If pushedBitmap is NULL, a reversed version of bitmap is // If pushedBitmap is NULL, a reversed version of bitmap is
// created and used as the pushed/toggled image. // created and used as the pushed/toggled image.
// If toggle is TRUE, the button toggles between the two states. // If toggle is TRUE, the button toggles between the two states.
@@ -60,18 +60,30 @@ class WXDLLEXPORT wxToolBar: public wxToolBarBase
wxSize GetMaxSize() const; wxSize GetMaxSize() const;
virtual bool GetToolState(int toolIndex) const;
// Add all the buttons // Add all the buttons
virtual bool CreateTools(); virtual bool CreateTools();
virtual bool Layout() { return TRUE; } virtual void SetRows(int nRows);
virtual void LayoutButtons() {}
// The post-tool-addition call. TODO: do here whatever's // The post-tool-addition call
// necessary for completing the toolbar construction.
bool Realize() { return CreateTools(); }; bool Realize() { return CreateTools(); };
// IMPLEMENTATION
virtual bool OS2Command(WXUINT param, WXWORD id);
virtual bool OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
// Responds to colour changes
void OnSysColourChanged(wxSysColourChangedEvent& event);
protected: protected:
WXHBITMAP m_hBitmap;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
#endif // wxUSE_TOOLBAR
#endif #endif
// _WX_TOOLBAR_H_ // _WX_TOOLBAR_H_

View File

@@ -1,11 +1,11 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Name: msw/tooltip.h // Name: msw/tooltip.h
// Purpose: wxToolTip class - tooltip control // Purpose: wxToolTip class - tooltip control
// Author: Vadim Zeitlin // Author: David Webster
// Modified by: // Modified by:
// Created: 31.01.99 // Created: 10/17/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 1999 Robert Roebling, Vadim Zeitlin // Copyright: (c) David Webster
// Licence: wxWindows license // Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@@ -35,6 +35,7 @@ public:
void RelayEvent(WXMSG *msg); void RelayEvent(WXMSG *msg);
private: private:
static WXHWND hwndTT;
// create the tooltip ctrl for our parent frame if it doesn't exist yet // create the tooltip ctrl for our parent frame if it doesn't exist yet
// and return its window handle // and return its window handle
WXHWND GetToolTipCtrl(); WXHWND GetToolTipCtrl();

View File

@@ -1,134 +1,154 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: treectrl.h // Name: treectrl.h
// Purpose: wxTreeCtrl class // Purpose: wxTreeCtrl class
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/17/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TREECTRL_H_ #ifndef _WX_TREECTRL_H_
#define _WX_TREECTRL_H_ #define _WX_TREECTRL_H_
#ifdef __GNUG__ #include "wx/textctrl.h"
#pragma interface "treectrl.h" #include "wx/dynarray.h"
#endif
#include "wx/control.h" // the type for "untyped" data
#include "wx/event.h" typedef long wxDataType;
#include "wx/imaglist.h"
#define wxTREE_MASK_HANDLE 0x0001 // fwd decl
#define wxTREE_MASK_STATE 0x0002 class WXDLLEXPORT wxImageList;
#define wxTREE_MASK_TEXT 0x0004 struct WXDLLEXPORT wxTreeViewItem;
#define wxTREE_MASK_IMAGE 0x0008
#define wxTREE_MASK_SELECTED_IMAGE 0x0010
#define wxTREE_MASK_CHILDREN 0x0020
#define wxTREE_MASK_DATA 0x0040
#define wxTREE_STATE_BOLD 0x0001 // a callback function used for sorting tree items, it should return -1 if the
#define wxTREE_STATE_DROPHILITED 0x0002 // first item precedes the second, +1 if the second precedes the first or 0 if
#define wxTREE_STATE_EXPANDED 0x0004 // they're equivalent
#define wxTREE_STATE_EXPANDEDONCE 0x0008 class wxTreeItemData;
#define wxTREE_STATE_FOCUSED 0x0010
#define wxTREE_STATE_SELECTED 0x0020
#define wxTREE_STATE_CUT 0x0040
#define wxTREE_HITTEST_ABOVE 0x0001 // Above the client area. // ----------------------------------------------------------------------------
#define wxTREE_HITTEST_BELOW 0x0002 // Below the client area. // constants
#define wxTREE_HITTEST_NOWHERE 0x0004 // In the client area but below the last item. // ----------------------------------------------------------------------------
#define wxTREE_HITTEST_ONITEMBUTTON 0x0010 // On the button associated with an item.
#define wxTREE_HITTEST_ONITEMICON 0x0020 // On the bitmap associated with an item.
#define wxTREE_HITTEST_ONITEMINDENT 0x0040 // In the indentation associated with an item.
#define wxTREE_HITTEST_ONITEMLABEL 0x0080 // On the label (string) associated with an item.
#define wxTREE_HITTEST_ONITEMRIGHT 0x0100 // In the area to the right of an item.
#define wxTREE_HITTEST_ONITEMSTATEICON 0x0200 // On the state icon for a tree view item that is in a user-defined state.
#define wxTREE_HITTEST_TOLEFT 0x0400 // To the right of the client area.
#define wxTREE_HITTEST_TORIGHT 0x0800 // To the left of the client area.
#define wxTREE_HITTEST_ONITEM (wxTREE_HITTEST_ONITEMICON | wxTREE_HITTEST_ONITEMLABEL | wxTREE_HITTEST_ONITEMSTATEICON) // values for the `flags' parameter of wxTreeCtrl::HitTest() which determine
// where exactly the specified point is situated:
// above the client area.
static const int wxTREE_HITTEST_ABOVE = 0x0001;
// below the client area.
static const int wxTREE_HITTEST_BELOW = 0x0002;
// in the client area but below the last item.
static const int wxTREE_HITTEST_NOWHERE = 0x0004;
// on the button associated with an item.
static const int wxTREE_HITTEST_ONITEMBUTTON = 0x0010;
// on the bitmap associated with an item.
static const int wxTREE_HITTEST_ONITEMICON = 0x0020;
// in the indentation associated with an item.
static const int wxTREE_HITTEST_ONITEMINDENT = 0x0040;
// on the label (string) associated with an item.
static const int wxTREE_HITTEST_ONITEMLABEL = 0x0080;
// in the area to the right of an item.
static const int wxTREE_HITTEST_ONITEMRIGHT = 0x0100;
// on the state icon for a tree view item that is in a user-defined state.
static const int wxTREE_HITTEST_ONITEMSTATEICON = 0x0200;
// to the right of the client area.
static const int wxTREE_HITTEST_TOLEFT = 0x0400;
// to the left of the client area.
static const int wxTREE_HITTEST_TORIGHT = 0x0800;
// anywhere on the item
static const int wxTREE_HITTEST_ONITEM = wxTREE_HITTEST_ONITEMICON |
wxTREE_HITTEST_ONITEMLABEL |
wxTREE_HITTEST_ONITEMSTATEICON;
// Flags for GetNextItem // NB: all the following flags are for compatbility only and will be removed in the
enum { // next versions
wxTREE_NEXT_CARET, // Retrieves the currently selected item.
wxTREE_NEXT_CHILD, // Retrieves the first child item. The hItem parameter must be NULL.
wxTREE_NEXT_DROPHILITE, // Retrieves the item that is the target of a drag-and-drop operation.
wxTREE_NEXT_FIRSTVISIBLE, // Retrieves the first visible item.
wxTREE_NEXT_NEXT, // Retrieves the next sibling item.
wxTREE_NEXT_NEXTVISIBLE, // Retrieves the next visible item that follows the specified item.
wxTREE_NEXT_PARENT, // Retrieves the parent of the specified item.
wxTREE_NEXT_PREVIOUS, // Retrieves the previous sibling item.
wxTREE_NEXT_PREVIOUSVISIBLE, // Retrieves the first visible item that precedes the specified item.
wxTREE_NEXT_ROOT // Retrieves the first child item of the root item of which the specified item is a part.
};
// Flags for ExpandItem // flags for deprecated `Expand(int action)'
enum { enum
{
wxTREE_EXPAND_EXPAND, wxTREE_EXPAND_EXPAND,
wxTREE_EXPAND_COLLAPSE, wxTREE_EXPAND_COLLAPSE,
wxTREE_EXPAND_COLLAPSE_RESET, wxTREE_EXPAND_COLLAPSE_RESET,
wxTREE_EXPAND_TOGGLE wxTREE_EXPAND_TOGGLE
}; };
// Flags for InsertItem // flags for deprecated InsertItem() variant
enum { #define wxTREE_INSERT_FIRST 0xFFFF0001
wxTREE_INSERT_LAST = -1, #define wxTREE_INSERT_LAST 0xFFFF0002
wxTREE_INSERT_FIRST = -2,
wxTREE_INSERT_SORT = -3
};
class WXDLLEXPORT wxTreeItem: public wxObject // ----------------------------------------------------------------------------
// wxTreeItemId identifies an element of the tree. In this implementation, it's
// just a trivial wrapper around Win32 HTREEITEM. It's opaque for the
// application.
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxTreeItemId
{ {
DECLARE_DYNAMIC_CLASS(wxTreeItem)
public: public:
long m_mask; // ctors
// 0 is invalid value for HTREEITEM
wxTreeItemId() { m_itemId = 0; }
// default copy ctor/assignment operator are ok for us
// accessors
// is this a valid tree item?
bool IsOk() const { return m_itemId != 0; }
// conversion to/from either real (system-dependent) tree item id or
// to "long" which used to be the type for tree item ids in previous
// versions of wxWindows
// for wxTreeCtrl usage only
wxTreeItemId(WXHTREEITEM itemId) { m_itemId = (long)itemId; }
operator WXHTREEITEM() const { return (WXHTREEITEM)m_itemId; }
void operator=(WXHTREEITEM item) { m_itemId = (long) item; }
protected:
long m_itemId; long m_itemId;
long m_state;
long m_stateMask;
wxString m_text;
int m_image;
int m_selectedImage;
int m_children;
long m_data;
wxTreeItem();
// Accessors
inline long GetMask() const { return m_mask; }
inline long GetItemId() const { return m_itemId; }
inline long GetState() const { return m_state; }
inline long GetStateMask() const { return m_stateMask; }
inline wxString GetText() const { return m_text; }
inline int GetImage() const { return m_image; }
inline int GetSelectedImage() const { return m_selectedImage; }
inline int GetChildren() const { return m_children; }
inline long GetData() const { return m_data; }
inline void SetMask(long mask) { m_mask = mask; }
inline void SetItemId(long id) { m_itemId = m_itemId = id; }
inline void SetState(long state) { m_state = state; }
inline void SetStateMask(long stateMask) { m_stateMask = stateMask; }
inline void GetText(const wxString& text) { m_text = text; }
inline void SetImage(int image) { m_image = image; }
inline void GetSelectedImage(int selImage) { m_selectedImage = selImage; }
inline void SetChildren(int children) { m_children = children; }
inline void SetData(long data) { m_data = data; }
}; };
WX_DEFINE_EXPORTED_ARRAY(wxTreeItemId, wxArrayTreeItemIds);
// ----------------------------------------------------------------------------
// wxTreeItemData is some (arbitrary) user class associated with some item. The
// main advantage of having this class (compared to old untyped interface) is
// that wxTreeItemData's are destroyed automatically by the tree and, as this
// class has virtual dtor, it means that the memory will be automatically
// freed. OTOH, we don't just use wxObject instead of wxTreeItemData because
// the size of this class is critical: in any real application, each tree leaf
// will have wxTreeItemData associated with it and number of leaves may be
// quite big.
//
// Because the objects of this class are deleted by the tree, they should
// always be allocated on the heap!
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxTreeItemData : private wxTreeItemId
{
public:
// default ctor/copy ctor/assignment operator are ok
// dtor is virtual and all the items are deleted by the tree control when
// it's deleted, so you normally don't have to care about freeing memory
// allocated in your wxTreeItemData-derived class
virtual ~wxTreeItemData() { }
// accessors: set/get the item associated with this node
void SetId(const wxTreeItemId& id) { m_itemId = id; }
const wxTreeItemId GetId() const { return *this; }
};
// ----------------------------------------------------------------------------
// wxTreeCtrl
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxTreeCtrl : public wxControl class WXDLLEXPORT wxTreeCtrl : public wxControl
{ {
public: public:
/*
* Public interface
*/
// creation // creation
// -------- // --------
wxTreeCtrl(); wxTreeCtrl() { Init(); }
inline wxTreeCtrl(wxWindow *parent, wxWindowID id = -1, wxTreeCtrl(wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT, long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
@@ -137,7 +157,8 @@ public:
{ {
Create(parent, id, pos, size, style, validator, name); Create(parent, id, pos, size, style, validator, name);
} }
~wxTreeCtrl();
virtual ~wxTreeCtrl();
bool Create(wxWindow *parent, wxWindowID id = -1, bool Create(wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
@@ -148,148 +169,329 @@ public:
// accessors // accessors
// --------- // ---------
// get the total number of items in the control
size_t GetCount() const;
// indent is the number of pixels the children are indented relative to
// the parents position. SetIndent() also redraws the control
// immediately.
unsigned int GetIndent() const;
void SetIndent(unsigned int indent);
// spacing is the number of pixels between the start and the Text
// not implemented under wxMSW
unsigned int GetSpacing() const { return 18; } // return wxGTK default
void SetSpacing(unsigned int WXUNUSED(spacing)) { }
// image list: these functions allow to associate an image list with
// the control and retrieve it. Note that the control does _not_ delete
// the associated image list when it's deleted in order to allow image
// lists to be shared between different controls.
// //
int GetCount() const; // The normal image list is for the icons which correspond to the
// normal tree item state (whether it is selected or not).
// Additionally, the application might choose to show a state icon
// which corresponds to an app-defined item state (for example,
// checked/unchecked) which are taken from the state image list.
wxImageList *GetImageList() const;
wxImageList *GetStateImageList() const;
// indent void SetImageList(wxImageList *imageList);
int GetIndent() const; void SetStateImageList(wxImageList *imageList);
void SetIndent(int indent);
// image list
wxImageList *GetImageList(int which = wxIMAGE_LIST_NORMAL) const;
void SetImageList(wxImageList *imageList, int which = wxIMAGE_LIST_NORMAL);
// navigation inside the tree // Functions to work with tree ctrl items. Unfortunately, they can _not_ be
long GetNextItem(long item, int code) const; // member functions of wxTreeItem because they must know the tree the item
bool ItemHasChildren(long item) const; // belongs to for Windows implementation and storing the pointer to
long GetChild(long item) const; // wxTreeCtrl in each wxTreeItem is just too much waste.
long GetParent(long item) const;
long GetFirstVisibleItem() const;
long GetNextVisibleItem(long item) const;
long GetSelection() const;
long GetRootItem() const;
// generic function for (g|s)etting item attributes // accessors
bool GetItem(wxTreeItem& info) const; // ---------
bool SetItem(wxTreeItem& info);
// item state
int GetItemState(long item, long stateMask) const;
bool SetItemState(long item, long state, long stateMask);
// item image
bool SetItemImage(long item, int image, int selImage);
// item text
wxString GetItemText(long item) const;
void SetItemText(long item, const wxString& str);
// custom data associated with the item
long GetItemData(long item) const;
bool SetItemData(long item, long data);
// convenience function
bool IsItemExpanded(long item)
{
return (GetItemState(item, wxTREE_STATE_EXPANDED) &
wxTREE_STATE_EXPANDED) != 0;
}
// bounding rect // retrieve items label
bool GetItemRect(long item, wxRect& rect, bool textOnly = FALSE) const; wxString GetItemText(const wxTreeItemId& item) const;
// get one of the images associated with the item (normal by default)
int GetItemImage(const wxTreeItemId& item,
wxTreeItemIcon which = wxTreeItemIcon_Normal) const;
// get the data associated with the item
wxTreeItemData *GetItemData(const wxTreeItemId& item) const;
// modifiers
// ---------
// set items label
void SetItemText(const wxTreeItemId& item, const wxString& text);
// get one of the images associated with the item (normal by default)
void SetItemImage(const wxTreeItemId& item, int image,
wxTreeItemIcon which = wxTreeItemIcon_Normal);
// associate some data with the item
void SetItemData(const wxTreeItemId& item, wxTreeItemData *data);
// force appearance of [+] button near the item. This is useful to
// allow the user to expand the items which don't have any children now
// - but instead add them only when needed, thus minimizing memory
// usage and loading time.
void SetItemHasChildren(const wxTreeItemId& item, bool has = TRUE);
// the item will be shown in bold
void SetItemBold(const wxTreeItemId& item, bool bold = TRUE);
// the item will be shown with a drop highlight
void SetItemDropHighlight(const wxTreeItemId& item, bool highlight = TRUE);
// item status inquiries
// ---------------------
// is the item visible (it might be outside the view or not expanded)?
bool IsVisible(const wxTreeItemId& item) const;
// does the item has any children?
bool ItemHasChildren(const wxTreeItemId& item) const;
// is the item expanded (only makes sense if HasChildren())?
bool IsExpanded(const wxTreeItemId& item) const;
// is this item currently selected (the same as has focus)?
bool IsSelected(const wxTreeItemId& item) const;
// is item text in bold font?
bool IsBold(const wxTreeItemId& item) const;
// number of children
// ------------------
// if 'recursively' is FALSE, only immediate children count, otherwise
// the returned number is the number of all items in this branch
size_t GetChildrenCount(const wxTreeItemId& item,
bool recursively = TRUE) const;
// navigation
// ----------
// wxTreeItemId.IsOk() will return FALSE if there is no such item
// get the root tree item
wxTreeItemId GetRootItem() const;
// get the item currently selected (may return NULL if no selection)
wxTreeItemId GetSelection() const;
// get the items currently selected, return the number of such item
// //
wxTextCtrl* GetEditControl() const; // NB: this operation is expensive and can take a long time for a
// control with a lot of items (~ O(number of items)).
size_t GetSelections(wxArrayTreeItemIds& selections) const;
// get the parent of this item (may return NULL if root)
wxTreeItemId GetParent(const wxTreeItemId& item) const;
// for this enumeration function you must pass in a "cookie" parameter
// which is opaque for the application but is necessary for the library
// to make these functions reentrant (i.e. allow more than one
// enumeration on one and the same object simultaneously). Of course,
// the "cookie" passed to GetFirstChild() and GetNextChild() should be
// the same!
// get the first child of this item
wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& _cookie) const;
// get the next child
wxTreeItemId GetNextChild(const wxTreeItemId& item, long& _cookie) const;
// get the last child of this item - this method doesn't use cookies
wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
// get the next sibling of this item
wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
// get the previous sibling
wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
// get first visible item
wxTreeItemId GetFirstVisibleItem() const;
// get the next visible item: item must be visible itself!
// see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
// get the previous visible item: item must be visible itself!
wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
// operations // operations
// ---------- // ----------
// adding/deleting items
bool DeleteItem(long item); // add the root node to the tree
long InsertItem(long parent, wxTreeItem& info, wxTreeItemId AddRoot(const wxString& text,
long insertAfter = wxTREE_INSERT_LAST); int image = -1, int selectedImage = -1,
// If image > -1 and selImage == -1, the same image is used for wxTreeItemData *data = NULL);
// both selected and unselected items.
long InsertItem(long parent, const wxString& label, // insert a new item in as the first child of the parent
wxTreeItemId PrependItem(const wxTreeItemId& parent,
const wxString& text,
int image = -1, int selectedImage = -1,
wxTreeItemData *data = NULL);
// insert a new item after a given one
wxTreeItemId InsertItem(const wxTreeItemId& parent,
const wxTreeItemId& idPrevious,
const wxString& text,
int image = -1, int selectedImage = -1,
wxTreeItemData *data = NULL);
// insert a new item in as the last child of the parent
wxTreeItemId AppendItem(const wxTreeItemId& parent,
const wxString& text,
int image = -1, int selectedImage = -1,
wxTreeItemData *data = NULL);
// delete this item and associated data if any
void Delete(const wxTreeItemId& item);
// delete all children (but don't delete the item itself)
// NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
void DeleteChildren(const wxTreeItemId& item);
// delete all items from the tree
// NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
void DeleteAllItems();
// expand this item
void Expand(const wxTreeItemId& item);
// collapse the item without removing its children
void Collapse(const wxTreeItemId& item);
// collapse the item and remove all children
void CollapseAndReset(const wxTreeItemId& item);
// toggles the current state
void Toggle(const wxTreeItemId& item);
// remove the selection from currently selected item (if any)
void Unselect();
// unselect all items (only makes sense for multiple selection control)
void UnselectAll();
// select this item
void SelectItem(const wxTreeItemId& item);
// make sure this item is visible (expanding the parent item and/or
// scrolling to this item if necessary)
void EnsureVisible(const wxTreeItemId& item);
// scroll to this item (but don't expand its parent)
void ScrollTo(const wxTreeItemId& item);
// start editing the item label: this (temporarily) replaces the item
// with a one line edit control. The item will be selected if it hadn't
// been before. textCtrlClass parameter allows you to create an edit
// control of arbitrary user-defined class deriving from wxTextCtrl.
wxTextCtrl* EditLabel(const wxTreeItemId& item,
wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl));
// returns the same pointer as StartEdit() if the item is being edited,
// NULL otherwise (it's assumed that no more than one item may be
// edited simultaneously)
wxTextCtrl* GetEditControl() const;
// end editing and accept or discard the changes to item label
void EndEditLabel(const wxTreeItemId& item, bool discardChanges = FALSE);
// sorting
// this function is called to compare 2 items and should return -1, 0
// or +1 if the first item is less than, equal to or greater than the
// second one. The base class version performs alphabetic comparaison
// of item labels (GetText)
virtual int OnCompareItems(const wxTreeItemId& item1,
const wxTreeItemId& item2);
// sort the children of this item using OnCompareItems
//
// NB: this function is not reentrant and not MT-safe (FIXME)!
void SortChildren(const wxTreeItemId& item);
// helpers
// -------
// determine to which item (if any) belongs the given point (the
// coordinates specified are relative to the client area of tree ctrl)
// and fill the flags parameter with a bitmask of wxTREE_HITTEST_xxx
// constants.
//
// The first function is more portable (because easier to implement
// on other platforms), but the second one returns some extra info.
wxTreeItemId HitTest(const wxPoint& point)
{ int dummy; return HitTest(point, dummy); }
wxTreeItemId HitTest(const wxPoint& point, int& flags);
// get the bounding rectangle of the item (or of its label only)
bool GetBoundingRect(const wxTreeItemId& item,
wxRect& rect,
bool textOnly = FALSE) const;
// deprecated
// ----------
// these methods are deprecated and will be removed in future versions of
// wxWindows, they're here for compatibility only, don't use them in new
// code (the comments indicate why these methods are now useless and how to
// replace them)
// use Expand, Collapse, CollapseAndReset or Toggle
void ExpandItem(const wxTreeItemId& item, int action);
// use AddRoot, PrependItem or AppendItem
wxTreeItemId InsertItem(const wxTreeItemId& parent,
const wxString& text,
int image = -1, int selImage = -1, int image = -1, int selImage = -1,
long insertAfter = wxTREE_INSERT_LAST); long insertAfter = wxTREE_INSERT_LAST);
// changing item state // use Set/GetImageList and Set/GetStateImageList
bool ExpandItem(long item) { return ExpandItem(item, wxTREE_EXPAND_EXPAND); } wxImageList *GetImageList(int) const
bool CollapseItem(long item) { return ExpandItem(item, wxTREE_EXPAND_COLLAPSE); } { return GetImageList(); }
bool ToggleItem(long item) { return ExpandItem(item, wxTREE_EXPAND_TOGGLE); } void SetImageList(wxImageList *imageList, int)
// common interface for {Expand|Collapse|Toggle}Item { SetImageList(imageList); }
bool ExpandItem(long item, int action);
// // use Set/GetItemImage directly
bool SelectItem(long item); // get the selected item image
bool ScrollTo(long item); int GetItemSelectedImage(const wxTreeItemId& item) const
bool DeleteAllItems(); { return GetItemImage(item, wxTreeItemIcon_Selected); }
// set the selected item image
void SetItemSelectedImage(const wxTreeItemId& item, int image)
{ SetItemImage(item, image, wxTreeItemIcon_Selected); }
// Edit the label (tree must have the focus) // implementation
wxTextCtrl* EditLabel(long item, wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl)); // --------------
virtual bool OS2Command(WXUINT param, WXWORD id);
virtual bool OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
// End label editing, optionally cancelling the edit // get/set the check state for the item (only for wxTR_MULTIPLE)
bool EndEditLabel(bool cancel); bool IsItemChecked(const wxTreeItemId& item) const;
void SetItemCheck(const wxTreeItemId& item, bool check = TRUE);
long HitTest(const wxPoint& point, int& flags);
// wxImageList *CreateDragImage(long item);
bool SortChildren(long item);
bool EnsureVisible(long item);
void Command(wxCommandEvent& event) { ProcessCommand(event); };
protected: protected:
wxTextCtrl* m_textCtrl; // SetImageList helper
wxImageList* m_imageListNormal; void SetAnyImageList(wxImageList *imageList, int which);
wxImageList* m_imageListState;
wxTextCtrl *m_textCtrl; // used while editing the item label
wxImageList *m_imageListNormal, // images for tree elements
*m_imageListState; // special images for app defined states
private:
// the common part of all ctors
void Init();
// helper functions
inline bool DoGetItem(wxTreeViewItem *tvItem) const;
inline void DoSetItem(wxTreeViewItem *tvItem);
inline void DoExpand(const wxTreeItemId& item, int flag);
wxTreeItemId DoInsertItem(const wxTreeItemId& parent,
wxTreeItemId hInsertAfter,
const wxString& text,
int image, int selectedImage,
wxTreeItemData *data);
int DoGetItemImageFromData(const wxTreeItemId& item,
wxTreeItemIcon which) const;
void DoSetItemImageFromData(const wxTreeItemId& item,
int image,
wxTreeItemIcon which) const;
void DoSetItemImages(const wxTreeItemId& item, int image, int imageSel);
void DeleteTextCtrl();
// support for additional item images
friend class wxTreeItemIndirectData;
void SetIndirectItemData(const wxTreeItemId& item,
wxTreeItemIndirectData *data);
bool HasIndirectData(const wxTreeItemId& item) const;
wxArrayTreeItemIds m_itemsWithIndirectData;
DECLARE_DYNAMIC_CLASS(wxTreeCtrl) DECLARE_DYNAMIC_CLASS(wxTreeCtrl)
}; };
/*
wxEVT_COMMAND_TREE_BEGIN_DRAG,
wxEVT_COMMAND_TREE_BEGIN_RDRAG,
wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT,
wxEVT_COMMAND_TREE_END_LABEL_EDIT,
wxEVT_COMMAND_TREE_DELETE_ITEM,
wxEVT_COMMAND_TREE_GET_INFO,
wxEVT_COMMAND_TREE_SET_INFO,
wxEVT_COMMAND_TREE_ITEM_EXPANDED,
wxEVT_COMMAND_TREE_ITEM_EXPANDING,
wxEVT_COMMAND_TREE_ITEM_COLLAPSED,
wxEVT_COMMAND_TREE_ITEM_COLLAPSING,
wxEVT_COMMAND_TREE_SEL_CHANGED,
wxEVT_COMMAND_TREE_SEL_CHANGING,
wxEVT_COMMAND_TREE_KEY_DOWN
*/
class WXDLLEXPORT wxTreeEvent: public wxCommandEvent
{
DECLARE_DYNAMIC_CLASS(wxTreeEvent)
public:
wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
int m_code;
wxTreeItem m_item;
long m_oldItem;
wxPoint m_pointDrag;
inline long GetOldItem() const { return m_oldItem; }
inline wxTreeItem& GetItem() const { return (wxTreeItem&) m_item; }
inline wxPoint GetPoint() const { return m_pointDrag; }
inline int GetCode() const { return m_code; }
};
typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&);
#define EVT_TREE_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
#define EVT_TREE_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
#define EVT_TREE_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
#define EVT_TREE_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
#define EVT_TREE_DELETE_ITEM(id, fn) { wxEVT_COMMAND_TREE_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
#define EVT_TREE_GET_INFO(id, fn) { wxEVT_COMMAND_TREE_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
#define EVT_TREE_SET_INFO(id, fn) { wxEVT_COMMAND_TREE_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
#define EVT_TREE_ITEM_EXPANDED(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
#define EVT_TREE_ITEM_EXPANDING(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
#define EVT_TREE_ITEM_COLLAPSED(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
#define EVT_TREE_ITEM_COLLAPSING(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
#define EVT_TREE_SEL_CHANGED(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
#define EVT_TREE_SEL_CHANGING(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
#define EVT_TREE_KEY_DOWN(id, fn) { wxEVT_COMMAND_TREE_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
#endif #endif
// _WX_TREECTRL_H_ // _WX_TREECTRL_H_

View File

@@ -2,21 +2,17 @@
// Name: wave.h // Name: wave.h
// Purpose: wxWave class (loads and plays short Windows .wav files). // Purpose: wxWave class (loads and plays short Windows .wav files).
// Optional on non-Windows platforms. // Optional on non-Windows platforms.
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/17/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_WAVE_H_ #ifndef _WX_WAVE_H_
#define _WX_WAVE_H_ #define _WX_WAVE_H_
#ifdef __GNUG__
#pragma interface "wave.h"
#endif
#include "wx/object.h" #include "wx/object.h"
class wxWave : public wxObject class wxWave : public wxObject
@@ -24,10 +20,15 @@ class wxWave : public wxObject
public: public:
wxWave(); wxWave();
wxWave(const wxString& fileName, bool isResource = FALSE); wxWave(const wxString& fileName, bool isResource = FALSE);
wxWave(int size, const wxByte* data);
~wxWave(); ~wxWave();
public: public:
// Create from resource or file
bool Create(const wxString& fileName, bool isResource = FALSE); bool Create(const wxString& fileName, bool isResource = FALSE);
// Create from data
bool Create(int size, const wxByte* data);
bool IsOk() const { return (m_waveData ? TRUE : FALSE); }; bool IsOk() const { return (m_waveData ? TRUE : FALSE); };
bool Play(bool async = TRUE, bool looped = FALSE) const; bool Play(bool async = TRUE, bool looped = FALSE) const;
@@ -35,7 +36,7 @@ protected:
bool Free(); bool Free();
private: private:
char* m_waveData; wxByte* m_waveData;
int m_waveLength; int m_waveLength;
bool m_isResource; bool m_isResource;
}; };

View File

@@ -48,7 +48,7 @@ enum wxTreeItemIcon
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/generic/treectrl.h" #include "wx/generic/treectrl.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
#include "wx/generic/treectrl.h" #include "wx/os2/treectrl.h"
#elif defined(__WXSTUBS__) #elif defined(__WXSTUBS__)
#include "wx/generic/treectrl.h" #include "wx/generic/treectrl.h"
#endif #endif

View File

@@ -351,6 +351,19 @@ OS2OBJS = \
..\os2\$D\spinctrl.obj \ ..\os2\$D\spinctrl.obj \
..\os2\$D\statbmp.obj \ ..\os2\$D\statbmp.obj \
..\os2\$D\statbox.obj \ ..\os2\$D\statbox.obj \
..\os2\$D\stattext.obj \
..\os2\$D\statbrpm.obj \
..\os2\$D\tabctrl.obj \
..\os2\$D\taskbar.obj \
..\os2\$D\textctrl.obj \
..\os2\$D\thread.obj \
..\os2\$D\timer.obj \
..\os2\$D\toolbar.obj \
..\os2\$D\tooltip.obj \
..\os2\$D\treectrl.obj \
..\os2\$D\utils.obj \
..\os2\$D\utilsexc.obj \
..\os2\$D\wave.obj \
..\os2\$D\window.obj ..\os2\$D\window.obj
OS2LIBOBJS1 = \ OS2LIBOBJS1 = \
@@ -417,6 +430,19 @@ OS2LIBOBJS2 = \
spinctrl.obj \ spinctrl.obj \
statbmp.obj \ statbmp.obj \
statbox.obj \ statbox.obj \
stattext.obj \
statbrpm.obj \
tabctrl.obj \
taskbar.obj \
textctrl.obj \
thread.obj \
timer.obj \
toolbar.obj \
tooltip.obj \
treectrl.obj \
utils.obj \
utilsexc.obj \
wave.obj \
window.obj window.obj
HTMLOBJS = \ HTMLOBJS = \
@@ -627,6 +653,19 @@ $(OS2LIBOBJS2):
copy ..\os2\$D\spinctrl.obj copy ..\os2\$D\spinctrl.obj
copy ..\os2\$D\statbmp.obj copy ..\os2\$D\statbmp.obj
copy ..\os2\$D\statbox.obj copy ..\os2\$D\statbox.obj
copy ..\os2\$D\stattext.obj
copy ..\os2\$D\statbrpm.obj
copy ..\os2\$D\tabctrl.obj
copy ..\os2\$D\taskbar.obj
copy ..\os2\$D\textctrl.obj
copy ..\os2\$D\thread.obj
copy ..\os2\$D\timer.obj
copy ..\os2\$D\toolbar.obj
copy ..\os2\$D\tooltip.obj
copy ..\os2\$D\treectrl.obj
copy ..\os2\$D\utils.obj
copy ..\os2\$D\utilsexc.obj
copy ..\os2\$D\wave.obj
copy ..\os2\$D\window.obj copy ..\os2\$D\window.obj
# wxWindows library as DLL # wxWindows library as DLL

171
src/os2/statbrpm.cpp Normal file
View File

@@ -0,0 +1,171 @@
///////////////////////////////////////////////////////////////////////////////
// Name: statbar.cpp
// Purpose: native implementation of wxStatusBar (optional)
// Author: David Webster
// Modified by:
// Created: 10/17/99
// RCS-ID: $Id$
// Copyright: (c) David Webster
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// for compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/setup.h"
#include "wx/frame.h"
#include "wx/settings.h"
#include "wx/dcclient.h"
#endif
#include "wx/log.h"
#include "wx/generic/statusbr.h"
#include "wx/os2/statusbr.h"
#include "wx/os2/private.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxStatusBarPM, wxStatusBar);
BEGIN_EVENT_TABLE(wxStatusBarPM, wxStatusBar)
EVT_SIZE(wxStatusBarPM::OnSize)
END_EVENT_TABLE()
#endif //USE_SHARED_LIBRARY
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// wxStatusBarPM class
// ----------------------------------------------------------------------------
wxStatusBarPM::wxStatusBarPM()
{
SetParent(NULL);
m_hWnd = 0;
m_windowId = 0;
}
wxStatusBarPM::wxStatusBarPM(wxWindow *parent, wxWindowID id, long style)
{
Create(parent, id, style);
}
bool wxStatusBarPM::Create(wxWindow *parent, wxWindowID id, long style)
{
SetParent(parent);
if (id == -1)
m_windowId = NewControlId();
else
m_windowId = id;
// TODO: create status bar
return FALSE;
}
void wxStatusBarPM::CopyFieldsWidth(const int widths[])
{
if (widths && !m_statusWidths)
m_statusWidths = new int[m_nFields];
if ( widths != NULL ) {
for ( int i = 0; i < m_nFields; i++ )
m_statusWidths[i] = widths[i];
}
else {
delete [] m_statusWidths;
m_statusWidths = NULL;
}
}
void wxStatusBarPM::SetFieldsCount(int nFields, const int widths[])
{
wxASSERT( (nFields > 0) && (nFields < 255) );
m_nFields = nFields;
CopyFieldsWidth(widths);
SetFieldsWidth();
}
void wxStatusBarPM::SetStatusWidths(int n, const int widths[])
{
wxASSERT( n == m_nFields );
CopyFieldsWidth(widths);
SetFieldsWidth();
}
void wxStatusBarPM::SetFieldsWidth()
{
int *pWidths = new int[m_nFields];
int nWindowWidth, y;
GetClientSize(&nWindowWidth, &y);
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];
}
if ( nVarCount == 0 ) {
// wrong! at least one field must be of variable width
wxFAIL;
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];
pWidths[i] = nCurPos;
}
}
// TODO: set widths
delete [] pWidths;
}
void wxStatusBarPM::SetStatusText(const wxString& strText, int nField)
{
// TODO
}
wxString wxStatusBarPM::GetStatusText(int nField) const
{
wxASSERT( (nField > -1) && (nField < m_nFields) );
// TODO
return wxString("");
}
void wxStatusBarPM::OnSize(wxSizeEvent& event)
{
// adjust fields widths to the new size
SetFieldsWidth();
}

View File

@@ -1,21 +1,25 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: stattext.cpp // Name: stattext.cpp
// Purpose: wxStaticText // Purpose: wxStaticText
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: 04/01/98 // Created: 10/17/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ // For compilers that support precompilation, includes "wx.h".
#pragma implementation "stattext.h" #include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/event.h"
#include "wx/app.h"
#include "wx/brush.h"
#endif #endif
#include "wx/app.h"
#include "wx/stattext.h" #include "wx/stattext.h"
#include "wx/os2/private.h"
#include <stdio.h> #include <stdio.h>
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
@@ -40,21 +44,94 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
else else
m_windowId = id; m_windowId = id;
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
m_windowStyle = style; m_windowStyle = style;
SetFont(parent->GetFont());
// TODO // TODO
SubclassWin(m_hWnd);
SetFont(parent->GetFont());
SetSize(x, y, width, height);
return FALSE; return FALSE;
} }
void wxStaticText::SetSize(int x, int y, int width, int height, int sizeFlags) wxSize wxStaticText::DoGetBestSize()
{ {
// TODO wxString text(wxGetWindowText(GetHWND()));
int widthTextMax = 0, widthLine,
heightTextTotal = 0, heightLine;
wxString curLine;
for ( const wxChar *pc = text; ; pc++ ) {
if ( *pc == wxT('\n') || *pc == wxT('\0') ) {
GetTextExtent(curLine, &widthLine, &heightLine);
if ( widthLine > widthTextMax )
widthTextMax = widthLine;
heightTextTotal += heightLine;
if ( *pc == wxT('\n') ) {
curLine.Empty();
}
else {
// the end of string
break;
}
}
else {
curLine += *pc;
}
}
return wxSize(widthTextMax, heightTextTotal);
} }
void wxStaticText::SetLabel(const wxString& label) void wxStaticText::SetLabel(const wxString& label)
{ {
// TODO // TODO
// adjust the size of the window to fit to the label (this behaviour is
// backward compatible and generally makes sense but we might want to still
// provide the user a way to disable it) (VZ)
DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT);
}
WXHBRUSH wxStaticText::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
// TODO:
/*
if (GetParent()->GetTransparentBackground())
SetBkMode((HDC) pDC, TRANSPARENT);
else
SetBkMode((HDC) pDC, OPAQUE);
::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
// Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
// has a zero usage count.
// backgroundBrush->RealizeResource();
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
*/
return (WXHBRUSH)0;
}
MRESULT wxStaticText::OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
// Ensure that static items get messages. Some controls don't like this
// message to be intercepted (e.g. RichEdit), hence the tests.
// TODO:
/*
if (nMsg == WM_NCHITTEST)
return (long)HTCLIENT;
*/
return wxWindow::OS2WindowProc(hwnd, nMsg, wParam, lParam);
} }

View File

@@ -1,162 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// Name: statbar.cpp
// Purpose: native implementation of wxStatusBar (optional)
// Author: AUTHOR
// Modified by:
// Created: ??/??/98
// RCS-ID: $Id$
// Copyright: (c) 1998 AUTHOR
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "statusbr.h"
#endif
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/stubs/statusbr.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXX, wxStatusBar);
BEGIN_EVENT_TABLE(wxStatusBarXX, wxStatusBar)
EVT_SIZE(wxStatusBarXX::OnSize)
END_EVENT_TABLE()
#endif //USE_SHARED_LIBRARY
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// wxStatusBarXX class
// ----------------------------------------------------------------------------
wxStatusBarXX::wxStatusBarXX()
{
SetParent(NULL);
}
wxStatusBarXX::wxStatusBarXX(wxWindow *parent, wxWindowID id, long style)
{
Create(parent, id, style);
}
bool wxStatusBarXX::Create(wxWindow *parent, wxWindowID id, long style)
{
SetParent(parent);
if (id == -1)
m_windowId = NewControlId();
else
m_windowId = id;
// TODO: create status bar
return FALSE;
}
void wxStatusBarXX::SetFieldsCount(int nFields, const int widths[])
{
wxASSERT( (nFields > 0) && (nFields < 255) );
m_nFields = nFields;
CopyFieldsWidth(widths);
SetFieldsWidth();
}
void wxStatusBarXX::SetStatusWidths(int n, const int widths[])
{
wxASSERT( n == m_nFields );
CopyFieldsWidth(widths);
SetFieldsWidth();
}
void wxStatusBarXX::CopyFieldsWidth(const int widths[])
{
if (widths && !m_statusWidths)
m_statusWidths = new int[m_nFields];
if ( widths != NULL ) {
for ( int i = 0; i < m_nFields; i++ )
m_statusWidths[i] = widths[i];
}
else {
delete [] m_statusWidths;
m_statusWidths = NULL;
}
}
void wxStatusBarXX::SetFieldsWidth()
{
int *pWidths = new int[m_nFields];
int nWindowWidth, y;
GetClientSize(&nWindowWidth, &y);
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];
}
if ( nVarCount == 0 ) {
// wrong! at least one field must be of variable width
wxFAIL;
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];
pWidths[i] = nCurPos;
}
}
// TODO: set widths
delete [] pWidths;
}
void wxStatusBarXX::SetStatusText(const wxString& strText, int nField)
{
// TODO
}
wxString wxStatusBarXX::GetStatusText(int nField) const
{
wxASSERT( (nField > -1) && (nField < m_nFields) );
// TODO
return wxString("");
}
void wxStatusBarXX::OnSize(wxSizeEvent& event)
{
// adjust fields widths to the new size
SetFieldsWidth();
}

View File

@@ -1,20 +1,31 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: tabctrl.cpp // Name: tabctrl.cpp
// Purpose: wxTabCtrl // Purpose: wxTabCtrl
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/17/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ // For compilers that support precompilation, includes "wx.h".
#pragma implementation "tabctrl.h" #include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/control.h" #include "malloc.h"
#include "wx/tabctrl.h"
#define INCL_PM
#include <os2.h>
//#include "wx/msw/dib.h"
#include "wx/os2/tabctrl.h"
#include "wx/app.h"
#include "wx/os2/private.h"
#include "wx/os2/imaglist.h"
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl)
@@ -33,28 +44,106 @@ bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
{ {
m_imageList = NULL; m_imageList = NULL;
m_backgroundColour = *wxWHITE; // TODO: wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
// GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
m_foregroundColour = *wxBLACK ;
SetName(name); SetName(name);
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
m_windowStyle = style; m_windowStyle = style;
SetFont(* (wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL)));
SetParent(parent); SetParent(parent);
DWORD msflags = 0;
if (width <= 0)
width = 100;
if (height <= 0)
height = 30;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
m_windowId = (id < 0 ? NewControlId() : id); m_windowId = (id < 0 ? NewControlId() : id);
long tabStyle = 0;
// Create the toolbar control.
HWND hWndTabCtrl = 0;
// TODO: create tab control
m_hWnd = (WXHWND) hWndTabCtrl;
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
// TODO: create tab control SubclassWin((WXHWND) hWndTabCtrl);
return FALSE; return FALSE;
} }
wxTabCtrl::~wxTabCtrl() wxTabCtrl::~wxTabCtrl()
{ {
UnsubclassWin();
} }
void wxTabCtrl::Command(wxCommandEvent& event) bool wxTabCtrl::OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
{ {
wxTabEvent event(wxEVT_NULL, m_windowId);
wxEventType eventType = wxEVT_NULL;
// TODO:
/*
NMHDR* hdr1 = (NMHDR*) lParam;
switch ( hdr1->code )
{
case TCN_SELCHANGE:
eventType = wxEVT_COMMAND_TAB_SEL_CHANGED;
break;
case TCN_SELCHANGING:
eventType = wxEVT_COMMAND_TAB_SEL_CHANGING;
break;
case TTN_NEEDTEXT:
{
// TODO
// if (tool->m_shortHelpString != "")
// ttText->lpszText = (char *) (const char *)tool->m_shortHelpString;
} }
default :
return wxControl::OS2OnNotify(idCtrl, lParam, result);
}
*/
event.SetEventObject( this );
event.SetEventType(eventType);
event.SetInt(idCtrl) ;
return ProcessEvent(event);
}
// Responds to colour changes, and passes event on to children.
void wxTabCtrl::OnSysColourChanged(wxSysColourChangedEvent& event)
{
// TODO:
/*
m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
GetGValue(GetSysColor(COLOR_BTNFACE)),
GetBValue(GetSysColor(COLOR_BTNFACE)));
Refresh();
*/
// Propagate the event to the non-top-level children
wxWindow::OnSysColourChanged(event);
}
// Delete all items // Delete all items
bool wxTabCtrl::DeleteAllItems() bool wxTabCtrl::DeleteAllItems()
{ {
@@ -191,6 +280,73 @@ void wxTabCtrl::SetPadding(const wxSize& padding)
// TODO // TODO
} }
#if 0
// These are the default colors used to map the bitmap colors
// to the current system colors
#define BGR_BUTTONTEXT (RGB(000,000,000)) // black
#define BGR_BUTTONSHADOW (RGB(128,128,128)) // dark grey
#define BGR_BUTTONFACE (RGB(192,192,192)) // bright grey
#define BGR_BUTTONHILIGHT (RGB(255,255,255)) // white
#define BGR_BACKGROUNDSEL (RGB(255,000,000)) // blue
#define BGR_BACKGROUND (RGB(255,000,255)) // magenta
void wxMapBitmap(HBITMAP hBitmap, int width, int height)
{
COLORMAP ColorMap[] = {
{BGR_BUTTONTEXT, COLOR_BTNTEXT}, // black
{BGR_BUTTONSHADOW, COLOR_BTNSHADOW}, // dark grey
{BGR_BUTTONFACE, COLOR_BTNFACE}, // bright grey
{BGR_BUTTONHILIGHT, COLOR_BTNHIGHLIGHT},// white
{BGR_BACKGROUNDSEL, COLOR_HIGHLIGHT}, // blue
{BGR_BACKGROUND, COLOR_WINDOW} // magenta
};
int NUM_MAPS = (sizeof(ColorMap)/sizeof(COLORMAP));
int n;
for ( n = 0; n < NUM_MAPS; n++)
{
ColorMap[n].to = ::GetSysColor(ColorMap[n].to);
}
HBITMAP hbmOld;
HDC hdcMem = CreateCompatibleDC(NULL);
if (hdcMem)
{
hbmOld = SelectObject(hdcMem, hBitmap);
int i, j, k;
for ( i = 0; i < width; i++)
{
for ( j = 0; j < height; j++)
{
COLORREF pixel = ::GetPixel(hdcMem, i, j);
/*
BYTE red = GetRValue(pixel);
BYTE green = GetGValue(pixel);
BYTE blue = GetBValue(pixel);
*/
for ( k = 0; k < NUM_MAPS; k ++)
{
if ( ColorMap[k].from == pixel )
{
/* COLORREF actualPixel = */ ::SetPixel(hdcMem, i, j, ColorMap[k].to);
break;
}
}
}
}
SelectObject(hdcMem, hbmOld);
DeleteObject(hdcMem);
}
}
#endif
// Tab event // Tab event
IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxCommandEvent) IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxCommandEvent)
@@ -199,3 +355,4 @@ wxTabEvent::wxTabEvent(wxEventType commandType, int id):
{ {
} }

View File

@@ -2,69 +2,372 @@
// File: taskbar.cpp // File: taskbar.cpp
// Purpose: Implements wxTaskBarIcon class for manipulating icons on // Purpose: Implements wxTaskBarIcon class for manipulating icons on
// the task bar. Optional. // the task bar. Optional.
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/17/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ // For compilers that support precompilation, includes "wx.h".
#pragma implementation "taskbar.h" #include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/defs.h"
#include "wx/window.h"
#include "wx/frame.h"
#include "wx/utils.h"
#include "wx/menu.h"
#endif #endif
#include <wx/taskbar.h> #define INCL_PM
#include <os2.h>
#include <string.h>
#include <wx/os2/taskbar.h>
#include <wx/os2/private.h>
wxTaskBarIcon::wxTaskBarIcon() MRESULT wxTaskBarIconWindowProc( HWND hWnd, UINT msg, MPARAM wParam, MPARAM lParam );
wxChar *wxTaskBarWindowClass = wxT("wxTaskBarWindowClass");
wxList wxTaskBarIcon::sm_taskBarIcons;
bool wxTaskBarIcon::sm_registeredClass = FALSE;
UINT wxTaskBarIcon::sm_taskbarMsg = 0;
#if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxTaskBarIcon, wxEvtHandler)
EVT_TASKBAR_MOVE (wxTaskBarIcon::_OnMouseMove)
EVT_TASKBAR_LEFT_DOWN (wxTaskBarIcon::_OnLButtonDown)
EVT_TASKBAR_LEFT_UP (wxTaskBarIcon::_OnLButtonUp)
EVT_TASKBAR_RIGHT_DOWN (wxTaskBarIcon::_OnRButtonDown)
EVT_TASKBAR_RIGHT_UP (wxTaskBarIcon::_OnRButtonUp)
EVT_TASKBAR_LEFT_DCLICK (wxTaskBarIcon::_OnLButtonDClick)
EVT_TASKBAR_RIGHT_DCLICK (wxTaskBarIcon::_OnRButtonDClick)
END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxTaskBarIcon, wxEvtHandler)
#endif
wxTaskBarIcon::wxTaskBarIcon(void)
{ {
// TODO m_hWnd = 0;
m_iconAdded = FALSE;
AddObject(this);
// TODO:
/*
if (RegisterWindowClass())
m_hWnd = CreateTaskBarWindow();
*/
} }
wxTaskBarIcon::~wxTaskBarIcon() wxTaskBarIcon::~wxTaskBarIcon(void)
{ {
// TODO // TODO:
/*
RemoveObject(this);
if (m_iconAdded)
{
RemoveIcon();
}
if (m_hWnd)
{
::DestroyWindow((HWND) m_hWnd);
m_hWnd = 0;
}
*/
} }
// Operations // Operations
bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip) bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
{ {
// TODO if (!IsOK())
return FALSE;
// TODO:
/*
NOTIFYICONDATA notifyData;
memset(&notifyData, 0, sizeof(notifyData));
notifyData.cbSize = sizeof(notifyData);
notifyData.hWnd = (HWND) m_hWnd;
notifyData.uCallbackMessage = sm_taskbarMsg;
notifyData.uFlags = NIF_MESSAGE ;
if (icon.Ok())
{
notifyData.uFlags |= NIF_ICON;
notifyData.hIcon = (HICON) icon.GetHICON();
}
if (((const wxChar*) tooltip != NULL) && (tooltip != wxT("")))
{
notifyData.uFlags |= NIF_TIP ;
lstrcpyn(notifyData.szTip, WXSTRINGCAST tooltip, sizeof(notifyData.szTip));
}
notifyData.uID = 99;
if (m_iconAdded)
return (Shell_NotifyIcon(NIM_MODIFY, & notifyData) != 0);
else
{
m_iconAdded = (Shell_NotifyIcon(NIM_ADD, & notifyData) != 0);
return m_iconAdded;
}
*/
return FALSE; return FALSE;
} }
bool wxTaskBarIcon::RemoveIcon() bool wxTaskBarIcon::RemoveIcon(void)
{ {
// TODO if (!m_iconAdded)
return FALSE; return FALSE;
//TODO:
/*
NOTIFYICONDATA notifyData;
memset(&notifyData, 0, sizeof(notifyData));
notifyData.cbSize = sizeof(notifyData);
notifyData.hWnd = (HWND) m_hWnd;
notifyData.uCallbackMessage = sm_taskbarMsg;
notifyData.uFlags = NIF_MESSAGE;
notifyData.hIcon = 0 ; // hIcon;
notifyData.uID = 99;
m_iconAdded = FALSE;
return (Shell_NotifyIcon(NIM_DELETE, & notifyData) != 0);
*/
return FALSE;
}
bool wxTaskBarIcon::PopupMenu(wxMenu *menu) //, int x, int y);
{
// OK, so I know this isn't thread-friendly, but
// what to do? We need this check.
static bool s_inPopup = FALSE;
if (s_inPopup)
return FALSE;
s_inPopup = TRUE;
bool rval = FALSE;
wxWindow* win;
int x, y;
wxGetMousePosition(&x, &y);
// is wxFrame the best window type to use???
win = new wxFrame(NULL, -1, "", wxPoint(x,y), wxSize(-1,-1), 0);
win->PushEventHandler(this);
// Remove from record of top-level windows, or will confuse wxWindows
// if we try to exit right now.
wxTopLevelWindows.DeleteObject(win);
menu->UpdateUI();
rval = win->PopupMenu(menu, 0, 0);
win->PopEventHandler(FALSE);
win->Destroy();
delete win;
s_inPopup = FALSE;
return rval;
} }
// Overridables // Overridables
void wxTaskBarIcon::OnMouseMove() void wxTaskBarIcon::OnMouseMove(wxEvent&)
{ {
} }
void wxTaskBarIcon::OnLButtonDown() void wxTaskBarIcon::OnLButtonDown(wxEvent&)
{ {
} }
void wxTaskBarIcon::OnLButtonUp() void wxTaskBarIcon::OnLButtonUp(wxEvent&)
{ {
} }
void wxTaskBarIcon::OnRButtonDown() void wxTaskBarIcon::OnRButtonDown(wxEvent&)
{ {
} }
void wxTaskBarIcon::OnRButtonUp() void wxTaskBarIcon::OnRButtonUp(wxEvent&)
{ {
} }
void wxTaskBarIcon::OnLButtonDClick() void wxTaskBarIcon::OnLButtonDClick(wxEvent&)
{ {
} }
void wxTaskBarIcon::OnRButtonDClick() void wxTaskBarIcon::OnRButtonDClick(wxEvent&)
{ {
} }
void wxTaskBarIcon::_OnMouseMove(wxEvent& e) { OnMouseMove(e); }
void wxTaskBarIcon::_OnLButtonDown(wxEvent& e) { OnLButtonDown(e); }
void wxTaskBarIcon::_OnLButtonUp(wxEvent& e) { OnLButtonUp(e); }
void wxTaskBarIcon::_OnRButtonDown(wxEvent& e) { OnRButtonDown(e); }
void wxTaskBarIcon::_OnRButtonUp(wxEvent& e) { OnRButtonUp(e); }
void wxTaskBarIcon::_OnLButtonDClick(wxEvent& e) { OnLButtonDClick(e); }
void wxTaskBarIcon::_OnRButtonDClick(wxEvent& e) { OnRButtonDClick(e); }
wxTaskBarIcon* wxTaskBarIcon::FindObjectForHWND(WXHWND hWnd)
{
wxNode*node = sm_taskBarIcons.First();
while (node)
{
wxTaskBarIcon* obj = (wxTaskBarIcon*) node->Data();
if (obj->GetHWND() == hWnd)
return obj;
node = node->Next();
}
return NULL;
}
void wxTaskBarIcon::AddObject(wxTaskBarIcon* obj)
{
sm_taskBarIcons.Append(obj);
}
void wxTaskBarIcon::RemoveObject(wxTaskBarIcon* obj)
{
sm_taskBarIcons.DeleteObject(obj);
}
bool wxTaskBarIcon::RegisterWindowClass()
{
if (sm_registeredClass)
return TRUE;
// Also register the taskbar message here
// TODO:
/*
sm_taskbarMsg = ::RegisterWindowMessage(wxT("wxTaskBarIconMessage"));
WNDCLASS wc;
bool rc;
HINSTANCE hInstance = GetModuleHandle(NULL);
//
// set up and register window class
//
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) wxTaskBarIconWindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = 0;
wc.lpszMenuName = NULL;
wc.lpszClassName = wxTaskBarWindowClass ;
rc = (::RegisterClass( &wc ) != 0);
sm_registeredClass = (rc != 0);
return( (rc != 0) );
*/
return FALSE;
}
WXHWND wxTaskBarIcon::CreateTaskBarWindow()
{
// TODO:
/*
HINSTANCE hInstance = GetModuleHandle(NULL);
HWND hWnd = CreateWindowEx (0, wxTaskBarWindowClass,
wxT("wxTaskBarWindow"),
WS_OVERLAPPED,
0,
0,
10,
10,
NULL,
(HMENU) 0,
hInstance,
NULL);
return (WXHWND) hWnd;
*/
return (WXHWND)0;
}
MRESULT wxTaskBarIcon::WindowProc( WXHWND hWnd, UINT msg, MPARAM wParam, MPARAM lParam )
{
wxEventType eventType = 0;
// TODO:
/*
if (msg != sm_taskbarMsg)
return DefWindowProc((HWND) hWnd, msg, wParam, lParam);
switch (lParam)
{
case WM_LBUTTONDOWN:
eventType = wxEVT_TASKBAR_LEFT_DOWN;
break;
case WM_LBUTTONUP:
eventType = wxEVT_TASKBAR_LEFT_UP;
break;
case WM_RBUTTONDOWN:
eventType = wxEVT_TASKBAR_RIGHT_DOWN;
break;
case WM_RBUTTONUP:
eventType = wxEVT_TASKBAR_RIGHT_UP;
break;
case WM_LBUTTONDBLCLK:
eventType = wxEVT_TASKBAR_LEFT_DCLICK;
break;
case WM_RBUTTONDBLCLK:
eventType = wxEVT_TASKBAR_RIGHT_DCLICK;
break;
case WM_MOUSEMOVE:
eventType = wxEVT_TASKBAR_MOVE;
break;
default:
break;
}
*/
if (eventType)
{
wxEvent event;
event.SetEventType(eventType);
event.SetEventObject(this);
ProcessEvent(event);
}
return 0;
}
MRESULT wxTaskBarIconWindowProc(
HWND hWnd
, UINT msg
, MPARAM wParam
, MPARAM lParam
)
{
wxTaskBarIcon* obj = wxTaskBarIcon::FindObjectForHWND((WXHWND) hWnd);
if (obj)
return obj->WindowProc((WXHWND) hWnd, msg, wParam, lParam);
else
return (MRESULT)0;
// return DefWindowProc(hWnd, msg, wParam, lParam);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,52 +1,134 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: timer.cpp // Name: timer.cpp
// Purpose: wxTimer implementation // Purpose: wxTimer implementation
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/17/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ // For compilers that support precompilation, includes "wx.h".
#pragma implementation "timer.h" #include "wx/wxprec.h"
#include "wx/window.h"
#include "wx/os2/private.h"
#ifndef WX_PRECOMP
#include "wx/setup.h"
#include "wx/list.h"
#include "wx/event.h"
#include "wx/app.h"
#endif #endif
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/timer.h" #include "wx/timer.h"
#include <time.h>
#include <sys/types.h>
#include <sys/timeb.h>
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
wxList wxTimerList(wxKEY_INTEGER);
UINT wxTimerProc(HWND hwnd, WORD, int idTimer, DWORD);
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
#endif #endif
wxTimer::wxTimer() wxTimer::wxTimer()
{ {
m_milli = 0 ; milli = 0 ;
m_id = 0; id = 0;
m_oneShot = FALSE; oneShot = FALSE;
} }
wxTimer::~wxTimer() wxTimer::~wxTimer()
{ {
Stop(); Stop();
wxTimerList.DeleteObject(this);
} }
bool wxTimer::Start(int milliseconds,bool mode) bool wxTimer::Start(int milliseconds,bool mode)
{ {
m_oneShot = mode ; oneShot = mode;
if (milliseconds <= 0) if (milliseconds < 0)
return FALSE; milliseconds = lastMilli;
m_milli = milliseconds; wxCHECK_MSG( milliseconds > 0, FALSE, wxT("invalid value for timer timeour") );
lastMilli = milli = milliseconds;
wxTimerList.DeleteObject(this);
// TODO:
/*
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"));
// TODO: set the timer going.
return FALSE; return FALSE;
} }
}
void wxTimer::Stop() void wxTimer::Stop()
{ {
m_id = 0 ; if ( id )
m_milli = 0 ; {
// KillTimer(NULL, (UINT)id);
wxTimerList.DeleteObject(this);
}
id = 0;
milli = 0;
} }
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
void wxProcessTimer(wxTimer& timer)
{
// Avoid to process spurious timer events
if ( timer.id == 0)
return;
if ( timer.oneShot )
timer.Stop();
timer.Notify();
}
UINT wxTimerProc(HWND WXUNUSED(hwnd), WORD, int idTimer, DWORD)
{
wxNode *node = wxTimerList.Find((long)idTimer);
wxCHECK_MSG( node, 0, wxT("bogus timer id in wxTimerProc") );
wxProcessTimer(*(wxTimer *)node->Data());
return 0;
}

View File

@@ -1,61 +1,181 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: toolbar.cpp // Name: toolbar.cpp
// Purpose: wxToolBar // Purpose: wxToolBar
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: 04/01/98 // Created: 10/17/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ // For compilers that support precompilation, includes "wx.h".
#pragma implementation "toolbar.h" #include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/wx.h" #if wxUSE_BUTTONBAR && wxUSE_TOOLBAR && defined(__WIN95__)
#include "malloc.h"
#define INCL_PM
#include <os2.h>
#include "wx/toolbar.h" #include "wx/toolbar.h"
#include "wx/app.h"
#include "wx/os2/private.h"
// Styles
#ifndef TBSTYLE_FLAT
#define TBSTYLE_LIST 0x1000
#define TBSTYLE_FLAT 0x0800
#define TBSTYLE_TRANSPARENT 0x8000
#endif
// use TBSTYLE_TRANSPARENT if you use TBSTYLE_FLAT
// Messages
#ifndef TB_GETSTYLE
#define TB_GETSTYLE (WM_USER + 57)
#define TB_SETSTYLE (WM_USER + 56)
#endif
/* Hint from a newsgroup for custom flatbar drawing:
Set the TBSTYLE_CUSTOMERASE style, then handle the
NM_CUSTOMDRAW message and do your custom drawing.
*/
#define DEFAULTBITMAPX 16
#define DEFAULTBITMAPY 15
#define DEFAULTBUTTONX 24
#define DEFAULTBUTTONY 24
#define DEFAULTBARHEIGHT 27
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase) IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase)
#endif
BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase) BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
EVT_MOUSE_EVENTS(wxToolBar::OnMouseEvent)
EVT_SYS_COLOUR_CHANGED(wxToolBar::OnSysColourChanged)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif
static void wxMapBitmap(HBITMAP hBitmap, int width, int height);
wxToolBar::wxToolBar() wxToolBar::wxToolBar()
{ {
m_maxWidth = -1; m_maxWidth = -1;
m_maxHeight = -1; m_maxHeight = -1;
m_defaultWidth = 24; m_hBitmap = 0;
m_defaultHeight = 22; m_defaultWidth = DEFAULTBITMAPX;
// TODO m_defaultHeight = DEFAULTBITMAPY;
} }
bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, bool wxToolBar::Create(wxWindow *parent,
long style, const wxString& name) wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{ {
m_hWnd = 0;
m_backgroundColour = *wxWHITE; //TODO: wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
// GetGValue(GetSysColor(COLOR_BTNFACE)),
// GetBValue(GetSysColor(COLOR_BTNFACE)));
m_foregroundColour = *wxBLACK ;
wxASSERT_MSG( (style & wxTB_VERTICAL) == 0,
wxT("Sorry, wxToolBar under Windows 95 only "
"supports horizontal orientation.") );
m_maxWidth = -1; m_maxWidth = -1;
m_maxHeight = -1; m_maxHeight = -1;
m_defaultWidth = 24; m_hBitmap = 0;
m_defaultHeight = 22;
m_defaultWidth = DEFAULTBITMAPX;
m_defaultHeight = DEFAULTBITMAPY;
SetName(name); SetName(name);
m_windowStyle = style; m_windowStyle = style;
SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
SetParent(parent); SetParent(parent);
if (parent) parent->AddChild(this); int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
// TODO create toolbar if (width <= 0)
width = 100;
if (height <= 0)
height = 30;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
return FALSE; m_windowId = (id < 0 ? NewControlId() : id);
DWORD msflags = 0;
// TODO:
/*
if (style & wxBORDER)
msflags |= WS_BORDER;
msflags |= WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS;
if (style & wxTB_FLAT)
{
if (wxTheApp->GetComCtl32Version() > 400)
msflags |= TBSTYLE_FLAT;
}
bool want3D;
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
if ( want3D || wxStyleHasBorder(m_windowStyle) )
msflags |= WS_BORDER;
// Create the toolbar control.
HWND hWndToolbar = CreateWindowEx
(
exStyle, // Extended styles.
TOOLBARCLASSNAME, // Class name for the toolbar.
wxT(""), // No default text.
msflags, // Styles
x, y, width, height, // Standard toolbar size and position.
(HWND) parent->GetHWND(), // Parent window of the toolbar.
(HMENU)m_windowId, // Toolbar ID.
wxGetInstance(), // Current instance.
NULL // No class data.
);
wxCHECK_MSG( hWndToolbar, FALSE, wxT("Toolbar creation failed") );
// Toolbar-specific initialisation
::SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE,
(WPARAM)sizeof(TBBUTTON), (LPARAM)0);
*/
m_hWnd = (WXHWND) hWndToolbar;
if (parent)
parent->AddChild(this);
SubclassWin((WXHWND)hWndToolbar);
return TRUE;
} }
wxToolBar::~wxToolBar() wxToolBar::~wxToolBar()
{ {
// TODO UnsubclassWin();
if (m_hBitmap)
{
// ::DeleteObject((HBITMAP) m_hBitmap);
m_hBitmap = 0;
}
} }
bool wxToolBar::CreateTools() bool wxToolBar::CreateTools()
@@ -63,26 +183,266 @@ bool wxToolBar::CreateTools()
if (m_tools.Number() == 0) if (m_tools.Number() == 0)
return FALSE; return FALSE;
// TODO HBITMAP oldToolBarBitmap = (HBITMAP) m_hBitmap;
int totalBitmapWidth = (int)(m_defaultWidth * m_tools.Number());
int totalBitmapHeight = (int)m_defaultHeight;
// TODO:
/*
// Create a bitmap for all the tool bitmaps
HDC dc = ::GetDC(NULL);
m_hBitmap = (WXHBITMAP) ::CreateCompatibleBitmap(dc, totalBitmapWidth, totalBitmapHeight);
::ReleaseDC(NULL, dc);
// Now blit all the tools onto this bitmap
HDC memoryDC = ::CreateCompatibleDC(NULL);
HBITMAP oldBitmap = (HBITMAP) ::SelectObject(memoryDC, (HBITMAP) m_hBitmap);
HDC memoryDC2 = ::CreateCompatibleDC(NULL);
int x = 0;
wxNode *node = m_tools.First();
int noButtons = 0;
while (node)
{
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
if ((tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR) && tool->m_bitmap1.Ok() && tool->m_bitmap1.GetHBITMAP())
{
// wxPalette *palette = tool->m_bitmap1->GetPalette();
HBITMAP oldBitmap2 = (HBITMAP) ::SelectObject(memoryDC2, (HBITMAP) tool->m_bitmap1.GetHBITMAP());
// int bltResult =
BitBlt(memoryDC, x, 0, (int) m_defaultWidth, (int) m_defaultHeight, memoryDC2,
0, 0, SRCCOPY);
::SelectObject(memoryDC2, oldBitmap2);
x += (int)m_defaultWidth;
noButtons ++;
}
node = node->Next();
}
::SelectObject(memoryDC, oldBitmap);
::DeleteDC(memoryDC);
::DeleteDC(memoryDC2);
// Map to system colours
wxMapBitmap((HBITMAP) m_hBitmap, totalBitmapWidth, totalBitmapHeight);
if ( oldToolBarBitmap )
{
TBREPLACEBITMAP replaceBitmap;
replaceBitmap.hInstOld = NULL;
replaceBitmap.hInstNew = NULL;
replaceBitmap.nIDOld = (UINT) oldToolBarBitmap;
replaceBitmap.nIDNew = (UINT) (HBITMAP) m_hBitmap;
replaceBitmap.nButtons = noButtons;
if (::SendMessage((HWND) GetHWND(), TB_REPLACEBITMAP, (WPARAM) 0, (LPARAM) &replaceBitmap) == -1)
{
wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
}
::DeleteObject((HBITMAP) oldToolBarBitmap);
// Now delete all the buttons
int i = 0;
while ( TRUE )
{
// TODO: What about separators???? They don't have an id!
if ( ! ::SendMessage( (HWND) GetHWND(), TB_DELETEBUTTON, i, 0 ) )
break;
}
}
else
{
TBADDBITMAP addBitmap;
addBitmap.hInst = 0;
addBitmap.nID = (UINT)m_hBitmap;
if (::SendMessage((HWND) GetHWND(), TB_ADDBITMAP, (WPARAM) noButtons, (LPARAM) &addBitmap) == -1)
{
wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
}
}
// Now add the buttons.
TBBUTTON buttons[50];
node = m_tools.First();
int i = 0;
int bitmapId = 0;
while (node)
{
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
if (tool->m_toolStyle == wxTOOL_STYLE_SEPARATOR)
{
buttons[i].iBitmap = 0;
buttons[i].idCommand = 0;
buttons[i].fsState = TBSTATE_ENABLED;
buttons[i].fsStyle = TBSTYLE_SEP;
buttons[i].dwData = 0L;
buttons[i].iString = 0;
}
else
{
buttons[i].iBitmap = bitmapId;
buttons[i].idCommand = tool->m_index;
buttons[i].fsState = 0;
if (tool->m_enabled)
buttons[i].fsState |= TBSTATE_ENABLED;
if (tool->m_toggleState)
buttons[i].fsState |= TBSTATE_CHECKED;
buttons[i].fsStyle = tool->m_isToggle ? TBSTYLE_CHECK : TBSTYLE_BUTTON;
buttons[i].dwData = 0L;
buttons[i].iString = 0;
bitmapId ++;
}
i ++;
node = node->Next();
}
long rc = ::SendMessage((HWND) GetHWND(), TB_ADDBUTTONS, (WPARAM)i, (LPARAM)& buttons);
wxCHECK_MSG( rc, FALSE, wxT("failed to add buttons to the toolbar") );
(void)::SendMessage((HWND) GetHWND(), TB_AUTOSIZE, (WPARAM)0, (LPARAM) 0);
SetRows(m_maxRows);
*/
return TRUE;
}
bool wxToolBar::OS2Command(WXUINT cmd, WXWORD id)
{
wxNode *node = m_tools.Find((long)id);
if (!node)
return FALSE;
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
// TODO:
/*
if (tool->m_isToggle)
tool->m_toggleState = (1 == (1 & (int)::SendMessage((HWND) GetHWND(), TB_GETSTATE, (WPARAM) id, (LPARAM) 0)));
BOOL ret = OnLeftClick((int)id, tool->m_toggleState);
if (ret == FALSE && tool->m_isToggle)
{
tool->m_toggleState = !tool->m_toggleState;
::SendMessage((HWND) GetHWND(), TB_CHECKBUTTON, (WPARAM)id, (LPARAM)MAKELONG(tool->m_toggleState, 0));
}
return TRUE;
*/
return FALSE;
}
bool wxToolBar::OS2OnNotify(int WXUNUSED(idCtrl),
WXLPARAM lParam,
WXLPARAM *result)
{
// TODO:
/*
// First check if this applies to us
NMHDR *hdr = (NMHDR *)lParam;
// the tooltips control created by the toolbar is sometimes Unicode, even in
// an ANSI application
int code = (int)hdr->code;
if ( (code != TTN_NEEDTEXTA) && (code != TTN_NEEDTEXTW) )
return FALSE;
HWND toolTipWnd = (HWND)::SendMessage((HWND)GetHWND(), TB_GETTOOLTIPS, 0, 0);
if ( toolTipWnd != hdr->hwndFrom )
return FALSE;
LPTOOLTIPTEXT ttText = (LPTOOLTIPTEXT)lParam;
int id = (int)ttText->hdr.idFrom;
wxNode *node = m_tools.Find((long)id);
if (!node)
return FALSE;
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
const wxString& help = tool->m_shortHelpString;
if ( !help.IsEmpty() )
{
if ( code == TTN_NEEDTEXTA )
{
ttText->lpszText = (wxChar *)help.c_str();
}
#if (_WIN32_IE >= 0x0300)
else
{
// FIXME this is a temp hack only until I understand better what
// must be done in both ANSI and Unicode builds
size_t lenAnsi = help.Len();
#ifdef __MWERKS__
// MetroWerks doesn't like calling mbstowcs with NULL argument
size_t lenUnicode = 2*lenAnsi;
#else
size_t lenUnicode = mbstowcs(NULL, help, lenAnsi);
#endif
// using the pointer of right type avoids us doing all sorts of
// pointer arithmetics ourselves
wchar_t *dst = (wchar_t *)ttText->szText,
*pwz = new wchar_t[lenUnicode + 1];
mbstowcs(pwz, help, lenAnsi + 1);
memcpy(dst, pwz, lenUnicode*sizeof(wchar_t));
// put the terminating _wide_ NUL
dst[lenUnicode] = 0;
delete [] pwz;
}
#endif // _WIN32_IE >= 0x0300
}
// For backward compatibility...
OnMouseEnter(tool->m_index);
return TRUE;
*/
return FALSE; return FALSE;
} }
void wxToolBar::SetToolBitmapSize(const wxSize& size) void wxToolBar::SetToolBitmapSize(const wxSize& size)
{ {
m_defaultWidth = size.x; m_defaultHeight = size.y; m_defaultWidth = size.x;
// TODO m_defaultHeight = size.y;
// ::SendMessage((HWND) GetHWND(), TB_SETBITMAPSIZE, 0, (LPARAM) MAKELONG ((int)size.x, (int)size.y));
}
void wxToolBar::SetRows(int nRows)
{
// TODO:
/*
RECT rect;
::SendMessage((HWND) GetHWND(), TB_SETROWS, MAKEWPARAM(nRows, TRUE), (LPARAM) & rect);
m_maxWidth = (rect.right - rect.left + 2);
m_maxHeight = (rect.bottom - rect.top + 2);
*/
} }
wxSize wxToolBar::GetMaxSize() const wxSize wxToolBar::GetMaxSize() const
{ {
// TODO // TODO:
return wxSize(0, 0); /*
if ((m_maxWidth == -1) || (m_maxHeight == -1))
{
RECT rect;
::SendMessage((HWND) GetHWND(), TB_SETROWS, MAKEWPARAM(m_maxRows, TRUE), (LPARAM) & rect);
((wxToolBar *)this)->m_maxWidth = (rect.right - rect.left + 2); // ???
((wxToolBar *)this)->m_maxHeight = (rect.bottom - rect.top + 2); // ???
}
*/
return wxSize(m_maxWidth, m_maxHeight);
} }
// The button size is bigger than the bitmap size // The button size is bigger than the bitmap size
wxSize wxToolBar::GetToolSize() const wxSize wxToolBar::GetToolSize() const
{ {
// TODO
return wxSize(m_defaultWidth + 8, m_defaultHeight + 7); return wxSize(m_defaultWidth + 8, m_defaultHeight + 7);
} }
@@ -93,7 +453,7 @@ void wxToolBar::EnableTool(int toolIndex, bool enable)
{ {
wxToolBarTool *tool = (wxToolBarTool *)node->Data(); wxToolBarTool *tool = (wxToolBarTool *)node->Data();
tool->m_enabled = enable; tool->m_enabled = enable;
// TODO enable button // ::SendMessage((HWND) GetHWND(), TB_ENABLEBUTTON, (WPARAM)toolIndex, (LPARAM)MAKELONG(enable, 0));
} }
} }
@@ -106,21 +466,28 @@ void wxToolBar::ToggleTool(int toolIndex, bool toggle)
if (tool->m_isToggle) if (tool->m_isToggle)
{ {
tool->m_toggleState = toggle; tool->m_toggleState = toggle;
// TODO: set toggle state // ::SendMessage((HWND) GetHWND(), TB_CHECKBUTTON, (WPARAM)toolIndex, (LPARAM)MAKELONG(toggle, 0));
} }
} }
} }
bool wxToolBar::GetToolState(int toolIndex) const
{
// return (::SendMessage((HWND) GetHWND(), TB_ISBUTTONCHECKED, (WPARAM)toolIndex, (LPARAM)0) != 0);
return FALSE;
}
void wxToolBar::ClearTools() void wxToolBar::ClearTools()
{ {
// TODO // TODO: Don't know how to reset the toolbar bitmap, as yet.
// But adding tools and calling CreateTools should probably
// recreate a buttonbar OK.
wxToolBarBase::ClearTools(); wxToolBarBase::ClearTools();
} }
// If pushedBitmap is NULL, a reversed version of bitmap is // If pushedBitmap is NULL, a reversed version of bitmap is
// created and used as the pushed/toggled image. // created and used as the pushed/toggled image.
// If toggle is TRUE, the button toggles between the two states. // If toggle is TRUE, the button toggles between the two states.
wxToolBarTool *wxToolBar::AddTool(int index, const wxBitmap& bitmap, const wxBitmap& pushedBitmap, wxToolBarTool *wxToolBar::AddTool(int index, const wxBitmap& bitmap, const wxBitmap& pushedBitmap,
bool toggle, long xPos, long yPos, wxObject *clientData, const wxString& helpString1, const wxString& helpString2) bool toggle, long xPos, long yPos, wxObject *clientData, const wxString& helpString1, const wxString& helpString2)
{ {
@@ -137,9 +504,137 @@ wxToolBarTool *wxToolBar::AddTool(int index, const wxBitmap& bitmap, const wxBit
else else
tool->m_y = m_yMargin; tool->m_y = m_yMargin;
tool->SetSize(GetDefaultButtonWidth(), GetDefaultButtonHeight()); tool->SetSize(GetToolSize().x, GetToolSize().y);
m_tools.Append((long)index, tool); m_tools.Append((long)index, tool);
return tool; return tool;
} }
// Responds to colour changes, and passes event on to children.
void wxToolBar::OnSysColourChanged(wxSysColourChangedEvent& event)
{
// TODO:
/*
m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
*/
// Remap the buttons
CreateTools();
Refresh();
// Propagate the event to the non-top-level children
wxWindow::OnSysColourChanged(event);
}
void wxToolBar::OnMouseEvent(wxMouseEvent& event)
{
if (event.RightDown())
{
// For now, we don't have an id. Later we could
// try finding the tool.
OnRightClick((int)-1, event.GetX(), event.GetY());
}
else
{
event.Skip();
}
}
// These are the default colors used to map the bitmap colors
// to the current system colors
#define BGR_BUTTONTEXT (RGB(000,000,000)) // black
#define BGR_BUTTONSHADOW (RGB(128,128,128)) // dark grey
#define BGR_BUTTONFACE (RGB(192,192,192)) // bright grey
#define BGR_BUTTONHILIGHT (RGB(255,255,255)) // white
#define BGR_BACKGROUNDSEL (RGB(255,000,000)) // blue
#define BGR_BACKGROUND (RGB(255,000,255)) // magenta
void wxMapBitmap(HBITMAP hBitmap, int width, int height)
{
COLORMAP ColorMap[] = {
{BGR_BUTTONTEXT, COLOR_BTNTEXT}, // black
{BGR_BUTTONSHADOW, COLOR_BTNSHADOW}, // dark grey
{BGR_BUTTONFACE, COLOR_BTNFACE}, // bright grey
{BGR_BUTTONHILIGHT, COLOR_BTNHIGHLIGHT},// white
{BGR_BACKGROUNDSEL, COLOR_HIGHLIGHT}, // blue
{BGR_BACKGROUND, COLOR_WINDOW} // magenta
};
int NUM_MAPS = (sizeof(ColorMap)/sizeof(COLORMAP));
int n;
for ( n = 0; n < NUM_MAPS; n++)
{
ColorMap[n].to = ::GetSysColor(ColorMap[n].to);
}
HBITMAP hbmOld;
HDC hdcMem = CreateCompatibleDC(NULL);
if (hdcMem)
{
hbmOld = (HBITMAP) SelectObject(hdcMem, hBitmap);
int i, j, k;
for ( i = 0; i < width; i++)
{
for ( j = 0; j < height; j++)
{
// COLORREF pixel = ::GetPixel(hdcMem, i, j);
/*
BYTE red = GetRValue(pixel);
BYTE green = GetGValue(pixel);
BYTE blue = GetBValue(pixel);
*/
for ( k = 0; k < NUM_MAPS; k ++)
{
if ( ColorMap[k].from == pixel )
{
// /* COLORREF actualPixel = */ ::SetPixel(hdcMem, i, j, ColorMap[k].to);
break;
}
}
}
}
// SelectObject(hdcMem, hbmOld);
// DeleteObject(hdcMem);
}
}
// Some experiments...
#if 0
// What we want to do is create another bitmap which has a depth of 4,
// and set the bits. So probably we want to convert this HBITMAP into a
// DIB, then call SetDIBits.
// AAAGH. The stupid thing is that if newBitmap has a depth of 4 (less than that of
// the screen), then SetDIBits fails.
HBITMAP newBitmap = ::CreateBitmap(totalBitmapWidth, totalBitmapHeight, 1, 4, NULL);
HANDLE newDIB = ::BitmapToDIB((HBITMAP) m_hBitmap, NULL);
LPBITMAPINFOHEADER lpbmi = (LPBITMAPINFOHEADER) GlobalLock(newDIB);
dc = ::GetDC(NULL);
// LPBITMAPINFOHEADER lpbmi = (LPBITMAPINFOHEADER) newDIB;
int result = ::SetDIBits(dc, newBitmap, 0, lpbmi->biHeight, FindDIBBits((LPSTR)lpbmi), (LPBITMAPINFO)lpbmi,
DIB_PAL_COLORS);
DWORD err = GetLastError();
::ReleaseDC(NULL, dc);
// Delete the DIB
GlobalUnlock (newDIB);
GlobalFree (newDIB);
// WXHBITMAP hBitmap2 = wxCreateMappedBitmap((WXHINSTANCE) wxGetInstance(), (WXHBITMAP) m_hBitmap);
// Substitute our new bitmap for the old one
::DeleteObject((HBITMAP) m_hBitmap);
m_hBitmap = (WXHBITMAP) newBitmap;
#endif
#endif

214
src/os2/tooltip.cpp Normal file
View File

@@ -0,0 +1,214 @@
///////////////////////////////////////////////////////////////////////////////
// Name: msw/tooltip.cpp
// Purpose: wxToolTip class implementation for MSW
// Author: David Webster
// Modified by:
// Created: 10/17/99
// RCS-ID: $Id$
// Copyright: (c) David Webster
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#if wxUSE_TOOLTIPS
#include "wx/tooltip.h"
#include "wx/os2/private.h"
// ----------------------------------------------------------------------------
// global variables
// ----------------------------------------------------------------------------
// the tooltip parent window
WXHWND wxToolTip::hwndTT = (WXHWND)NULL;
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
// a simple wrapper around TOOLINFO Win32 structure
class wxToolInfo // define a TOOLINFO for OS/2 here : public TOOLINFO
{
public:
wxToolInfo(wxWindow *win)
{
// initialize all members
// ::ZeroMemory(this, sizeof(TOOLINFO));
cbSize = sizeof(this);
uFlags = 0; // TTF_IDISHWND;
uId = (UINT)win->GetHWND();
}
size_t cbSize;
ULONG uFlags;
UINT uId;
HWND hwnd;
char* lpszText;
};
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
// send a message to the tooltip control
inline MRESULT SendTooltipMessage(WXHWND hwnd,
UINT msg,
MPARAM wParam,
MPARAM lParam)
{
// return hwnd ? ::SendMessage((HWND)hwnd, msg, wParam, (MPARAM)lParam)
// : 0;
return (MRESULT)0;
}
// send a message to all existing tooltip controls
static void SendTooltipMessageToAll(WXHWND hwnd,
UINT msg,
MPARAM wParam,
MPARAM lParam)
{
if ( hwnd )
(void)SendTooltipMessage((WXHWND)hwnd, msg, wParam, lParam);
}
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// static functions
// ----------------------------------------------------------------------------
void wxToolTip::Enable(bool flag)
{
// SendTooltipMessageToAll((WXHWND)hwndTT,TTM_ACTIVATE, flag, 0);
}
void wxToolTip::SetDelay(long milliseconds)
{
// SendTooltipMessageToAll((WXHWND)hwndTT,TTM_SETDELAYTIME, TTDT_INITIAL, milliseconds);
}
// ---------------------------------------------------------------------------
// implementation helpers
// ---------------------------------------------------------------------------
// create the tooltip ctrl for our parent frame if it doesn't exist yet
WXHWND wxToolTip::GetToolTipCtrl()
{
// TODO:
/*
if ( !hwndTT )
{
hwndTT = (WXHWND)::CreateWindow(TOOLTIPS_CLASS,
(LPSTR)NULL,
TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, (HMENU)NULL,
wxGetInstance(),
NULL);
if ( hwndTT )
{
SetWindowPos((HWND)hwndTT, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}
}
return (WXHWND)hwndTT;
*/
return (WXHWND)0;
}
void wxToolTip::RelayEvent(WXMSG *msg)
{
// (void)SendTooltipMessage(GetToolTipCtrl(), TTM_RELAYEVENT, 0, msg);
}
// ----------------------------------------------------------------------------
// ctor & dtor
// ----------------------------------------------------------------------------
wxToolTip::wxToolTip(const wxString &tip)
: m_text(tip)
{
m_window = NULL;
}
wxToolTip::~wxToolTip()
{
// there is no need to Remove() this tool - it will be done automatically
// anyhow
}
// ----------------------------------------------------------------------------
// others
// ----------------------------------------------------------------------------
void wxToolTip::Remove()
{
// remove this tool from the tooltip control
if ( m_window )
{
wxToolInfo ti(m_window);
// (void)SendTooltipMessage(GetToolTipCtrl(), TTM_DELTOOL, 0, &ti);
}
}
void wxToolTip::SetWindow(wxWindow *win)
{
Remove();
m_window = win;
if ( m_window )
{
wxToolInfo ti(m_window);
// as we store our text anyhow, it seems useless to waste system memory
// by asking the tooltip ctrl to remember it too - instead it will send
// us TTN_NEEDTEXT (via WM_NOTIFY) when it is about to be shown
ti.hwnd = (HWND)m_window->GetHWND();
// ti.lpszText = LPSTR_TEXTCALLBACK;
// instead of: ti.lpszText = (char *)m_text.c_str();
// TODO:
/*
if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, 0, &ti) )
{
wxLogSysError(_("Failed to create the tooltip '%s'"),
m_text.c_str());
}
*/
}
}
void wxToolTip::SetTip(const wxString& tip)
{
m_text = tip;
if ( m_window )
{
// update it immediately
wxToolInfo ti(m_window);
ti.lpszText = (wxChar *)m_text.c_str();
// (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti);
}
}
#endif // wxUSE_TOOLTIPS

File diff suppressed because it is too large Load Diff

View File

@@ -9,10 +9,6 @@
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
// #pragma implementation "utils.h" // Note: this is done in utilscmn.cpp now.
#endif
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
@@ -40,10 +36,12 @@
#include <errno.h> #include <errno.h>
#include <stdarg.h> #include <stdarg.h>
#define INCL_OS2 #define INCL_DOS
#define INCL_PM #define INCL_PM
#define INCL_GPI
#include <os2.h> #include <os2.h>
#include<netdb.h> #include<netdb.h>
#define PURE_32
#include<upm.h> #include<upm.h>
// In the WIN.INI file // In the WIN.INI file
@@ -60,7 +58,7 @@ static const wxChar eUSERNAME[] = _T("UserName");
// Get full hostname (eg. DoDo.BSn-Germany.crg.de) // Get full hostname (eg. DoDo.BSn-Germany.crg.de)
bool wxGetHostName(wxChar *buf, int maxSize) bool wxGetHostName(wxChar *buf, int maxSize)
{ {
#ifdef USE_NET_API #if wxUSE_NET_API
char server[256]; char server[256];
char computer[256]; char computer[256];
unsigned long ulLevel; unsigned long ulLevel;
@@ -80,9 +78,11 @@ bool wxGetHostName(wxChar *buf, int maxSize)
wxChar *sysname; wxChar *sysname;
const wxChar *default_host = _T("noname"); const wxChar *default_host = _T("noname");
if ((sysname = wxGetenv(_T("SYSTEM_NAME"))) == NULL) { if ((sysname = wxGetenv(_T("SYSTEM_NAME"))) == NULL)
GetProfileString(WX_SECTION, eHOSTNAME, default_host, buf, maxSize - 1); {
} else // GetProfileString(WX_SECTION, eHOSTNAME, default_host, buf, maxSize - 1);
}
else
wxStrncpy(buf, sysname, maxSize - 1); wxStrncpy(buf, sysname, maxSize - 1);
buf[maxSize] = _T('\0'); buf[maxSize] = _T('\0');
#endif #endif
@@ -92,7 +92,7 @@ bool wxGetHostName(wxChar *buf, int maxSize)
// Get user ID e.g. jacs // Get user ID e.g. jacs
bool wxGetUserId(wxChar *buf, int maxSize) bool wxGetUserId(wxChar *buf, int maxSize)
{ {
return(U32ELOCL(bub, maxSize)); return(U32ELOCL((unsigned char*)buf, (unsigned long *)&maxSize));
} }
bool wxGetUserName(wxChar *buf, int maxSize) bool wxGetUserName(wxChar *buf, int maxSize)
@@ -100,16 +100,7 @@ bool wxGetUserName(wxChar *buf, int maxSize)
#ifdef USE_NET_API #ifdef USE_NET_API
wxGetUserId(buf, maxSize); wxGetUserId(buf, maxSize);
#else #else
bool ok = GetProfileString(WX_SECTION, eUSERNAME, _T(""), buf, maxSize - 1) != 0;
if ( !ok )
{
ok = wxGetUserId(buf, maxSize);
}
if ( !ok )
{
wxStrncpy(buf, _T("Unknown User"), maxSize); wxStrncpy(buf, _T("Unknown User"), maxSize);
}
#endif #endif
return TRUE; return TRUE;
} }
@@ -140,7 +131,8 @@ bool wxShell(const wxString& command)
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX) // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
long wxGetFreeMemory() long wxGetFreeMemory()
{ {
return (long)GetFreeSpace(0); // return (long)GetFreeSpace(0);
return 0L;
} }
// Sleep for nSecs seconds. Attempt a Windows implementation using timers. // Sleep for nSecs seconds. Attempt a Windows implementation using timers.
@@ -198,7 +190,6 @@ void wxDebugMsg(const wxChar *fmt ...)
va_start(ap, fmt); va_start(ap, fmt);
sprintf(buffer,fmt,ap) ; sprintf(buffer,fmt,ap) ;
fflush(buffer) ;
va_end(ap); va_end(ap);
} }
@@ -211,21 +202,21 @@ void wxError(const wxString& msg, const wxString& title)
,NULL ,NULL
,(PSZ)wxBuffer ,(PSZ)wxBuffer
,(PSZ)WXSTRINGCAST title ,(PSZ)WXSTRINGCAST title
,0
,MB_ICONEXCLAMATION | MB_YESNO ,MB_ICONEXCLAMATION | MB_YESNO
) == IDNO) ) == MBID_YES)
wxExit(); wxExit();
} }
// Fatal error: pop up message box and abort // Fatal error: pop up message box and abort
void wxFatalError(const wxString& msg, const wxString& title) void wxFatalError(const wxString& rMsg, const wxString& rTitle)
{ {
YUint32 rc; unsigned long rc;
HWND hWnd;
WinMessageBox( HWND_DESKTOP rc = ::WinMessageBox( HWND_DESKTOP
,hWnd ,NULL
,rMsg.Data() ,WXSTRINGCAST rMsg
,rTitle.Data() ,WXSTRINGCAST rTitle
,0 ,0
,MB_NOICON | MB_OK ,MB_NOICON | MB_OK
); );
@@ -258,13 +249,19 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn)
} }
// Reading and writing resources (eg WIN.INI, .Xdefaults) // Reading and writing resources (eg WIN.INI, .Xdefaults)
// TODO: Ability to read and write to an INI file
#if wxUSE_RESOURCES #if wxUSE_RESOURCES
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file) bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
{ {
// TODO:
/*
if (file != "") if (file != "")
return (WritePrivateProfileString((PCSZ)WXSTRINGCAST section, (PCSZ)WXSTRINGCAST entry, (PCSZ)value, (PCSZ)WXSTRINGCAST file) != 0); return (WritePrivateProfileString((PCSZ)WXSTRINGCAST section, (PCSZ)WXSTRINGCAST entry, (PCSZ)value, (PCSZ)WXSTRINGCAST file) != 0);
else else
return (WriteProfileString((PCSZ)WXSTRINGCAST section, (PCSZ)WXSTRINGCAST entry, (PCSZ)WXSTRINGCAST value) != 0); return (WriteProfileString((PCSZ)WXSTRINGCAST section, (PCSZ)WXSTRINGCAST entry, (PCSZ)WXSTRINGCAST value) != 0);
*/
return FALSE;
} }
bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file) bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
@@ -291,6 +288,8 @@ bool wxWriteResource(const wxString& section, const wxString& entry, int value,
bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file) bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file)
{ {
static const wxChar defunkt[] = _T("$$default"); static const wxChar defunkt[] = _T("$$default");
// TODO:
/*
if (file != "") if (file != "")
{ {
int n = GetPrivateProfileString((PCSZ)WXSTRINGCAST section, (PCSZ)WXSTRINGCAST entry, (PCSZ)defunkt, int n = GetPrivateProfileString((PCSZ)WXSTRINGCAST section, (PCSZ)WXSTRINGCAST entry, (PCSZ)defunkt,
@@ -308,6 +307,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, wxChar **valu
if (*value) delete[] (*value); if (*value) delete[] (*value);
*value = copystring(wxBuffer); *value = copystring(wxBuffer);
return TRUE; return TRUE;
*/
return FALSE;
} }
bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file) bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
@@ -452,7 +453,7 @@ bool wxCheckForInterrupt(wxWindow *wnd)
HWND win= (HWND) wnd->GetHWND(); HWND win= (HWND) wnd->GetHWND();
while(::WinPeekMsg(hab,&msg,hwndFilter,0,0,PM_REMOVE)) while(::WinPeekMsg(hab,&msg,hwndFilter,0,0,PM_REMOVE))
{ {
::WinDispatchMsg( hab, &qmsg ); ::WinDispatchMsg( hab, &msg );
} }
return TRUE;//*** temporary? return TRUE;//*** temporary?
} }
@@ -488,16 +489,16 @@ wxChar *wxLoadUserResource(const wxString& resourceName, const wxString& resourc
* wxChar *theText = (wxChar *)LockResource(hData); * wxChar *theText = (wxChar *)LockResource(hData);
* if (!theText) * if (!theText)
* return NULL; * return NULL;
*
* s = copystring(theText);
*/ */
s = copystring(theText);
return s; return s;
} }
void wxGetMousePosition( int* x, int* y ) void wxGetMousePosition( int* x, int* y )
{ {
POINT pt; POINTL pt;
GetCursorPos( & pt ); ::WinQueryPointerPos( HWND_DESKTOP, & pt );
*x = pt.x; *x = pt.x;
*y = pt.y; *y = pt.y;
}; };
@@ -530,7 +531,7 @@ int wxDisplayDepth()
nDepth = nPlanes * nBitsPerPixel; nDepth = nPlanes * nBitsPerPixel;
} }
DevCloseDC(hDc); DevCloseDC(hDc);
return (depth); return (nDepth);
} }
// Get size of display // Get size of display
@@ -545,8 +546,8 @@ void wxDisplaySize(int *width, int *height)
,lArray ,lArray
)) ))
{ {
*pWidth = (int)lArray[CAPS_WIDTH]; *width = (int)lArray[CAPS_WIDTH];
*pHeight = (int)lArray[CAPS_HEIGHT]; *height = (int)lArray[CAPS_HEIGHT];
} }
DevCloseDC(hDc); DevCloseDC(hDc);
} }
@@ -565,7 +566,7 @@ wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd)
{ {
wxString str; wxString str;
long len = ::WinQueryWindowTextLength((HWND)hWnd) + 1; long len = ::WinQueryWindowTextLength((HWND)hWnd) + 1;
::WinQueryWindowText((HWND)hWnd, str.GetWriteBuf((int)len), len); ::WinQueryWindowText((HWND)hWnd, len, str.GetWriteBuf((int)len));
str.UngetWriteBuf(); str.UngetWriteBuf();
return str; return str;
@@ -579,7 +580,7 @@ wxString WXDLLEXPORT wxGetWindowClass(WXHWND hWnd)
for ( ;; ) for ( ;; )
{ {
int count = ::WinQueryClassName((HWND)hWnd, str.GetWriteBuf(len), len); int count = ::WinQueryClassName((HWND)hWnd, len, str.GetWriteBuf(len));
str.UngetWriteBuf(); str.UngetWriteBuf();
if ( count == len ) if ( count == len )

View File

@@ -1,28 +1,262 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: utilsexec.cpp // Name: utilsexec.cpp
// Purpose: Execution-related utilities // Purpose: Various utilities
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/17/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ // For compilers that support precompilation, includes "wx.h".
#pragma implementation #include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/setup.h"
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/intl.h"
#endif #endif
#include "wx/utils.h" #include "wx/log.h"
#include "wx/process.h"
#include "wx/os2/private.h"
#define INCL_DOS
#include <os2.h>
#include <ctype.h>
#include <direct.h>
#include <sys/stat.h>
#include <io.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h>
#include <stdarg.h>
#define wxEXECUTE_WIN_MESSAGE 10000 // this message is sent when the process we're waiting for terminates
#define wxWM_PROC_TERMINATED (WM_USER + 10000)
// structure describing the process we're being waiting for
struct wxExecuteData
{
public:
~wxExecuteData()
{
// TODO:
/*
if ( !::CloseHandle(hProcess) )
{
wxLogLastError("CloseHandle(hProcess)");
}
*/
}
HWND hWnd; // window to send wxWM_PROC_TERMINATED to
HANDLE hProcess; // handle of the process
DWORD dwProcessId; // pid of the process
wxProcess *handler;
DWORD dwExitCode; // the exit code of the process
bool state; // set to FALSE when the process finishes
};
static DWORD wxExecuteThread(wxExecuteData *data)
{
// TODO:
/*
WaitForSingleObject(data->hProcess, INFINITE);
// get the exit code
if ( !GetExitCodeProcess(data->hProcess, &data->dwExitCode) )
{
wxLogLastError("GetExitCodeProcess");
}
wxASSERT_MSG( data->dwExitCode != STILL_ACTIVE,
wxT("process should have terminated") );
// send a message indicating process termination to the window
SendMessage(data->hWnd, wxWM_PROC_TERMINATED, 0, (LPARAM)data);
*/
return 0;
}
// window procedure of a hidden window which is created just to receive
// the notification message when a process exits
MRESULT APIENTRY wxExecuteWindowCbk(HWND hWnd, UINT message,
MPARAM wParam, MPARAM lParam)
{
if ( message == wxWM_PROC_TERMINATED )
{
// DestroyWindow(hWnd); // we don't need it any more
wxExecuteData *data = (wxExecuteData *)lParam;
if ( data->handler )
{
data->handler->OnTerminate((int)data->dwProcessId,
(int)data->dwExitCode);
}
if ( data->state )
{
// we're executing synchronously, tell the waiting thread
// that the process finished
data->state = 0;
}
else
{
// asynchronous execution - we should do the clean up
delete data;
}
}
return 0;
}
extern wxChar wxPanelClassName[];
long wxExecute(const wxString& command, bool sync, wxProcess *handler) long wxExecute(const wxString& command, bool sync, wxProcess *handler)
{ {
// TODO wxCHECK_MSG( !!command, 0, wxT("empty command in wxExecute") );
// the old code is disabled because we really need a process handle
// if we want to execute it asynchronously or even just get its
// return code and for this we must use CreateProcess() and not
// ShellExecute()
// create the process
// TODO:
/*
STARTUPINFO si;
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
PROCESS_INFORMATION pi;
if ( ::CreateProcess(
NULL, // application name (use only cmd line)
(wxChar *)command.c_str(), // full command line
NULL, // security attributes: defaults for both
NULL, // the process and its main thread
FALSE, // don't inherit handles
CREATE_DEFAULT_ERROR_MODE, // flags
NULL, // environment (use the same)
NULL, // current directory (use the same)
&si, // startup info (unused here)
&pi // process info
) == 0 )
{
wxLogSysError(_("Execution of command '%s' failed"), command.c_str());
return 0; return 0;
} }
// close unneeded handle
if ( !::CloseHandle(pi.hThread) )
wxLogLastError("CloseHandle(hThread)");
// create a hidden window to receive notification about process
// termination
HWND hwnd = ::CreateWindow(wxPanelClassName, NULL, 0, 0, 0, 0, 0, NULL,
(HMENU)NULL, wxGetInstance(), 0);
wxASSERT_MSG( hwnd, wxT("can't create a hidden window for wxExecute") );
FARPROC ExecuteWindowInstance = MakeProcInstance((FARPROC)wxExecuteWindowCbk,
wxGetInstance());
::SetWindowLong(hwnd, GWL_WNDPROC, (LONG) ExecuteWindowInstance);
// Alloc data
wxExecuteData *data = new wxExecuteData;
data->hProcess = pi.hProcess;
data->dwProcessId = pi.dwProcessId;
data->hWnd = hwnd;
data->state = sync;
if ( sync )
{
wxASSERT_MSG( !handler, wxT("wxProcess param ignored for sync execution") );
data->handler = NULL;
}
else
{
// may be NULL or not
data->handler = handler;
}
DWORD tid;
HANDLE hThread = ::CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE)wxExecuteThread,
(void *)data,
0,
&tid);
if ( !hThread )
{
wxLogLastError("CreateThread in wxExecute");
DestroyWindow(hwnd);
delete data;
// the process still started up successfully...
return pi.dwProcessId;
}
if ( !sync )
{
// clean up will be done when the process terminates
// return the pid
return pi.dwProcessId;
}
// waiting until command executed
while ( data->state )
wxYield();
DWORD dwExitCode = data->dwExitCode;
delete data;
// return the exit code
return dwExitCode;
*/
return 0;
}
long wxExecute(char **argv, bool sync, wxProcess *handler)
{
wxString command;
while ( *argv != NULL )
{
command << *argv++ << ' ';
}
command.RemoveLast();
return wxExecute(command, sync, handler);
}
bool wxGetFullHostName(wxChar *buf, int maxSize)
{
DWORD nSize = maxSize ;
// TODO:
/*
if ( !::GetComputerName(buf, &nSize) )
{
wxLogLastError("GetComputerName");
return FALSE;
}
*/
return TRUE;
}

View File

@@ -1,21 +1,33 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: wave.cpp // Name: wave.cpp
// Purpose: wxWave class implementation: optional // Purpose: wxWave class implementation: optional
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/17/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ // For compilers that support precompilation, includes "wx.h".
#pragma implementation "wave.h" #include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/object.h" #include "wx/file.h"
#include "wx/string.h" #include "wx/os2/wave.h"
#include "wx/stubs/wave.h" #include "wx/os2/private.h"
#define INCL_DOS
#define INCL_PM
#include <os2.h>
#ifdef RECT
#undef RECT
#endif
#include <mmio.h>
#include <mmsystem.h>
wxWave::wxWave() wxWave::wxWave()
: m_waveData(NULL), m_waveLength(0), m_isResource(FALSE) : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
@@ -23,11 +35,16 @@ wxWave::wxWave()
} }
wxWave::wxWave(const wxString& sFileName, bool isResource) wxWave::wxWave(const wxString& sFileName, bool isResource)
: m_waveData(NULL), m_waveLength(0), m_isResource(FALSE) : m_waveData(NULL), m_waveLength(0), m_isResource(isResource)
{ {
Create(sFileName, isResource); Create(sFileName, isResource);
} }
wxWave::wxWave(int size, const wxByte* data)
: m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
{
Create(size, data);
}
wxWave::~wxWave() wxWave::~wxWave()
{ {
@@ -38,24 +55,102 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
{ {
Free(); Free();
// TODO if (isResource)
{
m_isResource = TRUE;
// TODO:
/*
HRSRC hresInfo;
#ifdef _UNICODE
hresInfo = ::FindResourceW((HMODULE) wxhInstance, fileName, wxT("WAVE"));
#else
hresInfo = ::FindResourceA((HMODULE) wxhInstance, fileName, wxT("WAVE"));
#endif
if (!hresInfo)
return FALSE; return FALSE;
HGLOBAL waveData = ::LoadResource((HMODULE) wxhInstance, hresInfo);
if (waveData)
{
m_waveData= (wxByte*)::LockResource(waveData);
m_waveLength = (int) ::SizeofResource((HMODULE) wxhInstance, hresInfo);
}
return (m_waveData ? TRUE : FALSE);
*/
return FALSE;
}
else
{
m_isResource = FALSE;
wxFile fileWave;
if (!fileWave.Open(fileName, wxFile::read))
return FALSE;
m_waveLength = (int) fileWave.Length();
// TODO:
/*
m_waveData = (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
if (!m_waveData)
return FALSE;
fileWave.Read(m_waveData, m_waveLength);
*/
return TRUE;
}
}
bool wxWave::Create(int size, const wxByte* data)
{
Free();
m_isResource = FALSE;
m_waveLength=size;
m_waveData = NULL; // (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
if (!m_waveData)
return FALSE;
for (int i=0; i<size; i++) m_waveData[i] = data[i];
return TRUE;
} }
bool wxWave::Play(bool async, bool looped) const bool wxWave::Play(bool async, bool looped) const
{ {
if (!IsOk()) if (!IsOk())
return FALSE; return FALSE;
// TODO:
// TODO /*
return ( ::PlaySound((LPCTSTR)m_waveData, NULL, SND_MEMORY |
SND_NODEFAULT | (async ? SND_ASYNC : SND_SYNC) | (looped ? (SND_LOOP | SND_ASYNC) : 0)) != 0 );
*/
return FALSE; return FALSE;
} }
bool wxWave::Free() bool wxWave::Free()
{ {
// TODO if (m_waveData)
{
// HGLOBAL waveData = ::GlobalHandle(m_waveData);
// TODO:
/*
if (waveData)
{
if (m_isResource)
::FreeResource(waveData);
else
{
::GlobalUnlock(waveData);
::GlobalFree(waveData);
}
m_waveData = NULL;
m_waveLength = 0;
return TRUE;
}
*/
}
return FALSE; return FALSE;
} }