projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove obsolete CodeWarrior-related batch files.
[wxWidgets.git]
/
src
/
osx
/
radiobox_osx.cpp
diff --git
a/src/osx/radiobox_osx.cpp
b/src/osx/radiobox_osx.cpp
index f6dc751f7585721203cb0da7d1aff2d048597d3e..d728bd821ea55ad44a6c8826e75741bc25d214ad 100644
(file)
--- a/
src/osx/radiobox_osx.cpp
+++ b/
src/osx/radiobox_osx.cpp
@@
-1,10
+1,9
@@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-// Name: src/osx/radiobox.cpp
+// Name: src/osx/radiobox
_osx
.cpp
// Purpose: wxRadioBox
// Author: Stefan Csomor
// Modified by: JS Lair (99/11/15) first implementation
// Created: 1998-01-01
// Purpose: wxRadioBox
// Author: Stefan Csomor
// Modified by: JS Lair (99/11/15) first implementation
// Created: 1998-01-01
-// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@
-22,6
+21,10
@@
#include "wx/osx/private.h"
#include "wx/osx/private.h"
+// regarding layout: note that there are differences in inter-control
+// spacing between InterfaceBuild and the Human Interface Guidelines, we stick
+// to the latter, as those are also used eg in the System Preferences Dialogs
+
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
@@
-34,7
+37,7
@@
void wxRadioBox::OnRadioButton( wxCommandEvent &outer )
{
if ( outer.IsChecked() )
{
{
if ( outer.IsChecked() )
{
- wxCommandEvent event( wxEVT_
COMMAND_RADIOBOX_SELECTED
, m_windowId );
+ wxCommandEvent event( wxEVT_
RADIOBOX
, m_windowId );
int i = GetSelection() ;
event.SetInt(i);
event.SetString(GetString(i));
int i = GetSelection() ;
event.SetInt(i);
event.SetString(GetString(i));
@@
-52,7
+55,7
@@
wxRadioBox::wxRadioBox()
wxRadioBox::~wxRadioBox()
{
wxRadioBox::~wxRadioBox()
{
-
m_isBeingDeleted = true
;
+
SendDestroyEvent()
;
wxRadioButton *next, *current;
wxRadioButton *next, *current;
@@
-93,15
+96,14
@@
bool wxRadioBox::Create( wxWindow *parent,
int n, const wxString choices[],
int majorDim, long style,
const wxValidator& val, const wxString& name )
int n, const wxString choices[],
int majorDim, long style,
const wxValidator& val, const wxString& name )
-{
-
m_macIsUserPane = false
;
-
+{
+
DontCreatePeer()
;
+
if ( !wxControl::Create( parent, id, pos, size, style, val, name ) )
return false;
if ( !wxControl::Create( parent, id, pos, size, style, val, name ) )
return false;
- int i;
-
- m_noItems = (unsigned int)n;
+ // during construction we must keep this at 0, otherwise GetBestSize fails
+ m_noItems = 0;
m_noRowsOrCols = majorDim;
m_radioButtonCycle = NULL;
m_noRowsOrCols = majorDim;
m_radioButtonCycle = NULL;
@@
-109,9
+111,9
@@
bool wxRadioBox::Create( wxWindow *parent,
m_labelOrig = m_label = label;
m_labelOrig = m_label = label;
-
m_peer = wxWidgetImpl::CreateGroupBox( this, parent, id, label, pos, size, style, GetExtraStyle()
);
+
SetPeer(wxWidgetImpl::CreateGroupBox( this, parent, id, label, pos, size, style, GetExtraStyle() )
);
- for (i = 0; i < n; i++)
+ for (i
nt i
= 0; i < n; i++)
{
wxRadioButton *radBtn = new wxRadioButton(
this,
{
wxRadioButton *radBtn = new wxRadioButton(
this,
@@
-126,7
+128,13
@@
bool wxRadioBox::Create( wxWindow *parent,
// m_radioButtonCycle = radBtn->AddInCycle( m_radioButtonCycle );
}
// m_radioButtonCycle = radBtn->AddInCycle( m_radioButtonCycle );
}
+ // as all radiobuttons have been set-up, set the correct dimensions
+ m_noItems = (unsigned int)n;
+ SetMajorDim( majorDim == 0 ? n : majorDim, style );
+
SetSelection( 0 );
SetSelection( 0 );
+ InvalidateBestSize();
+ SetInitialSize( size );
MacPostControlCreate( pos, size );
return true;
MacPostControlCreate( pos, size );
return true;
@@
-256,7
+264,7
@@
void wxRadioBox::SetString(unsigned int item,const wxString& label)
}
// Sets a button by passing the desired position. This does not cause
}
// Sets a button by passing the desired position. This does not cause
-// wxEVT_
COMMAND_RADIOBOX_SELECTED
event to get emitted
+// wxEVT_
RADIOBOX
event to get emitted
//
void wxRadioBox::SetSelection(int item)
{
//
void wxRadioBox::SetSelection(int item)
{
@@
-355,7
+363,12
@@
void wxRadioBox::SetFocus()
// Simulates the effect of the user issuing a command to the item
//
// Simulates the effect of the user issuing a command to the item
//
-#define RADIO_SIZE 20
+#if wxOSX_USE_CARBON
+ #define RADIO_SIZE 20
+#else
+ // Cocoa has an additional border are of about 3 pixels
+ #define RADIO_SIZE 23
+#endif
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
@@
-395,11
+408,15
@@
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
maxWidth = -1;
maxHeight = -1;
maxWidth = -1;
maxHeight = -1;
+ wxSize bestSizeRadio ;
+ if ( m_radioButtonCycle )
+ bestSizeRadio = m_radioButtonCycle->GetBestSize();
+
for (unsigned int i = 0 ; i < m_noItems; i++)
{
GetTextExtent(GetString(i), &eachWidth[i], &eachHeight[i] );
for (unsigned int i = 0 ; i < m_noItems; i++)
{
GetTextExtent(GetString(i), &eachWidth[i], &eachHeight[i] );
- eachWidth[i] =
(int)(eachWidth[i] + RADIO_SIZE)
;
- eachHeight[i] =
(int) eachHeight[i]
;
+ eachWidth[i] =
eachWidth[i] + RADIO_SIZE
;
+ eachHeight[i] =
wxMax( eachHeight[i], bestSizeRadio.y )
;
if (maxWidth < eachWidth[i])
maxWidth = eachWidth[i];
if (maxWidth < eachWidth[i])
maxWidth = eachWidth[i];
@@
-407,11
+424,16
@@
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
maxHeight = eachHeight[i];
}
maxHeight = eachHeight[i];
}
- totHeight = GetRowCount() * maxHeight + (GetRowCount() - 1) * maxHeight / 2;
+ // according to HIG (official space - 3 Pixels Diff between Frame and Layout size)
+ int space = 3;
+ if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI )
+ space = 2;
+
+ totHeight = GetRowCount() * maxHeight + (GetRowCount() - 1) * space;
totWidth = GetColumnCount() * (maxWidth + charWidth);
wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) ) ;
totWidth = GetColumnCount() * (maxWidth + charWidth);
wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) ) ;
-
+
// change the width / height only when specified
if ( width == wxDefaultCoord )
{
// change the width / height only when specified
if ( width == wxDefaultCoord )
{
@@
-454,15
+476,15
@@
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
else
{
x_offset = x_start;
else
{
x_offset = x_start;
- y_offset +=
3 * maxHeight / 2 ; //+ charHeight / 2
+ y_offset +=
maxHeight + space;
}
}
}
}
- current->SetSize( x_offset, y_offset, eachWidth[i], eachHeight[i]);
+ current->SetSize( x_offset, y_offset, eachWidth[i], eachHeight[i]
);
current = current->NextInCycle();
if (m_windowStyle & wxRA_SPECIFY_ROWS)
current = current->NextInCycle();
if (m_windowStyle & wxRA_SPECIFY_ROWS)
- y_offset +=
3 * maxHeight / 2 ; // + charHeight / 2
+ y_offset +=
maxHeight + space;
else
x_offset += maxWidth + charWidth;
}
else
x_offset += maxWidth + charWidth;
}
@@
-485,24
+507,33
@@
wxSize wxRadioBox::DoGetBestSize() const
maxWidth = -1;
maxHeight = -1;
maxWidth = -1;
maxHeight = -1;
+ wxSize bestSizeRadio ;
+ if ( m_radioButtonCycle )
+ bestSizeRadio = m_radioButtonCycle->GetBestSize();
+
for (unsigned int i = 0 ; i < m_noItems; i++)
{
GetTextExtent(GetString(i), &eachWidth, &eachHeight, NULL, NULL, &font );
for (unsigned int i = 0 ; i < m_noItems; i++)
{
GetTextExtent(GetString(i), &eachWidth, &eachHeight, NULL, NULL, &font );
- eachWidth = (
int)(
eachWidth + RADIO_SIZE);
- eachHeight =
(int)eachHeight
;
+ eachWidth = (eachWidth + RADIO_SIZE);
+ eachHeight =
wxMax(eachHeight, bestSizeRadio.y )
;
if (maxWidth < eachWidth)
maxWidth = eachWidth;
if (maxHeight < eachHeight)
maxHeight = eachHeight;
}
if (maxWidth < eachWidth)
maxWidth = eachWidth;
if (maxHeight < eachHeight)
maxHeight = eachHeight;
}
- totHeight = GetRowCount() * maxHeight + (GetRowCount() - 1) * maxHeight / 2;
+ // according to HIG (official space - 3 Pixels Diff between Frame and Layout size)
+ int space = 3;
+ if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI )
+ space = 2;
+
+ totHeight = GetRowCount() * maxHeight + (GetRowCount() - 1) * space;
totWidth = GetColumnCount() * (maxWidth + charWidth);
wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) );
totWidth = sz.x;
totHeight = sz.y;
totWidth = GetColumnCount() * (maxWidth + charWidth);
wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) );
totWidth = sz.x;
totHeight = sz.y;
-
+
// optimum size is an additional 5 pt border to all sides
totWidth += 10;
totHeight += 10;
// optimum size is an additional 5 pt border to all sides
totWidth += 10;
totHeight += 10;
@@
-522,6
+553,8
@@
bool wxRadioBox::SetFont(const wxFont& font)
// dont' update the native control, it has its own small font
// dont' update the native control, it has its own small font
+ // should we iterate over the children ?
+
return retval;
}
return retval;
}