2. memory leaks fixed in wxHashTableLong
3. and in wxGrid
4. changed newgrid sample to use char buffers
5. fixed double clicking owner-drawn buttons
6. compilation fix in enhmeta.cpp for !wxUSE_DND
7. bug introduced earlier today in wxGridCellAttr::GetEditor() fixed
8. bool renderer/editor now look as good as I may ever make them look
good under MSW
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6391
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
{
public:
wxHashTableLong(size_t size = wxHASH_SIZE_DEFAULT) { Init(size); }
{
public:
wxHashTableLong(size_t size = wxHASH_SIZE_DEFAULT) { Init(size); }
+ virtual ~wxHashTableLong();
void Create(size_t size = wxHASH_SIZE_DEFAULT);
void Destroy();
void Create(size_t size = wxHASH_SIZE_DEFAULT);
void Destroy();
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
#endif // GET_X_LPARAM
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
#endif // GET_X_LPARAM
+// get the current state of SHIFT/CTRL keys
+extern inline bool wxIsShiftDown()
+{
+ return (::GetKeyState(VK_SHIFT) & 0x100) != 0;
+}
+
+extern inline bool wxIsCtrlDown()
+{
+ return (::GetKeyState(VK_CONTROL) & 0x100) != 0;
+}
+
// ---------------------------------------------------------------------------
// small helper classes
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// small helper classes
// ---------------------------------------------------------------------------
// wxHashTableLong
// ----------------------------------------------------------------------------
// wxHashTableLong
// ----------------------------------------------------------------------------
+wxHashTableLong::~wxHashTableLong()
+{
+ Destroy();
+}
+
void wxHashTableLong::Init(size_t size)
{
m_hashSize = size;
void wxHashTableLong::Init(size_t size)
{
m_hashSize = size;
// so shift it to the right
size.x -= 8;
#elif defined(__WXMSW__)
// so shift it to the right
size.x -= 8;
#elif defined(__WXMSW__)
- // here too...
- size.x -= 6;
+ // here too, but in other way
+ size.x += 1;
// FIXME these checkbox size calculations are really ugly...
// between checkmark and box
// FIXME these checkbox size calculations are really ugly...
// between checkmark and box
-#ifdef __WXGTK__
- static const wxCoord wxGRID_CHECKMARK_MARGIN = 4;
-#else
- static const wxCoord wxGRID_CHECKMARK_MARGIN = 2;
-#endif
+static const wxCoord wxGRID_CHECKMARK_MARGIN = 2;
wxSize wxGridCellBoolRenderer::GetBestSize(wxGrid& grid,
wxGridCellAttr& WXUNUSED(attr),
wxSize wxGridCellBoolRenderer::GetBestSize(wxGrid& grid,
wxGridCellAttr& WXUNUSED(attr),
wxCoord checkSize = 0;
wxCheckBox *checkbox = new wxCheckBox(&grid, -1, wxEmptyString);
wxSize size = checkbox->GetBestSize();
wxCoord checkSize = 0;
wxCheckBox *checkbox = new wxCheckBox(&grid, -1, wxEmptyString);
wxSize size = checkbox->GetBestSize();
- checkSize = size.y + wxGRID_CHECKMARK_MARGIN;
+ checkSize = size.y + 2*wxGRID_CHECKMARK_MARGIN;
// FIXME wxGTK::wxCheckBox::GetBestSize() gives "wrong" result
#if defined(__WXGTK__) || defined(__WXMOTIF__)
// FIXME wxGTK::wxCheckBox::GetBestSize() gives "wrong" result
#if defined(__WXGTK__) || defined(__WXMOTIF__)
}
// draw a border around checkmark
}
// draw a border around checkmark
- wxRect rectMark;
- rectMark.x = rect.x + rect.width/2 - size.x/2;
- rectMark.y = rect.y + rect.height/2 - size.y/2;
- rectMark.width = size.x;
- rectMark.height = size.y;
-
- dc.SetBrush(*wxTRANSPARENT_BRUSH);
- dc.SetPen(wxPen(attr.GetTextColour(), 1, wxSOLID));
- dc.DrawRectangle(rectMark);
-
- rectMark.Inflate(-wxGRID_CHECKMARK_MARGIN);
-
-#ifdef __WXMSW__
- // looks nicer under MSW
- rectMark.x++;
-#endif // MSW
+ wxRect rectBorder;
+ rectBorder.x = rect.x + rect.width/2 - size.x/2;
+ rectBorder.y = rect.y + rect.height/2 - size.y/2;
+ rectBorder.width = size.x;
+ rectBorder.height = size.y;
bool value;
if ( grid.GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL) )
bool value;
if ( grid.GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL) )
+ wxRect rectMark = rectBorder;
+#ifdef __WXMSW__
+ // MSW DrawCheckMark() is weird (and should probably be changed...)
+ rectMark.Inflate(-wxGRID_CHECKMARK_MARGIN/2);
+ rectMark.x++;
+ rectMark.y++;
+#else // !MSW
+ rectMark.Inflate(-wxGRID_CHECKMARK_MARGIN);
+#endif // MSW/!MSW
+
dc.SetTextForeground(attr.GetTextColour());
dc.DrawCheckMark(rectMark);
}
dc.SetTextForeground(attr.GetTextColour());
dc.DrawCheckMark(rectMark);
}
+
+ dc.SetBrush(*wxTRANSPARENT_BRUSH);
+ dc.SetPen(wxPen(attr.GetTextColour(), 1, wxSOLID));
+ dc.DrawRectangle(rectBorder);
}
// ----------------------------------------------------------------------------
}
// ----------------------------------------------------------------------------
- if ( grid ) // get renderer for the data type
- editor = grid->GetDefaultEditorForCell(row, col);
+ if ( !editor && grid ) // get renderer for the data type
+ editor = grid->GetDefaultEditorForCell(row, col);
if ( !editor )
// if we still don't have one then use the grid default
if ( !editor )
// if we still don't have one then use the grid default
void wxGridRowOrColAttrData::SetAttr(wxGridCellAttr *attr, int rowOrCol)
{
void wxGridRowOrColAttrData::SetAttr(wxGridCellAttr *attr, int rowOrCol)
{
- int n = m_rowsOrCols.Index(rowOrCol);
- if ( n == wxNOT_FOUND )
+ int i = m_rowsOrCols.Index(rowOrCol);
+ if ( i == wxNOT_FOUND )
{
// add the attribute
m_rowsOrCols.Add(rowOrCol);
{
// add the attribute
m_rowsOrCols.Add(rowOrCol);
if ( attr )
{
// change the attribute
if ( attr )
{
// change the attribute
- m_attrs[(size_t)n] = attr;
+ m_attrs[n]->DecRef();
+ m_attrs[n] = attr;
}
else
{
// remove this attribute
}
else
{
// remove this attribute
- m_attrs[(size_t)n]->DecRef();
- m_rowsOrCols.RemoveAt((size_t)n);
- m_attrs.RemoveAt((size_t)n);
+ m_attrs[n]->DecRef();
+ m_rowsOrCols.RemoveAt(n);
+ m_attrs.RemoveAt(n);
editor->SetParameters(params);
// register the new typename
editor->SetParameters(params);
// register the new typename
- renderer->IncRef();
- editor->IncRef();
RegisterDataType(typeName, renderer, editor);
// we just registered it, it's the last one
RegisterDataType(typeName, renderer, editor);
// we just registered it, it's the last one
wxClientDC dc( m_gridWin );
PrepareDC( dc );
wxClientDC dc( m_gridWin );
PrepareDC( dc );
- y = wxMax( y, GetRowTop(m_dragRowOrCol) + WXGRID_MIN_ROW_HEIGHT );
+ y = wxMax( y, GetRowTop(m_dragRowOrCol) +
+ GetRowMinimalHeight(m_dragRowOrCol) );
dc.SetLogicalFunction(wxINVERT);
if ( m_dragLastPos >= 0 )
{
dc.SetLogicalFunction(wxINVERT);
if ( m_dragLastPos >= 0 )
{
{
wxClientDC dc(m_gridWin);
{
wxClientDC dc(m_gridWin);
+ // init both of them to avoid compiler warnings, even if weo nly need one
+ int row = -1,
+ col = -1;
if ( column )
col = colOrRow;
else
if ( column )
col = colOrRow;
else
- // leave some space around text
- extentMax += 10;
+ if ( column )
+ {
+ // leave some space around text
+ extentMax += 10;
+ }
bool processed = FALSE;
switch ( param )
{
bool processed = FALSE;
switch ( param )
{
- case 1: // means that the message came from an accelerator
- case BN_CLICKED:
+ case 1: // message came from an accelerator
+ case BN_CLICKED: // normal buttons send this
+ case BN_DOUBLECLICKED: // owner-drawn ones also send this
processed = SendClickEvent();
break;
}
processed = SendClickEvent();
break;
}
// let the default processign take place too
}
// let the default processign take place too
}
+ else if ( nMsg == WM_LBUTTONDBLCLK )
+ {
+ // trick the base class into thinking that this was just a click
+ nMsg = WM_LBUTTONDOWN;
+ }
// let the base class do all real processing
return wxControl::MSWWindowProc(nMsg, wParam, lParam);
// let the base class do all real processing
return wxControl::MSWWindowProc(nMsg, wParam, lParam);
SetWindowText(GetHwnd(), label);
}
SetWindowText(GetHwnd(), label);
}
wxSize wxCheckBox::DoGetBestSize() const
{
int wCheckbox, hCheckbox;
wxSize wxCheckBox::DoGetBestSize() const
{
int wCheckbox, hCheckbox;
if ( !str.IsEmpty() )
{
GetTextExtent(str, &wCheckbox, &hCheckbox);
if ( !str.IsEmpty() )
{
GetTextExtent(str, &wCheckbox, &hCheckbox);
- wCheckbox += RADIO_SIZE;
+ wCheckbox += CHECK_SIZE;
- if ( hCheckbox < RADIO_SIZE )
- hCheckbox = RADIO_SIZE;
+ if ( hCheckbox < CHECK_SIZE )
+ hCheckbox = CHECK_SIZE;
- wCheckbox = RADIO_SIZE;
- hCheckbox = RADIO_SIZE;
+ wCheckbox = CHECK_SIZE;
+ hCheckbox = CHECK_SIZE;
}
return wxSize(wCheckbox, hCheckbox);
}
return wxSize(wCheckbox, hCheckbox);
bool wxEnhMetaFile::SetClipboard(int WXUNUSED(width), int WXUNUSED(height))
{
bool wxEnhMetaFile::SetClipboard(int WXUNUSED(width), int WXUNUSED(height))
{
wxCHECK_MSG( m_hMF, FALSE, _T("can't copy invalid metafile to clipboard") );
return wxTheClipboard->AddData(new wxEnhMetaFileDataObject(*this));
wxCHECK_MSG( m_hMF, FALSE, _T("can't copy invalid metafile to clipboard") );
return wxTheClipboard->AddData(new wxEnhMetaFileDataObject(*this));
+#else // !wxUSE_DRAG_AND_DROP
+ wxFAIL_MSG(_T("not implemented"));
+#endif // wxUSE_DRAG_AND_DROP/!wxUSE_DRAG_AND_DROP
}
// ----------------------------------------------------------------------------
}
// ----------------------------------------------------------------------------
// looks quite ugly.
#define wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE 0
// looks quite ugly.
#define wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE 0
-// from msw/window.cpp
-extern bool wxIsShiftDown();
-extern bool wxIsCtrlDown();
-
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
// mouse clicks
static void TranslateKbdEventToMouse(wxWindow *win, int *x, int *y, WPARAM *flags);
// mouse clicks
static void TranslateKbdEventToMouse(wxWindow *win, int *x, int *y, WPARAM *flags);
-// get the current state of SHIFT/CTRL keys
-inline bool wxIsShiftDown() { return (GetKeyState(VK_SHIFT) & 0x100) != 0; }
-inline bool wxIsCtrlDown() { return (GetKeyState(VK_CONTROL) & 0x100) != 0; }
-
// ---------------------------------------------------------------------------
// event tables
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// event tables
// ---------------------------------------------------------------------------