Пример #1
0
void ArrangeAlignment::UpdateState()
{
	// update target
	CGadgetID Target = ReadRadioGroup(TargetArea,TargetArea[0]);
	if (Target == _R(IDC_ALIGNDIALOG_TOSELECTION))
	{
		Align.target=ToSelection;
	}
	else if (Target == _R(IDC_ALIGNDIALOG_TOPAGE))
	{
		Align.target=ToPage;
	}
	//	WEBSTER-ranbirr-13/11/96
	#ifndef WEBSTER
	else if (Target == _R(IDC_ALIGNDIALOG_TOSPREAD))
	{
		Align.target=ToSpread;
	}
	#endif //webster
	else
	{
		ERROR3("ArrangeAlignment::UpdateState() - unknown target");
	}

	// read alignments from horizontal and vertical combo boxes
	Align.h = (AlignType)GetSelectedValueIndex(_R(IDC_ALIGNDIALOG_HORIZONTAL));
	Align.v = (AlignType)GetSelectedValueIndex(_R(IDC_ALIGNDIALOG_VERTICAL));
	
	// force the diagram to redraw
	InvalidateGadget(_R(IDC_ALIGNDIALOG_DIAGRAM));

	// set state of Apply button
	INT32 NumObjs = 0;
	if (Document::GetSelected())
		NumObjs = GetApplication()->FindSelection()->Count();
	BOOL ApplyButtonState = (NumObjs>0);
	if (NumObjs==1 && Target==_R(IDC_ALIGNDIALOG_TOSELECTION)) ApplyButtonState = FALSE;
	if (Align.h==AlignNone && Align.v==AlignNone)          ApplyButtonState = FALSE;
	EnableGadget(_R(IDOK),ApplyButtonState);
}
Пример #2
0
void RenderDemoDlg::RenderControl(ReDrawInfoType* ExtraInfo)
{
	// Go get a render region
	DocRect VirtualSize(-ExtraInfo->dx/2, -ExtraInfo->dy/2, ExtraInfo->dx/2, ExtraInfo->dy/2);
	RenderRegion* pRender = CreateGRenderRegion(&VirtualSize, ExtraInfo);
	if (pRender!=NULL)
	{
		DialogColourInfo RedrawColours;		// Get a supplier for default dlg colours

		// Render stuff in here
		// Build a Linear fill attribute
		LinearFillAttribute MyGradFill;
		MyGradFill.Colour = DocColour(255, 255, 0);
		MyGradFill.EndColour = DocColour(0, 255, 255);
		MyGradFill.StartPoint = DocCoord(0, ExtraInfo->dy);
		MyGradFill.EndPoint = DocCoord(ExtraInfo->dx, 0);

		// Build a path
		Path InkPath;
		InkPath.Initialise(12,12);
		InkPath.FindStartOfPath();

		// Get the coords used to build a shape
		INT32 dx = ExtraInfo->dx / 2;
		INT32 dy = ExtraInfo->dy / 2;
		INT32 Midx = ExtraInfo->dx / 4;
		INT32 Midy = ExtraInfo->dy / 4;

		// build a circle in the middle of the control
		InkPath.InsertMoveTo(DocCoord(Midx, dy));
		InkPath.InsertCurveTo(DocCoord(Midx+Midx/2, dy), DocCoord(dx, Midy+Midy/2), DocCoord(dx, Midy));
		InkPath.InsertCurveTo(DocCoord(dx, Midy-Midy/2), DocCoord(Midx+Midx/2, 0), DocCoord(Midx, 0));
		InkPath.InsertCurveTo(DocCoord(Midx-Midx/2, 0), DocCoord(0, Midy-Midy/2), DocCoord(0, Midy));
		InkPath.InsertCurveTo(DocCoord(0, Midy+Midy/2), DocCoord(Midx-Midx/2, dy), DocCoord(Midx, dy));
		InkPath.IsFilled = TRUE;
		
		// A Grey colour [...hmmm, it's not a very grey grey any more... oragnge more like]
		DocColour Grey(255,200,0);

		// Render the attributes and the a rectangle
		pRender->SaveContext();
		pRender->SetLineColour(Grey);

		// Draw a rectangle to fill in the background - Fill with Dialogue Background colour
		DocRect DrawMe(0, 0, ExtraInfo->dx, ExtraInfo->dy);
		pRender->SetFillColour(RedrawColours.DialogBack());
		pRender->DrawRect(&VirtualSize);

		// Draw some shapes and stuff
		pRender->SetFillGeometry(&MyGradFill, FALSE);
		pRender->DrawPath(&InkPath);

		// Build a path
		Path TriPath;
		TriPath.Initialise(12,12);
		TriPath.FindStartOfPath();

		// build a circle in the middle of the control
		TriPath.InsertMoveTo(VirtualSize.lo);
		TriPath.InsertLineTo(DocCoord(VirtualSize.hi.x, VirtualSize.lo.y));
		TriPath.InsertLineTo(DocCoord(0, VirtualSize.hi.y));
		TriPath.InsertLineTo(VirtualSize.lo);
		TriPath.IsFilled = TRUE;

		LinearFillAttribute MyTriFill;
		MyTriFill.Colour = ShowFirst ? First : Second;
		MyTriFill.EndColour = DocColour(0,0,0);
		MyTriFill.StartPoint = DocCoord(ExtraInfo->dx, 0);
		MyTriFill.EndPoint = DocCoord(0, ExtraInfo->dy);

		pRender->SetFillGeometry(&MyTriFill, FALSE);
		pRender->DrawPath(&TriPath);

		pRender->RestoreContext();

		// Get rid of the render region
		DestroyGRenderRegion(pRender);
	}

	// and animate it!
	if (ShowFirst)
	{
		INT32 Red, Green, Blue;
		First.GetRGBValue(&Red, &Green, &Blue);

		if (Blue>0)
		{
			// Set the colour back again
			Blue -= 10;
			First.SetRGBValue(Red, Green, Blue);

			// redraw it
			InvalidateGadget(_R(IDC_REDRAW_ME));
		}
	}
	else
	{
		// Set the colour back to how it was
		First.SetRGBValue(255, 0, 250);
	}
}
Пример #3
0
MsgResult RenderDemoDlg::Message(Msg* Message)
{
	// See if it is for us
	if (IS_OUR_DIALOG_MSG(Message))
	{
		// it is
		DialogMsg* Msg = (DialogMsg*)Message;

		// decide what to do
		switch (Msg->DlgMsg)
		{
			// Create message
			case DIM_CREATE :
				break;

			// Close and destroy the dialog 
			case DIM_COMMIT :
			case DIM_CANCEL :
			{
				Close();
				End();
				break;
			}

			case DIM_LFT_BN_CLICKED :
			{
				// See which button was pressed
				if (Msg->GadgetID == _R(IDC_REDRAWBTN))
				{
					// Toggle the colour
					ShowFirst = ShowFirst ? FALSE : TRUE;

					// invalidate the gadget with the picture in it
					InvalidateGadget(_R(IDC_REDRAW_ME));
				}
				break;
			}

			case DIM_REDRAW :
			{
				// This is where all the redrawing is done
				// Which control in the window is sending the redraw message (if there are many
				// grdraw controls you can tell which is which from the Gadget ID
				if (Msg->GadgetID == _R(IDC_REDRAW_ME))
				{
					// Draw the redraw_me control in here
					// Render this control
					RenderControl((ReDrawInfoType*) Msg->DlgMsgParam);
				}
				else
				// there are no other controls that should get a redraw message ever
				{
					// give out an error in debug builds, ignore in retail builds
					ERROR3("Got a redraw message for a control I don't know about");
					break;
				}

				break;
			}
			default:
				break;
		}
		
		// Return
		return (DLG_EAT_IF_HUNGRY(Msg));
	}

	return OK;  
}