Beispiel #1
0
void ctlSQLGrid::AutoSizeColumn(int col, bool setAsMin, bool doLimit)
{
	ColKeySizeHashMap::iterator it = colSizes.find(GetColKeyValue(col));
	if (it != colSizes.end()) // Restore user-specified size
		SetColSize(col, it->second);
	else
		wxGrid::AutoSizeColumn(col, setAsMin);

	if (doLimit)
	{
		int newSize, oldSize;
		int maxSize, totalSize = 0, availSize;

		oldSize = GetColSize(col);
		availSize = GetClientSize().GetWidth() - GetRowLabelSize();
		maxSize = availSize / 2;
		for (int i = 0 ; i < GetNumberCols() ; i++)
			totalSize += GetColSize(i);

		if (oldSize > maxSize && totalSize > availSize)
		{
			totalSize -= oldSize;
			/* Shrink wide column to maxSize.
			 * If the rest of the columns are short, make sure to use all the remaining space,
			 *   but no more than oldSize (which is enough according to AutoSizeColumns())
			 */
			newSize = wxMin(oldSize, wxMax(maxSize, availSize - totalSize));
			SetColSize(col, newSize);
		}
	}
}
void CModifierSeqListView::OnSize(wxSizeEvent& event)
{
	BSLib::s32 wc = event.GetSize().GetWidth();
	BSLib::s32 colSize = wc * 0.25;
	SetColSize(0, colSize);
	SetColSize(1, colSize);
	SetColSize(2, colSize);
	SetColSize(3, colSize);
	DisableCellEditControl();
	event.Skip();
}
int wxDDGrid::StretchIt()
{
	int new_width = GetClientSize().GetWidth() - GetRowLabelSize() - 10;
	int fixedWidth = 0, numStretches = 0, numStretched = 0;

	for( int i = 0; i < GetNumberCols(); ++i )
	{
		if( sf[i] == 0 ) fixedWidth += GetColSize(i);
		else if( sf[i] < 0 )
		{
			AutoSizeColumn(i, false);
			fixedWidth += GetColSize(i);
		}
		else
		{
			numStretches += sf[i];
			numStretched += 1;
		}
	}

	// Now either we have space for normal layout or resort to wxGrid default behaviour
	if( numStretched && ((fixedWidth + numStretched * 10) < new_width) )
	{
		int stretchSpace = (new_width - fixedWidth) / numStretches;
		//BeginBatch();
		int i, max = GetNumberCols();
		for(i = 0; i < max; ++i )
			if( sf[i] > 0 )
				SetColSize(i, stretchSpace * sf[i]);
		//EndBatch();
		return 1;
	}
	return 0;
}
Beispiel #4
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();
}
Beispiel #5
0
void ctPropertyEditorGrid::OnSize(wxSizeEvent& event)
{
    if (m_stretchableColumn != -1)
    {
        // This window's client size = the internal window's
        // client size if it has no borders
        wxSize sz = GetClientSize();

        int totalSize = 0;
        int i;
        for (i = 0; i < GetNumberCols(); i ++)
        {
            if (i != m_stretchableColumn)
            {
                totalSize += GetColSize(i);
            }
        }

        // Allow for grid lines
        totalSize += 1;

        int stretchSize = wxMax(5, sz.x - totalSize);
        SetColSize(m_stretchableColumn, stretchSize);
    }

    event.Skip();
}
void ProdRestartGridCtrl::ResetGrid()
{
  static const int maxRestart = 16;
  productionRestartTimes.ReAlloc(maxRestart);

  SetRowCount(maxRestart  + 1);
  SetColCount(2);

  SetCenteredText(0, 1, "Restart Time" );

  CString sRowHeader;
  for (int i = 0; i < maxRestart; i++)
  {
    int row = i + 1;
    sRowHeader.Format("%d", row);
    SetCenteredText(row, 0, sRowHeader );

    if (i > productionRestartTimes.UpperBound())
      productionRestartTimes[i] = nullReal;

    SetCell(row, 1, new ProdRestartTimeGridCell(i));
  }

  SetEditMode();
  SetBorderThickness(4);
  AutoSize();
  SetColSize(1, GetColSize(1) + 15);

  UpdateAllRows();
}
Beispiel #7
0
void GridViewGridControl::UpdateGridData()
{
    for (int i = 1; i < GetRowCount(); i++)
    {
        for (int j = 1; j < GetColCount(); j++)
        {
            CGridCell* pCell = GetCell(i, j);
            pCell->UpdateText();
        }
    }


    AutoSize();
    int maxSize = GetColSize(1);
    for (int i = 2; i < GetColCount(); i++)
    {
        int colSize = GetColSize(i);
        if (colSize > maxSize)
            maxSize= colSize;
    }

    maxSize += 5;
    for (int i = 1; i < GetColCount(); i++)
        SetColSize(i, maxSize);

    InvalidateAll();
}
//---------------------------------------------------------
void CVIEW_Table_Control::On_Size(wxSizeEvent &event)//&WXUNUSED(event))
{
	if( m_Field_Offset && GetNumberCols() && GetClientSize().x > GetRowLabelSize() )
	{
		SetColSize(0, GetClientSize().x - GetRowLabelSize());
	}

	event.Skip();
}
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);
}
Beispiel #10
0
Threads::Threads(wxWindow *parent)
	: wxGrid(parent, wxID_ANY)
	, numThreads(0)
	, activeThread(0)
{
	CreateGrid(0, 2);
	HideRowLabels();

	// Add the headers.
	SetColLabelValue(0, "PID");
	SetColLabelValue(1, "Name");
	SetColSize(0, 40);
	SetColSize(1, 160);

	// tmp
	AddThread("123", "main_thread");
	AddThread("6001", "worker_pool_0");
	AddThread("6013", "worker_pool_1");

	UpdateActiveThread();
}
//---------------------------------------------------------
void CActive_Attributes_Control::On_Size(wxSizeEvent &event)//&WXUNUSED(event))
{
	if( m_Field_Offset )	// feature attributes
	{
		if( GetNumberCols() > 0 && GetClientSize().x > GetRowLabelSize() )
		{
			SetColSize(0, GetClientSize().x - GetRowLabelSize());
		}
	}

	event.Skip();
}
Beispiel #12
0
    void  ColorMapGridControl::UpdateColSize()
    {
        AutoSize();
        int maxSize = GetColSize(1);
        int i;
        for (i = 2; i < GetColCount(); i++)
            {
                int colSize = GetColSize(i);
                if (colSize > maxSize)
                    maxSize= colSize;
            }

        maxSize += 5;
        for (i = 1; i < GetColCount(); i++)
            SetColSize(i, maxSize);
    }
