Use stock labels. Native wxRadioButton. Getting position and size for the controls. Getting size for wxTLW. Default size and position for wxButton according to l&f guidelines. Removed wxUSE_CTL3D from wxPalmOS port. Better font for controls.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31616 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2005-01-28 10:58:13 +00:00
parent 613a24f7d2
commit 808e3bce62
15 changed files with 121 additions and 64 deletions

View File

@@ -151,6 +151,7 @@ SOURCES = ../../samples/minimal/minimal.cpp \
../../src/common/sizer.cpp \ ../../src/common/sizer.cpp \
../../src/common/socket.cpp \ ../../src/common/socket.cpp \
../../src/common/statbar.cpp \ ../../src/common/statbar.cpp \
../../src/common/stockitem.cpp \
../../src/common/strconv.cpp \ ../../src/common/strconv.cpp \
../../src/common/stream.cpp \ ../../src/common/stream.cpp \
../../src/common/string.cpp \ ../../src/common/string.cpp \

View File

@@ -118,6 +118,7 @@ wxPalmOS:
- native wxCheckBox implementation - native wxCheckBox implementation
- native wxSlider implementation - native wxSlider implementation
- native wxToggleButton implementation - native wxToggleButton implementation
- native wxRadioButton implementation
2.5.3 2.5.3

View File

@@ -89,6 +89,10 @@ protected:
// return default best size (doesn't really make any sense, override this) // return default best size (doesn't really make any sense, override this)
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
// getting and setting sizes
virtual void DoGetPosition( int *x, int *y ) const;
virtual void DoGetSize( int *width, int *height ) const;
// create the control of the given ControlStyleType: this is typically called // create the control of the given ControlStyleType: this is typically called
// from Create() method of the derived class passing its label, pos and // from Create() method of the derived class passing its label, pos and
// size parameter (style parameter is not needed because m_windowStyle is // size parameter (style parameter is not needed because m_windowStyle is
@@ -117,7 +121,9 @@ protected:
private: private:
// Label stores label in case of wxButton, wxCheckBox, wxToggleButton etc. virtual void DoGetBounds( RectangleType &rect ) const;
// m_label stores label in case of wxButton, wxCheckBox, wxToggleButton etc.
// We must ensure that it persists for as long as it is being displayed // We must ensure that it persists for as long as it is being displayed
// (that is, for as long as the control is displayed or until we call // (that is, for as long as the control is displayed or until we call
// CtlSetLabel() with a new string), and we must free the string after // CtlSetLabel() with a new string), and we must free the string after

View File

@@ -2,10 +2,10 @@
// Name: wx/palmos/radiobut.h // Name: wx/palmos/radiobut.h
// Purpose: wxRadioButton class // Purpose: wxRadioButton class
// Author: William Osborne - minimal working wxPalmOS port // Author: William Osborne - minimal working wxPalmOS port
// Modified by: // Modified by: Wlodzimierz ABX Skiba - native wxRadioButton implementation
// Created: 10/13/04 // Created: 10/13/04
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) William Osborne // Copyright: (c) William Osborne, Wlodzimierz Skiba
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -50,7 +50,6 @@ public:
virtual bool GetValue() const; virtual bool GetValue() const;
// implementation only from now on // implementation only from now on
virtual bool MSWCommand(WXUINT param, WXWORD id);
virtual void Command(wxCommandEvent& event); virtual void Command(wxCommandEvent& event);
virtual void ApplyParentThemeBackground(const wxColour& bg) virtual void ApplyParentThemeBackground(const wxColour& bg)
{ SetBackgroundColour(bg); } { SetBackgroundColour(bg); }
@@ -63,10 +62,6 @@ private:
// common part of all ctors // common part of all ctors
void Init(); void Init();
// we need to store the state internally as the result of GetValue()
// sometimes gets out of sync in WM_COMMAND handler
bool m_isChecked;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxRadioButton) DECLARE_DYNAMIC_CLASS_NO_COPY(wxRadioButton)
}; };

View File

