]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
use IMPLEMENT_APP_CONSOLE and not IMPLEMENT_APP for console apps
[wxWidgets.git] / src / generic / grid.cpp
index 7d98bcb1ea7d8528300652a2f0d775d2394a3e6f..2ba9c636e89da794ba21ea3edac21c711563adef 100644 (file)
@@ -485,7 +485,7 @@ void wxGridCellEditor::PaintBackground(const wxRect& rectCell,
         gridWindow->GetOwner()->PrepareDC(dc);
 
     dc.SetPen(*wxTRANSPARENT_PEN);
         gridWindow->GetOwner()->PrepareDC(dc);
 
     dc.SetPen(*wxTRANSPARENT_PEN);
-    dc.SetBrush(wxBrush(attr->GetBackgroundColour(), wxSOLID));
+    dc.SetBrush(wxBrush(attr->GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
     dc.DrawRectangle(rectCell);
 
     // redraw the control we just painted over
     dc.DrawRectangle(rectCell);
 
     // redraw the control we just painted over
@@ -1515,12 +1515,16 @@ void wxGridCellChoiceEditor::Create(wxWindow* parent,
                                     wxWindowID id,
                                     wxEvtHandler* evtHandler)
 {
                                     wxWindowID id,
                                     wxEvtHandler* evtHandler)
 {
-    int style = wxBORDER_NONE;
-    if (!m_allowOthers)
+    int style = wxTE_PROCESS_ENTER |
+                wxTE_PROCESS_TAB |
+                wxBORDER_NONE;
+
+    if ( !m_allowOthers )
         style |= wxCB_READONLY;
     m_control = new wxComboBox(parent, id, wxEmptyString,
                                wxDefaultPosition, wxDefaultSize,
         style |= wxCB_READONLY;
     m_control = new wxComboBox(parent, id, wxEmptyString,
                                wxDefaultPosition, wxDefaultSize,
-                               m_choices, style );
+                               m_choices,
+                               style);
 
     wxGridCellEditor::Create(parent, id, evtHandler);
 }
 
     wxGridCellEditor::Create(parent, id, evtHandler);
 }
@@ -1799,7 +1803,7 @@ void wxGridCellRenderer::Draw(wxGrid& grid,
                               int WXUNUSED(row), int WXUNUSED(col),
                               bool isSelected)
 {
                               int WXUNUSED(row), int WXUNUSED(col),
                               bool isSelected)
 {
-    dc.SetBackgroundMode( wxSOLID );
+    dc.SetBackgroundMode( wxBRUSHSTYLE_SOLID );
 
     // grey out fields if the grid is disabled
     if ( grid.IsEnabled() )
 
     // grey out fields if the grid is disabled
     if ( grid.IsEnabled() )
@@ -1811,16 +1815,16 @@ void wxGridCellRenderer::Draw(wxGrid& grid,
                 clr = grid.GetSelectionBackground();
             else
                 clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW);
                 clr = grid.GetSelectionBackground();
             else
                 clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW);
-            dc.SetBrush( wxBrush(clr, wxSOLID) );
+            dc.SetBrush( wxBrush(clr, wxBRUSHSTYLE_SOLID) );
         }
         else
         {
         }
         else
         {
-            dc.SetBrush( wxBrush(attr.GetBackgroundColour(), wxSOLID) );
+            dc.SetBrush( wxBrush(attr.GetBackgroundColour(), wxBRUSHSTYLE_SOLID) );
         }
     }
     else
     {
         }
     }
     else
     {
-        dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE), wxSOLID));
+        dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE), wxBRUSHSTYLE_SOLID));
     }
 
     dc.SetPen( *wxTRANSPARENT_PEN );
     }
 
     dc.SetPen( *wxTRANSPARENT_PEN );
@@ -1836,7 +1840,7 @@ void wxGridCellStringRenderer::SetTextColoursAndFont(const wxGrid& grid,
                                                      wxDC& dc,
                                                      bool isSelected)
 {
                                                      wxDC& dc,
                                                      bool isSelected)
 {
-    dc.SetBackgroundMode( wxTRANSPARENT );
+    dc.SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT );
 
     // TODO some special colours for attr.IsReadOnly() case?
 
 
     // TODO some special colours for attr.IsReadOnly() case?
 
@@ -3905,7 +3909,7 @@ def __WXGTK__
 
     wxRendererNative::Get().DrawHeaderButton( this, dc, rect, 0 );
 #else // !__WXGTK__
 
     wxRendererNative::Get().DrawHeaderButton( this, dc, rect, 0 );
 #else // !__WXGTK__
-    dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW), 1, wxSOLID) );
+    dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW), 1, wxPENSTYLE_SOLID) );
     dc.DrawLine( client_width - 1, client_height - 1, client_width - 1, 0 );
     dc.DrawLine( client_width - 1, client_height - 1, 0, client_height - 1 );
     dc.DrawLine( 0, 0, client_width, 0 );
     dc.DrawLine( client_width - 1, client_height - 1, client_width - 1, 0 );
     dc.DrawLine( client_width - 1, client_height - 1, 0, client_height - 1 );
     dc.DrawLine( 0, 0, client_width, 0 );
