RenderDemoDlg Class Reference

A Sample dialog that renders stuff into itself using render regions. More...

#include <renddlg.h>

Inheritance diagram for RenderDemoDlg:

DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 RenderDemoDlg ()
 Constructs a Render Dialog.
 ~RenderDemoDlg ()
 Destructor, does nothing.
void Do (OpDescriptor *)
 Creates and shows a Render Demo dialog.
virtual MsgResult Message (Msg *Message)
 Handles all the Render dialog's messages.

Static Public Member Functions

static BOOL Init ()
 Creates an OpDescriptor for a Render Dialog.
static OpState GetState (String_256 *, OpDescriptor *)
 Returns the OpState of the Render dialogue operation.

Static Public Attributes

static const UINT32 IDD = _R(IDD_RENDERDEMO)
static const CDlgMode Mode = MODELESS

Protected Member Functions

void RenderControl (ReDrawInfoType *ExtraInfo)
 Renders a grad fill into the main control in this dialog.

Protected Attributes

DocColour First
DocColour Second
BOOL ShowFirst

Private Member Functions

 CC_DECLARE_DYNCREATE (RenderDemoDlg)

Detailed Description

A Sample dialog that renders stuff into itself using render regions.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/94

Definition at line 120 of file renddlg.h.


Constructor & Destructor Documentation

RenderDemoDlg::RenderDemoDlg  ) 
 

Constructs a Render Dialog.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/94

Definition at line 146 of file renddlg.cpp.

00146                              : DialogOp(RenderDemoDlg::IDD, RenderDemoDlg::Mode) 
00147 {
00148     // Set the 2 colours that we can toggle between
00149     First = DocColour(255,0,250);
00150     Second = DocColour(0,255,255);
00151     ShowFirst = TRUE;
00152 }       

RenderDemoDlg::~RenderDemoDlg  ) 
 

Destructor, does nothing.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/94

Definition at line 166 of file renddlg.cpp.

00167 {
00168 } 


Member Function Documentation

RenderDemoDlg::CC_DECLARE_DYNCREATE RenderDemoDlg   )  [private]
 

void RenderDemoDlg::Do OpDescriptor  )  [virtual]
 

Creates and shows a Render Demo dialog.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/94

Reimplemented from Operation.

Definition at line 428 of file renddlg.cpp.

00429 {
00430     // if we can create the dialog, then open it
00431     if (Create())
00432         Open();
00433     else
00434         TRACE( _T("Failed to create Render Demo Dialog\n"));
00435 }

OpState RenderDemoDlg::GetState String_256 ,
OpDescriptor
[static]
 

Returns the OpState of the Render dialogue operation.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/94

Definition at line 380 of file renddlg.cpp.

00381 {
00382     return OpState(FALSE, FALSE);
00383 }

BOOL RenderDemoDlg::Init void   )  [static]
 

Creates an OpDescriptor for a Render Dialog.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/94
Returns:
FALSE if it fails (due to lack of memory)

Reimplemented from SimpleCCObject.

Definition at line 397 of file renddlg.cpp.

00398 {  
00399     return RegisterOpDescriptor(0,                              // Tool ID
00400                                 _R(IDS_RENDERDEMO),                 // String resouirce ID
00401                                 CC_RUNTIME_CLASS(RenderDemoDlg),// Runtime class
00402                                 OPTOKEN_RENDERDEMODLG,          // Token string
00403                                 RenderDemoDlg::GetState,        // GetState function
00404                                 0,                              // Help ID
00405                                 0,                              // Bubble ID
00406                                 0,                              // Resource ID
00407                                 0,                              // Control ID
00408                                 SYSTEMBAR_ILLEGAL,              // Bar ID
00409                                 FALSE,                          // Recieve system messages
00410                                 FALSE,                          // Smart duplicate operation
00411                                 TRUE,                           // Clean operation
00412                                 0,                              // No vertical counterpart
00413                                 0);                             // String for one copy only
00414 }   

MsgResult RenderDemoDlg::Message Msg Message  )  [virtual]
 

