blobby.cpp

Go to the documentation of this file.
00001 // $Id: blobby.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 
00099 // Implemetation of the following classes
00100 /*
00101     OperationHistory : The operation history used to store undoable operations
00102     OpUndo           : The undo operation
00103     OpRedo           : The redo operation
00104 
00105     BlobbyOp         : Demonstration temporary operation which changes the colour of a
00106                        documents paper.
00107 
00108     UndoColAction    : BlobbyOp undo action
00109     RedoColAction    : BlobbyOp redo action
00110 */
00111 
00112 /*
00113 */
00114 #include "camtypes.h"
00115 //#include "ops.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00116 
00117 DECLARE_SOURCE("$Revision: 1282 $");
00118 
00119 #include "blobby.h"
00120 #include "ophist.h"
00121 #include "lineattr.h"
00122 //#include "resource.h"
00123 #include "page.h"
00124 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00125 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00126 //#include "mario.h"
00127 //#include "simon.h"
00128 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00129 //#include "blobtab.h"
00130 #include <stdlib.h>
00131 
00132 #include "bfxatom.h"
00133 #include "tracergn.h"
00134 #include "bubbleid.h"
00135 
00136 CC_IMPLEMENT_DYNCREATE(BlobbyOp, UndoableOperation)
00137 CC_IMPLEMENT_DYNCREATE(UndoColAction, Action)
00138 CC_IMPLEMENT_DYNCREATE(RedoColAction, Action)
00139 CC_IMPLEMENT_DYNCREATE(UndoAction2, Action)
00140 CC_IMPLEMENT_DYNCREATE(UndoAction3, Action)
00141 CC_IMPLEMENT_DYNCREATE(RedoAction2, Action)
00142 CC_IMPLEMENT_DYNCREATE(RedoAction3, Action)
00143 CC_IMPLEMENT_DYNCREATE(BlobbyDlg, DialogOp)
00144 CC_IMPLEMENT_DYNCREATE(BlobbyBar, DialogOp)
00145 CC_IMPLEMENT_DYNCREATE(BlobbyTabDlg, DialogTabOp)
00146 
00147 #define new CAM_DEBUG_NEW
00148 
00149 //-------------------------------------------------------------------------------------------
00150 // Temporary Blobby operation to demonstrate the Operation history
00151 // BlobbyOp is a simple undoable operation which changes the current colour of
00152 // a document's pages. It is implemented using 3 pairs of Undo and Redo actions.
00153 // Only the UndoColAction and RedoColAction perform any redo/undo, the other
00154 // actions do nothing when executed. They exist only to test an operation's
00155 // ability to cope with more than a single action on each action list.
00156 
00157 /********************************************************************************************
00158 
00159 >   BlobbyOp::BlobbyOp()
00160 
00161     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00162     Created:    16/8/93
00163     Inputs:     -
00164     Outputs:    -
00165     Returns:    -
00166     Purpose:    BlobbyOp constructor
00167     Errors:     -
00168     SeeAlso:    -
00169 
00170 ********************************************************************************************/
00171 
00172 BlobbyOp::BlobbyOp(): UndoableOperation()
00173 {
00174 }
00175 
00176 /********************************************************************************************
00177 
00178 >   BOOL BlobbyOp::Init()
00179 
00180     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00181     Created:    16/8/93
00182     Inputs:     -
00183     Outputs:    -
00184     Returns:    TRUE if the operation could be successfully initialised
00185                 FALSE if no more memory could be allocated
00186 
00187     Purpose:    BlobyOp initialiser method
00188     Errors:     ERROR will be called if there was insufficient memory to allocate the
00189                 operation.
00190     SeeAlso:    -
00191 
00192 ********************************************************************************************/
00193 
00194 BOOL BlobbyOp::Init()
00195 {
00196     return (UndoableOperation::RegisterOpDescriptor(
00197                                             0,
00198                                             _R(IDS_BLOBBY_OP),
00199                                             CC_RUNTIME_CLASS(BlobbyOp),
00200                                             OPTOKEN_BLOBBY,
00201                                             BlobbyOp::GetState,
00202                                             0,  /* help ID */
00203                                             _R(IDBBL_BLOBBYOP),
00204                                             0   /* bitmap ID */));
00205 }
00206 
00207 /********************************************************************************************
00208 
00209 >   OpState BlobbyOp::GetState(String_256*, OpDescriptor*)
00210 
00211     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00212     Created:    16/8/93
00213     Inputs:     -
00214     Outputs:    -
00215     Returns:    The state of the BlobbyOp
00216     Purpose:    For finding the BlobbyOp's state.
00217     Errors:     -
00218     SeeAlso:    -
00219 
00220 ********************************************************************************************/
00221 
00222 OpState BlobbyOp::GetState(String_256*, OpDescriptor*)
00223 {
00224     OpState OpSt;
00225     return(OpSt);
00226 }
00227 
00228 /********************************************************************************************
00229 
00230 >   void BlobbyOp::Do(OpDescriptor*)
00231 
00232     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00233     Created:    16/8/93
00234     Inputs:     OpDescriptor (unused)
00235     Outputs:    -
00236     Returns:    -
00237     Purpose:    Performs the BlobbyOp for the first time
00238     Errors:     -
00239     SeeAlso:    -
00240 
00241 ********************************************************************************************/
00242 
00243 void BlobbyOp::Do(OpDescriptor*)
00244 {
00245 #if 1
00246     ActionCode ActCode;
00247     UndoColAction* UndoColAct;
00248 
00249     // Attempt to initialise the first action for blobby op
00250     if ((ActCode = UndoColAction::Init(this,
00251                                          &UndoActions,
00252                                          10,
00253                                         (Action**)(&UndoColAct))) != AC_FAIL) // 10 is bodge
00254         // If the action was successfully initialised i.e. AC_OK or AC_NO_RECORD then
00255         // record the current colour of a page in the undo action.
00256         UndoColAct->Color = Page::GetPageColour();
00257 
00258     if (ActCode != AC_FAIL)  // i.e. The ActCode = AC_OK or AC_NO_RECORD
00259     {
00260         DocColour Col ((INT32)(rand()%255),
00261                                         (INT32)(rand()%255),
00262                                         (INT32)(rand()%255));
00263         // Give the page a random colour
00264         Page::SetPageColour(Col);
00265     // Redraw the document to see the change in the page's colour
00266         (DocView::GetSelected())->ForceRedraw();
00267 
00268         //if (IsUserName("Simon"))
00269         // TRACE( _T("Created undo action 1\n"));
00270 
00271         UndoAction2* UndoAct2;
00272 
00273         // Try to init a second undo action (this one will perform nothing when executed)
00274         if  (UndoAction2::Init(this,
00275                               &UndoActions,
00276                               10,
00277                               (Action**)(&UndoAct2)) != AC_FAIL)
00278         {
00279             // The Undo action was successfully initialised
00280             //if (IsUserName("Simon"))
00281             //{
00282             //  TRACE( _T("Created undo action 2\n"));
00283             //}
00284             UndoAction3* UndoAct3;
00285 
00286             // Try to Init a third undo action (again this will perform nothing when executed)
00287             UndoAction3::Init(this,
00288                                  &UndoActions,
00289                                  10,
00290                                  (Action**)(&UndoAct3));
00291         }
00292     }
00293 
00294     #ifdef _DEBUG
00295     // Remember our working document
00296     Document *pDoc = GetWorkingDoc();
00297     #endif
00298 
00299     // End the operation
00300     End();
00301 
00302     #ifdef _DEBUG
00303     // Ensure that the size of the operation history is valid
00304     pDoc->GetOpHistory().DebugSizeCheck();
00305     #endif
00306 #else
00307     //BitmapEffectAtom::Test2(this);
00308     TraceRegion::Test(this);
00309     // End the operation
00310     End();
00311 
00312 #endif
00313 }
00314 
00315 /********************************************************************************************
00316 
00317 >   UndoColAction::UndoColAction()
00318 
00319     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00320     Created:    16/8/93
00321     Inputs:     -
00322     Outputs:    -
00323     Returns:    -
00324     Purpose:    UndoColAction constructor
00325     Errors:     -
00326     SeeAlso:    -
00327 
00328 ********************************************************************************************/
00329 
00330 UndoColAction::UndoColAction():Action()
00331 {
00332 }
00333 
00334 /********************************************************************************************
00335 
00336 >   ActionCode UndoColAction::Init(Operation* const pOp,
00337                                    ActionList* pActionList,
00338                                    UINT32 ActionSize,
00339                                    Action** NewAction)
00340 
00341     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00342     Created:    16/8/93
00343 
00344     Inputs:     pOp: The operation to which the action should be added
00345 
00346                 pActionList: The action list in the operation object
00347 
00348                 Size:        The size of the action in bytes. This should be the total
00349                              size of the action (including any objects pointed to by the
00350                              action).
00351 
00352     Outputs:    NewAction:   A pointer to the action if it could be allocated.
00353 
00354     Returns:    AC_FAIL:     There was not enough room in the operation history for the
00355                              action and the user did not wish to continue. Usually
00356                              End() should be called in this situation.
00357 
00358                 AC_NORECORD: There was not enough room in the operation history for
00359                              the action, but the user requested that he wished to
00360                              continue without undo.
00361 
00362                 AC_OK      : The action was successfully initialised and added to the
00363                              operation.
00364 
00365 
00366     Purpose:    To check that there is sufficient room for the action in the operation
00367                 history, and if there is, then to add the action to the operations
00368                 action list.
00369 
00370                 The function simply calls the Action::Init function passing the runtime class
00371                 of an UndoColAction.
00372     Errors:     -
00373     SeeAlso:    Action::Init
00374 
00375 ********************************************************************************************/
00376 
00377 ActionCode UndoColAction::Init(Operation* const pOp,
00378                                ActionList* pActionList,
00379                                UINT32 ActionSize,
00380                                Action** NewAction)
00381 {
00382 
00383     return(Action::Init(pOp,
00384                         pActionList,
00385                         ActionSize,
00386                         CC_RUNTIME_CLASS(UndoColAction),
00387                         NewAction));
00388 }
00389 
00390 /********************************************************************************************
00391 
00392 >   ActionCode UndoColAction::Execute()
00393 
00394     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00395     Created:    16/8/93
00396     Inputs:     -
00397     Outputs:    ActionCode indicating if the action was successfully executed or not
00398     Returns:    -
00399     Purpose:    Executes the UndoColAction setting the paper colour to the colour it was
00400                 prior to the operation being done or redone.
00401     Errors:     -
00402     SeeAlso:    -
00403 
00404 ********************************************************************************************/
00405 
00406 ActionCode UndoColAction::Execute()
00407 {
00408     RedoColAction* RedoColAct;
00409     ActionCode ActCode;
00410     // Attempt to initialise the action
00411     if ((ActCode = RedoColAction::Init(pOperation,
00412                                        pOperation->GetRedoActionList(),
00413                                        10,
00414                                        ((Action**)&RedoColAct))) != AC_FAIL) // 10 is bodge
00415         if (RedoColAct != NULL) // Check we are not unwinding
00416             RedoColAct->Color = Page::GetPageColour();
00417 
00418     if (ActCode != AC_FAIL)
00419     {
00420         // The action did not fail to initialise
00421         Page::SetPageColour(Color);               // Set the paper colour to the colour it was
00422                                                   // prior to the operation being done or redone
00423         (DocView::GetSelected())->ForceRedraw();   // Show the new colour
00424     }
00425     return (ActCode);
00426 }
00427 
00428 
00429 /********************************************************************************************
00430 
00431 >   RedoColAction::RedoColAction()
00432 
00433     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00434     Created:    16/8/93
00435     Inputs:     -
00436     Outputs:    -
00437     Returns:    -
00438     Purpose:    RedoColAction constructor
00439     Errors:     -
00440     SeeAlso:    -
00441 
00442 ********************************************************************************************/
00443 
00444 RedoColAction::RedoColAction():Action()
00445 {
00446 }
00447 
00448 /********************************************************************************************
00449 
00450 >   ActionCode RedoColAction::Init(Operation* const pOp,
00451                                    ActionList* pActionList,
00452                                    UINT32 ActionSize,
00453                                    Action** NewAction)
00454 
00455     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00456     Created:    16/8/93
00457 
00458     Inputs:     pOp: The operation to which the action should be added
00459 
00460                 pActionList: The action list in the operation object
00461 
00462                 Size:        The size of the action in bytes. This should be the total
00463                              size of the action (including any objects pointed to by the
00464                              action).
00465 
00466     Outputs:    NewAction:   A pointer to the action if it could be allocated.
00467 
00468     Returns:    AC_FAIL:     There was not enough room in the operation history for the
00469                              action and the user did not wish to continue. Usually
00470                              End() should be called in this situation.
00471 
00472                 AC_NORECORD: There was not enough room in the operation history for
00473                              the action, but the user requested that he wished to
00474                              continue without undo.
00475 
00476                 AC_OK      : The action was successfully initialised and added to the
00477                              operation.
00478 
00479 
00480     Purpose:    To check that there is sufficient room for the action in the operation
00481                 history, and if there is, then to add the action to the operations
00482                 action list.
00483 
00484                 The function simply calls the Action::Init function passing the runtime class
00485                 of a RedoColAction.
00486     Errors:     -
00487     SeeAlso:    Action::Init
00488 
00489 ********************************************************************************************/
00490 
00491 
00492 ActionCode RedoColAction::Init(Operation* const pOp,
00493                                ActionList* pActionList,
00494                                UINT32 ActionSize,
00495                                Action** NewAction)
00496 {
00497     return(Action::Init(pOp,
00498                         pActionList,
00499                         ActionSize,
00500                         CC_RUNTIME_CLASS(RedoColAction),
00501                         NewAction));
00502 }
00503 
00504 /********************************************************************************************
00505 
00506 >   ActionCode RedoColAction::Execute()
00507 
00508     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00509     Created:    16/8/93
00510     Inputs:     -
00511     Outputs:    ActionCode indicating if the action was successfully executed or not
00512     Returns:    -
00513     Purpose:    Executes the RedoColAction setting the paper colour to the colour it was
00514                 prior to the operation being undone.
00515     Errors:     -
00516     SeeAlso:    -
00517 
00518 ********************************************************************************************/
00519 
00520 
00521 ActionCode RedoColAction::Execute()
00522 {
00523     UndoColAction* UndoColAct;
00524     ActionCode ActCode;
00525     // Attempt to initialise the action
00526     if ((ActCode = UndoColAction::Init(pOperation,
00527                                        pOperation->GetUndoActionList(),
00528                                        10,
00529                                        ((Action**)&UndoColAct))) == AC_OK) // 10 is bodge
00530         if (UndoColAct != NULL)// Check we are not unwinding
00531             UndoColAct->Color = Page::GetPageColour();
00532 
00533     if (ActCode != AC_FAIL)
00534     {
00535         // The action was successfully initialised
00536         Page::SetPageColour(Color);                 // Set the page colour to the colour it was
00537                                                     // prior to the operation being undone.
00538         (DocView::GetSelected())->ForceRedraw();    // Show the colour change
00539     }
00540     return (ActCode);
00541 }
00542 
00543 // Redo Action 2 & 3 do nothing, they exist to test an operation with more than a single action
00544 
00545 /********************************************************************************************
00546 
00547 >   RedoAction2::RedoAction2()
00548 
00549     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00550     Created:    16/8/93
00551     Inputs:     -
00552     Outputs:    -
00553     Returns:    -
00554     Purpose:    RedoAction2 constructor
00555     Errors:     -
00556     SeeAlso:    -
00557 
00558 ********************************************************************************************/
00559 
00560 RedoAction2::RedoAction2():Action()
00561 {
00562 }
00563 
00564 
00565 /********************************************************************************************
00566 
00567 >   ActionCode RedoAction2::Init(Operation* const pOp,
00568                                    ActionList* pActionList,
00569                                    UINT32 ActionSize,
00570                                    Action** NewAction)
00571 
00572     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00573     Created:    16/8/93
00574 
00575     Inputs:     pOp: The operation to which the action should be added
00576 
00577                 pActionList: The action list in the operation object
00578 
00579                 Size:        The size of the action in bytes. This should be the total
00580                              size of the action (including any objects pointed to by the
00581                              action).
00582 
00583     Outputs:    NewAction:   A pointer to the action if it could be allocated.
00584 
00585     Returns:    AC_FAIL:     There was not enough room in the operation history for the
00586                              action and the user did not wish to continue. Usually
00587                              End() should be called in this situation.
00588 
00589                 AC_NORECORD: There was not enough room in the operation history for
00590                              the action, but the user requested that he wished to
00591                              continue without undo.
00592 
00593                 AC_OK      : The action was successfully initialised and added to the
00594                              operation.
00595 
00596 
00597     Purpose:    To check that there is sufficient room for the action in the operation
00598                 history, and if there is, then to add the action to the operations
00599                 action list.
00600 
00601                 The function simply calls the Action::Init function passing the runtime class
00602                 of a RedoAction2.
00603     Errors:     -
00604     SeeAlso:    Action::Init
00605 
00606 ********************************************************************************************/
00607 
00608 
00609 ActionCode RedoAction2::Init(Operation* const pOp,
00610                                ActionList* pActionList,
00611                                UINT32 ActionSize,
00612                                Action** NewAction)
00613 {
00614     return(Action::Init(pOp,
00615                         pActionList,
00616                         ActionSize,
00617                         CC_RUNTIME_CLASS(RedoAction2),
00618                         NewAction));
00619 }
00620 
00621 /********************************************************************************************
00622 
00623 >   ActionCode RedoAction2::Execute()
00624 
00625     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00626     Created:    16/8/93
00627     Inputs:     -
00628     Outputs:    ActionCode indicating if the action was successfully executed or not
00629     Returns:    -
00630     Purpose:    To execute RedoAction2. Does nothing except spawn an UndoAction2 action.
00631     Errors:     -
00632     SeeAlso:    -
00633 
00634 ********************************************************************************************/
00635 
00636 ActionCode RedoAction2::Execute()
00637 {
00638     UndoAction2* UndoAct;
00639     ActionCode ActCode;
00640     ActCode = UndoAction2::Init(pOperation,
00641                                 pOperation->GetUndoActionList(),
00642                                 10,
00643                                 ((Action**)&UndoAct)); // 10 is bodge
00644 
00645     if (ActCode != AC_FAIL)
00646     {
00647         //if (IsUserName("Simon"))
00648         //  TRACE( _T("Executing REDO Action 2\n"));
00649     }
00650     return (ActCode);
00651 }
00652 
00653 
00654 /********************************************************************************************
00655 
00656 >   RedoAction3::RedoAction3():Action()
00657 
00658     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00659     Created:    16/8/93
00660     Inputs:     -
00661     Outputs:    -
00662     Returns:    -
00663     Purpose:    RedoAction3 constructor
00664     Errors:     -
00665     SeeAlso:    -
00666 
00667 ********************************************************************************************/
00668 
00669 RedoAction3::RedoAction3():Action()
00670 {
00671 }
00672 
00673 /********************************************************************************************
00674 
00675 >   ActionCode RedoAction3::Init(Operation* const pOp,
00676                                    ActionList* pActionList,
00677                                    UINT32 ActionSize,
00678                                    Action** NewAction)
00679 
00680     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00681     Created:    16/8/93
00682 
00683     Inputs:     pOp: The operation to which the action should be added
00684 
00685                 pActionList: The action list in the operation object
00686 
00687                 Size:        The size of the action in bytes. This should be the total
00688                              size of the action (including any objects pointed to by the
00689                              action).
00690 
00691     Outputs:    NewAction:   A pointer to the action if it could be allocated.
00692 
00693     Returns:    AC_FAIL:     There was not enough room in the operation history for the
00694                              action and the user did not wish to continue. Usually
00695                              End() should be called in this situation.
00696 
00697                 AC_NORECORD: There was not enough room in the operation history for
00698                              the action, but the user requested that he wished to
00699                              continue without undo.
00700 
00701                 AC_OK      : The action was successfully initialised and added to the
00702                              operation.
00703 
00704 
00705     Purpose:    To check that there is sufficient room for the action in the operation
00706                 history, and if there is, then to add the action to the operations
00707                 action list.
00708 
00709                 The function simply calls the Action::Init function passing the runtime class
00710                 of a RedoAction3.
00711     Errors:     -
00712     SeeAlso:    Action::Init
00713 
00714 ********************************************************************************************/
00715 
00716 
00717 ActionCode RedoAction3::Init(Operation* const pOp,
00718                                ActionList* pActionList,
00719                                UINT32 ActionSize,
00720                                Action** NewAction)
00721 {
00722     return(Action::Init(pOp,
00723                         pActionList,
00724                         ActionSize,
00725                         CC_RUNTIME_CLASS(RedoAction3),
00726                         NewAction));
00727 }
00728 
00729 
00730 /********************************************************************************************
00731 
00732 >   ActionCode RedoAction3::Execute()
00733 
00734     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00735     Created:    16/8/93
00736     Inputs:     -
00737     Outputs:    -
00738     Returns:    ActionCode indicating if the action was successfully executed or not
00739     Purpose:    To execute RedoAction3. Does nothing except spawn an UndoAction3 action.
00740     Errors:     -
00741     SeeAlso:    -
00742 
00743 ********************************************************************************************/
00744 
00745 
00746 ActionCode RedoAction3::Execute()
00747 {
00748     UndoAction3* UndoAct;
00749     ActionCode ActCode;
00750     ActCode = UndoAction3::Init(pOperation,
00751                                 pOperation->GetUndoActionList(),
00752                                 10,
00753                                 ((Action**)&UndoAct)); // 10 is bodge
00754 
00755     if (ActCode != AC_FAIL)
00756     {
00757         //if (IsUserName("Simon"))
00758         //  TRACE( _T("Executing REDO Action 3\n"));
00759     }
00760     return (ActCode);
00761 }
00762 
00763 // Likewise undo action 2 & 3 are also for debugging and do nothing
00764 
00765 /********************************************************************************************
00766 
00767 >   UndoAction2::UndoAction2():Action()
00768 
00769     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00770     Created:    16/8/93
00771     Inputs:     -
00772     Outputs:    -
00773     Returns:    -
00774     Purpose:    UndoAction2 constructor
00775     Errors:     -
00776     SeeAlso:    -
00777 
00778 ********************************************************************************************/
00779 
00780 
00781 UndoAction2::UndoAction2():Action()
00782 {
00783 }
00784 
00785 /********************************************************************************************
00786 
00787 >   ActionCode UndoAction2::Init(Operation* const pOp,
00788                                    ActionList* pActionList,
00789                                    UINT32 ActionSize,
00790                                    Action** NewAction)
00791 
00792     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00793     Created:    16/8/93
00794 
00795     Inputs:     pOp: The operation to which the action should be added
00796 
00797                 pActionList: The action list in the operation object
00798 
00799                 Size:        The size of the action in bytes. This should be the total
00800                              size of the action (including any objects pointed to by the
00801                              action).
00802 
00803     Outputs:    NewAction:   A pointer to the action if it could be allocated.
00804 
00805     Returns:    AC_FAIL:     There was not enough room in the operation history for the
00806                              action and the user did not wish to continue. Usually
00807                              End() should be called in this situation.
00808 
00809                 AC_NORECORD: There was not enough room in the operation history for
00810                              the action, but the user requested that he wished to
00811                              continue without undo.
00812 
00813                 AC_OK      : The action was successfully initialised and added to the
00814                              operation.
00815 
00816 
00817     Purpose:    To check that there is sufficient room for the action in the operation
00818                 history, and if there is, then to add the action to the operations
00819                 action list.
00820 
00821                 The function simply calls the Action::Init function passing the runtime class
00822                 of an UndoAction2.
00823     Errors:     -
00824     SeeAlso:    Action::Init
00825 
00826 ********************************************************************************************/
00827 
00828 
00829 ActionCode UndoAction2::Init(Operation* const pOp,
00830                                ActionList* pActionList,
00831                                UINT32 ActionSize,
00832                                Action** NewAction)
00833 {
00834     return(Action::Init(pOp,
00835                         pActionList,
00836                         ActionSize,
00837                         CC_RUNTIME_CLASS(UndoAction2),
00838                         NewAction));
00839 }
00840 
00841 /********************************************************************************************
00842 
00843 >   ActionCode UndoAction2::Execute()
00844 
00845     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00846     Created:    16/8/93
00847     Inputs:     -
00848     Outputs:    -
00849     Returns:    ActionCode indicating if the action was successfully executed or not
00850     Purpose:    To execute UndoAction2. Does nothing except spawn a RedoAction2 action.
00851     Errors:     -
00852     SeeAlso:    -
00853 
00854 ********************************************************************************************/
00855 
00856 
00857 ActionCode UndoAction2::Execute()
00858 {
00859     RedoAction2* RedoAct;
00860     ActionCode ActCode;
00861     ActCode = RedoAction2::Init(pOperation,
00862                                 pOperation->GetRedoActionList(),
00863                                 10,
00864                                 ((Action**)&RedoAct)); // 10 is bodge
00865 
00866     if (ActCode != AC_FAIL)
00867     {
00868         //if (IsUserName("Simon"))
00869         //  TRACE( _T("Executing Undo Action 2\n"));
00870     }
00871     return (ActCode);
00872 }
00873 
00874 
00875 /********************************************************************************************
00876 
00877 >   UndoAction3::UndoAction3():Action()
00878 
00879     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00880     Created:    16/8/93
00881     Inputs:     -
00882     Outputs:    -
00883     Returns:    -
00884     Purpose:    UndoAction3 constructor
00885     Errors:     -
00886     SeeAlso:    -
00887 
00888 ********************************************************************************************/
00889 
00890 
00891 UndoAction3::UndoAction3():Action()
00892 {
00893 }
00894 
00895 /********************************************************************************************
00896 
00897 >   ActionCode UndoAction3::Init(Operation* const pOp,
00898                                    ActionList* pActionList,
00899                                    UINT32 ActionSize,
00900                                    Action** NewAction)
00901 
00902     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00903     Created:    16/8/93
00904 
00905     Inputs:     pOp: The operation to which the action should be added
00906 
00907                 pActionList: The action list in the operation object
00908 
00909                 Size:        The size of the action in bytes. This should be the total
00910                              size of the action (including any objects pointed to by the
00911                              action).
00912 
00913     Outputs:    NewAction:   A pointer to the action if it could be allocated.
00914 
00915     Returns:    AC_FAIL:     There was not enough room in the operation history for the
00916                              action and the user did not wish to continue. Usually
00917                              End() should be called in this situation.
00918 
00919                 AC_NORECORD: There was not enough room in the operation history for
00920                              the action, but the user requested that he wished to
00921                              continue without undo.
00922 
00923                 AC_OK      : The action was successfully initialised and added to the
00924                              operation.
00925 
00926 
00927     Purpose:    To check that there is sufficient room for the action in the operation
00928                 history, and if there is, then to add the action to the operations
00929                 action list.
00930 
00931                 The function simply calls the Action::Init function passing the runtime class
00932                 of an UndoAction3.
00933     Errors:     -
00934     SeeAlso:    Action::Init
00935 
00936 ********************************************************************************************/
00937 
00938 
00939 ActionCode UndoAction3::Init(Operation* const pOp,
00940                                ActionList* pActionList,
00941                                UINT32 ActionSize,
00942                                Action** NewAction)
00943 {
00944     return(Action::Init(pOp,
00945                         pActionList,
00946                         ActionSize,
00947                         CC_RUNTIME_CLASS(UndoAction3),
00948                         NewAction));
00949 }
00950 
00951 /********************************************************************************************
00952 
00953 >   ActionCode UndoAction3::Execute()
00954 
00955     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00956     Created:    16/8/93
00957     Inputs:     -
00958     Outputs:    -
00959     Returns:    ActionCode indicating if the action was successfully executed or not
00960     Purpose:    To execute UndoAction3. Does nothing except spawn a RedoAction3 action.
00961     Errors:     -
00962     SeeAlso:    -
00963 
00964 ********************************************************************************************/
00965 
00966 
00967 ActionCode UndoAction3::Execute()
00968 {
00969     RedoAction3* RedoAct;
00970     ActionCode ActCode;
00971     ActCode = RedoAction3::Init(pOperation,
00972                                 pOperation->GetRedoActionList(),
00973                                 10,
00974                                 ((Action**)&RedoAct)); // 10 is bodge
00975 
00976     if (ActCode != AC_FAIL)
00977     {
00978         //if (IsUserName("Simon"))
00979         //  TRACE( _T("Executing Undo Action 3\n"));
00980     }
00981     return (ActCode);
00982 }
00983 
00984 //------------------------------------------------------------------------------------------
00985 // Demo Dialog
00986 
00987 const CDlgMode BlobbyDlg::Mode = MODELESS;// Mode of the dialog
00988 
00989 const UINT32 BlobbyDlg::IDD = _R(IDD_BLOBBYDLG);
00990 
00991 BlobbyDlg::BlobbyDlg(): DialogOp(BlobbyDlg::IDD, BlobbyDlg::Mode)
00992 {
00993 }
00994 
00995 // -----------------------------------------------------------------------------------------
00996 
00997 void InitValues(BlobbyDlg* pBlob)
00998 {
00999 
01000     String_256 Wibble("WIBBLE");
01001     String_256 Wobble("WOBBLE");
01002     pBlob->SetStringGadgetValue(_R(IDC_BUTTON1),
01003                                  Wibble);
01004     pBlob->SetStringGadgetValue(_R(IDC_BUTTON2),
01005                                 Wobble);
01006 
01007     // Fill lists
01008     String_256 StrList[5*5];
01009     char a, b;
01010     INT32 i=0;
01011 
01012     for(a='e'; a>='a';a--)
01013     {
01014         for (b='a'; b<='e';b++)
01015         {
01016             ((TCHAR*)StrList[i])[0] = a;
01017             ((TCHAR*)StrList[i])[1] = b;
01018             ((TCHAR*)StrList[i])[2] = 0;
01019             pBlob->SetStringGadgetValue(_R(IDC_LIST1), StrList[i],FALSE,i);
01020             i++;
01021         }
01022     }
01023     // Scroll bars
01024     pBlob->SetLongGadgetValue(_R(IDC_SCROLLBAR1), 60, 10);
01025     pBlob->SetLongGadgetValue(_R(IDC_SCROLLBAR2), 60, 10);
01026     BOOL Valid;
01027     MILLIPOINT Value = (MILLIPOINT)(pBlob->GetLongGadgetValue(_R(IDC_SCROLLBAR1),10,100,0,&Valid)*72000);
01028     pBlob->SetUnitGadgetValue(_R(IDC_XVAL), INCHES, Value);
01029     Value = (MILLIPOINT)(pBlob->GetLongGadgetValue(_R(IDC_SCROLLBAR2),10,100,0,&Valid)*72000);
01030     pBlob->SetUnitGadgetValue(_R(IDC_YVAL), INCHES, Value);
01031 
01032     // Combos
01033     pBlob->DefaultUnit = INCHES;    // Default unit
01034     pBlob->ConvUnit = MILLIMETRES;  // Conversion unit
01035 
01036     // RadioBoxes
01037     pBlob->SetLongGadgetValue(_R(IDC_RADIO11), TRUE);
01038     pBlob->SetLongGadgetValue(_R(IDC_RADIO12), FALSE);
01039     pBlob->SetLongGadgetValue(_R(IDC_RADIO13), FALSE);
01040 
01041     pBlob->SetLongGadgetValue(_R(IDC_RADIO21), FALSE);
01042     pBlob->SetLongGadgetValue(_R(IDC_RADIO22), FALSE);
01043     pBlob->SetLongGadgetValue(_R(IDC_RADIO23), TRUE);
01044 }
01045 
01046 // -----------------------------------------------------------------------------------------
01047 
01048 void HideGadgets(BlobbyDlg* pBlob)
01049 {
01050     BOOL Valid;
01051     BOOL Hide = (BOOL)(pBlob->GetLongGadgetValue(_R(IDC_CHECK2),0,1,0,&Valid));
01052     pBlob->HideGadget(_R(IDC_STATIC1), Hide);
01053     pBlob->HideGadget(_R(IDC_STATIC2), Hide);
01054     pBlob->HideGadget(_R(IDC_STATIC3), Hide);
01055     pBlob->HideGadget(_R(IDC_STATIC4), Hide);
01056     pBlob->HideGadget(_R(IDC_BUTTON1), Hide);
01057     pBlob->HideGadget(_R(IDC_BUTTON2), Hide);
01058     pBlob->HideGadget(_R(IDC_SCROLLBAR1), Hide);
01059     pBlob->HideGadget(_R(IDC_SCROLLBAR2), Hide);
01060     pBlob->HideGadget(_R(IDOK), Hide);
01061     pBlob->HideGadget(_R(IDCANCEL), Hide);
01062     pBlob->HideGadget(_R(IDC_CHECK1), Hide);
01063     pBlob->HideGadget(_R(IDC_STATIC6), Hide);
01064     pBlob->HideGadget(_R(IDC_LIST1), Hide);
01065     pBlob->HideGadget(_R(IDC_LIST2), Hide);
01066 
01067     pBlob->HideGadget(_R(IDC_RADIO11), Hide);
01068     pBlob->HideGadget(_R(IDC_RADIO12), Hide);
01069     pBlob->HideGadget(_R(IDC_RADIO13), Hide);
01070     pBlob->HideGadget(_R(IDC_RADIO21), Hide);
01071     pBlob->HideGadget(_R(IDC_RADIO22), Hide);
01072     pBlob->HideGadget(_R(IDC_RADIO23), Hide);
01073 
01074     pBlob->HideGadget(_R(IDC_EDIT1), Hide);
01075     pBlob->HideGadget(_R(IDC_EDIT2), Hide);
01076     pBlob->HideGadget(_R(IDC_EDIT3), Hide);
01077 
01078     pBlob->HideGadget(_R(IDC_STCONV), Hide);
01079     pBlob->HideGadget(_R(IDC_STDEF), Hide);
01080     pBlob->HideGadget(_R(IDC_STCT), Hide);
01081     pBlob->HideGadget(_R(IDC_UNITVAL), Hide);
01082     pBlob->HideGadget(_R(IDC_CONVVAL), Hide);
01083     pBlob->HideGadget(_R(IDC_STUV), Hide);
01084     pBlob->HideGadget(_R(IDC_CONV), Hide);
01085     pBlob->HideGadget(_R(IDC_BUTTON3), Hide);
01086     pBlob->HideGadget(_R(IDC_STRD), Hide);
01087 
01088     pBlob->HideGadget(_R(IDC_STRD), Hide);
01089     pBlob->HideGadget(_R(IDC_YVAL), Hide);
01090     pBlob->HideGadget(_R(IDC_XVAL), Hide);
01091     pBlob->HideGadget(_R(IDC_STDEF), Hide);
01092     pBlob->HideGadget(_R(IDC_COMBO3), Hide);
01093     pBlob->HideGadget(_R(IDC_COMBO4), Hide);
01094     pBlob->HideGadget(_R(IDC_STCT), Hide);
01095     pBlob->HideGadget(_R(IDC_STUV), Hide);
01096 
01097     pBlob->HideGadget(_R(IDC_VLD), Hide);
01098     pBlob->HideGadget(_R(ID_STINT), Hide);
01099     pBlob->HideGadget(_R(IDC_STRL), Hide);
01100     pBlob->HideGadget(_R(IDC_STXYZ), Hide);
01101     pBlob->HideGadget(_R(IDC_EDIT1), Hide);
01102     pBlob->HideGadget(_R(IDC_EDIT2), Hide);
01103     pBlob->HideGadget(_R(IDC_EDIT3), Hide);
01104 }
01105 
01106 // -----------------------------------------------------------------------------------------
01107 
01108 void EnableGadgets(BlobbyDlg* pBlob)
01109 {
01110     BOOL Valid;
01111     BOOL Enable = !((BOOL)(pBlob->GetLongGadgetValue(_R(IDC_CHECK1), 0,1,0,&Valid)));
01112     pBlob->EnableGadget(_R(IDC_STATIC1), Enable);
01113     pBlob->EnableGadget(_R(IDC_STATIC2), Enable);
01114     pBlob->EnableGadget(_R(IDC_STATIC3), Enable);
01115     pBlob->EnableGadget(_R(IDC_STATIC4), Enable);
01116     pBlob->EnableGadget(_R(IDC_BUTTON1), Enable);
01117     pBlob->EnableGadget(_R(IDC_BUTTON2), Enable);
01118     pBlob->EnableGadget(_R(IDC_SCROLLBAR1), Enable);
01119     pBlob->EnableGadget(_R(IDC_SCROLLBAR2), Enable);
01120     pBlob->EnableGadget(_R(IDOK), Enable);
01121     pBlob->EnableGadget(_R(IDCANCEL), Enable);
01122     pBlob->EnableGadget(_R(IDC_CHECK2), Enable);
01123     pBlob->EnableGadget(_R(IDC_STATIC6), Enable);
01124     pBlob->EnableGadget(_R(IDC_LIST1), Enable);
01125     pBlob->EnableGadget(_R(IDC_LIST2), Enable);
01126 
01127     pBlob->EnableGadget(_R(IDC_RADIO11), Enable);
01128     pBlob->EnableGadget(_R(IDC_RADIO12), Enable);
01129     pBlob->EnableGadget(_R(IDC_RADIO13), Enable);
01130     pBlob->EnableGadget(_R(IDC_RADIO21), Enable);
01131     pBlob->EnableGadget(_R(IDC_RADIO22), Enable);
01132     pBlob->EnableGadget(_R(IDC_RADIO23), Enable);
01133 
01134     pBlob->EnableGadget(_R(IDC_EDIT1), Enable);
01135     pBlob->EnableGadget(_R(IDC_EDIT2), Enable);
01136     pBlob->EnableGadget(_R(IDC_EDIT3), Enable);
01137 
01138     pBlob->EnableGadget(_R(IDC_STCONV), Enable);
01139     pBlob->EnableGadget(_R(IDC_STDEF), Enable);
01140     pBlob->EnableGadget(_R(IDC_STCT), Enable);
01141     pBlob->EnableGadget(_R(IDC_UNITVAL), Enable);
01142     pBlob->EnableGadget(_R(IDC_CONVVAL), Enable);
01143     pBlob->EnableGadget(_R(IDC_STUV), Enable);
01144     pBlob->EnableGadget(_R(IDC_CONV), Enable);
01145     pBlob->EnableGadget(_R(IDC_BUTTON3), Enable);
01146     pBlob->EnableGadget(_R(IDC_STRD), Enable);
01147 
01148     pBlob->EnableGadget(_R(IDC_STRD), Enable);
01149     pBlob->EnableGadget(_R(IDC_YVAL), Enable);
01150     pBlob->EnableGadget(_R(IDC_XVAL), Enable);
01151     pBlob->EnableGadget(_R(IDC_STDEF), Enable);
01152     pBlob->EnableGadget(_R(IDC_COMBO3), Enable);
01153     pBlob->EnableGadget(_R(IDC_COMBO4), Enable);
01154     pBlob->EnableGadget(_R(IDC_STCT), Enable);
01155     pBlob->EnableGadget(_R(IDC_STUV), Enable);
01156 
01157     pBlob->EnableGadget(_R(IDC_VLD), Enable);
01158     pBlob->EnableGadget(_R(ID_STINT), Enable);
01159     pBlob->EnableGadget(_R(IDC_STRL), Enable);
01160     pBlob->EnableGadget(_R(IDC_STXYZ), Enable);
01161     pBlob->EnableGadget(_R(IDC_EDIT1), Enable);
01162     pBlob->EnableGadget(_R(IDC_EDIT2), Enable);
01163     pBlob->EnableGadget(_R(IDC_EDIT3), Enable);
01164 }
01165 
01166 // -----------------------------------------------------------------------------------------
01167 
01168 MsgResult BlobbyDlg::Message( Msg* Message)
01169 {
01170 
01171     if (IS_OUR_DIALOG_MSG(Message))
01172     {
01173         DialogMsg* Msg = (DialogMsg*)Message;
01174         // Handle ok button
01175         if ((Msg->DlgMsg == DIM_COMMIT) || (Msg->DlgMsg == DIM_CANCEL))
01176         {
01177 
01178 #if 0
01179 BOOL Valid=0;
01180 INT32 Value = (INT32) GetUnitGadgetValue(_R(IDC_UNITVAL),DefaultUnit,-10000000,10000000,0,&Valid);
01181 BitmapEffectAtom::Test(Value);
01182 #endif
01183 
01184             Close(); // Hide the dialog
01185             End();
01186         }
01187         else if (Msg->DlgMsg == DIM_SOFT_COMMIT)
01188         {
01189             InitValues(this);
01190         }
01191 
01192         // wibblewobble
01193         if (((Msg->GadgetID == _R(IDC_BUTTON1)) || (Msg->GadgetID == _R(IDC_BUTTON2)))
01194              && (Msg->DlgMsg == DIM_LFT_BN_CLICKED))
01195         {
01196             BOOL Valid =0;
01197             String_256 Temp = GetStringGadgetValue(_R(IDC_BUTTON1), &Valid);
01198             String_256 Temp2 = GetStringGadgetValue(_R(IDC_BUTTON2), &Valid);
01199             SetStringGadgetValue(_R(IDC_BUTTON1),
01200                                  Temp2);
01201 
01202             SetStringGadgetValue(_R(IDC_BUTTON2),
01203                                  Temp);
01204             SetTitlebarName(&Temp); // Returns a BOOL !!!
01205         }
01206         // Hide and enable
01207         else if ((Msg->GadgetID == _R(IDC_CHECK2)) && (Msg->DlgMsg == DIM_LFT_BN_CLICKED))
01208         {
01209             HideGadgets(this);
01210         }
01211         else if ((Msg->GadgetID == _R(IDC_CHECK1)) && (Msg->DlgMsg == DIM_LFT_BN_CLICKED))
01212         {
01213             EnableGadgets(this);
01214         }
01215         // List sorting
01216         else if ((Msg->GadgetID == _R(IDC_LIST1)) && (Msg->DlgMsg == DIM_SELECTION_CHANGED_COMMIT))
01217         {
01218             // Add the selected item to the sorted list
01219             BOOL Valid =0;
01220             String_256 MoveStr = GetStringGadgetValue(_R(IDC_LIST1), &Valid);
01221             SetStringGadgetValue(_R(IDC_LIST2), MoveStr);
01222             // Delete the selected item
01223             WORD Index;
01224             GetValueIndex(_R(IDC_LIST1), &Index);
01225             DeleteValue(_R(IDC_LIST1), FALSE, Index);
01226         }
01227         else if ((Msg->GadgetID == _R(IDC_LIST2)) && (Msg->DlgMsg == DIM_SELECTION_CHANGED))
01228         {
01229             // Add the selected item to LIST1
01230             BOOL Valid =0;
01231             String_256 MoveStr = GetStringGadgetValue(_R(IDC_LIST2), &Valid);
01232             SetStringGadgetValue(_R(IDC_LIST1), MoveStr);
01233             // Delete the selected item
01234             WORD Index;
01235             GetValueIndex(_R(IDC_LIST2), &Index);
01236             DeleteValue(_R(IDC_LIST2), FALSE, Index);
01237         }
01238         // Scrollbars
01239         else if (Msg->GadgetID == _R(IDC_SCROLLBAR1))
01240         {
01241             BOOL Valid=0;
01242             INT32 Value = (MILLIPOINT)(GetLongGadgetValue(_R(IDC_SCROLLBAR1),0,100,0,&Valid)*72000);
01243             SetUnitGadgetValue(_R(IDC_XVAL), INCHES, Value);
01244         }
01245         else if (Msg->GadgetID == _R(IDC_SCROLLBAR2))
01246         {
01247             BOOL Valid=0;
01248             INT32 Value = (MILLIPOINT)(GetLongGadgetValue(_R(IDC_SCROLLBAR2),0,100,0,&Valid)*72000);
01249             SetUnitGadgetValue(_R(IDC_YVAL), INCHES, Value);
01250         }
01251         // Unit Conversion
01252         else if ((Msg->GadgetID == _R(IDC_COMBO3)) && (Msg->DlgMsg == DIM_SELECTION_CHANGED))
01253         {
01254 //          BOOL Valid=0;
01255             INT32 Index;
01256             GetValueIndex(_R(IDC_COMBO3),&Index);
01257             if ((Index >= 0) && (Index <= 8))
01258                 DefaultUnit = UnitList[Index];
01259         }
01260         else if ((Msg->GadgetID == _R(IDC_COMBO4)) && (Msg->DlgMsg == DIM_SELECTION_CHANGED))
01261         {
01262 //          BOOL Valid=0;
01263             INT32 Index;
01264             GetValueIndex(_R(IDC_COMBO4),&Index);
01265             if ((Index >= 0) && (Index <= 8))
01266                 ConvUnit = UnitList[Index];
01267         }
01268         else if ((Msg->GadgetID == _R(IDC_BUTTON3)) && (Msg->DlgMsg == DIM_LFT_BN_CLICKED))
01269         {
01270             BOOL Valid=0;
01271             MILLIPOINT Value = GetUnitGadgetValue(_R(IDC_UNITVAL),DefaultUnit,-10000000,10000000,0,&Valid);
01272             SetUnitGadgetValue(_R(IDC_CONVVAL), ConvUnit, Value);
01273         }
01274         // Radio buttons
01275         else if ((Msg->GadgetID == _R(IDC_RADIO11)) && (Msg->DlgMsg == DIM_LFT_BN_CLICKED))
01276         {
01277             SetLongGadgetValue(_R(IDC_RADIO23), TRUE);
01278             SetLongGadgetValue(_R(IDC_RADIO21), FALSE);
01279             SetLongGadgetValue(_R(IDC_RADIO22), FALSE);
01280 
01281         }
01282         else if ((Msg->GadgetID == _R(IDC_RADIO12)) && (Msg->DlgMsg == DIM_LFT_BN_CLICKED))
01283         {
01284             SetLongGadgetValue(_R(IDC_RADIO22), TRUE);
01285             SetLongGadgetValue(_R(IDC_RADIO21), FALSE);
01286             SetLongGadgetValue(_R(IDC_RADIO23), FALSE);
01287 
01288         }
01289         else if ((Msg->GadgetID == _R(IDC_RADIO13)) && (Msg->DlgMsg == DIM_LFT_BN_CLICKED))
01290         {
01291             SetLongGadgetValue(_R(IDC_RADIO21), TRUE);
01292             SetLongGadgetValue(_R(IDC_RADIO22), FALSE);
01293             SetLongGadgetValue(_R(IDC_RADIO23), FALSE);
01294         }
01295         else if ((Msg->GadgetID == _R(IDC_RADIO21)) && (Msg->DlgMsg == DIM_LFT_BN_CLICKED))
01296         {
01297             SetLongGadgetValue(_R(IDC_RADIO13), TRUE);
01298             SetLongGadgetValue(_R(IDC_RADIO11), FALSE);
01299             SetLongGadgetValue(_R(IDC_RADIO12), FALSE);
01300 
01301         }
01302         else if ((Msg->GadgetID == _R(IDC_RADIO22)) && (Msg->DlgMsg == DIM_LFT_BN_CLICKED))
01303         {
01304             SetLongGadgetValue(_R(IDC_RADIO12), TRUE);
01305             SetLongGadgetValue(_R(IDC_RADIO11), FALSE);
01306             SetLongGadgetValue(_R(IDC_RADIO13), FALSE);
01307 
01308         }
01309         else if ((Msg->GadgetID == _R(IDC_RADIO23)) && (Msg->DlgMsg == DIM_LFT_BN_CLICKED))
01310         {
01311             SetLongGadgetValue(_R(IDC_RADIO11), TRUE);
01312             SetLongGadgetValue(_R(IDC_RADIO12), FALSE);
01313             SetLongGadgetValue(_R(IDC_RADIO13), FALSE);
01314         }
01315 
01316         return (DLG_EAT_IF_HUNGRY(Msg));
01317     }
01318     return OK;
01319 }
01320 
01321 // -----------------------------------------------------------------------------------------
01322 
01323 OpState BlobbyDlg::GetState(String_256*, OpDescriptor*)
01324 {
01325     OpState OpSt;
01326     return(OpSt);
01327 }
01328 
01329 // -----------------------------------------------------------------------------------------
01330 
01331 BOOL BlobbyDlg::Init()
01332 {
01333 
01334 return (RegisterOpDescriptor(
01335                                 0,
01336                                 _R(IDS_BLOBBYDLG),
01337                                 CC_RUNTIME_CLASS(BlobbyDlg),
01338                                 OPTOKEN_BLOBBYDLG,
01339                                 BlobbyDlg::GetState,
01340                                 0,  /* help ID */
01341                                 _R(IDBBL_BLOBBYDLG),
01342                                 0   /* bitmap ID */
01343                                 ));
01344 
01345 }
01346 
01347 // -----------------------------------------------------------------------------------------
01348 
01349 BOOL BlobbyDlg::Create()
01350 {
01351     if (DialogOp::Create())
01352     {
01353         SetGadgetRange(_R(IDC_SCROLLBAR1), /*10*/ 0, 100, 10);
01354         SetGadgetRange(_R(IDC_SCROLLBAR2), /*10*/ 0, 100, 10);
01355 
01356         //DualFunctionButton(IDOK);
01357         SetEditGadgetType(_R(IDC_UNITVAL), UNIT_NUMERIC);
01358         SetEditGadgetType(_R(IDC_EDIT1), INT_NUMERIC);
01359         SetEditGadgetType(_R(IDC_EDIT2), REAL_NUMERIC);
01360         SetEditGadgetType(_R(IDC_EDIT3), _R(IDS_BLOBBYXYZ));
01361 
01362         UnitStrList[0] = String(TEXT("Millimetres"));
01363         UnitStrList[1] = String(TEXT("Centimetres"));
01364         UnitStrList[2] = String(TEXT("Metres"));
01365         UnitStrList[3] = String(TEXT("Inches"));
01366         UnitStrList[4] = String(TEXT("Feet"));
01367         UnitStrList[5] = String(TEXT("Yards"));
01368         UnitStrList[6] = String(TEXT("Points"));
01369         UnitStrList[7] = String(TEXT("Picas"));
01370         UnitStrList[8] = String(TEXT("Millipoints"));
01371 
01372         UnitList[0] = MILLIMETRES;
01373         UnitList[1] = CENTIMETRES;
01374         UnitList[2] = METRES;
01375         UnitList[3] = INCHES;
01376         UnitList[4] = FEET;
01377         UnitList[5] = YARDS;
01378         UnitList[6] = COMP_POINTS;
01379         UnitList[7] = PICAS;
01380         UnitList[8] = MILLIPOINTS;
01381 
01382         for (INT32 i=0; i<9; i++)
01383         {
01384             SetStringGadgetValue(_R(IDC_COMBO3), UnitStrList[i],FALSE,i);
01385             SetStringGadgetValue(_R(IDC_COMBO4), UnitStrList[i],FALSE,i);
01386         }
01387 
01388 
01389         InitValues(this);
01390 
01391         return TRUE;
01392     }
01393     else return FALSE;
01394 }
01395 
01396 // -----------------------------------------------------------------------------------------
01397 
01398 void BlobbyDlg::Do(OpDescriptor*)
01399 {
01400     Create();
01401     Open();
01402 }
01403 
01404 
01405 // -----------------------------------------------------------------------------------------
01406 // BlobbyTabDialog methods, BlobbyTabDialog is an example implementation of a tabbed dialog
01407 
01408 
01409 const CDlgMode BlobbyTabDlg::Mode = MODAL; // Mode of the dialog
01410 const UINT32 BlobbyTabDlg::IDD = _R(IDD_BLOBBYTABDLG); // Used to uniquely identify the tabbed dialog
01411                                                  // there is no actual resource associated with
01412                                                  // this ID.
01413 
01414 
01415 
01416 /********************************************************************************************
01417 >   BlobbyTabDlg::BlobbyTabDlg(): DialogTabOp(BlobbyTabDlg::IDD, BlobbyTabDlg::Mode)
01418 
01419 
01420     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01421     Created:    17/11/94
01422     Purpose:    The Constructor of the DialogTabOp derived class simply sets modality of the
01423                 dialog, and it's ID.
01424 
01425 ********************************************************************************************/
01426 
01427 
01428 
01429 BlobbyTabDlg::BlobbyTabDlg(): DialogTabOp(BlobbyTabDlg::IDD, BlobbyTabDlg::Mode)
01430 {
01431 
01432     // Init Internals for conversion page
01433     UnitStrList[0] = String(TEXT("Millimetres"));
01434     UnitStrList[1] = String(TEXT("Centimetres"));
01435     UnitStrList[2] = String(TEXT("Metres"));
01436     UnitStrList[3] = String(TEXT("Inches"));
01437     UnitStrList[4] = String(TEXT("Feet"));
01438     UnitStrList[5] = String(TEXT("Yards"));
01439     UnitStrList[6] = String(TEXT("Points"));
01440     UnitStrList[7] = String(TEXT("Picas"));
01441     UnitStrList[8] = String(TEXT("Millipoints"));
01442 
01443     UnitList[0] = MILLIMETRES;
01444     UnitList[1] = CENTIMETRES;
01445     UnitList[2] = METRES;
01446     UnitList[3] = INCHES;
01447     UnitList[4] = FEET;
01448     UnitList[5] = YARDS;
01449     UnitList[6] = COMP_POINTS;
01450     UnitList[7] = PICAS;
01451     UnitList[8] = MILLIPOINTS;
01452 
01453 }
01454 
01455 
01456 /********************************************************************************************
01457 >   MsgResult BlobbyTabDlg::Message( Msg* Message)
01458 
01459     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01460     Created:    18/2/94
01461     Inputs:     Message: The message
01462 
01463 
01464     Returns:    OK            Message handled ok (return this even if you don't need to
01465                               respond to the message).
01466 
01467                 FAIL          Something terrible happened whilst processing the message
01468                               eg. we ran out of memory. You must set ERROR if you
01469                               are returning this value.
01470 
01471                 EAT_MSG       The Message was handled ok but don't send it to any
01472                               more MessageHandlers.
01473 
01474     Purpose:    This is the message handler for the BlobbyTabDlg
01475 
01476 ********************************************************************************************/
01477 
01478 
01479 MsgResult BlobbyTabDlg::Message( Msg* Message)
01480 {
01481     if (IS_OUR_DIALOG_MSG(Message))
01482     {
01483         DialogMsg* Msg = ((DialogMsg*) Message);
01484 
01485         BOOL EndDialog = FALSE;     // TRUE if we should quit the dialog
01486         BOOL CommitValues = FALSE;  // TRUE if we should commit the dialog values
01487 
01488         // Determine from what page the message originated
01489         if (Msg->PageID == _R(IDD_BLOBTAB_PG1))
01490         {
01491             HandleCoordsMsg(Msg);
01492         } else if (Msg->PageID == _R(IDD_BLOBTAB_PG2))
01493         {
01494             HandleRadioDazeMsg(Msg);
01495         } else if (Msg->PageID == _R(IDD_BLOBTAB_PG3))
01496         {
01497             HandleConvertMsg(Msg);
01498         } else if (Msg->PageID == 0)
01499         {
01500             // A message generated from the tabbed dialog itself
01501             switch (Msg->DlgMsg)
01502             {
01503                 case DIM_COMMIT:        // Want to commit and quit
01504                     EndDialog = TRUE;
01505                     CommitValues = TRUE;
01506                     break;
01507 
01508                 case DIM_SOFT_COMMIT:   // Want to commit
01509                     CommitValues = TRUE;
01510                     break;
01511 
01512                 case DIM_CANCEL:        // Want to quit
01513                     EndDialog = TRUE;
01514                     break;
01515 
01516                 default:
01517                     break;
01518             }
01519         } else
01520         {
01521             ERROR3("Message from unknown tab dialog page");
01522         }
01523 
01524         // Commit values here
01525         if (CommitValues)
01526         {
01527             TRACE( _T("BlobbyTabDlg::Message - If I wasn't blobby I would commit at this point"));
01528         }
01529 
01530         // End dialog here
01531         if (EndDialog)  // Dialog communication over
01532         {
01533             Close();
01534             End();      // End of dialog
01535         }
01536         return (DLG_EAT_IF_HUNGRY(Msg));   // I return EAT_MSG unless the message needs to be sent to all dialogs
01537     }
01538     return OK;
01539 }
01540 
01541 
01542 // -----------------------------------------------------------------------------------------
01543 // Message handlers for individual pages
01544 
01545 /********************************************************************************************
01546 
01547 >   void BlobbyTabDlg::HandleCoordsMsg(DialogMsg* Msg)
01548 
01549     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01550     Created:    28/11/94
01551     Inputs:     Msg: The message sent from page 1 of the dialog
01552     Outputs:    -
01553     Returns:    -
01554     Purpose:    All messages generated from the tabbed dialog's page 1 get processed here
01555     Errors:     -
01556     Scope:      private
01557     SeeAlso:    BlobbyTabDlg::Message
01558 
01559 ********************************************************************************************/
01560 
01561 
01562 void BlobbyTabDlg::HandleCoordsMsg(DialogMsg* Msg)
01563 {
01564     TalkToPage(_R(IDD_BLOBTAB_PG1));  // The Coords Page identifier
01565     MILLIPOINT Value = 0;
01566     switch(Msg->DlgMsg)
01567     {
01568         case DIM_CREATE:
01569             // Init coords controls here
01570 
01571             // Set the scrollers range
01572             SetGadgetRange(_R(IDC_TSCROLLBAR1), 10, 100, 10);
01573             SetGadgetRange(_R(IDC_TSCROLLBAR2), 10, 100, 10);
01574 
01575             // Set initial scroll bar positions
01576             SetLongGadgetValue(_R(IDC_TSCROLLBAR1), 60, 10);
01577             SetLongGadgetValue(_R(IDC_TSCROLLBAR2), 60, 10);
01578 
01579             BOOL Valid;
01580             Value = (MILLIPOINT)(GetLongGadgetValue(_R(IDC_TSCROLLBAR1),10,100,0,&Valid)*72000);
01581             SetUnitGadgetValue(_R(IDC_TXVAL), INCHES, Value);
01582             Value = (MILLIPOINT)(GetLongGadgetValue(_R(IDC_TSCROLLBAR2),10,100,0,&Valid)*72000);
01583             SetUnitGadgetValue(_R(IDC_TYVAL), INCHES, Value);
01584             break;
01585         case DIM_SELECTION_CHANGED:
01586             if (Msg->GadgetID == _R(IDC_TSCROLLBAR1))
01587             {
01588                 Value = (MILLIPOINT)(GetLongGadgetValue(_R(IDC_TSCROLLBAR1),10,100,0,&Valid)*72000);
01589                 SetUnitGadgetValue(_R(IDC_TXVAL), INCHES, Value);
01590             } else if (Msg->GadgetID == _R(IDC_TSCROLLBAR2))
01591             {
01592                 Value = (MILLIPOINT)(GetLongGadgetValue(_R(IDC_TSCROLLBAR2),10,100,0,&Valid)*72000);
01593                 SetUnitGadgetValue(_R(IDC_TYVAL), INCHES, Value);
01594             }
01595             break;
01596         default:
01597             break;
01598     }
01599 }
01600 
01601 /********************************************************************************************
01602 
01603 >   void BlobbyTabDlg::HandleRadioDazeMsg(DialogMsg* Msg)
01604 
01605     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01606     Created:    28/11/94
01607     Inputs:     Msg: The message sent from page 2 of the dialog
01608     Outputs:    -
01609     Returns:    -
01610     Purpose:    All messages generated from the tabbed dialog's page 2 get processed here
01611     Errors:     -
01612     Scope:      private
01613     SeeAlso:    BlobbyTabDlg::Message
01614 
01615 ********************************************************************************************/
01616 
01617 
01618 void BlobbyTabDlg::HandleRadioDazeMsg(DialogMsg* Msg)
01619 {
01620     TalkToPage(_R(IDD_BLOBTAB_PG2));  // The Coords Page identifier
01621     switch(Msg->DlgMsg)
01622     {
01623         case DIM_CREATE:
01624             // Init RadioDaze controls here
01625             SetLongGadgetValue(_R(IDC_TRADIO11), TRUE);
01626             SetLongGadgetValue(_R(IDC_TRADIO12), FALSE);
01627             SetLongGadgetValue(_R(IDC_TRADIO13), FALSE);
01628 
01629             SetLongGadgetValue(_R(IDC_TRADIO21), FALSE);
01630             SetLongGadgetValue(_R(IDC_TRADIO22), FALSE);
01631             SetLongGadgetValue(_R(IDC_TRADIO23), TRUE);
01632 
01633             break;
01634         case DIM_LFT_BN_CLICKED:
01635             if (Msg->GadgetID==_R(IDC_TRADIO11))
01636             {
01637                 SetLongGadgetValue(_R(IDC_TRADIO23), TRUE);
01638                 SetLongGadgetValue(_R(IDC_TRADIO21), FALSE);
01639                 SetLongGadgetValue(_R(IDC_TRADIO22), FALSE);
01640             }
01641             else if (Msg->GadgetID==_R(IDC_TRADIO12))
01642             {
01643                 SetLongGadgetValue(_R(IDC_TRADIO22), TRUE);
01644                 SetLongGadgetValue(_R(IDC_TRADIO21), FALSE);
01645                 SetLongGadgetValue(_R(IDC_TRADIO23), FALSE);
01646             }
01647             else if (Msg->GadgetID==_R(IDC_TRADIO13))
01648             {
01649                 SetLongGadgetValue(_R(IDC_TRADIO21), TRUE);
01650                 SetLongGadgetValue(_R(IDC_TRADIO22), FALSE);
01651                 SetLongGadgetValue(_R(IDC_TRADIO23), FALSE);
01652             }
01653             else if (Msg->GadgetID==_R(IDC_TRADIO21))
01654             {
01655                 SetLongGadgetValue(_R(IDC_TRADIO13), TRUE);
01656                 SetLongGadgetValue(_R(IDC_TRADIO11), FALSE);
01657                 SetLongGadgetValue(_R(IDC_TRADIO12), FALSE);
01658             }
01659             else if (Msg->GadgetID==_R(IDC_TRADIO22))
01660             {
01661                 SetLongGadgetValue(_R(IDC_TRADIO12), TRUE);
01662                 SetLongGadgetValue(_R(IDC_TRADIO11), FALSE);
01663                 SetLongGadgetValue(_R(IDC_TRADIO13), FALSE);
01664             }
01665             else if (Msg->GadgetID==_R(IDC_TRADIO23))
01666             {
01667                 SetLongGadgetValue(_R(IDC_TRADIO11), TRUE);
01668                 SetLongGadgetValue(_R(IDC_TRADIO12), FALSE);
01669                 SetLongGadgetValue(_R(IDC_TRADIO13), FALSE);
01670             }
01671             break;
01672         default:
01673             break;
01674     }
01675 }
01676 
01677 /********************************************************************************************
01678 
01679 >   void BlobbyTabDlg::HandleConvertMsg(DialogMsg* Msg)
01680 
01681     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01682     Created:    28/11/94
01683     Inputs:     Msg: The message sent from page 3 of the dialog
01684     Outputs:    -
01685     Returns:    -
01686     Purpose:    All messages generated from the tabbed dialog's page 3 get processed here
01687     Errors:     -
01688     Scope:      private
01689     SeeAlso:    BlobbyTabDlg::Message
01690 
01691 ********************************************************************************************/
01692 
01693 
01694 void BlobbyTabDlg::HandleConvertMsg(DialogMsg* Msg)
01695 {
01696     TalkToPage(_R(IDD_BLOBTAB_PG3));  // The Coords Page identifier
01697     switch(Msg->DlgMsg)
01698     {
01699         case DIM_CREATE:
01700         {
01701             DefaultUnit = INCHES;       // Default unit
01702             ConvUnit = MILLIMETRES;  // Conversion unit
01703 
01704             // Setup combos
01705             for (INT32 i=0; i<9; i++)
01706             {
01707                 SetStringGadgetValue(_R(IDC_TCOMBO3), UnitStrList[i],FALSE,i);
01708                 SetStringGadgetValue(_R(IDC_TCOMBO4), UnitStrList[i],FALSE,i);
01709             }
01710         }
01711         break;
01712         // Init coords controls here
01713         case DIM_SELECTION_CHANGED:
01714         {
01715             if (Msg->GadgetID == _R(IDC_TCOMBO3))
01716             {
01717 //              BOOL Valid=0;
01718                 WORD Index;
01719                 GetValueIndex(_R(IDC_TCOMBO3),&Index);
01720                 if (Index <= 8)
01721                     DefaultUnit = UnitList[Index];
01722 
01723             }
01724             else if (Msg->GadgetID == _R(IDC_TCOMBO4))
01725             {
01726 //              BOOL Valid=0;
01727                 WORD Index;
01728                 GetValueIndex(_R(IDC_TCOMBO4),&Index);
01729                 if (Index <= 8)
01730                     ConvUnit = UnitList[Index];
01731             }
01732         }
01733         break;
01734         case DIM_LFT_BN_CLICKED:
01735         {
01736             if (Msg->GadgetID == _R(IDC_TBUTTON3))
01737             {
01738                 BOOL Valid=0;
01739                 MILLIPOINT Value = GetUnitGadgetValue(_R(IDC_TUNITVAL),DefaultUnit,-10000000,10000000,0,&Valid);
01740                 SetUnitGadgetValue(_R(IDC_TCONVVAL), ConvUnit, Value);
01741             }
01742         }
01743         break;
01744         default: break;
01745     }
01746 }
01747 
01748 
01749 /********************************************************************************************
01750 
01751 >   OpState BlobbyTabDlg::GetState(String_256*, OpDescriptor*)
01752 
01753 
01754     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01755     Created:    17/11/94
01756     Inputs:     -
01757     Outputs:    -
01758     Returns:    -
01759     Purpose:    The standard GetState fn, does nothing
01760     Errors:     -
01761     SeeAlso:    -
01762 
01763 ********************************************************************************************/
01764 
01765 
01766 OpState BlobbyTabDlg::GetState(String_256*, OpDescriptor*)
01767 {
01768     OpState OpSt;
01769     return(OpSt);
01770 }
01771 
01772 /********************************************************************************************
01773 
01774 >   BOOL BlobbyTabDlg::Init()
01775 
01776 
01777     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01778     Created:    17/11/94
01779     Inputs:     -
01780     Outputs:    -
01781     Returns:    -
01782     Purpose:    The standard Init fn for the op.
01783     Errors:     -
01784     SeeAlso:    -
01785 
01786 ********************************************************************************************/
01787 
01788 
01789 BOOL BlobbyTabDlg::Init()
01790 {
01791 
01792 return (RegisterOpDescriptor(
01793                                 0,
01794                                 _R(IDS_BLOBBYTABDLG),
01795                                 CC_RUNTIME_CLASS(BlobbyTabDlg),
01796                                 OPTOKEN_BLOBBYTABDLG,
01797                                 BlobbyTabDlg::GetState,
01798                                 0,  /* help ID */
01799                                 _R(IDBBL_BLOBBYDLG),
01800                                 0,
01801                                 0,
01802                                 SYSTEMBAR_ILLEGAL,
01803                                 TRUE,
01804                                 FALSE,
01805                                 TRUE,
01806                                 0,
01807                                 0, // One open instance
01808                                 GREY_WHEN_NO_CURRENT_DOC
01809                                 ));
01810 
01811 }
01812 
01813 /********************************************************************************************
01814 
01815 >   void BlobbyTabDlg::Do(OpDescriptor*)
01816 
01817     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01818     Created:    17/11/94
01819     Inputs:     -
01820     Outputs:    -
01821     Returns:    -
01822     Purpose:    Like all Do functions invokes the BlobbyTabDlg
01823     Errors:     -
01824     SeeAlso:    -
01825 
01826 ********************************************************************************************/
01827 
01828 
01829 
01830 void BlobbyTabDlg::Do(OpDescriptor*)
01831 {
01832     // Note: For a real tabbed dialog you would not even think about including an explicit
01833     // string in the dialog would you ?
01834     String_256 Name(_T("Blobby tab dialog"));
01835     SetName(&Name);
01836     BOOL ok = Create(); // Create the TAB dialog please
01837     if (!ok)
01838     {
01839         /*InformError(blobby)*/;    // Display an error if this is a real dialog please
01840         End();
01841     }
01842 }
01843 /********************************************************************************************
01844 
01845 >   virtual BOOL BlobbyTabDlg::RegisterYourPagesInOrderPlease()
01846 
01847 
01848     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01849     Created:    21/11/94
01850     Inputs:     -
01851     Outputs:    -
01852     Returns:    return TRUE if all calls to AddAPage returned TRUE
01853     Purpose:    This virtual function will get called to give you a chance to add pages to your
01854                 DialogTabOp. This function will usually make multiple calls to AddAPage to
01855                 register the initial set of pages to be contained in the tab dialog. The pages
01856                 should all be the same size and be registered in the left to right order in which
01857                 you wish them to appear.
01858 
01859                 This function get's called directly from the Create method, Don't call it
01860                 explicitly yourself. If you return FALSE from this method then the Create
01861                 method will fail.
01862 
01863     Errors:     -
01864     SeeAlso:    DialogTabOp::AddPage
01865     SeeAlso:    DialogOp::Create
01866 
01867 ********************************************************************************************/
01868 
01869 
01870 BOOL BlobbyTabDlg::RegisterYourPagesInOrderPlease()
01871 {
01872     BOOL ok = AddAPage(_R(IDD_BLOBTAB_PG1)) &&
01873               AddAPage(_R(IDD_BLOBTAB_PG2)) &&
01874               AddAPage(_R(IDD_BLOBTAB_PG3));
01875     return (ok);
01876 }
01877 
01878 
01879 
01880 //------------------------------------------------------------------------------------------
01881 // Demo Dialog
01882 
01883 const CDlgMode BlobbyBar::Mode = MODELESS;// Mode of the dialog
01884 
01885 const UINT32 BlobbyBar::IDD = _R(IDD_SELECTORINFO);
01886 
01887 BlobbyBar::BlobbyBar(): DialogOp(BlobbyBar::IDD, BlobbyBar::Mode)
01888 {
01889 
01890 
01891 }
01892 MsgResult BlobbyBar::Message( Msg* Message)
01893 {
01894 
01895     if (IS_OUR_DIALOG_MSG(Message))
01896     {
01897         DialogMsg* Msg = (DialogMsg*)Message;
01898         // Handle ok button
01899         if ((Msg->DlgMsg == DIM_COMMIT) || (Msg->DlgMsg == DIM_CANCEL))
01900         {
01901             Close(); // Hide the dialog
01902             End();
01903         }
01904 
01905         if ((Msg->DlgMsg == DIM_LFT_BN_CLICKED) || (Msg->DlgMsg == DIM_SELECTION_CHANGED))
01906         {
01907             if ( (Msg->GadgetID == _R(IDC_SEL_GRID_NW) ) ||
01908                  (Msg->GadgetID == _R(IDC_SEL_GRID_N)  ) ||
01909                  (Msg->GadgetID == _R(IDC_SEL_GRID_NE) ) ||
01910                  (Msg->GadgetID == _R(IDC_SEL_GRID_W)  ) ||
01911                  (Msg->GadgetID == _R(IDC_SEL_GRID_CENTRE) ) ||
01912                  (Msg->GadgetID == _R(IDC_SEL_GRID_E)  ) ||
01913                  (Msg->GadgetID == _R(IDC_SEL_GRID_SW) ) ||
01914                  (Msg->GadgetID == _R(IDC_SEL_GRID_S)  ) ||
01915                  (Msg->GadgetID == _R(IDC_SEL_GRID_SE) )
01916                 )
01917             {
01918 #define SetGrid(x) do {SetLongGadgetValue(x, (x==Msg->GadgetID)?1:0);} while(0)
01919                 SetGrid(_R(IDC_SEL_GRID_NW));
01920                 SetGrid(_R(IDC_SEL_GRID_N) );
01921                 SetGrid(_R(IDC_SEL_GRID_NE));
01922                 SetGrid(_R(IDC_SEL_GRID_W) );
01923                 SetGrid(_R(IDC_SEL_GRID_CENTRE));
01924                 SetGrid(_R(IDC_SEL_GRID_E) );
01925                 SetGrid(_R(IDC_SEL_GRID_SW));
01926                 SetGrid(_R(IDC_SEL_GRID_S) );
01927                 SetGrid(_R(IDC_SEL_GRID_SE));
01928             }
01929 #define SetBump(x,y) do {SetLongGadgetValue(x, GetLongGadgetValue(x,0,100)+y);} while(0)
01930             if (Msg->GadgetID == _R(IDC_SEL_BUMP_X_MORE))
01931                 SetBump(_R(IDC_SEL_EDIT_X),1);
01932             if (Msg->GadgetID == _R(IDC_SEL_BUMP_X_LESS))
01933                 SetBump(_R(IDC_SEL_EDIT_X),-1);
01934             if (Msg->GadgetID == _R(IDC_SEL_BUMP_Y_MORE))
01935                 SetBump(_R(IDC_SEL_EDIT_Y),1);
01936             if (Msg->GadgetID == _R(IDC_SEL_BUMP_Y_LESS))
01937                 SetBump(_R(IDC_SEL_EDIT_Y),-1);
01938             if (Msg->GadgetID == _R(IDC_SEL_BUMP_H_MORE))
01939                 SetBump(_R(IDC_SEL_EDIT_H),1);
01940             if (Msg->GadgetID == _R(IDC_SEL_BUMP_H_LESS))
01941                 SetBump(_R(IDC_SEL_EDIT_H),-1);
01942             if (Msg->GadgetID == _R(IDC_SEL_BUMP_W_MORE))
01943                 SetBump(_R(IDC_SEL_EDIT_W),1);
01944             if (Msg->GadgetID == _R(IDC_SEL_BUMP_W_LESS))
01945                 SetBump(_R(IDC_SEL_EDIT_W),-1);
01946             if (Msg->GadgetID == _R(IDC_SEL_BUMP_ANGLE_MORE))
01947                 SetBump(_R(IDC_SEL_EDIT_ANGLE),1);
01948             if (Msg->GadgetID == _R(IDC_SEL_BUMP_ANGLE_LESS))
01949                 SetBump(_R(IDC_SEL_EDIT_ANGLE),-1);
01950             if (Msg->GadgetID == _R(IDC_SEL_BUMP_SHEAR_MORE))
01951                 SetBump(_R(IDC_SEL_EDIT_SHEAR),1);  
01952             if (Msg->GadgetID == _R(IDC_SEL_BUMP_SHEAR_LESS))
01953                 SetBump(_R(IDC_SEL_EDIT_SHEAR),-1);
01954 
01955             if (Msg->GadgetID == _R(IDC_SEL_SHOWFILLBLOBS))
01956             {
01957                 BOOL Enable=!GetLongGadgetValue(_R(IDC_SEL_SHOWFILLBLOBS),0,1);
01958 
01959 //              EnableGadget(_R(IDC_SEL_BRACKETSYMBOL), Enable);
01960                 EnableGadget(_R(IDC_SEL_BUMP_ANGLE_LESS), Enable);
01961                 EnableGadget(_R(IDC_SEL_BUMP_ANGLE_MORE), Enable);
01962                 EnableGadget(_R(IDC_SEL_BUMP_H_LESS), Enable);
01963                 EnableGadget(_R(IDC_SEL_BUMP_H_MORE), Enable);
01964                 EnableGadget(_R(IDC_SEL_BUMP_SHEAR_LESS), Enable);
01965                 EnableGadget(_R(IDC_SEL_BUMP_SHEAR_MORE), Enable);
01966                 EnableGadget(_R(IDC_SEL_BUMP_W_LESS), Enable);
01967                 EnableGadget(_R(IDC_SEL_BUMP_W_MORE), Enable);
01968                 EnableGadget(_R(IDC_SEL_BUMP_X_LESS), Enable);
01969                 EnableGadget(_R(IDC_SEL_BUMP_X_MORE), Enable);
01970                 EnableGadget(_R(IDC_SEL_BUMP_Y_LESS), Enable);
01971                 EnableGadget(_R(IDC_SEL_BUMP_Y_MORE), Enable);
01972                 EnableGadget(_R(IDC_SEL_EDIT_ANGLE), Enable);
01973                 EnableGadget(_R(IDC_SEL_EDIT_H), Enable);
01974                 EnableGadget(_R(IDC_SEL_EDIT_SHEAR), Enable);
01975                 EnableGadget(_R(IDC_SEL_EDIT_W), Enable);
01976                 EnableGadget(_R(IDC_SEL_EDIT_X), Enable);
01977                 EnableGadget(_R(IDC_SEL_EDIT_XSCALE), Enable);
01978                 EnableGadget(_R(IDC_SEL_EDIT_Y), Enable);
01979                 EnableGadget(_R(IDC_SEL_EDIT_YSCALE), Enable);
01980                 EnableGadget(_R(IDC_SEL_FLIPHORZ), Enable);
01981                 EnableGadget(_R(IDC_SEL_FLIPVERT), Enable);
01982                 EnableGadget(_R(IDC_SEL_GRID_CENTRE), Enable);
01983                 EnableGadget(_R(IDC_SEL_GRID_E), Enable);
01984                 EnableGadget(_R(IDC_SEL_GRID_N), Enable);
01985                 EnableGadget(_R(IDC_SEL_GRID_NE), Enable);
01986                 EnableGadget(_R(IDC_SEL_GRID_NW), Enable);
01987                 EnableGadget(_R(IDC_SEL_GRID_S), Enable);
01988                 EnableGadget(_R(IDC_SEL_GRID_SE), Enable);
01989                 EnableGadget(_R(IDC_SEL_GRID_SW), Enable);
01990                 EnableGadget(_R(IDC_SEL_GRID_W), Enable);
01991                 EnableGadget(_R(IDC_SEL_PADLOCK), Enable);
01992                 EnableGadget(_R(IDC_SEL_ROTATEBUTTON), Enable);
01993 //              EnableGadget(_R(IDC_SEL_ROTATESYMBOL), Enable);
01994                 EnableGadget(_R(IDC_SEL_SCALELINES), Enable);
01995 //              EnableGadget(_R(IDC_SEL_SHEARSYMBOL), Enable);
01996                 EnableGadget(_R(IDC_SEL_SHOWBOUNDSBLOBS), Enable);
01997 //              EnableGadget(_R(IDC_SEL_SHOWFILLBLOBS), Enable);
01998                 EnableGadget(_R(IDC_SEL_SHOWOBJECTBLOBS), Enable);
01999 //              EnableGadget(_R(IDC_SEL_STATIC_WH), Enable);
02000 //              EnableGadget(_R(IDC_SEL_STATIC_XY), Enable);
02001                 EnableGadget(_R(IDPB_NAMEDLG_RUN_BUTTON), Enable);
02002             }
02003         }
02004 
02005         // Do some other fun stuff here
02006 
02007         return (DLG_EAT_IF_HUNGRY(Msg));
02008     }
02009     return OK;
02010 }
02011 
02012 // -----------------------------------------------------------------------------------------
02013 
02014 OpState BlobbyBar::GetState(String_256*, OpDescriptor*)
02015 {
02016     OpState OpSt;
02017     return(OpSt);
02018 }
02019 
02020 // -----------------------------------------------------------------------------------------
02021 
02022 BOOL BlobbyBar::Init()
02023 {
02024     return (RegisterOpDescriptor(
02025                                 0,
02026                                 _R(IDS_BLOBBYBAR),
02027                                 CC_RUNTIME_CLASS(BlobbyBar),
02028                                 OPTOKEN_BLOBBYBAR,
02029                                 BlobbyBar::GetState,
02030                                 0,                                  // Help ID
02031                                 _R(IDBBL_BLOBBYBAR),                // Bubble help
02032                                 0,                                  // Resource ID
02033                                 0,                                  // Control ID
02034                                 SYSTEMBAR_EDIT,                     // Bar ID
02035                                 TRUE,                               // Recieve system messages
02036                                 FALSE,                              // Smart duplicate operation
02037                                 TRUE,                               // Clean operation
02038                                 0,                                  // No vertical counterpart
02039                                 _R(IDS_BLOBBYBAR_ONE),              // String for one copy only
02040                                 0                                   // Auto state flags
02041                                 ));
02042 
02043 }
02044 
02045 // -----------------------------------------------------------------------------------------
02046 
02047 BOOL BlobbyBar::Create()
02048 {
02049     if (DialogOp::Create())
02050     {
02051         // Set up  your gadgets here
02052         SetLongGadgetValue(_R(IDC_SEL_SHOWBOUNDSBLOBS),0);
02053         SetLongGadgetValue(_R(IDC_SEL_SHOWOBJECTBLOBS),0);
02054         SetLongGadgetValue(_R(IDC_SEL_SHOWFILLBLOBS),0);
02055         
02056         SetLongGadgetValue(_R(IDC_SEL_ROTATEBUTTON),0);
02057 
02058         SetLongGadgetValue(_R(IDC_SEL_GRID_NW),0);
02059         SetLongGadgetValue(_R(IDC_SEL_GRID_N),0);
02060         SetLongGadgetValue(_R(IDC_SEL_GRID_NE),0);
02061         SetLongGadgetValue(_R(IDC_SEL_GRID_W),0);
02062         SetLongGadgetValue(_R(IDC_SEL_GRID_CENTRE),0);
02063         SetLongGadgetValue(_R(IDC_SEL_GRID_E),0);
02064         SetLongGadgetValue(_R(IDC_SEL_GRID_SW),0);
02065         SetLongGadgetValue(_R(IDC_SEL_GRID_S),0);
02066         SetLongGadgetValue(_R(IDC_SEL_GRID_SE),0);
02067         
02068         SetLongGadgetValue(_R(IDC_SEL_EDIT_X),0);
02069         SetLongGadgetValue(_R(IDC_SEL_EDIT_Y),0);
02070 
02071         SetLongGadgetValue(_R(IDC_SEL_EDIT_W),0);
02072         SetLongGadgetValue(_R(IDC_SEL_EDIT_H),0);
02073 
02074         SetLongGadgetValue(_R(IDC_SEL_EDIT_XSCALE),0);
02075         SetLongGadgetValue(_R(IDC_SEL_EDIT_YSCALE),0);
02076         SetLongGadgetValue(_R(IDC_SEL_PADLOCK),0);
02077 
02078         SetLongGadgetValue(_R(IDC_SEL_EDIT_ANGLE),0);
02079         SetLongGadgetValue(_R(IDC_SEL_EDIT_SHEAR),0);
02080 
02081         SetLongGadgetValue(_R(IDC_SEL_SCALELINES),0);
02082 
02083         return TRUE;
02084     }
02085     else return FALSE;
02086 }
02087 
02088 // -----------------------------------------------------------------------------------------
02089 
02090 void BlobbyBar::Do(OpDescriptor*)
02091 {
02092     Create();
02093     Open();
02094 }
02095 
02096 

Generated on Sat Nov 10 03:44:25 2007 for Camelot by  doxygen 1.4.4