@@ -4131,12 +4135,7 @@ END_EVENT_TABLE()
 
 wxGrid::wxGrid()
 {
 
 wxGrid::wxGrid()
 {
-    // in order to make sure that a size event is not
-    // trigerred in a unfinished state
-    m_cornerLabelWin = NULL;
-    m_rowLabelWin = NULL;
-    m_colLabelWin = NULL;
-    m_gridWin = NULL;
+    InitVars();
 }
 
 wxGrid::wxGrid( wxWindow *parent,
 }
 
 wxGrid::wxGrid( wxWindow *parent,
@@ -4146,6 +4145,7 @@ wxGrid::wxGrid( wxWindow *parent,
                  long style,
                  const wxString& name )
 {
                  long style,
                  const wxString& name )
 {
+    InitVars();
     Create(parent, id, pos, size, style, name);
 }
 
     Create(parent, id, pos, size, style, name);
 }
 
@@ -4203,15 +4203,8 @@ wxGrid::~wxGrid()
 
 void wxGrid::Create()
 {
 
 void wxGrid::Create()
 {
-    // set to true by CreateGrid
-    m_created = false;
-
     // create the type registry
     m_typeRegistry = new wxGridTypeRegistry;
     // create the type registry
     m_typeRegistry = new wxGridTypeRegistry;
-    m_selection = NULL;
-
-    m_table = (wxGridTableBase *) NULL;
-    m_ownTable = false;
 
     m_cellEditCtrlEnabled = false;
 
 
     m_cellEditCtrlEnabled = false;
 
@@ -4405,6 +4398,24 @@ bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership,
     return m_created;
 }
 
     return m_created;
 }
 
+void wxGrid::InitVars()
+{
+    m_created = false;
+
+    m_cornerLabelWin = NULL;
+    m_rowLabelWin = NULL;
+    m_colLabelWin = NULL;
+    m_gridWin = NULL;
+
+    m_table = NULL;
+    m_ownTable = false;
+
+    m_selection = NULL;
+    m_defaultCellAttr = NULL;
+    m_typeRegistry = NULL;
+    m_winCapture = NULL;
+}
+
 void wxGrid::Init()
 {
     m_rowLabelWidth  = WXGRID_DEFAULT_ROW_LABEL_WIDTH;
 void wxGrid::Init()
 {
     m_rowLabelWidth  = WXGRID_DEFAULT_ROW_LABEL_WIDTH;
@@ -6818,7 +6829,7 @@ void wxGrid::Refresh(bool eraseb, const wxRect* rect)
 {
     // Don't do anything if between Begin/EndBatch...
     // EndBatch() will do all this on the last nested one anyway.
 {
     // Don't do anything if between Begin/EndBatch...
     // EndBatch() will do all this on the last nested one anyway.
-    if (! GetBatchCount())
+    if ( m_created && !GetBatchCount() )
     {
         // Refresh to get correct scrolled position:
         wxScrolledWindow::Refresh(eraseb, rect);
     {
         // Refresh to get correct scrolled position:
         wxScrolledWindow::Refresh(eraseb, rect);
@@ -7538,7 +7549,7 @@ void wxGrid::DrawGridSpace( wxDC& dc )
       int left, top;
       CalcUnscrolledPosition( 0, 0, &left, &top );
 
       int left, top;
       CalcUnscrolledPosition( 0, 0, &left, &top );
 
-      dc.SetBrush( wxBrush(GetDefaultCellBackgroundColour(), wxSOLID) );
+      dc.SetBrush( wxBrush(GetDefaultCellBackgroundColour(), wxBRUSHSTYLE_SOLID) );
       dc.SetPen( *wxTRANSPARENT_PEN );
 
       if ( right > rightCol )
       dc.SetPen( *wxTRANSPARENT_PEN );
 
       if ( right > rightCol )
@@ -7633,7 +7644,7 @@ void wxGrid::DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr )
         // Now draw the rectangle
         // use the cellHighlightColour if the cell is inside a selection, this
         // will ensure the cell is always visible.
         // Now draw the rectangle
         // use the cellHighlightColour if the cell is inside a selection, this
         // will ensure the cell is always visible.
-        dc.SetPen(wxPen(IsInSelection(row,col) ? m_selectionForeground : m_cellHighlightColour, penWidth, wxSOLID));
+        dc.SetPen(wxPen(IsInSelection(row,col) ? m_selectionForeground : m_cellHighlightColour, penWidth, wxPENSTYLE_SOLID));
         dc.SetBrush(*wxTRANSPARENT_BRUSH);
         dc.DrawRectangle(rect);
     }
         dc.SetBrush(*wxTRANSPARENT_BRUSH);
         dc.DrawRectangle(rect);
     }
@@ -7662,7 +7673,7 @@ void wxGrid::DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr )
 
 wxPen wxGrid::GetDefaultGridLinePen()
 {
 
 wxPen wxGrid::GetDefaultGridLinePen()
 {
-    return wxPen(GetGridLineColour(), 1, wxSOLID);
+    return wxPen(GetGridLineColour(), 1, wxPENSTYLE_SOLID);
 }
 
 wxPen wxGrid::GetRowGridLinePen(int WXUNUSED(row))
 }
 
 wxPen wxGrid::GetRowGridLinePen(int WXUNUSED(row))
@@ -7882,7 +7893,7 @@ void wxGrid::DrawRowLabel( wxDC& dc, int row )
     int rowTop = GetRowTop(row),
         rowBottom = GetRowBottom(row) - 1;
 
     int rowTop = GetRowTop(row),
         rowBottom = GetRowBottom(row) - 1;
 
-    dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW), 1, wxSOLID) );
+    dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW), 1, wxPENSTYLE_SOLID) );
     dc.DrawLine( m_rowLabelWidth - 1, rowTop, m_rowLabelWidth - 1, rowBottom );
     dc.DrawLine( 0, rowTop, 0, rowBottom );
     dc.DrawLine( 0, rowBottom, m_rowLabelWidth, rowBottom );
     dc.DrawLine( m_rowLabelWidth - 1, rowTop, m_rowLabelWidth - 1, rowBottom );
     dc.DrawLine( 0, rowTop, 0, rowBottom );
     dc.DrawLine( 0, rowBottom, m_rowLabelWidth, rowBottom );
