bevinfo.cpp

Go to the documentation of this file.
00001 // $Id: bevinfo.cpp 1752 2006-09-15 09:13:05Z luke $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // FreeHand Tool Info bar operations
00099 
00100 /*
00101 */
00102 
00103 #include "camtypes.h"
00104 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 //#include "app.h"
00106 //#include "resource.h"
00107 #include "bevinfo.h"
00108 //#include "bevres.h"
00109 #include "attrbev.h"
00110 //#include "range.h"
00111 //#include "resource.h"
00112 //#include "barsdlgs.h"
00113 #include "nbevcont.h"
00114 #include "opbevel.h"
00115 //#include "range.h"
00116 //#include "rikdlg.h"
00117 //#include "rik.h"
00118 //#include "justin2.h"
00119 #include "pen.h"
00120 //#include "unittype.h"
00121 //#include "attrmgr.h"
00122 //#include "attrbev.h"
00123 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00124 #include "blobs.h"
00125 #include "bevtool.h"
00126 #include "selall.h"
00127 #include "cutop.h"
00128 #include "csrstack.h"
00129 #include "optsmsgs.h"
00130 #include "gdraw2.h"
00131 //#include "biasgain.h"
00132 //#include "mario.h"
00133 #include "ncntrcnt.h"
00134 #include "lineattr.h"
00135 //#include "simon.h"
00136 //#include "camvw.h"
00137 #include "nodebev.h"
00138 
00139 DECLARE_SOURCE( "$Revision: 1752 $" );
00140 
00141 // Declare stuff for the memory tracking
00142 CC_IMPLEMENT_DYNCREATE( BevelInfoBarOp, InformationBarOp )
00143 #define new CAM_DEBUG_NEW
00144 
00145 struct BevelComboMap
00146 {
00147     // the ID for the string in the combo
00148     UINT32 StringID;
00149 
00150     // the number passed to the beveler to determine the type of bevel
00151     INT32 TypeNum;
00152 } ;
00153 
00154 // no. of bevel types including NONE!
00155 INT32 NumBevelTypes = 16;
00156 
00157 BevelComboMap BevelTypes[] = 
00158 {
00159     { _R(IDS_BEVELNONE), -1 },
00160     { _R(IDS_BEVELFLAT), (INT32)BEVEL_FLAT },
00161     { _R(IDS_BEVELSMOOTH_1), (INT32)BEVEL_SMOOTH_1 } ,
00162     { _R(IDS_BEVELSMOOTH_2), (INT32)BEVEL_SMOOTH_2 } ,
00163     { _R(IDS_BEVELMESA_1), (INT32)BEVEL_MESA_1 },
00164     { _R(IDS_BEVELMESA_2), (INT32)BEVEL_MESA_2 },
00165     { _R(IDS_BEVELROUND), (INT32)BEVEL_ROUND },
00166     { _R(IDS_BEVELHALFROUND), (INT32)BEVEL_HALFROUND}, 
00167     { _R(IDS_BEVELFRAME), (INT32)BEVEL_FRAME },
00168     { _R(IDS_BEVELPOINT_1), (INT32)BEVEL_POINT_1 },
00169     { _R(IDS_BEVELPOINT_2A), (INT32)BEVEL_POINT_2a },
00170     { _R(IDS_BEVELPOINT_2B), (INT32)BEVEL_POINT_2b },
00171     { _R(IDS_BEVELRUFFLE_2A), (INT32)BEVEL_RUFFLE_2a },
00172     { _R(IDS_BEVELRUFFLE_2B), (INT32)BEVEL_RUFFLE_2b },
00173     { _R(IDS_BEVELRUFFLE_3A), (INT32)BEVEL_RUFFLE_3a },
00174     { _R(IDS_BEVELRUFFLE_3B), (INT32)BEVEL_RUFFLE_3b }
00175 } ;
00176 
00177 // slider bar types next
00178 INT32 NumSliderTypes = 4;
00179 const UINT32 SliderTypes[] =
00180 {
00181     _R(IDS_BEVELDEPTH),
00182     _R(IDS_BEVELCONTRAST),
00183     _R(IDS_BEVELLIGHTANGLE),
00184     _R(IDS_BEVELLIGHTTILT)
00185 } ;
00186 
00187 // inner/outer combo definition
00188 INT32 NumInnerTypes = 2;
00189 const UINT32 InnerTypes[] =
00190 {
00191     _R(IDS_BEVELINNER),
00192     _R(IDS_BEVELOUTER)
00193 } ;
00194 
00195 // constraints for the slider
00196 #define BEVEL_DEPTH_MIN 0
00197 #define BEVEL_DEPTH_MAX 250000
00198 #define BEVEL_CONTRAST_MIN 0
00199 #define BEVEL_CONTRAST_MAX 100
00200 #define BEVEL_LIGHTANGLE_MIN 0
00201 #define BEVEL_LIGHTANGLE_MAX 360
00202 #define BEVEL_LIGHTTILT_MIN 0
00203 #define BEVEL_LIGHTTILT_MAX 90
00204 
00205 // static for the current bevel info bar
00206 BevelInfoBarOp * BevelInfoBarOp::pCurrentBar = NULL;
00207 
00209 // slider profile
00210 CProfileBiasGain BevelSliderProfile((AFp)0.7, (AFp)0.0);
00211 
00212 /********************************************************************************************
00213 
00214 >   BevelInfoBarOp::BevelInfoBarOp()
00215 
00216     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00217     Created:    30/8/94
00218     Purpose:    Sets the info bars vars to NULL defaults
00219 
00220 ********************************************************************************************/
00221 
00222 BevelInfoBarOp::BevelInfoBarOp()
00223 {
00224     DlgResID = _R(IDD_BEVELINFOBAR);
00225     // The Controls hasve not been created yet
00226     ControlsExist = FALSE;
00227     
00228     // variable to stop controls from flickering
00229     m_bControlsEnabled = FALSE;
00230 
00231     // slider values
00232     m_Depth = 0;
00233     m_LightAngle = 0;
00234     m_Contrast = 100;
00235     m_SliderComboIndex = 1;
00236     m_bComboChanged = FALSE;
00237     m_bAmDragging = FALSE;
00238     m_pDragBlob = NULL;
00239     m_BlobAngle = 0;
00240     m_bUserSet = FALSE;
00241     m_UserIndent = FALSE;
00242     m_bButtonIsInner = FALSE;
00243     m_bButtonIsOuter = FALSE;
00244     m_bAmDraggingSlider = FALSE;
00245     pTool = NULL;
00246     CanRetroFit = FALSE;
00247     m_LightTilt = 0;
00248     m_LastDragWidth = 0;
00249     m_BetweenViews = FALSE;
00250 }
00251 
00252 
00253 
00254 
00255 /********************************************************************************************
00256 
00257 >   MsgResult BevelInfoBarOp::Message(Msg* Message) 
00258 
00259     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00260     Created:    12/5/94
00261     Inputs:     Message - A dialog message 
00262     Returns:    The result of the message
00263     Purpose:    Takes a look at the message and if it is for me it responds to it.
00264                 Here the scroll bar for the freehand tool is Created and closed. It
00265                 also responds to changes in the sliders position and tells the freehand
00266                 tool to set its smoothing factor to something appropriate.
00267 
00268 ********************************************************************************************/
00269 
00270 MsgResult BevelInfoBarOp::Message(Msg* Message) 
00271 {
00272 //  NodeBevelController * pBevel = NULL;
00273     INT32 value = 0;
00274 
00275     if (IS_OUR_DIALOG_MSG(Message))
00276     {
00277         DialogMsg* Msg = (DialogMsg*)Message;
00278 
00279         // Check if the message is a CANCEL
00280         if (Msg->DlgMsg == DIM_CANCEL)
00281         {
00282             // Close the dialog 
00283             Close();
00284             m_bComboChanged = FALSE;
00285         }
00286         else if (Msg->DlgMsg == DIM_CREATE)
00287         {
00288             m_BetweenViews = FALSE;
00289             // Initialise the controls
00290             // go see if there is an info bar to use
00291             if (WindowID!=NULL)
00292             {
00293                 // Mark the controls as existing
00294                 ControlsExist = TRUE;
00295 
00296                 String_64 Str;
00297 
00298                 // set the combos                   
00299 //              SetLongGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT), m_SliderComboIndex, FALSE, -1);
00300                 SetLongGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT), 0, FALSE, -1);
00301 
00302                 // first, clear the combo
00303                 DeleteAllValues( _R(IDC_BEVEL_SLIDER_COMBO));
00304                 
00305                 // now the slider combo
00306                 for ( INT32 i=0; i<NumSliderTypes; i++ )
00307                 {
00308                     Str.Load( SliderTypes[i] );
00309                     SetStringGadgetValue(_R(IDC_BEVEL_SLIDER_COMBO), Str, TRUE, i);
00310                 }
00311                 
00312                 SetComboListLength(_R(IDC_BEVEL_SLIDER_COMBO));
00313 
00314                 LoadBevelTypeComboStrings(FALSE);
00315                 LoadBevelDirectionComboStrings(FALSE);
00316 
00317                 UpdateControls();
00318                 UpdateJoinTypeControls();
00319                 
00320                 SetGadgetBitmaps(_R(IDC_BEVELSLIDER), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
00321 
00322                 m_bComboChanged = FALSE;
00323             }
00324 
00325         }
00326         else
00327         {
00328             // Messages to all the controls, handled indivdually
00329             if (ControlsExist)
00330             {
00331                 if (WindowID!=NULL)
00332                 {
00333                     if (FALSE) {}
00334                     else if (Msg->GadgetID == _R(IDC_BEVEL_TYPE_COMBO))
00335                     {
00336                         if (Msg->DlgMsg == DIM_SELECTION_CHANGED)
00337                         {
00338                             // ensure values are updated
00339                             HandleBevelTypeChanged();
00340                         }
00341                     }
00342                     else if (Msg->GadgetID == _R(IDC_BEVEL_SLIDER_COMBO))
00343                     {   
00344                         if (Msg->DlgMsg == DIM_SELECTION_CHANGED)
00345                         {
00346                             // ensure values are updated
00347                             SliderUpdate(FALSE);
00348                         }
00349                     }
00350                         /*
00351                     else if (Msg->GadgetID == _R(IDC_BEVEL_INNER_COMBO))
00352                     {
00353                         if (Msg->DlgMsg == DIM_SELECTION_CHANGED)
00354                         {
00355                             // ensure values are updated
00356                             HandleBevelDirectionChanged();
00357                     
00358                         }
00359                     }
00360                         */
00361                     else if (Msg->GadgetID == _R(IDC_BEVELSLIDER))
00362                     {
00363                         // on drop of slider, change the bevel (if there is one selected !)
00364                         if (Msg->DlgMsg == DIM_SLIDER_POS_SET)
00365                         {
00366                             if (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)) == 0)
00367                             {
00368                                 pTool->m_pDragBevelOp->RenderDragBlobs(m_LastDragWidth,
00369                                     Document::GetSelectedSpread());
00370                             }
00371                             
00372                             HandleSliderChanged();
00373                             m_bAmDraggingSlider = FALSE;
00374                         }
00375                         else if (Msg->DlgMsg == DIM_SLIDER_POS_CHANGING)
00376                         {
00377                             // start the drag on the tool's drag info bar so we
00378                             // can render blobs
00379                             if (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)) == 0)
00380                             {
00381                                 if (!m_bAmDraggingSlider)
00382                                 {
00383                                     pTool->m_pDragBevelOp->SetupDragInfo();
00384                                     m_bAmDraggingSlider = TRUE;
00385                                 }
00386                                 else
00387                                 {
00388                                     // if we've already dragged, then remove the drag
00389                                     // blobs which are present
00390                                     pTool->m_pDragBevelOp->RenderDragBlobs(m_LastDragWidth,
00391                                         Document::GetSelectedSpread());
00392                                 }
00393                             }
00394                                         
00395                             // is there a 'many' setting ?
00396                             m_bAmDraggingSlider = TRUE;
00397                             if (pTool->AreManyBevelLightAngles() &&
00398                                 GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)) == 2)
00399                             {
00400                                 // set all the blob angles to be the same, and update
00401                                 MsgResult Result = InformationBarOp::Message(Message);
00402                                 SetGadgetRange(_R(IDC_BEVELSLIDER), BEVEL_LIGHTANGLE_MIN, BEVEL_LIGHTANGLE_MAX);
00403                 
00404                                 INT32 Angle = GetLongGadgetValue(_R(IDC_BEVELSLIDER),
00405                                                         BEVEL_LIGHTANGLE_MIN,
00406                                                         BEVEL_LIGHTANGLE_MAX);
00407 
00408                                 // change the angle for the slider stuff
00409                                 // Angle = BEVEL_LIGHTANGLE_MAX - Angle;
00410 
00411                                 // change the blob angles
00412                                 pTool->ChangeBlobAngles(Angle);
00413                                 
00414                                 // update the slider/edit control
00415                                 SliderUpdate(TRUE);
00416 
00417                                 return Result;
00418                             }
00419                             if (pTool->AreManyBevelLightTilts() &&
00420                                 GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)) == 3)
00421                             {
00422                                 // set all the blob angles to be the same, and update
00423                                 MsgResult Result = InformationBarOp::Message(Message);
00424                                 SetGadgetRange(_R(IDC_BEVELSLIDER), BEVEL_LIGHTTILT_MIN, BEVEL_LIGHTTILT_MAX);
00425                 
00426                                 INT32 Angle = GetLongGadgetValue(_R(IDC_BEVELSLIDER),
00427                                                         BEVEL_LIGHTTILT_MIN,
00428                                                         BEVEL_LIGHTTILT_MAX);
00429 
00430                                 // change the angle for the slider stuff
00431                                 // Angle = BEVEL_LIGHTTILT_MAX - Angle;
00432 
00433                                 // change the blob angles
00434                                 pTool->ChangeBlobTilts(Angle);
00435                                 
00436                                 // update the slider/edit control
00437                                 SliderUpdate(TRUE);
00438 
00439                                 return Result;
00440                             }
00441                             else
00442                             {
00443                                 SliderUpdate(TRUE);
00444                                 
00445                                 if (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)) == 3)
00446                                 {
00447                                     RedrawBlobs(FALSE, TRUE);
00448                                 }
00449                                 else
00450                                 {
00451                                     RedrawBlobs(TRUE, FALSE);
00452                                 }
00453 
00454                                 // render the width drag blobs if necessary
00455                                 if (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)) == 0)
00456                                 {
00457                                     INT32 Width = m_Depth;
00458 
00459                                     if(!m_bButtonIsInner)
00460                                         Width = -Width;
00461 
00462                                     pTool->m_pDragBevelOp->RenderDragBlobs(Width,Document::GetSelectedSpread());
00463                                     m_LastDragWidth = Width;
00464                                 }
00465                             }
00466 
00467                             // repaint the editable control now
00468                             PaintGadgetNow(_R(IDC_BEVEL_SLIDER_EDIT));
00469                         }
00470                     }   
00471                     else if (Msg->GadgetID == _R(IDC_BEVEL_SLIDER_EDIT))
00472                     {
00473                         if (Msg->DlgMsg == DIM_SELECTION_CHANGED)
00474                         {
00475                             if (ConvertStringToValue(_R(IDC_BEVEL_SLIDER_EDIT), value))
00476                             {
00477                                 
00478                                 if (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)) == 0)
00479                                 {
00480                                     m_Depth = value;
00481                                 }
00482                                 else if (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)) == 1)
00483                                 {
00484                                     m_Contrast = value;
00485                                 }
00486                                 else if (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)) == 2)
00487                                 {
00488                                     m_LightAngle = value;
00489                                 }
00490                                 else if (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)) == 3)
00491                                 {
00492                                     if (value < 0 || value > 90)
00493                                     {
00494                                         SliderUpdate(FALSE);
00495                                         goto sliderout;
00496                                     }
00497 
00498                                     m_LightTilt = value;
00499                                 }
00500                             }
00501                             
00502                             SliderUpdate(FALSE);
00503                             HandleSliderChanged();
00504                             sliderout: {}
00505                         }
00506                     }
00507                     else if (Msg->GadgetID == _R(IDC_BTN_BEVELOUTER))
00508                     {
00509                         if (Msg->DlgMsg == DIM_LFT_BN_CLICKED)
00510                         {
00511                             if (!m_bButtonIsOuter)
00512                             {
00513                                 // make all outer
00514                                 HandleBevelDirectionsToOuter();
00515                             }
00516                             else
00517                             {
00518                                 UpdateControls();
00519                             }
00520                         }
00521                     }
00522                     else if (Msg->GadgetID == _R(IDC_BTN_BEVELINNER))
00523                     {
00524                         if (Msg->DlgMsg == DIM_LFT_BN_CLICKED)
00525                         {
00526                             if (!m_bButtonIsInner)
00527                             {
00528                                 // make all outer
00529                                 HandleBevelDirectionsToInner();
00530                             }
00531                             else
00532                             {
00533                                 UpdateControls();
00534                             }
00535                         }
00536                     }
00537                     else if (Msg->GadgetID == _R(IDC_BEVELJOINTYPEMITRE))
00538                     {
00539                         if (Msg->DlgMsg == DIM_LFT_BN_CLICKED)
00540                         {
00541                             HandleJoinTypeMitreClicked();
00542                         }
00543                     }
00544                     else if (Msg->GadgetID == _R(IDC_BEVELJOINTYPEROUND))
00545                     {
00546                         if (Msg->DlgMsg == DIM_LFT_BN_CLICKED)
00547                         {
00548                             HandleJoinTypeRoundClicked();
00549                         }
00550                     }
00551                     else if (Msg->GadgetID == _R(IDC_BEVELJOINTYPEBEVEL))
00552                     {
00553                         if (Msg->DlgMsg == DIM_LFT_BN_CLICKED)
00554                         {
00555                             HandleJoinTypeBevelClicked();
00556                         }
00557                     }
00558                 }
00559             }
00560         }
00561     }
00562     else
00563     {
00564         if (Tool::GetCurrentID() == TOOLID_BEVELTOOL)
00565         {
00566             if (MESSAGE_IS_A(Message, DocViewMsg))
00567             {
00568                 // re-render the blobs
00569                 DocViewMsg* msg = (DocViewMsg*) Message;
00570 
00571                 // Render the tool blobs off the old view just before it changes
00572                 if ((msg->State == DocViewMsg::SELABOUTTOCHANGE || msg->State == DocViewMsg::SELCHANGED ) 
00573                     && msg->pOldDocView && !GetApplication()->CamelotIsDying())
00574                 {
00575                     // Do additional checks here to avoid ensures!
00576                     CCamView* pOilView = msg->pOldDocView->GetConnectionToOilView();
00577                     BlobManager* pBlobManager = GetApplication()->GetBlobManager();
00578                     ENSURE(pBlobManager, "Can't get BlobManager");
00579 
00580                     PORTNOTE("other", "Removed IsScreenCamView test");
00581                     if (pOilView!=NULL /*&& pOilView->IsScreenCamView()*/)
00582                     {
00583                         // handle the view will/has changed msgs and do NOT process and selection changes msgs between times (sjk 22/11/00)
00584                         if (msg->State == DocViewMsg::SELABOUTTOCHANGE)
00585                         {
00586                             pBlobManager->RenderToolBlobsOff(pTool, msg->pOldDocView->GetVisibleSpread(), NULL);
00587                             pTool->ClearToolBlobList();
00588                             //TRACE( _T("View about to change\n"));
00589                             m_BetweenViews = TRUE;
00590                         }
00591                         else
00592                         {
00593                             pTool->SetupSelectionBlobs();
00594                             pBlobManager->RenderToolBlobsOn(pTool, msg->pOldDocView->GetVisibleSpread(), NULL);
00595                             //TRACE( _T("View has just changed\n"));
00596                             m_BetweenViews = FALSE;
00597                         }
00598                     }
00599                 }
00600             }
00601             else if (MESSAGE_IS_A(Message, OpMsg))
00602             {
00603                 if (((OpMsg *)Message)->MsgType == OpMsg::AFTER_UNDO ||
00604                     ((OpMsg *)Message)->MsgType == OpMsg::AFTER_REDO)
00605                 {
00606                     // cope with blob rendering
00607                     if (pTool && BevelTool::AmActive())
00608                     {
00609                         // render blobs back on
00610                         pTool->SetBlobRendering(TRUE);
00611                         pTool->SetupBlobList();
00612                         pTool->RenderToolBlobs(Document::GetSelectedSpread(), NULL);
00613                     }
00614                 }
00615                 else if (((OpMsg *)Message)->MsgType == OpMsg::BEFORE_UNDO ||
00616                     ((OpMsg *)Message)->MsgType == OpMsg::BEFORE_REDO)
00617                 {
00618                     // cope with blob rendering
00619                     if (pTool && BevelTool::AmActive())
00620                     {
00621                         // render off blobs
00622                         pTool->RenderToolBlobs(Document::GetSelectedSpread(), NULL);
00623                         pTool->SetBlobRendering(FALSE);
00624                     }
00625                 }
00626                 else if (((OpMsg *)Message)->pOp->IsKindOf(CC_RUNTIME_CLASS(SelectAllOp)))
00627                 {
00628                     // TRACEUSER( "DavidM", _T("Select all op\n"));
00629                     pTool->InvalidateToolBlobs();
00630                 }
00631                 else if (((OpMsg *)Message)->pOp->IsKindOf(CC_RUNTIME_CLASS(SelectNoneOp)))
00632                 {
00633                     pTool->InvalidateToolBlobs();
00634                 }
00635                 else if (((OpMsg *)Message)->pOp->IsKindOf(CC_RUNTIME_CLASS(OpDelete)))
00636                 {
00637                     pTool->InvalidateToolBlobs();
00638                 }
00639             }
00640             else if (MESSAGE_IS_A(Message, OptionsChangingMsg))
00641             {
00642                 OptionsChangingMsg* Msg = (OptionsChangingMsg*)Message;
00643 
00644                 if(Msg->State == OptionsChangingMsg::NEWUNITS)
00645                 {       
00646                     // update all controls
00647                     UpdateControls();
00648                 }
00649             }
00650             else if (MESSAGE_IS_A(Message, SelChangingMsg))
00651             {
00652                 UpdateControls();
00653                 SelChangingMsg* pSelChangeMsg = (SelChangingMsg*)Message;
00654                 if (pSelChangeMsg->State == SelChangingMsg::SELECTIONCHANGED && pTool && !m_BetweenViews)
00655                 {   
00656 //                  Spread * pSpread = Document::GetSelectedSpread();
00657                     
00658                     if (!pSelChangeMsg->InDifferentDocument)
00659                     {
00660                         pTool->InvalidateToolBlobs();
00661 /*                      pTool->RenderToolBlobsOff(pSpread, NULL);
00662                         pTool->ClearToolBlobList();
00663                         pTool->SetupBlobList();
00664                         // render the blobs back on
00665                         pTool->RenderToolBlobsOn(pSpread, NULL);
00666 */                  }
00667 
00668                 }
00669 
00670                 // Karim 12/09/2000
00671                 // Update our join-type buttons for certain selection changes.
00672                 if (pSelChangeMsg->State == SelChangingMsg::SELECTIONCHANGED ||
00673                     pSelChangeMsg->State == SelChangingMsg::NONCOLOURATTCHANGED)
00674                     UpdateJoinTypeControls();
00675                     EnableDisableJoinTypeControls();
00676             }
00677         }
00678     }
00679 
00680     return (InformationBarOp::Message(Message)); 
00681 }    
00682 
00683 
00684 /********************************************************************************************
00685 
00686 >   void BevelInfoBarOp::SliderUpdate()
00687 
00688     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00689     Created:    16/1/99
00690     Inputs:     -
00691     Purpose:    Updates the variables in me depending on the slider position
00692 
00693 ********************************************************************************************/
00694 void BevelInfoBarOp::SliderUpdate(BOOL bSetVariables, BOOL bTestMany)
00695 {
00696     if (!ControlsExist)
00697         return;
00698 
00699     List ContourList;
00700     BevelTools::BuildListOfSelectedNodes(&ContourList, CC_RUNTIME_CLASS(NodeContourController));
00701     
00702     if (!ContourList.IsEmpty())
00703     {
00704         ContourList.DeleteAll();
00705         EnableGadget(_R(IDC_BEVEL_SLIDER_COMBO), FALSE);
00706         EnableGadget(_R(IDC_BEVELSLIDER), FALSE);
00707         EnableGadget(_R(IDC_BEVEL_SLIDER_EDIT), FALSE);
00708         EnableGadget(_R(IDC_BEVEL_TYPE_COMBO), FALSE);
00709         return;
00710     }
00711 
00712     TRACEUSER( "DavidM", _T("Slider update !\n"));
00713 
00714     INT32 value = 0;
00715 
00716     String_256 Str;
00717 
00718     TRACEUSER( "DavidM", _T("Slider update\n"));
00719 
00720 //  TCHAR unit[] = _T("Units");
00721 
00722     if (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)) < 0 ||
00723         GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)) > NumSliderTypes-1)
00724     {
00725         SetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO), 1);
00726     }
00727 
00728     // set the variables from the slider's position
00729     if (bSetVariables)
00730     {
00731         switch (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)))
00732         {
00733         case 0:
00734             // bevel depth update
00735             SetGadgetRange(_R(IDC_BEVELSLIDER), BEVEL_DEPTH_MIN, BEVEL_DEPTH_MAX);
00736             
00737             value = GetSliderDepth();
00738             m_Depth = value;
00739             ConvertValueToString(Str,
00740                                  value,
00741                                  PIXELS);
00742             // Str += _T(" pix");
00743             SetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT),
00744                                  Str);
00745             m_SliderComboIndex = 0;
00746             
00747             break;
00748         case 1:
00749             // bevel contrast update
00750             SetGadgetRange(_R(IDC_BEVELSLIDER), BEVEL_CONTRAST_MIN, BEVEL_CONTRAST_MAX);
00751             value = GetLongGadgetValue(_R(IDC_BEVELSLIDER), BEVEL_CONTRAST_MIN,
00752                 BEVEL_CONTRAST_MAX);
00753             // value = BEVEL_CONTRAST_MAX - value;
00754             m_Contrast = value;
00755             SetLongGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT), value);
00756             Str = GetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT));
00757             Str += _T(" %");
00758             SetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT),
00759                                  Str);
00760 
00761             m_SliderComboIndex = 1;
00762 
00763             if (pTool)
00764                 pTool->ChangeContrastAndReRender(m_Contrast);
00765         
00766             break;
00767         case 2:
00768             // bevel light angle update
00769             SetGadgetRange(_R(IDC_BEVELSLIDER), BEVEL_LIGHTANGLE_MIN, BEVEL_LIGHTANGLE_MAX);
00770             value = GetLongGadgetValue(_R(IDC_BEVELSLIDER), BEVEL_LIGHTANGLE_MIN,
00771                 BEVEL_LIGHTANGLE_MAX);
00772 
00773             // value = BEVEL_LIGHTANGLE_MAX - value;
00774 
00775             m_LightAngle = value;
00776             SetLongGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT), value);
00777             Str = GetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT));
00778             Str += _T(" ");
00779             SetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT),
00780                                  Str);
00781 
00782             m_SliderComboIndex = 2;
00783             
00784             break;
00785         case 3:
00786             // bevel light tilt update
00787             SetGadgetRange(_R(IDC_BEVELSLIDER), BEVEL_LIGHTTILT_MIN, BEVEL_LIGHTTILT_MAX);
00788             value = GetLongGadgetValue(_R(IDC_BEVELSLIDER), BEVEL_LIGHTTILT_MIN,
00789                 BEVEL_LIGHTTILT_MAX);
00790             // value = BEVEL_LIGHTTILT_MAX - value;
00791             m_LightTilt = value;
00792             SetLongGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT), value);
00793             Str = GetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT));
00794             Str += _T(" ");
00795             SetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT),
00796                                  Str);
00797 
00798             m_SliderComboIndex = 3;
00799             break;
00800         }
00801     }
00802     else
00803     {
00804         // set the slider's position from the variables
00805         switch (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)))
00806         {
00807         case 0:
00808             // bevel depth update
00809             // now, check for multiple depths of bevels
00810             // if so, then set the value appropriately
00811             SetGadgetRange(_R(IDC_BEVELSLIDER), BEVEL_DEPTH_MIN, BEVEL_DEPTH_MAX);
00812 
00813             SetSliderDepth(abs(m_Depth));
00814             
00815             if (pTool->AreManyBevelIndents() && bTestMany)
00816             {
00817                 Str.Load(_R(IDS_BEVELSTRING_MANY));
00818             }
00819             else
00820             {
00821                 ConvertValueToString(Str,
00822                     m_Depth,
00823                     PIXELS);
00824             }
00825             
00826             SetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT),
00827                                  Str);
00828 
00829             PaintGadgetNow(_R(IDC_BEVELSLIDER));
00830             PaintGadgetNow(_R(IDC_BEVEL_SLIDER_EDIT));      
00831 
00832             m_SliderComboIndex = 0;
00833             
00834             break;
00835         case 1:
00836             // bevel contrast update
00837             SetGadgetRange(_R(IDC_BEVELSLIDER), BEVEL_CONTRAST_MIN, BEVEL_CONTRAST_MAX);
00838             value = m_Contrast;
00839             //value = BEVEL_CONTRAST_MAX - value;
00840                 
00841             SetLongGadgetValue(_R(IDC_BEVELSLIDER), value);
00842 
00843             
00844             if (pTool->AreManyBevelContrasts() && bTestMany)
00845             {
00846                 Str.Load(_R(IDS_BEVELSTRING_MANY));
00847             }
00848             else
00849             {
00850                 SetLongGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT), m_Contrast);
00851                 Str = GetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT));
00852                 Str += _T(" %");
00853 
00854                 // find all selected bevel contrast 
00855             }
00856 
00857             SetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT),
00858                                  Str);
00859 
00860             m_SliderComboIndex = 1;
00861 
00862             PaintGadgetNow(_R(IDC_BEVELSLIDER));
00863             PaintGadgetNow(_R(IDC_BEVEL_SLIDER_EDIT));      
00864             
00865             break;
00866         case 2:
00867             // bevel light angle update
00868             SetGadgetRange(_R(IDC_BEVELSLIDER), BEVEL_LIGHTANGLE_MIN, BEVEL_LIGHTANGLE_MAX);
00869 
00870             value = m_LightAngle;
00871                 
00872             SetLongGadgetValue(_R(IDC_BEVELSLIDER), value);
00873             
00874             if (pTool->AreManyBevelLightAngles() && bTestMany)
00875             {
00876                 Str.Load(_R(IDS_BEVELSTRING_MANY));
00877             }
00878             else
00879             {           
00880                 SetLongGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT), BEVEL_LIGHTANGLE_MAX - value);
00881                 Str = GetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT));
00882                 Str += _T(" ");
00883             }
00884             
00885             SetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT),
00886                                  Str);
00887 
00888             m_SliderComboIndex = 2;         
00889 
00890             PaintGadgetNow(_R(IDC_BEVELSLIDER));
00891             PaintGadgetNow(_R(IDC_BEVEL_SLIDER_EDIT));      
00892             
00893             break;
00894         case 3:
00895             // bevel light angle update
00896             SetGadgetRange(_R(IDC_BEVELSLIDER), BEVEL_LIGHTTILT_MIN, BEVEL_LIGHTTILT_MAX);
00897 
00898             value = m_LightTilt;
00899             // value = BEVEL_LIGHTTILT_MAX - value;
00900                 
00901             SetLongGadgetValue(_R(IDC_BEVELSLIDER), value);
00902             
00903             if (pTool->AreManyBevelLightTilts() && bTestMany)
00904             {
00905                 Str.Load(_R(IDS_BEVELSTRING_MANY));
00906             }
00907             else
00908             {           
00909                 SetLongGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT), m_LightTilt);
00910                 Str = GetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT));
00911                 Str += _T(" ");
00912             }
00913             
00914             SetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT),
00915                                  Str);
00916 
00917             m_SliderComboIndex = 3;         
00918 
00919             PaintGadgetNow(_R(IDC_BEVELSLIDER));
00920             PaintGadgetNow(_R(IDC_BEVEL_SLIDER_EDIT));      
00921             
00922             break;
00923         }
00924     }
00925 
00926     // activate & deactivate gadgets dending on bevel type
00927     Document* pDoc = Document::GetCurrent();
00928 
00929     if (pDoc)
00930     {
00931         if (GetApplication()->FindSelection()->IsEmpty())
00932         {
00933             EnableGadget(_R(IDC_BEVEL_SLIDER_COMBO), FALSE);
00934             EnableGadget(_R(IDC_BEVELSLIDER), FALSE);
00935             EnableGadget(_R(IDC_BEVEL_SLIDER_EDIT), FALSE);
00936             EnableGadget(_R(IDC_BEVEL_TYPE_COMBO), FALSE);
00937         }
00938         else
00939         {
00940             // enable the join-type controls whenever the selection is non-empty.
00941 
00942             if (NodeBevelController::SelectionHasBevelNode() ||
00943                 NodeBevelController::SelectionHasBevelInkNode())
00944             {
00945                 EnableGadget(_R(IDC_BEVEL_SLIDER_COMBO), TRUE);
00946                 EnableGadget(_R(IDC_BEVELSLIDER), TRUE);
00947                 EnableGadget(_R(IDC_BEVEL_SLIDER_EDIT), TRUE);
00948                 EnableGadget(_R(IDC_BEVEL_TYPE_COMBO), TRUE);
00949             }
00950             else
00951             {
00952                 EnableGadget(_R(IDC_BEVEL_SLIDER_COMBO), TRUE);
00953 
00954                 if (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)) == 0)
00955                 {
00956                     EnableGadget(_R(IDC_BEVELSLIDER), TRUE);
00957                     EnableGadget(_R(IDC_BEVEL_SLIDER_EDIT), TRUE);
00958                 }
00959                 else
00960                 {
00961                     EnableGadget(_R(IDC_BEVELSLIDER), FALSE);
00962                     EnableGadget(_R(IDC_BEVEL_SLIDER_EDIT), FALSE);
00963                 }
00964 
00965                 if (OpCreateBevel::GetState(NULL, NULL).Greyed)
00966                 {
00967                     EnableGadget(_R(IDC_BEVEL_TYPE_COMBO), FALSE);
00968                 }
00969                 else
00970                 {
00971                     EnableGadget(_R(IDC_BEVEL_TYPE_COMBO), TRUE);
00972                 }
00973             }
00974         }
00975     }
00976     else
00977     {
00978         EnableGadget(_R(IDC_BEVEL_SLIDER_COMBO), FALSE);
00979         EnableGadget(_R(IDC_BEVELSLIDER), FALSE);
00980         EnableGadget(_R(IDC_BEVEL_SLIDER_EDIT), FALSE);
00981         EnableGadget(_R(IDC_BEVEL_TYPE_COMBO), FALSE);
00982     }
00983 
00984     // do bubble help
00985     switch (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)))
00986     {
00987     case 0:
00988         SetGadgetHelp(_R(IDC_BEVELSLIDER), _R(IDBBL_BEVELSLIDERDEPTH), _R(IDS_BEVELSLIDERDEPTHID));
00989         SetGadgetHelp(_R(IDC_BEVEL_SLIDER_EDIT), _R(IDBBL_BEVELSLIDERDEPTH), _R(IDS_BEVELSLIDERDEPTHID));
00990         break;
00991     case 1:
00992         SetGadgetHelp(_R(IDC_BEVELSLIDER), _R(IDBBL_BEVELSLIDERCONTRAST), _R(IDS_BEVELSLIDERCONTRASTID));
00993         SetGadgetHelp(_R(IDC_BEVEL_SLIDER_EDIT), _R(IDBBL_BEVELSLIDERCONTRAST), _R(IDS_BEVELSLIDERCONTRASTID));
00994         break;
00995     case 2:
00996         SetGadgetHelp(_R(IDC_BEVELSLIDER), _R(IDBBL_BEVELSLIDERLIGHTANGLE), _R(IDS_BEVELSLIDERLIGHTANGLEID));
00997         SetGadgetHelp(_R(IDC_BEVEL_SLIDER_EDIT), _R(IDBBL_BEVELSLIDERLIGHTANGLE), _R(IDS_BEVELSLIDERLIGHTANGLEID));
00998         break;
00999     case 3:
01000         SetGadgetHelp(_R(IDC_BEVELSLIDER), _R(IDBBL_BEVELSLIDERTILT), _R(IDS_BEVELSLIDERTILTID));
01001         SetGadgetHelp(_R(IDC_BEVEL_SLIDER_EDIT), _R(IDBBL_BEVELSLIDERTILT), _R(IDS_BEVELSLIDERTILTID));
01002         break;
01003     }
01004 
01005     SetGadgetHelp(_R(IDC_BEVEL_TYPE_COMBO), _R(IDBBL_BEVELTYPECOMBO), _R(IDS_BEVELTYPECOMBO));
01006     SetGadgetHelp(_R(IDC_BEVEL_SLIDER_COMBO), _R(IDBBL_BEVELSLIDERCOMBO), _R(IDS_BEVELSLIDERCOMBO));
01007 }
01008 
01009 /********************************************************************************************
01010 
01011 >   void BevelInfoBarOp::DoBevel()
01012 
01013     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01014     Created:    16/1/99
01015     Inputs:     -
01016     Purpose:    Does the business with the bevelling !
01017 
01018 ********************************************************************************************/
01019 void BevelInfoBarOp::DoBevel()
01020 {
01021     // create a bevel
01022     BevelInfo BI;
01023 
01024     OpDescriptor* pOpDesc = NULL;
01025 
01026     if(m_Depth == 0)
01027     {
01028         SetSelectedValueIndex(_R(IDC_BEVEL_TYPE_COMBO),0);
01029     }
01030 
01031     BI.m_BevelType = BevelTypes[GetSelectedValueIndex(_R(IDC_BEVEL_TYPE_COMBO))].TypeNum;
01032     BI.m_bBevelTypeChanged = TRUE;
01033     BI.m_LightAngle = m_LightAngle;
01034     BI.m_Indent = m_Depth;
01035 
01036     if (pTool->AreManyBevelTypes())
01037     {
01038         // ok, 'many' is selected so alter the type accordingly
01039         BI.m_BevelType = BevelTypes[GetSelectedValueIndex(_R(IDC_BEVEL_TYPE_COMBO)) - 1].TypeNum;
01040     }
01041 
01042     TRACEUSER( "DavidM", _T("Bevel type change %d\n"), BI.m_BevelType);
01043 
01044     BlobManager* BlobMgr = GetApplication()->GetBlobManager();
01045 
01046     BI.m_bOuter = GetBoolGadgetSelected(_R(IDC_BTN_BEVELOUTER));
01047     BI.m_Contrast   = m_Contrast;
01048     BI.m_bCreateNewBevels = TRUE;
01049 
01050     Spread * pSpread = Document::GetSelectedSpread();
01051 
01052     if (BI.m_BevelType >= 0)
01053     {
01054         pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpCreateBevel));
01055         
01056         if (pTool && pSpread && BlobMgr)
01057         {
01058             pTool->RenderToolBlobs(pSpread, NULL);
01059             pTool->SetBlobRendering(FALSE);
01060         }
01061         
01062         if (pOpDesc)
01063         {
01064             pOpDesc->Invoke(&BI);
01065         }
01066 
01067         if (pTool && pSpread && BlobMgr)
01068         {
01069             pTool->SetupBlobList();
01070             pTool->SetBlobRendering(TRUE);
01071             pTool->RenderToolBlobs(pSpread, NULL);
01072         }
01073     }
01074     else
01075     {
01076         // do a remove bevel operation !
01077         // tell my tool to remove its blobs
01078         pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpRemoveBevel));
01079         
01080         // tell my tool to update its blobs
01081     
01082         if (pTool && pSpread && BlobMgr)
01083         {
01084             // turn off all the tool blobs
01085             pTool->RenderToolBlobs(pSpread, NULL);
01086             pTool->SetBlobRendering(FALSE);
01087         }   
01088     
01089         if (pOpDesc)
01090         {
01091             pOpDesc->Invoke();
01092         }
01093 
01094         if (pTool && pSpread && BlobMgr)
01095         {
01096             pTool->SetBlobRendering(TRUE);
01097             pTool->SetupBlobList();
01098             pTool->RenderToolBlobs(pSpread, NULL);
01099         }   
01100     
01101     }
01102 
01103     UpdateControls();
01104 }
01105 
01106 /********************************************************************************************
01107 
01108 >   void BevelInfoBarOp::SetToolActiveState(BOOL IsToolActive)
01109 
01110     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
01111     Created:    31/8/94
01112     Inputs:     IsToolActive - TRUE if the tool is becoming active, FALSE if it not
01113     Purpose:    Allows the info bar to know if it is valid or not
01114 
01115 ********************************************************************************************/
01116 
01117 void BevelInfoBarOp::SetToolActiveState(BOOL IsToolActive)
01118 {
01119     // Set the control state
01120     m_bComboChanged = FALSE;
01121     ControlsExist = IsToolActive;
01122         
01123 }
01124 
01125 
01126 
01127 /********************************************************************************************
01128 
01129 >   void BevelInfoBarOp::SetRetroState(BOOL CanRetroFit)
01130 
01131     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
01132     Created:    30/8/94
01133     Inputs:     CanRetroFit - TRUE if we can currently retro fit the path, FALSE if not
01134     Purpose:    Sets the Flag CanRetroFit and gets the infobar to redraw the static
01135                 text item that says this.
01136 
01137 ********************************************************************************************/
01138 
01139 void BevelInfoBarOp::SetRetroState(BOOL CanFit)
01140 {
01141     // Set the Retro field to be empty by default
01142     CanRetroFit = CanFit;
01143 
01144     // Set the string in the info bar now
01145     SetRetroString();
01146 }
01147 
01148 
01149 /********************************************************************************************
01150 
01151 >   void BevelInfoBarOp::SetRetroString()
01152 
01153     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
01154     Created:    30/8/94
01155     Purpose:    Sets the static text item in the freehand info bar to say either 'Retro' or
01156                 nothing, depending on the state of the flag CanRetroFit.
01157     SeeAlso:    BevelInfoBarOp::SetRetroState
01158 
01159 ********************************************************************************************/
01160 
01161 void BevelInfoBarOp::SetRetroString()
01162 {
01163     // go see if there is an info bar to use
01164     /*
01165     if (WindowID!=NULL)
01166     {
01167         if (CanRetroFit)
01168         {
01169             // Make the word Retro appear
01170             String_64 RetroWord;
01171             if (RetroWord.Load(_R(IDS_FHANDRETROTEXT)))
01172             {
01173                 // Set the contents of the field to indicate retro is possible
01174                 SetStringGadgetValue(_R(IDC_FREEHANDRETRO), &RetroWord);
01175             }
01176         }
01177         else
01178         {
01179             // make the word retro not appear
01180             String_8 RetroWord("");
01181             SetStringGadgetValue(_R(IDC_FREEHANDRETRO), &RetroWord);
01182         }
01183     }
01184     */
01185 }
01186 
01187 /********************************************************************************************
01188 
01189 >   void BevelInfoBarOp::UpdateControls(BOOL bResetSliderCombo)
01190 
01191     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01192     Created:    15/2/99
01193 
01194     Purpose:    Updates the controls on the info bar
01195 
01196 ********************************************************************************************/
01197 
01198 void BevelInfoBarOp::UpdateControls()
01199 {
01200     // Check to see if we`ve got any contours in the selection!
01201     BOOL HaveGotContours = FALSE;
01202     List ContourList;
01203     BevelTools::BuildListOfSelectedNodes(&ContourList, CC_RUNTIME_CLASS(NodeContourController));
01204     
01205     if (!ContourList.IsEmpty())
01206     {
01207         ContourList.DeleteAll();
01208         HaveGotContours = TRUE;
01209     }
01210 
01211     if (!ControlsExist || !pTool)
01212         return;
01213 
01214     // these two MUST be done in this order otherwise camelot falls over on entry
01215     if (!HasWindow())
01216         return;
01217 
01218     TRACEUSER( "DavidM", _T("Update controls\n"));
01219 
01220     NodeBevel           * pBevel    = NULL;
01221 //  NodeAttribute       * pNode     = NULL;
01222     AttrBevelIndent     * pIndent   = NULL;
01223     AttrBevelLightAngle * pLightAngle = NULL;
01224     AttrBevelType       * pType     = NULL;
01225     AttrBevelContrast   * pContrast = NULL;
01226     AttrBevelLightTilt * pTilt = NULL;
01227 
01228     // Obtain the current selections 
01229     Range Sel(*(GetApplication()->FindSelection()));
01230     RangeControl rg = Sel.GetRangeControlFlags();
01231     rg.PromoteToParent = TRUE;
01232     Sel.SetRangeControl(rg);
01233 
01234     // the attribute list
01235     List NodeList;
01236     NodeListItem * pItem = NULL;
01237 
01238     // build a list of all the bevel attribute nodes in the selection
01239     BevelTools::BuildListOfSelectedNodes(&NodeList,
01240                             CC_RUNTIME_CLASS(NodeBevel), TRUE);
01241 
01242     AttrBevelIndent     * pCurrentIndent            = NULL;
01243     AttrBevelLightAngle * pCurrentLightAngle        = NULL;
01244     AttrBevelContrast   * pCurrentContrast          = NULL;
01245 //  AttrBevelType       * pCurrentType              = NULL;
01246     AttrBevelLightTilt  * pCurrentTilt              = NULL;
01247 
01248 //  NodeBevelController * pController = NULL;
01249 
01250     Document* pDoc = Document::GetCurrent();
01251 
01252     if (NodeList.IsEmpty() || HaveGotContours)
01253     {
01254         // means we need to do the default attributes
01255         if (pDoc)
01256         {
01257             // reset the 'many'
01258             LoadBevelTypeComboStrings(FALSE);
01259             LoadBevelDirectionComboStrings(FALSE);
01260             
01261             // has the user set the variables ??
01262 
01263             pCurrentIndent = (AttrBevelIndent *)pDoc->GetAttributeMgr().GetCurrentAttribute(
01264                 CC_RUNTIME_CLASS(NodeRenderableInk),
01265                 CC_RUNTIME_CLASS(AttrBevelIndent));
01266             
01267             if (pCurrentIndent)
01268             {
01269                 m_Depth = pCurrentIndent->Value.m_Indent;
01270                 
01271                 // just do this the first time
01272                 m_bUserSet = TRUE;
01273                 m_UserIndent = m_Depth;
01274             }
01275         
01276             if (m_Depth < 0)
01277                 m_Depth = - m_Depth;
01278             
01279             pCurrentLightAngle = (AttrBevelLightAngle *)pDoc->GetAttributeMgr().GetCurrentAttribute(
01280                             CC_RUNTIME_CLASS(NodeRenderableInk),
01281                             CC_RUNTIME_CLASS(AttrBevelLightAngle));
01282 
01283             if (pCurrentLightAngle)
01284             {
01285                 m_LightAngle = pCurrentLightAngle->Value.m_LightAngle;
01286             }
01287             
01288             SetSelectedValueIndex(_R(IDC_BEVEL_TYPE_COMBO), 
01289                 0);
01290             
01291             pCurrentContrast = (AttrBevelContrast *)pDoc->GetAttributeMgr().GetCurrentAttribute(
01292                 CC_RUNTIME_CLASS(NodeRenderableInk),
01293                 CC_RUNTIME_CLASS(AttrBevelContrast));
01294             
01295             if (pCurrentContrast)
01296             {
01297                 m_Contrast = pCurrentContrast->Value.m_Contrast;
01298             }
01299 
01300             pCurrentTilt = (AttrBevelLightTilt *)pDoc->GetAttributeMgr().GetCurrentAttribute(
01301                 CC_RUNTIME_CLASS(NodeRenderableInk),
01302                 CC_RUNTIME_CLASS(AttrBevelLightTilt));
01303 
01304             if (pCurrentTilt)
01305             {
01306                 m_LightTilt = pCurrentTilt->Value.m_LightTilt;
01307             }
01308         }
01309 
01310         UpdateInnerOuterButtons(FALSE, FALSE, TRUE);
01311         //UpdateJoinTypeButtons () ....
01312         EnableGadget(_R(IDC_BEVELJOINTYPEMITRE), FALSE);
01313         EnableGadget(_R(IDC_BEVELJOINTYPEROUND), FALSE);
01314         EnableGadget(_R(IDC_BEVELJOINTYPEBEVEL), FALSE);
01315     }
01316     else
01317     {
01318         m_bControlsEnabled = TRUE;
01319         
01320         pIndent     = NULL;
01321         pLightAngle = NULL;
01322         pContrast   = NULL;
01323         pType       = NULL;
01324 
01325         // get the head of the list
01326         pItem = (NodeListItem *)NodeList.GetHead();
01327         
01328         // get all the applied attributes of the first node
01329         if (pItem && (!pIndent || !pLightAngle || !pType || !pContrast))
01330         {
01331             if (pItem->pNode)
01332             {
01333                 pBevel = (NodeBevel *)pItem->pNode;
01334                 
01335                 pBevel->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelIndent),
01336                     (NodeAttribute **)(&pIndent));
01337 
01338                 pBevel->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelLightAngle),
01339                     (NodeAttribute **)(&pLightAngle));
01340 
01341                 pBevel->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelContrast),
01342                     (NodeAttribute **)(&pContrast));
01343 
01344                 pBevel->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelType),
01345                     (NodeAttribute **)(&pType));
01346 
01347                 pBevel->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelLightTilt),
01348                     (NodeAttribute **)(&pTilt));
01349             }
01350             
01351             pItem = (NodeListItem *)NodeList.GetNext(pItem);
01352         }
01353         
01354         // set up the gadgets
01355         if (pType)
01356         {
01357             // have we a 'many' setting ?
01358             if (pTool->AreManyBevelTypes())
01359             {
01360                 LoadBevelTypeComboStrings(TRUE);
01361                 SetSelectedValueIndex(_R(IDC_BEVEL_TYPE_COMBO), 0);
01362             }
01363             else
01364             {
01365                 LoadBevelTypeComboStrings(FALSE);
01366                 for (INT32 i = 0 ; i < NumBevelTypes; i++)
01367                 {
01368                     if (pType->Value.m_Type == BevelTypes[i].TypeNum)
01369                         SetSelectedValueIndex(_R(IDC_BEVEL_TYPE_COMBO), i);
01370                 }
01371             }
01372         }
01373         else
01374         {
01375             // no type found so set to "none"
01376             LoadBevelTypeComboStrings(FALSE);
01377             SetSelectedValueIndex(_R(IDC_BEVEL_TYPE_COMBO), 0);
01378         }
01379         
01380         if (pIndent)
01381         {
01382             if (pTool->AreManyBevelDirections())
01383             {
01384                 UpdateInnerOuterButtons(TRUE, FALSE, FALSE);
01385             }
01386             else
01387             {               
01388                 if (pIndent->Value.m_Indent < 0)
01389                 {
01390                     UpdateInnerOuterButtons(FALSE, TRUE, FALSE);
01391                 }
01392                 else
01393                 {
01394                     UpdateInnerOuterButtons(FALSE, FALSE, FALSE);
01395                 }
01396             }
01397             
01398             SetLongGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT), abs(pIndent->Value.m_Indent), FALSE, -1);
01399         }
01400         
01401         SetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO), m_SliderComboIndex);
01402         
01403         if (pIndent)
01404         {
01405             m_Depth = abs(pIndent->Value.m_Indent);
01406         }
01407         else
01408         {
01409             m_Depth = 0;
01410         }
01411         
01412         if (pLightAngle)
01413         {
01414             // take it from the attribute
01415 //          m_LightAngle = pLightAngle->Value.m_LightAngle;
01416             m_LightAngle = BEVEL_LIGHTANGLE_MAX - pLightAngle->Value.m_LightAngle;
01417         }
01418         
01419         if (pContrast)
01420         {
01421             m_Contrast = pContrast->Value.m_Contrast;
01422         }
01423         else
01424         {
01425             m_Contrast = 0;
01426         }
01427 
01428         if (pTilt)
01429         {
01430             m_LightTilt = pTilt->Value.m_LightTilt;
01431         }
01432         else
01433         {
01434             m_LightTilt = 45;
01435         }
01436     }
01437 
01438     // clean up the list
01439     NodeList.DeleteAll();
01440 
01441     SliderUpdate(FALSE);
01442 }
01443 
01444 /********************************************************************************************
01445 
01446 >   virtual void BevelInfoBarOp::UpdateState()
01447 
01448     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01449     Created:    21/1/97
01450 
01451     Purpose:    Sets the state of button on the bar to keep them up to date
01452 
01453 ********************************************************************************************/
01454 
01455 void BevelInfoBarOp::UpdateState()
01456 {
01457     // Don't try to set our controls when they're not there!
01458     TRACEUSER( "DavidM", _T("BevelInfoBarOp::UpdateState\n"));
01459 
01460     if (!ControlsExist)
01461         return;
01462 
01463     UpdateControls();
01464 
01465     return;
01466 
01467 }
01468 
01469 
01470 /********************************************************************************************
01471 
01472 >   BOOL SoftShadowInfoBarOp::ConvertValueToString(String_256 &In, const INT32 value, UnitType type, String_256 &unit)
01473 
01474     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01475     Created:    09/12/96
01476     Inputs:     The value to convert to a string (In)
01477     Outputs:    -
01478     Returns:    -
01479     Purpose:    TRUE if the function was able to convert the INT32 to a string
01480 
01481 ********************************************************************************************/
01482 
01483 BOOL BevelInfoBarOp::ConvertValueToString(String_256 &In, const INT32 value, UnitType type)
01484 {
01485     BOOL Converted = FALSE; // True when a value has been converted
01486     
01487     Spread * CurrentSpread = Document::GetSelectedSpread();
01488 
01489     if (CurrentSpread)
01490     {
01491         // Get the dimension scaling object (units) associated with the given spread
01492         // and convert to its units.
01493         DimScale* pDimScale = DimScale::GetPtrDimScale((Node*) CurrentSpread);
01494         pDimScale->ConvertToUnits((INT32)value , &In);
01495         Converted = TRUE;
01496     }
01497 
01498     if (In.Length() == 0)
01499     {
01500         In = _T("0");
01501     }
01502 
01503     return Converted;
01504         
01505 }
01506 
01507 
01508 /********************************************************************************************
01509 
01510 >   BOOL BevelInfoBarOp::ConvertStringToValue(CGadgetID ID, INT32 &Value)
01511 
01512     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01513     Created:    3/2/99
01514     Inputs:     The value to convert to a string (In)
01515     Outputs:    -
01516     Returns:    -
01517     Purpose:    TRUE if the function was able to convert the INT32 to a string
01518     See Also:   ShadowBarOp::ConvertStringToValue()
01519 
01520 ********************************************************************************************/
01521 
01522 BOOL BevelInfoBarOp::ConvertStringToValue(CGadgetID ID, INT32 &Value)
01523 {
01524     String_64 Str;
01525     Str.Load(_R(IDS_BEVELSTRING_MANY));
01526 
01527     BOOL Valid = FALSE; // True when a value has been converted
01528 
01529     Spread * CurrentSpread = Document::GetSelectedSpread();
01530 
01531     DimScale* pDimScale = NULL;
01532     String_128 FieldContents;
01533     String_128 NumberString;
01534     INT32 i = 0;
01535     BOOL bUpdate = FALSE;
01536 
01537     // find out if it reads 'many'
01538     FieldContents = GetStringGadgetValue(ID, &Valid);
01539 
01540     if (Str == FieldContents)
01541         return FALSE;
01542 
01543     if (CurrentSpread != NULL)
01544     {
01545         // Get the dimension scaling object (units) associated with the given spread
01546         // and convert to its units.
01547         switch (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)))
01548         {
01549         case 0:
01550             // depth
01551             pDimScale = DimScale::GetPtrDimScale((Node*) CurrentSpread);
01552             //String_128 FieldContents = GetStringGadgetValue(_R(IDC_SOFTSHADOWCENTRE_EDIT_X), &Valid);
01553             FieldContents = GetStringGadgetValue(ID, &Valid);
01554             Valid = pDimScale->ConvertToMillipoints(FieldContents, &Value);
01555 
01556             if (Value > BEVEL_DEPTH_MAX)
01557                 Value = BEVEL_DEPTH_MAX;
01558             break;
01559         case 1:
01560             FieldContents = GetStringGadgetValue(ID, &Valid);
01561             
01562             for (i = 0 ; i < FieldContents.Length(); i++)
01563             {
01564                 if (FieldContents[i] >= '0' && FieldContents[i] <= '9')
01565                 {
01566                     NumberString += FieldContents[i];
01567                 }
01568                 else
01569                 {
01570                     i = FieldContents.Length();
01571                 }
01572             }
01573             
01574             SetStringGadgetValue(ID, NumberString);
01575             Value = GetLongGadgetValue(ID, BEVEL_CONTRAST_MIN, BEVEL_CONTRAST_MAX);
01576             SetStringGadgetValue(ID, FieldContents);
01577             break;
01578         case 2:
01579         case 3:
01580             FieldContents = GetStringGadgetValue(ID, &Valid);
01581             
01582             for (i = 0 ; i < FieldContents.Length(); i++)
01583             {
01584                 if (FieldContents[i] >= '0' && FieldContents[i] <= '9')
01585                 {
01586                     NumberString += FieldContents[i];
01587                 }
01588                 else
01589                 {
01590                     // deal with a negative angle
01591                     if (i == 0 && FieldContents[i] == '-')
01592                     {
01593                         NumberString += FieldContents[i];
01594                     }
01595                     else
01596                     {                       
01597                         i = FieldContents.Length();
01598                     }
01599                 }
01600             }
01601             
01602             SetStringGadgetValue(ID, NumberString);
01603             Value = GetLongGadgetValue(ID, -1000, 1000);
01604             
01605             while (Value < BEVEL_LIGHTANGLE_MIN)
01606             {
01607                 bUpdate = TRUE;
01608                 Value += 360;
01609             }
01610             
01611             while (Value > BEVEL_LIGHTANGLE_MAX)
01612             {
01613                 bUpdate = TRUE;
01614                 Value -= 360;
01615             }
01616             
01617             if (!bUpdate)
01618             {
01619                 SetStringGadgetValue(ID, FieldContents);
01620             }
01621             else
01622             {
01623                 SetLongGadgetValue(ID, Value);
01624                 NumberString = GetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT));
01625                 NumberString += _T(" ");
01626                 SetStringGadgetValue(_R(IDC_BEVEL_SLIDER_EDIT),
01627                     NumberString);
01628             }       
01629             
01630             break;
01631         }
01632     }
01633     else
01634     { 
01635         //TODO ??
01636     }
01637     
01638     return Valid;
01639 }
01640 
01641 /********************************************************************************************
01642 
01643 >   void BevelInfoBarOp::HandleBevelTypeChanged()
01644 
01645     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01646     Created:    3/2/99
01647     Inputs:     
01648     Outputs:    -
01649     Returns:    -
01650     Purpose:    Updates the bevel type
01651     
01652 ********************************************************************************************/
01653 
01654 void BevelInfoBarOp::HandleBevelTypeChanged()
01655 {
01656     if (!pTool)
01657         return;
01658     
01659     if(m_Depth == 0)
01660     {
01661         m_Depth = 3000;
01662         SetBoolGadgetSelected(_R(IDC_BTN_BEVELOUTER),TRUE);
01663     }
01664 
01665     DoBevel();
01666 }
01667 
01668 /********************************************************************************************
01669 
01670 >   void BevelInfoBarOp::DoBevelAttrChange(BevelInfo * pBevParam)
01671 
01672     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01673     Created:    3/2/99
01674     Inputs:     
01675     Outputs:    -
01676     Returns:    -
01677     Purpose:    Applies the attributes to the selection
01678     
01679 ********************************************************************************************/
01680 void BevelInfoBarOp::DoBevelAttrChange(BevelInfo * pBevParam)
01681 {
01682     // use the create bevel (which is kinda an universal function) to change all the
01683     // indents in the selection
01684     Spread * pSpread = Document::GetSelectedSpread();
01685 
01686     pBevParam->m_bCreateNewBevels = FALSE;
01687 
01688     // render the tool blobs off
01689     if (pTool && pSpread)
01690     {
01691         pTool->RenderToolBlobs(pSpread, NULL);
01692         pTool->SetBlobRendering(FALSE);
01693     }       
01694 
01695     OpDescriptor * pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpCreateBevel));
01696     
01697     if (pOpDesc)
01698     {
01699         pOpDesc->Invoke(pBevParam);
01700     }   
01701 
01702     // render them back on
01703     // render the tool blobs off
01704     if (pTool && pSpread)
01705     {
01706         pTool->SetBlobRendering(TRUE);
01707         pTool->SetupBlobList();
01708         pTool->RenderToolBlobs(pSpread, NULL);
01709     }       
01710 
01711     
01712 }
01713 
01714 /********************************************************************************************
01715 
01716 >   void BevelInfoBarOp::HandleSliderChanged()
01717 
01718     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01719     Created:    3/2/99
01720     Inputs:     
01721     Outputs:    -
01722     Returns:    -
01723     Purpose:    Updates the bevel type
01724     
01725 ********************************************************************************************/
01726 
01727 void BevelInfoBarOp::HandleSliderChanged()
01728 {
01729     // has the edit field got 'many' in it ? if so, exit
01730     String_64 Str;
01731 
01732     // find out if the selection is null
01733     Range Sel(*(GetApplication()->FindSelection()));
01734     RangeControl rg = Sel.GetRangeControlFlags();
01735     rg.PromoteToParent = TRUE;
01736     Sel.SetRangeControl(rg);
01737 
01738     // update sliders & member variables first
01739     BevelInfo BI;
01740     
01741     SetUpBevelInfo(&BI);
01742 
01743 //  AttrBevelIndent     *pIndent      = NULL;
01744 //  AttrBevelType       *pType        = NULL;
01745 //  AttrBevelContrast   * pContrast   = NULL;
01746 //  AttrBevelLightAngle * pLightAngle = NULL;
01747 
01748     switch (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)))
01749     {
01750     case 0:
01751         // are there no bevels in the selection ? if so, make it an outer flat bevel
01752         if (!(NodeBevelController::SelectionHasBevelNode() ||
01753             NodeBevelController::SelectionHasBevelInkNode()) ||
01754             m_Depth == 0)
01755         {
01756             if(m_Depth > 0 && BevelTypes[GetSelectedValueIndex(_R(IDC_BEVEL_TYPE_COMBO))].TypeNum == -1)
01757             {
01758                 SetSelectedValueIndex(_R(IDC_BEVEL_TYPE_COMBO),1);
01759                 UpdateInnerOuterButtons(FALSE,TRUE,FALSE);
01760             }
01761 
01762             DoBevel();
01763             return;
01764         }
01765         
01766         // the depth/indent setting
01767         BI.m_bBevelIndentChanged = TRUE;
01768         m_bUserSet = TRUE;
01769         m_UserIndent = BI.m_Indent;
01770         
01771         if (BI.m_bOuter)
01772         {
01773             m_UserIndent = -m_UserIndent;
01774         }
01775         
01776         break;
01777     case 1:
01778         // the contrast setting
01779         BI.m_bBevelContrastChanged = TRUE;
01780         break;
01781     case 2:
01782         BI.m_bBevelLightAngleChanged = TRUE;
01783         break;
01784     case 3:
01785         BI.m_bBevelLightTiltChanged = TRUE;
01786         break;
01787     default:
01788         ERROR3("Bevel infobar slider combo has invalid value");
01789         return;
01790     }   
01791     
01792     // render the blobs off
01793 //  Spread * pSpread = Document::GetSelectedSpread();
01794 
01795     DoBevelAttrChange(&BI); 
01796 }
01797 
01798 /********************************************************************************************
01799 
01800 >   void BevelInfoBarOp::RedrawBlobs(BOOL bAngle, BOOL bTilt)
01801 
01802     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01803     Created:    3/2/99
01804     Inputs:     bAngle      =   To do change in light angles
01805                 bTilt       =   To do change in tilts
01806     Outputs:    -
01807     Returns:    -
01808     Purpose:    Redraws the object blobs
01809     
01810 ********************************************************************************************/
01811 void BevelInfoBarOp::RedrawBlobs(BOOL bAngle, BOOL bTilt)
01812 {
01813     if (bAngle)
01814     {   
01815         if (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)) != 2)
01816             return;
01817         
01818         INT32 LightAngle = 0;
01819         LightAngle = GetLongGadgetValue(_R(IDC_BEVELSLIDER), BEVEL_LIGHTANGLE_MIN,
01820             BEVEL_LIGHTANGLE_MAX);
01821 
01822         // LightAngle = BEVEL_LIGHTANGLE_MAX - LightAngle;
01823         
01824         if (pTool)
01825         {
01826             pTool->ChangeBlobAngles(LightAngle);
01827         }
01828     }
01829     else if (bTilt)
01830     {
01831         if (GetSelectedValueIndex(_R(IDC_BEVEL_SLIDER_COMBO)) != 3)
01832             return;
01833 
01834         INT32 Tilt = 0;
01835 
01836         Tilt = GetLongGadgetValue(_R(IDC_BEVELSLIDER), BEVEL_LIGHTTILT_MIN,
01837             BEVEL_LIGHTTILT_MAX);
01838         // Tilt = BEVEL_LIGHTTILT_MAX - Tilt;
01839         
01840         if (pTool)
01841         {
01842             pTool->ChangeBlobTilts(Tilt);
01843         }
01844     }
01845 }
01846 
01847 /********************************************************************************************
01848 
01849 >   void BevelInfoBarOp::HandleBevelDirectionsToOuter()
01850 
01851     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01852     Created:    3/2/99
01853     Inputs:     
01854     Outputs:    -
01855     Returns:    -
01856     Purpose:    Updates the bevel direction
01857     
01858 ********************************************************************************************/
01859 void BevelInfoBarOp::HandleBevelDirectionsToOuter()
01860 {
01861         // update my variables first
01862     BevelInfo BI;
01863     
01864     SetUpBevelInfo(&BI);
01865 
01866     BI.m_bBevelDirectionChanged = TRUE;
01867     BI.m_bOuter = TRUE;
01868 
01869     // check for zero selection
01870     Range Sel(*(GetApplication()->FindSelection()));    
01871     RangeControl rg = Sel.GetRangeControlFlags();
01872     rg.PromoteToParent = TRUE;
01873     Sel.SetRangeControl(rg);
01874 
01875     AttrBevelIndent * pIndent = NULL;
01876     if (Sel.IsEmpty())
01877     {
01878         // do the default attribute
01879         pIndent = new AttrBevelIndent;
01880 
01881         if (!pIndent)
01882         {
01883             ERROR3("Can't create bevel indent");
01884             return;
01885         }
01886 
01887         pIndent->Value.m_Indent = BI.m_Indent;
01888 
01889         m_bUserSet = TRUE;
01890         m_UserIndent = BI.m_Indent;
01891 
01892         if (BI.m_bOuter)
01893         {
01894             pIndent->Value.m_Indent = -BI.m_Indent;
01895             m_UserIndent = -m_UserIndent;
01896         }
01897 
01898         AttributeManager::AttributeSelected(pIndent);
01899 
01900         return;
01901     }
01902 
01903     // get the operation descriptor for the bevel change
01904     DoBevelAttrChange(&BI);
01905 
01906 }
01907 
01908 /********************************************************************************************
01909 
01910 >   void BevelInfoBarOp::HandleBevelDirectionsToInner()
01911 
01912     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01913     Created:    3/2/99
01914     Inputs:     
01915     Outputs:    -
01916     Returns:    -
01917     Purpose:    Updates the bevel direction
01918     
01919 ********************************************************************************************/
01920 void BevelInfoBarOp::HandleBevelDirectionsToInner()
01921 {
01922     // update my variables first
01923     BevelInfo BI;
01924     
01925     SetUpBevelInfo(&BI);
01926 
01927     BI.m_bBevelDirectionChanged = TRUE;
01928     BI.m_bOuter = FALSE;
01929 
01930     // check for zero selection
01931     Range Sel(*(GetApplication()->FindSelection()));    
01932     RangeControl rg = Sel.GetRangeControlFlags();
01933     rg.PromoteToParent = TRUE;
01934     Sel.SetRangeControl(rg);
01935 
01936     AttrBevelIndent * pIndent = NULL;
01937     if (Sel.IsEmpty())
01938     {
01939         // do the default attribute
01940         pIndent = new AttrBevelIndent;
01941         if (!pIndent)
01942         {
01943             ERROR3("Can't create bevel indent");
01944             return ;
01945         }
01946 
01947         pIndent->Value.m_Indent = BI.m_Indent;
01948 
01949         m_bUserSet = TRUE;
01950         m_UserIndent = BI.m_Indent;
01951 
01952         if (BI.m_bOuter)
01953         {
01954             pIndent->Value.m_Indent = -BI.m_Indent;
01955             m_UserIndent = -m_UserIndent;
01956         }
01957 
01958         AttributeManager::AttributeSelected(pIndent);
01959 
01960         return;
01961     }
01962 
01963     // get the operation descriptor for the bevel change
01964     DoBevelAttrChange(&BI);
01965 }
01966 
01967 
01968 
01969 
01970 /********************************************************************************************
01971 
01972 >   void BevelInfoBarOp::HandleBevelDirectionChanged()
01973 
01974     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01975     Created:    3/2/99
01976     Inputs:     
01977     Outputs:    -
01978     Returns:    -
01979     Purpose:    Updates the bevel direction
01980     
01981 ********************************************************************************************/
01982 
01983 void BevelInfoBarOp::HandleBevelDirectionChanged()
01984 {
01985     // check for 'many' being selected
01986     /*
01987     if (pTool->AreManyBevelDirections())
01988     {
01989         if (GetSelectedValueIndex(_R(IDC_BEVEL_INNER_COMBO)) == 0)
01990         {
01991             // do nothing - '<Many>' has been selected again
01992             return;
01993         }
01994     }
01995     */
01996     
01997     // update my variables first
01998     BevelInfo BI;
01999     
02000     SetUpBevelInfo(&BI);
02001 
02002     BI.m_bBevelDirectionChanged = TRUE;
02003 
02004     // check for zero selection
02005     Range Sel(*(GetApplication()->FindSelection()));
02006     RangeControl rg = Sel.GetRangeControlFlags();
02007     rg.PromoteToParent = TRUE;
02008     Sel.SetRangeControl(rg);
02009 
02010     AttrBevelIndent * pIndent = NULL;
02011     if (Sel.IsEmpty())
02012     {
02013         // do the default attribute
02014         pIndent = new AttrBevelIndent;
02015 
02016         if (!pIndent)
02017         {
02018             ERROR3("Can't create bevel indent");
02019             return;
02020         }
02021 
02022         pIndent->Value.m_Indent = BI.m_Indent;
02023 
02024         m_bUserSet = TRUE;
02025         m_UserIndent = BI.m_Indent;
02026 
02027         if (BI.m_bOuter)
02028         {
02029             pIndent->Value.m_Indent = -BI.m_Indent;
02030             m_UserIndent = -m_UserIndent;
02031         }
02032 
02033         AttributeManager::AttributeSelected(pIndent);
02034 
02035         return;
02036     }
02037 
02038     // get the operation descriptor for the bevel change
02039     DoBevelAttrChange(&BI);
02040 }
02041 
02042 
02043 
02044 /********************************************************************************************
02045 
02046 >   void BevelInfoBarOp::HandleJoinTypeMitreClicked()
02047 
02048     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
02049     Created:    08 September 2000
02050 
02051     Outputs:    We ensure that all objects in the selection have a mitre join type.
02052 
02053     Purpose:    Handles the user clicking on the mitre join-type button on our infobar.
02054 
02055     Notes:      This method assumes that an object must have a join type;
02056                 ie  if none of the other join types apply to the selection,
02057                     then the whole selection must have this join type, so there
02058                     is no point in reapplying it in this case.
02059 
02060 ********************************************************************************************/
02061 void BevelInfoBarOp::HandleJoinTypeMitreClicked()
02062 {
02063     BOOL fRound = GetBoolGadgetSelected(_R(IDC_BEVELJOINTYPEROUND));
02064     BOOL fBevel = GetBoolGadgetSelected(_R(IDC_BEVELJOINTYPEBEVEL));
02065 
02066     // only bother changing to a mitre join type if any selected objects
02067     // use the other join types.
02068     if (fRound || fBevel)
02069         ChangeJoinType(MitreJoin);
02070     else
02071         SetBoolGadgetSelected(_R(IDC_BEVELJOINTYPEMITRE), TRUE);
02072 }
02073 
02074 
02075 
02076 /********************************************************************************************
02077 
02078 >   void BevelInfoBarOp::HandleJoinTypeRoundClicked()
02079 
02080     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
02081     Created:    08 September 2000
02082 
02083     Outputs:    We ensure that all objects in the selection have a round join type.
02084 
02085     Purpose:    Handles the user clicking on the round join-type button on our infobar.
02086 
02087     Notes:      This method assumes that an object must have a join type;
02088                 ie  if none of the other join types apply to the selection,
02089                     then the whole selection must have this join type, so there
02090                     is no point in reapplying it in this case.
02091 
02092 ********************************************************************************************/
02093 void BevelInfoBarOp::HandleJoinTypeRoundClicked()
02094 {
02095     BOOL fMitre = GetBoolGadgetSelected(_R(IDC_BEVELJOINTYPEMITRE));
02096     BOOL fBevel = GetBoolGadgetSelected(_R(IDC_BEVELJOINTYPEBEVEL));
02097 
02098     // only bother changing to a mitre join type if any selected objects
02099     // use the other join types.
02100     if (fMitre || fBevel)
02101         ChangeJoinType(RoundJoin);
02102     else
02103         SetBoolGadgetSelected(_R(IDC_BEVELJOINTYPEROUND), TRUE);
02104 }
02105 
02106 
02107 
02108 /********************************************************************************************
02109 
02110 >   void BevelInfoBarOp::HandleJoinTypeBevelClicked()
02111 
02112     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
02113     Created:    08 September 2000
02114 
02115     Outputs:    We ensure that all objects in the selection have a bevel join type.
02116 
02117     Purpose:    Handles the user clicking on the bevel join-type button on our infobar.
02118 
02119     Notes:      This method assumes that an object must have a join type;
02120                 ie  if none of the other join types apply to the selection,
02121                     then the whole selection must have this join type, so there
02122                     is no point in reapplying it in this case.
02123 
02124 ********************************************************************************************/
02125 void BevelInfoBarOp::HandleJoinTypeBevelClicked()
02126 {
02127     BOOL fRound = GetBoolGadgetSelected(_R(IDC_BEVELJOINTYPEROUND));
02128     BOOL fMitre = GetBoolGadgetSelected(_R(IDC_BEVELJOINTYPEMITRE));
02129 
02130     // only bother changing to a mitre join type if any selected objects
02131     // use the other join types.
02132     if (fRound || fMitre)
02133         ChangeJoinType(BevelledJoin);
02134     else
02135         SetBoolGadgetSelected(_R(IDC_BEVELJOINTYPEBEVEL), TRUE);
02136 }
02137 
02138 
02139 
02140 /********************************************************************************************
02141 
02142 >   void BevelInfoBarOp::ChangeJoinType(JointType jt)
02143 
02144     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
02145     Created:    11 September 2000
02146     Inputs:     jt  the join type to apply to the selection.
02147 
02148     Outputs:    An attribute describing the given join type is applied to the selection.
02149 
02150     Purpose:    Apply the given join type to the selection.
02151 
02152     Errors:     Shows a warning if we run out of memory.
02153 
02154     See also:   AttributeManager::AttributeSelected().
02155 
02156 ********************************************************************************************/
02157 void BevelInfoBarOp::ChangeJoinType(JointType jt)
02158 {
02159         // update my variables first
02160     BevelInfo BI;
02161     
02162     SetUpBevelInfo(&BI);
02163 
02164     BI.m_bJointTypeChanged = TRUE;
02165     BI.m_JointType = jt;
02166 
02167     // check for zero selection
02168     Range               Sel(*(GetApplication()->FindSelection()));  
02169     RangeControl        rg = Sel.GetRangeControlFlags();
02170     rg.PromoteToParent = TRUE;
02171     Sel.SetRangeControl(rg);
02172 
02173     AttrJoinType*       pJoinType = NULL;
02174     if (Sel.IsEmpty())
02175     {
02176         // do the default attribute
02177         pJoinType = new AttrJoinType;
02178 
02179         if (!pJoinType)
02180         {
02181             ERROR3("Can't create bevel indent");
02182             return;
02183         }
02184 
02185         pJoinType->Value.JoinType = BI.m_JointType;
02186 
02187         AttributeManager::AttributeSelected( pJoinType );
02188         return;
02189     }
02190 
02191     // get the operation descriptor for the bevel change
02192     DoBevelAttrChange(&BI);
02193 }
02194 
02195 
02196 
02197 /********************************************************************************************
02198 
02199 >   void BevelInfoBarOp::UpdateJoinTypeControls()
02200 
02201     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
02202     Created:    11 September 2000
02203 
02204     Outputs:    The join type buttons on the infobar are updated to reflect the join types
02205                 contained in the selection.
02206 
02207     Purpose:    Update our infobar join type buttons.
02208                 This method is currently called only in response to a SelChanging message.
02209 
02210 ********************************************************************************************/
02211 void BevelInfoBarOp::UpdateJoinTypeControls()
02212 {
02213 // DEBUG:
02214 //  TRACEUSER( "Karim", _T("BevelInfoBarOp::UpdateJoinTypeControls\n"));
02215 
02216     if (!ControlsExist || !HasWindow())
02217         return;
02218 
02219     // the check for join types is possibly time-consuming, as we may need to scan the
02220     // selection if there are multiple join types in use on selected objects.
02221 
02222     // Determine if there is a common attribute.
02223     NodeAttribute* pAttr;
02224     SelRange::CommonAttribResult eResult;
02225     eResult = GetApplication()->
02226                  FindSelection()->
02227                      FindCommonAttribute(CC_RUNTIME_CLASS(AttrJoinType), &pAttr);
02228 
02229     // initialise all button-states to FALSE - they will be set to TRUE appropriately below.
02230     BOOL fMitre = FALSE;
02231     BOOL fRound = FALSE;
02232     BOOL fBevel = FALSE;
02233 
02234     switch (eResult)
02235     {
02236         // uncheck all buttons.
02237         case SelRange::ATTR_NONE:
02238             break;
02239 
02240         // only check the common join type.
02241         case SelRange::ATTR_COMMON:
02242             if (pAttr != NULL)
02243             {
02244                 fMitre = ( ((AttrJoinType*)pAttr)->Value.JoinType == MitreJoin );
02245                 fRound = ( ((AttrJoinType*)pAttr)->Value.JoinType == RoundJoin );
02246                 fBevel = ( ((AttrJoinType*)pAttr)->Value.JoinType == BevelledJoin );
02247             }
02248             break;
02249 
02250         // test the selection for all common line attr types.
02251         case SelRange::ATTR_MANY:
02252             {
02253                 // scan the selection, quitting as soon as all three states get set.
02254                 SelRange* pSel = GetApplication()->FindSelection();
02255                 for (Node*  pSelNode =  pSel->FindFirst();
02256                             pSelNode != NULL && !(fMitre && fRound && fBevel);
02257                             pSelNode =  pSel->FindNext(pSelNode))
02258                 {
02259                     if (!pSelNode->IsAnObject())
02260                         continue;
02261 
02262                     ((NodeRenderableInk*)pSelNode)->
02263                         FindAppliedAttribute(CC_RUNTIME_CLASS(AttrJoinType), &pAttr);
02264                     if (pAttr != NULL)
02265                     {
02266                         fMitre |= ( ((AttrJoinType*)pAttr)->Value.JoinType == MitreJoin );
02267                         fRound |= ( ((AttrJoinType*)pAttr)->Value.JoinType == RoundJoin );
02268                         fBevel |= ( ((AttrJoinType*)pAttr)->Value.JoinType == BevelledJoin );
02269                     }
02270                 }
02271             }
02272             break;
02273 
02274         // error - unrecognised return option from FindCommonAttribute().
02275         default:
02276             ERROR3("BevelInfoBarOp::UpdateJoinTypeControls; invalid result from FindCommonAttribute()");
02277             break;
02278     }
02279 
02280     SetBoolGadgetSelected(_R(IDC_BEVELJOINTYPEMITRE), fMitre);
02281     SetBoolGadgetSelected(_R(IDC_BEVELJOINTYPEROUND), fRound);
02282     SetBoolGadgetSelected(_R(IDC_BEVELJOINTYPEBEVEL), fBevel);
02283 }
02284 
02285 
02286 
02287 /********************************************************************************************
02288 
02289 >   void BevelInfoBarOp::EnableDisableJoinTypeControls()
02290 
02291     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
02292     Created:    12 September 2000
02293     Purpose:    Enable/disable the join type buttons on the info bar,
02294                 according to the contents of the selection.
02295 
02296 ********************************************************************************************/
02297 void BevelInfoBarOp::EnableDisableJoinTypeControls()
02298 {
02299     // our join type buttons act only upon the selection.
02300     SelRange* pSel = GetApplication()->FindSelection();
02301     if (pSel == NULL || pSel->IsEmpty())
02302     {
02303         EnableGadget(_R(IDC_BEVELJOINTYPEMITRE), FALSE);
02304         EnableGadget(_R(IDC_BEVELJOINTYPEROUND), FALSE);
02305         EnableGadget(_R(IDC_BEVELJOINTYPEBEVEL), FALSE);
02306     }
02307     else
02308     {
02309         EnableGadget(_R(IDC_BEVELJOINTYPEMITRE), TRUE);
02310         EnableGadget(_R(IDC_BEVELJOINTYPEROUND), TRUE);
02311         EnableGadget(_R(IDC_BEVELJOINTYPEBEVEL), TRUE);
02312     }
02313 }
02314 
02315 
02316 
02317 /********************************************************************************************
02318 
02319 >   void BevelInfoBarOp::SetUpBevelInfo(BevelInfo * pInfo)
02320 
02321     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02322     Created:    3/2/99
02323     Inputs:     
02324     Outputs:    -
02325     Returns:    -
02326     Purpose:    Initialises the bevel info class based on the dialog's settings
02327     
02328 ********************************************************************************************/
02329 void BevelInfoBarOp::SetUpBevelInfo(BevelInfo * pInfo)
02330 {
02331     pInfo->m_BevelType  = BevelTypes[GetSelectedValueIndex(_R(IDC_BEVEL_TYPE_COMBO))].TypeNum;
02332 
02333     pInfo->m_LightAngle = m_LightAngle;
02334     pInfo->m_Contrast   = m_Contrast;
02335     pInfo->m_Indent     = m_Depth;
02336     pInfo->m_Tilt       = m_LightTilt;
02337 
02338     INT32 DirectionIndex = 0 ;
02339 
02340     if (m_bButtonIsOuter)
02341         DirectionIndex = 1;
02342 
02343     if (pTool->AreManyBevelTypes())
02344     {
02345         pInfo->m_BevelType  = BevelTypes[GetSelectedValueIndex(_R(IDC_BEVEL_TYPE_COMBO))-1].TypeNum;
02346     }
02347 
02348     // have we a many situation ?
02349     if (pTool->AreManyBevelDirections())
02350     {
02351         DirectionIndex -= 1;
02352     }
02353 
02354     // depth is negative for outer bevels (in the attribute)
02355     if (DirectionIndex == 0)
02356     {
02357         pInfo->m_bOuter = FALSE;
02358     }
02359     else
02360     {
02361         pInfo->m_bOuter = TRUE;
02362     }
02363 }
02364 
02365 /********************************************************************************************
02366 
02367 >   void BevelInfoBarOp::BeginDrag(BevelBlob * pBlob)
02368 
02369     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02370     Created:    23/2/99
02371     Inputs:     
02372     Outputs:    -
02373     Returns:    -
02374     Purpose:    starts the drag on a particular blob
02375     Notes:      Called by the BevelTool when the user begins a drag on a bevel blob
02376                 arrowhead
02377     
02378 ********************************************************************************************/
02379 void BevelInfoBarOp::BeginDrag(BevelBlob * pBlob)
02380 {
02381     if (!pBlob)
02382     {
02383         ERROR3("BevelInfoBarOp::BeginDrag - blob passed in is NULL");
02384         return;
02385     }
02386     
02387     m_pDragBlob = pBlob;
02388     m_bAmDragging = TRUE;
02389     m_BlobAngle = pBlob->GetAngle();
02390 
02391     StartDrag( DRAGTYPE_AUTOSCROLL );
02392 }
02393 
02394 /********************************************************************************************
02395 
02396 >   void BevelInfoBarOp::DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, 
02397                                    Spread* pSpread, BOOL bSolidDrag)
02398 
02399 
02400     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02401     Created:    23/2/99
02402     Inputs:     
02403     Outputs:    -
02404     Returns:    -
02405     Purpose:    Deals with pointer movement messages whilst dragging
02406     
02407 ********************************************************************************************/
02408 
02409 void BevelInfoBarOp::DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, 
02410                                    Spread* pSpread, BOOL bSolidDrag)
02411 {
02412     // first, render my blob off
02413     if (!pTool || !m_pDragBlob)
02414         return;
02415 
02416     // now, get the blob to recalculate its angle
02417     m_pDragBlob->CalculateAngle(PointerPos, ClickMods.Constrain);
02418 
02419     m_pDragBlob->RenderNodes();
02420 
02421     Document * pDoc = Document::GetCurrent();
02422 
02423     if (pDoc)
02424     {
02425         pDoc->ForceRedraw(pSpread, m_pDragBlob->GetRect());
02426     }
02427     
02428     GetApplication()->ServiceRendering();
02429     
02430     // update our controls
02431 //  m_LightAngle = m_pDragBlob->GetAngle();
02432     m_LightAngle = BEVEL_LIGHTANGLE_MAX - m_pDragBlob->GetAngle();
02433 
02434     SliderUpdate(FALSE);
02435 }
02436 
02437 /********************************************************************************************
02438 
02439 >   void BevelInfoBarOp::DragFinished( DocCoord PointerPos, ClickModifiers ClickMods, 
02440                                 Spread* pSpread, BOOL Success, BOOL bSolidDrag)
02441 
02442 
02443     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02444     Created:    23/2/99
02445     Inputs:     
02446     Outputs:    -
02447     Returns:    -
02448     Purpose:    Finishes or quits the dragging
02449     
02450 ********************************************************************************************/
02451 
02452 void BevelInfoBarOp::DragFinished( DocCoord PointerPos, ClickModifiers ClickMods, 
02453                                 Spread* pSpread, BOOL Success, BOOL bSolidDrag)
02454 {
02455     if (!pTool || !m_pDragBlob)
02456     {
02457         EndDrag();
02458         return;
02459     }
02460     
02461 //  AttrBevelLightAngle * pAttr = NULL;
02462 //  NodeListItem * pItem = NULL;
02463 
02464     BlobManager* pBlobMgr = GetApplication()->GetBlobManager();
02465 
02466     if (!pBlobMgr)
02467     {
02468         ERROR3("DragFinished - no blob manager\n");
02469         return;
02470     }
02471 
02472     OpDescriptor * pOpDesc = NULL;
02473 
02474     OpChangeLightAnglesParam Param;
02475     
02476     if (!Success)
02477     {
02478         // user clicked ESC or some other reason for the drag to not complete properly
02479         // restore the blob's angle
02480         pTool->RenderBlob(m_pDragBlob);
02481         m_pDragBlob->SetAngle(m_BlobAngle);
02482 
02483         // re-render the bitmaps back to what they were
02484         NodeListItem * pItem = (NodeListItem *)m_pDragBlob->GetList()->GetHead();
02485 
02486         Document * pDoc = Document::GetCurrent();
02487 
02488         while (pItem)
02489         {
02490             ((NodeBevelController *)pItem->pNode)->RegenerateNode(NULL, FALSE);
02491             ((NodeBevelController *)pItem->pNode)->ReleaseCached();
02492 
02493             pItem = (NodeListItem *)m_pDragBlob->GetList()->GetNext(pItem);
02494         }
02495         
02496         if (pDoc)
02497         {
02498             if (pSpread)
02499             {
02500                 pDoc->ForceRedraw(pSpread, 
02501                     m_pDragBlob->GetRect());
02502             }
02503             else
02504             {
02505                 pSpread = Document::GetSelectedSpread();
02506 
02507                 pDoc->ForceRedraw(pSpread, 
02508                     m_pDragBlob->GetRect());
02509             }
02510         }       
02511 
02512         pTool->RenderBlob(m_pDragBlob);
02513 
02514         // GetApplication()->ServiceRendering();
02515     }
02516     else
02517     {
02518         // success ! replace all attributes in the blob's list with the new angle
02519         // get the operation descriptor for the bevel change
02520         pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpChangeBevelLightAngle));
02521 
02522         Param.pNodes         = m_pDragBlob->GetList();
02523         Param.NewLightAngle  = m_pDragBlob->GetAngle();
02524         Param.OldLightAngle  = m_BlobAngle;
02525 
02526         if (pTool)
02527         {
02528             pTool->RenderToolBlobs(pSpread, NULL);
02529             pTool->SetBlobRendering(FALSE);
02530         }
02531 
02532         // invoke the op
02533         if (pOpDesc)
02534         {
02535             pOpDesc->Invoke(&Param);
02536         }
02537         
02538         if (pTool)
02539         {
02540             pTool->SetBlobRendering(TRUE);
02541             pTool->SetupBlobList();
02542             pTool->RenderToolBlobs(pSpread, NULL);
02543         }
02544     }
02545 
02546     m_bAmDragging = FALSE;
02547 
02548     EndDrag();
02549 }
02550 
02551 /********************************************************************************************
02552 
02553 >   void BevelInfoBarOp::LoadBevelTypeComboStrings(BOOL bMany)
02554 
02555 
02556     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02557     Created:    26/7/99
02558     Inputs:     
02559     Outputs:    -
02560     Returns:    -
02561     Purpose:    Loads the values into the bevel type combo
02562     
02563 ********************************************************************************************/
02564 
02565 void BevelInfoBarOp::LoadBevelTypeComboStrings(BOOL bMany)
02566 {
02567     // first, clear the combo
02568     DeleteAllValues( _R(IDC_BEVEL_TYPE_COMBO));
02569     
02570     // now load in the combo text entries
02571     String_64 Str;
02572 
02573     INT32 Offset = 0;
02574 
02575     // have we a many ??
02576     if (bMany)
02577     {
02578         Str.Load( _R(IDS_BEVELSTRING_MANY) );
02579         SetStringGadgetValue(_R(IDC_BEVEL_TYPE_COMBO), Str, TRUE, 0);
02580         Offset = 1;
02581     }
02582                 
02583     // load the bevel types
02584     for ( INT32 i=0; i<NumBevelTypes; i++ )
02585     {
02586         Str.Load( BevelTypes[i].StringID );
02587         SetStringGadgetValue(_R(IDC_BEVEL_TYPE_COMBO), Str, TRUE, i + Offset);
02588     }
02589                 
02590     SetComboListLength(_R(IDC_BEVEL_TYPE_COMBO));
02591 }
02592                 
02593 /********************************************************************************************
02594 
02595 >   void BevelInfoBarOp::LoadBevelDirectionComboStrings(BOOL bMany)
02596 
02597 
02598     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02599     Created:    26/7/99
02600     Inputs:     
02601     Outputs:    -
02602     Returns:    -
02603     Purpose:    Loads the values into the bevel type combo
02604     
02605 ********************************************************************************************/
02606 
02607 void BevelInfoBarOp::LoadBevelDirectionComboStrings(BOOL bMany)
02608 {
02609     // first, clear the combo
02610     /*
02611     DeleteAllValues( _R(IDC_BEVEL_INNER_COMBO));
02612     
02613     // now load in the combo text entries
02614     String_64 Str;
02615 
02616     INT32 Offset = 0;
02617 
02618     // have we a many ??
02619     if (bMany)
02620     {
02621         Str.Load( _R(IDS_BEVELSTRING_MANY) );
02622         SetStringGadgetValue(_R(IDC_BEVEL_INNER_COMBO), &Str, TRUE, 0);
02623         Offset = 1;
02624     }
02625                 
02626     // load the direction combo strings
02627     for (INT32 i=0; i<NumInnerTypes; i++)
02628     {
02629         Str.Load( InnerTypes[i] );
02630         SetStringGadgetValue(_R(IDC_BEVEL_INNER_COMBO), &Str, TRUE, i + Offset);
02631     }
02632                 
02633     SetComboListLength(_R(IDC_BEVEL_INNER_COMBO));              
02634     */
02635 }
02636 
02637 /********************************************************************************************
02638 
02639 >   void BevelInfoBarOp::UpdateInnerOuterButtons(BOOL bMany, BOOL bOuter, BOOL bNoSelection)
02640 
02641 
02642     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02643     Created:    26/7/99
02644     Inputs:     
02645     Outputs:    -
02646     Returns:    -
02647     Purpose:    Updates the inner / outer buttons on the info bar
02648     
02649 ********************************************************************************************/
02650 
02651 void BevelInfoBarOp::UpdateInnerOuterButtons(BOOL bMany, BOOL bOuter, BOOL bNoSelection)
02652 {
02653     m_bButtonIsInner = FALSE;
02654     m_bButtonIsOuter = FALSE;
02655 
02656     if (bNoSelection)
02657     {
02658         EnableGadget(_R(IDC_BTN_BEVELOUTER), FALSE);
02659         EnableGadget(_R(IDC_BTN_BEVELINNER), FALSE);
02660         SetBoolGadgetSelected(_R(IDC_BTN_BEVELOUTER), FALSE);
02661         SetBoolGadgetSelected(_R(IDC_BTN_BEVELINNER), FALSE);
02662     }
02663     else if (bMany)
02664     {
02665         EnableGadget(_R(IDC_BTN_BEVELOUTER), TRUE);
02666         EnableGadget(_R(IDC_BTN_BEVELINNER), TRUE);
02667 
02668         SetBoolGadgetSelected(_R(IDC_BTN_BEVELOUTER), FALSE);
02669         SetBoolGadgetSelected(_R(IDC_BTN_BEVELINNER), FALSE);
02670     }
02671     else if (bOuter)
02672     {
02673         EnableGadget(_R(IDC_BTN_BEVELOUTER), TRUE);
02674         EnableGadget(_R(IDC_BTN_BEVELINNER), TRUE);
02675 
02676         SetBoolGadgetSelected(_R(IDC_BTN_BEVELOUTER), TRUE);
02677         SetBoolGadgetSelected(_R(IDC_BTN_BEVELINNER), FALSE);
02678         m_bButtonIsOuter = TRUE;
02679     }
02680     else
02681     {
02682         EnableGadget(_R(IDC_BTN_BEVELOUTER), TRUE);
02683         EnableGadget(_R(IDC_BTN_BEVELINNER), TRUE);
02684 
02685         SetBoolGadgetSelected(_R(IDC_BTN_BEVELOUTER), FALSE);
02686         SetBoolGadgetSelected(_R(IDC_BTN_BEVELINNER), TRUE);
02687         m_bButtonIsInner = TRUE;
02688     }
02689 }
02690 
02691 
02692 /********************************************************************************************
02693 
02694 >   MILLIPOINT BevelInfoBarOp::GetSliderDepth()
02695 
02696 
02697     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02698     Created:    26/7/99
02699     Inputs:     
02700     Outputs:    Depth in millipoints
02701     Returns:    -
02702     Purpose:    Sets the slider for depth settings (logarithmic)
02703     
02704 ********************************************************************************************/
02705 MILLIPOINT BevelInfoBarOp::GetSliderDepth()
02706 {
02707     SetGadgetRange(_R(IDC_BEVELSLIDER), BEVEL_DEPTH_MIN, BEVEL_DEPTH_MAX);
02708     MILLIPOINT Value = GetLongGadgetValue(_R(IDC_BEVELSLIDER), BEVEL_DEPTH_MIN,
02709         BEVEL_DEPTH_MAX);
02710     
02711     // make the value appear between 0 and 1
02712     if (Value > BEVEL_DEPTH_MAX)
02713         Value = BEVEL_DEPTH_MAX;
02714 
02715     double dValue = Value - BEVEL_DEPTH_MIN;
02716     dValue /= (double)(BEVEL_DEPTH_MAX - BEVEL_DEPTH_MIN);
02717     // dValue = 1.0 - dValue;
02718 
02719     // change the profile
02720     BevelSliderProfile.SetBias(-BevelSliderProfile.GetBias());
02721     double dSliderValue = BevelSliderProfile.MapZeroToOne((AFp)dValue);
02722     BevelSliderProfile.SetBias(-BevelSliderProfile.GetBias());
02723         
02724     dSliderValue *= (double)(BEVEL_DEPTH_MAX - BEVEL_DEPTH_MIN);
02725     dSliderValue += BEVEL_DEPTH_MIN;
02726 
02727     return (INT32)dSliderValue;
02728 }
02729 
02730 /********************************************************************************************
02731 
02732 >   MILLIPOINT BevelInfoBarOp::SetSliderDepth(MILLIPOINT Depth)
02733 
02734 
02735     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02736     Created:    26/7/99
02737     Inputs:     
02738     Outputs:    Depth in millipoints
02739     Returns:    -
02740     Purpose:    Sets the slider for depth settings (logarithmic)
02741     
02742 ********************************************************************************************/
02743 void BevelInfoBarOp::SetSliderDepth(MILLIPOINT Value)
02744 {
02745     // make the value appear between 0 and 1
02746     if (Value > BEVEL_DEPTH_MAX)
02747         Value = BEVEL_DEPTH_MAX;
02748 
02749     if (Value < BEVEL_DEPTH_MIN)
02750         Value = BEVEL_DEPTH_MIN;
02751 
02752     double dValue = Value - BEVEL_DEPTH_MIN;
02753     dValue /= (double)(BEVEL_DEPTH_MAX - BEVEL_DEPTH_MIN);
02754 
02755     // change the profile
02756     double dSliderValue = 0;
02757     
02758     dSliderValue = BevelSliderProfile.MapZeroToOne((AFp)(dValue));
02759     // dSliderValue = 1.0 - dSliderValue;
02760         
02761     dSliderValue *= (double)(BEVEL_DEPTH_MAX - BEVEL_DEPTH_MIN);
02762     dSliderValue += BEVEL_DEPTH_MIN;
02763 
02764     SetGadgetRange(_R(IDC_BEVELSLIDER), BEVEL_DEPTH_MIN, BEVEL_DEPTH_MAX);
02765 
02766     SetLongGadgetValue(_R(IDC_BEVELSLIDER), (INT32)dSliderValue);
02767 }
02768 
02769 
02770 
02771 
02772 
02773                 
02774 
02775 
02776 
02777 
02778 
02779 
02780 
02781 

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