OS/2 common controls code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13065 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
2001-12-17 22:56:41 +00:00
parent 4c53d9ece2
commit 3c299c3ab6
24 changed files with 3714 additions and 3149 deletions

View File

@@ -18,52 +18,68 @@ WXDLLEXPORT_DATA(extern const char*) wxGaugeNameStr;
class WXDLLEXPORT wxGauge: public wxControl class WXDLLEXPORT wxGauge: public wxControl
{ {
DECLARE_DYNAMIC_CLASS(wxGauge)
public: public:
inline wxGauge() { m_rangeMax = 0; m_gaugePos = 0; } inline wxGauge() { m_nRangeMax = 0; m_nGaugePos = 0; }
inline wxGauge(wxWindow *parent, wxWindowID id, inline wxGauge( wxWindow* pParent
int range, ,wxWindowID vId
const wxPoint& pos = wxDefaultPosition, ,int nRange
const wxSize& size = wxDefaultSize, ,const wxPoint& rPos = wxDefaultPosition
long style = wxGA_HORIZONTAL, ,const wxSize& rSize = wxDefaultSize
,long lStyle = wxGA_HORIZONTAL
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
const wxValidator& validator = wxDefaultValidator, ,const wxValidator& rValidator = wxDefaultValidator
#endif #endif
const wxString& name = wxGaugeNameStr) ,const wxString& rsName = wxGaugeNameStr
)
{ {
Create(parent, id, range, pos, size, style, validator, name); Create( pParent
,vId
,nRange
,rPos
,rSize
,lStyle
#if wxUSE_VALIDATORS
,rValidator
#endif
,rsName
);
} }
bool Create(wxWindow *parent, wxWindowID id, bool Create( wxWindow* pParent
int range, ,wxWindowID vId
const wxPoint& pos = wxDefaultPosition, ,int nRange
const wxSize& size = wxDefaultSize, ,const wxPoint& rPos = wxDefaultPosition
long style = wxGA_HORIZONTAL, ,const wxSize& rSize = wxDefaultSize
,long lStyle = wxGA_HORIZONTAL
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
const wxValidator& validator = wxDefaultValidator, ,const wxValidator& rValidator = wxDefaultValidator
#endif #endif
const wxString& name = wxGaugeNameStr); ,const wxString& rsName = wxGaugeNameStr
);
void SetShadowWidth(int w); int GetShadowWidth(void) const;
void SetBezelFace(int w); int GetBezelFace(void) const;
void SetRange(int r); int GetRange(void) const;
void SetValue(int pos); int GetValue(void) const;
int GetShadowWidth() const ; bool SetBackgroundColour(const wxColour& rColour);
int GetBezelFace() const ; void SetBezelFace(int nWidth);
int GetRange() const ; bool SetForegroundColour(const wxColour& rColour);
int GetValue() const ; void SetRange(int nRange);
void SetShadowWidth(int nWidth);
void SetValue(int nPos);
bool SetForegroundColour(const wxColour& col); inline virtual bool AcceptsFocus(void) const { return FALSE; }
bool SetBackgroundColour(const wxColour& col); inline virtual void Command(wxCommandEvent& WXUNUSED(rEvent)) {};
virtual void Command(wxCommandEvent& WXUNUSED(event)) {} ;
protected: protected:
int m_rangeMax; int m_nRangeMax;
int m_gaugePos; int m_nGaugePos;
};
private:
DECLARE_DYNAMIC_CLASS(wxGauge)
}; // end of CLASS wxGauge
#endif // _WX_GAUGE_H_
#endif
// _WX_GAUGE_H_

View File

@@ -232,6 +232,10 @@ inline bool wxStyleHasBorder(long style)
wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0; wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0;
} }
WXDLLEXPORT extern void wxOS2SetFont( HWND hWnd
,const wxFont& rFont
);
#endif #endif
// _WX_PRIVATE_H_ // _WX_PRIVATE_H_

View File

@@ -19,105 +19,168 @@ class WXDLLEXPORT wxBitmap ;
class WXDLLEXPORT wxRadioBox: public wxControl, public wxRadioBoxBase class WXDLLEXPORT wxRadioBox: public wxControl, public wxRadioBoxBase
{ {
DECLARE_DYNAMIC_CLASS(wxRadioBox)
public: public:
wxRadioBox(); wxRadioBox();
inline wxRadioBox(wxWindow *parent, wxWindowID id, const wxString& title, inline wxRadioBox( wxWindow* pParent
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, ,wxWindowID vId
int n = 0, const wxString choices[] = NULL, ,const wxString& rsTitle
int majorDim = 0, long style = wxRA_HORIZONTAL, ,const wxPoint& rPos = wxDefaultPosition
,const wxSize& rSize = wxDefaultSize
,int nNum = 0
,const wxString asChoices[] = NULL
,int nMajorDim = 0
,long lStyle = wxRA_HORIZONTAL
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr) ,const wxValidator& rVal = wxDefaultValidator
#endif #endif
,const wxString& rsName = wxRadioBoxNameStr
)
{ {
Create(parent, id, title, pos, size, n, choices, majorDim, style, val, name); Create( pParent
,vId
,rsTitle
,rPos
,rSize
,nNum
,asChoices
,nMajorDim
,lStyle
#if wxUSE_VALIDATORS
,rVal
#endif
,rsName
);
} }
~wxRadioBox(); ~wxRadioBox();
bool Create(wxWindow *parent, wxWindowID id, const wxString& title, bool Create( wxWindow* pParent
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, ,wxWindowID vId
int n = 0, const wxString choices[] = NULL, ,const wxString& rsTitle
int majorDim = 0, long style = wxRA_HORIZONTAL, ,const wxPoint& rPos = wxDefaultPosition
,const wxSize& rSize = wxDefaultSize
,int nNum = 0
,const wxString asChoices[] = NULL
,int nMajorDim = 0
,long lStyle = wxRA_HORIZONTAL
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr); ,const wxValidator& rVal = wxDefaultValidator
#endif #endif
,const wxString& rsName = wxRadioBoxNameStr
);
virtual bool OS2Command(WXUINT param, WXWORD id); void Command(wxCommandEvent& rEvent);
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
int FindString(const wxString& s) const;
void SetSelection(int N);
int GetSelection() const;
virtual int GetCount() const;
wxString GetString(int N) const;
virtual void SetString(int n, const wxString& label);
virtual int GetColumnCount() const;
virtual int GetRowCount() const;
void GetSize(int *x, int *y) const;
void GetPosition(int *x, int *y) const;
void SetLabel(int item, const wxString& label);
void SetLabel(int item, wxBitmap *bitmap);
wxString GetLabel(int item) const;
bool Show(bool show);
void SetFocus();
bool Enable(bool enable);
void Enable(int item, bool enable);
void Show(int item, bool show) ;
inline void SetLabelFont(const wxFont& WXUNUSED(font)) {};
inline void SetButtonFont(const wxFont& font) { SetFont(font); }
virtual wxString GetStringSelection() const;
virtual bool SetStringSelection(const wxString& s);
inline virtual int Number() const { return m_noItems; } ;
void Command(wxCommandEvent& event);
inline int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; }
inline void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; }
// implementation only from now on
// -------------------------------
WXHWND *GetRadioButtons() const { return m_radioButtons; }
bool ContainsHWND(WXHWND hWnd) const; bool ContainsHWND(WXHWND hWnd) const;
void SendNotificationEvent(); bool Enable(bool bEnable);
void Enable( int nItem
,bool bEnable
);
int FindString(const wxString& sStr) const;
// get the number of buttons per column/row virtual WXHBRUSH OnCtlColor( WXHDC hDC
int GetNumVer() const; ,WXHWND hWnd
int GetNumHor() const; ,WXUINT uCtlColor
,WXUINT uMessage
,WXWPARAM wParam
,WXLPARAM lParam
);
virtual bool OS2Command( WXUINT uParam
,WXWORD wId
);
void SendNotificationEvent(void);
void Show( int nItem
,bool bShow = TRUE
) ;
bool Show(bool bShow);
MRESULT WindowProc( WXUINT uMsg
,WXWPARAM wParam
,WXLPARAM lParam
);
virtual int GetColumnCount(void) const;
virtual int GetCount(void) const;
inline int GetNumberOfRowsOrCols(void) const { return m_nNoRowsOrCols; }
int GetNumHor(void) const;
int GetNumVer(void) const;
void GetPosition( int* pnX
,int* pnY
) const;
inline WXHWND* GetRadioButtons(void) const { return m_ahRadioButtons; }
virtual int GetRowCount(void) const;
int GetSelection(void) const;
void GetSize( int* pnX
,int* pnY
) const;
void GetSizeFlags(void) const;
void AdjustButtons( int nX
,int nY
,int nWidth
,int nHeight
,int lSizeFlags
);
wxString GetString(int nIndex) const;
virtual wxString GetStringSelection(void) const;
inline void SetButtonFont(const wxFont& rFont) { SetFont(rFont); }
void SetFocus(void);
virtual bool SetFont(const wxFont& rFont);
inline void SetLabelFont(const wxFont& WXUNUSED(font)) {};
inline void SetNumberOfRowsOrCols(int nNum) { m_nNoRowsOrCols = nNum; }
void SetSelection(int nIndex);
virtual void SetString( int nNum
,const wxString& rsLabel
);
virtual bool SetStringSelection(const wxString& rsStr);
void SetLabel( int nItem
,const wxString& rsLabel
);
void SetLabel( int item
,wxBitmap* pBitmap
);
wxString GetLabel(int nItem) const;
#if WXWIN_COMPATIBILITY
wxRadioBox(wxWindow *parent, wxFunction func, const char *title,
int x = -1, int y = -1, int width = -1, int height = -1,
int n = 0, char **choices = NULL,
int majorDim = 0, long style = wxRA_HORIZONTAL, const char *name = wxRadioBoxNameStr);
#endif // WXWIN_COMPATIBILITY
protected: protected:
void AdjustButtons( int nX
,int nY
,int nWidth
,int nHeight
,long lSizeFlags
);
virtual wxSize DoGetBestSize(void) const;
virtual void DoSetSize( int nX
,int nY
,int nWidth
,int nHeight
,int nSizeFlags = wxSIZE_AUTO
);
wxSize GetMaxButtonSize(void) const;
wxSize GetTotalButtonSize(const wxSize& rSizeBtn) const;
void SubclassRadioButton(WXHWND hWndBtn); void SubclassRadioButton(WXHWND hWndBtn);
WXHWND * m_radioButtons;
int m_majorDim ;
int * m_radioWidth; // for bitmaps
int * m_radioHeight;
int m_noItems; WXHWND* m_ahRadioButtons;
int m_noRowsOrCols; int m_nMajorDim ;
int m_selectedButton; int* m_pnRadioWidth; // for bitmaps
int* m_pnRadioHeight;
int m_nNoItems;
int m_nNoRowsOrCols;
int m_nSelectedButton;
int m_nSizeFlags;
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
private: private:
virtual void SetLabel(const wxString& label) inline wxString GetLabel() const
{ wxWindowBase::SetLabel(label); } { return wxWindowBase::GetLabel(); }
wxString GetLabel() const inline void SetLabel(const wxString& rsLabel)
{ return(wxWindowBase::GetLabel()); } { wxWindowBase::SetLabel(rsLabel); }
};
DECLARE_DYNAMIC_CLASS(wxRadioBox)
}; // end of wxRadioBox
#endif #endif
// _WX_RADIOBOX_H_ // _WX_RADIOBOX_H_

