Beispiel #1
0
void ctlSQLGrid::OnLabelDoubleClick(wxGridEvent &event)
{
	int maxHeight, maxWidth;
	GetClientSize(&maxWidth, &maxHeight);
	int row = event.GetRow();
	int col = event.GetCol();

	int extent, extentWant = 0;

	if (row >= 0)
	{
		for (col = 0 ; col < GetNumberCols() ; col++)
		{
			extent = GetBestSize(row, col).GetHeight();
			if (extent > extentWant)
				extentWant = extent;
		}

		extentWant += EXTRAEXTENT_HEIGHT;
		extentWant = wxMax(extentWant, GetRowMinimalAcceptableHeight());
		extentWant = wxMin(extentWant, maxHeight * 3 / 4);
		int currentHeight = GetRowHeight(row);

		if (currentHeight >= maxHeight * 3 / 4 || currentHeight == extentWant)
			extentWant = GetRowMinimalAcceptableHeight();
		else if (currentHeight < maxHeight / 4)
			extentWant = wxMin(maxHeight / 4, extentWant);
		else if (currentHeight < maxHeight / 2)
			extentWant = wxMin(maxHeight / 2, extentWant);
		else if (currentHeight < maxHeight * 3 / 4)
			extentWant = wxMin(maxHeight * 3 / 4, extentWant);

		if (extentWant != currentHeight)
		{
			BeginBatch();
			if(IsCellEditControlShown())
			{
				HideCellEditControl();
				SaveEditControlValue();
			}

			SetRowHeight(row, extentWant);
			EndBatch();
		}
	}
	else if (col >= 0)
	{
		// Holding Ctrl or Meta switches back to automatic column's sizing
		if (event.ControlDown() || event.CmdDown())
		{
			colSizes.erase(GetColKeyValue(col));
			BeginBatch();
			if(IsCellEditControlShown())
			{
				HideCellEditControl();
				SaveEditControlValue();
			}
			AutoSizeColumn(col, false);
			EndBatch();
		}
		else // toggle between some predefined sizes
		{

			if (col < (int)colMaxSizes.GetCount() && colMaxSizes[col] >= 0)
				extentWant = colMaxSizes[col];
			else
			{
				for (row = 0 ; row < GetNumberRows() ; row++)
				{
					if (CheckRowPresent(row))
					{
						extent = GetBestSize(row, col).GetWidth();
						if (extent > extentWant)
							extentWant = extent;
					}
				}
			}

			extentWant += EXTRAEXTENT_WIDTH;
			extentWant = wxMax(extentWant, GetColMinimalAcceptableWidth());
			extentWant = wxMin(extentWant, maxWidth * 3 / 4);
			int currentWidth = GetColumnWidth(col);

			if (currentWidth >= maxWidth * 3 / 4 || currentWidth == extentWant)
				extentWant = GetColMinimalAcceptableWidth();
			else if (currentWidth < maxWidth / 4)
				extentWant = wxMin(maxWidth / 4, extentWant);
			else if (currentWidth < maxWidth / 2)
				extentWant = wxMin(maxWidth / 2, extentWant);
			else if (currentWidth < maxWidth * 3 / 4)
				extentWant = wxMin(maxWidth * 3 / 4, extentWant);

			if (extentWant != currentWidth)
			{
				BeginBatch();
				if(IsCellEditControlShown())
				{
					HideCellEditControl();
					SaveEditControlValue();
				}
				SetColumnWidth(col, extentWant);
				EndBatch();
				colSizes[GetColKeyValue(col)] = extentWant;
			}
		}
	}
}
Beispiel #2
0
void ctlSQLGrid::OnLabelDoubleClick(wxGridEvent &event)
{
	int maxHeight, maxWidth;
	GetClientSize(&maxWidth, &maxHeight);
	int row = event.GetRow();
	int col = event.GetCol();

	int extent, extentWant = 0;

	if (row >= 0)
	{
		for (col = 0 ; col < GetNumberCols() ; col++)
		{
			extent = GetBestSize(row, col).GetHeight();
			if (extent > extentWant)
				extentWant = extent;
		}

		extentWant += EXTRAEXTENT_HEIGHT;
		extentWant = wxMax(extentWant, GetRowMinimalAcceptableHeight());
		extentWant = wxMin(extentWant, maxHeight * 3 / 4);
		int currentHeight = GetRowHeight(row);

		if (currentHeight >= maxHeight * 3 / 4 || currentHeight == extentWant)
			extentWant = GetRowMinimalAcceptableHeight();
		else if (currentHeight < maxHeight / 4)
			extentWant = wxMin(maxHeight / 4, extentWant);
		else if (currentHeight < maxHeight / 2)
			extentWant = wxMin(maxHeight / 2, extentWant);
		else if (currentHeight < maxHeight * 3 / 4)
			extentWant = wxMin(maxHeight * 3 / 4, extentWant);

		if (extentWant != currentHeight)
		{
			BeginBatch();
			if(IsCellEditControlShown())
			{
				HideCellEditControl();
				SaveEditControlValue();
			}

			SetRowHeight(row, extentWant);
			EndBatch();
		}
	}
	else if (col >= 0)
	{
		for (row = 0 ; row < GetNumberRows() ; row++)
		{
			if (CheckRowPresent(row))
			{
				extent = GetBestSize(row, col).GetWidth();
				if (extent > extentWant)
					extentWant = extent;
			}
		}

		extentWant += EXTRAEXTENT_WIDTH;
		extentWant = wxMax(extentWant, GetColMinimalAcceptableWidth());
		extentWant = wxMin(extentWant, maxWidth * 3 / 4);
		int currentWidth = GetColumnWidth(col);

		if (currentWidth >= maxWidth * 3 / 4 || currentWidth == extentWant)
			extentWant = GetColMinimalAcceptableWidth();
		else if (currentWidth < maxWidth / 4)
			extentWant = wxMin(maxWidth / 4, extentWant);
		else if (currentWidth < maxWidth / 2)
			extentWant = wxMin(maxWidth / 2, extentWant);
		else if (currentWidth < maxWidth * 3 / 4)
			extentWant = wxMin(maxWidth * 3 / 4, extentWant);

		if (extentWant != currentWidth)
		{
			BeginBatch();
			if(IsCellEditControlShown())
			{
				HideCellEditControl();
				SaveEditControlValue();
			}
			SetColumnWidth(col, extentWant);
			EndBatch();
		}
	}
}