shadinfo.cpp

Go to the documentation of this file.
00001 // $Id: shadinfo.cpp 1401 2006-07-03 11:17:52Z 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 // Implementation of the Shadow Tool info bar 
00099 
00100 /*
00101     All new implementation of shadow code new/old produced by Mark Howitt 4/8/98!
00102 */
00103 
00104 #include "camtypes.h"
00105 //#include "nodecont.h"
00106 
00107 #ifdef BUILDSHADOWS
00108 
00109 #include "shadtool.h"
00110 #include "shadinfo.h"
00111 //#include "shadbar.h"
00112 //#include "shadres.h"
00113 //#include "range.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 //#include "resource.h"
00115 //#include "barsdlgs.h"
00116 //#include "rikdlg.h"
00117 //#include "justin2.h"
00118 //#include "simon.h"            // #define _R(IDS_AND)
00119 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00120 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00121 //#include "unittype.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00122 #include "optsmsgs.h"
00123 //#include "fillattr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00124 //#include "attrmgr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00125 #include "pathops.h"
00126 #include "opshadow.h"
00127 #include "opbevel.h"
00128 #include "nodeshad.h"
00129 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00130 #include "cutop.h"
00131 #include "blobs.h"
00132 #include "camelot.h"
00133 #include "dragmgr.h"
00134 //#include "biasres.h"
00135 //#include "biasgain.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00136 #include "objchge.h"
00137 #include "biasdlg.h"
00138 #include "nodeblnd.h"
00139 #include "opliveeffects.h"
00140 #include "selector.h"
00141 #include "ophist.h"
00142 
00143 DECLARE_SOURCE( "$Revision: 1401 $" );
00144 CC_IMPLEMENT_DYNCREATE(SoftShadowInfoBarOp,InformationBarOp)
00145 CC_IMPLEMENT_DYNCREATE(ShadowDragData,ListItem)
00146 
00147 #define new CAM_DEBUG_NEW
00148 
00149 // constants used by the infobar controls
00150 const   INT32           PositionShadowLimit = 999;
00151 const   INT32           PenumbraSizeLimit   = 999;
00152 const   INT32           ShadowSizeLimit     = 999;
00153         MILLIPOINT  IncPositionShadow   = 750;  // 1 Pixel
00154 const   MILLIPOINT  IncPenumbraSize     = 750;  // 1 Pixel
00155 
00156 
00157 const INT32     CONTRASTSLIDERMAX   = 100;
00158 const INT32     BLURSLIDERMAX       = 40 * 750; // 40 pixels
00159 const double    ANGLESLIDERMAX      = 69;       // 69 degrees
00160 const double    SIZESLIDERMAX       = 200;
00161 const float     SHADOWHEIGHTMAX     = 1.5;      // times object height
00162 const INT32     WIDTHSLIDERMAX      = 250000;
00163 
00164 // static members of the SoftShadowInfoBarData class
00165 InformationBarOp* SoftShadowInfoBarOp::pSoftShadowInfoBar   = NULL;
00166 Document*         SoftShadowInfoBarOp::pDoc                 = NULL;
00167 
00169 // Profile for the logarithmic width slider
00170 CProfileBiasGain GlowSliderProfile((AFp)0.7, (AFp)0.0);
00171 
00172 /********************************************************************************************
00173 
00174 >   SoftShadowInfoBarOp::SoftShadowInfoBarOp()
00175 
00176     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00177     Created:    15/11/96
00178     Purpose:    Sets the info bars vars to NULL defaults
00179 
00180 ********************************************************************************************/
00181 
00182 SoftShadowInfoBarOp::SoftShadowInfoBarOp()
00183 {
00184     pSoftShadowTool = NULL;
00185     CurrentSpread = NULL;
00186     CurrentNodePath = NULL;
00187 
00188     // Used to know whether it's the Apply button or the Remove button in the InfoBar
00189     ApplyButton = TRUE; 
00190 
00191     m_bControlsExist = FALSE;
00192 
00193     m_bBumping = FALSE;
00194     
00195     DlgResID = _R(IDD_SOFTSHADOWTOOLBAR);
00196 }
00197 
00198 /********************************************************************************************
00199 
00200 >   void SoftShadowInfoBarOp::InitControls()
00201 
00202     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00203     Created:    19/11/96
00204     Inputs:     -
00205     Outputs:    -
00206     Returns:    -
00207     Purpose:    Initialise the slider Info Bar control 
00208     
00209 ********************************************************************************************/
00210 
00211 void SoftShadowInfoBarOp::Init()
00212 {
00213     // current info bar public for callbacks arg..
00214     pSoftShadowInfoBar = this;
00215 
00216     //  The slider (Shadow Transparency)
00217     // Set the range of the control
00218     pSoftShadowInfoBar->SetGadgetRange(_R(IDC_SOFTSHADOWSLIDER), 0, CONTRASTSLIDERMAX, 1);
00219     // Gives the 3d bitmap to the slider, otherwise it has the appearance of a Win 95 slider (2d)
00220     pSoftShadowInfoBar->SetGadgetBitmaps(_R(IDC_SOFTSHADOWSLIDER), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
00221 
00222     pSoftShadowInfoBar->SetGadgetRange(_R(IDC_SOFTSHADOWSLIDER), 0, CONTRASTSLIDERMAX, 1);
00223     pSoftShadowInfoBar->SetGadgetBitmaps(_R(IDC_SOFTSHADOWTRANSPSLIDER), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
00224 
00225     // now load in the combo text entries
00226     String_64 Str;
00227 
00228     UpdateGadgetBlurSlider();
00229     UpdateGadgetTranspSlider();
00230 
00231 //  BiasGainGadget_m.LinkControlButton( this, _R(IDC_BIASGAIN), _R(IDBBL_BIASGAIN),  _R(IDS_BIASGAINDLG) );
00232     BiasGainGadget_m.Init(this, _R(IDC_BIASGAIN), _R(IDBBL_BIASGAIN),  _R(IDS_BIASGAINDLG) );
00233     BiasGainGadget_m.ToggleFillProfile ();
00234     
00235     UpdateInfoBar();
00236 }
00237 
00238 
00239 /********************************************************************************************
00240 
00241 >   BOOL SoftShadowInfoBarOp::ConvertValueToString(String_256 &In, const INT32 value, UnitType type, String_256 &unit)
00242 
00243     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00244     Created:    09/12/96
00245     Inputs:     The value to convert to a string (In)
00246     Outputs:    -
00247     Returns:    -
00248     Purpose:    TRUE if the function was able to convert the INT32 to a string
00249 
00250 ********************************************************************************************/
00251 
00252 BOOL SoftShadowInfoBarOp::ConvertValueToString(String_256 &In, const INT32 value, UnitType type, TCHAR *unit)
00253 {
00254     BOOL Converted = FALSE; // True when a value has been converted
00255     Range   Selection(*(GetApplication()->FindSelection()));
00256     RangeControl rg = Selection.GetRangeControlFlags();
00257     rg.PromoteToParent = TRUE;
00258     Selection.SetRangeControl(rg);
00259 
00260     if (Document::GetCurrent() == NULL)
00261         return FALSE;
00262 
00263     Node*   pNode = Selection.FindFirst();
00264 
00265     while (pNode != NULL/* && Selection != NULL*/)
00266     {
00267         CurrentSpread = pNode->FindParentSpread();
00268 
00269         if (CurrentSpread != NULL)
00270         {
00271             // Get the dimension scaling object (units) associated with the given spread
00272             // and convert to its units.
00273             DimScale* pDimScale = DimScale::GetPtrDimScale((Node*) CurrentSpread);
00274 //          UnitType Type = pDimScale->GetUnits();
00275             pDimScale->ConvertToUnits((INT32)value , &In);
00276             // In += unit;
00277                 Converted = TRUE;
00278         }
00279         else
00280         { 
00281             //TODO ??
00282         }
00283     
00284         pNode = Selection.FindNext(pNode);
00285     }
00286 
00287     return Converted;
00288         
00289 }
00290 
00291 
00292 /********************************************************************************************
00293 
00294 >   BOOL SoftShadowInfoBarOp::ConvertStringToValue(const String_256 &Out, MILLIPOINT& value)
00295 
00296     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00297     Created:    09/12/96
00298     Inputs:     The value to convert to a string (In)
00299     Outputs:    -
00300     Returns:    -
00301     Purpose:    TRUE if the function was able to convert the INT32 to a string
00302 
00303 ********************************************************************************************/
00304 
00305 BOOL SoftShadowInfoBarOp::ConvertStringToValue(CGadgetID ID, MILLIPOINT& Value)
00306 {
00307     BOOL Valid = FALSE; // True when a value has been converted
00308 
00309     Range   Selection(*(GetApplication()->FindSelection()));
00310     RangeControl rg = Selection.GetRangeControlFlags();
00311     rg.PromoteToParent = TRUE;
00312     Selection.SetRangeControl(rg);
00313     Node*   pNode = Selection.FindFirst();
00314 
00315     BOOL bContinue = FALSE;
00316 
00317     while (pNode != NULL/* && Selection != NULL*/)
00318     {   
00319         CurrentSpread = pNode->FindParentSpread();
00320 
00321         if (CurrentSpread != NULL)
00322         {
00323             // Get the dimension scaling object (units) associated with the given spread
00324             // and convert to its units.
00325             DimScale* pDimScale = DimScale::GetPtrDimScale((Node*) CurrentSpread);
00326             //String_128 FieldContents = GetStringGadgetValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_X), &Valid);
00327             String_128 FieldContents = GetStringGadgetValue(ID, &Valid);
00328             String_128 NumberString;
00329 
00330             bContinue = TRUE;
00331             /*
00332 
00333             for (INT32 i = 0 ; i < FieldContents.Length() && bContinue; i++)
00334             {
00335                 if (FieldContents[i] == '-' || FieldContents == '.' ||
00336                     (FieldContents[i] >= '0' && FieldContents[i] <= '9'))
00337                 {
00338                     NumberString += FieldContents[i];
00339                 }
00340                 else
00341                 {
00342                     bContinue = FALSE;
00343                 }
00344             }
00345 
00346             NumberString += "pix";
00347         
00348             Valid = pDimScale->ConvertToMillipoints(&NumberString, &Value);
00349                 */
00350 
00351             Valid = pDimScale->ConvertToMillipoints(FieldContents, &Value);
00352 
00353         }
00354         else
00355         { 
00356             //TODO ??
00357         }
00358 
00359         pNode = Selection.FindNext(pNode);
00360     }
00361 
00362     return Valid;
00363 }
00364 
00365 /********************************************************************************************
00366 
00367 >   void SoftShadowInfoBarOp::UpdateGadgetPositionShadowX()
00368 
00369     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00370     Created:    18/11/96
00371     Inputs:     TRUE if several selected shadow => display "Many" in the InfoBar
00372     Outputs:    -
00373     Returns:    -
00374     Purpose:    Update the PositionShadowX field
00375 
00376 ********************************************************************************************/
00377 
00378 void SoftShadowInfoBarOp::UpdateGadgetPositionShadowX()
00379 {
00380     String_256 In(_T("0 pix"));
00381 
00382     NodeShadowController* pMaster = pSoftShadowTool->GetShadowEditField(smOFFSETX, &In);
00383     if (pMaster)
00384         ConvertValueToString(In, pMaster->GetOffsetX() , PIXELS, _T(" pix"));
00385 
00386     pSoftShadowInfoBar->SetStringGadgetValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_X), In);
00387 }
00388 
00389 /********************************************************************************************
00390 
00391 >   void SoftShadowInfoBarOp::UpdateGadgetPositionShadowY()
00392 
00393     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00394     Created:    18/11/96
00395     Inputs:     TRUE if several selected shadow => display "Many" in the InfoBar
00396     Outputs:    -
00397     Returns:    -
00398     Purpose:    Update the PositionShadowX field
00399 
00400 ********************************************************************************************/
00401 
00402 void SoftShadowInfoBarOp::UpdateGadgetPositionShadowY()
00403 {
00404     String_256 In(_T("0pix"));
00405 
00406     NodeShadowController* pMaster = pSoftShadowTool->GetShadowEditField(smOFFSETY, &In);
00407     if (pMaster)
00408         ConvertValueToString(In, pMaster->GetOffsetY(), PIXELS, _T(" pix"));
00409 
00410     pSoftShadowInfoBar->SetStringGadgetValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_Y), In);
00411 }
00412 
00413 /********************************************************************************************
00414 
00415 >   void SoftShadowInfoBarOp::UpdateGadgetBlurSlider()
00416 
00417     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00418     Created:    19/11/96
00419     Inputs:     TRUE if several selected shadow => display "Many" in the InfoBar
00420     Outputs:    -
00421     Returns:    -
00422     Purpose:    Update the Slider
00423                 If bUpdateSlider is FALSE, then the slider settings aren't changed - just
00424                 the edit box
00425 
00426 ********************************************************************************************/
00427 
00428 void SoftShadowInfoBarOp::UpdateGadgetBlurSlider(BOOL bUpdateSlider)
00429 {
00430     // set the gadget range first
00431     pSoftShadowInfoBar->SetGadgetRange(_R(IDC_SOFTSHADOWSLIDER), 0, CONTRASTSLIDERMAX, 1);
00432 
00433     // Set the position of the slider
00434     String_256 Str(_T("0%"));
00435 
00436     double d = NodeShadowController::DefaultBlurSize;
00437     
00438     NodeShadowController* pMaster = pSoftShadowTool->GetShadowEditField(smPENUMBRA, &Str);
00439 //  if (pMaster==NULL && !SliderDragged)
00440 //  {
00441 //      Str.Load(_R(IDS_SHADOWSTRING_MANY));
00442 //  }
00443 //  else
00444 //  {
00445         if (pMaster)
00446         {
00447             d = pMaster->GetPenumbraWidth();
00448             ConvertValueToString(Str, (INT32)d, PIXELS, _T(" pix"));
00449         }
00450 //  }
00451     
00452     pSoftShadowInfoBar->SetStringGadgetValue(_R(IDC_SHADOW_SLIDER_EDIT), Str);
00453     
00454     d /= (double)BLURSLIDERMAX;
00455     //d = 1.0 - d;
00456     d *= 100;
00457     
00458     if (bUpdateSlider)
00459         pSoftShadowInfoBar->SetLongGadgetValue(_R(IDC_SOFTSHADOWSLIDER), (INT32)d);
00460 
00461     UpdateGadgetHelp();
00462     
00463 }
00464 
00465 /********************************************************************************************
00466 
00467 >   void SoftShadowInfoBarOp::UpdateGadgetTranspSlider()
00468 
00469     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00470     Created:    31/1/2000
00471     Inputs:     TRUE if several selected shadow => display "Many" in the InfoBar
00472     Outputs:    -
00473     Returns:    -
00474     Purpose:    Update the Transparency Slider
00475                 If bUpdateSlider is FALSE, then the slider settings aren't changed - just
00476                 the edit box
00477 
00478 ********************************************************************************************/
00479 
00480 void SoftShadowInfoBarOp::UpdateGadgetTranspSlider(BOOL bUpdateSlider)
00481 {
00482     // set the gadget range first
00483     pSoftShadowInfoBar->SetGadgetRange(_R(IDC_SOFTSHADOWTRANSPSLIDER), 0, CONTRASTSLIDERMAX, 1);
00484 
00485     // Set the position of the slider
00486     String_256 Str(_T("0%"));
00487     double dDarkness = 0;
00488 
00489     NodeShadowController* pMaster = pSoftShadowTool->GetShadowEditField(smDARKNESS, &Str);
00490     if (pMaster)
00491     {
00492         dDarkness = pMaster->GetShadow()->GetDarkness();
00493         SetDarknessEditGadget(dDarkness);
00494     }
00495     else
00496         pSoftShadowInfoBar->SetStringGadgetValue(_R(IDC_SHADOWTRANSP_EDIT), Str);
00497 
00498     if (bUpdateSlider)
00499         SetDarknessSlider(dDarkness);
00500 
00501     UpdateGadgetHelp(); 
00502 }
00503 
00504 
00505 /********************************************************************************************
00506 
00507 >   void SoftShadowInfoBarOp::UpdateGadgetPenumbraSize()
00508 
00509     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00510     Created:    19/11/96
00511     Inputs:     TRUE if several selected shadow => display "Many" in the InfoBar
00512     Outputs:    -
00513     Returns:    -
00514     Purpose:    Update the PenumbraSize field
00515 
00516 ********************************************************************************************/
00517 
00518 void SoftShadowInfoBarOp::UpdateGadgetPenumbraSize()
00519 {   
00520     
00521 }
00522 
00523 /********************************************************************************************
00524 
00525 >   void SoftShadowInfoBarOp::UpdateAllGadgets()
00526 
00527     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00528     Created:    05/12/96
00529     Inputs:     -
00530     Outputs:    -
00531     Returns:    - 
00532     Purpose:    Update all the gadgets
00533 
00534 ********************************************************************************************/
00535 
00536 void SoftShadowInfoBarOp::UpdateAllGadgets()
00537 {
00538     UpdateGadgetPositionShadowX();
00539     UpdateGadgetPositionShadowY();
00540     UpdateGadgetBlurSlider();
00541     UpdateGadgetTranspSlider();
00542     UpdateGadgetPenumbraSize();
00543     UpdateGadgetTypeButtons();
00544     UpdateGadgetHelp();
00545 }
00546 
00547 /********************************************************************************************
00548 
00549 >   void SoftShadowInfoBarOp::UpdateInfoBar()
00550 
00551     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00552     Created:    04/12/96
00553     Inputs:     -
00554     Outputs:    -
00555     Returns:    - 
00556     Purpose:    Update the InfoBar fields according to the selected shadow(s)
00557 
00558 ********************************************************************************************/
00559 
00560 void SoftShadowInfoBarOp::UpdateInfoBar()
00561 {
00562     BOOL bNothingSelected = (GetApplication()->FindSelection()->FindFirst()==NULL);
00563 
00564     // Update the InfoBar fields according the selection
00565     NodeShadowController* pMaster = NULL;
00566     pSoftShadowTool->GetShadowEditRange(&pMaster);
00567     if (pMaster==NULL)
00568     {
00569         UpdateAllGadgets();
00570 
00571         if (bNothingSelected)
00572             EnableGadgets(FALSE);
00573         else
00574         {
00575             // Grey all controls apart from the button
00576             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_EDIT_X),FALSE);
00577             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_EDIT_Y),FALSE);
00578             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_X_LESS) ,FALSE);
00579             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_X_MORE) ,FALSE);
00580             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_Y_LESS) ,FALSE);
00581             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_Y_MORE) ,FALSE);
00582             pSoftShadowInfoBar->EnableGadget(_R(IDC_BIASGAIN) ,FALSE);
00583             
00584             // the following are enabled anyway to enable users to set a blur &
00585             // create a shadow
00586             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWSLIDER) ,TRUE);
00587             pSoftShadowInfoBar->EnableGadget(_R(IDC_SHADOW_SLIDER_EDIT), TRUE);
00588 
00589             // same for the transparency
00590             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWTRANSPSLIDER), TRUE);
00591             pSoftShadowInfoBar->EnableGadget(_R(IDC_SHADOWTRANSP_EDIT), TRUE);      
00592         }
00593     }
00594     else 
00595     {
00596         // Retrieve all values (position, size, transparency) of the shadow from the object
00597         // and then set in the InfoData
00598 //      GetSetInfoBarValue(pSoftShadowTool->GetEditableShadowLevel()->pPPNode);
00599         UpdateAllGadgets();
00600         EnableGadgets(TRUE);
00601     }
00602 
00603     UpdateGadgetHelp();
00604 }
00605 
00606 
00607 /********************************************************************************************
00608 
00609 >   void SoftShadowInfoBarOp::DoChangeShadPos(INT32 x, INT32 y, BOOL PosX, BOOL PosY)
00610 
00611     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00612     Created:    18/12/96
00613     Inputs:     Whether to update the X or the Y (or both) variables
00614     Outputs:    -
00615     Returns:    - 
00616     Purpose:    Update the Doc and the view according to the new pos of the shadow
00617 
00618 ********************************************************************************************/
00619 
00620 void SoftShadowInfoBarOp::DoChangeShadPos(INT32 x, INT32 y, BOOL PosX, BOOL PosY)
00621 {
00622     ShadowPosition ShadPos(x, y, PosX, PosY, pSoftShadowTool);
00623 
00624     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SHADOWPOSITION);
00625     if (pOpDesc != NULL)
00626     {
00627         String_256 UIDesc;
00628         OpState State = OpShadowPosition::GetState(&UIDesc, pOpDesc);
00629         if (!State.Greyed)
00630             pOpDesc->Invoke(&ShadPos);
00631     }
00632 }
00633 
00634 
00635 /********************************************************************************************
00636 
00637 >   void SoftShadowInfoBarOp::EnableGadgets(BOOL Enable)
00638 
00639     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00640     Created:    18/11/96
00641     Inputs:     FALSE if all controls have to be greyed, TRUE if not
00642     Outputs:    -
00643     Returns:    -
00644     Purpose:    Called to enable or disable all controls in the InfoBar
00645     
00646 ********************************************************************************************/
00647 
00648 void SoftShadowInfoBarOp::EnableGadgets(BOOL Enable)
00649 {
00650     if(pSoftShadowInfoBar== NULL)
00651         return;
00652     if(!pSoftShadowInfoBar->HasWindow())
00653         return;
00654 
00655     if (!Enable)
00656     {
00657         pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_EDIT_X), FALSE);
00658         pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_EDIT_Y), FALSE);
00659         pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_X_LESS), FALSE);
00660         pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_X_MORE), FALSE);
00661         pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_Y_LESS), FALSE);
00662         pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_Y_MORE), FALSE);
00663         pSoftShadowInfoBar->EnableGadget(_R(IDC_BIASGAIN), FALSE);
00664 
00665         // set all the gadgets to not being selected
00666 //      pSoftShadowInfoBar->SetBoolGadgetSelected(_R(IDC_BTN_NOSHADOW), FALSE);
00667 //      pSoftShadowInfoBar->SetBoolGadgetSelected(_R(IDC_BTN_WALLSHADOW), FALSE);
00668 //      pSoftShadowInfoBar->SetBoolGadgetSelected(_R(IDC_BTN_FLOORSHADOW), FALSE);
00669 //      pSoftShadowInfoBar->SetBoolGadgetSelected(_R(IDC_BTN_GLOWSHADOW), FALSE);
00670     }
00671     else
00672     {
00673         NodeShadowController* pMaster = pSoftShadowTool->GetShadowEditField(smTYPE);
00674         ShadowType stype = SHADOWTYPE_NONE;
00675         if (pMaster)
00676             stype = pMaster->GetShadowType();
00677 
00678         pSoftShadowInfoBar->EnableGadget(_R(IDC_BIASGAIN), (stype != SHADOWTYPE_NONE));
00679         
00680         if (stype == SHADOWTYPE_NONE ||
00681             stype == SHADOWTYPE_FLOOR ||
00682             stype == SHADOWTYPE_GLOW)
00683         {
00684             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_EDIT_X), FALSE);
00685             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_EDIT_Y), FALSE);
00686             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_X_LESS), FALSE);
00687             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_X_MORE), FALSE);
00688             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_Y_LESS), FALSE);
00689             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_Y_MORE), FALSE);
00690 //          pSoftShadowInfoBar->EnableGadget(_R(IDC_BTN_NOSHADOW), TRUE);
00691         }
00692         else
00693         {
00694             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_EDIT_X), TRUE);
00695             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_EDIT_Y), TRUE);
00696             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_X_LESS), TRUE);
00697             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_X_MORE), TRUE);
00698             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_Y_LESS), TRUE);
00699             pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWCENTRE_Y_MORE), TRUE);
00700 //          pSoftShadowInfoBar->EnableGadget(_R(IDC_BIASGAIN), TRUE);
00701         }
00702     }
00703 
00704         
00705     pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWSLIDER) ,Enable);
00706     pSoftShadowInfoBar->EnableGadget(_R(IDC_SHADOW_SLIDER_EDIT) ,Enable);
00707     pSoftShadowInfoBar->EnableGadget(_R(IDC_SOFTSHADOWTRANSPSLIDER), Enable);
00708     pSoftShadowInfoBar->EnableGadget(_R(IDC_SHADOWTRANSP_EDIT), Enable);        
00709     
00710     pSoftShadowInfoBar->EnableGadget(_R(IDC_BTN_NOSHADOW), Enable);
00711     pSoftShadowInfoBar->EnableGadget(_R(IDC_BTN_WALLSHADOW), Enable);
00712     pSoftShadowInfoBar->EnableGadget(_R(IDC_BTN_FLOORSHADOW), Enable);
00713     pSoftShadowInfoBar->EnableGadget(_R(IDC_BTN_GLOWSHADOW), Enable);       
00714 
00715     UpdateGadgetHelp();
00716 }
00717 
00718 /********************************************************************************************
00719 
00720 >   void SoftShadowInfoBarOp::ChangeShadowPosIncremental(INT32 incx, INT32 incy)
00721 
00722     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00723     Created:    19/11/96
00724     Inputs:     -
00725     Outputs:    -
00726     Returns:    -
00727     Purpose:    find out the new value of PositionShadowX and update the control
00728     
00729 ********************************************************************************************/
00730 
00731 void SoftShadowInfoBarOp::ChangeShadowPosIncremental(INT32 incx, INT32 incy)
00732 {
00733     Document * pDoc = Document::GetCurrent();
00734     Spread * pSpread = Document::GetSelectedSpread();
00735     BlobManager * pBlobMgr = GetApplication()->GetBlobManager();
00736     DocRect BoundsToDraw;
00737     BOOL Valid = FALSE;
00738     MILLIPOINT x = 0;
00739     MILLIPOINT y = 0;
00740 
00741 //  String_256 Str = GetStringGadgetValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_X), &Valid);
00742 //  if (Str == ManyStr)
00743 //      incx = 0;
00744 //
00745 //  Str = GetStringGadgetValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_Y), &Valid);
00746 //  if (Str == ManyStr)
00747 //      incy = 0;
00748 //
00749     // This isn't strictly needed but makes the function consistent
00750     // with greying and DoChangeShadowPosIncremental.
00751     // It prevents the increments being applied to inconsistent shadows
00752     Valid = ConvertStringToValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_X), x);
00753     if (!Valid)
00754         incx = 0;
00755     Valid = ConvertStringToValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_Y), y);
00756     if (!Valid)
00757         incy = 0;
00758 
00759     if (incx==0 && incy==0)
00760         return;
00761 
00762     NodeShadowController* pMaster = NULL;
00763     ListRange* pEditRange = pSoftShadowTool->GetShadowEditRange(&pMaster);
00764     if (pEditRange)
00765     {
00766         Node* pNode = pEditRange->FindFirst();
00767         while (pNode)
00768         {
00769             ENSURE(pNode->IsAShadowController(), "Found unexpected node type in shadow stack level");
00770             NodeShadowController* pControl = (NodeShadowController*)pNode;
00771 //          NodeShadow * pShadow = pControl->GetShadow();
00772             pControl->ReleaseCached(TRUE, FALSE, FALSE, TRUE);
00773 
00774             if (pControl->GetShadowType() == SHADOWTYPE_WALL)
00775             {
00776                 BoundsToDraw = BoundsToDraw.Union(pControl->GetBoundingRect());
00777 
00778                 DocCoord offset = pControl->GetWallShadowOffset();
00779                 offset.x += incx;
00780                 offset.y += incy;
00781                 pControl->SetWallShadowOffset(offset, TRUE);
00782 
00783                 DocRect dr = pControl->GetInsideBoundingRect();
00784                 DocRect shadRect = dr;
00785                 
00786                 dr.lo.x += pControl->GetOffsetX();
00787                 dr.hi.x += pControl->GetOffsetX();
00788                 dr.lo.y += pControl->GetOffsetY();
00789                 dr.hi.y += pControl->GetOffsetY();
00790                 dr.Inflate(pControl->GetPenumbraWidth() + pBlobMgr->GetBlobSize());
00791                 
00792                 BoundsToDraw = BoundsToDraw.Union(dr);
00793                 BoundsToDraw = BoundsToDraw.Union(shadRect);
00794             }
00795 
00796             pNode = pEditRange->FindNext(pNode);
00797         }
00798 
00799         UpdateGadgetPositionShadowX();
00800         UpdateGadgetPositionShadowY();
00801 
00802         if (pDoc && pSpread && BoundsToDraw.IsValid() && !BoundsToDraw.IsEmpty())
00803         {
00804             pDoc->ForceRedraw(pSpread, BoundsToDraw);
00805             GetApplication()->ServiceRendering();           
00806         }
00807     }
00808 }
00809 
00810 
00811 /********************************************************************************************
00812 
00813 >   void SoftShadowInfoBarOp::DoChangeShadowPosIncremental(MILLIPOINT incx, MILLIPOINT incy)
00814 
00815     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00816     Created:    18/05/2005
00817     Inputs:     incx - the x increment
00818                 incy - the y increment
00819     Outputs:    -
00820     returns     -
00821     Purpose:    Undoably change the positions of the shadows in the current edit range
00822 
00823 *********************************************************************************************/
00824 
00825 void SoftShadowInfoBarOp::DoChangeShadowPosIncremental(MILLIPOINT incx, MILLIPOINT incy)
00826 {
00827     BOOL Valid = FALSE;
00828     MILLIPOINT x = 0;
00829     MILLIPOINT y = 0;
00830     String_256 ManyStr;
00831     ManyStr.Load(_R(IDS_SHADOWSTRING_MANY));
00832 
00833 //  String_256 Str = GetStringGadgetValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_X), &Valid);
00834 //  if (Str == ManyStr)
00835 //      incx = 0;
00836 //
00837 //  Str = GetStringGadgetValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_Y), &Valid);
00838 //  if (Str == ManyStr)
00839 //      incy = 0;
00840 //
00841     Valid = ConvertStringToValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_X), x);
00842     if (!Valid)
00843         incx = 0;
00844     Valid = ConvertStringToValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_Y), y);
00845     if (!Valid)
00846         incy = 0;
00847 
00848     if (incx==0 && incy==0)
00849         return;
00850 
00851     ShadowPosition ShadPos(x + incx, y + incy, incx!=0, incy!=0, pSoftShadowTool);
00852 
00853     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SHADOWPOSITION);
00854     if (pOpDesc != NULL)
00855     {
00856         String_256 UIDesc;
00857         OpState State = OpShadowPosition::GetState(&UIDesc, pOpDesc);
00858         if (!State.Greyed)
00859             pOpDesc->Invoke(&ShadPos);
00860     }
00861 
00862     UpdateGadgetPositionShadowX();
00863     UpdateGadgetPositionShadowY();
00864 }
00865 
00866 
00867 /********************************************************************************************
00868 
00869 >   virtual void SoftShadowInfoBarOp::HandleProfileSelChangingMsg(CBiasGainGadget& Gadget, CGadgetID ProfileGadgetID)
00870 
00871     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00872     Created:    19/1/2000
00873     Inputs:     CBiasGainGadget& and its GadgetID (for added safety)
00874     Outputs:    -
00875     Returns:    -
00876     Purpose:    Handles the updating/closing of the profile gadgets corrensponding profile
00877                 dialog when a SelChangingMsg is received.   Errors:     -
00878     SeeAlso:    InformationBarOp::GetProfileFromSelection()
00879 
00880 ********************************************************************************************/
00881 
00882 void SoftShadowInfoBarOp::HandleProfileSelChangingMsg(CBiasGainGadget& Gadget, CGadgetID GadgetID)
00883 {
00884 
00885     InformationBarOp::HandleProfileSelChangingMsg(Gadget, GadgetID);
00886     return;
00887 
00888 //  BOOL ok = (GadgetID == _R(IDC_BIASGAIN));
00889 
00890 //  ERROR2IF(ok==FALSE, FALSE, "Invalid gadgetID passed");
00891     
00892     BOOL bNone = TRUE;
00893     BOOL bConsistent = FALSE;
00894     BOOL bMany = FALSE;
00895     CProfileBiasGain* pProfile = NULL;
00896     NodeShadowController* pMasterProfile = pSoftShadowTool->GetShadowEditField(smBIASGAIN, &bNone, &bConsistent, &bMany);
00897 
00898     if (pMasterProfile)
00899     {
00900         NodeShadow* pShadow = pMasterProfile->GetShadow();
00901         ERROR3IF(pShadow==NULL, "GetProfileFromSelection");
00902 
00903         pProfile = pShadow->GetBiasGainPtr();
00904     }
00905 
00906     if (Gadget.IsDialogOpen())
00907     {
00908         if (bNone && !SelectorTool::GetNormalClick_CheckProfileDialog())
00909         {
00910             Gadget.CloseDialog();
00911             return;
00912         }
00913 
00914         Gadget.ReInitialiseDialog(pProfile, bMany);
00915         EnableGadget(GadgetID, FALSE);
00916     }
00917     else
00918     {
00919         EnableGadget(GadgetID, !bNone);
00920     }
00921 }
00922 
00923 
00924 /********************************************************************************************
00925 
00926 >   virtual CProfileBiasGain* SoftShadowInfoBarOp::GetProfileFromSelection(CGadgetID GadgetID, BOOL* bMany, BOOL* bAllSameType)
00927 
00928     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> Snook
00929     Created:    19/1/2000
00930     Inputs:     The GadgetID of the CBiasGainGadget that we are dealing with.
00931     Outputs:    bMany - returned as TRUE if we have MANY profiles selected.
00932                 bAllSameType - returned as TRUE if objects within selection are all of the
00933                 same type.
00934     returns     Ptr to common CProfileBiasGain, or NULL if there is NOT one.
00935     Purpose:    See InformationBarOp::GetProfileFromSelection () for a description of this
00936                 function.
00937 
00938 *********************************************************************************************/
00939 
00940 CProfileBiasGain* SoftShadowInfoBarOp::GetProfileFromSelection(CGadgetID GadgetID, BOOL* bMany, BOOL* bAllSameType)
00941 {
00942     BOOL ok = (GadgetID == _R(IDC_BIASGAIN));
00943 
00944     ERROR2IF(ok==FALSE, FALSE, "Invalid gadgetID passed");
00945     
00946     BOOL bProfileNone = TRUE;
00947     BOOL bProfileConsistent = FALSE;
00948     BOOL bProfileMany = FALSE;
00949     NodeShadowController* pMasterProfile = pSoftShadowTool->GetShadowEditField(smBIASGAIN, &bProfileNone, &bProfileConsistent, &bProfileMany);
00950 //  NodeShadowController* pMasterType = pSoftShadowTool->GetShadowEditField(smTYPE);
00951 
00952     *bMany = bProfileMany ;
00953     *bAllSameType = bProfileConsistent && !bProfileNone;
00954 
00955     if (pMasterProfile)
00956     {
00957         NodeShadow* pShadow = pMasterProfile->GetShadow();
00958         ERROR3IF(pShadow==NULL, "GetProfileFromSelection");
00959 
00960         return pShadow->GetBiasGainPtr();
00961     }
00962 
00963     return NULL;
00964 }
00965 
00966 
00967 /********************************************************************************************
00968 
00969 >   void SoftShadowInfoBarOp::DoPenumbraSizeBumps()
00970 
00971     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00972     Created:    19/11/96
00973     Inputs:     -
00974     Outputs:    -
00975     Returns:    -
00976     Purpose:    find out the new value of PenumbraSize and update the control
00977     
00978 ********************************************************************************************/
00979 
00980 void SoftShadowInfoBarOp::DoPenumbraSizeBumps(UINT32 Button)
00981 {
00982 }
00983 
00984 
00985 /********************************************************************************************
00986 
00987 >   MsgResult SoftShadowInfoBarOp::Message(Msg* Message) 
00988 
00989     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00990     Created:    29/10/96
00991     Inputs:     Message = The message to handle
00992     Outputs:    -
00993     Returns:    -
00994     Purpose:    Shadow Tool info bar dialog message handler
00995     Errors:     -
00996     SeeAlso:    -
00997 
00998 ********************************************************************************************/
00999 
01000 MsgResult SoftShadowInfoBarOp::Message(Msg* Message) 
01001 {
01002 
01003     if (!SoftShadowTool::IsCurrentTool() || !IsVisible())
01004         return (InformationBarOp::Message(Message));
01005 
01006 //  INT32 SliderType = 0;
01007 
01008     String_256 ManyStr;
01009     ManyStr.Load(_R(IDS_SHADOWSTRING_MANY));
01010 
01011     CProfileBiasGain Profile;
01012 //  BOOL bMany = FALSE;
01013 
01014     BOOL Valid = FALSE;
01015 //  INT32 Result = 0;
01016 //  double d = 0;
01017 
01018     if (IS_OUR_DIALOG_MSG(Message))
01019     {
01020         DialogMsg* Msg = (DialogMsg*)Message;
01021 
01022         // Check if the message is a CANCEL
01023         if (Msg->DlgMsg == DIM_CANCEL)
01024         {
01025             m_bControlsExist = FALSE;
01026 
01027             Close(); // Close the dialog 
01028         }
01029         else if (Msg->DlgMsg == DIM_CREATE)
01030         {
01031             SliderDragged = FALSE;
01032 
01033             // Initialise the infobar controls here
01034             Init();
01035 
01036             UpdateInfoBar();
01037 
01038             m_bControlsExist = TRUE;
01039         }
01040         else
01041         {
01042             // Note: Can't use switch because of the nature of _R()
01043 
01044             // Position (X and Y) of centre of shadow
01045             // First handle the edit field of position X then position Y
01046             if (Msg->GadgetID == _R(IDC_SOFTSHADOWCENTRE_EDIT_X) || Msg->GadgetID == _R(IDC_SOFTSHADOWCENTRE_EDIT_Y))
01047             {
01048                 if (Msg->DlgMsg == DIM_SELECTION_CHANGED)   // A user has typed in something
01049                 {
01050                     BOOL Valid = FALSE;
01051                     String_256 Str = GetStringGadgetValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_X),&Valid);
01052 
01053                     INT32 PosShadowX = 0;
01054                     // Parse the edit field string and then convert the value
01055                     // Return true or false
01056                     Valid = ConvertStringToValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_X),PosShadowX);
01057 
01058                     if (Str != ManyStr)
01059                     {
01060 
01061                         if(Valid)   // Ok, we can set the internal value and then update
01062                         {
01063                             // Update and apply the new value to the object in the view and in the doc
01064                             DoChangeShadPos(PosShadowX, 0, TRUE, FALSE);
01065                         }
01066                         else
01067                         {
01068                             // Error message
01069                             DoInputError(Msg->GadgetID);
01070                             UpdateGadgetPositionShadowX();
01071                         }
01072                     }
01073 
01074                     // Now deal with the position Y of the centre of the shadow
01075 
01076                     Str = GetStringGadgetValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_Y),&Valid);
01077                     INT32 PosShadowY = 0;
01078 
01079                     // Parse the edit field string and then convert the value
01080                     // Return true or false
01081                     if (Str != ManyStr)
01082                     {
01083                         Valid = ConvertStringToValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_Y),PosShadowY);
01084 
01085                         if(Valid)   // Ok, we can set the internal value and then update
01086                         {
01087                             // Update and apply the new value to the object in the view and in the doc
01088                             DoChangeShadPos(0, PosShadowY, FALSE, TRUE);
01089                         }
01090                         else
01091                         {
01092                             // Error message
01093                             DoInputError(Msg->GadgetID);
01094                             UpdateGadgetPositionShadowY();
01095                         }
01096                     }
01097                 }
01098             }
01099 
01100             else if (Msg->GadgetID == _R(IDC_BIASGAIN))
01101             {
01102                 switch (Msg->DlgMsg)
01103                 {
01104                     case DIM_LFT_BN_CLICKED:
01105                         HandleProfileButtonClick (BiasGainGadget_m, _R(IDC_BIASGAIN));
01106                         break;
01107                     
01108                     default:
01109                         ProfileSelectionChange( Msg, Msg->GadgetID );
01110                     break;
01111                 }
01112             }
01113 
01114             else if (Msg->GadgetID == _R(IDC_SOFTSHADOWCENTRE_Y_LESS))
01115                 HandleShadowPosBump(Msg, 0, -Document::GetCurrent()->GetDocNudge());
01116 
01117             else if (Msg->GadgetID == _R(IDC_SOFTSHADOWCENTRE_Y_MORE))
01118                 HandleShadowPosBump(Msg, 0, Document::GetCurrent()->GetDocNudge());
01119 
01120             else if (Msg->GadgetID == _R(IDC_SOFTSHADOWCENTRE_X_LESS))
01121                 HandleShadowPosBump(Msg, -Document::GetCurrent()->GetDocNudge(), 0);
01122 
01123             else if (Msg->GadgetID == _R(IDC_SOFTSHADOWCENTRE_X_MORE))
01124                 HandleShadowPosBump(Msg, Document::GetCurrent()->GetDocNudge(), 0);
01125 
01127                 // the transparency slider
01128             else if (Msg->GadgetID == _R(IDC_SOFTSHADOWTRANSPSLIDER))
01129             {
01130                 switch (Msg->DlgMsg)
01131                 {
01132                     case DIM_SLIDER_POS_CHANGING:
01133                     {
01134                         if (!SliderDragged)
01135                         {
01136                             SaveShadowDragData(&ShadowDataList);
01137                             Operation::SetQuickRender(TRUE);
01138                         }
01139 
01140                         Valid = FALSE;
01141                         double dDarkness = GetDarknessSlider(&Valid);
01142                         SetDarknessEditGadget(dDarkness);
01143 
01144                         ChangeShadowDarkness(dDarkness);
01145 
01146                         PaintGadgetNow(_R(IDC_SHADOWTRANSP_EDIT));
01147                         SliderDragged = TRUE;
01148                     }
01149                     break;
01150 
01151                     case DIM_SLIDER_POS_SET:
01152                     {
01153                         Operation::SetQuickRender(FALSE);
01154 
01155                         // restore the original values
01156                         RestoreShadowDragData(&ShadowDataList, FALSE);
01157 
01158                         // Find the current scrollers position
01159                         SliderDragged = FALSE;
01160                         double dDarkness = GetDarknessSlider(&Valid);
01161                         SetDarknessEditGadget(dDarkness);
01162 
01163                         DoChangeShadowDarkness(dDarkness);
01164 
01165                         SliderDragged = FALSE;
01166 
01167                         SetBitmapUpdate(TRUE);
01168                     }
01169                     break;
01170 
01171                     default:
01172                     {
01173                         // Do nothing
01174                         break;
01175                     }
01176                 }
01177             }
01178 
01180                 // The shadow tool slider
01181             else if (Msg->GadgetID == _R(IDC_SOFTSHADOWSLIDER))
01182             {
01183                 switch (Msg->DlgMsg)
01184                 {
01185                     case DIM_SLIDER_POS_CHANGING:
01186                     {
01187                         if (!SliderDragged)
01188                         {
01189                             SaveShadowDragData(&ShadowDataList);
01190                             Operation::SetQuickRender(TRUE);
01191                         }
01192 
01193                         SetBitmapUpdate(FALSE);
01194 
01195                         // Find the current scrollers position
01196                         BOOL Valid = FALSE;
01197                         INT32 Result = GetLongGadgetValue(_R(IDC_SOFTSHADOWSLIDER), 0, CONTRASTSLIDERMAX, 0, &Valid);
01198 
01199                         NodeShadowController* pMaster = NULL;
01200                         pSoftShadowTool->GetShadowEditRange(&pMaster);
01201                         if (pMaster!=NULL)
01202                         {
01203                             ChangeShadowPenumbra((MILLIPOINT)((((double)(/*100 - */Result)) / 100.0) * ((double)BLURSLIDERMAX)));
01204 
01205                             UpdateGadgetBlurSlider(FALSE);
01206                         }
01207 
01208                         PaintGadgetNow(_R(IDC_SHADOW_SLIDER_EDIT));
01209 
01210                         SliderDragged = TRUE;
01211 
01212                         break;
01213                     }
01214 
01215                     case DIM_SLIDER_POS_SET:
01216                     {
01217                         Operation::SetQuickRender(FALSE);
01218 
01219                         // restore the original values
01220                         RestoreShadowDragData(&ShadowDataList, FALSE);
01221 
01222                         // Find the current scrollers position
01223                         BOOL Valid;
01224                         SliderDragged = FALSE;
01225                         INT32 Result = GetLongGadgetValue(_R(IDC_SOFTSHADOWSLIDER), 0, CONTRASTSLIDERMAX, 0, &Valid);
01226 
01227                         DoChangePenumbra((MILLIPOINT)((((double)(/*100 - */Result)) / 100.0) * ((double)BLURSLIDERMAX)));
01228                         SliderDragged = FALSE;
01229 
01230                         SetBitmapUpdate(TRUE);
01231                         break;
01232                     }
01233 
01234                     default:
01235                     {
01236                         // Do nothing
01237                         break;
01238                     }
01239                 }
01240             }
01241 
01242             else if (Msg->GadgetID == _R(IDC_SHADOW_SLIDER_EDIT))
01243             {
01244                 if (Msg->DlgMsg == DIM_SELECTION_CHANGED)
01245                 {
01246                     // handle the edit control changing
01247                     HandleSliderEditChange();
01248                 }
01249             }
01250             else if (Msg->GadgetID == _R(IDC_SHADOWTRANSP_EDIT))
01251             {
01252                 if (Msg->DlgMsg == DIM_SELECTION_CHANGED)
01253                 {
01254                     // handle the edit control changing
01255                     HandleSliderTranspEditChange();
01256                 }
01257             }
01258             else if (Msg->GadgetID == _R(IDC_BTN_NOSHADOW))
01259             {
01260                 if (Msg->DlgMsg == DIM_LFT_BN_CLICKED)
01261                 {
01262                     HandleNoShadowBtnClicked();
01263                     return OK;
01264                 }
01265             }
01266             else if (Msg->GadgetID == _R(IDC_BTN_WALLSHADOW))
01267             {
01268                 if (Msg->DlgMsg == DIM_LFT_BN_CLICKED)
01269                 {
01270                     HandleWallShadowBtnClicked();
01271                     return OK;
01272                 }
01273             }
01274             else if (Msg->GadgetID == _R(IDC_BTN_FLOORSHADOW))
01275             {
01276                 if (Msg->DlgMsg == DIM_LFT_BN_CLICKED)
01277                 {
01278                     HandleFloorShadowBtnClicked();
01279                     return OK;
01280                 }
01281             }
01282             else if (Msg->GadgetID == _R(IDC_BTN_GLOWSHADOW))
01283             {
01284                 if (Msg->DlgMsg == DIM_LFT_BN_CLICKED)
01285                 {
01286                     HandleGlowShadowBtnClicked();
01287                     return OK;
01288                 }
01289             }
01290         }
01291     }
01292 
01293     else if (MESSAGE_IS_A(Message,OpMsg))   // Check for undo/redo
01294     {
01295         if ( (((OpMsg*)Message)->MsgType == OpMsg::AFTER_UNDO) ||
01296                                         (((OpMsg*)Message)->MsgType == OpMsg::AFTER_REDO) )
01297         {
01298             if (pSoftShadowInfoBar != NULL)
01299             {
01300 //              if (pSoftShadowTool != NULL)
01301 //                  pSoftShadowTool->SelectionHasChanged();
01302 
01303                 // update the gadgets
01304                 UpdateInfoBar();
01305 
01306             }
01307         }
01308     }
01309     // Does this message mean that the selected object has changed?
01310     else if (MESSAGE_IS_A(Message, SelChangingMsg))
01311     {
01312         // Is it the current tool ?
01313         if (pSoftShadowInfoBar==NULL || !pSoftShadowInfoBar->HasWindow())
01314             return InformationBarOp::Message(Message);
01315 
01316         // Selection has changed so we must update our ideas about the
01317         // selected shadow range here (before profile dialog is updated)
01318         pSoftShadowTool->SetShadowEditRangeFromSelection(FALSE);
01319 
01320         // Tell the tool
01321 //      if (pSoftShadowTool != NULL)
01322 //          pSoftShadowTool->SelectionHasChanged();
01323 
01324         HandleProfileSelChangingMsg(BiasGainGadget_m, _R(IDC_BIASGAIN));
01325 
01326         if (SliderDragged)
01327         {
01328             // this means that the selection has changed inside of a drag
01329             // therefore, restore the original values to the selection
01330             RestoreShadowDragData(&ShadowDataList, TRUE);
01331             SliderDragged = FALSE;
01332         }                           
01333 
01334         // Enable gadget according the selection
01335         Range Sel(*(GetApplication()->FindSelection()));
01336         RangeControl rg = Sel.GetRangeControlFlags();
01337         rg.PromoteToParent = TRUE;
01338         Sel.SetRangeControl(rg);
01339     
01340         UINT32 NumSelected = Sel.Count();
01341 
01342         // Nothing selected
01343         if(NumSelected == 0)
01344             EnableGadgets(FALSE);
01345         else
01346         {
01347             EnableGadgets(TRUE);
01348 
01349             // The user may have clicked on a shadow, so we must attempt to set up
01350             // valid m_pEditRange from the selection here before
01351             // UpdateInfobar decides that it must find a TopClassRange
01352 //          if (pSoftShadowTool)
01353 //              pSoftShadowTool->SetShadowEditRangeFromSelection();
01354         }
01355 
01356         // Update the InfoBar
01357         UpdateInfoBar();
01358     }
01359     else if(MESSAGE_IS_A(Message,OptionsChangingMsg))
01360     {
01361 
01362         OptionsChangingMsg* Msg = (OptionsChangingMsg*)Message;
01363 
01364         if(Msg->State == OptionsChangingMsg::NEWUNITS)
01365         {
01366             pDoc = Document::GetSelected();
01367             
01368             // update all controls
01369             UpdateInfoBar();
01370         }
01371     }
01372     
01373     // Pass the message on to the immediate blank class
01374     return (InformationBarOp::Message(Message));
01375 }    
01376 
01377 void SoftShadowInfoBarOp::HandleShadowPosBump(DialogMsg* dmsg, INT32 incx, INT32 incy)
01378 {
01379     switch (dmsg->DlgMsg)
01380     {
01381         case DIM_LFT_BN_CLICKED:
01382         {
01383             if (!m_bBumping)
01384             {
01385                 Operation::SetQuickRender(TRUE);        // Prevent recacheing while the button is held down
01386                 SaveShadowDragData(&ShadowDataList);
01387                 m_bBumping = TRUE;
01388             }
01389 
01390             ChangeShadowPosIncremental(incx, incy);     // Non-undoable
01391 
01392         }
01393         break;
01394 
01395         case DIM_LFT_BN_UP:
01396         {
01397             Operation::SetQuickRender(FALSE);           // Re-enable cacheing
01398 
01399             //Update the view and the document
01400             if (m_bBumping)
01401             {
01402                 RestoreShadowDragData(&ShadowDataList);
01403                 m_bBumping = FALSE;
01404             }
01405 
01406             DoChangeShadowPosIncremental(incx, incy);   // Undoable
01407 
01408 //          if (pSoftShadowTool)
01409 //              pSoftShadowTool->SelectionHasChanged();                         
01410         }
01411         break;
01412 
01413         default:
01414         {
01415             // Do nothing
01416         }
01417         break;
01418     }
01419 }
01420 
01421 
01422 
01423 /********************************************************************************************
01424 
01425 >   void SoftShadowInfoBarOp::ChangeProfile(CProfileBiasGain* Profile, CGadgetID GadgetID)
01426 
01427     Author:     Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> Snook
01428     Created:    17/9/99
01429     Purpose:    See InformationBarOp::ChangeProfile () for an explanation of this function.
01430     See Also:   InformationBarOp::ChangeProfile ()
01431 
01432 *********************************************************************************************/
01433 
01434 void SoftShadowInfoBarOp::ChangeProfile(CProfileBiasGain* Profile, CGadgetID GadgetID)
01435 {
01436     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SHADOWPROFILE);
01437     if (pOpDesc != NULL)
01438     {
01439         BOOL FireOp = TRUE;
01440 
01441         // we only want to generate one bit of undo information - so decided whether
01442         // we have to fire the above op, or whether we just 'pump' the values into
01443         // our nodes (thereby nolonger generating infinite undo information) ....
01444 
01445         Operation* pLastOp = NULL;
01446 
01447         if (Profile->GetGeneratesInfiniteUndo ())   // only do if they didn't select a preset profile
01448         {
01449             pLastOp = Document::GetSelected()->GetOpHistory().FindLastOp();
01450         }
01451 
01452         if (pLastOp)
01453         {
01454             if (pLastOp->GetRuntimeClass() == CC_RUNTIME_CLASS(OpChangeShadowProfile))
01455             {
01456                 FireOp = FALSE;
01457             }
01458         }
01459 
01460         if (FireOp == TRUE)
01461         {
01462             ShadowProfileOpParam Param(*Profile, pSoftShadowTool);
01463 //          Param.Profile = *Profile;
01464         
01465             pOpDesc->Invoke(&Param);
01466         }
01467         else
01468         {
01469             // we don't need/want any undo information - so just change the value ....
01470 
01471             ChangeProfileAction Action;
01472             Action.ChangeShadowProfileWithNoUndo(*Profile, pSoftShadowTool);
01473         }
01474     }
01475 }
01476 
01477 /********************************************************************************************
01478 
01479 >   void SoftShadowInfoBarOp::DoInputError(UINT32 GadgetID) 
01480 
01481     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
01482     Created:    28/11/96
01483     Inputs:     Gadget ID
01484     Outputs:    -
01485     Returns:    -
01486     Purpose:    Make the error string and then display a window
01487     Errors:     -
01488     SeeAlso:    -
01489 
01490 ********************************************************************************************/
01491 
01492 void SoftShadowInfoBarOp::DoInputError(UINT32 GadgetID) 
01493 {
01494     String_256 sErrString;
01495     String_64 sWarnString(_R(IDS_INVALID_INPUT));
01496     String_8 sAndString(_R(IDS_AND));
01497     String_16 sMaxStr(_T("0"));
01498     String_16 sMinStr(_T("0"));
01499 
01500     if (GadgetID == _R(IDC_SOFTSHADOWCENTRE_EDIT_X))
01501     {
01502         sMinStr._MakeMsg(TEXT("#1%dpix"),-PositionShadowLimit);
01503         sMaxStr._MakeMsg(TEXT("#1%dpix"),PositionShadowLimit);
01504     }
01505 
01506     else if (GadgetID == _R(IDC_SOFTSHADOWCENTRE_EDIT_Y))
01507     {
01508         sMinStr._MakeMsg(TEXT("#1%dpix"),-PositionShadowLimit);
01509         sMaxStr._MakeMsg(TEXT("#1%dpix"),PositionShadowLimit);
01510     }
01511 
01512     else if (GadgetID == _R(IDC_PENUMBRASIZE_EDIT))
01513     {
01514         sMinStr._MakeMsg(TEXT("#1%dpix"),0);
01515         sMaxStr._MakeMsg(TEXT("#1%dpix"),PenumbraSizeLimit);
01516     }
01517 
01518     else
01519         return;
01520     
01521     sErrString._MakeMsg(TEXT("#1%s #2%s #3%s #4%s \n"),
01522                                         (TCHAR*)sWarnString,
01523                                         (TCHAR*)sMinStr,
01524                                         (TCHAR*)sAndString,
01525                                         (TCHAR*)sMaxStr); 
01526             
01527     Error::SetError(0,(TCHAR* )sErrString,0);
01528     InformError();
01529 }
01530 
01531 
01532 /********************************************************************************************
01533 
01534 >   void SoftShadowInfoBarOp::DoChangeShadowDarkness(double dDarkness)
01535 
01536     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
01537     Created:    11/12/96
01538     Purpose:    Called when a the transparency slider is changed.
01539 
01540 ********************************************************************************************/
01541 
01542 void SoftShadowInfoBarOp::DoChangeShadowDarkness(double dDarkness)
01543 {
01544     // invoke the op
01545     OpDescriptor* pOpDesc = NULL;
01546 
01547     NodeShadowController* pMaster = NULL;
01548     pSoftShadowTool->GetShadowEditRange(&pMaster);
01549     if (pMaster==NULL)
01550     {
01551         // if there's no shadow - create one !!
01552         NodeShadowParam Param;
01553         Param.m_dDarkness = dDarkness;
01554         Param.StackPosition = STACKPOS_INSERT_TOP;
01555         Param.pPPStack = GetApplication()->FindSelection()->GetEffectsStack(TRUE);  // Get a copy while the sel changes
01556         Param.pShadowTool = pSoftShadowTool;
01557 
01558         pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_APPLYSHADOW);
01559 
01560         if (pOpDesc)
01561         {
01562             pOpDesc->Invoke(&Param);
01563         }
01564 
01565         delete Param.pPPStack;
01566 
01567         return;     
01568     }
01569 
01570     pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SHADOWDARKNESS);
01571 
01572     ShadowDarknessOpParam Param(dDarkness, pSoftShadowTool);
01573 
01574     if (pOpDesc != NULL)
01575     {
01576         pOpDesc->Invoke(&Param);
01577     }
01578 }
01579 
01580 /********************************************************************************************
01581 
01582 >   void SoftShadowInfoBarOp::SetBitmapUpdate(BOOL OnOrOff)
01583 
01584     Author:     Mark_Howitt (Xara Group Ltd) <camelotdev@xara.com>
01585     Created:    22/10/98
01586     Purpose:    Turns the bitmap generation process on or off for shadows.
01587 
01588 ********************************************************************************************/
01589 
01590 void SoftShadowInfoBarOp::SetBitmapUpdate(BOOL OnOrOff)
01591 {
01592     Range Sel(*(GetApplication()->FindSelection()));
01593     RangeControl rg = Sel.GetRangeControlFlags();
01594     rg.PromoteToParent = TRUE;
01595     Sel.SetRangeControl(rg);
01596 
01597     // if (pSel != NULL)
01598     {
01599         Node* pNode = Sel.FindFirst();
01600         while (pNode != NULL)
01601         {
01602             if(IS_A(pNode,NodeShadowController))
01603             {
01604                 NodeShadow* pShadow = ((NodeShadowController*)pNode)->GetShadow();
01605                 pShadow->SetBitmapShadowRendering(OnOrOff);
01606             }
01607             pNode = Sel.FindNext(pNode);
01608         }
01609     }
01610 }
01611 
01612 
01613 /********************************************************************************************
01614 
01615 >   void SoftShadowInfoBarOp::UpdateGadgetHelp()
01616 
01617     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> Mc
01618     Created:    10/5/99
01619     Inputs:     
01620     Outputs:    -
01621     Returns:    - 
01622     Purpose:    Update the combos
01623 
01624 ********************************************************************************************/
01625 void SoftShadowInfoBarOp::UpdateGadgetHelp()
01626 {
01627     // do the bubble helps
01628     SetGadgetHelp(_R(IDC_SOFTSHADOWSLIDER), _R(IDBBL_SHADOWSLIDERBLUR), _R(IDS_SHADOWSLIDERBLURID));
01629     SetGadgetHelp(_R(IDC_SHADOW_SLIDER_EDIT), _R(IDBBL_SHADOWSLIDERBLUR), _R(IDS_SHADOWSLIDERBLURID));
01630 }
01631 
01632 /********************************************************************************************
01633 
01634 >   void SoftShadowInfoBarOp::DoChangePenumbra(UINT32 NewPenumbra)
01635 
01636     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> Mc
01637     Created:    10/5/99
01638     Inputs:     The new penumbra
01639     Outputs:    -
01640     Returns:    - 
01641     Purpose:    Change the penumbra size
01642 
01643 ********************************************************************************************/
01644 void SoftShadowInfoBarOp::DoChangePenumbra(INT32 NewPenumbra)
01645 {
01646     OpDescriptor* pOpDesc = NULL;
01647     
01648     // if there's no shadow in the selection, then create one !
01649     NodeShadowController* pMaster = NULL;
01650     pSoftShadowTool->GetShadowEditRange(&pMaster);
01651     if (pMaster==NULL)
01652     {
01653         NodeShadowParam Param;
01654         Param.m_Blur = NewPenumbra;
01655         Param.StackPosition = STACKPOS_INSERT_TOP;
01656         Param.pPPStack = GetApplication()->FindSelection()->GetEffectsStack(TRUE);  // Get a copy while the sel changes
01657         Param.pShadowTool = pSoftShadowTool;
01658 
01659         pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_APPLYSHADOW);
01660 
01661         if (pOpDesc)
01662         {
01663             pOpDesc->Invoke(&Param);
01664         }
01665 
01666         delete Param.pPPStack;
01667 
01668         return;
01669     }       
01670     
01671     ShadowPenumbra Param(NewPenumbra, pSoftShadowTool);
01672 
01673     pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SHADOWPENUMBRA);
01674     
01675     if (pOpDesc != NULL)
01676     {
01677         pOpDesc->Invoke(&Param);
01678     }
01679 
01680 //  if (pSoftShadowTool)
01681 //      pSoftShadowTool->SelectionHasChanged();
01682 }
01683 
01684 /********************************************************************************************
01685 
01686 >   void SoftShadowInfoBarOp::DoChangeWidth(UINT32 NewWidth)
01687 
01688     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> Mc
01689     Created:    10/5/99
01690     Inputs:     The new width
01691     Outputs:    -
01692     Returns:    - 
01693     Purpose:    Change the glow width
01694 
01695 ********************************************************************************************/
01696 void SoftShadowInfoBarOp::DoChangeWidth(INT32 NewWidth)
01697 {
01698     NodeShadowParam Param;
01699     Param.m_GlowWidth = NewWidth;
01700     Param.pShadowTool = pSoftShadowTool;
01701 
01702     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_GLOWWIDTH);
01703     
01704     if (pOpDesc != NULL)
01705     {
01706         pOpDesc->Invoke(&Param);
01707     }
01708 
01709 //  if (pSoftShadowTool)
01710 //      pSoftShadowTool->SelectionHasChanged();
01711 }
01712 
01713 /********************************************************************************************
01714 
01715 >   void SoftShadowInfoBarOp::HandleSliderEditChange()
01716 
01717     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> Mc
01718     Created:    10/5/99
01719     Inputs:     
01720     Outputs:    -
01721     Returns:    - 
01722     Purpose:    Edit control change for the slider
01723 
01724 ********************************************************************************************/
01725 void SoftShadowInfoBarOp::HandleSliderEditChange()
01726 {
01727     // first, get the value out of the edit box
01728     double Value = 0;
01729 //  double d = 0;
01730     String_256 FieldContents;
01731     String_256 NumberString;
01732     BOOL Valid = FALSE;
01733 //  BOOL bNegative = FALSE;
01734 //  INT32 Start = 0;
01735     INT32 KValue = 0;
01736 
01737     String_256 ManyString;
01738     ManyString.Load(_R(IDS_SHADOWSTRING_MANY));
01739 
01740     FieldContents = GetStringGadgetValue(_R(IDC_SHADOW_SLIDER_EDIT), &Valid);
01741 
01742 //  BOOL bValid = FALSE;
01743 
01744     // check for a many in the box
01745     BOOL bMany = FALSE;
01746 
01747     if (FieldContents == ManyString)
01748     {
01749         bMany = TRUE;
01750     }
01751 
01752     // this is the blur, so it's ok to go ahead
01753     if (ConvertStringToValue(_R(IDC_SHADOW_SLIDER_EDIT), KValue) && !bMany)
01754     {
01755         Value = KValue;
01756         if (Value >= 0 && Value <= BLURSLIDERMAX)
01757         {
01758             DoChangePenumbra((INT32)Value);
01759         }
01760     }
01761 
01762     UpdateInfoBar();
01763     
01764     // redraw all the blobs
01765 //  if (pSoftShadowTool)
01766 //  {
01767 //      pSoftShadowTool->SelectionHasChanged();
01768 //  }
01769 }
01770 
01771 /********************************************************************************************
01772 
01773 >   void SoftShadowInfoBarOp::HandleSliderTranspEditChange()
01774 
01775     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> Mc
01776     Created:    10/5/99
01777     Inputs:     
01778     Outputs:    -
01779     Returns:    - 
01780     Purpose:    Edit control change for the transparency slider
01781 
01782 ********************************************************************************************/
01783 void SoftShadowInfoBarOp::HandleSliderTranspEditChange()
01784 {
01785     // get the value out of the edit box
01786     BOOL bOK = FALSE;
01787     BOOL bMany = FALSE;
01788     double dDarkness = 0;
01789 
01790     bOK = GetDarknessEditGadget(dDarkness, bMany);
01791     if (!bOK || bMany)
01792     {
01793         UpdateGadgetTranspSlider(FALSE);
01794         return;
01795     }
01796 
01797     // ok, let's do the transparency change
01798     DoChangeShadowDarkness(dDarkness);
01799     UpdateInfoBar();
01800 }
01801 
01802 /********************************************************************************************
01803 
01804 >   void SoftShadowInfoBarOp::DoChangeAngle(double Angle)
01805 
01806     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> Mc
01807     Created:    10/5/99
01808     Inputs:     The angle
01809     Outputs:    -
01810     Returns:    - 
01811     Purpose:    Sets the angle for the selection
01812 
01813 ********************************************************************************************/
01814 void SoftShadowInfoBarOp::DoChangeAngle(double Angle)
01815 {
01816     NodeShadowParam Param;
01817     Param.m_FloorShadowAngle = Angle;
01818     Param.pShadowTool = pSoftShadowTool;
01819     
01820     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SHADOWANGLE);
01821     
01822     if (pOpDesc != NULL)
01823     {
01824         pOpDesc->Invoke(&Param);
01825     }
01826 
01827 //  if (pSoftShadowTool)
01828 //      pSoftShadowTool->SelectionHasChanged();
01829 }
01830 
01831 /********************************************************************************************
01832 
01833 >   void SoftShadowInfoBarOp::DoChangeHeight(double Height)
01834 
01835     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> Mc
01836     Created:    10/5/99
01837     Inputs:     The new height
01838     Outputs:    -
01839     Returns:    - 
01840     Purpose:    Sets the angle for the selection
01841 
01842 ********************************************************************************************/
01843 void SoftShadowInfoBarOp::DoChangeHeight(double Height)
01844 {
01845     NodeShadowParam Param;
01846     Param.m_FloorShadowHeight = Height;
01847     Param.pShadowTool = pSoftShadowTool;
01848     
01849     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SHADOWHEIGHT);
01850     
01851     if (pOpDesc != NULL)
01852     {
01853         pOpDesc->Invoke(&Param);
01854     }
01855 
01856 //  if (pSoftShadowTool)
01857 //      pSoftShadowTool->SelectionHasChanged();
01858 }
01859 
01860 /********************************************************************************************
01861 
01862 >   void SoftShadowInfoBarOp::DoChangeScale(double Scale)
01863 
01864     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> Mc
01865     Created:    10/5/99
01866     Inputs:     The new scale
01867     Outputs:    -
01868     Returns:    - 
01869     Purpose:    Sets the shadow scale for the selection
01870 
01871 ********************************************************************************************/
01872 void SoftShadowInfoBarOp::DoChangeScale(double Scale)
01873 {
01874     NodeShadowParam Param;
01875     Param.m_Scale = Scale;
01876     Param.pShadowTool = pSoftShadowTool;
01877     
01878     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SHADOWSCALE);
01879     
01880     if (pOpDesc != NULL)
01881     {
01882         pOpDesc->Invoke(&Param);
01883     }
01884 
01885 //  if (pSoftShadowTool)
01886 //      pSoftShadowTool->SelectionHasChanged();
01887 }
01888 
01889 
01890 
01891 /********************************************************************************************
01892 
01893 >   void SoftShadowInfoBarOp::ChangeShadowDarkness(double dDarkness)
01894 
01895     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01896     Created:    17/05/2005
01897     Inputs:     -
01898     Outputs:    -
01899     Returns:    - 
01900     Purpose:    Directly sets transparency value into the selected shadows
01901 
01902 ********************************************************************************************/
01903 void SoftShadowInfoBarOp::ChangeShadowDarkness(double dDarkness)
01904 {
01905     if (ShadowDataList.IsEmpty())
01906     {
01907         return;
01908     }
01909 
01910     ShadowDragData* pItem = (ShadowDragData*)ShadowDataList.GetHead();
01911     
01912     NodeShadowController* pControl = NULL;
01913     NodeShadow* pShadow = NULL;
01914 
01915     Document* pDoc = Document::GetCurrent();
01916 
01917     DocRect BoundsToDraw;
01918 
01919     Spread* pSpread = NULL;
01920 
01921     while (pItem)
01922     {
01923         pControl = (NodeShadowController *)pItem->pNode;
01924         pShadow = pControl->GetShadow();
01925         pControl->ReleaseCached(TRUE, FALSE, FALSE, TRUE);  // Parents and derived data only
01926 
01927         pSpread = pControl->FindParentSpread(); 
01928         BoundsToDraw = BoundsToDraw.Union(pControl->GetBlobBoundingRect());
01929         
01930         pShadow->SetDarkness(dDarkness);
01931 
01932         // force a redraw
01933         pControl->InvalidateBoundingRect();
01934 
01935         // we MUST regenerate in this case ....
01936         if (IS_A (pControl->FindParent (), NodeBlend))
01937         {
01938             pControl->RegenerateNode(NULL);
01939         }
01940 
01941         BoundsToDraw = BoundsToDraw.Union(pControl->GetBlobBoundingRect());
01942         
01943         pItem = (ShadowDragData*)ShadowDataList.GetNext(pItem);
01944     }
01945 
01946     if (pDoc)
01947         pDoc->ForceRedraw(pSpread, BoundsToDraw, FALSE);
01948     GetApplication()->ServiceRendering();
01949 }
01950 
01951 
01952 
01953 
01954 /********************************************************************************************
01955 
01956 >   void SoftShadowInfoBarOp::ChangeShadowPenumbra(INT32 nBlur)
01957 
01958     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01959     Created:    17/05/2005
01960     Inputs:     -
01961     Outputs:    -
01962     Returns:    - 
01963     Purpose:    Directly sets transparency value into the selected shadows
01964 
01965 ********************************************************************************************/
01966 void SoftShadowInfoBarOp::ChangeShadowPenumbra(INT32 nBlur)
01967 {
01968     if (ShadowDataList.IsEmpty())
01969     {
01970         return;
01971     }
01972 
01973     ShadowDragData* pItem = (ShadowDragData*)ShadowDataList.GetHead();
01974     
01975     NodeShadowController* pControl = NULL;
01976     NodeShadow* pShadow = NULL;
01977 
01978     Document* pDoc = Document::GetCurrent();
01979 
01980     DocRect BoundsToDraw;
01981 
01982     Spread* pSpread = NULL;
01983 
01984     while (pItem)
01985     {
01986         pControl = (NodeShadowController *)pItem->pNode;
01987         pShadow = pControl->GetShadow();
01988         pControl->ReleaseCached(TRUE, FALSE, FALSE, TRUE);  // Parents and derived data only
01989 
01990         pSpread = pControl->FindParentSpread(); 
01991         BoundsToDraw = BoundsToDraw.Union(pControl->GetBlobBoundingRect());
01992         
01993         pControl->SetPenumbraWidth(nBlur);
01994 
01995         // force a redraw
01996         pControl->InvalidateBoundingRect();
01997 
01998         pControl->RegenerateNode(NULL);
01999 
02000         BoundsToDraw = BoundsToDraw.Union(pControl->GetBlobBoundingRect());
02001         
02002         pItem = (ShadowDragData*)ShadowDataList.GetNext(pItem);
02003     }
02004 
02005     if (pDoc)
02006         pDoc->ForceRedraw(pSpread, BoundsToDraw, FALSE);
02007     GetApplication()->ServiceRendering();
02008 }
02009 
02010 
02011 
02012 
02013 /********************************************************************************************
02014 
02015 >   void SoftShadowInfoBarOp::SaveShadowDragData(List * pList)
02016 
02017     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> Mc
02018     Created:    14/6/99
02019     Inputs:     The list to store all the shadow data to
02020     Outputs:    -
02021     Returns:    - 
02022     Purpose:    Stores all the shadow data in the ShadowDataList list
02023 
02024 ********************************************************************************************/
02025 void SoftShadowInfoBarOp::SaveShadowDragData(List * pList)
02026 {
02027     // first, build a list of all the shadow controller nodes in the selection
02028     pList->DeleteAll();
02029 
02030     // make up the list
02031     pList->DeleteAll();
02032 
02033     ShadowDragData * pShadDragItem = NULL;
02034 
02035     NodeShadowController * pController = NULL;
02036     NodeShadow *pShadow = NULL;
02037 
02038     NodeShadowController* pMaster = NULL;
02039     ListRange* pEditRange = pSoftShadowTool->GetShadowEditRange(&pMaster);
02040     if (pEditRange)
02041     {
02042         Node* pNode = pEditRange->FindFirst();
02043         while (pNode)
02044         {
02045             ENSURE(pNode->IsAShadowController(), "Found unexpected node type in shadow stack level");
02046             pController = (NodeShadowController*)pNode;
02047 
02048             pShadDragItem = new ShadowDragData;
02049             
02050             pShadDragItem->pNode = pController;
02051             pShadow = pController->GetShadow();
02052 
02053             pShadDragItem->PenumbraSize     = pController->GetPenumbraWidth();
02054             pShadDragItem->PositionShadowX  = pController->GetOffsetX();
02055             pShadDragItem->PositionShadowY  = pController->GetOffsetY();
02056             pShadDragItem->ShadowAngle      = pController->GetFloorShadowAngle();
02057             pShadDragItem->ShadowHeight     = pController->GetFloorShadowHeight();
02058             pShadDragItem->ShadowScale      = pController->GetWallShadowScale();
02059             pShadDragItem->GlowWidth        = pController->GetGlowWidth();
02060             pShadDragItem->FeatherWidth     = pController->GetFeatherWidth();
02061             pShadDragItem->ShadowTransparency  =  pShadow->GetTransp();
02062 
02063             pList->AddTail(pShadDragItem);
02064 
02065             pNode = pEditRange->FindNext(pNode);
02066         }
02067     }
02068 }
02069 
02070 /********************************************************************************************
02071 
02072 >   void SoftShadowInfoBarOp::RestoreShadowDragData(List * pList, BOOL bRegen = FALSE)
02073 
02074     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> Mc
02075     Created:    14/6/99
02076     Inputs:     Whether to call the regenerate function on every node or not
02077     Outputs:    -
02078     Returns:    - 
02079     Purpose:    Stores all the shadow data in the ShadowDataList list
02080 
02081 ********************************************************************************************/
02082 void SoftShadowInfoBarOp::RestoreShadowDragData(List * pList, BOOL bRegen,
02083                                                 BOOL bForceRegen)
02084 {
02085     if (pList->IsEmpty())
02086     {
02087         return;
02088     }
02089 
02090     ShadowDragData * pItem = (ShadowDragData *)pList->GetHead();
02091     
02092     NodeShadowController * pControl = NULL;
02093     NodeShadow           * pShadow  = NULL;
02094 
02095     DocView * pView = DocView::GetCurrent();
02096 
02097     while (pItem)
02098     {
02099         pControl = (NodeShadowController *)pItem->pNode;
02100 
02101         // force an initial redraw
02102         if (pView)
02103         {
02104             pView->ForceRedraw(pControl->FindParentSpread(), pControl->GetBoundingRect(),
02105                 FALSE);
02106         }
02107 
02108         pShadow = pControl->GetShadow();
02109 
02110         // I don;t need to regen if just the offsets have changed
02111         BOOL bMustIRegen = FALSE;
02112         
02113         if (pControl->GetFloorShadowAngle() != pItem->ShadowAngle)
02114         {
02115             pControl->SetFloorShadowAngle(pItem->ShadowAngle);
02116             bMustIRegen = TRUE;
02117         }
02118 
02119         if (pControl->GetFloorShadowHeight() != pItem->ShadowHeight)
02120         {
02121             pControl->SetFloorShadowHeight(pItem->ShadowHeight);
02122             bMustIRegen = TRUE;
02123         }
02124 
02125         if (pControl->GetPenumbraWidth() != pItem->PenumbraSize)
02126         {
02127             pControl->SetPenumbraWidth(pItem->PenumbraSize);
02128             bMustIRegen = TRUE;
02129         }
02130 
02131 
02132         pControl->SetOffsetX(pItem->PositionShadowX);
02133         pControl->SetOffsetY(pItem->PositionShadowY);
02134         
02135         if (pControl->GetWallShadowScale() != pItem->ShadowScale)
02136         {
02137             pControl->SetWallShadowScale(pItem->ShadowScale);
02138             bMustIRegen = TRUE;
02139         }
02140 
02141         if (pControl->GetGlowWidth() != pItem->GlowWidth)
02142         {
02143             pControl->SetGlowWidth(pItem->GlowWidth);
02144             bMustIRegen = TRUE;
02145         }
02146 
02147         if (pControl->GetFeatherWidth() != pItem->FeatherWidth)
02148         {
02149             pControl->SetFeatherWidth(pItem->FeatherWidth);
02150             bMustIRegen = TRUE;
02151         }
02152 
02153         pShadow->SetTransp(pItem->ShadowTransparency);
02154 
02155         // force a redraw
02156         if (pView)
02157         {
02158             pControl->InvalidateBoundingRect();
02159             pControl->ReleaseCached(TRUE, FALSE, TRUE, TRUE);   // Parents, Self and Derived data
02160             
02161             if ((bRegen && bMustIRegen) || bForceRegen)
02162             {
02163                 pControl->RegenerateNode(NULL);
02164             }
02165 
02166             pView->ForceRedraw(pControl->FindParentSpread(), pControl->GetBoundingRect(),
02167                 FALSE);
02168         }
02169 
02170         pItem = (ShadowDragData *)pList->GetNext(pItem);
02171     }
02172 
02173     pList->DeleteAll();
02174     ShadowDataList.DeleteAll();
02175 }
02176 
02177 /********************************************************************************************
02178 
02179 >   MILLIPOINT SoftShadowInfoBarOp::GetGlowSliderValue()
02180 
02181     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02182     Created:    3/1/2000
02183     Inputs:     
02184     Outputs:    The glow slider value
02185     Returns:    -
02186     Purpose:    Gets the glow slider value, which is logarithmic
02187     
02188 ********************************************************************************************/
02189 MILLIPOINT SoftShadowInfoBarOp::GetGlowSliderValue()
02190 {
02191     SetGadgetRange(_R(IDC_SOFTSHADOWSLIDER), 0, WIDTHSLIDERMAX);
02192     MILLIPOINT Value = GetLongGadgetValue(_R(IDC_SOFTSHADOWSLIDER), 0,
02193         WIDTHSLIDERMAX);
02194     
02195     // make the value appear between 0 and 1
02196     if (Value > WIDTHSLIDERMAX)
02197         Value = WIDTHSLIDERMAX;
02198 
02199     double dValue = Value - 0;
02200     dValue /= (double)(WIDTHSLIDERMAX - 0);
02201     //dValue = 1.0 - dValue;
02202 
02203     // change the profile
02204     GlowSliderProfile.SetBias(-GlowSliderProfile.GetBias());
02205     double dSliderValue = GlowSliderProfile.MapZeroToOne((AFp)(dValue));
02206     GlowSliderProfile.SetBias(-GlowSliderProfile.GetBias());
02207         
02208     dSliderValue *= (double)(WIDTHSLIDERMAX - 0);
02209     dSliderValue += 0;
02210 
02211     return (INT32)dSliderValue; 
02212 }
02213 
02214 /********************************************************************************************
02215 
02216 >   void SoftShadowInfoBarOp::SetGlowSliderValue(MILLIPOINT Value)
02217 
02218     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02219     Created:    3/1/2000
02220     Inputs:     
02221     Outputs:    The glow slider value
02222     Returns:    -
02223     Purpose:    Sets the glow slider value, which is logarithmic
02224     
02225 ********************************************************************************************/
02226 void SoftShadowInfoBarOp::SetGlowSliderValue(MILLIPOINT Value)
02227 {
02228     // make the value appear between 0 and 1
02229     if (Value > WIDTHSLIDERMAX)
02230         Value = WIDTHSLIDERMAX;
02231 
02232     if (Value < 0)
02233         Value = 0;
02234 
02235     double dValue = Value;
02236     dValue /= (double)(WIDTHSLIDERMAX);
02237 
02238     // change the profile
02239     double dSliderValue = dValue;
02240     
02241     dSliderValue = GlowSliderProfile.MapZeroToOne((AFp)(dValue));
02242     //dSliderValue = 1.0 - dSliderValue;
02243         
02244     dSliderValue *= (double)WIDTHSLIDERMAX;
02245     dSliderValue += 0;
02246 
02247     SetGadgetRange(_R(IDC_SOFTSHADOWSLIDER), 0, WIDTHSLIDERMAX);
02248 
02249     SetLongGadgetValue(_R(IDC_SOFTSHADOWSLIDER), (INT32)dSliderValue);
02250 }
02251 
02252 /********************************************************************************************
02253 
02254 >   void SoftShadowInfoBarOp::UpdateGadgetTypeButtons()
02255 
02256     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02257     Created:    3/1/2000
02258     Inputs:     Nothing
02259     Outputs:    Nothing
02260     Returns:    Nothing
02261     Purpose:    Updates the type button strip with the appropriate settings for the selection
02262     
02263 ********************************************************************************************/
02264 void SoftShadowInfoBarOp::UpdateGadgetTypeButtons()
02265 {
02266     BOOL bHasWallShadow = FALSE;
02267     BOOL bHasGlowShadow = FALSE;
02268     BOOL bHasFloorShadow = FALSE;
02269     BOOL bHasFeather = FALSE;
02270 
02271     NodeShadowController* pMaster = NULL;
02272     ListRange* pEditRange = pSoftShadowTool->GetShadowEditRange(&pMaster);
02273     if (pEditRange)
02274     {
02275         Node* pNode = pEditRange->FindFirst();
02276         while (pNode)
02277         {
02278             ENSURE(pNode->IsAShadowController(), "Found unexpected node type in shadow stack level");
02279             NodeShadowController* pControl = (NodeShadowController*)pNode;
02280 
02281             switch (pControl->GetShadowType())
02282             {
02283             case SHADOWTYPE_WALL:
02284                 bHasWallShadow = TRUE;
02285                 break;
02286             case SHADOWTYPE_FLOOR:
02287                 bHasFloorShadow = TRUE;
02288                 break;
02289             case SHADOWTYPE_GLOW:
02290                 bHasGlowShadow = TRUE;
02291                 break;
02292             case SHADOWTYPE_FEATHER:
02293                 bHasFeather = TRUE;
02294                 break;
02295 
02296             default:
02297                 {
02298                     // Do nothing
02299                 }
02300                 break;
02301             }
02302 
02303             pNode = pEditRange->FindNext(pNode);
02304         }
02305     }
02306 
02307     // select/deselect buttons
02308     SetBoolGadgetSelected(_R(IDC_BTN_WALLSHADOW), bHasWallShadow);
02309     SetBoolGadgetSelected(_R(IDC_BTN_FLOORSHADOW), bHasFloorShadow);
02310     SetBoolGadgetSelected(_R(IDC_BTN_GLOWSHADOW), bHasGlowShadow);
02311     // TODO: Feather?
02312 
02313     if (!bHasWallShadow && !bHasFloorShadow && !bHasGlowShadow)
02314     {
02315         SetBoolGadgetSelected(_R(IDC_BTN_NOSHADOW), TRUE);
02316     }
02317     else
02318     {
02319         SetBoolGadgetSelected(_R(IDC_BTN_NOSHADOW), FALSE);
02320     }
02321 
02322 }
02323 
02324 /********************************************************************************************
02325 
02326 >   void SoftShadowInfoBarOp::HandleNoShadowBtnClicked()
02327 
02328     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02329     Created:    31/1/2000
02330     Inputs:     Nothing
02331     Outputs:    Nothing
02332     Returns:    Nothing
02333     Purpose:    Handles the clicking of the 'no shadow' button
02334     
02335 ********************************************************************************************/
02336 void SoftShadowInfoBarOp::HandleNoShadowBtnClicked()
02337 {
02338     // is this button already selected
02339     if (!GetBoolGadgetSelected(_R(IDC_BTN_NOSHADOW)))
02340     {
02341         // do nothing - can't do anything since there's no shadow in the selection!
02342         return;
02343     }
02344 
02345     HandleShadowTypeChange(SHADOWTYPE_NONE);
02346 }
02347 
02348 /********************************************************************************************
02349 
02350 >   void SoftShadowInfoBarOp::HandleWallShadowBtnClicked()
02351 
02352     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02353     Created:    31/1/2000
02354     Inputs:     Nothing
02355     Outputs:    Nothing
02356     Returns:    Nothing
02357     Purpose:    Handles the clicking of the 'wall shadow' button
02358     
02359 ********************************************************************************************/
02360 void SoftShadowInfoBarOp::HandleWallShadowBtnClicked()
02361 {
02362     HandleShadowTypeChange(SHADOWTYPE_WALL);
02363 }
02364 
02365 /********************************************************************************************
02366 
02367 >   void SoftShadowInfoBarOp::HandleFloorShadowBtnClicked()
02368 
02369     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02370     Created:    31/1/2000
02371     Inputs:     Nothing
02372     Outputs:    Nothing
02373     Returns:    Nothing
02374     Purpose:    Handles the clicking of the 'floor shadow' button
02375     
02376 ********************************************************************************************/
02377 void SoftShadowInfoBarOp::HandleFloorShadowBtnClicked()
02378 {
02379     HandleShadowTypeChange(SHADOWTYPE_FLOOR);
02380 }
02381 
02382 /********************************************************************************************
02383 
02384 >   void SoftShadowInfoBarOp::HandleGlowShadowBtnClicked()
02385 
02386     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02387     Created:    31/1/2000
02388     Inputs:     Nothing
02389     Outputs:    Nothing
02390     Returns:    Nothing
02391     Purpose:    Handles the clicking of the 'glow shadow' button
02392     
02393 ********************************************************************************************/
02394 void SoftShadowInfoBarOp::HandleGlowShadowBtnClicked()
02395 {
02396     HandleShadowTypeChange(SHADOWTYPE_GLOW);
02397 }
02398 
02399 /********************************************************************************************
02400 
02401 >   void SoftShadowInfoBarOp::HandleShadowTypeChange(ShadowType Type)
02402 
02403     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02404     Created:    31/1/2000
02405     Inputs:     Nothing
02406     Outputs:    Nothing
02407     Returns:    Nothing
02408     Purpose:    Performs the change in type indicated by a button being clicked
02409     
02410 ********************************************************************************************/
02411 void SoftShadowInfoBarOp::HandleShadowTypeChange(ShadowType Type)
02412 {
02413 //  BOOL Valid = FALSE;
02414 
02415     NodeShadowParam Param(Type);
02416     Param.StackPosition = STACKPOS_INSERT_TOP;
02417     Param.pPPStack = GetApplication()->FindSelection()->GetEffectsStack(TRUE);  // Get a copy while the sel changes
02418     Param.pShadowTool = pSoftShadowTool;
02419 
02420     // create a new shadow
02421     if (Type != SHADOWTYPE_NONE)
02422     {
02423 PORTNOTE("other", "Removed use of Feather effect from SoftShadowInfoBarOp")
02424 #if !defined(EXCLUDE_FROM_XARALX)
02425         if (Type==SHADOWTYPE_FEATHER)
02426         {
02427 #ifdef FEATHER_EFFECT
02428             OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_APPLY_FEATHEREFFECT);
02429             if (pOpDesc != NULL)
02430             {
02431                 OpFeatherEffectParam fxparam;
02432                 fxparam.StackPosition = STACKPOS_INSERT_TOP;
02433                 fxparam.strOpUnique = POSTPRO_ID_FEATHER;
02434                 fxparam.FeatherSize = 2;
02435                 fxparam.pPPStack = Param.pPPStack;
02436                 //param.Profile = ?
02437                 pOpDesc->Invoke(&fxparam);
02438 
02439                 // Update the InfoBar
02440 //TODO:         UpdateInfoBar();
02441             }
02442 
02443             delete Param.pPPStack;
02444             return;
02445 #endif
02446         }
02447         else
02448 #endif
02449         {
02450             NodeShadowController* pMaster = NULL;
02451             pSoftShadowTool->GetShadowEditRange(&pMaster);
02452             if (pMaster==NULL)
02453             {
02454                 // No consistent shadow on top of effect stack
02455                 // So create a new one...
02456                 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_APPLYSHADOW);
02457                 if (pOpDesc != NULL)
02458                 {
02459                     String_256 UIDesc;
02460                     OpState State = OpApplyShadow::GetState(&UIDesc, pOpDesc);
02461                     if (!State.Greyed)
02462                         pOpDesc->Invoke(&Param);
02463                                 
02464                     // Update the InfoBar
02465                     UpdateInfoBar();
02466                 }
02467 
02468                 delete Param.pPPStack;
02469                 return;
02470             }
02471             else
02472             {
02473                 // There is a consistent shadow on top of the effect stack
02474                 // So we need to change it's type...
02475                 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_CHANGESHADOWTYPE);
02476                 if (pOpDesc != NULL)
02477                 {
02478                     String_256 UIDesc;
02479                     OpState State = OpChangeShadowType::GetState(&UIDesc, pOpDesc);
02480                     if (!State.Greyed)
02481                         pOpDesc->Invoke(&Param);
02482                                 
02483                     // Update the InfoBar
02484                     UpdateInfoBar();
02485                 }
02486 
02487                 delete Param.pPPStack;
02488                 return;
02489             }
02490         }
02491     }
02492 
02493     // Is it the no shadow type ? if so, remove all shadows
02494     else
02495     {
02496         OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_REMOVESHADOW);
02497         if (pOpDesc != NULL)
02498         {
02499             String_256 UIDesc;
02500             OpState State = OpRemoveShadow::GetState(&UIDesc, pOpDesc);
02501             if (!State.Greyed)
02502                 pOpDesc->Invoke(&Param);
02503 
02504             // Update the InfoBar
02505             UpdateInfoBar();
02506         }
02507     }
02508 }
02509 
02510 /********************************************************************************************
02511 
02512 >   void SoftShadowInfoBarOp::SetDarknessEditGadget(double dDarkness)
02513 
02514     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
02515     Created:    18/05/2005
02516     Inputs:     dDarkness   -   Standard 0-1 darkness value
02517                 bMany       -   Whether to put the string 'many' into the gadget
02518     Outputs:    Nothing
02519     Returns:    Nothing
02520     Purpose:    Loads the gadget with the percentage string from the value
02521     
02522 ********************************************************************************************/
02523 void SoftShadowInfoBarOp::SetDarknessEditGadget(double dDarkness)
02524 {
02525     // Calculate percentage value from darkness
02526     INT32 percent = (INT32)(100 - (dDarkness * 100));
02527 
02528     // Set the percentage string
02529     TCHAR Str[32];
02530     String_32 temp(_R(IDS_PERCENT_FORMAT));
02531     camSnprintf(Str, 32, temp, percent);
02532     String_32 PercentStr(Str);
02533     pSoftShadowInfoBar->SetStringGadgetValue(_R(IDC_SHADOWTRANSP_EDIT), PercentStr);
02534 }
02535 
02536 /********************************************************************************************
02537 
02538 >   BOOL SoftShadowInfoBarOp::GetDarknessEditGadget(double& dDarkness, BOOL &bMany)
02539 
02540     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
02541     Created:    18/05/2005
02542     Inputs:     -
02543     Outputs:    dDarkness   -   The darkness value currently in the gadget
02544                 bMany       -   Whether a 'many' setting is in the gadget
02545     Returns:    TRUE for success, FALSE for failure (e.g. the gadget's string is invalid)
02546     Purpose:    Gets a percentage string from the gadget and turns it into a INT32
02547     
02548 ********************************************************************************************/
02549 BOOL SoftShadowInfoBarOp::GetDarknessEditGadget(double& dDarkness, BOOL &bMany)
02550 {
02551     dDarkness = 0;
02552     String_256 ManyStr;
02553     ManyStr.Load(_R(IDS_SHADOWSTRING_MANY));
02554 
02555     BOOL Valid = TRUE;
02556     String_256 FieldContents = pSoftShadowInfoBar->GetStringGadgetValue(_R(IDC_SHADOWTRANSP_EDIT), &Valid);
02557     if (!Valid)
02558         return FALSE;
02559 
02560     bMany = (FieldContents == ManyStr);
02561     if (bMany)
02562         return TRUE;
02563 
02564     // Why don't we have Get/SetPercentageGadgetValue functions???
02565     //
02566     // OK, now we can parse the string
02567     // Shouldn't this really use GetDoubleGadgetValue ???
02568     INT32   Length  = (INT32)FieldContents.Length();
02569     TCHAR*  StrText = (TCHAR*)FieldContents;
02570 
02571     // Search for first numeric character
02572     INT32 i = 0;
02573     while (i < Length && !StringBase::IsNumeric(StrText[i]))
02574         i++;
02575 
02576     if (i>=Length)
02577         return FALSE;
02578 
02579     // Search for last numeric character
02580     INT32 j = i;
02581     while (j < Length && StringBase::IsNumeric(StrText[j]))
02582         j++;
02583 
02584     INT32 value;
02585     String_256 PercentStr;
02586     FieldContents.Mid(&PercentStr, i, (j - i));
02587     Convert::StringToLong(PercentStr, &value);
02588 
02589     if (value < 0 || value > 100)
02590         return FALSE;
02591 
02592     dDarkness = (100 - value)/100.0;
02593     SetDarknessEditGadget(dDarkness);
02594 
02595     return TRUE;
02596 }
02597 
02598 void SoftShadowInfoBarOp::SetDarknessSlider(double dDarkness)
02599 {
02600     SetLongGadgetValue(_R(IDC_SOFTSHADOWTRANSPSLIDER), (INT32)((1.0-dDarkness) * CONTRASTSLIDERMAX));
02601 }
02602 
02603 double SoftShadowInfoBarOp::GetDarknessSlider(BOOL* pValid)
02604 {
02605     return 1.0-((double)GetLongGadgetValue(_R(IDC_SOFTSHADOWTRANSPSLIDER), 0, CONTRASTSLIDERMAX, 0, pValid)/(double)CONTRASTSLIDERMAX);
02606 }
02607 
02608 BOOL SoftShadowInfoBarOp::SelectShadowsAlone()
02609 {
02610     // We need to get a copy of the stack because we're going to party on the selection!
02611     EffectsStack* pMyStack = GetApplication()->FindSelection()->GetEffectsStack(TRUE);
02612     if (pMyStack==NULL)
02613     {
02614         FailAndExecute();
02615         End();
02616         return FALSE;
02617     }
02618 
02619     NodeRenderableInk::DeselectAll();
02620 
02621     NodeShadowController* pMaster = NULL;
02622     ListRange* pShadowRange = pSoftShadowTool->GetShadowEditRange(&pMaster);
02623     if (pShadowRange)
02624     {
02625         Node* pSCNode = pShadowRange->FindFirst();
02626         while (pSCNode)
02627         {
02628             ENSURE(pSCNode->IsAShadowController(), "Found unexpected node type in shadow stack level");
02629             NodeShadowController* pControl = (NodeShadowController*)pSCNode;
02630             NodeShadow * pShadow = pControl->GetShadow();
02631 
02632             pShadow->Select(TRUE);
02633 
02634             pSCNode = pShadowRange->FindNext(pSCNode);
02635         }
02636     }
02637 
02638 //  ShadowList.DeleteAll();
02639     if (pMyStack)
02640     {
02641         delete pMyStack;
02642         pMyStack = NULL;
02643     }
02644 
02645     return TRUE;
02646 }
02647 
02648 
02649 
02650 #endif

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