View File

@@ -18,38 +18,55 @@ WXDLLEXPORT_DATA(extern const char*) wxRadioButtonNameStr;
class WXDLLEXPORT wxRadioButton: public wxControl class WXDLLEXPORT wxRadioButton: public wxControl
{ {
DECLARE_DYNAMIC_CLASS(wxRadioButton)
protected:
public: public:
inline wxRadioButton() {} inline wxRadioButton() {}
inline wxRadioButton(wxWindow *parent, wxWindowID id, inline wxRadioButton( wxWindow* pParent
const wxString& label, ,wxWindowID vId
const wxPoint& pos = wxDefaultPosition, ,const wxString& rsLabel
const wxSize& size = wxDefaultSize, long style = 0, ,const wxPoint& rPos = wxDefaultPosition
,const wxSize& rSize = wxDefaultSize
,long lStyle = 0
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
const wxValidator& validator = wxDefaultValidator, ,const wxValidator& rValidator = wxDefaultValidator
#endif #endif
const wxString& name = wxRadioButtonNameStr) ,const wxString& rsName = wxRadioButtonNameStr
)
{ {
Create(parent, id, label, pos, size, style, validator, name); Create( pParent
,vId
,rsLabel
,rPos
,rSize
,lStyle
#if wxUSE_VALIDATORS
,rValidator
#endif
,rsName
);
} }
bool Create(wxWindow *parent, wxWindowID id, bool Create( wxWindow* pParent
const wxString& label, ,wxWindowID vId
const wxPoint& pos = wxDefaultPosition, ,const wxString& rsLabel
const wxSize& size = wxDefaultSize, long style = 0, ,const wxPoint& rPos = wxDefaultPosition
,const wxSize& rSize = wxDefaultSize
,long lStyle = 0
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
const wxValidator& validator = wxDefaultValidator, ,const wxValidator& rValidator = wxDefaultValidator
#endif #endif
const wxString& name = wxRadioButtonNameStr); ,const wxString& rsName = wxRadioButtonNameStr
);
virtual void SetLabel(const wxString& rsLabel);
virtual void SetValue(bool bVal);
virtual bool GetValue(void) const ;
virtual void SetLabel(const wxString& label); bool OS2Command( WXUINT wParam
virtual void SetValue(bool val); ,WXWORD wId
virtual bool GetValue() const ; );
void Command(wxCommandEvent& rEvent);
bool OS2Command(WXUINT param, WXWORD id); private:
void Command(wxCommandEvent& event); DECLARE_DYNAMIC_CLASS(wxRadioButton)
}; }; // end of wxRadioButton
#endif #endif
// _WX_RADIOBUT_H_ // _WX_RADIOBUT_H_

View File

@@ -376,5 +376,8 @@
#define NO_TEXT_WINDOW_STREAM 1 // defined in textctrl.h for DLL builds #define NO_TEXT_WINDOW_STREAM 1 // defined in textctrl.h for DLL builds
#endif #endif
#define wxUSE_UNICODE 0
#define wxUSE_UNICODE_MSLU 0
#endif #endif
// _WX_SETUP_H_ // _WX_SETUP_H_

View File

@@ -19,95 +19,135 @@ WXDLLEXPORT_DATA(extern const char*) wxSliderNameStr;
// Slider // Slider
class WXDLLEXPORT wxSlider: public wxSliderBase class WXDLLEXPORT wxSlider: public wxSliderBase
{ {
DECLARE_DYNAMIC_CLASS(wxSlider)
public: public:
wxSlider(); wxSlider();
inline wxSlider( wxWindow* pParent
inline wxSlider(wxWindow *parent, wxWindowID id, ,wxWindowID vId
int value, int minValue, int maxValue, ,int nValue
const wxPoint& pos = wxDefaultPosition, ,int nMinValue
const wxSize& size = wxDefaultSize, ,int nMaxValue
long style = wxSL_HORIZONTAL, ,const wxPoint& rPos = wxDefaultPosition
,const wxSize& rSize = wxDefaultSize
,long lStyle = wxSL_HORIZONTAL
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
const wxValidator& validator = wxDefaultValidator, ,const wxValidator& rValidator = wxDefaultValidator
#endif #endif
const wxString& name = wxSliderNameStr) ,const wxString& rsName = wxSliderNameStr
)
{ {
Create(parent, id, value, minValue, maxValue, pos, size, style, validator, name); Create( pParent
,vId
,nValue
,nMinValue
,nMaxValue
,rPos
,rSize
,lStyle
#if wxUSE_VALIDATORS
,rValidator
#endif
,rsName
);
} }
~wxSlider(); ~wxSlider();
bool Create(wxWindow *parent, wxWindowID id, bool Create( wxWindow* pParent
int value, int minValue, int maxValue, ,wxWindowID vId
const wxPoint& pos = wxDefaultPosition, ,int nValue
const wxSize& size = wxDefaultSize, ,int nMinValue
long style = wxSL_HORIZONTAL, ,int nMaxValue
,const wxPoint& rPos = wxDefaultPosition
,const wxSize& rSize = wxDefaultSize
,long lStyle = wxSL_HORIZONTAL
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
const wxValidator& validator = wxDefaultValidator, ,const wxValidator& rValidator = wxDefaultValidator
#endif #endif
const wxString& name = wxSliderNameStr); ,const wxString& rsName = wxSliderNameStr
);
virtual int GetValue() const ; virtual int GetValue(void) const ;
virtual void SetValue(int); virtual void SetValue(int);
void GetSize(int *x, int *y) const ; void GetSize( int* pnX
void GetPosition(int *x, int *y) const ; ,int* pnY
) const;
bool Show(bool show); void GetPosition( int* pnX
,int* pnY
void SetRange(int minValue, int maxValue); ) const ;
bool Show(bool bShow);
inline int GetMin() const { return m_rangeMin; } void SetRange( int nMinValue
inline int GetMax() const { return m_rangeMax; } ,int nMaxValue
);
void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
inline int GetMin(void) const { return m_nRangeMin; }
inline int GetMax(void) const { return m_nRangeMax; }
//
// For trackbars only // For trackbars only
void SetTickFreq(int n, int pos); //
inline int GetTickFreq() const { return m_tickFreq; } void ClearSel(void);
void SetPageSize(int pageSize); void ClearTicks(void);
int GetPageSize() const ;
void ClearSel() ;
void ClearTicks() ;
void SetLineSize(int lineSize);
int GetLineSize() const ;
int GetSelEnd() const ;
int GetSelStart() const ;
void SetSelection(int minPos, int maxPos);
void SetThumbLength(int len) ;
int GetThumbLength() const ;
void SetTick(int tickPos) ;
int GetLineSize(void) const;
int GetPageSize(void) const ;
int GetSelEnd(void) const;
int GetSelStart(void) const;
inline int GetTickFreq(void) const { return m_nTickFreq; }
int GetThumbLength(void) const ;
void SetLineSize(int nLineSize);
void SetPageSize(int nPageSize);
void SetSelection( int nMinPos
,int nMaxPos
);
void SetThumbLength(int nLen) ;
void SetTick(int ntickPos) ;
void SetTickFreq( int n
,int nPos
);
//
// IMPLEMENTATION // IMPLEMENTATION
WXHWND GetStaticMin() const { return m_staticMin; } //
WXHWND GetStaticMax() const { return m_staticMax; } inline WXHWND GetStaticMin(void) const { return m_hStaticMin; }
WXHWND GetEditValue() const { return m_staticValue; } inline WXHWND GetStaticMax(void) const { return m_hStaticMax; }
inline WXHWND GetEditValue(void) const { return m_hStaticValue; }
virtual bool ContainsHWND(WXHWND hWnd) const; virtual bool ContainsHWND(WXHWND hWnd) const;
void Command(wxCommandEvent& rEvent);
void Command(wxCommandEvent& event); virtual WXHBRUSH OnCtlColor( WXHDC hDC
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, ,WXHWND hWnd
WXUINT message, WXWPARAM wParam, WXLPARAM lParam); ,WXUINT uCtlColor
virtual bool OS2OnScroll(int orientation, WXWORD wParam, ,WXUINT uMessage
WXWORD pos, WXHWND control); ,WXWPARAM wParam
,WXLPARAM lParam
);
virtual bool OS2OnScroll( int nOrientation
,WXWORD wParam
,WXWORD wPos
,WXHWND hControl
);
protected: protected:
WXHWND m_staticMin; WXHWND m_hStaticMin;
WXHWND m_staticMax; WXHWND m_hStaticMax;
WXHWND m_staticValue; WXHWND m_hStaticValue;
int m_rangeMin; int m_nRangeMin;
int m_rangeMax; int m_nRangeMax;
int m_pageSize; int m_nPageSize;
int m_lineSize; int m_nLineSize;
int m_tickFreq; int m_nTickFreq;
double m_dPixelToRange;
int m_nThumbLength;
virtual void DoSetSize(int x, int y, virtual void DoSetSize( int nX
int width, int height, ,int nY
int sizeFlags = wxSIZE_AUTO); ,int nWidth
}; ,int nHeight
,int nSizeFlags = wxSIZE_AUTO
);
private:
DECLARE_DYNAMIC_CLASS(wxSlider)
}; // end of CLASS wxSlider
#endif #endif
// _WX_SLIDER_H_ // _WX_SLIDER_H_

