delete m_resizeCursor;
}
+ virtual void UpdateDisplay() { Refresh(); }
+
// event handlers:
void OnPaint( wxPaintEvent &event );
return m_dc;
}
-bool wxDataViewRenderer::StartEditing( unsigned int row, wxRect labelRect )
-{
- GetView()->CalcScrolledPosition( labelRect.x, labelRect.y,
- &labelRect.x, &labelRect.y);
-
- m_row = row; // remember for later
-
- unsigned int col = GetOwner()->GetModelColumn();
- wxVariant value;
- GetOwner()->GetOwner()->GetModel()->GetValue( value, col, row );
-
- m_editorCtrl = CreateEditorCtrl( GetOwner()->GetOwner()->GetMainWindow(), labelRect, value );
-
- m_editorCtrl->PushEventHandler( new wxDataViewEditorCtrlEvtHandler( m_editorCtrl, this ) );
-
- m_editorCtrl->SetFocus();
-
- return true;
-}
-
-void wxDataViewRenderer::CancelEditing()
-{
- // m_editorCtrl->PopEventHandler( true );
-
- delete m_editorCtrl;
-
- GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
-}
-
-bool wxDataViewRenderer::FinishEditing()
-{
- // m_editorCtrl->PopEventHandler( true );
-
- wxVariant value;
- GetValueFromEditorCtrl( m_editorCtrl, value );
-
- delete m_editorCtrl;
-
- GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
-
- if (!Validate(value))
- return false;
-
- unsigned int col = GetOwner()->GetModelColumn();
- GetOwner()->GetOwner()->GetModel()->SetValue( value, col, m_row );
- GetOwner()->GetOwner()->GetModel()->ValueChanged( col, m_row );
-
- return true;
-}
-
-//-----------------------------------------------------------------------------
-// wxDataViewEditorCtrlEvtHandler
-//-----------------------------------------------------------------------------
-
-BEGIN_EVENT_TABLE(wxDataViewEditorCtrlEvtHandler, wxEvtHandler)
- EVT_CHAR (wxDataViewEditorCtrlEvtHandler::OnChar)
- EVT_KILL_FOCUS (wxDataViewEditorCtrlEvtHandler::OnKillFocus)
-END_EVENT_TABLE()
-
-wxDataViewEditorCtrlEvtHandler::wxDataViewEditorCtrlEvtHandler(
- wxControl *editorCtrl,
- wxDataViewRenderer *owner )
-{
- m_owner = owner;
- m_editorCtrl = editorCtrl;
-
- m_finished = false;
-}
-
-void wxDataViewEditorCtrlEvtHandler::OnChar( wxKeyEvent &event )
-{
- switch ( event.m_keyCode )
- {
- case WXK_RETURN:
- m_finished = true;
- m_owner->FinishEditing();
- break;
-
- case WXK_ESCAPE:
- m_finished = true;
- m_owner->CancelEditing();
- break;
-
- default:
- event.Skip();
- }
-}
-
-void wxDataViewEditorCtrlEvtHandler::OnKillFocus( wxFocusEvent &event )
-{
- if (!m_finished)
- {
- m_finished = true;
- m_owner->FinishEditing();
- }
-
- // We must let the native text control handle focus
- event.Skip();
-}
-
// ---------------------------------------------------------
// wxDataViewCustomRenderer
// ---------------------------------------------------------
{
m_width = width;
m_minWidth = wxDVC_DEFAULT_MINWIDTH;
+ m_ascending = true;
}
void wxDataViewColumn::SetResizeable( bool resizeable )
m_flags |= wxDATAVIEW_COL_SORTABLE;
else
m_flags &= ~wxDATAVIEW_COL_SORTABLE;
+
+ // Update header button
+ if (GetOwner())
+ GetOwner()->OnColumnChange();
}
-void wxDataViewColumn::SetSortOrder( bool WXUNUSED(ascending) )
+void wxDataViewColumn::SetSortOrder( bool ascending )
{
- // TODO
+ m_ascending = ascending;
+
+ // Update header button
+ if (GetOwner())
+ GetOwner()->OnColumnChange();
}
bool wxDataViewColumn::IsSortOrderAscending() const
{
- // TODO
- return true;
+ return m_ascending;
}
void wxDataViewColumn::SetInternalWidth( int width )
int cw = col->GetWidth();
int ch = h;
+ wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE;
+ if (col->IsSortable())
+ {
+ if (col->IsSortOrderAscending())
+ sortArrow = wxHDR_SORT_ICON_UP;
+ else
+ sortArrow = wxHDR_SORT_ICON_DOWN;
+ }
+
wxRendererNative::Get().DrawHeaderButton
(
this,
dc,
wxRect(xpos, 0, cw, ch-1),
m_parent->IsEnabled() ? 0
- : (int)wxCONTROL_DISABLED
+ : (int)wxCONTROL_DISABLED,
+ sortArrow
);
// align as required the column title:
if ( m_dirty )
wxSafeYield();
-
int xpos = 0;
unsigned int cols = GetOwner()->GetColumnCount();
unsigned int i;
wxRect labelRect( xpos, m_currentRow * m_lineHeight,
m_currentCol->GetWidth(), m_lineHeight );
+ GetOwner()->CalcScrolledPosition( labelRect.x, labelRect.y,
+ &labelRect.x, &labelRect.y);
+
m_currentCol->GetRenderer()->StartEditing( m_currentRow, labelRect );
}