@@ -7891,7 +7902,7 @@ void wxGrid::DrawRowLabel( wxDC& dc, int row )
     dc.DrawLine( 1, rowTop, 1, rowBottom );
     dc.DrawLine( 1, rowTop, m_rowLabelWidth - 1, rowTop );
 
     dc.DrawLine( 1, rowTop, 1, rowBottom );
     dc.DrawLine( 1, rowTop, m_rowLabelWidth - 1, rowTop );
 
-    dc.SetBackgroundMode( wxTRANSPARENT );
+    dc.SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT );
     dc.SetTextForeground( GetLabelTextColour() );
     dc.SetFont( GetLabelFont() );
 
     dc.SetTextForeground( GetLabelTextColour() );
     dc.SetFont( GetLabelFont() );
 
@@ -7954,7 +7965,7 @@ void wxGrid::DrawColLabel( wxDC& dc, int col )
     {
         int colRight = GetColRight(col) - 1;
 
     {
         int colRight = GetColRight(col) - 1;
 
-        dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW), 1, wxSOLID) );
+        dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW), 1, wxPENSTYLE_SOLID) );
         dc.DrawLine( colRight, 0, colRight, m_colLabelHeight - 1 );
         dc.DrawLine( colLeft, 0, colRight, 0 );
         dc.DrawLine( colLeft, m_colLabelHeight - 1,
         dc.DrawLine( colRight, 0, colRight, m_colLabelHeight - 1 );
         dc.DrawLine( colLeft, 0, colRight, 0 );
         dc.DrawLine( colLeft, m_colLabelHeight - 1,
@@ -7965,7 +7976,7 @@ void wxGrid::DrawColLabel( wxDC& dc, int col )
         dc.DrawLine( colLeft, 1, colRight, 1 );
     }
 
         dc.DrawLine( colLeft, 1, colRight, 1 );
     }
 
-    dc.SetBackgroundMode( wxTRANSPARENT );
+    dc.SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT );
     dc.SetTextForeground( GetLabelTextColour() );
     dc.SetFont( GetLabelFont() );
 
     dc.SetTextForeground( GetLabelTextColour() );
     dc.SetFont( GetLabelFont() );
 
@@ -8329,7 +8340,7 @@ void wxGrid::ShowCellEditControl()
             wxClientDC dc( m_gridWin );
             PrepareDC( dc );
             wxGridCellAttr* attr = GetCellAttr(row, col);
             wxClientDC dc( m_gridWin );
             PrepareDC( dc );
             wxGridCellAttr* attr = GetCellAttr(row, col);
-            dc.SetBrush(wxBrush(attr->GetBackgroundColour(), wxSOLID));
+            dc.SetBrush(wxBrush(attr->GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
             dc.SetPen(*wxTRANSPARENT_PEN);
             dc.DrawRectangle(rect);
 
             dc.SetPen(*wxTRANSPARENT_PEN);
             dc.DrawRectangle(rect);
 
@@ -11103,6 +11114,20 @@ wxRect wxGrid::BlockToDeviceRect( const wxGridCellCoords &topLeft,
     return rect;
 }
 
     return rect;
 }
 
+// ----------------------------------------------------------------------------
+// drop target
+// ----------------------------------------------------------------------------
+
+#if wxUSE_DRAG_AND_DROP
+
+// this allow setting drop target directly on wxGrid
+void wxGrid::SetDropTarget(wxDropTarget *dropTarget)
+{
+    GetGridWindow()->SetDropTarget(dropTarget);
+}
+
+#endif // wxUSE_DRAG_AND_DROP
+
 // ----------------------------------------------------------------------------
 // grid event classes
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // grid event classes
 // ----------------------------------------------------------------------------