View File

@@ -15,58 +15,66 @@
#include "wx/control.h" #include "wx/control.h"
#include "wx/event.h" #include "wx/event.h"
extern MRESULT EXPENTRY wxSpinCtrlWndProc(
HWND hWnd
, UINT uMessage
, MPARAM wParam
, MPARAM lParam
);
class WXDLLEXPORT wxSpinButton: public wxSpinButtonBase class WXDLLEXPORT wxSpinButton: public wxSpinButtonBase
{ {
public: public:
// Construction // Construction
wxSpinButton() { } wxSpinButton() { }
inline wxSpinButton( wxWindow* pParent
inline wxSpinButton( wxWindow *parent ,wxWindowID vId = -1
,wxWindowID id = -1 ,const wxPoint& rPos = wxDefaultPosition
,const wxPoint& pos = wxDefaultPosition ,const wxSize& rSize = wxDefaultSize
,const wxSize& size = wxDefaultSize ,long lStyle = wxSP_VERTICAL
,long style = wxSP_VERTICAL ,const wxString& rsName = "wxSpinButton"
,const wxString& name = "wxSpinButton"
) )
{ {
Create(parent, id, pos, size, style, name); Create(pParent, vId, rPos, rSize, lStyle, rsName);
} }
virtual ~wxSpinButton(); virtual ~wxSpinButton();
bool Create( wxWindow *parent
,wxWindowID id = -1 bool Create( wxWindow* pParent
,const wxPoint& pos = wxDefaultPosition ,wxWindowID vId = -1
,const wxSize& size = wxDefaultSize ,const wxPoint& rPos = wxDefaultPosition
,long style = wxSP_VERTICAL ,const wxSize& rSize = wxDefaultSize
,const wxString& name = "wxSpinButton" ,long lStyle = wxSP_VERTICAL
,const wxString& rsName = "wxSpinButton"
); );
// Accessors // Accessors
virtual int GetValue() const ; inline virtual int GetMax(void) const { return m_max; }
virtual void SetValue(int val) ; inline virtual int GetMin(void) const { return m_min; }
virtual void SetRange( int minVal virtual int GetValue(void) const;
,int maxVal inline bool IsVertical(void) const {return ((m_windowStyle & wxSP_VERTICAL) != 0); }
virtual void SetValue(int nVal);
virtual void SetRange( int nMinVal
,int nMaxVal
); );
//
// Implementation // Implementation
virtual bool OS2Command( WXUINT param //
,WXWORD id virtual bool OS2Command( WXUINT wParam
,WXWORD wId
); );
virtual bool OS2OnNotify( int idCtrl virtual bool OS2OnScroll( int nOrientation
,WXLPARAM lParam
,WXLPARAM* result
);
virtual bool OS2OnScroll( int orientation
,WXWORD wParam ,WXWORD wParam
,WXWORD pos ,WXWORD wPos
,WXHWND control ,WXHWND hControl
); );
inline virtual bool AcceptsFocus(void) const { return FALSE; }
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
private: private:
DECLARE_DYNAMIC_CLASS(wxSpinButton) DECLARE_DYNAMIC_CLASS(wxSpinButton)
}; }; // end of CLASS wxSpinButton
#endif
// _WX_SPINBUTT_H_ #endif // _WX_SPINBUTT_H_

View File

@@ -13,6 +13,9 @@
#define _WX_MSW_SPINCTRL_H_ #define _WX_MSW_SPINCTRL_H_
#include "wx/spinbutt.h" // the base class #include "wx/spinbutt.h" // the base class
#include "wx/dynarray.h"
class WXDLLEXPORT wxSpinCtrl;
WX_DEFINE_EXPORTED_ARRAY(wxSpinCtrl *, wxArraySpins);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Under Win32 and OS2 PM, wxSpinCtrl is a wxSpinButton with a buddy // Under Win32 and OS2 PM, wxSpinCtrl is a wxSpinButton with a buddy
@@ -24,55 +27,99 @@ class WXDLLEXPORT wxSpinCtrl : public wxSpinButton
{ {
public: public:
wxSpinCtrl() { } wxSpinCtrl() { }
wxSpinCtrl( wxWindow* pParent
wxSpinCtrl(wxWindow *parent, ,wxWindowID vId = -1
wxWindowID id = -1, ,const wxString& rsValue = wxEmptyString
const wxString& value = wxEmptyString, ,const wxPoint& rPos = wxDefaultPosition
const wxPoint& pos = wxDefaultPosition, ,const wxSize& rSize = wxDefaultSize
const wxSize& size = wxDefaultSize, ,long lStyle = wxSP_ARROW_KEYS
long style = wxSP_ARROW_KEYS, ,int nMin = 0
int min = 0, int max = 100, int initial = 0, ,int nMax = 100
const wxString& name = _T("wxSpinCtrl")) ,int nInitial = 0
,const wxString& rsName = _T("wxSpinCtrl")
)
{ {
Create(parent, id, value, pos, size, style, min, max, initial, name); Create(pParent, vId, rsValue, rPos, rSize, lStyle, nMin, nMax, nInitial, rsName);
} }
virtual ~wxSpinCtrl();
bool Create(wxWindow *parent, bool Create(wxWindow* pParent
wxWindowID id = -1, ,wxWindowID vId = -1
const wxString& value = wxEmptyString, ,const wxString& rsValue = wxEmptyString
const wxPoint& pos = wxDefaultPosition, ,const wxPoint& rPos = wxDefaultPosition
const wxSize& size = wxDefaultSize, ,const wxSize& rSize = wxDefaultSize
long style = wxSP_ARROW_KEYS, ,long lStyle = wxSP_ARROW_KEYS
int min = 0, int max = 100, int initial = 0, ,int nMin = 0
const wxString& name = _T("wxSpinCtrl")); ,int nMax = 100
,int nInitial = 0
,const wxString& rsName = _T("wxSpinCtrl")
);
// a wxTextCtrl-like method (but we can't have GetValue returning wxString //
// A wxTextCtrl-like method (but we can't have GetValue returning wxString
// because the base class already has one returning int!) // because the base class already has one returning int!)
void SetValue(const wxString& text); //
void SetValue(const wxString& rsText);
//
// implementation only from now on // implementation only from now on
// ------------------------------- // -------------------------------
//
virtual bool Enable(bool bEnable = TRUE);
virtual void SetValue(int val) { wxSpinButton::SetValue(val); } virtual int GetValue(void) const;
virtual int GetValue() const;
virtual bool SetFont(const wxFont &font); virtual bool SetFont(const wxFont &rFont);
virtual void SetFocus(void);
inline virtual void SetValue(int nVal) { wxSpinButton::SetValue(nVal); }
virtual bool Show(bool bShow = TRUE);
//
// wxSpinButton doesn't accept focus, but we do
//
inline virtual bool AcceptsFocus(void) const { return FALSE; }
//
// Return the spinctrl object whose buddy is the given window or NULL
// Doesn't really do much under OS/2
//
static wxSpinCtrl* GetSpinForTextCtrl(WXHWND hWndBuddy);
//
// Process a WM_COMMAND generated by the buddy text control
//
bool ProcessTextCommand( WXWORD wCmd
,WXWORD wId
);
virtual bool Enable(bool enable = TRUE);
virtual bool Show(bool show = TRUE);
protected: protected:
void DoMoveWindow(int x, int y, int width, int height); virtual void DoGetPosition( int* nlX
,int* nlY
) const;
void DoMoveWindow( int nX
,int nY
,int nWidth
,int nHeight
);
virtual wxSize DoGetBestSize(void) const;
virtual void DoGetSize( int* pnWidth
,int* pnHeight
) const;
virtual wxSize DoGetBestSize() const; //
// The handler for wxSpinButton events
//
void OnSpinChange(wxSpinEvent& rEvent);
void OnChar(wxKeyEvent& rEvent);
// the handler for wxSpinButton events WXHWND m_hWndBuddy;
void OnSpinChange(wxSpinEvent& event); static wxArraySpins m_svAllSpins;
WXHWND m_hwndBuddy;
private: private:
DECLARE_DYNAMIC_CLASS(wxSpinCtrl) DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; }; // end of CLASS wxSpinCtrl
#endif // _WX_MSW_SPINCTRL_H_ #endif // _WX_MSW_SPINCTRL_H_

View File

@@ -60,6 +60,10 @@ class WXDLLEXPORT wxStaticBitmap : public wxStaticBitmapBase
// overriden base class virtuals // overriden base class virtuals
virtual bool AcceptsFocus() const { return FALSE; } virtual bool AcceptsFocus() const { return FALSE; }
virtual MRESULT OS2WindowProc( WXUINT uMsg
,WXWPARAM wParam
,WXLPARAM lParam
);
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
@@ -77,7 +81,7 @@ protected:
wxGDIImage* m_pImage; wxGDIImage* m_pImage;
private: private:
DECLARE_DYNAMIC_CLASS(wxStaticBitmap) DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
}; }; // end of wxStaticBitmap
#endif #endif
// _WX_STATBMP_H_ // _WX_STATBMP_H_

View File

@@ -19,50 +19,49 @@ WXDLLEXPORT_DATA(extern const char*) wxStaticBoxNameStr;
// Group box // Group box
class WXDLLEXPORT wxStaticBox : public wxStaticBoxBase class WXDLLEXPORT wxStaticBox : public wxStaticBoxBase
{ {
DECLARE_DYNAMIC_CLASS(wxStaticBox)
public: public:
inline wxStaticBox() {} inline wxStaticBox() {}
inline wxStaticBox( wxWindow* parent inline wxStaticBox( wxWindow* pParent
,wxWindowID id ,wxWindowID vId
,const wxString& label ,const wxString& rsLabel
,const wxPoint& pos = wxDefaultPosition ,const wxPoint& rPos = wxDefaultPosition
,const wxSize& size = wxDefaultSize ,const wxSize& rSize = wxDefaultSize
,long style = 0 ,long lStyle = 0
,const wxString& name = wxStaticBoxNameStr ,const wxString& rsName = wxStaticBoxNameStr
) )
{ {
Create(parent, id, label, pos, size, style, name); Create(pParent, vId, rsLabel, rPos, rSize, lStyle, rsName);
} }
bool Create( wxWindow* parent bool Create( wxWindow* pParent
,wxWindowID id ,wxWindowID vId
,const wxString& label ,const wxString& rsLabel
,const wxPoint& pos = wxDefaultPosition ,const wxPoint& rPos = wxDefaultPosition
,const wxSize& size = wxDefaultSize ,const wxSize& rSize = wxDefaultSize
,long style = 0 ,long lStyle = 0
,const wxString& name = wxStaticBoxNameStr ,const wxString& rsName = wxStaticBoxNameStr
); );
//
// implementation from now on // implementation from now on
// -------------------------- // --------------------------
//
virtual MRESULT OS2WindowProc( WXUINT uMsg
,WXWPARAM wParam
,WXLPARAM lParam
);
void OnEraseBackground(wxEraseEvent& event); //
virtual MRESULT OS2WindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
// overriden base class virtuals // overriden base class virtuals
virtual bool AcceptsFocus() const { return FALSE; } //
inline virtual bool AcceptsFocus(void) const { return FALSE; }
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize(void) const;
private: private:
DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxStaticBox)
}; }; // end of CLASS wxStaticBox
#endif #endif
// _WX_STATBOX_H_ // _WX_STATBOX_H_

