/* 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);
}
示例#2
0
void ctlSQLGrid::OnMouseWheel(wxMouseEvent &event)
{
	if (event.ControlDown() || event.CmdDown())
	{
		wxFont fontlabel = GetLabelFont();
		wxFont fontcells = GetDefaultCellFont();
		if (event.GetWheelRotation() > 0)
		{
			fontlabel.SetPointSize(fontlabel.GetPointSize() - 1);
			fontcells.SetPointSize(fontcells.GetPointSize() - 1);
		}
		else
		{
			fontlabel.SetPointSize(fontlabel.GetPointSize() + 1);
			fontcells.SetPointSize(fontcells.GetPointSize() + 1);
		}
		SetLabelFont(fontlabel);
		SetDefaultCellFont(fontcells);
		SetColLabelSize(fontlabel.GetPointSize() * 4);
		SetDefaultRowSize(fontcells.GetPointSize() * 2);
		for (int index = 0; index < GetNumberCols(); index++)
			SetColSize(index, -1);
		ForceRefresh();
	}
	else
		event.Skip();
}
示例#3
0
ctlSQLGrid::ctlSQLGrid(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size)
	: wxGrid(parent, id, pos, size, wxWANTS_CHARS | wxVSCROLL | wxHSCROLL)
{
	// Set cells font
	wxFont fntCells(settings->GetSQLFont());
	SetDefaultCellFont(fntCells);
	// Set labels font
	wxFont fntLabel(settings->GetSystemFont());
	fntLabel.SetWeight(wxBOLD);
	SetLabelFont(fntLabel);
	SetColLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
	SetRowLabelSize(50);
	SetDefaultRowSize(fntCells.GetPointSize() * 2);
	SetColLabelSize(fntLabel.GetPointSize() * 4);
	SetDefaultCellOverflow(false);

	Connect(wxID_ANY, wxEVT_GRID_LABEL_LEFT_DCLICK, wxGridEventHandler(ctlSQLGrid::OnLabelDoubleClick));
}
示例#4
0
文件: dbgrid.cpp 项目: gitrider/wxsj2
//----------------------------------------------------------------------------------------
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;
}