//#define wxPG_TEXT_INDENT 4 // For the wxComboControl
-#define wxPG_ALLOW_CLIPPING 1 // If 1, GetUpdateRegion() in OnPaint event handler is not ignored
+//#define wxPG_ALLOW_CLIPPING 1 // If 1, GetUpdateRegion() in OnPaint event handler is not ignored
#define wxPG_GUTTER_DIV 3 // gutter is max(iconwidth/gutter_div,gutter_min)
#define wxPG_GUTTER_MIN 3 // gutter before and after image of [+] or [-]
#define wxPG_YSPACING_MIN 1
#define wxPG_DEFAULT_VSPACING 2 // This matches .NET propertygrid's value,
// but causes normal combobox to spill out under MSW
-#define wxPG_OPTIMAL_WIDTH 200 // Arbitrary
+//#define wxPG_OPTIMAL_WIDTH 200 // Arbitrary
-#define wxPG_MIN_SCROLLBAR_WIDTH 10 // Smallest scrollbar width on any platform
+//#define wxPG_MIN_SCROLLBAR_WIDTH 10 // Smallest scrollbar width on any platform
// Must be larger than largest control border
// width * 2.
//#define wxPG_NAT_CHOICE_BORDER_ANY 0
-#define wxPG_HIDER_BUTTON_HEIGHT 25
+//#define wxPG_HIDER_BUTTON_HEIGHT 25
#define wxPG_PIXELS_PER_UNIT m_lineHeight
#define m_iconHeight m_iconWidth
#endif
-#define wxPG_TOOLTIP_DELAY 1000
+//#define wxPG_TOOLTIP_DELAY 1000
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
-const wxChar *wxPropertyGridNameStr = wxT("wxPropertyGrid");
+const char wxPropertyGridNameStr[] = "wxPropertyGrid";
// -----------------------------------------------------------------------
// Statics in one class for easy destruction.
}
void OnPaint( wxPaintEvent& event );
-
+
// Always be focussable, even with child windows
virtual void SetCanFocus(bool WXUNUSED(canFocus))
{ wxPanel::SetCanFocus(true); }
-
+
private:
DECLARE_EVENT_TABLE()
const wxPoint& pos,
const wxSize& size,
long style,
- const wxChar* name )
+ const wxString& name )
: wxScrolledWindow()
{
Init1();
const wxPoint& pos,
const wxSize& size,
long style,
- const wxChar* name )
+ const wxString& name )
{
if ( !(style&wxBORDER_MASK) )
#ifdef __WXMAC__
// Smaller controls on Mac
SetWindowVariant(wxWINDOW_VARIANT_SMALL);
-#endif
+#endif
// Now create state, if one didn't exist already
// (wxPropertyGridManager might have created it for us).
void wxPropertyGrid::RegainColours()
{
- wxColour def_bgcol = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
-
if ( !(m_coloursCustomized & 0x0002) )
{
wxColour col = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
bool wxPropertyGrid::SetFont( const wxFont& font )
{
// Must disable active editor.
- if ( m_selected )
- {
- bool selRes = ClearSelection();
- wxPG_CHECK_MSG_DBG( selRes,
- false,
- wxT("failed to deselect a property (editor probably had invalid value)") );
- }
+ ClearSelection(false);
// TODO: Following code is disabled with wxMac because
// it is reported to fail. I (JMS) cannot debug it
Refresh();
}
-// -----------------------------------------------------------------------
-
-void wxPropertyGrid::SetPropertyBackgroundColour( wxPGPropArg id,
- const wxColour& colour,
- bool recursively )
-{
- wxPG_PROP_ARG_CALL_PROLOG()
- p->SetBackgroundColour( colour, recursively );
- DrawItemAndChildren( p );
-}
-
-// -----------------------------------------------------------------------
-
-wxColour wxPropertyGrid::GetPropertyBackgroundColour( wxPGPropArg id ) const
-{
- wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour())
-
- return p->GetCell(0).GetBgCol();
-}
-
-// -----------------------------------------------------------------------
-
-void wxPropertyGrid::SetPropertyTextColour( wxPGPropArg id, const wxColour& colour,
- bool recursively )
-{
- wxPG_PROP_ARG_CALL_PROLOG()
- p->SetTextColour( colour, recursively );
- DrawItemAndChildren( p );
-}
-
-// -----------------------------------------------------------------------
-
-wxColour wxPropertyGrid::GetPropertyTextColour( wxPGPropArg id ) const
-{
- wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour())
-
- return p->GetCell(0).GetFgCol();
-}
-
-// -----------------------------------------------------------------------
-
-void wxPropertyGrid::SetPropertyColoursToDefault( wxPGPropArg id )
-{
- wxPG_PROP_ARG_CALL_PROLOG()
-
- p->m_cells.clear();
-}
-
// -----------------------------------------------------------------------
// wxPropertyGrid property adding and removal
// -----------------------------------------------------------------------
dst_str.clear();
- for ( ; i != src_str.end(); i++ )
+ for ( ; i != src_str.end(); ++i )
{
wxUniChar a = *i;
dst_str.clear();
- for ( ; i != src_str.end(); i++ )
+ for ( ; i != src_str.end(); ++i )
{
wxChar a = *i;
//
// clipRect conversion
- if ( clipRect )
- {
- cr2 = *clipRect;
- cr2.x -= xRelMod;
- cr2.y -= yRelMod;
- clipRect = &cr2;
- }
+ cr2 = *clipRect;
+ cr2.x -= xRelMod;
+ cr2.y -= yRelMod;
+ clipRect = &cr2;
firstItemTopY -= yRelMod;
lastItemBottomY -= yRelMod;
}
const wxFont& normalfont = m_font;
- bool reallyFocused = (m_iFlags & wxPG_FL_FOCUSED) ? true : false;
+ bool reallyFocused = (m_iFlags & wxPG_FL_FOCUSED) != 0;
bool isEnabled = IsEnabled();
}
else
{
- renderFlags |= wxPGCellRenderer::Selected;
+ renderFlags |= wxPGCellRenderer::Selected;
- if ( !p->IsCategory() )
- {
+ if ( !p->IsCategory() )
+ {
renderFlags |= wxPGCellRenderer::DontUseCellFgCol |
wxPGCellRenderer::DontUseCellBgCol;
cellX += state->m_colWidths[ci];
if ( ci < (state->m_colWidths.size()-1) )
nextCellWidth = state->m_colWidths[ci+1];
- cellRect.x = cellX;
+ cellRect.x = cellX;
dc.DestroyClippingRegion(); // Is this really necessary?
textXAdd = 0;
}
void wxPropertyGrid::Clear()
{
- if ( m_selected )
- {
- bool selRes = DoSelectProperty(NULL, wxPG_SEL_DELETING); // This must be before state clear
- wxPG_CHECK_RET_DBG( selRes,
- wxT("failed to deselect a property (editor probably had invalid value)") );
- }
+ ClearSelection(false);
m_pState->DoClear();
bool wxPropertyGrid::EnableCategories( bool enable )
{
- if ( !ClearSelection() )
- return false;
+ ClearSelection(false);
if ( enable )
{
wxPGProperty* oldSelection = m_selected;
- // Deselect
- if ( m_selected )
- {
- bool selRes = ClearSelection();
- wxPG_CHECK_RET_DBG( selRes,
- wxT("failed to deselect a property (editor probably had invalid value)") );
- }
+ ClearSelection(false);
m_pState->m_selected = oldSelection;
void wxPropertyGrid::Sort()
{
- bool selRes = ClearSelection(); // This must be before state clear
- wxPG_CHECK_RET_DBG( selRes,
- wxT("failed to deselect a property (editor probably had invalid value)") );
+ ClearSelection(false); // This must be before state clear
m_pState->Sort();
}
// Don't do this if already processing editor event. It might
// induce recursive dialogs and crap like that.
- if ( m_iFlags & wxPG_FL_IN_ONCUSTOMEDITOREVENT )
+ if ( m_iFlags & wxPG_FL_IN_HANDLECUSTOMEDITOREVENT )
{
if ( m_inDoPropertyChanged )
return true;
// -----------------------------------------------------------------------
-bool wxPropertyGrid::ProcessEvent(wxEvent& event)
-{
- wxWindow* wnd = (wxWindow*) event.GetEventObject();
- if ( wnd && wnd->IsKindOf(CLASSINFO(wxWindow)) )
- {
- wxWindow* parent = wnd->GetParent();
-
- if ( parent &&
- (parent == m_canvas ||
- parent->GetParent() == m_canvas) )
- {
- OnCustomEditorEvent(event);
- return true;
- }
- }
- return wxPanel::ProcessEvent(event);
-}
-
-// -----------------------------------------------------------------------
-
-void wxPropertyGrid::OnCustomEditorEvent( wxEvent &event )
+void wxPropertyGrid::HandleCustomEditorEvent( wxEvent &event )
{
wxPGProperty* selected = m_selected;
if ( !selected )
return;
- if ( m_iFlags & wxPG_FL_IN_ONCUSTOMEDITOREVENT )
+ if ( m_iFlags & wxPG_FL_IN_HANDLECUSTOMEDITOREVENT )
return;
wxVariant pendingValue(selected->GetValueRef());
m_prevTcValue = newTcValue;
}
- SetInternalFlag(wxPG_FL_IN_ONCUSTOMEDITOREVENT);
+ SetInternalFlag(wxPG_FL_IN_HANDLECUSTOMEDITOREVENT);
bool validationFailure = false;
bool buttonWasHandled = false;
else
{
// No value after all
-
+
// Regardless of editor type, unfocus editor on
// text-editing related enter press.
if ( event.GetEventType() == wxEVT_COMMAND_TEXT_ENTER )
}
}
- ClearInternalFlag(wxPG_FL_IN_ONCUSTOMEDITOREVENT);
+ ClearInternalFlag(wxPG_FL_IN_HANDLECUSTOMEDITOREVENT);
}
// -----------------------------------------------------------------------
}
// -----------------------------------------------------------------------
-// wxPropertyGrid property selection
+// wxPropertyGrid property selection, editor creation
// -----------------------------------------------------------------------
+//
+// This class forwards events from property editor controls to wxPropertyGrid.
+class wxPropertyGridEditorEventForwarder : public wxEvtHandler
+{
+public:
+ wxPropertyGridEditorEventForwarder( wxPropertyGrid* propGrid )
+ : wxEvtHandler(), m_propGrid(propGrid)
+ {
+ }
+
+ virtual ~wxPropertyGridEditorEventForwarder()
+ {
+ }
+
+private:
+ bool ProcessEvent( wxEvent& event )
+ {
+ // Always skip
+ event.Skip();
+
+ m_propGrid->HandleCustomEditorEvent(event);
+
+ return wxEvtHandler::ProcessEvent(event);
+ }
+
+ wxPropertyGrid* m_propGrid;
+};
+
// Setups event handling for child control
void wxPropertyGrid::SetupChildEventHandling( wxWindow* argWnd )
{
NULL, this);
}
+ wxPropertyGridEditorEventForwarder* forwarder;
+ forwarder = new wxPropertyGridEditorEventForwarder(this);
+ argWnd->PushEventHandler(forwarder);
+
argWnd->Connect(id, wxEVT_KEY_DOWN,
wxCharEventHandler(wxPropertyGrid::OnChildKeyDown),
NULL, this);
// Do not free editors immediately if processing events
if ( m_wndEditor2 )
{
+ m_wndEditor2->PopEventHandler(true);
m_wndEditor2->Hide();
wxPendingDelete.Append( m_wndEditor2 );
m_wndEditor2 = (wxWindow*) NULL;
if ( m_wndEditor )
{
+ m_wndEditor->PopEventHandler(true);
m_wndEditor->Hide();
wxPendingDelete.Append( m_wndEditor );
m_wndEditor = (wxWindow*) NULL;
// Call with NULL to de-select property
bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
{
- wxPanel* canvas = GetPanel();
-
/*
if (p)
wxLogDebug(wxT("SelectProperty( %s (%s[%i]) )"),p->m_label.c_str(),
wxPrintf( "Selected %s\n", m_selected->GetClassInfo()->GetClassName() );
else
wxPrintf( "None selected\n" );
-
+
if (p)
wxPrintf( "P = %s\n", p->GetClassInfo()->GetClassName() );
else
wxPrintf( "P = NULL\n" );
*/
-
+
// If we are frozen, then just set the values.
if ( m_frozen )
{
wxASSERT( m_wndEditor == (wxWindow*) NULL );
- // Do we need OnMeasureCalls?
- wxSize imsz = p->OnMeasureImage();
-
//
// Only create editor for non-disabled non-caption
if ( !p->IsCategory() && !(p->m_flags & wxPG_PROP_DISABLED) )
if ( m_wndEditor )
{
- wxASSERT_MSG( m_wndEditor->GetParent() == canvas,
+ wxASSERT_MSG( m_wndEditor->GetParent() == GetPanel(),
wxT("CreateControls must use result of wxPropertyGrid::GetPanel() as parent of controls.") );
// Set validator, if any
if ( m_wndEditor2 )
{
- wxASSERT_MSG( m_wndEditor2->GetParent() == canvas,
+ wxASSERT_MSG( m_wndEditor2->GetParent() == GetPanel(),
wxT("CreateControls must use result of wxPropertyGrid::GetPanel() as parent of controls.") );
// Get proper id for wndSecondary
// -----------------------------------------------------------------------
+void wxPropertyGrid::RefreshEditor()
+{
+ if ( !m_selected || !m_wndEditor || m_frozen )
+ return;
+ m_selected->UpdateControl(m_wndEditor);
+}
+
+// -----------------------------------------------------------------------
+
// This method is not inline because it called dozens of times
// (i.e. two-arg function calls create smaller code size).
bool wxPropertyGrid::DoClearSelection()
wxPGProperty* pwc = wxStaticCast(p, wxPGProperty);
// If active editor was inside collapsed section, then disable it
- if ( m_selected && m_selected->IsSomeParent (p) )
+ if ( m_selected && m_selected->IsSomeParent(p) )
{
- if ( !ClearSelection() )
- return false;
+ ClearSelection(false);
}
// Store dont-center-splitter flag 'cause we need to temporarily set it
}
// Clear dont-center-splitter flag if it wasn't set
- m_iFlags = m_iFlags & ~(wxPG_FL_DONT_CENTER_SPLITTER) | old_flag;
+ m_iFlags = (m_iFlags & ~wxPG_FL_DONT_CENTER_SPLITTER) | old_flag;
return res;
}
( m_selected == p || m_selected->IsSomeParent(p) )
)
{
- if ( !ClearSelection() )
- return false;
+ ClearSelection(false);
}
m_pState->DoHideProperty(p, hide, flags);
if ( by1 != by2 )
{
wxString s = wxString::Format(wxT("VirtualHeight=%i, ActualVirtualHeight=%i, should match!"), by1, by2);
- wxASSERT_MSG( false,
- s.c_str() );
+ wxFAIL_MSG(s.c_str());
wxLogDebug(s);
}
#endif
int curPropHoverY = y - (y % ih);
// On which item it hovers
- if ( ( !m_propHover )
+ if ( !m_propHover
||
- ( m_propHover && ( sy < m_propHoverY || sy >= (m_propHoverY+ih) ) )
+ ( sy < m_propHoverY || sy >= (m_propHoverY+ih) )
)
{
// Mouse moves on another property
// (also not if we were dragging and its started
// outside the splitter region)
- if ( m_propHover &&
- !m_propHover->IsCategory() &&
+ if ( !m_propHover->IsCategory() &&
!event.Dragging() )
{
{
wxPGHashMapI2I::iterator it;
- for ( it = m_actionTriggers.begin(); it != m_actionTriggers.end(); it++ )
+ for ( it = m_actionTriggers.begin(); it != m_actionTriggers.end(); ++it )
{
if ( it->second == action )
{
// Handles key event when editor control is not focused.
//
- wxASSERT( !m_frozen );
- if ( m_frozen )
- return;
+ wxCHECK2(!m_frozen, return);
// Travelsal between items, collapsing/expanding, etc.
int keycode = event.GetKeyCode();
}
else
{
- i++;
+ ++i;
m_curPos = i;
return true;
}
prev_a = wxT('\0');
}
}
- i++;
+ ++i;
}
m_curPos = str.end();
// -----------------------------------------------------------------------
-wxArrayInt wxPGChoices::GetIndicesForStrings( const wxArrayString& strings,
+wxArrayInt wxPGChoices::GetIndicesForStrings( const wxArrayString& strings,
wxArrayString* unmatched ) const
{
wxArrayInt arr;
int state = 0;
bool labelValid = false;
- for ( ; it != choicesString.end(); it++ )
+ for ( ; it != choicesString.end(); ++it )
{
wxChar c = *it;