View File

@@ -21,29 +21,62 @@
class WXDLLEXPORT wxStaticLine : public wxStaticLineBase class WXDLLEXPORT wxStaticLine : public wxStaticLineBase
{ {
DECLARE_DYNAMIC_CLASS(wxStaticLine)
public: public:
// constructors and pseudo-constructors // constructors and pseudo-constructors
wxStaticLine() { } wxStaticLine() { }
wxStaticLine( wxWindow* pParent
wxStaticLine( wxWindow *parent, ,wxWindowID vId
wxWindowID id, ,const wxPoint& rPos = wxDefaultPosition
const wxPoint &pos = wxDefaultPosition, ,const wxSize& rSize = wxDefaultSize
const wxSize &size = wxDefaultSize, ,long lStyle = wxLI_HORIZONTAL
long style = wxLI_HORIZONTAL, ,const wxString& rsName = wxStaticTextNameStr
const wxString &name = wxStaticTextNameStr ) )
{ {
Create(parent, id, pos, size, style, name); Create(pParent, vId, rPos, rSize, lStyle, rsName);
} }
bool Create( wxWindow *parent, bool Create( wxWindow* pParent
wxWindowID id, ,wxWindowID vId
const wxPoint &pos = wxDefaultPosition, ,const wxPoint& rPos = wxDefaultPosition
const wxSize &size = wxDefaultSize, ,const wxSize& rSize = wxDefaultSize
long style = wxLI_HORIZONTAL, ,long lStyle = wxLI_HORIZONTAL
const wxString &name = wxStaticTextNameStr ); ,const wxString& rsName = wxStaticTextNameStr
}; );
inline bool IsVertical(void) const { return((GetWindowStyleFlag() & wxLI_VERTICAL) != 0); }
inline static int GetDefaultSize(void) { return 2; }
//
// Overriden base class virtuals
//
inline virtual bool AcceptsFocus(void) const {return FALSE;}
protected:
inline wxSize AdjustSize(const wxSize& rSize) const
{
wxSize vSizeReal( rSize.x
,rSize.y
);
if (IsVertical())
{
if (rSize.x == -1 )
vSizeReal.x = GetDefaultSize();
}
else
{
if (rSize.y == -1)
vSizeReal.y = GetDefaultSize();
}
return vSizeReal;
}
inline wxSize DoGetBestSize(void) const { return (AdjustSize(wxDefaultSize)); }
private:
DECLARE_DYNAMIC_CLASS(wxStaticLine)
}; // end of CLASS wxStaticLine
#endif // _WX_OS2_STATLINE_H_ #endif // _WX_OS2_STATLINE_H_

View File

