sglinepr.cpp

Go to the documentation of this file.
00001 // $Id: sglinepr.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // SGLinePr.cpp - the LineGallery property dialog classes
00099 
00100 #include "camtypes.h"
00101 #include "sglinepr.h"
00102 
00103 #include "camelot.h"
00104 //#include "fixmem.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 //#include "galstr.h"
00106 //#include "galres.h"
00107 #include "mainfrm.h"
00108 //#include "sgallery.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 #include "sgdrag.h"
00110 #include "sgmenu.h"
00111 //#include "sgtree.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 #include "sgstroke.h"
00113 #include "strkcomp.h"
00114 //#include "rndrgn.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00115 
00116 //#include "app.h"          // for RedrawStrokesInDocuments - in camtypes.h [AUTOMATICALLY REMOVED]
00117 #include "objchge.h"        // for RedrawStrokesInDocuments
00118 #include "strkattr.h"       // for RedrawStrokesInDocuments
00119 #include "ppstroke.h"       // for RedrawStrokesInDocuments
00120 #include "ppvecstr.h"       // for RedrawStrokesInDocuments
00121 
00122 //#include "rikdlg.h"           // for slider stuff
00123 
00124 // Implement the dynamic class bits...
00125 CC_IMPLEMENT_DYNCREATE(SGalleryLinePropertiesDlg, DialogOp)
00126 
00127 // This line mustn't go before any CC_IMPLEMENT_... macros
00128 #define new CAM_DEBUG_NEW
00129 
00130 // OpParam class for opening the line properties dlgs - local to this .cpp file
00131 class LinePropertiesDlgParam : public OpParam
00132 {
00133 CC_DECLARE_MEMDUMP(LinePropertiesDlgParam)
00134 public:
00135     LinePropertiesDlgParam(SuperGallery *Parent) : OpParam(0, 0) { ParentGal = Parent; };
00136     SuperGallery *ParentGal;
00137 };
00138 CC_IMPLEMENT_MEMDUMP(LinePropertiesDlgParam, OpParam)
00139 
00140 
00141 // Used for the commit when text is typed stuff
00142 static BOOL SGLinePrJustSetATextEditChangeMessage = FALSE;
00143 
00144 // Mode of the dialog  
00145 const CDlgMode SGalleryLinePropertiesDlg::Mode = MODELESS;
00146 
00147 // Dialog template to use
00148 const UINT32 SGalleryLinePropertiesDlg::IDD = _R(IDD_SGLINEPROPERTIES);
00149 
00150 const INT32 SliderMax = 50;
00151 /********************************************************************************************
00152 
00153 >   SGalleryLinePropertiesDlg::SGalleryLinePropertiesDlg(): 
00154                 DialogOp(SGalleryLinePropertiesDlg::IDD, SGalleryLinePropertiesDlg::Mode)
00155 
00156     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00157     Created:    9/3/95
00158 
00159     Purpose:    Constructor
00160 
00161 ********************************************************************************************/
00162 
00163 SGalleryLinePropertiesDlg::SGalleryLinePropertiesDlg()
00164                    : DialogOp(SGalleryLinePropertiesDlg::IDD, SGalleryLinePropertiesDlg::Mode)
00165 {
00166     ParentGallery = NULL;
00167     m_pItem = NULL;
00168 }
00169 
00170 
00171 
00172 /********************************************************************************************
00173 
00174 >   SGalleryLinePropertiesDlg::~SGalleryLinePropertiesDlg()
00175 
00176     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00177     Created:    9/3/95
00178 
00179     Purpose:    destructor
00180 
00181 ********************************************************************************************/
00182 
00183 SGalleryLinePropertiesDlg::~SGalleryLinePropertiesDlg()
00184 {
00185     if (ParentGallery != NULL)
00186         ParentGallery->CurrentLinePropertiesDlg = NULL;
00187 }
00188 
00189 
00190 
00191 /********************************************************************************************
00192 
00193 >   void SGalleryLinePropertiesDlg::InitValues(void)
00194 
00195     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00196     Created:    9/3/95
00197 
00198     Purpose:    Initialises the line properties dialogue, and sets its controls
00199     Scope:      private
00200 
00201     SeeAlso:    SGalleryLinePropertiesDlg::SetControls
00202 
00203 ********************************************************************************************/
00204 
00205 void SGalleryLinePropertiesDlg::InitValues(void)
00206 {
00207     if (ParentGallery == NULL)
00208     {
00209         ERROR3("SGalleryLinePropertiesDlg MUST be given a valid parent pointer");
00210         return;
00211     }
00212 
00213     // The fixed thingy slider
00214     SetSliderMinMax(0, SliderMax);
00215     SetGadgetBitmaps(_R(IDC_SGLINEPROPERTIES_FIXED_SLIDER), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
00216     SetSliderPos(0);
00217 
00218     // Set up the OK button to respond to Adjust (SOFT_COMMIT) clicks
00219     // Don't call this more than once per dialog - fireworks ensue !
00220 //  DualFunctionButton(IDOK);
00221 
00222     // Fill in the controls with the current settings
00223     SetControls();
00224 }
00225 
00226 
00227 
00228 /********************************************************************************************
00229 
00230 >   static void SGalleryLinePropertiesDlg::InvokeDialog(SuperGallery *Parent)
00231 
00232     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00233     Created:    9/3/95
00234 
00235     Inputs:     Parent - the parent (owner) of this display dialogue. This pointer
00236                 is used to inform the parent of changes to display/sort modes.
00237                 May NOT be NULL.
00238 
00239     Purpose:    Creates a new instance of this dialogue type, connects it to the given
00240                 gallery, and opens the dialogue on screen.
00241 
00242 ********************************************************************************************/
00243 
00244 void SGalleryLinePropertiesDlg::InvokeDialog(SuperGallery *Parent)
00245 {
00246     if (Parent->CurrentLinePropertiesDlg != NULL)       // There's one already open!
00247     {
00248         // Update the settings in the dialog
00249         Parent->CurrentLinePropertiesDlg->SetControls();
00250 
00251         // Bring it to the front of the window stack, then return
00252         Parent->CurrentLinePropertiesDlg->BringToTop();
00253         return;
00254     }
00255 
00256     LinePropertiesDlgParam OptInfo(Parent);
00257     OpDescriptor *Dlg = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(SGalleryLinePropertiesDlg));
00258 
00259     ERROR3IF(Dlg == NULL, "I can't find the Dialog OpDescriptor");
00260 
00261     if (Dlg != NULL)
00262         Dlg->Invoke(&OptInfo);
00263 }
00264 
00265 
00266 
00267 
00268 /********************************************************************************************
00269 
00270 >   void SGalleryLinePropertiesDlg::SetControls(void)
00271 
00272     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00273     Created:    7/3/97
00274 
00275     Purpose:    (Re)Initialises the line properties dialogue controls
00276 
00277 ********************************************************************************************/
00278 
00279 void SGalleryLinePropertiesDlg::SetControls(void)
00280 {
00281     if (ParentGallery == NULL)
00282     {
00283         ERROR3("ParentGallery is NULL!");
00284         return;
00285     }
00286 
00287     // Call gallery first
00288     BOOL Result = ParentGallery->ApplyAction(SGACTION_SETLINEPROPERTIES);
00289 
00290     // Now set values in the dialog
00291     SGDisplayNode *pNode = ParentGallery->DisplayTree->FindNextSelectedItem(NULL);
00292     if(pNode != NULL && pNode->IsKindOf(CC_RUNTIME_CLASS(StrokeTypeItem)))
00293     {
00294         StrokeTypeItem *pItem = (StrokeTypeItem *)pNode;
00295         m_pItem = pItem;
00296     
00297         // Set the edit name field
00298         String_256 ItemText;
00299         pItem->GetNameText(&ItemText);
00300         SetNameEditField(&ItemText);
00301 
00302         // Set the repeating button
00303         SetRepeatingBool(pItem->IsRepeating());
00304 
00305         // Set the fixed repeating values
00306         SetRepeatingLong(pItem->NumRepeats());
00307 
00308         // Grey the fixed repeat stuff
00309         GreyRepeats(pItem->IsRepeating() == 0);
00310 
00311         // Set the override fill button
00312         SetOverrideFillBool(pItem->OverridesFill());
00313 
00314         // Set the override transparency button
00315         SetOverrideTransBool(pItem->OverridesTrans());
00316     }
00317 
00318     InvalidateGadget(_R(IDC_SGLINEPROPERTIES_DIAGRAM));
00319 }
00320 
00321 
00322 
00323 /********************************************************************************************
00324 
00325 >   void SGalleryLinePropertiesDlg::Commit(BOOL RedrawDocument = TRUE)
00326 
00327     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00328     Created:    7/3/97
00329 
00330     Inputs:     RedrawDocument  - For things like changing the textual description of the
00331                                     stroke, we don't really need to redraw the document
00332                                     each time. Normally it's safer to redraw the lot...
00333 
00334     Purpose:    Applies the current settings in the dialog to its parent gallery and the
00335                 referenced stroke in the document.
00336 
00337 ********************************************************************************************/
00338 
00339 void SGalleryLinePropertiesDlg::Commit(BOOL RedrawDocument)
00340 {
00341     if (ParentGallery == NULL)
00342     {
00343         ERROR3("No parent gallery!");
00344         return;
00345     }
00346 
00347     if(m_pItem == NULL)
00348     {
00349         ERROR3("SGalleryLinePropertiesDlg::Commit - No associated item");
00350         return;
00351     }
00352 
00353     // Commit changes to item and redraw the various bits
00354     if(m_pItem->IsKindOf(CC_RUNTIME_CLASS(StrokeTypeItem)))
00355     {
00356         StrokeTypeItem *pItem = (StrokeTypeItem *)m_pItem;
00357 
00358         StrokeDefinition *pStroke = pItem->GetStrokeDefinition();
00359         if (pStroke != NULL)
00360         {
00361             // Apply the checkboxes
00362             pStroke->SetStrokeRepeating(GetRepeatingBool());
00363             pStroke->SetNumStrokeRepeats(GetRepeatingLong());
00364             pStroke->SetOverrideFill(GetOverrideFillBool());
00365             pStroke->SetOverrideTrans(GetOverrideTransBool());
00366 
00367             // Change the brush name
00368             String_256 NewName;
00369             GetNameEditField(&NewName);
00370             pStroke->SetStrokeName(&NewName);
00371 
00372             // Get the number of repeats
00373             INT32 Repeats = GetRepeatingLong();
00374             pStroke->SetNumStrokeRepeats(Repeats);
00375             SetSliderPos(Repeats);
00376 
00377             // Grey the fixed repeat stuff
00378             GreyRepeats(pItem->IsRepeating() == 0);
00379 
00380             pItem->UpdateGalleryItem();
00381             InvalidateGadget(_R(IDC_SGLINEPROPERTIES_DIAGRAM));
00382 
00383             if(RedrawDocument)
00384             {
00385                 StrokeHandle Handle = pItem->GetStrokeHandle();
00386                 RedrawStrokesInDocuments(Handle);
00387             }
00388         }
00389     }
00390 }
00391 
00392 
00393 
00394 /********************************************************************************************
00395 
00396 >   MsgResult SGalleryLinePropertiesDlg::Message( Msg* Message)
00397 
00398     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00399     Created:    9/3/95
00400 
00401     Inputs:     Msg - The dialogue manager message to handle
00402 
00403     Returns:    A MsgResult
00404     Purpose:    Standard DialogOp message handler which handles redraw and commit stuff
00405 
00406 ********************************************************************************************/
00407 
00408 MsgResult SGalleryLinePropertiesDlg::Message( Msg* Message)
00409 {
00410     if (!(IS_OUR_DIALOG_MSG(Message))) return DialogOp::Message(Message);
00411 
00412     DialogMsg* TheMsg = (DialogMsg*)Message;
00413 
00414     switch(TheMsg->DlgMsg)
00415     {
00416         case DIM_SLIDER_POS_CHANGING:
00417         case DIM_SLIDER_POS_IDLE:
00418         case DIM_SLIDER_POS_SET:    
00419         {
00420             BOOL Valid = FALSE;
00421 
00422             INT32 Value = GetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_FIXED_SLIDER),0,SliderMax,0,&Valid);
00423             if(Value != 0 && Valid)
00424             {
00425                 SetRepeatingLong(SliderMax - Value);
00426             }
00427             break;
00428         }
00429 
00430         case DIM_LFT_BN_CLICKED:
00431         case DIM_RGT_BN_CLICKED:
00432             Commit();
00433             break;
00434 
00435         case DIM_TEXT_CHANGED:
00436             // Only commit if the user typed something rather than the code
00437             if(SGLinePrJustSetATextEditChangeMessage)
00438                 SGLinePrJustSetATextEditChangeMessage = FALSE;
00439             else
00440             {
00441                 CGadgetID GadgetID = TheMsg->GadgetID;
00442                 if(GadgetID == _R(IDC_SGLINEPROPERTIES_NAMEEDIT))
00443                     Commit(FALSE);  // No need to redraw the document here
00444                 else
00445                     Commit(TRUE);   // OK, we need to redraw the document
00446             }
00447             break;
00448 
00449         case DIM_COMMIT:                        // OK clicked
00450             Commit();
00451             // Drop through to CANCEL to close the dlg...
00452 
00453         case DIM_CANCEL:                        // Cancel clicked
00454             Close();
00455             End();
00456             break;
00457 
00458         case DIM_SOFT_COMMIT:                   // OK "adjust clicked"
00459             Commit();
00460             break;
00461 
00462         case DIM_REDRAW:                // handle redraw request for diagram gadget
00463             if (TheMsg->GadgetID == _R(IDC_SGLINEPROPERTIES_DIAGRAM))
00464                 RedrawDiagram((ReDrawInfoType*)TheMsg->DlgMsgParam);
00465             break;
00466 
00467     }
00468 
00469     return DialogOp::Message(Message);
00470 }
00471 
00472 
00473 
00474 /********************************************************************************************
00475 
00476 >   OpState SGalleryLinePropertiesDlg::GetState(String_256*, OpDescriptor*)
00477 
00478     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00479     Created:    9/3/95
00480     Inputs:     -
00481     Outputs:    -
00482     Returns:    -
00483     Purpose:    Get the state of the Line Properties Dialog Op
00484     Errors:     -
00485     SeeAlso:    -
00486 
00487 ********************************************************************************************/
00488 
00489 OpState SGalleryLinePropertiesDlg::GetState(String_256*, OpDescriptor*)
00490 {    
00491     OpState OpSt;
00492     return(OpSt);
00493 }
00494 
00495 
00496 
00497 /********************************************************************************************
00498 
00499 >   BOOL SGalleryLinePropertiesDlg::Init()
00500 
00501     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00502     Created:    9/3/95
00503     Inputs:     -
00504     Outputs:    -
00505     Returns:    -
00506     Purpose:    Initialises the Line Properties Dialogue Op
00507     Errors:     -
00508     SeeAlso:    -
00509 
00510 ********************************************************************************************/
00511 
00512 BOOL SGalleryLinePropertiesDlg::Init()
00513 {
00514     return (RegisterOpDescriptor(
00515                                 0,
00516                                 _R(IDS_SGLINEPROPERTIESDLG),
00517                                 CC_RUNTIME_CLASS(SGalleryLinePropertiesDlg),
00518                                 OPTOKEN_SGLINEPROPERTIESDLG,
00519                                 SGalleryLinePropertiesDlg::GetState,
00520                                 _R(IDST_GALLERY_MENU),  // Status line help
00521                                 _R(IDBBL_GALLERY_MENU), // Bubble help
00522                                 0   /* bitmap ID */
00523                                 ));
00524 }
00525 
00526 
00527 
00528 /********************************************************************************************
00529 
00530 >   BOOL SGalleryLinePropertiesDlg::Create()
00531 
00532     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00533     Created:    9/3/95
00534 
00535     Returns:    FALSE if it fails
00536     Purpose:    Creates a Line Properties dialogue box
00537 
00538 ********************************************************************************************/
00539 
00540 BOOL SGalleryLinePropertiesDlg::Create()
00541 {
00542     ERROR3IF(ParentGallery == NULL, "My ParentGallery is NULL!");
00543 
00544     if (DialogOp::Create())
00545     { 
00546         ParentGallery->CurrentLinePropertiesDlg = this;
00547 
00548         InitValues();
00549         return(TRUE);
00550     }
00551 
00552     return(FALSE);
00553 }
00554 
00555 
00556 
00557 /********************************************************************************************
00558 
00559 >   void SGalleryLinePropertiesDlg::Do(OpDescriptor*)
00560 
00561     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00562     Created:    9/3/95
00563     Inputs:     OPDescriptor - the Opdescriptor for this op
00564 
00565     Purpose:    'Does' a line properties dialogue op.
00566                 DO NOT call this method - it must be invoked via DoWithParam
00567 
00568     Notes:      To show this dialogue you should call InvokeDialog
00569                                                                   
00570     SeeAlso:    SGalleryLinePropertiesDlg::InvokeDialog
00571 
00572 ********************************************************************************************/
00573 
00574 void SGalleryLinePropertiesDlg::Do(OpDescriptor*)
00575 {
00576     ERROR3("SGalleryLinePropertiesDlg - You must use DoWithParam (Call InvokeDialog)");
00577     End();
00578 }
00579 
00580 
00581 
00582 /********************************************************************************************
00583 
00584 >   void SGalleryLinePropertiesDlg::DoWithParam(OpDescriptor *Bob, OpParam *Param)
00585 
00586     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00587     Created:    9/3/95
00588     Inputs:     Bob - the Opdescriptor for this op
00589                 Param - The parameter. Must point at a LinePropertiesDlgParam object
00590 
00591     Purpose:    'Does' a line properties dialogue op. Shows the dialogue.
00592 
00593     Notes:      To show this dialogue you should call InvokeDialog
00594                                                                   
00595     SeeAlso:    SGalleryLinePropertiesDlg::InvokeDialog
00596 
00597 ********************************************************************************************/
00598 
00599 void SGalleryLinePropertiesDlg::DoWithParam(OpDescriptor*, OpParam *Param)
00600 {
00601     ERROR3IF(Param == NULL, "Null parameters are illegal");
00602 
00603     ParentGallery = ((LinePropertiesDlgParam *)Param)->ParentGal;
00604 
00605     ERROR3IF(ParentGallery == NULL, "SGalleryLinePropertiesDlg needs a non-NULL parent gallery!");  
00606 
00607     if (ParentGallery != NULL && Create())
00608         Open();
00609     else
00610         End();
00611 }
00612 
00613 
00614 
00615 /********************************************************************************************
00616 
00617 >   void SGalleryLinePropertiesDlg::SetNameEditField(String_256 *pString)
00618 
00619     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00620     Created:    7/3/97
00621     Inputs:     pString     - The string to copy into the edit field
00622     Purpose:    Can be called by sgline to set the name text from the dialog
00623 
00624 ********************************************************************************************/
00625 
00626 void SGalleryLinePropertiesDlg::SetNameEditField(String_256 *pString)
00627 {
00628     if(pString != NULL)
00629     {
00630         SGLinePrJustSetATextEditChangeMessage = TRUE;
00631         SetStringGadgetValue(_R(IDC_SGLINEPROPERTIES_NAMEEDIT), pString);
00632     }
00633 }
00634 
00635 /********************************************************************************************
00636 
00637 >   void SGalleryLinePropertiesDlg::GetNameEditField(String_256 *pString)
00638 
00639     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00640     Created:    7/3/97
00641     Returns:    pString - Copies the edit text into this string (which should have been
00642                             allocated and passed to the function).
00643     Purpose:    Can be called by sgline to get the name text from the dialog
00644 
00645 ********************************************************************************************/
00646 
00647 void SGalleryLinePropertiesDlg::GetNameEditField(String_256 *pString)
00648 {
00649     if(pString != NULL)
00650     {
00651         *pString = "";
00652 
00653         BOOL Valid = FALSE;
00654         String_256 TheString = GetStringGadgetValue(_R(IDC_SGLINEPROPERTIES_NAMEEDIT), &Valid);
00655         if(Valid)
00656             *pString = TheString;
00657     }
00658 }
00659 
00660 /********************************************************************************************
00661 
00662 >   void SGalleryLinePropertiesDlg::SetRepeatingBool(BOOL Repeating)
00663 
00664     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00665     Created:    7/3/97
00666     Inputs:     Repeating   - TRUE and we'll put a tick by the repeating item
00667     Purpose:    Can be called by sgline to set the repeating button state from the dialog
00668 
00669 ********************************************************************************************/
00670 
00671 void SGalleryLinePropertiesDlg::SetRepeatingBool(BOOL Repeating)
00672 {
00673     INT32 RadioValue = 0;
00674     if(Repeating)
00675         RadioValue = 1;
00676 
00677     SetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_REPEAT), RadioValue, TRUE, 0);
00678 }
00679 
00680 /********************************************************************************************
00681 
00682 >   BOOL SGalleryLinePropertiesDlg::GetRepeatingBool()
00683 
00684     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00685     Created:    7/3/97
00686     Returns:    TRUE if the checkbox for 'repeating' is ticked
00687     Purpose:    Can be called by sgline to get the repeating button state from the dialog
00688 
00689 ********************************************************************************************/
00690 
00691 BOOL SGalleryLinePropertiesDlg::GetRepeatingBool()
00692 {
00693     BOOL Valid = FALSE;
00694     INT32 Value = GetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_REPEAT),0,1,0,&Valid);
00695     if(Valid && Value > 0)
00696         return TRUE;
00697 
00698     return FALSE;
00699 }
00700 
00701 /********************************************************************************************
00702 
00703 >   void SGalleryLinePropertiesDlg::SetRepeatingLong(INT32 Repeats)
00704 
00705     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00706     Created:    11/3/97
00707     Inputs:     Repeats     - Number of fixed repeats for the brush
00708     Purpose:    Set the UI corresponding to the number of fixed repeats for a brush (where
00709                 0 repeats really means optimal repeats)
00710 
00711 ********************************************************************************************/
00712 
00713 void SGalleryLinePropertiesDlg::SetRepeatingLong(INT32 Repeats)
00714 {
00715     SetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_FIXED), (Repeats > 0), TRUE, 0);
00716     SetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_OPTIMAL), (Repeats == 0), TRUE, 0);
00717     SetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_FIXED_EDIT), Repeats, TRUE, 0);
00718 }
00719 
00720 /********************************************************************************************
00721 
00722 >   INT32 SGalleryLinePropertiesDlg::GetRepeatingLong()
00723 
00724     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00725     Created:    11/3/97
00726     Returns:    Number of fixed repeats for the brush
00727     Purpose:    Get the number of fixed repeats for this brush from the UI. 0 means optimal.
00728 
00729 ********************************************************************************************/
00730 
00731 INT32 SGalleryLinePropertiesDlg::GetRepeatingLong()
00732 {
00733     BOOL Valid = FALSE;
00734 
00735     INT32 Fixed = GetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_FIXED),0,1,0,&Valid);
00736     if(Fixed != 0 && Valid)
00737     {
00738         INT32 Value = GetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_FIXED_EDIT),0,255,0,&Valid);
00739         if(Valid && (Value > 0))
00740             return Value;
00741     }
00742 
00743 //  SetRepeatingLong(0);
00744 
00745     return 0;
00746 }
00747 
00748 
00749 void SGalleryLinePropertiesDlg::SetSliderMinMax(INT32 Min, INT32 Max)
00750 {
00751     SetGadgetRange(_R(IDC_SGLINEPROPERTIES_FIXED_SLIDER), Min, Max, 1);
00752 }
00753 
00754 void SGalleryLinePropertiesDlg::SetSliderPos(INT32 Value)
00755 {
00756     SetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_FIXED_SLIDER), SliderMax - Value); 
00757 }
00758 
00759 // Grey's / un-grey's the repeat section
00760 void SGalleryLinePropertiesDlg::GreyRepeats(BOOL Grey)
00761 {
00762     EnableGadget(_R(IDC_SGLINEPROPERTIES_FIXED), !Grey);
00763     EnableGadget(_R(IDC_SGLINEPROPERTIES_OPTIMAL), !Grey);
00764     EnableGadget(_R(IDC_SGLINEPROPERTIES_FIXED_EDIT), !Grey);
00765     EnableGadget(_R(IDC_SGLINEPROPERTIES_FIXED_SLIDER), !Grey);
00766 
00767 /*  SetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_FIXED), (Repeats > 0), TRUE, 0);
00768     SetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_OPTIMAL), (Repeats == 0), TRUE, 0);
00769     SetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_FIXED_EDIT), Repeats, TRUE, 0);*/
00770 }
00771 
00772 /********************************************************************************************
00773 
00774 >   void SGalleryLinePropertiesDlg::SetOverrideFillBool(BOOL OverrideFill)
00775 
00776     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00777     Created:    7/3/97
00778     Inputs:     OverrideFill    - TRUE and we'll put a tick by the Override Fill item
00779     Purpose:    Set the Override Fill button state from the dialog
00780 
00781 ********************************************************************************************/
00782 
00783 void SGalleryLinePropertiesDlg::SetOverrideFillBool(BOOL OverrideFill)
00784 {
00785     INT32 RadioValue = 0;
00786     if(OverrideFill)
00787         RadioValue = 1;
00788 
00789     SetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_OVERRIDE_FILL), RadioValue, TRUE, 0);
00790 }
00791 
00792 /********************************************************************************************
00793 
00794 >   BOOL SGalleryLinePropertiesDlg::GetOverrideFillBool()
00795 
00796     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00797     Created:    7/3/97
00798     Returns:    TRUE if the checkbox for 'Override Fill' is ticked
00799     Purpose:    Get the Override Fill button state from the dialog
00800 
00801 ********************************************************************************************/
00802 
00803 BOOL SGalleryLinePropertiesDlg::GetOverrideFillBool()
00804 {
00805     BOOL Valid = FALSE;
00806     INT32 Value = GetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_OVERRIDE_FILL),0,1,0,&Valid);
00807     if(Valid && Value > 0)
00808         return TRUE;
00809 
00810     return FALSE;
00811 }
00812 
00813 /********************************************************************************************
00814 
00815 >   void SGalleryLinePropertiesDlg::SetOverrideTransBool(BOOL OverrideTrans)
00816 
00817     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00818     Created:    7/3/97
00819     Inputs:     OverrideTrans   - TRUE and we'll put a tick by the Override Trans item
00820     Purpose:    Set the Override Trans button state from the dialog
00821 
00822 ********************************************************************************************/
00823 
00824 void SGalleryLinePropertiesDlg::SetOverrideTransBool(BOOL OverrideTrans)
00825 {
00826     INT32 RadioValue = 0;
00827     if(OverrideTrans)
00828         RadioValue = 1;
00829 
00830     SetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_OVERRIDE_TRANS), RadioValue, TRUE, 0);
00831 }
00832 
00833 /********************************************************************************************
00834 
00835 >   BOOL SGalleryLinePropertiesDlg::GetOverrideTransBool()
00836 
00837     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00838     Created:    7/3/97
00839     Returns:    TRUE if the checkbox for 'Override Trans' is ticked
00840     Purpose:    Get the Override Trans button state from the dialog
00841 
00842 ********************************************************************************************/
00843 
00844 BOOL SGalleryLinePropertiesDlg::GetOverrideTransBool()
00845 {
00846     BOOL Valid = FALSE;
00847     INT32 Value = GetLongGadgetValue(_R(IDC_SGLINEPROPERTIES_OVERRIDE_TRANS),0,1,0,&Valid);
00848     if(Valid && Value > 0)
00849         return TRUE;
00850 
00851     return FALSE;
00852 }
00853 
00854 /******************************************************************************
00855 
00856 >   void SGalleryLinePropertiesDlg::RedrawDiagram(ReDrawInfoType* ExtraInfo)
00857 
00858     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00859     Created:    05/03/97
00860     Purpose:    Redraws the diagram on the line properties dialog
00861 
00862 ******************************************************************************/
00863 
00864 void SGalleryLinePropertiesDlg::RedrawDiagram(ReDrawInfoType* ExtraInfo)
00865 {
00866     INT32 dx = ExtraInfo->dx;   // In millipoints
00867     INT32 dy = ExtraInfo->dy;
00868     INT32 Dpi = ExtraInfo->Dpi; // The DPI of the screen
00869 
00870     if(m_pItem == NULL || !(m_pItem->IsKindOf(CC_RUNTIME_CLASS(StrokeTypeItem))))
00871     {
00872         ERROR3("SGalleryLinePropertiesDlg::RedrawDiagram - Dodgy or no item");
00873         return;
00874     }
00875 
00876     StrokeTypeItem *pItem = (StrokeTypeItem *)m_pItem;
00877 
00878     // Total size of control
00879     DocRect ControlRect;
00880     ControlRect.lox = 0;
00881     ControlRect.loy = 0;
00882     ControlRect.hix = dx;
00883     ControlRect.hiy = dy;
00884 
00885     // make a render region
00886     DocRect RendRect = ControlRect;
00887     RenderRegion* pRender=CreateGRenderRegion(&RendRect,ExtraInfo);
00888     if (pRender!=NULL)
00889     {
00890         // Renders the stroke into the render region
00891 //      pItem->RenderItem(pRender, &RendRect, (32000)); // 32pt line width
00892         pItem->RenderItem(pRender, &RendRect, dy); // almost as big as the control
00893 
00894         // Destroys and blits the render region
00895         DestroyGRenderRegion(pRender);
00896     }
00897 }
00898 
00899 
00900 
00901 /********************************************************************************************
00902 
00903 >   void SGalleryLinePropertiesDlg::RedrawStrokesInDocuments(StrokeHandle Handle)
00904 
00905     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com> / Jason
00906     Created:    7/3/97
00907     Inputs:     Handle  - the handle of the stroke to search for in the docs
00908     Purpose:    Whizzes through all the documents, redrawing nodes containing the passed
00909                 in stroke business.
00910 
00911 ********************************************************************************************/
00912 
00913 void SGalleryLinePropertiesDlg::RedrawStrokesInDocuments(StrokeHandle Handle)
00914 {
00915     Document *pOurDoc = (Document *) GetApplication()->Documents.GetHead();
00916     while (pOurDoc != NULL)
00917     {
00918         ObjChangeFlags ChangeFlags;
00919         ChangeFlags.Attribute = TRUE;
00920 
00921         ObjChangeParam ChangeParam(OBJCHANGE_STARTING, ChangeFlags, NULL, NULL);
00922 
00923         Node *CurNode = Node::DocFindFirstDepthFirst(pOurDoc);
00924         while (CurNode != NULL)
00925         {
00926             if (CurNode->IsAnAttribute() && CurNode->IsKindOf(CC_RUNTIME_CLASS(AttrStrokeType)))
00927             {
00928                 // actually, in here, we could possibly just use NodeAttribute::operator== to
00929                 // see if it's the same as the Stroke Attribute that we're playing with
00930                 // - this would be better than IsKindOf's
00931 
00932                 // Have found a StrokeType Attribute. Check if it's a Vector Stroke attribute
00933                 // If it is one using the stroke we're after, then force a redraw of our parent node
00934                 AttrStrokeType *pNode = (AttrStrokeType *) CurNode;
00935 
00936                 StrokeTypeAttrValue *pValue = (StrokeTypeAttrValue *)pNode->GetAttributeValue();
00937 
00938                 PathProcessorStroke *pProcessor = pValue->GetPathProcessor();
00939 
00940                 if (pProcessor != NULL && pProcessor->IsKindOf(CC_RUNTIME_CLASS(PathProcessorStrokeVector)))
00941                 {
00942                     StrokeHandle ThisHandle = ((PathProcessorStrokeVector *)pProcessor)->GetStrokeDefinition();
00943                     if (ThisHandle == Handle || Handle == StrokeHandle_NoStroke)
00944                     {
00945                         Node *Parent = CurNode->FindParent();  
00946                         if (Parent != NULL && Parent->IsBounded())
00947                         {
00948                             // Invoke AllowOp on the node to tag it so that parents such as blends
00949                             // and moulds will also redraw if necessary. We ignore the return code
00950                             // because we're not actually going to touch the node at all.
00951                             CurNode->AllowOp(&ChangeParam);
00952 
00953                             // And redraw the directly affected node (our parent)
00954                             DocRect NodeBounds = ((NodeRenderableBounded *)Parent)->GetBoundingRect();
00955                             pOurDoc->ForceRedraw(Parent->FindParentSpread(), NodeBounds, FALSE, Parent);
00956                         }
00957                     }
00958                 }
00959             }
00960             CurNode = CurNode->DocFindNextDepthFirst();
00961         }
00962         
00963         // And make sure that the redraw occurs right away
00964         pOurDoc->FlushRedraw();
00965 
00966         ChangeParam.Define(OBJCHANGE_FINISHED, ChangeParam.GetChangeFlags(), NULL, NULL);
00967         UpdateAllChangedNodes(&ChangeParam);
00968 
00969         pOurDoc = (Document *) GetApplication()->Documents.GetNext(pOurDoc);
00970     }
00971 }

Generated on Sat Nov 10 03:48:56 2007 for Camelot by  doxygen 1.4.4