#include "wx/msw/dc.h"
#endif
+#include "wx/odcombo.h"
+
// -----------------------------------------------------------------------
#if defined(__WXMSW__)
wnd2->SetRange( INT_MIN, INT_MAX );
wnd2->SetValue( 0 );
+ wxWindow* wnd1 = wxPGTextCtrlEditor::CreateControls(propgrid, property, pos, tcSz).m_primary;
+#if wxUSE_VALIDATORS
// Let's add validator to make sure only numbers can be entered
wxTextValidator validator(wxFILTER_NUMERIC, &m_tempString);
-
- wxTextCtrl* wnd1 = (wxTextCtrl*) wxPGTextCtrlEditor::CreateControls( propgrid, property, pos, tcSz ).m_primary;
wnd1->SetValidator(validator);
+#endif
return wxPGWindowList(wnd1, wnd2);
}
#include "wx/fontdlg.h"
#include "wx/fontenum.h"
+//
+// NB: Do not use wxS here since unlike wxT it doesn't translate to wxChar*
+//
+
static const wxChar* gs_fp_es_family_labels[] = {
wxT("Default"), wxT("Decorative"),
wxT("Roman"), wxT("Script"),
wxT("Swiss"), wxT("Modern"),
+ wxT("Teletype"), wxT("Unknown"),
(const wxChar*) NULL
};
static long gs_fp_es_family_values[] = {
- wxDEFAULT, wxDECORATIVE,
- wxROMAN, wxSCRIPT,
- wxSWISS, wxMODERN
+ wxFONTFAMILY_DEFAULT, wxFONTFAMILY_DECORATIVE,
+ wxFONTFAMILY_ROMAN, wxFONTFAMILY_SCRIPT,
+ wxFONTFAMILY_SWISS, wxFONTFAMILY_MODERN,
+ wxFONTFAMILY_TELETYPE, wxFONTFAMILY_UNKNOWN
};
static const wxChar* gs_fp_es_style_labels[] = {
wxFont font;
font << m_value;
- SetParentalType(wxPG_PROP_AGGREGATE);
-
- AddChild( new wxIntProperty( _("Point Size"), wxS("Point Size"),(long)font.GetPointSize() ) );
-
- AddChild( new wxEnumProperty(_("Family"), wxS("PointSize"),
- gs_fp_es_family_labels,gs_fp_es_family_values,
- font.GetFamily()) );
+ AddPrivateChild( new wxIntProperty( _("Point Size"),
+ wxS("Point Size"),(long)font.GetPointSize() ) );
wxString faceName = font.GetFaceName();
// If font was not in there, add it now
p->SetValueFromString(faceName, wxPG_FULL_VALUE);
- AddChild( p );
+ AddPrivateChild( p );
+
+ AddPrivateChild( new wxEnumProperty(_("Style"), wxS("Style"),
+ gs_fp_es_style_labels,gs_fp_es_style_values,
+ font.GetStyle()) );
- AddChild( new wxEnumProperty(_("Style"), wxS("Style"),
- gs_fp_es_style_labels,gs_fp_es_style_values,font.GetStyle()) );
+ AddPrivateChild( new wxEnumProperty(_("Weight"), wxS("Weight"),
+ gs_fp_es_weight_labels,gs_fp_es_weight_values,
+ font.GetWeight()) );
- AddChild( new wxEnumProperty(_("Weight"), wxS("Weight"),
- gs_fp_es_weight_labels,gs_fp_es_weight_values,font.GetWeight()) );
+ AddPrivateChild( new wxBoolProperty(_("Underlined"), wxS("Underlined"),
+ font.GetUnderlined()) );
- AddChild( new wxBoolProperty(_("Underlined"), wxS("Underlined"),
- font.GetUnderlined()) );
+ AddPrivateChild( new wxEnumProperty(_("Family"), wxS("PointSize"),
+ gs_fp_es_family_labels,gs_fp_es_family_values,
+ font.GetFamily()) );
}
wxFontProperty::~wxFontProperty() { }
if ( !font.Ok() )
{
- font = wxFont(10,wxSWISS,wxNORMAL,wxNORMAL);
- m_value << font;
+ m_value << *wxNORMAL_FONT;
}
}
wxFont font;
font << m_value;
Item(0)->SetValue( (long)font.GetPointSize() );
- Item(1)->SetValue( (long)font.GetFamily() );
- Item(2)->SetValueFromString( font.GetFaceName(), wxPG_FULL_VALUE );
- Item(3)->SetValue( (long)font.GetStyle() );
- Item(4)->SetValue( (long)font.GetWeight() );
- Item(5)->SetValue( font.GetUnderlined() );
+ Item(1)->SetValueFromString( font.GetFaceName(), wxPG_FULL_VALUE );
+ Item(2)->SetValue( (long)font.GetStyle() );
+ Item(3)->SetValue( (long)font.GetWeight() );
+ Item(4)->SetValue( font.GetUnderlined() );
+ Item(5)->SetValue( (long)font.GetFamily() );
}
-void wxFontProperty::ChildChanged( wxVariant& thisValue, int ind, wxVariant& childValue ) const
+wxVariant wxFontProperty::ChildChanged( wxVariant& thisValue,
+ int ind,
+ wxVariant& childValue ) const
{
wxFont font;
font << thisValue;
if ( ind == 0 )
{
- font.SetPointSize( wxPGVariantToInt(childValue) );
+ font.SetPointSize( childValue.GetLong() );
}
else if ( ind == 1 )
- {
- int fam = childValue.GetLong();
- if ( fam < wxDEFAULT ||
- fam > wxTELETYPE )
- fam = wxDEFAULT;
- font.SetFamily( fam );
- }
- else if ( ind == 2 )
{
wxString faceName;
int faceIndex = childValue.GetLong();
font.SetFaceName( faceName );
}
- else if ( ind == 3 )
+ else if ( ind == 2 )
{
int st = childValue.GetLong();
if ( st != wxFONTSTYLE_NORMAL &&
st = wxFONTWEIGHT_NORMAL;
font.SetStyle( st );
}
- else if ( ind == 4 )
+ else if ( ind == 3 )
{
int wt = childValue.GetLong();
if ( wt != wxFONTWEIGHT_NORMAL &&
wt = wxFONTWEIGHT_NORMAL;
font.SetWeight( wt );
}
- else if ( ind == 5 )
+ else if ( ind == 4 )
{
font.SetUnderlined( childValue.GetBool() );
}
+ else if ( ind == 5 )
+ {
+ int fam = childValue.GetLong();
+ if ( fam < wxDEFAULT ||
+ fam > wxTELETYPE )
+ fam = wxDEFAULT;
+ font.SetFamily( fam );
+ }
- thisValue << font;
+ wxVariant newVariant;
+ newVariant << font;
+ return newVariant;
}
/*
int wxSystemColourProperty::ColToInd( const wxColour& colour ) const
{
size_t i;
- size_t i_max = m_choices.GetCount() - 1;
+ size_t i_max = m_choices.GetCount();
+
+ if ( !(m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
+ i_max -= 1;
for ( i=0; i<i_max; i++ )
{
return;
}
- if ( cpv.m_type < wxPG_COLOUR_WEB_BASE )
+ if ( cpv.m_type < wxPG_COLOUR_WEB_BASE ||
+ (m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
{
ind = GetIndexForValue(cpv.m_type);
}
ind = ColToInd(col);
- if ( ind == wxNOT_FOUND )
+ if ( ind == wxNOT_FOUND &&
+ !(m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
ind = GetCustomColourIndex();
}
// If custom colour was selected, use invalid index, so that
// ColourToString() will return properly formatted colour text.
- if ( index == GetCustomColourIndex() )
+ if ( index == GetCustomColourIndex() &&
+ !(m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
index = wxNOT_FOUND;
}
else
}
// Need to do some extra event handling.
-bool wxSystemColourProperty::OnEvent( wxPropertyGrid* propgrid, wxWindow* WXUNUSED(primary), wxEvent& event )
+bool wxSystemColourProperty::OnEvent( wxPropertyGrid* propgrid,
+ wxWindow* WXUNUSED(primary),
+ wxEvent& event )
{
+ bool askColour = false;
+
if ( propgrid->IsMainButtonEvent(event) )
{
// We need to handle button click in case editor has been
// switched to one that has wxButton as well.
+ askColour = true;
+ }
+ else if ( event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED )
+ {
+ // Must override index detection since at this point GetIndex()
+ // will return old value.
+ wxOwnerDrawnComboBox* cb =
+ static_cast<wxOwnerDrawnComboBox*>(propgrid->GetEditorControl());
+
+ if ( cb )
+ {
+ int index = cb->GetSelection();
+
+ if ( index == GetCustomColourIndex() &&
+ !(m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
+ askColour = true;
+ }
+ }
+
+ if ( askColour && !propgrid->WasValueChangedInEvent() )
+ {
wxVariant variant;
if ( QueryColourFromUser(variant) )
return true;
{
wxColour col;
- if ( paintdata.m_choiceItem >= 0 && paintdata.m_choiceItem < (int)m_choices.GetCount() &&
- paintdata.m_choiceItem != GetCustomColourIndex() )
+ if ( paintdata.m_choiceItem >= 0 &&
+ paintdata.m_choiceItem < (int)m_choices.GetCount() &&
+ (paintdata.m_choiceItem != GetCustomColourIndex() ||
+ m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
{
int colInd = m_choices[paintdata.m_choiceItem].GetValue();
col = GetColour( colInd );
colourRGB.clear();
if ( colourRGB.length() == 0 && m_choices.GetCount() &&
+ !(m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) &&
colourName == m_choices.GetLabel(GetCustomColourIndex()) )
{
if ( !(argFlags & wxPG_EDITABLE_VALUE ))
{
if ( name == wxPG_COLOUR_ALLOW_CUSTOM )
{
- int ival = wxPGVariantToInt(value);
+ int ival = value.GetLong();
if ( ival && (m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
{
{
wxDateTime dt;
- const char* c = dt.ParseFormat(text, wxString(wxDefaultDateTimeFormat), wxDefaultDateTime, NULL);
+ // FIXME: do we really want to return true from here if only part of the
+ // string was parsed?
+ const char* c = dt.ParseFormat(text);
if ( c )
{