@@ -22,11 +22,8 @@ WXDLLEXPORT_DATA(extern const char*) wxStaticTextNameStr;
class WXDLLEXPORT wxStaticText : public wxControl class WXDLLEXPORT wxStaticText : public wxControl
{ {
DECLARE_DYNAMIC_CLASS(wxStaticText)
public: public:
inline wxStaticText() { } inline wxStaticText() { }
inline wxStaticText( wxWindow* pParent inline wxStaticText( wxWindow* pParent
,wxWindowID vId ,wxWindowID vId
,const wxString& rsLabel ,const wxString& rsLabel
@@ -69,6 +66,9 @@ class WXDLLEXPORT wxStaticText : public wxControl
protected: protected:
virtual wxSize DoGetBestSize(void) const; virtual wxSize DoGetBestSize(void) const;
private:
DECLARE_DYNAMIC_CLASS(wxStaticText)
}; // end of CLASS wxStaticText }; // end of CLASS wxStaticText
#endif #endif

View File

@@ -134,6 +134,8 @@ bool wxControl::OS2CreateControl(
if ((strcmp(zClassname, "COMBOBOX")) == 0) if ((strcmp(zClassname, "COMBOBOX")) == 0)
zClass = WC_COMBOBOX; zClass = WC_COMBOBOX;
else if ((strcmp(zClassname, "STATIC")) == 0)
zClass = WC_STATIC;
dwStyle |= WS_VISIBLE; dwStyle |= WS_VISIBLE;
m_hWnd = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(GetParent()) // Parent window handle m_hWnd = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(GetParent()) // Parent window handle
,(PSZ)zClassname // Window class ,(PSZ)zClassname // Window class

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -27,197 +27,153 @@
IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
bool wxRadioButton::OS2Command(WXUINT param, WXWORD id) void wxRadioButton::Command (
wxCommandEvent& rEvent
)
{ {
if (param == BN_CLICKED) SetValue ((rEvent.GetInt() != 0) );
{ ProcessCommand (rEvent);
wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId); } // end of wxRadioButton::Command
event.SetEventObject( this );
ProcessCommand(event);
return TRUE;
}
else return FALSE;
}
bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, bool wxRadioButton::Create(
const wxString& label, wxWindow* pParent
const wxPoint& pos, , wxWindowID vId
const wxSize& size, long style, , const wxString& rsLabel
, const wxPoint& rPos
, const wxSize& rSize
, long lStyle
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
const wxValidator& validator, , const wxValidator& rValidator
#endif #endif
const wxString& name) , const wxString& rsName
)
{ {
SetName(name); int nX = rPos.x;
int nY = rPos.y;
int nWidth = rSize.x;
int nHeight = rSize.y;
long lsStyle = 0L;
long lGroupStyle = 0L;
SetName(rsName);
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
SetValidator(validator); SetValidator(rValidator);
#endif #endif
if (parent) parent->AddChild(this); if (pParent)
pParent->AddChild(this);
SetBackgroundColour(parent->GetBackgroundColour()); SetBackgroundColour(pParent->GetBackgroundColour());
SetForegroundColour(parent->GetForegroundColour()); SetForegroundColour(pParent->GetForegroundColour());
if ( id == -1 ) if (vId == -1)
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
else else
m_windowId = id; m_windowId = vId;
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
m_windowStyle = style ; m_windowStyle = lStyle ;
// TODO create radiobutton
/*
long groupStyle = 0;
if (m_windowStyle & wxRB_GROUP) if (m_windowStyle & wxRB_GROUP)
groupStyle = WS_GROUP; lGroupStyle = WS_GROUP;
// long msStyle = groupStyle | RADIO_FLAGS; lsStyle = lGroupStyle | BS_AUTORADIOBUTTON | WS_VISIBLE ;
long msStyle = groupStyle | BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE ;
bool want3D;
WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const wxChar *)label,
msStyle,0,0,0,0,
(HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
if (m_windowStyle & wxCLIP_SIBLINGS )
lsStyle |= WS_CLIPSIBLINGS;
m_hWnd = (WXHWND)::WinCreateWindow ( GetHwndOf(pParent)
,WC_BUTTON
,rsLabel.c_str()
,lsStyle
,0, 0, 0, 0
,GetWinHwnd(pParent)
,HWND_TOP
,(HMENU)m_windowId
,NULL
,NULL
);
wxCHECK_MSG(m_hWnd, FALSE, wxT("Failed to create radiobutton")); wxCHECK_MSG(m_hWnd, FALSE, wxT("Failed to create radiobutton"));
if (rsLabel != wxT(""))
SetFont(parent->GetFont());
// Subclass again for purposes of dialog editing mode
SubclassWin((WXHWND)m_hWnd);
// SetValue(value);
*/
// start GRW fix
if (label != wxT(""))
{ {
int label_width, label_height; int nLabelWidth;
GetTextExtent(label, &label_width, &label_height, NULL, NULL, & this->GetFont()); int nLabelHeight;
if (width < 0)
width = (int)(label_width + RADIO_SIZE); GetTextExtent( rsLabel
if (height<0) ,&nLabelWidth
,&nLabelHeight
,NULL
,NULL
,&this->GetFont()
);
if (nWidth < 0)
nWidth = (int)(nLabelWidth + RADIO_SIZE);
if (nHeight<0)
{ {
height = (int)(label_height); nHeight = (int)(nLabelHeight);
if (height < RADIO_SIZE) if (nHeight < RADIO_SIZE)
height = RADIO_SIZE; nHeight = RADIO_SIZE;
} }
} }
else else
{ {
if (width < 0) if (nWidth < 0)
width = RADIO_SIZE; nWidth = RADIO_SIZE;
if (height < 0) if (nHeight < 0)
height = RADIO_SIZE; nHeight = RADIO_SIZE;
} }
// end GRW fix
SetSize(x, y, width, height); //
// Subclass again for purposes of dialog editing mode
//
SubclassWin((WXHWND)m_hWnd);
SetFont(pParent->GetFont());
SetSize( nX
,nY
,nWidth
,nHeight
);
return FALSE; return FALSE;
} } // end of wxRadioButton::Create
void wxRadioButton::SetLabel(const wxString& label)
{
// TODO
}
void wxRadioButton::SetValue(bool value)
{
// TODO
}
//
// Get single selection, for single choice list items // Get single selection, for single choice list items
//
bool wxRadioButton::GetValue() const bool wxRadioButton::GetValue() const
{ {
// TODO return((::WinSendMsg((HWND) GetHWND(), BM_QUERYCHECK, (MPARAM)0L, (MPARAM)0L) != 0));
return FALSE; } // end of wxRadioButton::GetValue
}
void wxRadioButton::Command (wxCommandEvent & event) bool wxRadioButton::OS2Command(
WXUINT wParam
, WXWORD wId
)
{ {
SetValue ( (event.m_commandInt != 0) ); if (wParam == BN_CLICKED)
ProcessCommand (event);
}
// Not implemented
#if 0
bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id,
const wxBitmap *bitmap,
const wxPoint& pos,
const wxSize& size, long style,
#if wxUSE_VALIDATORS
const wxValidator& validator,
#endif
const wxString& name)
{ {
SetName(name); wxCommandEvent rEvent( wxEVT_COMMAND_RADIOBUTTON_SELECTED
#if wxUSE_VALIDATORS ,m_windowId
SetValidator(validator); );
#endif
if (parent) parent->AddChild(this);
SetBackgroundColour(parent->GetBackgroundColour());
SetForegroundColour(parent->GetForegroundColour());
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
m_windowStyle = style ;
long groupStyle = 0;
if (m_windowStyle & wxRB_GROUP)
groupStyle = WS_GROUP;
// TODO:
/*
// long msStyle = groupStyle | RADIO_FLAGS;
// long msStyle = groupStyle | BS_RADIOBUTTON | WS_CHILD | WS_VISIBLE ;
m_hWnd = (WXHWND) CreateWindowEx(MakeExtendedStyle(m_windowStyle), RADIO_CLASS, "toggle",
msStyle,0,0,0,0,
(HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
wxCHECK_MSG( m_hWnd, "Failed to create radio button", FALSE );
*/
// Subclass again for purposes of dialog editing mode
SubclassWin(GetHWND());
SetSize(x, y, width, height);
rEvent.SetEventObject(this);
ProcessCommand(rEvent);
return TRUE; return TRUE;
} }
else
void wxBitmapRadioButton::SetLabel(const wxBitmap *bitmap)
{
}
void wxBitmapRadioButton::SetValue(bool value)
{
// Following necessary for Win32s, because Win32s translate BM_SETCHECK
// SendMessage((HWND) GetHWND(), BM_SETCHECK, (WPARAM)value, 0L);
}
// Get single selection, for single choice list items
bool wxBitmapRadioButton::GetValue(void) const
{
// return (bool)SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0L);
return FALSE; return FALSE;
} } // end of wxRadioButton::OS2Command
void wxRadioButton::SetLabel(
const wxString& rsLabel
)
{
::WinSetWindowText((HWND)GetHWND(), (const char *)rsLabel.c_str());
} // end of wxRadioButton::SetLabel
void wxRadioButton::SetValue(
bool bValue
)
{
::WinSendMsg((HWND)GetHWND(), BM_SETCHECK, (MPARAM)bValue, (MPARAM)0);
} // end of wxRadioButton::SetValue
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -29,6 +29,11 @@
#include "wx/spinbutt.h" #include "wx/spinbutt.h"
extern void wxAssociateWinWithHandle( HWND hWnd
,wxWindowOS2* pWin
);
static WXFARPROC fnWndProcSpinCtrl = (WXFARPROC)NULL;
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxNotifyEvent) IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxNotifyEvent)
#include "wx/os2/private.h" #include "wx/os2/private.h"
@@ -44,29 +49,106 @@ IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxNotifyEvent)
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
bool wxSpinButton::Create( bool wxSpinButton::Create(
wxWindow* parent wxWindow* pParent
, wxWindowID id , wxWindowID vId
, const wxPoint& pos , const wxPoint& rPos
, const wxSize& size , const wxSize& rSize
, long style , long lStyle
, const wxString& name , const wxString& rsName
) )
{ {
SetName(name); int nX = rPos.x;
int nY = rPos.y;
int nWidth = rSize.x;
int nHeight = rSize.y;
m_windowStyle = style; m_min = 0;
m_max = 100;
if (vId == -1)
m_windowId = NewControlId();
else
m_windowId = vId;
m_backgroundColour = pParent->GetBackgroundColour();
m_foregroundColour = pParent->GetForegroundColour();
SetName(rsName);
SetParent(pParent);
m_windowStyle = lStyle;
SetParent(parent); //
// Get the right size for the control
//
if (nWidth <= 0 || nHeight <= 0 )
{
wxSize vSize = DoGetBestSize();
m_windowId = (id == -1) ? NewControlId() : id; if (nWidth <= 0 )
nWidth = vSize.x;
if (nHeight <= 0 )
nHeight = vSize.y;
}
if (nX < 0 )
nX = 0;
if (nY < 0 )
nY = 0;
// TODO create spin button long lSstyle = 0L;
lSstyle = WS_VISIBLE |
WS_TABSTOP |
SPBS_MASTER | // We use only single field spin buttons
SPBS_NUMERICONLY; // We default to numeric data
if (m_windowStyle & wxCLIP_SIBLINGS )
lSstyle |= WS_CLIPSIBLINGS;
SPBCDATA vCtrlData;
vCtrlData.cbSize = sizeof(SPBCDATA);
vCtrlData.ulTextLimit = 10L;
vCtrlData.lLowerLimit = 0L;
vCtrlData.lUpperLimit = 100L;
vCtrlData.idMasterSpb = vId;
vCtrlData.pHWXCtlData = NULL;
m_hWnd = (WXHWND)::WinCreateWindow( GetWinHwnd(pParent)
,WC_SPINBUTTON
,(PSZ)NULL
,lSstyle
,0L, 0L, 0L, 0L
,GetWinHwnd(pParent)
,HWND_TOP
,(HMENU)vId
,(PVOID)&vCtrlData
,NULL
);
if (m_hWnd == 0)
{
return FALSE; return FALSE;
} }
if(pParent)
pParent->AddChild((wxSpinButton *)this);
SetFont(pParent->GetFont());
//
// For OS/2 we want to hide the text portion so we can substitute an
// independent text ctrl in its place. 10 device units does this
//
SetSize( nX
,nY
,10L
,nHeight
);
wxAssociateWinWithHandle( m_hWnd
,(wxWindowOS2*)this
);
::WinSetWindowULong(GetHwnd(), QWL_USER, (LONG)this);
fnWndProcSpinCtrl = (WXFARPROC)::WinSubclassWindow(m_hWnd, (PFNWP)wxSpinCtrlWndProc);
return TRUE;
} // end of wxSpinButton::Create
wxSpinButton::~wxSpinButton() wxSpinButton::~wxSpinButton()
{ {
} } // end of wxSpinButton::~wxSpinButton
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// size calculation // size calculation
@@ -74,23 +156,12 @@ wxSpinButton::~wxSpinButton()
wxSize wxSpinButton::DoGetBestSize() const wxSize wxSpinButton::DoGetBestSize() const
{ {
// TODO: //
/* // OS/2 PM does not really have system metrics so we'll just set our best guess
if ( (GetWindowStyle() & wxSP_VERTICAL) != 0 ) // Also we have no horizontal spin buttons.
{ //
// vertical control return (wxSize(10,20));
return wxSize(GetSystemMetrics(SM_CXVSCROLL), } // end of wxSpinButton::DoGetBestSize
2*GetSystemMetrics(SM_CYVSCROLL));
}
else
{
// horizontal control
return wxSize(2*GetSystemMetrics(SM_CXHSCROLL),
GetSystemMetrics(SM_CYHSCROLL));
}
*/
return wxSize(0, 0);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Attributes // Attributes
@@ -98,66 +169,68 @@ wxSize wxSpinButton::DoGetBestSize() const
int wxSpinButton::GetValue() const int wxSpinButton::GetValue() const
{ {
// TODO int nVal = 0;
return 0; long lVal = 0L;
} char zVal[10];
void wxSpinButton::SetValue(int val) ::WinSendMsg( GetHwnd()
{ ,SPBM_QUERYVALUE
// TODO ,MPFROMP(zVal)
} ,MPFROM2SHORT( (USHORT)10
,SPBQ_UPDATEIFVALID
)
);
lVal = atol(zVal);
return ((int)lVal);
} // end of wxSpinButton::GetValue
void wxSpinButton::SetRange(int minVal, int maxVal) bool wxSpinButton::OS2OnScroll(
int nOrientation
, WXWORD wParam
, WXWORD wPos
, WXHWND hControl
)
{ {
// TODO wxCHECK_MSG(hControl, FALSE, wxT("scrolling what?") )
}
bool wxSpinButton::OS2OnScroll(int orientation, WXWORD wParam, wxSpinEvent vEvent( wxEVT_SCROLL_THUMBTRACK
WXWORD pos, WXHWND control) ,m_windowId
);
int nVal = (int)wPos; // cast is important for negative values!
vEvent.SetPosition(nVal);
vEvent.SetEventObject(this);
return(GetEventHandler()->ProcessEvent(vEvent));
} // end of wxSpinButton::OS2OnScroll
bool wxSpinButton::OS2Command(
WXUINT uCmd
, WXWORD wId
)
{ {
wxCHECK_MSG( control, FALSE, wxT("scrolling what?") )
// TODO:
/*
if ( wParam != SB_THUMBPOSITION )
{
// probable SB_ENDSCROLL - we don't react to it
return FALSE; return FALSE;
} } // end of wxSpinButton::OS2Command
wxSpinEvent event(wxEVT_SCROLL_THUMBTRACK, m_windowId); void wxSpinButton::SetRange(
event.SetPosition((short)pos); // cast is important for negative values! int nMinVal
event.SetEventObject(this); , int nMaxVal
)
return GetEventHandler()->ProcessEvent(event);
*/
return FALSE;
}
bool wxSpinButton::OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
{ {
// TODO: m_min = nMinVal;
/* m_max = nMaxVal;
LPNM_UPDOWN lpnmud = (LPNM_UPDOWN)lParam;
wxSpinEvent event(lpnmud->iDelta > 0 ? wxEVT_SCROLL_LINEUP ::WinSendMsg( GetHwnd()
: wxEVT_SCROLL_LINEDOWN, ,SPBM_SETLIMITS
m_windowId); ,MPFROMLONG(nMaxVal)
event.SetPosition(lpnmud->iPos + lpnmud->iDelta); ,MPFROMLONG(nMinVal)
event.SetEventObject(this); );
} // end of wxSpinButton::SetRange
bool processed = GetEventHandler()->ProcessEvent(event); void wxSpinButton::SetValue(
int nValue
*result = event.IsAllowed() ? 0 : 1; )
return processed;
*/
return FALSE;
}
bool wxSpinButton::OS2Command(WXUINT cmd, WXWORD id)
{ {
// No command messages ::WinSendMsg(GetHwnd(), SPBM_SETCURRENTVALUE, MPFROMLONG(nValue), MPARAM(0));
return FALSE; } // end of wxSpinButton::SetValue
}
#endif //wxUSE_SPINBTN #endif //wxUSE_SPINBTN

View File

@@ -40,6 +40,11 @@
// macros // macros
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
extern void wxAssociateWinWithHandle( HWND hWnd
,wxWindowOS2* pWin
);
static WXFARPROC fnWndProcSpinCtrl = (WXFARPROC)NULL;
IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl)
BEGIN_EVENT_TABLE(wxSpinCtrl, wxSpinButton) BEGIN_EVENT_TABLE(wxSpinCtrl, wxSpinButton)
@@ -55,244 +60,423 @@ static const int MARGIN_BETWEEN = 5;
// ============================================================================ // ============================================================================
// implementation // implementation
// ============================================================================ // ============================================================================
MRESULT EXPENTRY wxSpinCtrlWndProc(
HWND hWnd
, UINT uMessage
, MPARAM wParam
, MPARAM lParam
)
{
wxSpinCtrl* pSpin = (wxSpinCtrl *)::WinQueryWindowULong( hWnd
,QWL_USER
);
bool bProccesed = FALSE;
MRESULT rc = (MRESULT)0;
//
// Forward some messages (the key ones only so far) to the spin ctrl
//
switch (uMessage )
{
case WM_CHAR:
pSpin->OS2WindowProc( uMessage
,wParam
,lParam
);
//
// The control may have been deleted at this point, so check.
//
if (!(::WinIsWindow(vHabmain, hWnd) && ((wxSpinCtrl *)::WinQueryWindowULong( hWnd
,QWL_USER
)
) == pSpin))
return 0;
break;
}
return (fnWndProcSpinCtrl( hWnd
,(ULONG)uMessage
,(MPARAM)wParam
,(MPARAM)lParam
)
);
} // end of wxSpinCtrlWndProc
wxSpinCtrl::~wxSpinCtrl()
{
m_svAllSpins.Remove(this);
// This removes spurious memory leak reporting
if (m_svAllSpins.GetCount() == 0)
m_svAllSpins.Clear();
} // end of wxSpinCtrl::~wxSpinCtrl
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// construction // construction
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxSpinCtrl::Create(wxWindow *parent, bool wxSpinCtrl::Create(
wxWindowID id, wxWindow* pParent
const wxString& value, , wxWindowID vId
const wxPoint& pos, , const wxString& rsValue
const wxSize& size, , const wxPoint& rPos
long style, , const wxSize& rSize
int min, int max, int initial, , long lStyle
const wxString& name) , int nMin
, int nMax
, int nInitial
, const wxString& rsName
)
{ {
// TODO: if (vId == -1)
/* m_windowId = NewControlId();
// before using DoGetBestSize(), have to set style to let the base class else
// know whether this is a horizontal or vertical control (we're always m_windowId = vId;
// vertical) m_backgroundColour = pParent->GetBackgroundColour();
style |= wxSP_VERTICAL; m_foregroundColour = pParent->GetForegroundColour();
SetWindowStyle(style); SetName(rsName);
SetParent(pParent);
m_windowStyle = lStyle;
// calculate the sizes: the size given is the toal size for both controls int lSstyle = 0L;
// and we need to fit them both in the given width (height is the same)
wxSize sizeText(size), sizeBtn(size);
sizeBtn.x = wxSpinButton::DoGetBestSize().x;
if ( sizeText.x <= 0 )
{
// DEFAULT_ITEM_WIDTH is the default width for the text control
sizeText.x = DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN + sizeBtn.x;
}
sizeText.x -= sizeBtn.x + MARGIN_BETWEEN; lSstyle = WS_VISIBLE |
if ( sizeText.x <= 0 ) WS_TABSTOP |
{ SPBS_MASTER | // We use only single field spin buttons
wxLogDebug(_T("not enough space for wxSpinCtrl!")); SPBS_NUMERICONLY; // We default to numeric data
}
wxPoint posBtn(pos); if (m_windowStyle & wxCLIP_SIBLINGS )
posBtn.x += sizeText.x + MARGIN_BETWEEN; lSstyle |= WS_CLIPSIBLINGS;
// create the spin button SPBCDATA vCtrlData;
if ( !wxSpinButton::Create(parent, id, posBtn, sizeBtn, style, name) )
vCtrlData.cbSize = sizeof(SPBCDATA);
vCtrlData.ulTextLimit = 10L;
vCtrlData.lLowerLimit = 0L;
vCtrlData.lUpperLimit = 100L;
vCtrlData.idMasterSpb = vId;
vCtrlData.pHWXCtlData = NULL;
m_hWnd = (WXHWND)::WinCreateWindow( GetWinHwnd(pParent)
,WC_SPINBUTTON
,(PSZ)NULL
,lSstyle
,0L, 0L, 0L, 0L
,GetWinHwnd(pParent)
,HWND_TOP
,(HMENU)vId
,(PVOID)&vCtrlData
,NULL
);
if (m_hWnd == 0)
{ {
return FALSE; return FALSE;
} }
m_hWndBuddy = m_hWnd; // One in the same for OS/2
SetRange(min, max); if(pParent)
SetValue(initial); pParent->AddChild((wxSpinButton *)this);
SetFont(pParent->GetFont());
// create the text window SetSize( rPos.x
m_hwndBuddy = (WXHWND)::CreateWindowEx ,rPos.y
( ,rSize.x
WS_EX_CLIENTEDGE, // sunken border ,rSize.y
_T("EDIT"), // window class
NULL, // no window title
WS_CHILD | WS_BORDER, // style (will be shown later)
pos.x, pos.y, // position
0, 0, // size (will be set later)
GetHwndOf(parent), // parent
(HMENU)-1, // control id
wxGetInstance(), // app instance
NULL // unused client data
); );
if ( !m_hwndBuddy ) SetRange(nMin, nMax);
{ SetValue(nInitial);
wxLogLastError("CreateWindow(buddy text window)");
//
// For OS/2 we'll just set our handle into our long data
//
wxAssociateWinWithHandle( m_hWnd
,(wxWindowOS2*)this
);
::WinSetWindowULong(GetHwnd(), QWL_USER, (LONG)this);
fnWndProcSpinCtrl = (WXFARPROC)::WinSubclassWindow(m_hWnd, (PFNWP)wxSpinCtrlWndProc);
m_svAllSpins.Add(this);
return TRUE;
} // end of wxSpinCtrl::Create
wxSize wxSpinCtrl::DoGetBestSize() const
{
wxSize vSizeBtn = wxSpinButton::DoGetBestSize();
int nHeight;
vSizeBtn.x += DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN;
wxGetCharSize( GetHWND()
,NULL
,&nHeight
,(wxFont*)&GetFont()
);
nHeight = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nHeight);
if (vSizeBtn.y < nHeight)
{
//
// Make the text tall enough
//
vSizeBtn.y = nHeight;
}
return vSizeBtn;
} // end of wxSpinCtrl::DoGetBestSize
void wxSpinCtrl::DoGetPosition(
int* pnX
, int* pnY
) const
{
WXHWND hWnd = GetHWND();
wxConstCast(this, wxSpinCtrl)->m_hWnd = m_hWndBuddy;
wxSpinButton::DoGetPosition( pnX
,pnY
);
wxConstCast(this, wxSpinCtrl)->m_hWnd = hWnd;
} // end of wxpinCtrl::DoGetPosition
void wxSpinCtrl::DoGetSize(
int* pnWidth
, int* pnHeight
) const
{
RECTL vSpinrect;
::WinQueryWindowRect(GetHwnd(), &vSpinrect);
if (pnWidth)
*pnWidth = vSpinrect.xRight - vSpinrect.xLeft;
if (pnHeight)
*pnHeight = vSpinrect.yTop - vSpinrect.yBottom;
} // end of wxSpinCtrl::DoGetSize
void wxSpinCtrl::DoMoveWindow(
int nX
, int nY
, int nWidth
, int nHeight
)
{
wxWindowOS2* pParent = (wxWindowOS2*)GetParent();
if (pParent)
{
if (pParent->IsKindOf(CLASSINFO(wxFrame)))
{
nY = pParent->GetClientSize().y - (nY + nHeight);
}
else
nY = pParent->GetSize().y - (nY + nHeight);
}
else
{
RECTL vRect;
::WinQueryWindowRect(HWND_DESKTOP, &vRect);
nY = vRect.yTop - (nY + nHeight);
}
::WinSetWindowPos( GetHwnd()
,HWND_TOP
,nX
,nY
,nWidth
,nHeight
,SWP_SIZE | SWP_MOVE | SWP_ZORDER | SWP_SHOW
);
} // end of wxSpinCtrl::DoMoveWindow
bool wxSpinCtrl::Enable(
bool bEnable
)
{
if (!wxControl::Enable(bEnable))
{
return FALSE; return FALSE;
} }
::WinEnableWindow(GetHwnd(), bEnable);
return TRUE;
} // end of wxSpinCtrl::Enable
// should have the same font as the other controls wxSpinCtrl* wxSpinCtrl::GetSpinForTextCtrl(
SetFont(GetParent()->GetFont()); WXHWND hWndBuddy
)
// set the size of the text window - can do it only now, because we
// couldn't call DoGetBestSize() before as font wasn't set
if ( sizeText.y <= 0 )
{ {
int cx, cy; wxSpinCtrl* pSpin = (wxSpinCtrl *)::WinQueryWindowULong( (HWND)hWndBuddy
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont()); ,QWL_USER
);
int i = m_svAllSpins.Index(pSpin);
sizeText.y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy); if (i == wxNOT_FOUND)
} return NULL;
DoMoveWindow(pos.x, pos.y, // sanity check
sizeText.x + sizeBtn.x + MARGIN_BETWEEN, sizeText.y); wxASSERT_MSG( pSpin->m_hWndBuddy == hWndBuddy,
_T("wxSpinCtrl has incorrect buddy HWND!") );
(void)::ShowWindow((HWND)m_hwndBuddy, SW_SHOW); return pSpin;
} // end of wxSpinCtrl::GetSpinForTextCtrl
// associate the text window with the spin button
(void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)m_hwndBuddy, 0);
if ( !value.IsEmpty() )
{
SetValue(value);
}
*/
return FALSE;
}
// ----------------------------------------------------------------------------
// wxTextCtrl-like methods
// ----------------------------------------------------------------------------
void wxSpinCtrl::SetValue(const wxString& text)
{
// TODO:
/*
if ( !::SetWindowText((HWND)m_hwndBuddy, text.c_str()) )
{
wxLogLastError("SetWindowText(buddy)");
}
*/
}
int wxSpinCtrl::GetValue() const int wxSpinCtrl::GetValue() const
{ {
wxString val = wxGetWindowText(m_hwndBuddy); long lVal = 0L;
char zVal[10];
long n; ::WinSendMsg( GetHwnd()
if ( (wxSscanf(val, wxT("%lu"), &n) != 1) ) ,SPBM_QUERYVALUE
n = INT_MIN; ,MPFROMP(zVal)
,MPFROM2SHORT( (USHORT)10
,SPBQ_UPDATEIFVALID
)
);
lVal - atol(zVal);
return lVal;
} // end of wxSpinCtrl::GetValue
return n; void wxSpinCtrl::OnChar (
wxKeyEvent& rEvent
)
{
switch (rEvent.KeyCode())
{
case WXK_RETURN:
{
wxCommandEvent vEvent( wxEVT_COMMAND_TEXT_ENTER
,m_windowId
);
wxString sVal = wxGetWindowText(m_hWndBuddy);
InitCommandEvent(vEvent);
vEvent.SetString((char*)sVal.c_str());
vEvent.SetInt(GetValue());
if (GetEventHandler()->ProcessEvent(vEvent))
return;
break;
} }
// ---------------------------------------------------------------------------- case WXK_TAB:
// forward some methods to subcontrols //
// ---------------------------------------------------------------------------- // Always produce navigation event - even if we process TAB
// ourselves the fact that we got here means that the user code
bool wxSpinCtrl::SetFont(const wxFont& font) // decided to skip processing of this TAB - probably to let it
// do its default job.
//
{ {
if ( !wxWindowBase::SetFont(font) ) wxNavigationKeyEvent vEventNav;
vEventNav.SetDirection(!rEvent.ShiftDown());
vEventNav.SetWindowChange(rEvent.ControlDown());
vEventNav.SetEventObject(this);
if (GetParent()->GetEventHandler()->ProcessEvent(vEventNav))
return;
}
break;
}
//
// No, we didn't process it
//
rEvent.Skip();
} // end of wxSpinCtrl::OnChar
void wxSpinCtrl::OnSpinChange(
wxSpinEvent& rEventSpin
)
{
wxCommandEvent vEvent( wxEVT_COMMAND_SPINCTRL_UPDATED
,GetId()
);
vEvent.SetEventObject(this);
vEvent.SetInt(rEventSpin.GetPosition());
(void)GetEventHandler()->ProcessEvent(vEvent);
if (rEventSpin.GetSkipped())
{
vEvent.Skip();
}
} // end of wxSpinCtrl::OnSpinChange
bool wxSpinCtrl::ProcessTextCommand(
WXWORD wCmd
, WXWORD wId
)
{
switch (wCmd)
{
case SPBN_CHANGE:
{
wxCommandEvent vEvent( wxEVT_COMMAND_TEXT_UPDATED
,GetId()
);
vEvent.SetEventObject(this);
wxString sVal = wxGetWindowText(m_hWndBuddy);
vEvent.SetString((char*)sVal.c_str());
vEvent.SetInt(GetValue());
return (GetEventHandler()->ProcessEvent(vEvent));
}
case SPBN_SETFOCUS:
case SPBN_KILLFOCUS:
{
wxFocusEvent vEvent( wCmd == EN_KILLFOCUS ? wxEVT_KILL_FOCUS : wxEVT_SET_FOCUS
,m_windowId
);
vEvent.SetEventObject(this);
return(GetEventHandler()->ProcessEvent(vEvent));
}
default:
break;
}
//
// Not processed
//
return FALSE;
} // end of wxSpinCtrl::ProcessTextCommand
void wxSpinCtrl::SetFocus()
{
::WinSetFocus(HWND_DESKTOP, GetHwnd());
} // end of wxSpinCtrl::SetFocus
bool wxSpinCtrl::SetFont(
const wxFont& rFont
)
{
if (!wxWindowBase::SetFont(rFont))
{ {
// nothing to do // nothing to do
return FALSE; return FALSE;
} }
WXHANDLE hFont = GetFont().GetResourceHandle(); WXHANDLE hFont = GetFont().GetResourceHandle();
// TODO: wxOS2SetFont( m_hWnd
/* ,rFont
(void)::SendMessage((HWND)m_hwndBuddy, WM_SETFONT, (WPARAM)hFont, TRUE); );
*/
return TRUE; return TRUE;
} } // end of wxSpinCtrl::SetFont
bool wxSpinCtrl::Show(bool show) void wxSpinCtrl::SetValue(
const wxString& rsText
)
{ {
if ( !wxControl::Show(show) ) long lVal;
lVal = atol(rsText.c_str());
wxSpinButton::SetValue(lVal);
} // end of wxSpinCtrl::SetValue
bool wxSpinCtrl::Show(
bool bShow
)
{
if (!wxControl::Show(bShow))
{ {
return FALSE; return FALSE;
} }
// TODO:
/*
::ShowWindow((HWND)m_hwndBuddy, show ? SW_SHOW : SW_HIDE);
*/
return TRUE; return TRUE;
} } // end of wxSpinCtrl::Show
bool wxSpinCtrl::Enable(bool enable)
{
if ( !wxControl::Enable(enable) )
{
return FALSE;
}
// TODO:
/*
::EnableWindow((HWND)m_hwndBuddy, enable);
*/
return TRUE;
}
// ----------------------------------------------------------------------------
// event processing
// ----------------------------------------------------------------------------
void wxSpinCtrl::OnSpinChange(wxSpinEvent& eventSpin)
{
wxCommandEvent event(wxEVT_COMMAND_SPINCTRL_UPDATED, GetId());
event.SetEventObject(this);
event.SetInt(eventSpin.GetPosition());
(void)GetEventHandler()->ProcessEvent(event);
if ( eventSpin.GetSkipped() )
{
event.Skip();
}
}
// ----------------------------------------------------------------------------
// size calculations
// ----------------------------------------------------------------------------
wxSize wxSpinCtrl::DoGetBestSize() const
{
wxSize sizeBtn = wxSpinButton::DoGetBestSize();
// TODO:
/*
sizeBtn.x += DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN;
int y;
wxGetCharSize(GetHWND(), NULL, &y, &GetFont());
y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(y);
if ( sizeBtn.y < y )
{
// make the text tall enough
sizeBtn.y = y;
}
*/
return sizeBtn;
}
void wxSpinCtrl::DoMoveWindow(int x, int y, int width, int height)
{
int widthBtn = DoGetBestSize().x;
int widthText = width - widthBtn - MARGIN_BETWEEN;
if ( widthText <= 0 )
{
wxLogDebug(_T("not enough space for wxSpinCtrl!"));
}
// TODO:
/*
if ( !::MoveWindow((HWND)m_hwndBuddy, x, y, widthText, height, TRUE) )
{
wxLogLastError("MoveWindow(buddy)");
}
x += widthText + MARGIN_BETWEEN;
if ( !::MoveWindow(GetHwnd(), x, y, widthBtn, height, TRUE) )
{
wxLogLastError("MoveWindow");
}
*/
}
#endif //wxUSE_SPINBTN #endif //wxUSE_SPINBTN

View File

@@ -24,175 +24,94 @@
IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
BEGIN_EVENT_TABLE(wxStaticBox, wxControl) bool wxStaticBox::Create(
EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground) wxWindow* pParent
END_EVENT_TABLE() , wxWindowID vId
, const wxString& rsLabel
, const wxPoint& rPos
/* , const wxSize& rSize
* Group box , long lStyle
*/ , const wxString& rsName
)
bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{ {
SetName(name); if(!OS2CreateControl( pParent
,vId
if (parent) parent->AddChild(this); ,rPos
,rSize
SetBackgroundColour(parent->GetBackgroundColour()) ; ,lStyle
SetForegroundColour(parent->GetForegroundColour()) ; #if wxUSE_VALIDATORS
,wxDefaultValidator
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
m_windowStyle = style;
// TODO:
/*
long msStyle = BS_GROUPBOX | WS_CHILD | WS_VISIBLE ; // GROUP_FLAGS;
bool want3D;
WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
HWND wx_button =
CreateWindowEx(exStyle, wxT("BUTTON"), (const wxChar *)label, msStyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL);
#if wxUSE_CTL3D
if (want3D)
{
Ctl3dSubclassCtl(wx_button);
m_useCtl3D = TRUE;
}
#endif #endif
,rsName
m_hWnd = (WXHWND)wx_button; ))
{
// Subclass again for purposes of dialog editing mode
SubclassWin(GetHWND());
SetFont(parent->GetFont());
SetSize(x, y, width, height);
ShowWindow(wx_button, SW_SHOW);
*/
return FALSE; return FALSE;
} }
wxPoint vPos(0,0);
wxSize vSize(0,0);
if (!OS2CreateControl( "STATIC"
,SS_GROUPBOX
,vPos
,vSize
,rsLabel
))
{
return FALSE;
}
wxColour vColour;
vColour.Set(wxString("BLACK"));
LONG lColor = (LONG)vColour.GetPixel();
::WinSetPresParam( m_hWnd
,PP_FOREGROUNDCOLOR
,sizeof(LONG)
,(PVOID)&lColor
);
SetFont(pParent->GetFont());
SetSize( rPos.x
,rPos.y
,rSize.x
,rSize.y
);
return TRUE;
} // end of wxStaticBox::Create
wxSize wxStaticBox::DoGetBestSize() const wxSize wxStaticBox::DoGetBestSize() const
{ {
int cx, cy; int nCx;
wxGetCharSize(GetHWND(), &cx, &cy, (wxFont*)&GetFont()); int nCy;
int wBox; int wBox;
GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy);
wBox += 3*cx; wxGetCharSize( GetHWND()
int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy); ,&nCx
,&nCy
,(wxFont*)&GetFont()
);
GetTextExtent( wxGetWindowText(m_hWnd)
,&wBox
,&nCy
);
wBox += 3 * nCx;
return wxSize(wBox, hBox); int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy);
}
WXHBRUSH wxStaticBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, return wxSize( wBox
WXUINT message, ,hBox
WXWPARAM wParam, );
WXLPARAM lParam) } // end of wxStaticBox::DoGetBestSize
MRESULT wxStaticBox::OS2WindowProc(
WXUINT nMsg
, 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;
}
// Shouldn't erase the whole window, since the static box must only paint its
// outline.
void wxStaticBox::OnEraseBackground(wxEraseEvent& event)
{
// If we don't have this (call Default()), we don't paint the background properly.
// If we do have this, we seem to overwrite enclosed controls.
// Is it the WS_CLIPCHILDREN style that's causing the problems?
// Probably - without this style, the background of the window will show through,
// so the control doesn't have to paint it. The window background will always be
// painted before all other controls, therefore there are no problems with
// controls being hidden by the static box.
// So, if we could specify wxCLIP_CHILDREN in window, or not, we could optimise painting better.
// We would assume wxCLIP_CHILDREN in a frame and a scrolled window, but not in a panel.
// Is this too platform-specific?? What else can we do? Not a lot, since we have to pass
// this information from arbitrary wxWindow derivatives, and it depends on what you wish to
// do with the windows.
// Alternatively, just make sure that wxStaticBox is always at the back! There are probably
// few other circumstances where it matters about child clipping. But what about painting onto
// to panel, inside a groupbox? Doesn't appear, because the box wipes it out.
wxWindow *parent = GetParent();
// TODO:
/*
if ( parent && parent->GetHWND() && (::GetWindowLong((HWND) parent->GetHWND(), GWL_STYLE) & WS_CLIPCHILDREN) )
{
// TODO: May in fact need to generate a paint event for inside this
// control's rectangle, otherwise all controls are going to be clipped -
// ugh.
HBRUSH hBrush = ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
int mode = ::SetMapMode((HDC) event.GetDC()->GetHDC(), MM_TEXT);
RECT rect;
::GetClientRect(GetHwnd(), &rect);
::FillRect ((HDC) event.GetDC()->GetHDC(), &rect, hBrush);
::DeleteObject(hBrush);
::SetMapMode((HDC) event.GetDC()->GetHDC(), mode);
}
else
{
event.Skip();
}
*/
}
MRESULT wxStaticBox::OS2WindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
// TODO:
/*
if ( nMsg == WM_NCHITTEST)
{
int xPos = LOWORD(lParam); // horizontal position of cursor
int yPos = HIWORD(lParam); // vertical position of cursor
// ScreenToClient(&xPos, &yPos);
// Make sure you can drag by the top of the groupbox, but let
// other (enclosed) controls get mouse events also
if (yPos < 10)
return (long)HTCLIENT;
}
*/
return wxControl::OS2WindowProc(nMsg, wParam, lParam); return wxControl::OS2WindowProc(nMsg, wParam, lParam);
} } // end of wxStaticBox::OS2WindowProc