/* restores column widths and sorting attributes */
bool CBOINCGridCtrl::OnRestoreState(wxConfigBase* pConfig) {
    wxString    strBaseConfigLocation = wxEmptyString;
    wxInt32     iIndex = 0;
    wxInt32     iTempValue = 0;
	wxInt32		iColumnCount = GetCols();

    wxASSERT(pConfig);

    // Retrieve the base location to store configuration information
    // Should be in the following form: "/Projects/"
    strBaseConfigLocation = pConfig->GetPath() + wxT("/");

    // Cycle through the columns recording anything interesting
    for (iIndex = 0; iIndex < iColumnCount; iIndex++) {
        wxString label = GetColLabelValue(iIndex);
        // Don't restore width for hidden / invisible columns
        if (label.IsEmpty()) {
            continue;
        }
        pConfig->SetPath(strBaseConfigLocation + label);

        pConfig->Read(wxT("Width"), &iTempValue, -1);
        if (-1 != iTempValue) {
			SetColSize(iIndex, iTempValue);
        }
    }
	//read sorting
	pConfig->SetPath(strBaseConfigLocation);
	pConfig->Read(wxT("SortColumn"),&iTempValue,-1);
	if(-1 != iTempValue) {
		sortColumn = iTempValue;
	}
	pConfig->Read(wxT("SortAscending"),&iTempValue,-1);
	if(-1 != iTempValue) {
		sortAscending = iTempValue != 0 ? true : false;
	}

    return true;
}
Beispiel #14
0
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();
}
Beispiel #15
0
/** InitGridSizes
  *
  * Initializes the Grid Sizes
  */
