File: specgrid.cpp

package info (click to toggle)
wxsqlite3 3.0.0.1~dfsg0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,740 kB
  • sloc: cpp: 20,130; sh: 2,837; makefile: 302; ansic: 197; php: 9
file content (646 lines) | stat: -rwxr-xr-x 20,648 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
/*---------------------------------------------------------------------------*/
/* Logiciel de gestion de fichier de bases de donnes SQLite                 */
/*---------------------------------------------------------------------------*/
/* Projet  : wxSQLitePlus                              Version  : 0.3.0.0    */
/* Fichier : specgrid.cpp                                                    */
/* Auteur  : Fred Cailleau-Lepetit                     Date     : 07/09/2007 */
/* email   : softinthebox@free.fr                      Rvision : 12/04/2009 */
/*---------------------------------------------------------------------------*/
/* Copyright (C) Fred Cailleau-Lepetit 2007                                  */
/* Licence GNU General Public License  http://www.fsf.org/copyleft/gpl.html  */
/*---------------------------------------------------------------------------*/
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation (version 3);

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

Ce programme est libre, vous pouvez le redistribuer et/ou le modifier
selon les termes de la Licence Publique Gnrale GNU publie par la
Free Software Foundation (version 3).

Ce programme est distribu car potentiellement utile, mais
SANS AUCUNE GARANTIE, ni explicite ni implicite, y compris
les garanties de commercialisation ou d'adaptation dans un but
spcifique. Reportez-vous  la Licence Publique Gnrale GNU
pour plus de dtails.
*/
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "specgrid.h"
#endif

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
/*---------------------------------------------------------------------------*/
#include <wx/dynarray.h>
#include <wx/arrimpl.cpp>
#include <wx/clipbrd.h>
/*---------------------------------------------------------------------------*/
#include "wxsqliteplusapp.h"
#include "sqlite3table.h"
#include "specgrid.h"
#include "filterdlg.h"
#include "sortdlg.h"
#include "blobdlg.h"
/*---------------------------------------------------------------------------*/
WX_DEFINE_OBJARRAY(wxArrayOfCellsBlock);
/*---------------------------------------------------------------------------*/
int wxCompCellsBlock(wxCellsBlock** first, wxCellsBlock** second)
{
   if (**first < **second)
      return -1;
   else if (**first > **second)
      return 1;
   else
      return 0;
}
/*---------------------------------------------------------------------------*/
IMPLEMENT_DYNAMIC_CLASS(wxSpecGrid, wxGrid)

BEGIN_EVENT_TABLE(wxSpecGrid, wxGrid)
   EVT_MENU(wxID_COPY, wxSpecGrid::OnCopy)
   EVT_UPDATE_UI(wxID_COPY, wxSpecGrid::OnCopyUpdate)
   EVT_MENU(wxID_SELECTALL, wxSpecGrid::OnSelectAll)
   EVT_UPDATE_UI(wxID_SELECTALL, wxSpecGrid::OnSelectAllUpdate)
   EVT_GRID_CELL_RIGHT_CLICK(wxSpecGrid::OnRightDown)
   EVT_GRID_SELECT_CELL(wxSpecGrid::OnSelectCell)
   EVT_GRID_BLOBEDIT(wxID_ANY, wxSpecGrid::OnBlodEdit)