View File

@@ -40,48 +40,50 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticLine, wxControl)
// wxStaticLine // wxStaticLine
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxStaticLine::Create( wxWindow *parent, bool wxStaticLine::Create(
wxWindowID id, wxWindow* pParent
const wxPoint &pos, , wxWindowID vId
const wxSize &size, , const wxPoint& rPos
long style, , const wxSize& rSize
const wxString &name) , long lStyle
, const wxString& rsName
)
{ {
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) if (!CreateBase( pParent
,vId
,rPos
,rSize
,lStyle
,wxDefaultValidator
,rsName
))
return FALSE; return FALSE;
parent->AddChild(this); pParent->AddChild(this);
wxSize sizeReal = AdjustSize(size); wxSize vSizeReal = AdjustSize(rSize);
// TODO: m_hWnd = (WXHWND)::WinCreateWindow( GetWinHwnd(pParent)
/* ,WC_STATIC
m_hWnd = (WXHWND)::CreateWindow ,""
( ,WS_VISIBLE | SS_TEXT | DT_VCENTER | DT_CENTER
wxT("STATIC"), ,rPos.x
wxT(""), ,rPos.y
WS_VISIBLE | WS_CHILD | ,vSizeReal.x
SS_GRAYRECT | SS_SUNKEN, // | SS_ETCHEDFRAME, ,vSizeReal.y
pos.x, pos.y, sizeReal.x, sizeReal.y, ,GetWinHwnd(pParent)
GetWinHwnd(parent), ,HWND_TOP
(HMENU)m_windowId, ,(ULONG)m_windowId
wxGetInstance(), ,NULL
NULL ,NULL
); );
if ( !m_hWnd ) if ( !m_hWnd )
{ {
#ifdef __WXDEBUG__
wxLogDebug(wxT("Failed to create static control")); wxLogDebug(wxT("Failed to create static control"));
#endif
return FALSE; return FALSE;
} }
SubclassWin(m_hWnd); SubclassWin(m_hWnd);
return TRUE; return TRUE;
*/ } // end of wxStaticLine::Create
return FALSE;
}
#endif
#endif // wxUSE_STATLINE

