void SGDisplayDATATYPE::HandleRedraw(SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo) { // First, inform the system that we are about to start rendering this item StartRendering(RedrawInfo, MiscInfo); DocRect MyRect(FormatRect); // Get my redraw position from the cached FormatRect RenderRegion *Renderer = RedrawInfo->Renderer; INT32 OnePixel = (INT32) DevicePixels(MiscInfo, 1); INT32 TwoPixels = (INT32) DevicePixels(MiscInfo, 2); Renderer->SetLineWidth(0); Renderer->SetLineColour(RedrawInfo->Transparent); // First, render the icon at the left end of our rectangle DocRect IconRect(MyRect); IconRect.hi.x = IconRect.lo.x + IconRect.Height(); // Make it a square MyRect.lo.x = IconRect.hi.x + TwoPixels; // And exclude it from 'MyRect' // Redraw the icon GridLockRect(MiscInfo, &IconRect); // Ensure it maps exactly to specific pixels IconRect.Inflate(-OnePixel, -OnePixel); // Leave a bit of space around the edge Renderer->SetFillColour(DocColour(COLOUR_RED)); Renderer->DrawRect(&IconRect); GridLockRect(MiscInfo, &MyRect); // Ensure the new 'MyRect' is pixel-grid-aligned // Set up the colours for rendering our text, and fill the background if selected if (Flags.Selected) { // Fill the entire background with the 'selected' colour, so we don't // get gaps between bits of text or uneven rectangles in multiple selections Renderer->SetFillColour(RedrawInfo->SelBackground); Renderer->DrawRect(&MyRect); Renderer->SetFixedSystemTextColours(&RedrawInfo->SelForeground, &RedrawInfo->SelBackground); } else Renderer->SetFixedSystemTextColours(&RedrawInfo->Foreground, &RedrawInfo->Background); MyRect.lo.x += SG_GapBeforeText; // Leave a small gap before text begins // And render the text String_256 MyText; GetNameText(&MyText); Renderer->DrawFixedSystemText(&MyText, MyRect); // Finally, inform the system that we have completed rendering this item StopRendering(RedrawInfo, MiscInfo); }
void OpDragBox::DrawXorRect(const DocRect& drClip, Spread* pspdXor, const DocRect& drXor) const { // Check if we have nothing to do. if (drXor.IsEmpty()) return; // Ask the derived class what colour its drag box is. If we are doing solid drags we // want to use the same colour to fill the box as well, otherwise we fill with no colour. StockColour scLineColour = GetBoxColour(); StockColour scFillColour = (m_fDoSolidDragBoxes) ? scLineColour : COLOUR_NONE; // Xor the rect on all supplied render-regions. RenderRegion* pRegion = DocView::RenderOnTop(&((DocRect&) drClip), pspdXor, ClippedEOR); while (pRegion != NULL) { // Set the line and fill colours. pRegion->SetLineColour(scLineColour); pRegion->SetFillColour(scFillColour); // Draw the xored drag box and go on to the next render-region. pRegion->DrawDragRect(&((DocRect&) drXor)); pRegion = DocView::GetNextOnTop(&((DocRect&) drClip)); } }
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); } }