@@ -521,7 +521,7 @@
#define wxUSE_LISTBOX 0 // wxListBox #define wxUSE_LISTBOX 0 // wxListBox
#define wxUSE_LISTCTRL 0 // wxListCtrl #define wxUSE_LISTCTRL 0 // wxListCtrl
#define wxUSE_RADIOBOX 0 // wxRadioBox #define wxUSE_RADIOBOX 0 // wxRadioBox
#define wxUSE_RADIOBTN 0 // wxRadioButton #define wxUSE_RADIOBTN 1 // wxRadioButton
#define wxUSE_SCROLLBAR 0 // wxScrollBar #define wxUSE_SCROLLBAR 0 // wxScrollBar
#define wxUSE_SLIDER 1 // wxSlider #define wxUSE_SLIDER 1 // wxSlider
#define wxUSE_SPINBTN 0 // wxSpinButton #define wxUSE_SPINBTN 0 // wxSpinButton

View File

@@ -82,12 +82,15 @@ public:
wxWindow *GetLastFocus() const { return m_winLastFocused; } wxWindow *GetLastFocus() const { return m_winLastFocused; }
// interface to native frame structure // interface to native frame structure
FormType *GetForm(); FormType *GetForm() const;
protected: protected:
// common part of all ctors // common part of all ctors
void Init(); void Init();
// getting and setting sizes
virtual void DoGetSize( int *width, int *height ) const;
// common part of Iconize(), Maximize() and Restore() // common part of Iconize(), Maximize() and Restore()
void DoShowWindow(int nShowCmd); void DoShowWindow(int nShowCmd);

View File

@@ -47,6 +47,8 @@ extern WXDLLEXPORT_DATA(const wxChar*) wxRadioButtonNameStr;
#include "wx/cocoa/radiobut.h" #include "wx/cocoa/radiobut.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
#include "wx/os2/radiobut.h" #include "wx/os2/radiobut.h"
#elif defined(__WXPALMOS__)
#include "wx/palmos/radiobut.h"
#endif #endif
#endif // wxUSE_RADIOBTN #endif // wxUSE_RADIOBTN

View File

@@ -30,7 +30,7 @@
#include "wx/stockitem.h" #include "wx/stockitem.h"
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/utils.h" // for wxStripMenuCodes()
bool wxIsStockID(wxWindowID id) bool wxIsStockID(wxWindowID id)
{ {
@@ -95,7 +95,7 @@ bool wxIsStockID(wxWindowID id)
wxString wxGetStockLabel(wxWindowID id) wxString wxGetStockLabel(wxWindowID id)
{ {
#ifdef __SMARTPHONE__ #if defined(__SMARTPHONE__) || defined(__WXPALMOS__)
#define STOCKITEM(stockid, label) \ #define STOCKITEM(stockid, label) \
case stockid: \ case stockid: \
return wxStripMenuCodes(label); return wxStripMenuCodes(label);

View File

@@ -38,6 +38,9 @@
#include "wx/bmpbuttn.h" #include "wx/bmpbuttn.h"
#include "wx/settings.h" #include "wx/settings.h"
#include "wx/dcscreen.h" #include "wx/dcscreen.h"
#include "wx/frame.h"
#include "wx/dialog.h"
#include "wx/stockitem.h"
#endif #endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -126,7 +129,48 @@ bool wxButton::Create(wxWindow *parent,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
wxControl::PalmCreateControl(buttonCtl, parent, id, label, pos, size); // Default coordinates based on the knowledgebase recipe "Buttons"
wxSize palmSize(size.x==wxDefaultCoord?36:size.x,
size.y==wxDefaultCoord?12:size.y);
// Default placement depends on dialog vs. frame type of parent
wxPoint palmPos(pos);
if((palmPos.x==wxDefaultCoord)||(palmPos.y==wxDefaultCoord))
{
wxSize parentSize(parent->GetSize());
wxWindow* parentTLW = parent;
while ( parentTLW && !parentTLW->IsTopLevel() )
{
parentTLW = parentTLW->GetParent();
}
if(wxDynamicCast(parentTLW, wxFrame)!=NULL)
{
if(palmPos.x==wxDefaultCoord)
palmPos.x = 1;
if(palmPos.y==wxDefaultCoord)
palmPos.y = parentSize.y-palmSize.y;
}
else if(wxDynamicCast(parentTLW, wxDialog)!=NULL)
{
if(palmPos.x==wxDefaultCoord)
palmPos.x = 5;
if(palmPos.y==wxDefaultCoord)
palmPos.y = parentSize.y-palmSize.y-5;
}
else
{
// something seriously broken
return false;
}
}
// take the stock label
wxString palmLabel = label;
if( palmLabel.empty() && wxIsStockID(id) )
palmLabel = wxGetStockLabel(id);
wxControl::PalmCreateControl(buttonCtl, parent, id, palmLabel, palmPos, palmSize);
return true; return true;
} }
@@ -140,13 +184,13 @@ wxButton::~wxButton()
wxSize wxButton::DoGetBestSize() const wxSize wxButton::DoGetBestSize() const
{ {
return wxSize(0,0); return wxSize(36,12);
} }
/* static */ /* static */
wxSize wxButtonBase::GetDefaultSize() wxSize wxButtonBase::GetDefaultSize()
{ {
return wxSize(0,0); return wxSize(36,12);
} }
void wxButton::SetDefault() void wxButton::SetDefault()
@@ -180,7 +224,7 @@ bool wxButton::SendClickEvent()
return false; return false;
} }
void wxButton::Command(wxCommandEvent & event) void wxButton::Command(wxCommandEvent &event)
{ {
} }