END_EVENT_TABLE()
/*---------------------------------------------------------------------------*/
wxString wxSpecGrid::GetDataBlock(const wxGridCellCoords& topleft,
                                  const wxGridCellCoords& bottomright)
{
   wxString tmp;
   for (int r = topleft.GetRow(); r < bottomright.GetRow() + 1; r++)
   {
      for (int c = topleft.GetCol(); c < bottomright.GetCol() + 1; c++)
      {
         tmp += GetCellValue(r, c);
         if (c != bottomright.GetCol())
            tmp += _T("\t");
      }
      if (r != bottomright.GetRow())
         tmp += _T("\r\n");
   }
   return tmp;
}
/*---------------------------------------------------------------------------*/
wxString wxSpecGrid::GetDataBlock(const wxArrayOfCellsBlock& array)
{
   wxString tmp;
   size_t count;

   count = array.GetCount();
   for (size_t i =  0; i < count; i++)
   {
      tmp += GetDataBlock(array[i].GetLeftTop(), array[i].GetRightBottom());
      tmp += _T("\r\n");
   }

   return tmp;
}
/*---------------------------------------------------------------------------*/
void wxSpecGrid::OnCopy(wxCommandEvent& event)
{
  wxUnusedVar(event);
   wxString tmp;
   wxArrayOfCellsBlock array;
   wxGridCellCoordsArray coordsArray = GetSelectedCells();
   wxGridCellCoordsArray blocksTopLeft = GetSelectionBlockTopLeft();
   wxGridCellCoordsArray blocksBottomRight = GetSelectionBlockBottomRight();
   wxArrayInt cols = GetSelectedCols();
   wxArrayInt rows = GetSelectedRows();

   for (size_t i = 0; i < cols.GetCount(); i++)
      array.Add(wxCellsBlock(cols[i], 0, cols[i], GetNumberRows() - 1));
   for (size_t i = 0; i < rows.GetCount(); i++)
      array.Add(wxCellsBlock(0, rows[i], GetNumberCols() - 1, rows[i]));
   for (size_t i =  0; i < coordsArray.GetCount(); i++)
      array.Add(wxCellsBlock(coordsArray[i], coordsArray[i]));
   for (size_t i =  0; i < blocksTopLeft.GetCount(); i++)
      array.Add(wxCellsBlock(blocksTopLeft[i], blocksBottomRight[i]));

   array.Sort(wxCompCellsBlock);

   tmp = GetDataBlock(array);

   if (!tmp.IsEmpty())
      if (wxTheClipboard->Open())
      {
         wxTheClipboard->SetData(new wxTextDataObject(tmp));
         wxTheClipboard->Close();
      }
}
/*---------------------------------------------------------------------------*/
void wxSpecGrid::OnCopyUpdate(wxUpdateUIEvent& event)
{
   event.Enable(IsSelection());
}
/*---------------------------------------------------------------------------*/
void wxSpecGrid::OnSelectAll(wxCommandEvent& event)
{
  wxUnusedVar(event);
   SelectAll();
}
/*---------------------------------------------------------------------------*/
void wxSpecGrid::OnSelectAllUpdate(wxUpdateUIEvent& event)
{
   event.Enable(GetNumberRows() > 0);
}
/*---------------------------------------------------------------------------*/
void wxSpecGrid::OnRightDown(wxGridEvent& event)
{
  wxUnusedVar(event);
   wxMenu* popMenu = CreateRightMenu();
   if (popMenu)
   {
      PopupMenu(popMenu);
      delete popMenu;
   }
}
/*---------------------------------------------------------------------------*/
wxMenu* wxSpecGrid::CreateRightMenu()
{
   wxMenu* menu = new wxMenu;
   menu->Append(wxID_COPY, _("C&opy"), _("Copy the selected text"), wxITEM_NORMAL);
   menu->AppendSeparator();
   menu->Append(wxID_SELECTALL, _("Select &All"), _T(""), wxITEM_NORMAL);
   return menu;
}
/*---------------------------------------------------------------------------*/
void wxSpecGrid::OnSelectCell(wxGridEvent& event)
{
   SetDefaultSelection(event.GetRow(), event.GetCol());
   event.Skip();
}
/*---------------------------------------------------------------------------*/
void wxSpecGrid::OnBlodEdit(wxGridCellBlobEditorEvent& event)
{
   wxGridSQLite3Table* pGridSQLite3Table;
   wxMemoryBuffer* buffer;

   pGridSQLite3Table = wxDynamicCast(GetTable(), wxGridSQLite3Table);
   if (pGridSQLite3Table &&
       pGridSQLite3Table->GetBlob(event.GetRow(), event.GetCol(), buffer))
   {
      if (buffer)
      {
         wxBlobDialog BlobDlg(wxGetApp().GetTopWindow());

         BlobDlg.SetBlob(buffer);
         BlobDlg.ShowModal();
      }
      else
         wxMessageBox(_T("The value is NULL!"), _T("Blob"));
   }
}
/*---------------------------------------------------------------------------*/
void wxSpecGrid::SetDefaultSelection(int row, int col)
{
   if (!IsSelection())
   {
      int c1, c2;

      if (row == -1)
      {
         row = GetGridCursorRow();
         if ((row == -1)&&(GetNumberRows() > 0))
            row = 0;
      }
      if (col == -1)
      {
         col = GetGridCursorCol();
         if ((col == -1)&&(GetNumberCols() > 0))
            col = 0;
      }

      if (GetSelectionMode() == wxGrid::wxGridSelectCells)
         c1 = c2 = col;
      else
      {
         c1 = 0;
         c2 = GetNumberCols() - 1;
      }
      SelectBlock(row, c1, row, c2);
   }
}
/*---------------------------------------------------------------------------*/
bool wxSpecGrid::HasFocus()
{
   wxWindow* window = FindFocus();

   return (window && ((window == this)||(window == GetGridWindow())||
           (window == GetGridRowLabelWindow())||(window == GetGridColLabelWindow())||
           (window == GetGridCornerLabelWindow())));
}
/*---------------------------------------------------------------------------*/
IMPLEMENT_DYNAMIC_CLASS(wxDataGrid, wxSpecGrid)