void MemoryGrid::InitGridSizes()
{
    int w, h;
    GetClientSize(&w, &h);
    w -= 24;

    AutoSizeColumn(MemoryBinary);

    w -= GetColSize(MemoryBinary);

    SetColSize(MemoryInfo, 22);
    SetColSize(MemoryAddress, 8 * w / 75 - 8);
    SetColSize(MemoryHexadecimal, 8 * w / 75);
    SetColSize(MemoryDecimal, 10 * w / 75);
    //SetColSize(MemoryBinary, 25 * w / 100);
    SetColSize(MemoryLabel, 18 * w / 75);
    SetColSize(MemoryInstruction, 31 * w / 75 + 9);

    wxGridCellAttr* info = new wxGridCellAttr; info->SetReadOnly(); info->SetTextColour(*wxBLACK);
    info->SetRenderer(new GridCellInfoRenderer());
    wxGridCellAttr* addr = new wxGridCellAttr; addr->SetReadOnly(); addr->SetTextColour(*wxBLACK);
    wxGridCellAttr* instr = new wxGridCellAttr; instr->SetTextColour(*wxBLACK);
    wxGridCellAttr* hex = new wxGridCellAttr; hex->SetTextColour(*wxBLUE);
    wxGridCellAttr* decimal = new wxGridCellAttr; decimal->SetTextColour(*wxRED);
    wxGridCellAttr* binary = new wxGridCellAttr; binary->SetTextColour(*wxWHITE); binary->SetBackgroundColour(wxTransparentColor);
    binary->SetRenderer(new GridCellBinaryRenderer());
    //binary->SetFont(wxFont( 10, 70, 90, wxFONTWEIGHT_BOLD, false, wxT("Courier New")));
    wxGridCellAttr* label = new wxGridCellAttr; label->SetTextColour(wxColour(64, 64, 64));

    SetColAttr(MemoryInfo, info);
    SetColAttr(MemoryAddress, addr);
    SetColAttr(MemoryHexadecimal, hex);
    SetColAttr(MemoryDecimal, decimal);
    SetColAttr(MemoryBinary, binary);
    SetColAttr(MemoryLabel, label);
    SetColAttr(MemoryInstruction, instr);
}
//---------------------------------------------------------
bool CActive_Attributes_Control::Update_Table(void)
{
	if( GetBatchCount() > 0 )
	{
		return( false );
	}

	BeginBatch();

	//-----------------------------------------------------
	int	Difference	= (m_pTable->Get_Field_Count() - m_Field_Offset) - GetNumberCols();

	if( Difference > 0 )
	{
		AppendCols(Difference);
	}
	else if( (Difference = -Difference < GetNumberCols() ? -Difference : GetNumberCols()) > 0 )
	{	// here is (or was!?) a memory leak - solution: use own wxGridTableBase derived grid table class
		DeleteCols(0, Difference);
	}

	//-----------------------------------------------------
	for(int iCol=0, iField=m_Field_Offset; iField<m_pTable->Get_Field_Count(); iCol++, iField++)
	{
		SetColLabelValue(iCol, m_pTable->Get_Field_Name(iField));

		switch( m_pTable->Get_Field_Type(iField) )
		{
		default:
		case SG_DATATYPE_Byte:
		case SG_DATATYPE_Char:
		case SG_DATATYPE_String:
		case SG_DATATYPE_Date:
		case SG_DATATYPE_Binary:
			SetColFormatCustom(iCol, wxGRID_VALUE_STRING);
			break;

		case SG_DATATYPE_Bit:
		case SG_DATATYPE_Word:
		case SG_DATATYPE_Short:
		case SG_DATATYPE_DWord:
		case SG_DATATYPE_Int:
		case SG_DATATYPE_ULong:
		case SG_DATATYPE_Long:
		case SG_DATATYPE_Color:
			SetColFormatNumber(iCol);
			break;

		case SG_DATATYPE_Float:
		case SG_DATATYPE_Double:
			SetColFormatFloat(iCol);
			break;
		}
	}

	//-----------------------------------------------------
	if( (Difference = m_pTable->Get_Count() - GetNumberRows()) > 0 )
	{
		AppendRows(Difference);
	}
	else if( Difference < 0 && (Difference = -Difference < GetNumberRows() ? -Difference : GetNumberRows()) > 0 )
	{
		DeleteRows(0, Difference);
	}

	//-------------------------------------------------
	for(int iRecord=0; iRecord<m_pTable->Get_Count(); iRecord++)
	{
		_Set_Record(iRecord);
	}

	//-----------------------------------------------------
	if( GetNumberCols() > 0 && GetNumberRows() > 0 )
	{
		SetRowLabelSize(wxGRID_AUTOSIZE);

		if( m_Field_Offset )	// feature attributes
		{
			if( GetClientSize().x > GetRowLabelSize() )
			{
				SetColSize(0, GetClientSize().x - GetRowLabelSize());
			}
		}
		else					// grid cell values
		{
			AutoSizeColumns();
		}
	}

	Enable(GetNumberRows() > 0);

	m_pTable->Set_Modified(false);

	//-----------------------------------------------------
	EndBatch();

	return( true );
}
Beispiel #17
0
//----------------------------------------------------------------------------------------
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;
}
Beispiel #18
0
void TestZoneCurveGridCtrl::ResetTestZoneCurveGrid()
{
    // start with a clean slate
    sequence.SequenceCleanup();

    // set type strings
    curveTypeStrings.Alloc(6);
    curveTypeMap.Alloc(6);

    // always valid
    curveTypeStrings += "Pressure";
    curveTypeMap += TestZoneCurve::tzPressure;

    curveTypeStrings += "Flow";
    curveTypeMap += TestZoneCurve::tzFlowRate;

    if (testZoneTemperatureVaries && control.IsLiquid())
    {
        curveTypeStrings += "Temperature";
        curveTypeMap += TestZoneCurve::tzTemperature;
    }

    if (testZoneCompressibilityVaries && control.IsLiquid())
    {
        curveTypeStrings += "Compressibility";
        curveTypeMap += TestZoneCurve::tzCompressibility;
    }

    if (testZoneVolumeVaries)
    {
        curveTypeStrings += "Volume Change";
        curveTypeMap += TestZoneCurve::tzDeltaVolume;
        curveTypeStrings += "Volume";
        curveTypeMap += TestZoneCurve::tzAbsVolume;
    }

    // curve file desigs
    if (control.UseCurveFiles())
    {
        nsCurveFileStatics::testZoneBCCurveFile.GetIDs(curveFileDesigStrings);
    }
    else
    {
        curveFOOK = AppMenuC::GetFuncObjList(typeid(DO_Curve), curveFOStrings, curveFOData, "   ");
    }

    // and sequences
    sequence.GetSequenceIDs(sequenceDesigStrings);


    // make sure there are 20 blanks
    testZoneCurves.ReAlloc(testZoneCurves.Size() + 20);
    SetRowCount(testZoneCurves.AllocSize() + 1);
    SetColCount(6);

    SetCenteredText(0, 1, "Type" );
    if (control.UseCurveFiles())
        SetCenteredText(0, 2, "Curve ID" );
    else
        SetCenteredText(0, 2, "Curve Object" );

    SetCenteredText(0, 3, "Start Sequence" );
    SetCenteredText(0, 4, "End Sequence" );
    SetCenteredText(0, 5, "Curve Data" );

    CString sRowHeader;
    for (int i = 0; i < testZoneCurves.AllocSize(); i++) {

        int row = i + 1;
        sRowHeader.Format("%d", row);
        SetCenteredText(row, 0, sRowHeader );

        SetCell(row, 1, new CurveTypeGridCell(i));
        if (control.UseCurveFiles())
            SetCell(row, 2, new CurveDesigGridCell(i));
        else
            SetCell(row, 2, new CurveFOGridCell(i));

        SetCell(row, 3, new StartSequenceDesigGridCell(i));
        SetCell(row, 4, new EndSequenceDesigGridCell(i));
        SetCell(row, 5, new TZDataGridCell(i));

        // reset all data
        for (int j = 1; j < 6; j++)
            ResetCell(i + 1, j);
    }

    SetEditMode();
    SetBorderThickness(4);
    AutoSize();
    for (int j = 1; j < 6; j++)
        SetColSize(j, GetColSize(j) + 15);

    InvalidateAll();
}
Beispiel #19
0
void ctlSQLResult::DisplayData(bool single)
{
	if (!thread || !thread->DataValid())
		return;

	if (thread->ReturnCode() != PGRES_TUPLES_OK)
		return;

	rowcountSuppressed = single;
	Freeze();

	/*
	 * Resize and repopulate by informing it to delete all the rows and
	 * columns, then append the correct number of them. Probably is a
	 * better way to do this.
	 */
	wxGridTableMessage *msg;
	sqlResultTable *table = (sqlResultTable *)GetTable();
	msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, GetNumberRows());
	ProcessTableMessage(*msg);
	delete msg;
	msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_COLS_DELETED, 0, GetNumberCols());
	ProcessTableMessage(*msg);
	delete msg;
	msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, NumRows());
	ProcessTableMessage(*msg);
	delete msg;
	msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_COLS_APPENDED, thread->DataSet()->NumCols());
	ProcessTableMessage(*msg);
	delete msg;

	if (single)
	{
		int w, h;
		if (colSizes.GetCount() == 1)
			w = colSizes.Item(0);
		else
			GetSize(&w, &h);

		colNames.Add(thread->DataSet()->ColName(0));
		colTypes.Add(wxT(""));
		colTypClasses.Add(0L);

		SetColSize(0, w);
	}
	else
	{
		wxString colName, colType;
		int w;

		size_t hdrIndex = 0;
		long col, nCols = thread->DataSet()->NumCols();

		for (col = 0 ; col < nCols ; col++)
		{
			colName = thread->DataSet()->ColName(col);
			colType = thread->DataSet()->ColFullType(col);
			colNames.Add(colName);
			colTypes.Add(colType);
			colTypClasses.Add(thread->DataSet()->ColTypClass(col));

			wxString colHeader = colName + wxT("\n") + colType;

			if (hdrIndex < colHeaders.GetCount() && colHeaders.Item(hdrIndex) == colHeader)
				w = colSizes.Item(hdrIndex++);
			else
				w = -1;

			SetColSize(col, w);
			if (thread->DataSet()->ColTypClass(col) == PGTYPCLASS_NUMERIC)
			{
				/*
				 * For numeric columns, set alignment to right.
				 */
				wxGridCellAttr *attr = new wxGridCellAttr();
				attr->SetAlignment(wxALIGN_RIGHT, wxALIGN_TOP);
				SetColAttr(col, attr);
			}
		}
	}
	Thaw();
}
Beispiel #20
0
void DataCaptureGridCtrl::ResetDataCaptureGrid()
{
  // start with a clean slate
  dataCapture.DataCaptureCleanup();

  // set type strings
  captureTypeStrings.Alloc(5);

  // always valid
  captureTypeStrings += "Pressure";
  captureTypeStrings += "Flow";
  captureTypeStrings += "Production";
  if (!control.IsGas())
    captureTypeStrings += "Test Zone";
  if (control.IsUnconfined())
    captureTypeStrings += "Water Table";

  pressureCapTypeStrings.Alloc(3);
  pressureCapTypeStrings += "Test Zone";
  pressureCapTypeStrings += "Observation Well";
  pressureCapTypeStrings += "Superposition";

  flowCapTypeStrings.Alloc(4);
  flowCapTypeStrings += "Well";
  flowCapTypeStrings += "Formation";
  flowCapTypeStrings += "Test Zone";
  flowCapTypeStrings += "Wellbore Storage";

  productionCapTypeStrings.Alloc(4);
  productionCapTypeStrings += "Well";
  productionCapTypeStrings += "Formation";
  productionCapTypeStrings += "Test Zone";
  productionCapTypeStrings += "Wellbore Storage";

  testZoneCapTypeStrings.Alloc(3);
  testZoneCapTypeStrings += "TZ Temp.";
  testZoneCapTypeStrings += "TZ Comp.";
  testZoneCapTypeStrings += "TZ Volume";

  waterTableCapTypeStrings.Alloc(1);
  waterTableCapTypeStrings += "Observation Well";

  int maxCol = 6;
  if (control.IsLayered())
  {
    maxCol++;
    wellboreZoneStrings.Alloc(layerSpec.GetNWellboreZone());
    for (int i = 0; i < wellBoreZones.Size(); i++)
    {
      const WellBoreZone& currZone = wellBoreZones[i];
      if (!currZone.zoneIsPacker)
        wellboreZoneStrings += currZone.intervalID;
    }
  }

  if (control.Is1DRadial())
    maxCol++;

  // make sure there are 20 blanks
  dataCaptureData.ReAlloc(dataCaptureData.Size() + 20);
  SetRowCount(dataCaptureData.AllocSize() + 1);
  SetColCount(maxCol);

  SetCenteredText(0, 1, "Well ID" );
  SetCenteredText(0, 2, "Output Type" );
  SetCenteredText(0, 3, "Sub-Type" );
  int nextCol = 4;
  if (control.IsLayered())
    SetCenteredText(0, nextCol++, "Wellbore Zone" );

  SetCenteredText(0, nextCol++, "Radius" );
  if (control.Is1DRadial())
    SetCenteredText(0, nextCol++, "RadiusUnits" );
  SetCenteredText(0, nextCol++, "Output Units" );

  CString sRowHeader;
  for (int i = 0; i < dataCaptureData.AllocSize(); i++) {

    int row = i + 1;
    sRowHeader.Format("%d", row);
    SetCenteredText(row, 0, sRowHeader );

    SetCell(row, 1, new DcapDesigGridCell(i));
    SetCell(row, 2, new CaptureTypeGridCell(i));
    SetCell(row, 3, new CaptureSubTypeGridCell(i));
    nextCol = 4;
    if (control.IsLayered())
      SetCell(row, nextCol++, new DcapWellboreZoneDesigGridCell(i));

    SetCell(row, nextCol++, new DataCaptureRadiusGridCell(i));

    if (control.Is1DRadial())
      SetCell(row, nextCol++, new RadUnitsGridCell(i));
    SetCell(row, nextCol++, new OutputUnitsGridCell(i));

    // reset all data
    for (int j = 1; j < maxCol; j++)
      ResetCell(i + 1, j);
  }

  SetEditMode();
  SetBorderThickness(4);
  AutoSize();
  for (int j = 1; j < maxCol; j++)
    SetColSize(j, GetColSize(j) + 15);

  InvalidateAll();
}
Beispiel #21
0
void ctlSQLGrid::AutoSizeColumns(bool setAsMin)
{
	wxCoord newSize, oldSize;
	wxCoord maxSize, totalSize = 0, availSize;
	int col, nCols = GetNumberCols();
	int row, nRows = GetNumberRows();
	colMaxSizes.Empty();

	/* We need to check each cell's width to choose best. wxGrid::AutoSizeColumns()
	 * is good, but looping through long result sets gives a noticeable slowdown.
	 * Thus we'll check every first 500 cells for each column.
	 */

	// First pass: auto-size columns
	for (col = 0 ; col < nCols; col++)
	{
		ColKeySizeHashMap::iterator it = colSizes.find(GetColKeyValue(col));
		if (it != colSizes.end()) // Restore user-specified size
		{
			newSize = it->second;
			colMaxSizes.Add(-1);
		}
		else
		{
			wxClientDC dc(GetGridWindow());
			newSize = 0;
			// get cells's width
			for (row = 0 ; row < wxMin(nRows, 500) ; row++)
			{
				wxSize size = GetBestSize(row, col);
				if ( size.x > newSize )
					newSize = size.x;
			}
			// get column's label width
			wxCoord w, h;
			dc.SetFont( GetLabelFont() );
			dc.GetMultiLineTextExtent( GetColLabelValue(col), &w, &h );
			if ( GetColLabelTextOrientation() == wxVERTICAL )
				w = h;

			if ( w > newSize )
				newSize = w;

			if (!newSize)
				newSize = GetRowLabelSize();
			else
				// leave some space around text
				newSize += 6;

			colMaxSizes.Add(newSize);
		}
		SetColSize(col, newSize);
		totalSize += newSize;
	}

	availSize = GetClientSize().GetWidth() - GetRowLabelSize();

	// Second pass: shrink wide columns if exceeded available width
	if (totalSize > availSize)
	{
		// A wide column shouldn't take up more than 50% of the visible space
		maxSize = availSize / 2;
		for (col = 0 ; col < nCols ; col++)
		{
			oldSize = GetColSize(col);
			// Is too wide and no user-specified size
			if (oldSize > maxSize && !(col < (int)colMaxSizes.GetCount() && colMaxSizes[col] == -1))
			{
				totalSize -= oldSize;
				/* Shrink wide column to maxSize.
				 * If the rest of the columns are short, make sure to use all the remaining space,
				 *   but no more than oldSize (which is enough according to first pass)
				 */
				newSize = wxMin(oldSize, wxMax(maxSize, availSize - totalSize));
				SetColSize(col, newSize);
				totalSize += newSize;
			}
		}
	}
}
Beispiel #22
0
bool CGridCMF::TransferDataToGrid()
{
  size_t n = m_vpSample.size();
  bool bRtn = (n > 0);
  if(bRtn)
  {

    // loop through samples

    const CLabSettings &lab(m_pFile->GetLabSettings());
    wxString sName;
    wxString sCat;
    COARsample *pSample;
    const CLabNameStrings *pNameStr;
    size_t i;

    for(i = 0; i < n; i++)
    {
      pSample = m_vpSample.at(i);

      // sample name and category

      sName = pSample->GetName();
      pNameStr = lab.GetLabStrings();
      if(pNameStr == NULL)
      {
        sCat = DEFAULT;
      }
      else
      {
        sCat = pNameStr->GetCategory(sName);
        if(sCat.IsEmpty())
        {
          sCat = DEFAULT;
        }
      }


      // now set cell values

      SetBoolValue((int)i,EXCLUDE,false);
      SetCellValue((int)i,SPECIMEN_TYPE,sCat);
      SetCellValue((int)i,SAMPLE,pSample->GetName());
      SetTextLength((int)i,SAMPLE,nwxXmlCMFSpecimen::LEN_SPECIMEN_ID);
      SetTextLength((int)i,SOURCE_ID,nwxXmlCMFSpecimen::LEN_SOURCE_ID);
      SetTextLength((int)i,CASE_ID,nwxXmlCMFSpecimen::LEN_CASE_ID);
      SetTextLength((int)i,COMMENT,nwxXmlCMFSpecimen::LEN_SPECIMEN_COMMENT);
    }
    UpdateEmptyLoci();
    nwxGrid::UpdateLabelSizes(this);
    AutoSizeColumn(EXCLUDE);
    AutoSizeColumn(SAMPLE);
    AutoSizeColumn(PARTIAL);

    // compute size of SPECIMENT_TYPE columns
    int nWidth = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
    const char *ps = CLabSpecimenCategory::LongestType();
    wxClientDC dc(this);
    dc.SetFont(GetDefaultCellFont());
    wxSize sz = dc.GetTextExtent(ps);
    if(!nWidth)
    {
      nWidth = 20;
    }
    nWidth += sz.GetWidth();
    nWidth += 6;
    SetColSize(SPECIMEN_TYPE,nWidth);
    sz = dc.GetTextExtent(
      "This is sample text to determine the width of the comment column.");
    nWidth = sz.GetWidth();
    nWidth += 2;
    SetColSize(COMMENT,nWidth);
  }
  return bRtn;
}