liveeffectsinfo.cpp

Go to the documentation of this file.
00001 // $Id: liveeffectsinfo.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 // FreeHand Tool Info bar operations
00099 
00100 #include "camtypes.h"
00101 #include "camelot.h"
00102 #include "liveeffectstool.h"
00103 #include "liveeffectsinfo.h"
00104 //#include "range.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 //#include "resource.h"
00106 //#include "barsdlgs.h"
00107 //#include "justin2.h"
00108 //#include "will.h" // for the 'many' string
00109 //#include "attrmgr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 //#include "docvmsg.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00111 #include "colmsg.h"
00112 #include "brushmsg.h"
00113 //#include "liveeffectres.h"
00114 #include "xpehost.h"
00115 #include "opliveeffects.h"
00116 #include "nodeliveeffect.h"
00117 #include "liveeffectsmenu.h"
00118 #include "shadtool.h"
00119 #include "opfeathr.h"
00120 #include "appprefs.h"
00121 
00122 DECLARE_SOURCE( "$Revision: 1282 $" );
00123 
00124 // Declare stuff for the memory tracking
00125 CC_IMPLEMENT_DYNCREATE( LiveEffectsInfoBarOp, InformationBarOp )
00126 #define new CAM_DEBUG_NEW
00127 
00128 
00129 
00130 
00131 /********************************************************************************************
00132 
00133 >   LiveEffectsInfoBarOp::LiveEffectsInfoBarOp()
00134 
00135     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00136     Created:    30/8/94
00137     Purpose:    Sets the info bars vars to NULL defaults
00138 
00139 ********************************************************************************************/
00140 
00141 LiveEffectsInfoBarOp::LiveEffectsInfoBarOp()
00142 {
00143     // Don't know about the tool and can not retro fit to start with
00144     m_pTool = NULL;
00145 
00146     // The Controls hasve not been created yet
00147     m_bControlsExist = FALSE;
00148     m_bLockSwitchState = FALSE;
00149     m_bLockAllSwitchState = FALSE;
00150 }
00151 
00152 
00153 
00154 
00155 /********************************************************************************************
00156 
00157 >   LiveEffectsInfoBarOp::~LiveEffectsInfoBarOp()
00158 
00159     Author:     Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
00160     Created:    18/5/2000
00161     Purpose:    destructor
00162 
00163 ********************************************************************************************/
00164 
00165 LiveEffectsInfoBarOp::~LiveEffectsInfoBarOp()
00166 {
00167 }
00168 
00169 
00170 /********************************************************************************************
00171 
00172 >   MsgResult LiveEffectsInfoBarOp::Message(Msg* Message) 
00173 
00174     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00175     Created:    12/5/94
00176     Inputs:     Message - A dialog message 
00177     Returns:    The result of the message
00178     Purpose:    Takes a look at the message and if it is for me it responds to it.
00179 
00180 ********************************************************************************************/
00181 
00182 MsgResult LiveEffectsInfoBarOp::Message(Msg* Message) 
00183 {
00184     if (IS_OUR_DIALOG_MSG(Message))
00185     {
00186         DialogMsg* DMsg = (DialogMsg*)Message;
00187 
00188         // Check if the message is a CANCEL
00189         if (DMsg->DlgMsg == DIM_CANCEL)
00190         {
00191             // Mark the controls as no longer existing
00192             m_bControlsExist = FALSE;
00193             
00194             // Close the dialog 
00195             Close();
00196         }
00197 
00198         else if (DMsg->DlgMsg == DIM_CREATE)
00199         {
00200             HandleCreate();
00201         }
00202 
00203         else
00204         {
00205             // Messages to all the controls, handled indivdually
00206             switch (DMsg->GadgetID)
00207             {
00208                 case _R(IDC_LE_LABEL):
00209                 {
00210                     GadgetMessage_Label(DMsg);
00211                     break;
00212                 }
00213                 case _R(IDC_COMBOBOX_LE_ORDER):
00214                 {
00215                     GadgetMessage_Order(DMsg);
00216                     break;
00217                 }
00218                 case _R(IDC_CCBUTTON_LE_EDIT):
00219                 case _R(IDC_BUTTON_LE_EDIT):
00220                 {
00221                     GadgetMessage_Edit(DMsg);
00222                     break;
00223                 }
00224                 case _R(IDC_CCBUTTON_LE_ADD):
00225                 case _R(IDC_BUTTON_LE_ADD):
00226                 {
00227                     GadgetMessage_Add(DMsg);
00228                     break;
00229                 }
00230                 case _R(IDC_CCBUTTON_LE_INSERT):
00231                 {
00232                     GadgetMessage_Insert(DMsg);
00233                     break;
00234                 }
00235                 case _R(IDC_COMBOBOX_LE_RES):
00236                 {
00237                     GadgetMessage_Resolution(DMsg);
00238                     break;
00239                 }
00240                 case _R(IDC_CCBUTTON_LE_TOGGLELOCK):
00241                 {
00242                     GadgetMessage_ToggleLock(DMsg);
00243                     break;
00244                 }
00245                 case _R(IDC_CCBUTTON_LE_REMOVE):
00246                 {
00247                     GadgetMessage_Remove(DMsg);
00248                     break;
00249                 }
00250                 case _R(IDC_CCBUTTON_LE_REMOVEALL):
00251                 {
00252                     GadgetMessage_RemoveAll(DMsg);
00253                     break;
00254                 }
00255                 case _R(IDC_CCBUTTON_LE_TOGGLELOCKALL):
00256                 {
00257                     GadgetMessage_ToggleLockAll(DMsg);
00258                     break;
00259                 }
00260                 case _R(IDC_BUTTON_LE_SETUP):
00261                 {
00262                     GadgetMessage_Setup(DMsg);
00263                     break;
00264                 }
00265             }
00266         }
00267     }
00268     else
00269     {
00270         // Handle non dialog messages in here
00271 
00272         // likewise if it is a screen change message
00273 // Commented out, Phil, 25/10/2004
00274 // This upsets OpLiveEffect::UpdateCurrentEditor because it causes one of these messages to be sent while it's working
00275 // and so the current PPStack that it's working on is deleted from under it by ScreenChanged
00276 //      if (Message->IsKindOf(CC_RUNTIME_CLASS(ScreenChangeMsg)) || Message->IsKindOf(CC_RUNTIME_CLASS(CurrentAttrChangedMsg)))
00277 //      {
00278 //          if (m_pTool != NULL && HasWindow() 
00279 //              && (Document::GetCurrent() != NULL))
00280 //          {
00281 //              m_pTool->ScreenChanged(TRUE); //((ScreenChangeMsg*)Message)->m_bClear);
00282 //              UpdateState();
00283 //          }
00284 //      }
00285 
00286 
00287         if (Message->IsKindOf(CC_RUNTIME_CLASS(DocViewMsg)))
00288         {
00289             DocViewMsg* pDVM = (DocViewMsg*)Message;
00290             if (pDVM->State == pDVM->DocViewState::SELCHANGED)
00291                 m_pTool->ScreenChanged(TRUE);
00292         }
00293     }
00294 
00295     // do we have a selection change message? 
00296     if (MESSAGE_IS_A(Message, SelChangingMsg))
00297     {
00298         Document* pDoc  = Document::GetCurrent();
00299         if (pDoc != NULL)
00300         {
00301             if (m_bControlsExist && IsVisible())
00302             {
00303             }
00304         }
00305         // ask the tool to refresh its cache, as blobs will have changed
00306         // TODO: Could test for and exclude COLOURATTCHANGED and NONCOLOURATTCHANGED here?
00307         if (m_pTool != NULL && HasWindow()) 
00308             m_pTool->ScreenChanged(TRUE); 
00309     }
00310 
00311     if (MESSAGE_IS_A(Message, ColourChangingMsg))
00312     {
00313         ColourChangingMsg *TheMsg = (ColourChangingMsg *) Message;
00314 
00315         // handle the selected View's Colour Context is changing
00316         // e.g. if the show printer colours (plate) has changed
00317         if(TheMsg->State == ColourChangingMsg::ColourState::SELVIEWCONTEXTCHANGE)
00318         {
00319             // ask the tool to refresh its cache
00320             // (so that the cache does not have the old colour in it
00321             //  and the drawing will be agains the correct (current)
00322             //  background!)
00323             if (m_pTool != NULL && HasWindow()) 
00324                 m_pTool->ScreenChanged(TRUE);
00325         }
00326     }
00327 
00328     if (MESSAGE_IS_A(Message, DocChangingMsg))
00329     {
00330         DocChangingMsg* pMsg = (DocChangingMsg*) Message;
00331         if (pMsg->State == DocChangingMsg::DocState::ABOUTTODIE && XPEHost::GetEditSessionDocument()==pMsg->pChangingDoc)
00332         {
00333             XPEHost::EndEditLiveEffect();
00334         }
00335     }
00336 
00337     else if (MESSAGE_IS_A(Message,OpMsg))   // Check for undo/redo
00338     {
00339         // update the gadgets
00340 //      UpdateState();
00341         BlobManager* BlobMgr = GetApplication()->GetBlobManager();
00342         ENSURE(BlobMgr, "Can't get BlobManager");
00343         
00344         if ( (((OpMsg*)Message)->MsgType == OpMsg::BEFORE_UNDO) ||
00345                                         (((OpMsg*)Message)->MsgType == OpMsg::BEFORE_REDO))
00346         {
00347             OpLiveEffect* pCurrentOp = XPEHost::GetCurrentLEOp();
00348 
00349             // If we haven't got a list of editors yet then get one
00350             if (pCurrentOp!=NULL)
00351             {
00352 /*              // Attempt to suspend the modeless XPE edit while we undo
00353                 m_strUndoEffectID = pCurrentOp->GetEffectID();
00354                 m_iUndoStackPos = pCurrentOp->GetStackPos();
00355                 // Stop the current Op and commit all of its changes
00356                 // Disconnect it from the XPE system so that, just for the moment at least, other routines
00357                 // think that there's no running edit session
00358                 pCurrentOp->DoEndEdit(TRUE, TRUE);              // Sends ScreenChangeMsg - and thus releases pPPStack
00359                 XPEHost::SetCurrentLEOp(NULL);                  // Tells UpdateCurrentEditor not to try to update dying editor
00360 */
00361                 // This is the only safe thing to do at the moment...
00362 //              XPEHost::EndEditLiveEffect();
00363                 pCurrentOp->DoEndEdit(TRUE, TRUE, TRUE, TRUE);
00364                 XPEHost::SetCurrentLEOp(NULL);
00365                 XPEHost::EndEditLiveEffect();
00366             }
00367         }
00368         else if ( (((OpMsg*)Message)->MsgType == OpMsg::AFTER_UNDO) ||
00369                                         (((OpMsg*)Message)->MsgType == OpMsg::AFTER_REDO))
00370         {
00371 /*          // Attempt tp restore the modeless XPE edit after undo
00372             // Reset pPPStack in LiveEffectTool to reset the Tool after the ScreenChangeMsg sent above
00373             // (prevent idle handler looping forever calling this function)
00374             EffectsStack* pPPStack = EffectsStack::GetEffectsStackFromSelection();
00375 
00376             // Try to find the same effect in the new stack
00377             // If found then invoke a new Op to use the running editor on that effect
00378             BOOL bOK = pPPStack->FindBestProcessor(&m_strUndoEffectID, &m_iUndoStackPos);
00379 
00380             // Decide which sort of Operation we need to use instead...
00381             OpDescriptor* pOp = NULL;
00382             if (bOK)
00383             {
00384                 // We found the right sort of Effect in the stack so we'll just edit that
00385                 pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_EDIT_LIVEEFFECT);
00386             }
00387             else
00388             {
00389                 // We didn't find the right sort of effect so we'll apply a brand new one!
00390                 // At the top of the stack
00391                 pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_APPLY_LIVEEFFECT);
00392                 m_iUndoStackPos = STACKPOS_INSERT_TOP;
00393             }
00394 
00395             // Start a new Op but tell it to use the existing edit session instead of making a new one
00396             if (pOp)
00397             {
00398                 OpLiveEffectParam Param;
00399                 Param.strOpUnique = m_strUndoEffectID;
00400                 Param.StackPosition = m_iUndoStackPos;
00401                 Param.pPPStack = pPPStack;
00402                 Param.bReUseEditor = TRUE;              // This is the important param!
00403                 BOOL bValid = XPEHost::GetEffectDetails(m_strUndoEffectID, &Param.strMenuText, &Param.bIsDestructive);
00404 
00405                 String_256 strDummy;
00406                 if (bValid && pOp->GetOpsState(&strDummy).Greyed==FALSE)
00407                 {
00408                     pOp->Invoke(&Param);
00409 
00410                     // Reset the Tool's current stack pointer now so that it doesn't need
00411                     // to be updated under idle events with the consequent call to this function
00412                     // and infinite loop...
00413                     Tool* pTool = Tool::GetCurrent();
00414                     if (pTool->GetID()==TOOLID_LIVEEFFECT)
00415                         ((LiveEffectsTool*)pTool)->UpdatePPStack(FALSE);
00416 
00417                     // If that successfully set up a new editor op then we're fine to carry on
00418                     if (XPEHost::GetCurrentLEOp()!=NULL)
00419                     {
00420                         delete pPPStack;
00421                         return (InformationBarOp::Message(Message));
00422                     }
00423                 }
00424             }
00425 
00426             // If we get here then we must have failed in some way so close down the running editor
00427             XPEHost::EndEditLiveEffect();
00428             delete pPPStack;
00429 */
00430         }
00431     }
00432 
00433     // Pass message on
00434     return (InformationBarOp::Message(Message));
00435 }    
00436 
00437 
00438 
00439 
00440 /********************************************************************************************
00441 
00442 >   void LiveEffectsInfoBarOp::GadgetMessage_Order(DialogMsg* Message) 
00443 
00444     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00445     Created:    06/10/2004
00446     Inputs:     Message - A dialog message 
00447     Returns:    The result of the message
00448     Purpose:    Takes a look at the message and if it is for me it responds to it.
00449     Note:       Strings in this gadget are NOT distinct - you cannot use string matching
00450                 on effect names to identify which is selected!
00451 
00452 ********************************************************************************************/
00453 
00454 void LiveEffectsInfoBarOp::GadgetMessage_Order(DialogMsg* Message) 
00455 {
00456     switch (Message->DlgMsg)
00457     {
00458         case DIM_SELECTION_CHANGED:
00459         {
00460             WORD Index;
00461             GetValueIndex(Message->GadgetID, &Index);
00462             EffectsStack* pStack = m_pTool->GetEffectsStack();
00463             PPStackLevel* pStackLevel = (PPStackLevel*)pStack->FindItem(Index);
00464 
00465             if (pStackLevel)
00466             {
00467                 String_256 strEffectID = pStackLevel->strPostProID;
00468                 m_pTool->SetCurrentEffectID(strEffectID);
00469                 m_pTool->SetCurrentStackPos(Index);
00470             }
00471             else
00472             {
00473                 m_pTool->SetCurrentEffectID(String(""));
00474                 m_pTool->SetCurrentStackPos(Index);
00475             }
00476 
00477             UpdateState();
00478 
00479 #ifdef FEATHER_EFFECT
00480             String_256 strCurrentEffectID = m_pTool->GetCurrentEffectID();
00481             if (strCurrentEffectID==String_256(POSTPRO_ID_FEATHER))
00482             {
00483                 INT32 iStackPos = m_pTool->GetCurrentStackPos();
00484                 ListRange* pFeatherRange = m_pTool->GetEffectsStack()->GetLevelRange(&iStackPos);
00485                 OpChangeFeatherSize::SetEditContext(iStackPos, pFeatherRange);
00486                 return;
00487             }
00488 #endif
00489 
00490         }
00491     }
00492 }
00493 
00494 
00495 
00496 
00497 /********************************************************************************************
00498 
00499 >   void LiveEffectsInfoBarOp::GadgetMessage_Edit(DialogMsg* Message)
00500 
00501     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00502     Created:    06/10/2004
00503     Inputs:     Message - A dialog message 
00504     Returns:    The result of the message
00505     Purpose:    Takes a look at the message and if it is for me it responds to it.
00506 
00507 ********************************************************************************************/
00508 
00509 void LiveEffectsInfoBarOp::GadgetMessage_Edit(DialogMsg* Message)
00510 {
00511     switch (Message->DlgMsg)
00512     {
00513         case DIM_LFT_BN_CLICKED:
00514         {
00515             String_256 strCurrentEffectID = m_pTool->GetCurrentEffectID();
00516 
00517             // Special case for old legacy effects
00518             if (strCurrentEffectID==String_256(POSTPRO_ID_SHADOW))
00519             {
00520                 // Make sure the Shadow tool is current... (this func can be called from other tools)
00521                 Tool* pShadowTool = Tool::FindTool(TOOLID_SOFTSHADOW);
00522                 if (pShadowTool && !pShadowTool->IsCurrent())
00523                 {
00524                     INT32 iStackPos = m_pTool->GetCurrentStackPos();
00525                     ListRange* pShadowRange = m_pTool->GetEffectsStack()->GetLevelRange(&iStackPos);
00526                     if (pShadowRange)
00527                     {
00528                         ((SoftShadowTool*)pShadowTool)->SelectShadowRange(pShadowRange);
00529                     }
00530 
00531                     pShadowTool->SetCurrent();
00533 //                  INT32 iStackPos = m_pTool->GetCurrentStackPos();
00534 //                  ListRange* pShadowRange = m_pTool->GetEffectsStack()->GetLevelRange(&iStackPos);
00535 //                  ((SoftShadowTool*)pShadowTool)->SetShadowEditRange(pShadowRange, m_pTool->GetCurrentStackPos(), TRUE);  // Must be consistent because it comes from the PPStack
00536                     return;
00537                 }
00538             }
00539 
00540 #ifdef FEATHER_EFFECT
00541             if (strCurrentEffectID==String_256(POSTPRO_ID_FEATHER))
00542             {
00543                 INT32 iStackPos = m_pTool->GetCurrentStackPos();
00544                 ListRange* pFeatherRange = m_pTool->GetEffectsStack()->GetLevelRange(&iStackPos);
00545                 OpChangeFeatherSize::SetEditContext(iStackPos, pFeatherRange);
00546                 return;
00547             }
00548 #endif
00549 
00550             if (strCurrentEffectID!=String(""))
00551             {
00552                 OpDescriptor* pOp = NULL;
00553                 pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_EDIT_LIVEEFFECT);
00554 
00555                 if (pOp)
00556                 {
00557                     // Commit changes of any modeless edit session already running
00558                     // and close it down ready for this new one...
00559                     if (XPEHost::IsEditSessionRunning())
00560                     {
00561                         XPEHost::EndEditLiveEffect();       // Could change PPStack!
00562                         m_pTool->UpdatePPStack();
00563                     }
00564 
00565                     OpLiveEffectParam Param;
00566                     Param.strOpUnique = strCurrentEffectID;
00567                     Param.StackPosition = m_pTool->GetCurrentStackPos();
00568                     Param.pPPStack = m_pTool->GetEffectsStack();
00569                     BOOL bValid = XPEHost::GetEffectDetails(strCurrentEffectID, &Param.strMenuText, &Param.bIsDestructive);
00570 
00571                     if (bValid)
00572                     {
00573                         pOp->Invoke(&Param);
00574                         return;
00575                     }
00576                 }
00577             }
00578         }
00579     }
00580 }
00581 
00582 
00583 
00584 
00585 /********************************************************************************************
00586 
00587 >   void LiveEffectsInfoBarOp::GadgetMessage_Add(DialogMsg* Message)
00588 
00589     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00590     Created:    06/10/2004
00591     Inputs:     Message - A dialog message 
00592     Returns:    The result of the message
00593     Purpose:    Takes a look at the message and if it is for me it responds to it.
00594 
00595 ********************************************************************************************/
00596 
00597 void LiveEffectsInfoBarOp::GadgetMessage_Add(DialogMsg* Message)
00598 {
00599     switch (Message->DlgMsg)
00600     {
00601         case DIM_LFT_BN_CLICKED:
00602         {
00603             // Commit changes of any modeless edit session already running
00604             // and close it down ready for this new one...
00605             if (XPEHost::IsEditSessionRunning())
00606             {
00607                 XPEHost::EndEditLiveEffect();       // Could change PPStack!
00608                 m_pTool->UpdatePPStack();
00609             }
00610 
00611             LiveEffectsMenu* pLEMenu = new LiveEffectsMenu();
00612             if (pLEMenu)
00613             {
00614                 pLEMenu->SetStackPos(STACKPOS_INSERT_TOP);
00615                 pLEMenu->SetEffectsStack(m_pTool->GetEffectsStack());
00616                 pLEMenu->Show();
00617             }
00618         }
00619     }
00620 }
00621 
00622 
00623 
00624 
00625 /********************************************************************************************
00626 
00627 >   void LiveEffectsInfoBarOp::GadgetMessage_Label(DialogMsg* Message)
00628 
00629     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00630     Created:    06/10/2004
00631     Inputs:     Message - A dialog message 
00632     Returns:    The result of the message
00633     Purpose:    Takes a look at the message and if it is for me it responds to it.
00634 
00635 ********************************************************************************************/
00636 
00637 void LiveEffectsInfoBarOp::GadgetMessage_Label(DialogMsg* Message)
00638 {
00639     switch (Message->DlgMsg)
00640     {
00641         case DIM_RGT_BN_CLICKED:
00642         {
00643             // Commit changes of any modeless edit session already running
00644             // and close it down ready for this new one...
00645             if (XPEHost::IsEditSessionRunning())
00646             {
00647                 XPEHost::EndEditLiveEffect();       // Could change PPStack!
00648                 m_pTool->UpdatePPStack();
00649             }
00650 
00651             LiveEffectsMenu* pLEMenu = new LiveEffectsMenu();
00652             if (pLEMenu)
00653             {
00654                 pLEMenu->SetStackPos(STACKPOS_INSERT_TOP);
00655                 pLEMenu->SetEffectsStack(m_pTool->GetEffectsStack());
00656                 pLEMenu->Show();
00657             }
00658         }
00659     }
00660 }
00661 
00662 
00663 
00664 
00665 /********************************************************************************************
00666 
00667 >   void LiveEffectsInfoBarOp::GadgetMessage_Resolution(DialogMsg* Message) 
00668 
00669     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00670     Created:    07/06/2005
00671     Inputs:     Message - A dialog message 
00672     Returns:    The result of the message
00673     Purpose:    Takes a look at the message and if it is for me it responds to it.
00674 
00675 ********************************************************************************************/
00676 
00677 void LiveEffectsInfoBarOp::GadgetMessage_Resolution(DialogMsg* Message) 
00678 {
00679     switch (Message->DlgMsg)
00680     {
00681         case DIM_SELECTION_CHANGED:
00682         {
00683             // Commit changes of any modeless edit session already running
00684             // and close it down ready for this new one...
00685             if (XPEHost::IsEditSessionRunning())
00686             {
00687                 XPEHost::EndEditLiveEffect();       // Could change PPStack!
00688                 m_pTool->UpdatePPStack();
00689             }
00690 
00691             BOOL Valid = FALSE;
00692             INT32 lValue = 0;
00693 
00694             lValue = GetResDropListValue(_R(IDC_COMBOBOX_LE_RES), TRUE, &Valid);
00695 
00696             if (Valid)
00697             {
00698                 // Update the resolution of the specified effects
00699                 OpDescriptor* pOp = NULL;
00700                 pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_CHANGE_EFFECT_RES);
00701 
00702                 if (pOp)
00703                 {
00704                     OpLiveEffectParam Param;
00705 //                  Param.strOpUnique = strCurrentEffectID;
00706                     Param.StackPosition = m_pTool->GetCurrentStackPos();
00707                     Param.pPPStack = m_pTool->GetEffectsStack();
00708                     Param.dResolution = (double) lValue;
00709 //                  BOOL bValid = XPEHost::GetEffectDetails(strCurrentEffectID, &Param.strMenuText, &Param.bIsDestructive);
00710 
00711                     pOp->Invoke(&Param);
00712                     return;
00713                 }
00714             }
00715 
00716             // Repopulate the dropdown so that if the user missed off the ppi
00717             // it is restored
00718             EffectsStack* pStack = m_pTool->GetEffectsStack();
00719             INT32 iStackPos = m_pTool->GetCurrentStackPos();
00720             ListRange* pLevelRange = NULL;
00721             if (pStack)
00722                 pLevelRange = pStack->GetLevelRange(&iStackPos);
00723 
00724             PopulateResolutionDropdown(pStack, pLevelRange, FALSE);
00725         }
00726     }
00727 }
00728 
00729 
00730 
00731 
00732 /********************************************************************************************
00733 
00734 >   void LiveEffectsInfoBarOp::GadgetMessage_ToggleLock(DialogMsg* Message)
00735 
00736     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00737     Created:    07/06/2005
00738     Inputs:     Message - A dialog message 
00739     Returns:    The result of the message
00740     Purpose:    Takes a look at the message and if it is for me it responds to it.
00741 
00742 ********************************************************************************************/
00743 
00744 void LiveEffectsInfoBarOp::GadgetMessage_ToggleLock(DialogMsg* Message)
00745 {
00746     switch (Message->DlgMsg)
00747     {
00748         case DIM_LFT_BN_CLICKED:
00749         {
00750             // Commit changes of any modeless edit session already running
00751             // and close it down ready for this new one...
00752             if (XPEHost::IsEditSessionRunning())
00753             {
00754                 XPEHost::EndEditLiveEffect();       // Could change PPStack!
00755                 m_pTool->UpdatePPStack();
00756             }
00757 
00758             // Toggle the state of the button
00759             m_bLockSwitchState = !m_bLockSwitchState;
00760             BOOL bIsSelected = GetBoolGadgetSelected(Message->GadgetID, m_bLockSwitchState);
00761 
00762             OpDescriptor* pOp = NULL;
00763             pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_CHANGE_EFFECT_LOCK);
00764 
00765             if (pOp)
00766             {
00767                 OpLiveEffectParam Param;
00768 //              Param.strOpUnique = strCurrentEffectID;
00769                 Param.StackPosition = m_pTool->GetCurrentStackPos();
00770                 Param.pPPStack = m_pTool->GetEffectsStack();
00771 //              BOOL bValid = XPEHost::GetEffectDetails(strCurrentEffectID, &Param.strMenuText, &Param.bIsDestructive);
00772                 Param.bForceLock = m_bLockSwitchState;
00773 
00774                 pOp->Invoke(&Param);
00775                 return;
00776             }
00777         }
00778     }
00779 }
00780 
00781 
00782 
00783 
00784 /********************************************************************************************
00785 
00786 >   void LiveEffectsInfoBarOp::GadgetMessage_ToggleLockAll(DialogMsg* Message)
00787 
00788     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00789     Created:    07/06/2005
00790     Inputs:     Message - A dialog message 
00791     Returns:    The result of the message
00792     Purpose:    Takes a look at the message and if it is for me it responds to it.
00793 
00794 ********************************************************************************************/
00795 
00796 void LiveEffectsInfoBarOp::GadgetMessage_ToggleLockAll(DialogMsg* Message)
00797 {
00798     switch (Message->DlgMsg)
00799     {
00800         case DIM_LFT_BN_CLICKED:
00801         {
00802             // Commit changes of any modeless edit session already running
00803             // and close it down ready for this new one...
00804             if (XPEHost::IsEditSessionRunning())
00805             {
00806                 XPEHost::EndEditLiveEffect();       // Could change PPStack!
00807                 m_pTool->UpdatePPStack();
00808             }
00809 
00810             // Toggle the state of the button
00811             m_bLockAllSwitchState = !m_bLockAllSwitchState;
00812             BOOL bIsSelected = GetBoolGadgetSelected(Message->GadgetID, m_bLockAllSwitchState);
00813 
00814             OpDescriptor* pOp = NULL;
00815             pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_CHANGE_EFFECT_LOCKALL);
00816 
00817             if (pOp)
00818             {
00819                 OpLiveEffectParam Param;
00820                 Param.bForceLock = m_bLockAllSwitchState;
00821 
00822                 pOp->Invoke(&Param);
00823                 return;
00824             }
00825         }
00826     }
00827 }
00828 
00829 
00830 
00831 
00832 /********************************************************************************************
00833 
00834 >   void LiveEffectsInfoBarOp::GadgetMessage_Insert(DialogMsg* Message)
00835 
00836     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00837     Created:    06/10/2004
00838     Inputs:     Message - A dialog message 
00839     Returns:    The result of the message
00840     Purpose:    Takes a look at the message and if it is for me it responds to it.
00841 
00842 ********************************************************************************************/
00843 
00844 void LiveEffectsInfoBarOp::GadgetMessage_Insert(DialogMsg* Message)
00845 {
00846     switch (Message->DlgMsg)
00847     {
00848         case DIM_LFT_BN_CLICKED:
00849         {
00850             // Commit changes of any modeless edit session already running
00851             // and close it down ready for this new one...
00852             if (XPEHost::IsEditSessionRunning())
00853             {
00854                 XPEHost::EndEditLiveEffect();       // Could change PPStack!
00855                 m_pTool->UpdatePPStack();
00856             }
00857 
00858             LiveEffectsMenu* pLEMenu = new LiveEffectsMenu();
00859             if (pLEMenu)
00860             {
00861                 pLEMenu->SetStackPos(m_pTool->GetCurrentStackPos());
00862                 pLEMenu->SetEffectsStack(m_pTool->GetEffectsStack());
00863                 pLEMenu->Show();
00864             }
00865         }
00866     }
00867 }
00868 
00869 
00870 
00871 
00872 /********************************************************************************************
00873 
00874 >   void LiveEffectsInfoBarOp::GadgetMessage_Remove(DialogMsg* Message)
00875 
00876     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00877     Created:    06/10/2004
00878     Inputs:     Message - A dialog message 
00879     Returns:    The result of the message
00880     Purpose:    Takes a look at the message and if it is for me it responds to it.
00881 
00882 ********************************************************************************************/
00883 
00884 void LiveEffectsInfoBarOp::GadgetMessage_Remove(DialogMsg* Message)
00885 {
00886     switch (Message->DlgMsg)
00887     {
00888         case DIM_LFT_BN_CLICKED:
00889         {
00890             String_256 strCurrentEffectID = m_pTool->GetCurrentEffectID();
00891             if (strCurrentEffectID!=String(""))
00892             {
00893                 // Commit changes of any modeless edit session already running
00894                 // and close it down ready for this new one...
00895                 if (XPEHost::IsEditSessionRunning())
00896                 {
00897                     XPEHost::EndEditLiveEffect();       // Could change PPStack!
00898                     m_pTool->UpdatePPStack();
00899                 }
00900 
00901                 OpDescriptor* pOp = NULL;
00902                 pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_DELETE_LIVEEFFECT);
00903 
00904                 if (pOp)
00905                 {
00906                     OpLiveEffectParam Param;
00907                     Param.strOpUnique = strCurrentEffectID;
00908                     Param.StackPosition = m_pTool->GetCurrentStackPos();
00909                     Param.pPPStack = m_pTool->GetEffectsStack();
00910                     BOOL bValid = XPEHost::GetEffectDetails(strCurrentEffectID, &Param.strMenuText, &Param.bIsDestructive);
00911 
00912                     // We want to delete the effect whether it was valid or not
00913                     pOp->Invoke(&Param);
00914                     return;
00915                 }
00916             }
00917         }
00918     }
00919 }
00920 
00921 
00922 
00923 
00924 /********************************************************************************************
00925 
00926 >   void LiveEffectsInfoBarOp::GadgetMessage_RemoveAll(DialogMsg* Message)
00927 
00928     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00929     Created:    06/10/2004
00930     Inputs:     Message - A dialog message 
00931     Returns:    The result of the message
00932     Purpose:    Takes a look at the message and if it is for me it responds to it.
00933 
00934 ********************************************************************************************/
00935 
00936 void LiveEffectsInfoBarOp::GadgetMessage_RemoveAll(DialogMsg* Message)
00937 {
00938     switch (Message->DlgMsg)
00939     {
00940         case DIM_LFT_BN_CLICKED:
00941         {
00942             // Commit changes of any modeless edit session already running
00943             // and close it down ready for this new one...
00944             if (XPEHost::IsEditSessionRunning())
00945             {
00946                 XPEHost::EndEditLiveEffect();       // Could change PPStack!
00947                 m_pTool->UpdatePPStack();
00948             }
00949 
00950             OpDescriptor* pOp = NULL;
00951             pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_DELETEALL_LIVEEFFECT);
00952 
00953             if (pOp)
00954             {
00955                 OpLiveEffectParam Param;
00956                 pOp->Invoke(&Param);
00957                 return;
00958             }
00959         }
00960     }
00961 }
00962 
00963 
00964 
00965 
00966 /********************************************************************************************
00967 
00968 >   void LiveEffectsInfoBarOp::GadgetMessage_Setup(DialogMsg* Message)
00969 
00970     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00971     Created:    06/10/2004
00972     Inputs:     Message - A dialog message 
00973     Returns:    The result of the message
00974     Purpose:    Takes a look at the message and if it is for me it responds to it.
00975 
00976 ********************************************************************************************/
00977 
00978 void LiveEffectsInfoBarOp::GadgetMessage_Setup(DialogMsg* Message)
00979 {
00980     switch (Message->DlgMsg)
00981     {
00982         case DIM_LFT_BN_CLICKED:
00983         {
00984             // Commit changes of any modeless edit session already running
00985             // and close it down ready for this new one...
00986             if (XPEHost::IsEditSessionRunning())
00987             {
00988                 XPEHost::EndEditLiveEffect();       // Could change PPStack!
00989                 m_pTool->UpdatePPStack();
00990             }
00991 
00992             if (ClickModifiers::GetClickModifiers().Adjust)
00993                 XPEEditOp::EditPluginSettings();
00994             else
00995             {
00996                 OpDescriptor* pOp = NULL;
00997                 pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_PLUGSDLG);
00998 
00999                 String_256 strDesc;
01000                 if (pOp && !pOp->GetOpsState(&strDesc).Greyed)
01001                 {
01002                     pOp->Invoke();
01003                     return;
01004                 }
01005             }
01006         }
01007     }
01008 }
01009 
01010 
01011 
01012 
01013 /********************************************************************************************
01014 
01015 >   void LiveEffectsInfoBarOp::HandleCreate()
01016 
01017     Author:     Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
01018     Created:    23/3/2000
01019     Inputs:     -
01020     Returns:    -
01021     Purpose:    Called when a DIM_CREATE message is received
01022 
01023 ********************************************************************************************/
01024 
01025 void LiveEffectsInfoBarOp::HandleCreate()
01026 {
01027     // Don't do anything if the Info bar isn't displayed
01028 //  if (!LiveEffectsTool::IsCurrentTool() || !IsVisible()) return;
01029 
01030     if (WindowID!=NULL)
01031     {
01032         // Mark the controls as existing
01033         m_bControlsExist = TRUE;
01034 
01035         // Set the state of the pressure button according to the Op's state.
01036         // Why buttons on infobars can't dynamically auto-connect to their ops is beyond me
01037         UpdateState();
01038     }
01039 }
01040 
01041 /********************************************************************************************
01042 
01043 >   void LiveEffectsInfoBarOp::SetToolActiveState(BOOL IsToolActive)
01044 
01045     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
01046     Created:    31/8/94
01047     Inputs:     IsToolActive - TRUE if the tool is becoming active, FALSE if it not
01048     Purpose:    Allows the info bar to know if it is valid or not
01049 
01050 ********************************************************************************************/
01051 
01052 void LiveEffectsInfoBarOp::SetToolActiveState(BOOL IsToolActive)
01053 {
01054     // Set the control state
01055     m_bControlsExist = IsToolActive;
01056 }
01057 
01058 
01059 
01060 /********************************************************************************************
01061 
01062 >   virtual void LiveEffectsInfoBarOp::UpdateState()
01063 
01064     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
01065     Created:    21/1/97
01066 
01067     Purpose:    Sets the state of button on the bar to keep them up to date
01068 
01069 ********************************************************************************************/
01070 
01071 void LiveEffectsInfoBarOp::UpdateState()
01072 {
01073     // Don't try to set our controls when they're not there!
01074     if (!m_bControlsExist)
01075         return;
01076 
01077     if (CCamApp::DisableSys)            // Inside an error handler
01078         return;
01079 
01080     EffectsStack* pStack = m_pTool->GetEffectsStack();
01081     INT32 iStackPos = m_pTool->GetCurrentStackPos();
01082 
01083     IXMLDOMDocumentPtr pDoc = XPEHost::GetEditorsList();
01084     PopulateOrderDropdown(pStack, iStackPos);
01085 
01086     ListRange* pLevelRange = NULL;
01087     if (pStack)
01088         pLevelRange = pStack->GetLevelRange(&iStackPos);
01089 
01090     UpdateAddButton(pStack, pLevelRange);
01091     UpdateEditButton(pStack, pLevelRange);
01092     PopulateResolutionDropdown(pStack, pLevelRange);
01093     UpdateLockButton(pLevelRange);
01094     UpdateRemoveButton(pLevelRange);
01095     UpdateLockAllButton();
01096     UpdateRemoveAllButton();
01097     UpdateSetupButton();
01098 }
01099 
01100 
01101 
01102 
01103 /********************************************************************************************
01104 
01105 >   void LiveEffectsInfoBarOp::PopulateOrderDropdown(ListRange* pPPStack, iSelectedStackPos)
01106 
01107     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01108     Created:    06/10/2004
01109     Inputs:     -
01110     Outputs:    -
01111     Returns:    -
01112     Purpose:    -
01113 ********************************************************************************************/
01114 
01115 void LiveEffectsInfoBarOp::PopulateOrderDropdown(EffectsStack* pPPStack, INT32 iSelectedStackPos)
01116 {
01117     // Don't try to set our controls when they're not there!
01118     if (!m_bControlsExist)
01119         return;
01120 
01121     if (pPPStack==NULL)
01122         return;
01123 
01124     DeleteAllValues(_R(IDC_COMBOBOX_LE_ORDER));
01125     SetComboListLength(_R(IDC_COMBOBOX_LE_ORDER));
01126     SetGadgetWritable(_R(IDC_COMBOBOX_LE_ORDER), FALSE);
01127 
01128     if (!pPPStack->bConsistent)
01129     {
01130         // There is no consistent set of LiveEffects applied to the selection
01131         SetStringGadgetValue(_R(IDC_COMBOBOX_LE_ORDER), _R(IDS_LE_MANY));
01132         SetSelectedValueIndex(_R(IDC_COMBOBOX_LE_ORDER), 0);
01133     }
01134     else
01135     {
01136         if (pPPStack->IsEmpty())
01137         {
01138             // There is no consistent set of LiveEffects applied to the selection
01139             SetStringGadgetValue(_R(IDC_COMBOBOX_LE_ORDER), _R(IDS_LE_NONE));
01140             SetSelectedValueIndex(_R(IDC_COMBOBOX_LE_ORDER), 0);
01141         }
01142         else
01143         {
01144             // This is a consistent set of LiveEffects applied to the selection
01145             INT32 pos = 0;
01146             PPStackLevel* pLevel = (PPStackLevel*)pPPStack->GetHead();
01147             while (pLevel!=NULL)
01148             {
01149                 String_64 strDisplayName;
01150                 if (pLevel->pPPNode!=NULL && pLevel->pPPNode->IsBitmapEffect())
01151                     strDisplayName = ((NodeBitmapEffect*)(pLevel->pPPNode))->GetDisplayName();
01152                 BOOL bDestructive = FALSE;
01153                 BOOL bFound = XPEHost::GetEffectDetails(pLevel->strPostProID, &strDisplayName, &bDestructive);
01154 
01155                 TCHAR Str[64];
01156                 String_64 pjm(_R(IDS_LE_ORDER_FORMAT));
01157                 if (!bFound)
01158                     pjm = String_64(_R(IDS_LE_ORDER_FORMAT_NOTFOUND));
01159                 else if (bDestructive)
01160                     pjm = String_64(_R(IDS_LE_ORDER_FORMAT_DESTRUCTIVE));
01161                 camSprintf(Str, pjm, pos+1, (LPTSTR)strDisplayName);
01162                 String_64 strOrderedName(Str);
01163 
01164                 SetStringGadgetValue(_R(IDC_COMBOBOX_LE_ORDER), &strOrderedName, FALSE, pos);
01165 
01166                 if (pos==iSelectedStackPos)
01167                     SetSelectedValueIndex(_R(IDC_COMBOBOX_LE_ORDER), pos);
01168 
01169                 pos++;
01170                 pLevel = (PPStackLevel*)pPPStack->GetNext(pLevel);
01171             }
01172         }
01173     }
01174     SetComboListLength(_R(IDC_COMBOBOX_LE_ORDER));
01175 }
01176 
01177 
01178 
01179 
01180 /********************************************************************************************
01181 
01182 >   void LiveEffectsInfoBarOp::PopulateResolutionDropdown(EffectsStack* pStack, ListRange* pLevelRange, BOOL bUpdateList = TRUE)
01183 
01184     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01185     Created:    06/10/2004
01186     Inputs:     -
01187     Outputs:    -
01188     Returns:    -
01189     Purpose:    -
01190 
01191 ********************************************************************************************/
01192 
01193 void LiveEffectsInfoBarOp::PopulateResolutionDropdown(EffectsStack* pStack, ListRange* pLevelRange, BOOL bUpdateList)
01194 {
01195     // Don't try to set our controls when they're not there!
01196     if (!m_bControlsExist)
01197         return;
01198 
01199     if (bUpdateList)
01200     {
01201         BuildResDropList(_R(IDC_COMBOBOX_LE_RES), TRUE, FALSE, -1);
01202         SetGadgetWritable(_R(IDC_COMBOBOX_LE_RES), TRUE);
01203     }
01204 
01205     if (pLevelRange==NULL)
01206         return;
01207 
01208     double dRes = -1;                               // -1 means "None"
01209     Node* pNode = pLevelRange->FindFirst();
01210     BOOL bCanChangeRes = FALSE;
01211     while (pNode)
01212     {
01213         if (pNode->IsBitmapEffect())
01214         {
01215             NodeBitmapEffect* pEffect = (NodeBitmapEffect*)pNode;
01216             bCanChangeRes = bCanChangeRes || pEffect->CanBeUnlocked();
01217             if (dRes==-1)
01218                 dRes = pEffect->GetPixelsPerInchValue();
01219             else
01220             {
01221                 if (dRes != pEffect->GetPixelsPerInchValue())
01222                 {
01223                     dRes = -2;                      // -2 means "Many"
01224                     break;
01225                 }
01226             }
01227         }
01228 
01229         pNode = pLevelRange->FindNext(pNode);
01230     }
01231 
01232     switch ((INT32)dRes)
01233     {
01234     case -2:    // Many
01235         // There is no consistent set of LiveEffects applied to the selection
01236         SetSelectedValueIndex(_R(IDC_COMBOBOX_LE_RES), -1);
01237         SetStringGadgetValue(_R(IDC_COMBOBOX_LE_RES), _R(IDS_LE_MANY), FALSE, -1);
01238         EnableGadget(_R(IDC_COMBOBOX_LE_RES), FALSE);
01239         break;
01240 
01241     case -1:    // None
01242         // There are no LiveEffects applied to the selection
01243         SetSelectedValueIndex(_R(IDC_COMBOBOX_LE_RES), -1);
01244         SetStringGadgetValue(_R(IDC_COMBOBOX_LE_RES), _R(IDS_LE_NONE), FALSE, -1);
01245         EnableGadget(_R(IDC_COMBOBOX_LE_RES), FALSE);
01246         break;
01247 
01248     case 0:     // Automatic
01249         // There is a consistent LiveEffect resolution of 0/automatic applied to the selection
01250         SetStringGadgetValue(_R(IDC_COMBOBOX_LE_RES), _R(IDS_LE_AUTO), FALSE, -1);
01251         SetSelectedValueIndex(_R(IDC_COMBOBOX_LE_RES), 0);
01252         EnableGadget(_R(IDC_COMBOBOX_LE_RES), bCanChangeRes);
01253         break;
01254 
01255     default:    // Consistent value
01256         SetResDropListValue(_R(IDC_COMBOBOX_LE_RES), TRUE, (INT32)dRes);
01257         EnableGadget(_R(IDC_COMBOBOX_LE_RES), bCanChangeRes);
01258         break;
01259     }
01260 }
01261 
01262 
01263 
01264 
01265 /********************************************************************************************
01266 
01267 >   void LiveEffectsInfoBarOp::UpdateLockButton(ListRange* pLevelRange)
01268 
01269     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01270     Created:    06/10/2004
01271     Inputs:     -
01272     Outputs:    -
01273     Returns:    -
01274     Purpose:    -
01275 ********************************************************************************************/
01276 
01277 void LiveEffectsInfoBarOp::UpdateLockButton(ListRange* pLevelRange)
01278 {
01279 // While the Lock button is hidden from the UI
01280 // we have to avoid trying to use it (I can't find
01281 // a way to test programmatically whether it exists)
01282 return;
01283 
01284     // Don't try to set our controls when they're not there!
01285     if (!m_bControlsExist)
01286         return;
01287 
01288     if (pLevelRange==NULL)
01289         return;
01290 
01291     // Try to find a consistent lock state...
01292     BOOL bSomeOrAllAreLocked = FALSE;
01293     BOOL bEnableButton = FALSE;
01294     Node* pNode = pLevelRange->FindFirst();
01295     while (pNode)
01296     {
01297         if (pNode->IsBitmapEffect())
01298         {
01299             NodeBitmapEffect* pEffect = (NodeBitmapEffect*)pNode;
01300             if (!pEffect->IsFeatherEffect())
01301             {
01302                 if (pEffect->IsLockedEffect())
01303                 {
01304                     bEnableButton = (bEnableButton || pEffect->CanBeUnlocked());
01305                     bSomeOrAllAreLocked = (bSomeOrAllAreLocked || pEffect->CanBeUnlocked());
01306                     if (bSomeOrAllAreLocked && bEnableButton)
01307                         break;
01308                 }
01309                 else
01310                     bEnableButton = TRUE;
01311             }
01312         }
01313 
01314         pNode = pLevelRange->FindNext(pNode);
01315     }
01316 
01317     m_bLockSwitchState = bSomeOrAllAreLocked;
01318     SetBoolGadgetSelected(_R(IDC_CCBUTTON_LE_TOGGLELOCK), m_bLockSwitchState);
01319     EnableGadget(_R(IDC_CCBUTTON_LE_TOGGLELOCK), bEnableButton);
01320 }
01321 
01322 
01323 
01324 
01325 /********************************************************************************************
01326 
01327 >   void LiveEffectsInfoBarOp::UpdateRemoveButton(ListRange* pLevelRange)
01328 
01329     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01330     Created:    20/06/2005
01331     Inputs:     -
01332     Outputs:    -
01333     Returns:    -
01334     Purpose:    -
01335 ********************************************************************************************/
01336 
01337 void LiveEffectsInfoBarOp::UpdateRemoveButton(ListRange* pLevelRange)
01338 {
01339     // Don't try to set our controls when they're not there!
01340     if (!m_bControlsExist)
01341         return;
01342 
01343     if (pLevelRange==NULL)
01344         return;
01345 
01346     BOOL bEnableButton = FALSE;
01347     Node* pNode = pLevelRange->FindFirst();
01348     while (pNode)
01349     {
01350         if (pNode->IsEffect())
01351         {
01352             bEnableButton = TRUE;
01353             break;
01354         }
01355 
01356         pNode = pLevelRange->FindNext(pNode);
01357     }
01358 
01359     EnableGadget(_R(IDC_CCBUTTON_LE_REMOVE), bEnableButton);
01360 }
01361 
01362 
01363 
01364 
01365 /********************************************************************************************
01366 
01367 >   void LiveEffectsInfoBarOp::UpdateAddButton(EffectsStack* pStack, ListRange* pLevelRange)
01368 
01369     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01370     Created:    20/09/2005
01371     Inputs:     -
01372     Outputs:    -
01373     Returns:    -
01374     Purpose:    -
01375 ********************************************************************************************/
01376 
01377 void LiveEffectsInfoBarOp::UpdateAddButton(EffectsStack* pStack, ListRange* pLevelRange)
01378 {
01379     // Don't try to set our controls when they're not there!
01380     if (!m_bControlsExist)
01381         return;
01382 
01383     if (pLevelRange==NULL)
01384         return;
01385 
01386 //  BOOL bEnableButton = !XPEHost::IsEditSessionRunning();
01387     BOOL bEnableButton = (pLevelRange->FindFirst()!=NULL);
01388 
01389     EnableGadget(_R(IDC_CCBUTTON_LE_ADD), bEnableButton);
01390     EnableGadget(_R(IDC_BUTTON_LE_ADD), bEnableButton);
01391 }
01392 
01393 
01394 
01395 
01396 /********************************************************************************************
01397 
01398 >   void LiveEffectsInfoBarOp::UpdateAddButton(EffectsStack* pStack, ListRange* pLevelRange)
01399 
01400     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01401     Created:    20/09/2005
01402     Inputs:     -
01403     Outputs:    -
01404     Returns:    -
01405     Purpose:    -
01406 ********************************************************************************************/
01407 
01408 void LiveEffectsInfoBarOp::UpdateAddButton(EffectsStack* pStack, ListRange* pLevelRange)
01409 {
01410     // Don't try to set our controls when they're not there!
01411     if (!m_bControlsExist)
01412         return;
01413 
01414     if (pLevelRange==NULL)
01415         return;
01416 
01417 //  BOOL bEnableButton = !XPEHost::IsEditSessionRunning();
01418     BOOL bEnableButton = (pLevelRange->FindFirst()!=NULL);
01419 
01420     EnableGadget(_R(IDC_CCBUTTON_LE_ADD), bEnableButton);
01421     EnableGadget(_R(IDC_BUTTON_LE_ADD), bEnableButton);
01422 }
01423 
01424 
01425 
01426 
01427 /********************************************************************************************
01428 
01429 >   void LiveEffectsInfoBarOp::UpdateEditButton(EffectsStack* pStack, ListRange* pLevelRange)
01430 
01431     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01432     Created:    20/06/2005
01433     Inputs:     -
01434     Outputs:    -
01435     Returns:    -
01436     Purpose:    -
01437 ********************************************************************************************/
01438 
01439 void LiveEffectsInfoBarOp::UpdateEditButton(EffectsStack* pStack, ListRange* pLevelRange)
01440 {
01441     // Don't try to set our controls when they're not there!
01442     if (!m_bControlsExist)
01443         return;
01444 
01445     if (pLevelRange==NULL)
01446         return;
01447 
01448     BOOL bEnableButton = FALSE;
01449     if (pStack->bConsistent /*&& !XPEHost::IsEditSessionRunning()*/)
01450     {
01451         Node* pNode = pLevelRange->FindFirst();
01452         while (pNode)
01453         {
01454             if (pNode->IsEffect())
01455             {
01456                 bEnableButton = TRUE;
01457                 break;
01458             }
01459 
01460             pNode = pLevelRange->FindNext(pNode);
01461         }
01462     }
01463 
01464     EnableGadget(_R(IDC_CCBUTTON_LE_EDIT), bEnableButton);
01465     EnableGadget(_R(IDC_BUTTON_LE_EDIT), bEnableButton);
01466 }
01467 
01468 
01469 
01470 
01471 /********************************************************************************************
01472 
01473 >   void LiveEffectsInfoBarOp::UpdateLockAllButton()
01474 
01475     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01476     Created:    06/10/2004
01477     Inputs:     -
01478     Outputs:    -
01479     Returns:    -
01480     Purpose:    -
01481 ********************************************************************************************/
01482 
01483 void LiveEffectsInfoBarOp::UpdateLockAllButton()
01484 {
01485     // Don't try to set our controls when they're not there!
01486     if (!m_bControlsExist)
01487         return;
01488 
01489     SelRange Sel(*(GetApplication()->FindSelection()));
01490     Sel.SetPromoteToParent(TRUE);
01491     Node* pNode = Sel.FindFirst();
01492     Node* pNextNode = NULL;
01493     BOOL bSomeOrAllAreLocked = FALSE;
01494     BOOL bEnableButton = FALSE;
01495     while (pNode && !bSomeOrAllAreLocked && !bEnableButton)
01496     {
01497         pNextNode = Sel.FindNext(pNode);
01498 
01499         // We must find all effects in our subtree
01500         Node* pScanNode = pNode->FindFirstPreorder();
01501         while (pScanNode)
01502         {
01503             if (pScanNode->IsBitmapEffect() && !((NodeBitmapEffect*)pScanNode)->IsFeatherEffect())
01504             {
01505                 NodeBitmapEffect* pEffect = (NodeBitmapEffect*)pScanNode;
01506                 if (pEffect->IsLockedEffect())
01507                 {
01508                     bEnableButton = (bEnableButton || pEffect->CanBeUnlocked());
01509                     bSomeOrAllAreLocked = (bSomeOrAllAreLocked || pEffect->CanBeUnlocked());
01510                     if (bEnableButton && bSomeOrAllAreLocked)
01511                         break;
01512                 }
01513                 else
01514                     bEnableButton = TRUE;
01515 
01516                 // We don't want to lock any effects under this one
01517                 // So find the next node in preorder order outside the scan node
01518                 pScanNode = pScanNode->FindNextPreorder(pNode, TRUE);
01519             }
01520             else
01521                 pScanNode = pScanNode->FindNextPreorder(pNode);
01522         }
01523 
01524         pNode = pNextNode;
01525     }
01526 
01527     m_bLockAllSwitchState = bSomeOrAllAreLocked;
01528     SetBoolGadgetSelected(_R(IDC_CCBUTTON_LE_TOGGLELOCKALL), m_bLockAllSwitchState);
01529     EnableGadget(_R(IDC_CCBUTTON_LE_TOGGLELOCKALL), bEnableButton);
01530 }
01531 
01532 
01533 
01534 
01535 /********************************************************************************************
01536 
01537 >   void LiveEffectsInfoBarOp::UpdateRemoveAllButton()
01538 
01539     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01540     Created:    20/06/2005
01541     Inputs:     -
01542     Outputs:    -
01543     Returns:    -
01544     Purpose:    -
01545 ********************************************************************************************/
01546 
01547 void LiveEffectsInfoBarOp::UpdateRemoveAllButton()
01548 {
01549     // Don't try to set our controls when they're not there!
01550     if (!m_bControlsExist)
01551         return;
01552 
01553     SelRange Sel(*(GetApplication()->FindSelection()));
01554     Node* pNode = Sel.FindFirst();
01555     BOOL bEnableButton = FALSE;
01556     ListRange* pStack = NULL;
01557     while (pNode)
01558     {
01559         pStack = EffectsStack::GetEffectsStackFromNode(pNode, TRUE, TRUE);
01560         if (pStack)
01561         {
01562             bEnableButton = TRUE;
01563             break;
01564         }
01565 
01566         pNode = Sel.FindNext(pNode);
01567     }
01568 
01569     if (pStack)
01570     {
01571         delete pStack;
01572         pStack = NULL;
01573     }
01574 
01575     EnableGadget(_R(IDC_CCBUTTON_LE_REMOVEALL), bEnableButton);
01576 }
01577 
01578 
01579 
01580 
01581 /********************************************************************************************
01582 
01583 >   void LiveEffectsInfoBarOp::UpdateSetupButton()
01584 
01585     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01586     Created:    15/07/2005
01587     Inputs:     -
01588     Outputs:    -
01589     Returns:    -
01590     Purpose:    -
01591 ********************************************************************************************/
01592 
01593 void LiveEffectsInfoBarOp::UpdateSetupButton()
01594 {
01595     // Don't try to set our controls when they're not there!
01596     if (!m_bControlsExist)
01597         return;
01598 
01599     OpDescriptor* pOp = NULL;
01600     pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_PLUGSDLG);
01601 
01602     String_256 strDesc;
01603     EnableGadget(_R(IDC_BUTTON_LE_SETUP), pOp && !pOp->GetOpsState(&strDesc).Greyed);
01604 }
01605 
01606 
01607 
01608 
01609 /********************************************************************************************
01610 
01611 >   void LiveEffectsInfoBarOp::SetGadgetWritable(INT32 id, BOOL enable)
01612 
01613     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01614     Created:    15/11/94
01615     Inputs:     id, the 'IDC_?' of the control.
01616                 enable, TRUE to allow the control to be typed into. FALSE to make it
01617                         read only.
01618     Purpose:    Sets the state of the 'Read Only' flag of an edit field or combo box.
01619     NOTE!!!     This should be in DialogOp/DialogManager!
01620 
01621 ********************************************************************************************/
01622 
01623 void LiveEffectsInfoBarOp::SetGadgetWritable(INT32 id, BOOL enable)
01624 {
01625     // Get the window handle of the gadget, from the gadget ID
01626     HWND gadget = ::GetDlgItem(WindowID, id);
01627 
01628     // See if it's got a child window (it may be a Combo Box)
01629     HWND hEdit = ::ChildWindowFromPoint(gadget, CPoint(1,1));
01630 
01631     if (hEdit)              // Was there a child window ?
01632         gadget = hEdit;     // Yes, so send the message to it
01633 
01634     if (enable)
01635     {
01636         ::SendMessage(gadget, EM_SETREADONLY, FALSE, 0);    // Clear the Read Only Flag
01637     }
01638     else
01639     {
01640         ::SendMessage(gadget, EM_SETREADONLY, TRUE, 0);     // Set the Read Only Flag
01641     }
01642 }
01643 
01644 
01645 
01646 

Generated on Sat Nov 10 03:47:40 2007 for Camelot by  doxygen 1.4.4