#define USE_NATIVE_HEADER_WINDOW 1
-class wxDataViewHeaderWindowBase : public wxControl
+// NB: for some reason, this class must be dllexport'ed or we get warnings from
+// MSVC in DLL build
+class WXDLLIMPEXP_ADV wxDataViewHeaderWindowBase : public wxControl
{
public:
wxDataViewHeaderWindowBase()
{ m_owner = NULL; }
bool Create(wxDataViewCtrl *parent, wxWindowID id,
- const wxPoint &pos, const wxSize &size,
+ const wxPoint &pos, const wxSize &size,
const wxString &name)
{
return wxWindow::Create(parent, id, pos, size, wxNO_BORDER, name);
virtual wxDataViewColumn *GetColumn(unsigned int n)
{
wxASSERT(m_owner);
- wxDataViewColumn *ret = m_owner->GetColumn(n);
+ wxDataViewColumn *ret = m_owner->GetColumn(n);
wxASSERT(ret);
- return ret;
+ return ret;
}
protected:
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
const wxString &name = wxT("wxdataviewctrlheaderwindow") )
- {
+ {
Create(parent, id, pos, size, name);
}
bool Create(wxDataViewCtrl *parent, wxWindowID id,
- const wxPoint &pos, const wxSize &size,
+ const wxPoint &pos, const wxSize &size,
const wxString &name);
~wxDataViewHeaderWindowMSW();
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
const wxString &name = wxT("wxdataviewctrlheaderwindow") )
- {
+ {
Init();
Create(parent, id, pos, size, name);
}
bool Create(wxDataViewCtrl *parent, wxWindowID id,
- const wxPoint &pos, const wxSize &size,
+ const wxPoint &pos, const wxSize &size,
const wxString &name);
~wxGenericDataViewHeaderWindow()
bool m_dirty; // needs refresh?
int m_column; // index of the column being resized
int m_currentX; // divider line position in logical (unscrolled) coords
- int m_minX; // minimal position beyond which the divider line
+ int m_minX; // minimal position beyond which the divider line
// can't be dragged in logical coords
// the pen used to draw the current column width drag line
// wxDataViewMainWindow
//-----------------------------------------------------------------------------
-WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SIZE_T(unsigned int, wxDataViewSelection,
+WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SIZE_T(unsigned int, wxDataViewSelection,
WXDLLIMPEXP_ADV);
class wxDataViewMainWindow: public wxWindow
IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer, wxDataViewRendererBase)
-wxDataViewRenderer::wxDataViewRenderer( const wxString &varianttype,
+wxDataViewRenderer::wxDataViewRenderer( const wxString &varianttype,
wxDataViewCellMode mode,
int align) :
wxDataViewRendererBase( varianttype, mode, align )
IMPLEMENT_CLASS(wxDataViewTextRenderer, wxDataViewCustomRenderer)
-wxDataViewTextRenderer::wxDataViewTextRenderer( const wxString &varianttype,
+wxDataViewTextRenderer::wxDataViewTextRenderer( const wxString &varianttype,
wxDataViewCellMode mode, int align ) :
wxDataViewCustomRenderer( varianttype, mode, align )
{
IMPLEMENT_CLASS(wxDataViewBitmapRenderer, wxDataViewCustomRenderer)
-wxDataViewBitmapRenderer::wxDataViewBitmapRenderer( const wxString &varianttype,
+wxDataViewBitmapRenderer::wxDataViewBitmapRenderer( const wxString &varianttype,
wxDataViewCellMode mode, int align ) :
wxDataViewCustomRenderer( varianttype, mode, align )
{
return true;
}
-bool wxDataViewToggleRenderer::Activate( wxRect WXUNUSED(cell),
- wxDataViewListModel *model,
+bool wxDataViewToggleRenderer::Activate( wxRect WXUNUSED(cell),
+ wxDataViewListModel *model,
unsigned int col, unsigned int row )
{
bool value = !m_toggle;
return wxSize(x,y+d);
}
-bool wxDataViewDateRenderer::Activate( wxRect WXUNUSED(cell), wxDataViewListModel *model,
+bool wxDataViewDateRenderer::Activate( wxRect WXUNUSED(cell), wxDataViewListModel *model,
unsigned int col, unsigned int row )
{
wxVariant variant;
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn, wxDataViewColumnBase)
-wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewRenderer *cell,
+wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewRenderer *cell,
unsigned int model_column,
int width, wxAlignment align, int flags ) :
wxDataViewColumnBase( title, cell, model_column, width, align, flags )
Init(width < 0 ? wxDVC_DEFAULT_WIDTH : width);
}
-wxDataViewColumn::wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *cell,
+wxDataViewColumn::wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *cell,
unsigned int model_column,
int width, wxAlignment align, int flags ) :
wxDataViewColumnBase( bitmap, cell, model_column, width, align, flags )
#if defined(__WXMSW__) && USE_NATIVE_HEADER_WINDOW
// implemented in msw/listctrl.cpp:
-unsigned int wxMSWGetColumnClicked(NMHDR *nmhdr, POINT *ptClick);
+int WXDLLIMPEXP_CORE wxMSWGetColumnClicked(NMHDR *nmhdr, POINT *ptClick);
IMPLEMENT_ABSTRACT_CLASS(wxDataViewHeaderWindowMSW, wxWindow)
bool wxDataViewHeaderWindowMSW::Create( wxDataViewCtrl *parent, wxWindowID id,
- const wxPoint &pos, const wxSize &size,
+ const wxPoint &pos, const wxSize &size,
const wxString &name )
{
m_owner = parent;
// create the native WC_HEADER window:
WXHWND hwndParent = (HWND)parent->GetHandle();
WXDWORD msStyle = WS_CHILD | HDS_BUTTONS | HDS_HORZ | HDS_HOTTRACK | HDS_FULLDRAG;
- m_hWnd = CreateWindowEx(0,
- WC_HEADER,
- (LPCTSTR) NULL,
+ m_hWnd = CreateWindowEx(0,
+ WC_HEADER,
+ (LPCTSTR) NULL,
msStyle,
x, y, w, h,
- (HWND)hwndParent,
- (HMENU)-1,
- wxGetInstance(),
+ (HWND)hwndParent,
+ (HMENU)-1,
+ wxGetInstance(),
(LPVOID) NULL);
- if (m_hWnd == NULL)
+ if (m_hWnd == NULL)
{
wxLogLastError(_T("CreateWindowEx"));
return false;
// to call wxDataViewHeaderWindow::MSWOnNotify
SubclassWin(m_hWnd);
- // the following is required to get the default win's font for
+ // 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());
HDLAYOUT hdl;
WINDOWPOS wp;
- // Retrieve the bounding rectangle of the parent window's
- // client area, and then request size and position values
- // from the header control.
- ::GetClientRect((HWND)hwndParent, &rcParent);
-
- hdl.prc = &rcParent;
- hdl.pwpos = ℘
- if (!SendMessage((HWND)m_hWnd, HDM_LAYOUT, 0, (LPARAM) &hdl))
+ // Retrieve the bounding rectangle of the parent window's
+ // client area, and then request size and position values
+ // from the header control.
+ ::GetClientRect((HWND)hwndParent, &rcParent);
+
+ hdl.prc = &rcParent;
+ hdl.pwpos = ℘
+ if (!SendMessage((HWND)m_hWnd, HDM_LAYOUT, 0, (LPARAM) &hdl))
{
wxLogLastError(_T("SendMessage"));
return false;
}
-
- // Set the size, position, and visibility of the header control.
- SetWindowPos((HWND)m_hWnd,
- wp.hwndInsertAfter,
- wp.x, wp.y,
- wp.cx, wp.cy,
+
+ // Set the size, position, and visibility of the header control.
+ SetWindowPos((HWND)m_hWnd,
+ wp.hwndInsertAfter,
+ wp.x, wp.y,
+ wp.cx, wp.cy,
wp.flags | SWP_SHOWWINDOW);
// set our size hints: wxDataViewCtrl will put this wxWindow inside
// remove old columns
for (int j=0, max=Header_GetItemCount((HWND)m_hWnd); j < max; j++)
Header_DeleteItem((HWND)m_hWnd, 0);
-
+
// add the updated array of columns to the header control
unsigned int cols = GetOwner()->GetColumnCount();
unsigned int added = 0;
hdi.lParam = (LPARAM)i;
// the native wxMSW implementation of the header window
- // draws the column separator COLUMN_WIDTH_OFFSET pixels
+ // draws the column separator COLUMN_WIDTH_OFFSET pixels
// on the right: to correct this effect we make the column
// exactly COLUMN_WIDTH_OFFSET wider (for the first column):
if (i == 0)
// such alignment is not allowed for the column header!
wxFAIL;
}
-
- SendMessage((HWND)m_hWnd, HDM_INSERTITEM,
- (WPARAM)added, (LPARAM)&hdi);
+
+ SendMessage((HWND)m_hWnd, HDM_INSERTITEM,
+ (WPARAM)added, (LPARAM)&hdi);
added++;
}
}
break;
case HDN_ITEMCHANGING:
- if (nmHDR->pitem != NULL &&
+ if (nmHDR->pitem != NULL &&
(nmHDR->pitem->mask & HDI_WIDTH) != 0)
{
int minWidth = GetColumnFromHeader(nmHDR)->GetMinWidth();
if (nmHDR->pitem->cxy < minWidth)
{
- // do not allow the user to resize this column under
+ // do not allow the user to resize this column under
// its minimal width:
*result = TRUE;
}
case HDN_ENDDRAG: // user has finished reordering a column
// update the width of the modified column:
- if (nmHDR->pitem != NULL &&
+ if (nmHDR->pitem != NULL &&
(nmHDR->pitem->mask & HDI_WIDTH) != 0)
{
unsigned int idx = GetColumnIdxFromHeader(nmHDR);
case HDN_ITEMCLICK:
{
unsigned int idx = GetColumnIdxFromHeader(nmHDR);
- wxEventType evt = nmHDR->iButton == 0 ?
+ wxEventType evt = nmHDR->iButton == 0 ?
wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK :
wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK;
SendEvent(evt, idx);
ZeroMemory(&hd, sizeof(hd));
hd.mask = HDI_WIDTH;
hd.cxy = w;
- Header_SetItem(GetHwnd(),
+ Header_SetItem(GetHwnd(),
nmHDR->iItem, // NOTE: we don't want 'idx' here!
&hd);
return true;
}
-void wxDataViewHeaderWindowMSW::ScrollWindow(int WXUNUSED(dx), int WXUNUSED(dy),
+void wxDataViewHeaderWindowMSW::ScrollWindow(int WXUNUSED(dx), int WXUNUSED(dy),
const wxRect *WXUNUSED(rect))
{
wxSize ourSz = GetClientSize();
int x1 = 0, y1 = 0;
m_owner->CalcUnscrolledPosition(0, 0, &x1, &y1);
- // put this window on top of our parent and
- SetWindowPos((HWND)m_hWnd, HWND_TOP, -x1, 0,
- ownerSz.GetWidth() + x1, ourSz.GetHeight(),
+ // put this window on top of our parent and
+ SetWindowPos((HWND)m_hWnd, HWND_TOP, -x1, 0,
+ ownerSz.GetWidth() + x1, ourSz.GetHeight(),
SWP_SHOWWINDOW);
}
-void wxDataViewHeaderWindowMSW::DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
- int WXUNUSED(w), int WXUNUSED(h),
+void wxDataViewHeaderWindowMSW::DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
+ int WXUNUSED(w), int WXUNUSED(h),
int WXUNUSED(f))
{
// the wxDataViewCtrl's internal wxBoxSizer will call this function when
END_EVENT_TABLE()
bool wxGenericDataViewHeaderWindow::Create(wxDataViewCtrl *parent, wxWindowID id,
- const wxPoint &pos, const wxSize &size,
- const wxString &name )
+ const wxPoint &pos, const wxSize &size,
+ const wxString &name )
{
m_owner = parent;
// always center the title vertically:
int y = wxMax((ch - titleSz.GetHeight()) / 2, HEADER_VERT_BORDER);
- dc.SetClippingRegion( xpos+HEADER_HORIZ_BORDER,
+ dc.SetClippingRegion( xpos+HEADER_HORIZ_BORDER,
HEADER_VERT_BORDER,
wxMax(cw - 2 * HEADER_HORIZ_BORDER, 1), // width
wxMax(ch - 2 * HEADER_VERT_BORDER, 1)); // height
if (m_isDragging)
{
- // we don't draw the line beyond our window,
+ // we don't draw the line beyond our window,
// but we allow dragging it there
int w = 0;
GetClientSize( &w, NULL );
w -= 6;
// erase the line if it was drawn
- if (m_currentX < w)
+ if (m_currentX < w)
DrawCurrent();
- if (event.ButtonUp())
+ if (event.ButtonUp())
{
m_isDragging = false;
- if (HasCapture())
+ if (HasCapture())
ReleaseMouse();
m_dirty = true;
// find the column where this event occured
int countCol = m_owner->GetColumnCount();
- for (int column = 0; column < countCol; column++)
+ for (int column = 0; column < countCol; column++)
{
wxDataViewColumn *p = GetColumn(column);
- if (p->IsHidden())
+ if (p->IsHidden())
continue; // skip if not shown
xpos += p->GetWidth();
m_column = column;
- if ((abs(x-xpos) < 3) && (y < 22))
+ if ((abs(x-xpos) < 3) && (y < 22))
{
hit_border = true;
break;
}
- if (x < xpos)
+ if (x < xpos)
{
// inside the column
break;
}
else if (event.LeftDown() || event.RightUp())
{
- if (hit_border && event.LeftDown() && resizeable)
+ if (hit_border && event.LeftDown() && resizeable)
{
m_isDragging = true;
CaptureMouse();
}
else // click on a column
{
- wxEventType evt = event.LeftDown() ?
+ wxEventType evt = event.LeftDown() ?
wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK :
wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK;
SendEvent(evt, m_column);
}
else if (event.Moving())
{
- if (hit_border && resizeable)
+ if (hit_border && resizeable)
m_currentCursor = m_resizeCursor;
else
m_currentCursor = wxSTANDARD_CURSOR;
m_currentRow = 0;
// TODO: we need to calculate this smartly
- m_lineHeight =
+ m_lineHeight =
#ifdef __WXMSW__
17;
#else
break;
xpos += c->GetWidth();
}
- wxRect labelRect( xpos, m_currentRow * m_lineHeight,
+ wxRect labelRect( xpos, m_currentRow * m_lineHeight,
m_currentCol->GetWidth(), m_lineHeight );
wxClassInfo *textControlClass = CLASSINFO(wxTextCtrl);
// compute which items needs to be redrawn
unsigned int item_start = wxMax( 0, (update.y / m_lineHeight) );
- unsigned int item_count =
+ unsigned int item_count =
wxMin( (int)(((update.y + update.height) / m_lineHeight) - item_start + 1),
(int)(model->GetRowCount() - item_start) );
unsigned int item_last = item_start + item_count;
}
// Draw last vertical rule
- dc.DrawLine(x, item_start * m_lineHeight,
+ dc.DrawLine(x, item_start * m_lineHeight,
x, item_last * m_lineHeight);
}
unsigned int i;
for (i = 0; i < GetOwner()->GetColumnCount(); i++)
{
- const wxDataViewColumn *c =
+ const wxDataViewColumn *c =
wx_const_cast(wxDataViewCtrl*, GetOwner())->GetColumn( i );
if (!c->IsHidden())
unsigned int wxDataViewMainWindow::GetLastVisibleRow() const
{
wxSize client_size = GetClientSize();
- m_owner->CalcUnscrolledPosition( client_size.x, client_size.y,
+ m_owner->CalcUnscrolledPosition( client_size.x, client_size.y,
&client_size.x, &client_size.y );
return wxMin( GetRowCount()-1, ((unsigned)client_size.y/m_lineHeight)+1 );
wxVariant value;
model->GetValue( value, col->GetModelColumn(), current );
cell->SetValue( value );
- wxRect cell_rect( xpos, current * m_lineHeight,
+ wxRect cell_rect( xpos, current * m_lineHeight,
col->GetWidth(), m_lineHeight );
cell->Activate( cell_rect, model, col->GetModelColumn(), current );
}
// Update selection here...
m_currentCol = col;
- m_lastOnSame = !forceClick && ((col == oldCurrentCol) &&
+ m_lastOnSame = !forceClick && ((col == oldCurrentCol) &&
(current == oldCurrentRow)) && oldWasSelected;
}
}
const wxPoint& pos, const wxSize& size,
long style, const wxValidator& validator )
{
- if (!wxControl::Create( parent, id, pos, size,
+ if (!wxControl::Create( parent, id, pos, size,
style | wxScrolledWindowStyle|wxSUNKEN_BORDER, validator))
return false;