biasgdgt.cpp

Go to the documentation of this file.
00001 // $Id: biasgdgt.cpp 1386 2006-06-28 17:49:55Z alex $
00002 //------------------------------------------------
00003 //  CBiasGainGadget.cpp
00004 //------------------------------------------------
00005 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00006 ================================XARAHEADERSTART===========================
00007  
00008                Xara LX, a vector drawing and manipulation program.
00009                     Copyright (C) 1993-2006 Xara Group Ltd.
00010        Copyright on certain contributions may be held in joint with their
00011               respective authors. See AUTHORS file for details.
00012 
00013 LICENSE TO USE AND MODIFY SOFTWARE
00014 ----------------------------------
00015 
00016 This file is part of Xara LX.
00017 
00018 Xara LX is free software; you can redistribute it and/or modify it
00019 under the terms of the GNU General Public License version 2 as published
00020 by the Free Software Foundation.
00021 
00022 Xara LX and its component source files are distributed in the hope
00023 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00024 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00025 See the GNU General Public License for more details.
00026 
00027 You should have received a copy of the GNU General Public License along
00028 with Xara LX (see the file GPL in the root directory of the
00029 distribution); if not, write to the Free Software Foundation, Inc., 51
00030 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00031 
00032 
00033 ADDITIONAL RIGHTS
00034 -----------------
00035 
00036 Conditional upon your continuing compliance with the GNU General Public
00037 License described above, Xara Group Ltd grants to you certain additional
00038 rights. 
00039 
00040 The additional rights are to use, modify, and distribute the software
00041 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00042 library and any other such library that any version of Xara LX relased
00043 by Xara Group Ltd requires in order to compile and execute, including
00044 the static linking of that library to XaraLX. In the case of the
00045 "CDraw" library, you may satisfy obligation under the GNU General Public
00046 License to provide source code by providing a binary copy of the library
00047 concerned and a copy of the license accompanying it.
00048 
00049 Nothing in this section restricts any of the rights you have under
00050 the GNU General Public License.
00051 
00052 
00053 SCOPE OF LICENSE
00054 ----------------
00055 
00056 This license applies to this program (XaraLX) and its constituent source
00057 files only, and does not necessarily apply to other Xara products which may
00058 in part share the same code base, and are subject to their own licensing
00059 terms.
00060 
00061 This license does not apply to files in the wxXtra directory, which
00062 are built into a separate library, and are subject to the wxWindows
00063 license contained within that directory in the file "WXXTRA-LICENSE".
00064 
00065 This license does not apply to the binary libraries (if any) within
00066 the "libs" directory, which are subject to a separate license contained
00067 within that directory in the file "LIBS-LICENSE".
00068 
00069 
00070 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00071 ----------------------------------------------
00072 
00073 Subject to the terms of the GNU Public License (see above), you are
00074 free to do whatever you like with your modifications. However, you may
00075 (at your option) wish contribute them to Xara's source tree. You can
00076 find details of how to do this at:
00077   http://www.xaraxtreme.org/developers/
00078 
00079 Prior to contributing your modifications, you will need to complete our
00080 contributor agreement. This can be found at:
00081   http://www.xaraxtreme.org/developers/contribute/
00082 
00083 Please note that Xara will not accept modifications which modify any of
00084 the text between the start and end of this header (marked
00085 XARAHEADERSTART and XARAHEADEREND).
00086 
00087 
00088 MARKS
00089 -----
00090 
00091 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00092 designs are registered or unregistered trademarks, design-marks, and/or
00093 service marks of Xara Group Ltd. All rights in these marks are reserved.
00094 
00095 
00096       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00097                         http://www.xara.com/
00098 
00099 =================================XARAHEADEREND============================
00100  */
00101 
00102 
00103 
00104 
00105 #include "camtypes.h"
00106 
00107 #include "biasgdgt.h"
00108 #include "bars.h"
00109 //#include "biasres.h"
00110 #include "biasdlg.h"
00111 
00112 //#include "ccomboud.h"         // this class now needs to know about CustomComboBoxControlDataItem
00113 //#include "app.h"              // for the new bitmap resources
00114 #include "fillval.h"
00115 
00116 // we'd best have this as well ....
00117 
00118 #define new CAM_DEBUG_NEW                   // use camelot new
00119 
00120 
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 
00131 // statics definitions
00132 
00133 const double  CBiasGainGadget::kBiasPresets_s[ eNumberOfPresets ]  =  { 0.0,  0.5, -0.5,  0.0,  0.0 };
00134 const double  CBiasGainGadget::kGainPresets_s[ eNumberOfPresets ]  =  { 0.0,  0.0,  0.0,  0.5, -0.5 };
00135 
00136 // CGS //////////////////////////////////////////////////////////////////////////////////////////
00137 
00138 // functions that set our beloved pointers ....
00139 
00140 void CBiasGainGadget::SetStartColour(DocColour* NewCol)
00141 {
00142     StartColour = NewCol;
00143 }
00144 
00145 void CBiasGainGadget::SetEndColour(DocColour* NewCol)
00146 {
00147     EndColour = NewCol;
00148 }
00149 
00150 void CBiasGainGadget::SetStartTransp(UINT32* NewTransp)
00151 {
00152     StartTransp = NewTransp;
00153 }
00154 
00155 void CBiasGainGadget::SetEndTransp(UINT32* NewTransp)
00156 {
00157     EndTransp = NewTransp;
00158 }
00159 
00160 void CBiasGainGadget::SetFillEffect(FillEffectAttribute* NewFillEffect)
00161 {
00162     if (FillEffect) delete (FillEffect);
00163     FillEffect = NewFillEffect;
00164 }
00165 
00166 // CGS //////////////////////////////////////////////////////////////////////////////////////////
00167 
00168 
00169 
00170     
00171 // standard object services ///////////////////////////////////////////////////////////////////////
00172 
00173 //-------------------------------------------------------------------------------------------------
00174 //  Author:     Harrison Ainsworth
00175 //  Date:       06/99
00176 //  Purpose:    Set each member to a default value.
00177 //-------------------------------------------------------------------------------------------------
00178 
00179 CBiasGainGadget::CBiasGainGadget ()
00180 //  : pOwningBar_m( 0 ),
00181     : GadgetID_m( 0 ),
00182       BubbleID_m( 0 ),
00183       StatusID_m( 0 ),
00184       pDialog_m( 0 )
00185 {
00186     useFillProfile = FALSE;
00187     useTranspFillProfile = FALSE;
00188 
00189     StartColour = NULL;
00190     EndColour = NULL;
00191     EndColour2 = NULL;
00192     EndColour3 = NULL;
00193     FillEffect = NULL;
00194     StartTransp = NULL;
00195     EndTransp = NULL;
00196     EndTransp2 = NULL;
00197     EndTransp3 = NULL;
00198 }
00199 
00200 
00201 /*//-------------------------------------------------------------------------------------------------
00202 //  Author:     Harrison Ainsworth
00203 //  Date:       06/99
00204 //  Purpose:    Set each member to a default value. except set DlgTitle_m with the input
00205 //-------------------------------------------------------------------------------------------------
00206 
00207 CBiasGainGadget::CBiasGainGadget ( const String_64& DlgTitle )
00208     : pOwningBar_m( 0 ),
00209       DlgTitle_m( DlgTitle ),
00210       GadgetID_m( 0 ),
00211       BubbleID_m( 0 ),
00212       StatusID_m( 0 ),
00213       pDialog_m( 0 )
00214 {
00215 }*/
00216 
00217 
00218 
00219 
00220 CBiasGainGadget::~CBiasGainGadget ()
00221 {
00222 
00223     if (FillEffect) delete (FillEffect);
00224     
00225     delete  pDialog_m;
00226 
00227 }
00228 
00229 
00230 
00231 
00232 
00233 
00234 
00235 
00236 /****************************************************************************************
00237 Function  : CBiasGainGadget::Init
00238 Author    : Mikhail Tatarnikov
00239 Purpose   : Initializes the gadget
00240 Returns   : void
00241 Exceptions: 
00242 Parameters: [in] DialogOp* pOwningDialog - the parent dialog;
00243             [in] CGadgetID GadgetID      - the gadget ID;
00244             [in] UINT32    BubbleID      - tooltip help string ID;
00245             [in] UINT32    StatusID      - status bar string ID.
00246 Notes     : 
00247 ****************************************************************************************/
00248 void CBiasGainGadget::Init(DialogOp* pOwningDialog, CGadgetID GadgetID, UINT32 BubbleID, UINT32 StatusID)
00249 {
00250     // check preconditions
00251     if( ( pOwningDialog != 0 ) && ( GadgetID != 0 ) && ( BubbleID != 0 ) && ( StatusID != 0 ) )
00252     {
00253         // set members
00254         pOwningDialog_m   = pOwningDialog;
00255         GadgetID_m        = GadgetID;
00256         InfobarGadgetID_m = (CGadgetID)-1;
00257         BubbleID_m        = BubbleID;
00258         StatusID_m        = StatusID;
00259     }
00260 }
00261 
00262 
00263 /****************************************************************************************
00264 Function  : CBiasGainGadget::Enable
00265 Author    : Mikhail Tatarnikov
00266 Purpose   : Enables/disables the gadget.
00267 Returns   : void
00268 Exceptions: 
00269 Parameters: [in] BOOL Enable - TRUE for enabling, FALSE for disabling.
00270 Notes     : 
00271 ****************************************************************************************/
00272 void CBiasGainGadget::Enable(BOOL Enable)
00273 {
00274     pOwningDialog_m->EnableGadget(GadgetID_m, Enable);
00275 }
00276 
00277 
00278 
00279 
00280 /****************************************************************************************
00281 Function  : CBiasGainGadget::GetPresetBiasGainValue
00282 Author    : Mikhail Tatarnikov
00283 Purpose   : Obtains the preset value based on its index
00284 Returns   : void
00285 Exceptions: 
00286 Parameters: [in]  WORD              Index - the index of preset to obtain;
00287             [out] CProfileBiasGain& Value - preset value for the index.
00288 Notes     : Reverse operation for FindPresetBiasGain().
00289 ****************************************************************************************/
00290 void CBiasGainGadget::GetPresetBiasGainValue(WORD Index, CProfileBiasGain& Value) const
00291 {
00292     // check preconditions
00293     if( Index <= WORD(eNumberOfPresets) )
00294     {
00295         Value.SetBiasGain( AFp( kBiasPresets_s[ Index ] ),  AFp( kGainPresets_s[ Index ] ) );
00296     }
00297 }
00298 
00299 
00300 
00301 /****************************************************************************************
00302 Function  : CBiasGainGadget::FindPresetBiasGain
00303 Author    : Mikhail Tatarnikov
00304 Purpose   : Finds a preset index based on the value, or -1 if couldn't find (custom preset).
00305 Returns   : INT32 - the found preset index.
00306 Exceptions: 
00307 Parameters: [in] CProfileBiasGain const& Value - the preset we'll search for.
00308 Notes     : Reverse operation for GetPresetBiasGainValue().
00309 ****************************************************************************************/
00310 INT32 CBiasGainGadget::FindPresetBiasGain(CProfileBiasGain const& Value) const
00311 {
00312     CProfileBiasGain preset;
00313     for (INT32 i = 0; i < (INT32)eNumberOfPresets; i++)
00314     {
00315         GetPresetBiasGainValue (i, preset);
00316         if (Value == preset)
00317             return i;                   // is a preset
00318     }
00319     
00320     return -1;      // is a custom
00321 }
00322 
00323 
00324 /****************************************************************************************
00325 Function  : CBiasGainGadget::ReInitialiseDialog
00326 Author    : Mikhail Tatarnikov
00327 Purpose   : Updates the dialog with a profile value
00328 Returns   : void
00329 Exceptions: 
00330 Parameters: [in] CProfileBiasGain* ReInitOn - the new value to display in the dialog;
00331             [in] BOOL              bMany    - 
00332 Notes     : 
00333 ****************************************************************************************/
00334 void CBiasGainGadget::ReInitialiseDialog(CProfileBiasGain* ReInitOn, BOOL bMany)
00335 {
00336     if (/*(ReInitOn != NULL) &&*/ (pDialog_m != NULL))
00337     {
00338         if ((ReInitOn != NULL) || (bMany == TRUE))
00339         {
00340             pDialog_m->ReInitialiseDialog (ReInitOn, bMany);
00341         }
00342     }
00343 }
00344 
00345 
00346 /****************************************************************************************
00347 Function  : CBiasGainGadget::GetCurrentDialogProfile
00348 Author    : Mikhail Tatarnikov
00349 Purpose   : Reads the dialog profile value
00350 Returns   : CProfileBiasGain - the value currently displayed in the dialog.
00351 Exceptions: 
00352 Parameters: None
00353 Notes     : The linked dialog MUST be open
00354 ****************************************************************************************/
00355 CProfileBiasGain CBiasGainGadget::GetCurrentDialogProfile()
00356 {
00357     ERROR3IF (!IsDialogOpen (), "The dialogue isn't open - something is seriously wrong!");
00358     return (pDialog_m->GetCurrentDialogProfile ());
00359 }
00360 
00361 
00362 /****************************************************************************************
00363 Function  : CBiasGainGadget::Message
00364 Author    : Mikhail Tatarnikov
00365 Purpose   : Message handling routine
00366 Returns   : void
00367 Exceptions: 
00368 Parameters: [in] DialogMsg* pMessage - a message to handle
00369 Notes     : 
00370 ****************************************************************************************/
00371 void  CBiasGainGadget::Message(DialogMsg* pMessage)
00372 {
00373     Message( pMessage,  CProfileBiasGain() );
00374 }
00375 
00376 
00377 /****************************************************************************************
00378 Function  : CBiasGainGadget::Message
00379 Author    : Mikhail Tatarnikov
00380 Purpose   : Message handling routing
00381 Returns   : void
00382 Exceptions: 
00383 Parameters: [in] DialogMsg*              pMessage - an incoming message;
00384             [in] CProfileBiasGain const& BiasGain -
00385 Notes     : 
00386 ****************************************************************************************/
00387 void CBiasGainGadget::Message(DialogMsg* pMessage, CProfileBiasGain const& BiasGain)
00388 {
00389 }
00390 
00391 
00392 /****************************************************************************************
00393 Function  : CBiasGainGadget::CloseDialog
00394 Author    : Mikhail Tatarnikov
00395 Purpose   : Close the related dialog
00396 Returns   : void
00397 Exceptions: 
00398 Parameters: None
00399 Notes     : 
00400 ****************************************************************************************/
00401 void  CBiasGainGadget::CloseDialog()
00402 {
00403     if( pDialog_m != 0 )
00404     {
00405         DialogMsg  MessageCancel( 0, DIM_CANCEL, GadgetID_m );
00406 
00407         pDialog_m->Message( &MessageCancel );
00408     }
00409 }
00410 
00411 
00412 
00413 
00414 
00415 
00416 
00417 
00418 /****************************************************************************************
00419 Function  : CBiasGainGadget::DialogHasOpened
00420 Author    : Mikhail Tatarnikov
00421 Purpose   : Handling the dialog opening event
00422 Returns   : void
00423 Exceptions: 
00424 Parameters: None
00425 Notes     : 
00426 ****************************************************************************************/
00427 void  CBiasGainGadget::DialogHasOpened()
00428 {
00429     // Put the gadet into the pushed state.
00430     pOwningDialog_m->SetLongGadgetValue(GadgetID_m, 1);
00431 }
00432 
00433 
00434 /****************************************************************************************
00435 Function  : CBiasGainGadget::DialogHasClosed()
00436 Author    : Mikhail Tatarnikov
00437 Purpose   : Handling the dialog closing event
00438 Returns   : void
00439 Exceptions: 
00440 Parameters: None
00441 Notes     : 
00442 ****************************************************************************************/
00443 void  CBiasGainGadget::DialogHasClosed()
00444 {
00445     delete  pDialog_m;
00446     pDialog_m  =  0;
00447 
00448     // Unpush the gadget.
00449     pOwningDialog_m->SetLongGadgetValue(GadgetID_m, 0);
00450 }
00451 
00452 
00453 /****************************************************************************************
00454 Function  : CBiasGainGadget::GetGadgetID
00455 Author    : Mikhail Tatarnikov
00456 Purpose   : Returns ID of the attached adget
00457 Returns   : CGadgetID - the attached gadget ID
00458 Exceptions: 
00459 Parameters: None
00460 Notes     : 
00461 ****************************************************************************************/
00462 CGadgetID CBiasGainGadget::GetGadgetID() const
00463 {
00464     return  GadgetID_m;
00465 }
00466 
00467 
00468 /****************************************************************************************
00469 Function  : CBiasGainGadget::GetDialogTitle
00470 Author    : Mikhail Tatarnikov
00471 Purpose   : Returns the dialog title
00472 Returns   : void
00473 Exceptions: 
00474 Parameters: [out] String_256& DlgTitle - the dialog title.
00475 Notes     : 
00476 ****************************************************************************************/
00477 void  CBiasGainGadget::GetDialogTitle(String_256& DlgTitle) const
00478 {
00479     DlgTitle.Load( BubbleID_m );
00480 }
00481 

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