Handles all the Render dialog's messages.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/94

Reimplemented from DialogOp.

Definition at line 182 of file renddlg.cpp.

00183 {
00184     // See if it is for us
00185     if (IS_OUR_DIALOG_MSG(Message))
00186     {
00187         // it is
00188         DialogMsg* Msg = (DialogMsg*)Message;
00189 
00190         // decide what to do
00191         switch (Msg->DlgMsg)
00192         {
00193             // Create message
00194             case DIM_CREATE :
00195                 break;
00196 
00197             // Close and destroy the dialog 
00198             case DIM_COMMIT :
00199             case DIM_CANCEL :
00200             {
00201                 Close();
00202                 End();
00203                 break;
00204             }
00205 
00206             case DIM_LFT_BN_CLICKED :
00207             {
00208                 // See which button was pressed
00209                 if (Msg->GadgetID == _R(IDC_REDRAWBTN))
00210                 {
00211                     // Toggle the colour
00212                     ShowFirst = ShowFirst ? FALSE : TRUE;
00213 
00214                     // invalidate the gadget with the picture in it
00215                     InvalidateGadget(_R(IDC_REDRAW_ME));
00216                 }
00217                 break;
00218             }
00219 
00220             case DIM_REDRAW :
00221             {
00222                 // This is where all the redrawing is done
00223                 // Which control in the window is sending the redraw message (if there are many
00224                 // grdraw controls you can tell which is which from the Gadget ID
00225                 if (Msg->GadgetID == _R(IDC_REDRAW_ME))
00226                 {
00227                     // Draw the redraw_me control in here
00228                     // Render this control
00229                     RenderControl((ReDrawInfoType*) Msg->DlgMsgParam);
00230                 }
00231                 else
00232                 // there are no other controls that should get a redraw message ever
00233                 {
00234                     // give out an error in debug builds, ignore in retail builds
00235                     ERROR3("Got a redraw message for a control I don't know about");
00236                     break;
00237                 }
00238 
00239                 break;
00240             }
00241             default:
00242                 break;
00243         }
00244         
00245         // Return
00246         return (DLG_EAT_IF_HUNGRY(Msg));
00247     }
00248 
00249     return OK;  
00250 }  

void RenderDemoDlg::RenderControl ReDrawInfoType ExtraInfo  )  [protected]
 

Renders a grad fill into the main control in this dialog.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/10/94
Parameters:
ExtraInfo - The structure that has the extra data we need to start rendering [INPUTS]

Definition at line 266 of file renddlg.cpp.

