Exemplo n.º 1
0
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;
}
Exemplo n.º 2
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);
		}
	}
}
Exemplo n.º 3
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();
}
Exemplo n.º 4
0
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();
}
Exemplo n.º 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();
}
Exemplo n.º 6
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);
    }
Exemplo n.º 7
0
wxSize MultiDimGridGrid::DoGetBestSize() const
{
    // 100 is the default minimal size of a widget - taken from wx headers.
    int width  = std::max(GetRowLabelSize() + GetColSize(0), 100);
    int height = std::max(GetColLabelSize() + GetRowSize(0), 100);

    // The following is from the wx header file for wxScrollWindow:
    // Round up to a multiple the scroll rate NOTE: this still doesn't get rid
    // of the scrollbars, is there any magic incantaion for that?
    int xpu, ypu;
    GetScrollPixelsPerUnit(&xpu, &ypu);
    if(xpu)
        {
        width  += 1 + xpu - (width  % xpu);
        }
    if(ypu)
        {
        height += 1 + ypu - (height % ypu);
        }

    return wxSize(width, height);
}
Exemplo n.º 8
0
int ctlSQLResult::Execute(const wxString &query, int resultToRetrieve, wxWindow *caller, long eventId, void *data)
{
	colSizes.Empty();
	colHeaders.Empty();
	for (int col = 0 ; col < GetNumberCols() ; col++)
	{
		colSizes.Add(GetColSize(col));
		colHeaders.Add(this->GetColLabelValue(col));
	}

	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;

	Abort();

	colNames.Empty();
	colTypes.Empty();
	colTypClasses.Empty();

	thread = new pgQueryThread(conn, query, resultToRetrieve, caller, eventId, data);

	if (thread->Create() != wxTHREAD_NO_ERROR)
	{
		Abort();
		return -1;
	}

	((sqlResultTable *)GetTable())->SetThread(thread);

	thread->Run();
	return RunStatus();
}
Exemplo n.º 9
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);
}
Exemplo n.º 10
0
void ctlSQLGrid::OnGridColSize(wxGridSizeEvent &event)
{
	// Save key="index:label", value=size
	int col = event.GetRowOrCol();
	colSizes[GetColKeyValue(col)] = GetColSize(col);
}
Exemplo n.º 11
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;
			}
		}
	}
}
Exemplo n.º 12
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();
}
Exemplo n.º 13
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();
}