// the column count
virtual void UpdateDisplay();
+ virtual void OnInternalIdle();
+
// called Refresh afterwards
virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL);
+ virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
+
protected:
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
-
+
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags);
wxSize DoGetBestSize() const;
wxDataViewColumn *GetColumnFromHeader(NMHEADER *nmHDR)
{ return GetColumn(GetColumnIdxFromHeader(nmHDR)); }
-
- int m_scrollOffsetX;
- int m_buttonHeight;
+
+ int m_scrollOffsetX;
+ int m_buttonHeight;
+ bool m_delayedUpdate;
private:
DECLARE_DYNAMIC_CLASS(wxDataViewHeaderWindowMSW)
colour = dc->GetTextForeground();
dc->SetTextForeground( m_attr.GetColour() );
}
-
+
if (m_attr.GetBold() || m_attr.GetItalic())
{
font = dc->GetFont();
dc->SetFont( myfont );
}
}
-
+
dc->DrawText( m_text, cell.x, cell.y + ((cell.height - dc->GetCharHeight()) / 2));
-
+
// restore dc
if (m_hasAttr)
{
if (m_attr.HasColour())
dc->SetTextForeground( colour );
-
+
if (m_attr.GetBold() || m_attr.GetItalic())
dc->SetFont( font );
}
-
+
return true;
}
-
+
// ---------------------------------------------------------
// wxDataViewBitmapRenderer
SetTitle(title);
SetFlags(flags);
+ m_autosize = width < 0; // TODO
+
Init(width < 0 ? wxDVC_DEFAULT_WIDTH : width);
}
m_owner = parent;
m_scrollOffsetX = 0;
- m_buttonHeight = wxRendererNative::Get().GetHeaderButtonHeight( this ) + 10;
+ m_delayedUpdate = false;
+ m_buttonHeight = wxRendererNative::Get().GetHeaderButtonHeight( this );
int x = pos.x == wxDefaultCoord ? 0 : pos.x,
y = pos.y == wxDefaultCoord ? 0 : pos.y,
w = size.x == wxDefaultCoord ? 1 : size.x,
- h = size.y == wxDefaultCoord ? m_buttonHeight : size.y;
+ h = m_buttonHeight;
+
+ wxSize new_size(w,h);
- if ( !CreateControl(parent, id, pos, size, 0, wxDefaultValidator, name) )
+ if ( !CreateControl(parent, id, pos, new_size, 0, wxDefaultValidator, name) )
return false;
// create the native WC_HEADER window:
WXHWND hwndParent = (HWND)parent->GetHandle();
WXDWORD msStyle = WS_CHILD | HDS_DRAGDROP | HDS_BUTTONS | HDS_HORZ | HDS_HOTTRACK | HDS_FULLDRAG;
-
+
if ( m_isShown )
msStyle |= WS_VISIBLE;
-
+
m_hWnd = CreateWindowEx(0,
WC_HEADER,
(LPCTSTR) NULL,
// the following is required to get the default win's font for
// header windows and must be done befor sending the HDM_LAYOUT msg
SetFont(GetFont());
-
+
return true;
}
wxSize wxDataViewHeaderWindowMSW::DoGetBestSize() const
{
- return wxSize(80, m_buttonHeight );
+ return wxSize( 80, m_buttonHeight+2 );
+}
+
+void wxDataViewHeaderWindowMSW::OnInternalIdle()
+{
+ if (m_delayedUpdate)
+ {
+ m_delayedUpdate = false;
+ UpdateDisplay();
+ }
}
void wxDataViewHeaderWindowMSW::UpdateDisplay()
case HDN_ENDDRAG: // user has finished reordering a column
{
- // TODO: How to query the new position here?
+ wxDataViewColumn *col = GetColumn(nmHDR->iItem);
+ unsigned int new_pos = nmHDR->pitem->iOrder;
+ m_owner->ColumnMoved( col, new_pos );
+ m_delayedUpdate = true;
}
break;
-
+
case HDN_ITEMCHANGING:
if (nmHDR->pitem != NULL &&
(nmHDR->pitem->mask & HDI_WIDTH) != 0)
const wxRect * WXUNUSED(rect))
{
m_scrollOffsetX += dx;
-
+
GetParent()->Layout();
}
SetBackgroundColour( *wxWHITE );
+ SetBackgroundStyle(wxBG_STYLE_CUSTOM);
+
m_penRule = wxPen(GetRuleColour(), 1, wxSOLID);
//Here I compose a pen can draw black lines, maybe there are something system colour to use
wxVariant value;
wxDataViewTreeNode *node = NULL;
wxDataViewItem dataitem;
-
+
if (m_root)
{
node = GetTreeNodeByRow(item);
model->GetValue( value, dataitem, col->GetModelColumn());
cell->SetValue( value );
-
+
if (cell->GetWantsAttr())
{
wxDataViewItemAttr attr;
if ((m_root) && (col == expander))
{
indent = node->GetIndentLevel();
-
+
//Calculate the indent first
indent = cell_rect.x + GetOwner()->GetIndent() * indent;
// I am wondering whether we should draw dot lines between tree nodes
if (node)
delete node;
- // Yes, if the node does not have any child, it must be a leaf which
+ // Yes, if the node does not have any child, it must be a leaf which
// mean that it is a temporarily created by GetTreeNodeByRow
}
UpdateDisplay();
return true;
}
-
+
SortPrepare();
wxDataViewTreeNode * node;
m_currentRow = m_count - 1;
m_selection.Empty();
-
+
UpdateDisplay();
return true;
bool wxDataViewMainWindow::Cleared()
{
DestroyTree();
-
+
SortPrepare();
BuildTree( GetOwner()->GetModel() );
-
+
UpdateDisplay();
return true;
model->AddNotifier( m_notifier );
m_clientArea->DestroyTree();
-
+
m_clientArea->BuildTree(model);
m_clientArea->UpdateDisplay();
return NULL;
}
+void wxDataViewCtrl::ColumnMoved( wxDataViewColumn* col, unsigned int new_pos )
+{
+ if (new_pos > m_cols.GetCount()) return;
+ m_cols.DeleteObject( col );
+ m_cols.Insert( new_pos, col );
+
+ m_clientArea->UpdateDisplay();
+}
+
bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
{
wxDataViewColumnList::compatibility_iterator ret = m_cols.Find( column );