View File

@@ -43,6 +43,7 @@
#include "wx/button.h" #include "wx/button.h"
#include "wx/checkbox.h" #include "wx/checkbox.h"
#include "wx/tglbtn.h" #include "wx/tglbtn.h"
#include "wx/radiobut.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxWin macros // wxWin macros
@@ -113,7 +114,7 @@ bool wxControl::PalmCreateControl(ControlStyleType style,
( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y, ( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y,
( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x, ( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x,
( size.y == wxDefaultCoord ) ? winUndefConstraint : size.y, ( size.y == wxDefaultCoord ) ? winUndefConstraint : size.y,
boldFont, stdFont,
0, 0,
false false
); );
@@ -182,6 +183,37 @@ wxSize wxControl::DoGetBestSize() const
return wxSize(16, 16); return wxSize(16, 16);
} }
void wxControl::DoGetBounds( RectangleType &rect ) const
{
FormType* form = GetParentForm();
if(form==NULL)
return;
uint16_t index = FrmGetObjectIndex(form,GetId());
if(index==frmInvalidObjectId)
return;
FrmGetObjectBounds(form,index,&rect);
}
void wxControl::DoGetPosition( int *x, int *y ) const
{
RectangleType rect;
DoGetBounds(rect);
if(x)
*x = rect.topLeft.x;
if(y)
*y = rect.topLeft.y;
}
void wxControl::DoGetSize( int *width, int *height ) const
{
RectangleType rect;
DoGetBounds(rect);
if(width)
*width = rect.extent.x;
if(height)
*height = rect.extent.y;
}
bool wxControl::Enable(bool enable) bool wxControl::Enable(bool enable)
{ {
if( m_control == NULL ) if( m_control == NULL )
@@ -224,6 +256,7 @@ void wxControl::SetLabel(const wxString& label)
// setting in wrong control causes crash // setting in wrong control causes crash
if ( ( wxDynamicCast(this,wxButton) != NULL ) || if ( ( wxDynamicCast(this,wxButton) != NULL ) ||
( wxDynamicCast(this,wxCheckBox) != NULL ) || ( wxDynamicCast(this,wxCheckBox) != NULL ) ||
( wxDynamicCast(this,wxRadioButton) != NULL ) ||
( wxDynamicCast(this,wxToggleButton) != NULL ) ) ( wxDynamicCast(this,wxToggleButton) != NULL ) )
{ {
m_label = label; m_label = label;
@@ -238,6 +271,7 @@ wxString wxControl::GetLabel()
// setting in wrong control causes crash // setting in wrong control causes crash
if ( wxDynamicCast(this,wxButton) || if ( wxDynamicCast(this,wxButton) ||
wxDynamicCast(this,wxCheckBox) || wxDynamicCast(this,wxCheckBox) ||
wxDynamicCast(this,wxRadioButton) ||
wxDynamicCast(this,wxToggleButton) ) wxDynamicCast(this,wxToggleButton) )
{ {
return m_label; return m_label;
@@ -290,15 +324,9 @@ void wxControl::OnEraseBackground(wxEraseEvent& event)
} }
WXHBRUSH wxControl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor), WXHBRUSH wxControl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor),
#if wxUSE_CTL3D
WXUINT message,
WXWPARAM wParam,
WXLPARAM lParam
#else
WXUINT WXUNUSED(message), WXUINT WXUNUSED(message),
WXWPARAM WXUNUSED(wParam), WXWPARAM WXUNUSED(wParam),
WXLPARAM WXUNUSED(lParam) WXLPARAM WXUNUSED(lParam)
#endif
) )
{ {
return (WXHBRUSH)0; return (WXHBRUSH)0;

View File

@@ -247,19 +247,3 @@ WXLRESULT wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lPar
{ {
return false; return false;
} }
#if wxUSE_CTL3D
// Define for each class of dialog and control
WXHBRUSH wxDialog::OnCtlColor(WXHDC WXUNUSED(pDC),
WXHWND WXUNUSED(pWnd),
WXUINT WXUNUSED(nCtlColor),
WXUINT message,
WXWPARAM wParam,
WXLPARAM lParam)
{
return (WXHBRUSH)Ctl3dCtlColorEx(message, wParam, lParam);
}
#endif // wxUSE_CTL3D

View File

@@ -304,15 +304,9 @@ WXLRESULT wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara
} }
WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor), WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor),
#if wxUSE_CTL3D
WXUINT message,
WXWPARAM wParam,
WXLPARAM lParam
#else
WXUINT WXUNUSED(message), WXUINT WXUNUSED(message),
WXWPARAM WXUNUSED(wParam), WXWPARAM WXUNUSED(wParam),
WXLPARAM WXUNUSED(lParam) WXLPARAM WXUNUSED(lParam)
#endif
) )
{ {
return (WXHBRUSH)0; return (WXHBRUSH)0;

View File

@@ -2,10 +2,10 @@
// Name: src/palmos/radiobut.cpp // Name: src/palmos/radiobut.cpp
// Purpose: wxRadioButton // Purpose: wxRadioButton
// Author: William Osborne - minimal working wxPalmOS port // Author: William Osborne - minimal working wxPalmOS port
// Modified by: // Modified by: Wlodzimierz ABX Skiba - native wxRadioButton implementation
// Created: 10/13/04 // Created: 10/13/04
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) William Osborne // Copyright: (c) William Osborne, Wlodzimierz Skiba
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -36,8 +36,6 @@
#include "wx/dcscreen.h" #include "wx/dcscreen.h"
#endif #endif
#include "wx/palmos/private.h"
// ============================================================================ // ============================================================================
// wxRadioButton implementation // wxRadioButton implementation
// ============================================================================ // ============================================================================
@@ -115,7 +113,8 @@ bool wxRadioButton::Create(wxWindow *parent,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
return false; wxControl::PalmCreateControl(pushButtonCtl, parent, id, label, pos, size);
return true;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -124,11 +123,12 @@ bool wxRadioButton::Create(wxWindow *parent,
void wxRadioButton::SetValue(bool value) void wxRadioButton::SetValue(bool value)
{ {
SetBoolValue(value);
} }
bool wxRadioButton::GetValue() const bool wxRadioButton::GetValue() const
{ {
return false; return GetBoolValue();
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -139,11 +139,6 @@ void wxRadioButton::Command (wxCommandEvent& event)
{ {
} }
bool wxRadioButton::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
{
return false;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRadioButton geometry // wxRadioButton geometry
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -568,15 +568,9 @@ bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
} }
WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor), WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor),
#if wxUSE_CTL3D
WXUINT message,
WXWPARAM wParam,
WXLPARAM lParam
#else
WXUINT WXUNUSED(message), WXUINT WXUNUSED(message),
WXWPARAM WXUNUSED(wParam), WXWPARAM WXUNUSED(wParam),
WXLPARAM WXUNUSED(lParam) WXLPARAM WXUNUSED(lParam)
#endif
) )
{ {
return (WXHBRUSH) 0; return (WXHBRUSH) 0;

View File

@@ -186,6 +186,16 @@ void wxTopLevelWindowPalm::Restore()
{ {
} }
void wxTopLevelWindowPalm::DoGetSize( int *width, int *height ) const
{
RectangleType rect;
FrmGetFormBounds( GetForm() , &rect );
if(width)
*width = rect.extent.x;
if(height)
*height = rect.extent.y;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxTopLevelWindowPalm fullscreen // wxTopLevelWindowPalm fullscreen
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -212,9 +222,9 @@ bool wxTopLevelWindowPalm::EnableCloseButton(bool enable)
return false; return false;
} }
FormType *wxTopLevelWindowPalm::GetForm() FormType *wxTopLevelWindowPalm::GetForm() const
{ {
return FrmGetActiveForm (); return FrmGetActiveForm();
} }
#ifndef __WXWINCE__ #ifndef __WXWINCE__