]> git.saurik.com Git - wxWidgets.git/commitdiff
1. wxGrid row can't be resized to less than minimal height
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 2 Mar 2000 00:58:11 +0000 (00:58 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 2 Mar 2000 00:58:11 +0000 (00:58 +0000)
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

include/wx/hash.h
include/wx/msw/private.h
src/common/hash.cpp
src/generic/grid.cpp
src/msw/button.cpp
src/msw/checkbox.cpp
src/msw/enhmeta.cpp
src/msw/treectrl.cpp
src/msw/window.cpp

index 4320f720c8f9fe5bae85dea5277fc292f9b862cf..cf10d040c8abef6f38db0b73b08d754fbcd2da2c 100644 (file)
@@ -80,6 +80,7 @@ class WXDLLEXPORT wxHashTableLong : public wxObject
 {
 public:
     wxHashTableLong(size_t size = wxHASH_SIZE_DEFAULT) { Init(size); }
+    virtual ~wxHashTableLong();
 
     void Create(size_t size = wxHASH_SIZE_DEFAULT);
     void Destroy();
index 6ed5fcb913878f500591ef07ea02d031327c9bd2..b9e0c1829bac2f96d481bc2e0220730c0147bc19 100644 (file)
@@ -256,6 +256,17 @@ extern HBITMAP wxInvertMask(HBITMAP hbmpMask, int w = 0, int h = 0);
     #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
 // ---------------------------------------------------------------------------
index 1aa13adf84982444d41e93c54c2f27b6c5ba4c4a..78e1c6039d2d21e11e644aadcc7400d72ba79028 100644 (file)
@@ -123,6 +123,11 @@ wxNodeBase *wxHashTableBase::GetNode(long key, long value) const
 // wxHashTableLong
 // ----------------------------------------------------------------------------
 
+wxHashTableLong::~wxHashTableLong()
+{
+    Destroy();
+}
+
 void wxHashTableLong::Init(size_t size)
 {
     m_hashSize = size;
index dce4f7b9c87a51b90d2d1ab6d8cdbfa6ebd13898..9eced764e0e424b703aceae6c1b8b7644a9876d3 100644 (file)
@@ -914,8 +914,8 @@ void wxGridCellBoolEditor::SetSize(const wxRect& r)
     // 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;
     size.y -= 2;
 #endif
 
@@ -1457,11 +1457,7 @@ wxSize wxGridCellBoolRenderer::ms_sizeCheckMark;
 // 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),
@@ -1476,7 +1472,7 @@ wxSize wxGridCellBoolRenderer::GetBestSize(wxGrid& grid,
         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__)
@@ -1512,22 +1508,11 @@ void wxGridCellBoolRenderer::Draw(wxGrid& grid,
     }
 
     // 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) )
@@ -1537,9 +1522,23 @@ void wxGridCellBoolRenderer::Draw(wxGrid& grid,
 
     if ( value )
     {
+        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.SetBrush(*wxTRANSPARENT_BRUSH);
+    dc.SetPen(wxPen(attr.GetTextColour(), 1, wxSOLID));
+    dc.DrawRectangle(rectBorder);
 }
 
 // ----------------------------------------------------------------------------
@@ -1689,8 +1688,8 @@ wxGridCellEditor* wxGridCellAttr::GetEditor(wxGrid* grid, int row, int col) cons
             editor->IncRef();
     }
 
-    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
@@ -1855,8 +1854,8 @@ wxGridCellAttr *wxGridRowOrColAttrData::GetAttr(int rowOrCol) const
 
 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);
@@ -1864,17 +1863,19 @@ void wxGridRowOrColAttrData::SetAttr(wxGridCellAttr *attr, int rowOrCol)
     }
     else
     {
+        size_t n = (size_t)i;
         if ( attr )
         {
             // change the attribute
-            m_attrs[(size_t)n] = attr;
+            m_attrs[n]->DecRef();
+            m_attrs[n] = attr;
         }
         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);
         }
     }
 }
@@ -2121,8 +2122,6 @@ int wxGridTypeRegistry::FindOrCloneDataType(const wxString& 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
@@ -4254,7 +4253,8 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
 
             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 )
             {
@@ -7257,7 +7257,9 @@ void wxGrid::AutoSizeColOrRow( int colOrRow, bool setAsMin, bool column )
 {
     wxClientDC dc(m_gridWin);
 
-    int row, col;
+    // init both of them to avoid compiler warnings, even if weo nly need one
+    int row = -1,
+        col = -1;
     if ( column )
         col = colOrRow;
     else
@@ -7312,8 +7314,11 @@ void wxGrid::AutoSizeColOrRow( int colOrRow, bool setAsMin, bool column )
     }
     else
     {
-        // leave some space around text
-        extentMax += 10;
+        if ( column )
+        {
+            // leave some space around text
+            extentMax += 10;
+        }
     }
 
     if ( column )
index 28dfc634dabbd708003b96dd51c9f7718fa53928..64e3c798a22a4701407bc1bd7cac9df30c9b98ee 100644 (file)
@@ -237,8 +237,9 @@ bool wxButton::MSWCommand(WXUINT param, WXWORD id)
     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;
     }
@@ -256,6 +257,11 @@ long wxButton::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
 
         // 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);
index 97b471a1e3ec006f012fae9a056ebc75efb1e14b..04856bb161197294cf204ab74e170724c5e0d897 100644 (file)
@@ -145,6 +145,8 @@ void wxCheckBox::SetLabel(const wxString& label)
   SetWindowText(GetHwnd(), label);
 }
 
+#define CHECK_SIZE 13
+
 wxSize wxCheckBox::DoGetBestSize() const
 {
     int wCheckbox, hCheckbox;
@@ -154,15 +156,15 @@ wxSize wxCheckBox::DoGetBestSize() const
     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;
     }
     else
     {
-        wCheckbox = RADIO_SIZE;
-        hCheckbox = RADIO_SIZE;
+        wCheckbox = CHECK_SIZE;
+        hCheckbox = CHECK_SIZE;
     }
 
     return wxSize(wCheckbox, hCheckbox);
index 0fd8b2d9af796d83a3bb0ed539da9a6a343fe715..5ce1e70d94449223eb3889545c12799f16396014 100644 (file)
@@ -164,9 +164,13 @@ wxSize wxEnhMetaFile::GetSize() const
 
 bool wxEnhMetaFile::SetClipboard(int WXUNUSED(width), int WXUNUSED(height))
 {
+#if wxUSE_DRAG_AND_DROP
     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
 }
 
 // ----------------------------------------------------------------------------
index 63f54e57d3c7e358b93daa21194422119f369e69..bf062b711525f11eeb4cf5f121b9022ddbe7906c 100644 (file)
 // looks quite ugly.
 #define wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE 0
 
-// from msw/window.cpp
-extern bool wxIsShiftDown();
-extern bool wxIsCtrlDown();
-
 // ----------------------------------------------------------------------------
 // private functions
 // ----------------------------------------------------------------------------
index e0ca05bd88da78767bb9ba2aead50ae23d41f653..3f8c4085f70dc197b4611404d513ec03b8b82f91 100644 (file)
@@ -129,10 +129,6 @@ wxWindow *wxFindWinFromHandle(WXHWND hWnd);
 // 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
 // ---------------------------------------------------------------------------