View File

@@ -80,10 +80,26 @@ bool wxStaticText::Create(
wxCHECK_MSG(m_hWnd, FALSE, wxT("Failed to create static ctrl")); wxCHECK_MSG(m_hWnd, FALSE, wxT("Failed to create static ctrl"));
wxColour vColour;
vColour.Set(wxString("BLACK"));
LONG lColor = (LONG)vColour.GetPixel();
::WinSetPresParam( m_hWnd
,PP_FOREGROUNDCOLOR
,sizeof(LONG)
,(PVOID)&lColor
);
SubclassWin(m_hWnd); SubclassWin(m_hWnd);
wxControl::SetFont(pParent->GetFont()); wxControl::SetFont(pParent->GetFont());
SetSize(nX, nY, nWidth, nHeight); SetSize( nX
return FALSE; ,nY
,nWidth
,nHeight
);
return TRUE;
} // end of wxStaticText::Create } // end of wxStaticText::Create
wxSize wxStaticText::DoGetBestSize() const wxSize wxStaticText::DoGetBestSize() const
@@ -143,23 +159,6 @@ wxSize wxStaticText::DoGetBestSize() const
); );
} // end of wxStaticText::DoGetBestSize } // end of wxStaticText::DoGetBestSize
void wxStaticText::SetLabel(
const wxString& rsLabel
)
{
::WinSetWindowText(GetHwnd(), rsLabel.c_str());
//
// Adjust the size of the window to fit to the label unless autoresizing is
// disabled
//
if (!(GetWindowStyle() & wxST_NO_AUTORESIZE))
{
DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT);
}
DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT);
} // end of wxStaticText::SetLabel
bool wxStaticText::SetFont( bool wxStaticText::SetFont(
const wxFont& rFont const wxFont& rFont
) )
@@ -177,6 +176,23 @@ bool wxStaticText::SetFont(
return bRet; return bRet;
} // end of wxStaticText::SetFont } // end of wxStaticText::SetFont
void wxStaticText::SetLabel(
const wxString& rsLabel
)
{
::WinSetWindowText(GetHwnd(), rsLabel.c_str());
//
// Adjust the size of the window to fit to the label unless autoresizing is
// disabled
//
if (!(GetWindowStyle() & wxST_NO_AUTORESIZE))
{
DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT);
}
DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT);
} // end of wxStaticText::SetLabel
MRESULT wxStaticText::OS2WindowProc( MRESULT wxStaticText::OS2WindowProc(
WXUINT uMsg WXUINT uMsg
, WXWPARAM wParam , WXWPARAM wParam

View File

@@ -1207,3 +1207,78 @@ void wxDrawBorder(
} }
} // end of wxDrawBorder } // end of wxDrawBorder
void wxOS2SetFont(
HWND hWnd
, const wxFont& rFont
)
{
char zFont[128];
char zFacename[30];
char zWeight[30];
char zStyle[30];
if (hWnd == NULLHANDLE)
//
// The fonts available for Presentation Params are just three
// outline fonts, the rest are available to the GPI, so we must
// map the families to one of these three
//
switch(rFont.GetFamily())
{
case wxSCRIPT:
case wxDECORATIVE:
case wxROMAN:
strcpy(zFacename,"Times New Roman");
break;
case wxTELETYPE:
case wxMODERN:
strcpy(zFacename, "Courier");
break;
case wxSWISS:
case wxDEFAULT:
default:
strcpy(zFacename, "Helvetica");
break;
}
switch(rFont.GetWeight())
{
default:
case wxNORMAL:
case wxLIGHT:
zWeight[0] = '\0';
break;
case wxBOLD:
case wxFONTWEIGHT_MAX:
strcpy(zWeight, "Bold");
break;
}
switch(rFont.GetStyle())
{
case wxITALIC:
case wxSLANT:
strcpy(zStyle, "Italic");
break;
default:
zStyle[0] = '\0';
break;
}
sprintf(zFont, "%d.%s", rFont.GetPointSize(), zFacename);
if (zWeight[0] != '\0')
{
strcat(zFont, " ");
strcat(zFont, zWeight);
}
if (zStyle[0] != '\0')
{
strcat(zFont, " ");
strcat(zFont, zStyle);
}
::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont) + 1, (PVOID)zFont);
} // end of wxOS2SetFont

