/* make settings for the grid here instead in the constructor */ void CBOINCGridCtrl::Setup() { //make grid cursor invisible SetCellHighlightPenWidth(0); SetCellHighlightROPenWidth(0); //change default selection colours SetSelectionBackground(*wxLIGHT_GREY); SetSelectionForeground(*wxBLACK); // SetRowLabelSize(1);//hide row labels SetColLabelSize(20); //make header row smaller as default SetColLabelAlignment(wxALIGN_LEFT,wxALIGN_CENTER); EnableGridLines(false); EnableDragRowSize(false);//prevent the user from changing the row height with the mouse EnableDragCell(false); EnableEditing(false);//make the whole grid read-only SetDefaultCellBackgroundColour(*wxWHITE); #ifdef __WXMAC__ SetLabelFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); SetDefaultCellFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE)); #else SetLabelFont(*wxNORMAL_FONT); #endif this->SetScrollLineX(5); this->SetScrollLineY(5); }
LogMessagesViewer::LogMessagesViewer( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxGrid( parent, id, pos, size, style, name ), _timer( this ) { // grid CreateGrid( 0, 4 ); EnableEditing( false ); EnableGridLines( false ); EnableDragGridSize( false ); SetMargins( 0, 0 ); // columns //EnableDragColMove( false ); EnableDragColSize( true ); SetColLabelSize( 20 ); SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // rows EnableDragRowSize( true ); SetRowLabelSize( 40 ); SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // label appearance SetColLabelValue( 0, _T( "description" ) ); SetColLabelValue( 1, _T( "source" ) ); SetColLabelValue( 2, _T( "line" ) ); SetColLabelValue( 3, _T( "clock" ) ); // cell defaults SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); coca::getLogger().addHandler( *this ); _timer.Start( 200 ); }
//---------------------------------------------------------------------------------------- void DBGrid::OnModusBrowse(wxCommandEvent& WXUNUSED(event)) { b_EditModus = false; // Needed by PopupMenu EnableEditing(b_EditModus); // Deactivate in-place Editing UpdateDimensions(); // Redraw the Grid // wxLogMessage(_("-I-> DBGrid::OnModusBrowse() - End")); }
//------------------------------------------------------------------------------ // 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); }
void ctlResultGrid::fillGrid( PGresult * result ) { int rowCount = PQntuples( result ); int colCount = PQnfields( result ); // If this PGresult represents a non-query command // (like an INSERT), there won't be any columns in // the result set - just return if( colCount == 0 ) return; // Disable repaints to we don't flicker too much BeginBatch(); // Clear out the old results (if any) and resize // grid to match the result set if( GetNumberRows()) DeleteRows( 0, GetNumberRows()); if( GetNumberCols()) DeleteCols( 0, GetNumberCols()); AppendRows( rowCount ); AppendCols( colCount ); EnableEditing( false ); // Copy the column names from the result set into the column headers for( int col = 0; col < colCount; ++col ) SetColLabelValue( col, wxString( PQfname( result, col ), wxConvUTF8 )); // Now copy each value from the result set into the grid for( int row = 0; row < rowCount; ++row ) { for( int col = 0; col < colCount; ++col ) { if( PQgetisnull( result, row, col )) SetCellValue( row, col, wxT( "" )); else SetCellValue( row, col, wxString( PQgetvalue( result, row, col ), wxConvUTF8 )); } } // Resize each column to fit its content AutoSizeColumns( false ); // Enable repaints EndBatch(); }
ctlSQLResult::ctlSQLResult(wxWindow *parent, pgConn *_conn, wxWindowID id, const wxPoint &pos, const wxSize &size) : ctlSQLGrid(parent, id, pos, size) { conn = _conn; thread = 0; SetTable(new sqlResultTable(), true); EnableEditing(false); SetSizer(new wxBoxSizer(wxVERTICAL)); Connect(wxID_ANY, wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEventHandler(ctlSQLResult::OnGridSelect)); }
void THDContentGrid::Refresh() { // Update the table to account for current index state. BeginBatch(); // Give wxGrid ownership over the pointer, so it's destroyed at the proper time. table = new THDContentTable(model); ClearColumns(); SetTable(table, true); SetRowLabelSize(0); SetColLabelSize(0); EnableEditing(false); EnableDragRowSize(false); EnableDragColSize(false); if (GetNumberRows() > 0) { // Scroll by entire rows int rowSize = GetRowSize(0); if (rowSize > 0) SetScrollLineY(rowSize); // Size all columns for (int col = 0; col < table->columns.size(); col++) { THDContentColumn &colObj = table->columns[col]; wxClientDC dc(GetParent()); int width = colObj.visualizer->GetWidth(dc); SetColMinimalWidth(col, width); SetColSize(col, width); } } EndBatch(); }
LRESULT CUWPsWindow::Notify(HWND hWnd, WPARAM idFrom, NMHDR* nmhdr) { if ( nmhdr->code == TVN_SELCHANGED && ((NMTREEVIEW*)nmhdr)->action != TVC_UNKNOWN ) { s32 cuwpId = ((NMTREEVIEW*)nmhdr)->itemNew.lParam; if ( cuwpId >= 0 && cuwpId < 64 ) { if ( selectedCuwp == -1 ) EnableEditing(); selectedCuwp = cuwpId; } else { if ( selectedCuwp != -1 ) DisableEditing(); selectedCuwp = -1; } RefreshWindow(false); } return ClassWindow::Notify(hWnd, idFrom, nmhdr); }
//---------------------------------------------------------------------------------------- int DBGrid::OnTableView(wxString Table) { wxStopWatch sw; //--------------------------------------------------------------------------------------- int x,y,z; wxString Temp0; wxBeginBusyCursor(); SetDefaultCellFont(* pDoc->ft_Doc); //--------------------------------------------------------------------------------------- ct_BrowserDB = (db_Br+i_Which)->ct_BrowserDB; // Get the DSN Pointer //--------------------------------------------------------------------------------------- if (ct_BrowserDB) // Valid pointer (!= NULL) ? { // Pointer is Valid, use the wxDatabase Information for (x=0;x<ct_BrowserDB->numTables;x++) // go through the Tables { if (!wxStrcmp((ct_BrowserDB->pTableInf+x)->tableName,Table)) // is this our Table ? { // Yes, the Data of this Table shall be put into the Grid int ValidTable = x; // Save the Tablenumber (db_Br+i_Which)->OnSelect(Table,false); // Select * from "table" // Set the local Pointer to the Column Information we are going to use (db_Br+i_Which)->cl_BrowserDB = (ct_BrowserDB->pTableInf+x)->pColInf; if ((ct_BrowserDB->pTableInf+x)->pColInf) // Valid pointer (!= NULL) ? { // Pointer is Valid, Column Informationen sind Vorhanden int i = (db_Br+i_Which)->i_Records; // How many Records are there (db_Br+i_Which)->i_Which = ValidTable; // Still used ???? mj10777 if (i == 0) // If the Table is empty, then show one empty row i++; // wxLogMessage(_("\n-I-> DBGrid::OnTableView() : Vor CreateGrid")); CreateGrid(i,(ct_BrowserDB->pTableInf+x)->numCols); // Records , Columns for (y=0;y<(ct_BrowserDB->pTableInf+x)->numCols;y++) // Loop through the Fields { // The Field / Column name is used here as Row Titel SetColLabelValue(y,((ct_BrowserDB->pTableInf+x)->pColInf+y)->colName); SetColSize(y,95); } // for (y=0;y<(ct_BrowserDB->pTableInf+x)->numCols;y++) SetColSize(((ct_BrowserDB->pTableInf+x)->numCols-1),120); // Make the last Column Wider // The Grid has been created, now fill it for (z=0;z<(db_Br+i_Which)->i_Records;z++) // Loop through the Records { Temp0.Printf(_T("%06d"),z+1); SetRowLabelValue(z,Temp0); // Set Row Lable Value (db_Br+i_Which)->OnGetNext((ct_BrowserDB->pTableInf+ValidTable)->numCols,false); for (y=0;y<(ct_BrowserDB->pTableInf+ValidTable)->numCols;y++) // Loop through the Fields { // BrowserDB::OnGetNext Formats the field Value into tablename SetCellValue(z, y,((db_Br+i_Which)->cl_BrowserDB+y)->tableName); } #if wxUSE_STATUSBAR if (z % 50 == 0) { Temp0.Printf(_("-I-> DBGrid::OnTableView(%s) - Record %6d (from %d) has been read."),Table.c_str(),z,(db_Br+i_Which)->i_Records); pDoc->p_MainFrame->SetStatusText(Temp0, 0); } #endif // wxUSE_STATUSBAR } // for (z=0;z<(db_Br+i_Which)->i_Records;z++) Temp0.Printf(_("-I-> DBGrid::OnTableView(%s) - %6d Records have been read. - Time needed : %ld ms"),Table.c_str(),z,sw.Time()); wxLogMessage(Temp0); #if wxUSE_STATUSBAR pDoc->p_MainFrame->SetStatusText(Temp0, 0); #endif // wxUSE_STATUSBAR // The Grid has been filled, now leave goto Weiter; } // if ((ct_BrowserDB->pTableInf+x)->pColInf) else wxLogMessage(_("\n-E-> DBGrid::OnTableView() : Invalid Column Pointer : Failed")); } // if ((ct_BrowserDB->pTableInf+x)->tableType == "TABLE") } // for (x=0;x<ct_BrowserDB->numTables;x++) } // if (ct_BrowserDB) else wxLogMessage(_("\n-E-> DBGrid::OnTableView() : Invalid DSN Pointer : Failed")); //--------------------------------------------------------------------------------------- Weiter: EnableEditing(b_EditModus); // Deactivate in-place Editing wxEndBusyCursor(); //--------------------------------------------------------------------------------------- wxLogMessage(_("-I-> DBGrid::OnTableView() - End")); return 0; }