BEGIN_EVENT_TABLE(wxDataGrid, wxSpecGrid)
   EVT_MENU(ID_MNU_FILTER, wxDataGrid::OnFilter)
   EVT_UPDATE_UI(ID_MNU_FILTER, wxDataGrid::OnFilterSortUpdate)
   EVT_MENU(ID_MNU_SORT, wxDataGrid::OnSort)
   EVT_UPDATE_UI(ID_MNU_SORT, wxDataGrid::OnFilterSortUpdate)
   EVT_MENU(ID_MNU_REFRESH, wxDataGrid::OnRefresh)
END_EVENT_TABLE()
/*---------------------------------------------------------------------------*/
void wxDataGrid::SetDbTableViewName(wxSQLite3Database* db,
                                    const wxString objectname,
                                    const wxString& base)
{
   m_db = db;
   m_Base = base;
   m_TableViewName = objectname;
}
/*---------------------------------------------------------------------------*/
void wxDataGrid::DoRefresh(bool usefilter)
{
   if (!m_db || m_TableViewName.IsEmpty())
      return;

   wxString sql, basename;
   wxSQLite3ResultSet resultSet;
   wxGridSQLite3TableBase* table;
   wxColour oddColour(wxGetApp().GetParamStr(PARAM_ODDROWCOLOR));

   if (m_Base != wxEmptyString)
      basename = m_Base;
   else
      basename = _T("main");
   try
   {  // remplissage de la grille des donnes
      sql = wxString::Format(_T("SELECT * FROM %s.%s"), basename.c_str(),
                             m_TableViewName.c_str());
      m_IsFiltered = m_IsSorted = false;
      if (usefilter)
      {
         if (!m_StringWhere.IsEmpty())
         {
            m_IsFiltered = true;
            sql += _T(" WHERE ") + m_StringWhere;
         }
         for (size_t i = 0; i < m_StringsOrder.Count(); i++)
         {
            if (i == 0)
            {
               m_IsSorted = true;
               sql += _T(" ORDER BY ");
            }
            else
               sql += _T(", ");
            sql += m_StringsOrder[i];
         }
      }
      sql += _T(";");
      resultSet = m_db->ExecuteQuery(ToUTF8(sql));
      SetTable(&g_EmptyTable);
      ForceRefresh();
      table = new wxGridSQLite3Table(&resultSet);
      table->SetAttrProvider(new OddRowsGridCellAttrProvider(oddColour));
      SetTable((wxGridTableBase*)table, true);
      table->AdaptColumnsSize();
      SetDefaultSelection();
      ForceRefresh();
      resultSet.Finalize();
   }
   catch(wxSQLite3Exception& ex)
   {
      wxGetApp().ShowError(_T("Refresh"), ex);
   }
}
/*---------------------------------------------------------------------------*/
void wxDataGrid::DoSort()
{
   wxSortDialog dlgSort(this);

   dlgSort.SetDatabase(m_db, m_Base);
   dlgSort.SetTable(m_TableViewName);
   dlgSort.SetStringsOrder(m_StringsOrder);

   if (dlgSort.ShowModal() == wxID_OK)
   {
      m_StringsOrder = dlgSort.GetStringsOrder();
      DoRefresh(true);
   }
}
/*---------------------------------------------------------------------------*/
void wxDataGrid::DoFilter()
{
   wxFilterDialog dlgFilter(this);

   dlgFilter.SetDatabase(m_db, m_Base);
   dlgFilter.SetTable(m_TableViewName);
   dlgFilter.SetStatement(m_StringWhere);

   if (dlgFilter.ShowModal() == wxID_OK)
   {
      m_StringWhere = dlgFilter.GetStatement();
      DoRefresh(true);
   }
}
/*---------------------------------------------------------------------------*/
void wxDataGrid::OnFilter(wxCommandEvent& event)
{
  wxUnusedVar(event);
   DoFilter();
}
/*---------------------------------------------------------------------------*/
void wxDataGrid::OnSort(wxCommandEvent& event)
{
  wxUnusedVar(event);
   DoSort();
}
/*---------------------------------------------------------------------------*/
void wxDataGrid::OnRefresh(wxCommandEvent& event)
{
  wxUnusedVar(event);
   DoRefresh(true);
}
/*---------------------------------------------------------------------------*/
void wxDataGrid::OnFilterSortUpdate(wxUpdateUIEvent& event)
{
   event.Skip();
}
/*---------------------------------------------------------------------------*/
wxMenu* wxDataGrid::CreateRightMenu()
{
   wxMenu* menu = wxSpecGrid::CreateRightMenu();

   menu->AppendSeparator();
   menu->Append(ID_MNU_FILTER, _("&Filter..."), wxEmptyString, wxITEM_NORMAL);
   menu->Append(ID_MNU_SORT, _("&Sort..."), wxEmptyString, wxITEM_NORMAL);
   menu->AppendSeparator();
   menu->Append(ID_MNU_REFRESH, _("&Refresh"), wxEmptyString, wxITEM_NORMAL);
   return menu;
}
/*---------------------------------------------------------------------------*/
wxGridCellBlobRenderer::wxGridCellBlobRenderer(bool displaynullvalue,
                                               const wxString& defaultstring)
{
   m_IsNullValueDisplayed = displaynullvalue;
   m_DefaultString = defaultstring;
   if (defaultstring == wxEmptyString)
      m_DefaultString = _T("(blob)");
}
/*---------------------------------------------------------------------------*/
wxString wxGridCellBlobRenderer::GetString(const wxGrid& grid, int row, int col)
{
   wxString text;

   text = m_DefaultString;
   if (grid.GetTable()->IsEmptyCell(row, col))
   {
      if (m_IsNullValueDisplayed)
         text = _T("(null)");
      else
         text = wxEmptyString;
   }
   return text;
}
/*---------------------------------------------------------------------------*/
void wxGridCellBlobRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
                             const wxRect& rect, int row, int col,
                             bool isSelected)
{
   int hAlign, vAlign;
   wxRect l_rect;

   // wxGridCellStringRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
   wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);

   SetTextColoursAndFont(grid, attr, dc, isSelected);

   // draw the text right aligned by default
   attr.GetAlignment(&hAlign, &vAlign);
   hAlign = wxALIGN_LEFT;

   l_rect = rect;
   l_rect.Inflate(-1);


   grid.DrawTextRectangle(dc, GetString(grid, row, col), l_rect, hAlign, vAlign);

}
/*---------------------------------------------------------------------------*/
wxSize wxGridCellBlobRenderer::GetBestSize(wxGrid& grid, wxGridCellAttr& attr,
                                           wxDC& dc, int row, int col)
{
    return DoGetBestSize(attr, dc, GetString(grid, row, col));
}
/*---------------------------------------------------------------------------*/
BEGIN_EVENT_TABLE(wxGridCellBlobEditor, wxEvtHandler)
   EVT_BUTTON(wxID_ANY, wxGridCellBlobEditor::OnBtnClick)