View File

@@ -2543,6 +2543,48 @@ MRESULT wxWindowOS2::OS2WindowProc(
} }
break; break;
case WM_CONTROL:
switch(SHORT2FROMMP(wParam))
{
case SPBN_UPARROW:
case SPBN_DOWNARROW:
case SPBN_CHANGE:
{
char zVal[10];
long lVal;
::WinSendMsg( HWNDFROMMP(lParam)
,SPBM_QUERYVALUE
,&zVal
,MPFROM2SHORT( (USHORT)10
,(USHORT)SPBQ_UPDATEIFVALID
)
);
lVal = atol(zVal);
bProcessed = OS2OnScroll( wxVERTICAL
,(int)SHORT2FROMMP(wParam)
,(int)lVal
,HWNDFROMMP(lParam)
);
}
break;
case SLN_SLIDERTRACK:
{
HWND hWnd = ::WinWindowFromID(GetHWND(), SHORT1FROMMP(wParam));
wxWindowOS2* pChild = wxFindWinFromHandle(hWnd);
if (pChild->IsKindOf(CLASSINFO(wxSlider)))
bProcessed = OS2OnScroll( wxVERTICAL
,(int)SHORT2FROMMP(wParam)
,(int)LONGFROMMP(lParam)
,hWnd
);
}
break;
}
break;
#if defined(__VISAGECPP__) && (__IBMCPP__ >= 400) #if defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
case WM_CTLCOLORCHANGE: case WM_CTLCOLORCHANGE:
{ {