//------------------------------------------------------------------------------ // custom grid implementation //------------------------------------------------------------------------------ CustomGrid::CustomGrid( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) : wxGrid( parent, id, pos, size, style, name ) { //create grid SetTable( new wxGridStringTable(0, 0), true, wxGridSelectRows ); //some general settings EnableEditing( false ); EnableGridLines( true ); EnableDragGridSize( false ); SetMargins( 0, 0 ); EnableDragColMove( false ); EnableDragColSize( false ); EnableDragRowSize( false ); //init rows pref wxFileConfig *pConf = GetOCPNConfigObject(); if (pConf) { pConf->SetPath(_T("/Settings/GRIB")); m_IsDigit = pConf->Read(_T("GribDataTableRowPref"), _T("XXX")); } if( m_IsDigit.Len() != wxString(_T("XXX")).Len() ) m_IsDigit = _T("XXX"); //create structure for all numerical rows for( unsigned int i = 0; i < m_IsDigit.Len(); i++ ){ m_NumRow.push_back(wxNOT_FOUND); m_NumRowVal.push_back(std::vector <double>()); } //init labels attr wxFont labelfont = GetOCPNGUIScaledFont_PlugIn( _T("Dialog") ).MakeBold(); SetLabelFont(labelfont); wxColour colour; GetGlobalColor(_T("DILG0"), &colour); SetLabelBackgroundColour(colour); //set row label size int w; GetTextExtent( _T("Ab"), &w, NULL, 0, 0, &labelfont); double x = (double)w * 6.5; SetRowLabelSize((int)x); //colour settings GetGlobalColor(_T("GREEN1"), &m_greenColour); GetGlobalColor(_T("DILG1"), &m_greyColour); #ifdef __WXOSX__ m_bLeftDown = false; #endif //connect events at dialog level Connect(wxEVT_SCROLLWIN_THUMBTRACK, wxScrollEventHandler( CustomGrid::OnScroll ), NULL, this ); Connect(wxEVT_SIZE, wxSizeEventHandler( CustomGrid::OnResize ), NULL, this ); Connect(wxEVT_GRID_LABEL_LEFT_CLICK, wxGridEventHandler( CustomGrid::OnLabeClick ), NULL, this ); //connect events at grid level GetGridWindow()->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler( CustomGrid::OnMouseEvent ), NULL, this ); GetGridWindow()->Connect(wxEVT_LEFT_UP, wxMouseEventHandler( CustomGrid::OnMouseEvent ), NULL, this ); GetGridWindow()->Connect(wxEVT_MOTION, wxMouseEventHandler( CustomGrid::OnMouseEvent ), NULL, this ); //timer event m_tRefreshTimer.Connect(wxEVT_TIMER, wxTimerEventHandler( CustomGrid::OnRefreshTimer ), NULL, this); }
GLIDebugVariableGrid::GLIDebugVariableGrid(wxWindow *parent, wxWindowID id, uint displayFlags, const wxPoint& pos, const wxSize& size, long style, const wxString& name): wxGrid(parent, id, pos, size, style, name), gridFlags(displayFlags), internalCellEditCounter(0) { //Create a drag target SetDropTarget(new GridDnDText(this)); //Create the grid of 3 columns CreateGrid(0, 3, wxGrid::wxGridSelectRows); //Set the label values SetColLabelValue(NAME_COLUMN_INDEX, wxT("Name")); SetColLabelValue(VALUE_COLUMN_INDEX, wxT("Value")); SetColLabelValue(TYPE_COLUMN_INDEX, wxT("Type")); SetColLabelAlignment(wxALIGN_CENTRE, wxALIGN_TOP); SetColLabelSize(17); //Set the column sizes SetColSize(NAME_COLUMN_INDEX, 125); SetColSize(VALUE_COLUMN_INDEX, 200); SetColSize(TYPE_COLUMN_INDEX, 115); //Turn off row labels SetRowLabelSize(0); //Turn off cell overflowing SetDefaultCellOverflow(false); //Setup default colours SetDefaultCellBackgroundColour(*wxWHITE); SetDefaultCellTextColour (*wxBLACK); SetGridLineColour (gridGrey); SetLabelBackgroundColour(gridGrey); SetLabelTextColour (*wxBLACK); }