END_EVENT_TABLE()
/*---------------------------------------------------------------------------*/
wxGridCellBlobEditor::wxGridCellBlobEditor() : wxGridCellEditor(), wxEvtHandler()
{
   m_Row = m_Col = 0;
   m_Grid = NULL;
}
/*---------------------------------------------------------------------------*/
void wxGridCellBlobEditor::Create(wxWindow* parent, wxWindowID id,
                          wxEvtHandler* evtHandler)
{
   m_control = new wxButton(parent, id, _T("..."), wxDefaultPosition,
                            wxDefaultSize, wxBU_EXACTFIT);

   wxGridCellEditor::Create(parent, id, evtHandler);
}
/*---------------------------------------------------------------------------*/
void wxGridCellBlobEditor::PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr)
{
   // erase the background because we might not fill the cell
   wxClientDC dc(m_control->GetParent());
   wxWindow* gridWindow = wxDynamicCast(m_control->GetParent(), wxWindow);
   if (gridWindow)
   {
      wxGrid* grid = wxDynamicCast(gridWindow->GetParent(), wxGrid);
      if (grid)
      {
         grid->PrepareDC(dc);

         wxGridCellEditor::PaintBackground(rectCell, attr);

         wxGridCellRenderer *renderer = attr->GetRenderer(grid, m_Row, m_Col);
         renderer->Draw(*grid, *attr, dc, rectCell, m_Row, m_Col, false);
         renderer->DecRef();
      }
   }
   else
      wxGridCellEditor::PaintBackground(rectCell, attr);
   // redraw the control we just painted over
   m_control->Refresh();
}
/*---------------------------------------------------------------------------*/
void wxGridCellBlobEditor::BeginEdit(int row, int col, wxGrid* grid)
{
   wxASSERT_MSG(m_control,
                wxT("The wxGridCellBlobEditor must be created first!"));

   m_Row = row;
   m_Col = col;
   m_Grid = grid;

   m_control->PushEventHandler(this);

   m_control->SetFocus();

}
/*---------------------------------------------------------------------------*/
#if wxCHECK_VERSION(2,9,0)
bool wxGridCellBlobEditor::EndEdit(int row, int col, const wxGrid* grid,
                                   const wxString& oldval, wxString* newval)
{
  wxUnusedVar(row);
  wxUnusedVar(col);
  wxUnusedVar(grid);
  wxUnusedVar(oldval);
  wxUnusedVar(newval);
  m_control->PopEventHandler();

   m_Row = m_Col = 0;
   m_Grid = NULL;

   return false;
}