00267 {
00268     // Go get a render region
00269     DocRect VirtualSize(-ExtraInfo->dx/2, -ExtraInfo->dy/2, ExtraInfo->dx/2, ExtraInfo->dy/2);
00270     RenderRegion* pRender = CreateGRenderRegion(&VirtualSize, ExtraInfo);
00271     if (pRender!=NULL)
00272     {
00273         DialogColourInfo RedrawColours;     // Get a supplier for default dlg colours
00274 
00275         // Render stuff in here
00276         // Build a Linear fill attribute
00277         LinearFillAttribute MyGradFill;
00278         MyGradFill.Colour = DocColour(255, 255, 0);
00279         MyGradFill.EndColour = DocColour(0, 255, 255);
00280         MyGradFill.StartPoint = DocCoord(0, ExtraInfo->dy);
00281         MyGradFill.EndPoint = DocCoord(ExtraInfo->dx, 0);
00282 
00283         // Build a path
00284         Path InkPath;
00285         InkPath.Initialise(12,12);
00286         InkPath.FindStartOfPath();
00287 
00288         // Get the coords used to build a shape
00289         INT32 dx = ExtraInfo->dx / 2;
00290         INT32 dy = ExtraInfo->dy / 2;
00291         INT32 Midx = ExtraInfo->dx / 4;
00292         INT32 Midy = ExtraInfo->dy / 4;
00293 
00294         // build a circle in the middle of the control
00295         InkPath.InsertMoveTo(DocCoord(Midx, dy));
00296         InkPath.InsertCurveTo(DocCoord(Midx+Midx/2, dy), DocCoord(dx, Midy+Midy/2), DocCoord(dx, Midy));
00297         InkPath.InsertCurveTo(DocCoord(dx, Midy-Midy/2), DocCoord(Midx+Midx/2, 0), DocCoord(Midx, 0));
00298         InkPath.InsertCurveTo(DocCoord(Midx-Midx/2, 0), DocCoord(0, Midy-Midy/2), DocCoord(0, Midy));
00299         InkPath.InsertCurveTo(DocCoord(0, Midy+Midy/2), DocCoord(Midx-Midx/2, dy), DocCoord(Midx, dy));
00300         InkPath.IsFilled = TRUE;
00301         
00302         // A Grey colour [...hmmm, it's not a very grey grey any more... oragnge more like]
00303         DocColour Grey(255,200,0);
00304 
00305         // Render the attributes and the a rectangle
00306         pRender->SaveContext();
00307         pRender->SetLineColour(Grey);
00308 
00309         // Draw a rectangle to fill in the background - Fill with Dialogue Background colour
00310         DocRect DrawMe(0, 0, ExtraInfo->dx, ExtraInfo->dy);
00311         pRender->SetFillColour(RedrawColours.DialogBack());
00312         pRender->DrawRect(&VirtualSize);
00313 
00314         // Draw some shapes and stuff
00315         pRender->SetFillGeometry(&MyGradFill, FALSE);
00316         pRender->DrawPath(&InkPath);
00317 
00318         // Build a path
00319         Path TriPath;
00320         TriPath.Initialise(12,12);
00321         TriPath.FindStartOfPath();
00322 
00323         // build a circle in the middle of the control
00324         TriPath.InsertMoveTo(VirtualSize.lo);
00325         TriPath.InsertLineTo(DocCoord(VirtualSize.hi.x, VirtualSize.lo.y));
00326         TriPath.InsertLineTo(DocCoord(0, VirtualSize.hi.y));
00327         TriPath.InsertLineTo(VirtualSize.lo);
00328         TriPath.IsFilled = TRUE;
00329 
00330         LinearFillAttribute MyTriFill;
00331         MyTriFill.Colour = ShowFirst ? First : Second;
00332         MyTriFill.EndColour = DocColour(0,0,0);
00333         MyTriFill.StartPoint = DocCoord(ExtraInfo->dx, 0);
00334         MyTriFill.EndPoint = DocCoord(0, ExtraInfo->dy);
00335 
00336         pRender->SetFillGeometry(&MyTriFill, FALSE);
00337         pRender->DrawPath(&TriPath);
00338 
00339         pRender->RestoreContext();
00340 
00341         // Get rid of the render region
00342         DestroyGRenderRegion(pRender);
00343     }
00344 
00345     // and animate it!
00346     if (ShowFirst)
00347     {
00348         INT32 Red, Green, Blue;
00349         First.GetRGBValue(&Red, &Green, &Blue);
00350 
00351         if (Blue>0)
00352         {
00353             // Set the colour back again
00354             Blue -= 10;
00355             First.SetRGBValue(Red, Green, Blue);
00356 
00357             // redraw it
00358             InvalidateGadget(_R(IDC_REDRAW_ME));
00359         }
00360     }
00361     else
00362     {
00363         // Set the colour back to how it was
00364         First.SetRGBValue(255, 0, 250);
00365     }
00366 }


Member Data Documentation

DocColour RenderDemoDlg::First [protected]
 

Definition at line 148 of file renddlg.h.

const UINT32 RenderDemoDlg::IDD = _R(IDD_RENDERDEMO) [static]
 

Definition at line 143 of file renddlg.h.

const CDlgMode RenderDemoDlg::Mode = MODELESS [static]
 

Definition at line 144 of file renddlg.h.

DocColour RenderDemoDlg::Second [protected]
 

Definition at line 149 of file renddlg.h.

BOOL RenderDemoDlg::ShowFirst [protected]
 

Definition at line 150 of file renddlg.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:00:28 2007 for Camelot by  doxygen 1.4.4