void wxGridCellBlobEditor::ApplyEdit(int row, int col, wxGrid* grid)
{
  wxUnusedVar(row);
  wxUnusedVar(col);
  wxUnusedVar(grid);
}
#else
bool wxGridCellBlobEditor::EndEdit(int row, int col, wxGrid* grid)
{
  wxUnusedVar(row);
  wxUnusedVar(col);
  wxUnusedVar(grid);
  m_control->PopEventHandler();

  m_Row = m_Col = 0;
  m_Grid = NULL;

  return false;
}
#endif

/*---------------------------------------------------------------------------*/
void wxGridCellBlobEditor::Reset()
{
   // do nothing
}
/*---------------------------------------------------------------------------*/
wxGridCellEditor* wxGridCellBlobEditor::Clone() const
{
   wxGridCellBlobEditor* editor = new wxGridCellBlobEditor;

   return editor;
}
/*---------------------------------------------------------------------------*/
wxString wxGridCellBlobEditor::GetValue() const
{
   return wxEmptyString;
}
/*---------------------------------------------------------------------------*/
void wxGridCellBlobEditor::SetSize(const wxRect& rectOrig)
{
   wxRect rect(rectOrig);

   // Make the edit control large enough to allow for internal margins
   //
   // TODO: remove this if the text ctrl sizing is improved esp. for unix
   //
#if defined(__WXGTK__)
   if (rect.x != 0)
   {
      rect.x += 1;
      rect.y += 1;
      rect.width -= 1;
      rect.height -= 1;
   }
#elif defined(__WXMSW__)
   if (rect.x == 0)
      rect.x += 2;
   else
      rect.x += 3;

   if (rect.y == 0)
      rect.y += 2;
   else
      rect.y += 3;

   rect.width -= 2;
   rect.height -= 2;
#else
   int extra_x = (rect.x > 2) ? 2 : 1;
   int extra_y = (rect.y > 2) ? 2 : 1;

   #if defined(__WXMOTIF__)
   extra_x *= 2;
   extra_y *= 2;
   #endif

   rect.SetLeft(wxMax(0, rect.x - extra_x));
   rect.SetTop(wxMax(0, rect.y - extra_y));
   rect.SetRight(rect.GetRight() + 2 * extra_x);
   rect.SetBottom(rect.GetBottom() + 2 * extra_y);
#endif
   wxSize size = m_control->GetBestSize();

   if (rect.width > size.GetWidth())
   {
      rect.x += rect.width - size.GetWidth();
      rect.width = size.GetWidth();
   }
   wxGridCellEditor::SetSize(rect);
}
/*---------------------------------------------------------------------------*/
void wxGridCellBlobEditor::OnBtnClick(wxCommandEvent& event)
{
  wxUnusedVar(event);
   if (m_Grid)
   {
      wxGridCellBlobEditorEvent evt;
      evt.SetEventType(wxEVT_GRID_BLOBEDIT);
      evt.SetId(m_Grid->GetId());
      evt.SetRow(m_Row);
      evt.SetCol(m_Col);
      evt.SetGrid(m_Grid);

      m_Grid->GetEventHandler()->ProcessEvent(evt);
   }

}
/*---------------------------------------------------------------------------*/
DEFINE_EVENT_TYPE(wxEVT_GRID_BLOBEDIT)

IMPLEMENT_DYNAMIC_CLASS(wxGridCellBlobEditorEvent, wxNotifyEvent)
/*---------------------------------------------------------------------------*/
wxGridCellBlobEditorEvent::wxGridCellBlobEditorEvent(wxEventType commandType,
                                                     int id) :
                           wxNotifyEvent(commandType, id)
{
   m_Row = m_Col = 0;
   m_Grid = NULL;
}
/*---------------------------------------------------------------------------*/
wxGridCellBlobEditorEvent::wxGridCellBlobEditorEvent(const wxGridCellBlobEditorEvent& event)
{
   m_Row = event.m_Row;
   m_Col = event.m_Col;
   m_Grid = event.m_Grid;
}
/*---------------------------------------------------------------------------*/