qualops.cpp

Go to the documentation of this file.
00001 // $Id: qualops.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 /*
00100 //*/
00101 
00102 #include "camtypes.h"
00103 #include "qualops.h"
00104 #include "menuops.h"
00105 //#include "mario.h"
00106 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "ensure.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "dialogop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 //#include "resource.h"
00111 //#include "rik.h"
00112 //#include "bars.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 //#include "barsdlgs.h"
00114 #include "bubbleid.h"
00115 #include "brushmsg.h"
00116 
00117 
00118 CC_IMPLEMENT_DYNAMIC(QualitySliderDescriptor, OpDescriptor)
00119 CC_IMPLEMENT_DYNCREATE(OpQuality, Operation)
00120 
00121 #define new CAM_DEBUG_NEW
00122 
00123 
00124 /********************************************************************************************
00125 
00126 >   QualitySliderDescriptor::QualitySliderDescriptor(UINT32 toolID,
00127                                                     UINT32 txID,
00128                                                     CCRuntimeClass* Op,
00129                                                     TCHAR* tok,
00130                                                     pfnGetState gs,
00131                                                     UINT32 helpId,
00132                                                     UINT32 bubbleID,
00133                                                     UINT32 resourceID,
00134                                                     UINT32 controlID,
00135                                                     BOOL ReceiveMessages,
00136                                                     BOOL Smart,
00137                                                     BOOL Clean)
00138 
00139     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00140     Created:    2/11/94
00141     Inputs:     As for OpDescriptor
00142     Purpose:    Builds a new Quality Slider Op Descriptor
00143     SeeAlso:    OpDescriptor::OpDescriptor
00144 
00145 ********************************************************************************************/
00146 
00147 QualitySliderDescriptor::QualitySliderDescriptor(
00148                             UINT32 toolID,                    // Tool (Module) Identifier
00149                             UINT32 txID,                      // String Resource ID
00150                             CCRuntimeClass* Op,             // pointer to the Op's runtime class object
00151                             TCHAR* tok,                     // pointer to the token string
00152                             pfnGetState gs,                 // pointer to the GetState function
00153                             UINT32 helpId,              // help identifier 
00154                             UINT32 bubbleID,                // string resource for bubble help
00155                             UINT32 resourceID,          // resource ID
00156                             UINT32 controlID,               // control ID within resource
00157                             BOOL ReceiveMessages,       
00158                             BOOL Smart, 
00159                             BOOL Clean 
00160                            )
00161     : OpDescriptor(toolID, txID, Op, tok, gs, helpId, bubbleID, resourceID, controlID,
00162                     ReceiveMessages, Smart, Clean, 0, GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE)
00163 {
00164     // Does nothing
00165 }
00166 
00167 
00168      
00169 
00170 /********************************************************************************************
00171 
00172 >   void QualitySliderDescriptor::OnControlCreate(OpDescControlCreateMsg* CreateMsg)
00173 
00174     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00175     Created:    2/11/94
00176     Inputs:     CreateMsg - Details about the control being created
00177     Purpose:    Gets called when the control is first created to allow me to init it.
00178 
00179 ********************************************************************************************/
00180 
00181 void QualitySliderDescriptor::OnControlCreate(OpDescControlCreateMsg* CreateMsg)
00182 {
00183     // Get the dialog op details I need
00184     DialogOp* pDialogOp = CreateMsg->pDlgOp;
00185     CGadgetID GadgetID = CreateMsg->SetGadgetID;
00186 
00187     // And ask the control to use bitmaps
00188     pDialogOp->SetGadgetRange(GadgetID, 10, 110, 25);
00189     BOOL IsHorizontal = TRUE;
00190     if  (pDialogOp->IsKindOf(CC_RUNTIME_CLASS(DialogBarOp)))
00191          IsHorizontal = ((DialogBarOp *) pDialogOp)->IsHorizontal();
00192     
00193     if(IsHorizontal)
00194         pDialogOp->SetGadgetBitmaps(GadgetID, _R(IDB_QUALITYBASE),_R(IDB_QUALITYSLIDER));
00195     else
00196         pDialogOp->SetGadgetBitmaps(GadgetID, _R(IDB_QUALITYBASEVERT), _R(IDB_QUALITYSLIDERVERT));
00197 
00198     // If there is a view, set the position of the slider according to the
00199     // selected view's view quality
00200     DocView* pDocView = DocView::GetSelected();
00201     INT32 NewQuality;
00202     if (pDocView!=NULL)
00203     {
00204         // Ask the view about its view quality and set the sliders position
00205         NewQuality = pDocView->RenderQuality.GetQuality();
00206     }
00207     else
00208     {
00209         // Use the default quality value
00210         NewQuality = Quality::DefaultQuality.QualityValue;
00211     }
00212 
00213     // Set the slider position
00214     pDialogOp->SetLongGadgetValue(GadgetID, NewQuality /*110-NewQuality+10*/);
00215 }
00216 
00217 
00218 
00219 /********************************************************************************************
00220 
00221 >   BOOL QualitySliderDescriptor::OnDocViewMsg(DocView* pDocView, DocViewMsg::DocViewState State)
00222 
00223     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00224     Created:    4/11/94
00225     Inputs:     pDocView - The new docview that is becoming active.
00226     Returns:    TRUE if it happened
00227     Purpose:    Respond to a DocView changing message
00228 
00229 ********************************************************************************************/
00230 
00231 BOOL QualitySliderDescriptor::OnDocViewMsg(DocView* pDocView, DocViewMsg::DocViewState State)
00232 {
00233     // Only respond to the DocView changing
00234     if (State==DocViewMsg::SELCHANGED)
00235     {
00236         // see if it is valid
00237         if (pDocView != NULL)
00238         {
00239             // Its OK, change the sliders
00240             INT32 NewQuality = pDocView->RenderQuality.GetQuality();
00241 
00242             // update all slider controls that show the view quality
00243             List Gadgets;
00244             if (BuildGadgetList(&Gadgets))
00245             {
00246                 // Found some. Set the controls position according to the quality
00247                 GadgetListItem* pGadgetItem = (GadgetListItem*) Gadgets.GetHead();
00248 
00249                 while (pGadgetItem!=NULL)
00250                 {
00251                     // Set the sliders position
00252                     pGadgetItem->pDialogOp->SetLongGadgetValue(pGadgetItem->gidGadgetID, NewQuality /*110-NewQuality+10*/);
00253 
00254                     // go find the next gadget
00255                     pGadgetItem = (GadgetListItem*) Gadgets.GetNext(pGadgetItem);
00256                 }
00257         
00258                 // Clean out the list
00259                 Gadgets.DeleteAll();
00260             }
00261         }
00262     }
00263     return TRUE;
00264 }
00265 
00266 
00267 
00268 /********************************************************************************************
00269 
00270 >   void QualitySliderDescriptor::OnSliderSet(OpDescControlMsg* SelChangedMsg)
00271 
00272     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00273     Created:    2/11/94
00274     Inputs:     SelChangedMsg - The message details
00275     Purpose:    Informs us when the slider position changes
00276 
00277 ********************************************************************************************/
00278 
00279 void QualitySliderDescriptor::OnSliderSet(OpDescControlMsg* SelChangedMsg)
00280 {
00281     // Go find the details we need
00282     DialogOp* pDialogOp = SelChangedMsg->pDlgOp;
00283     CGadgetID GadgetID = SelChangedMsg->SetGadgetID;
00284 
00285     // get the position of the slider
00286     BOOL Valid;
00287     INT32 NewPos = pDialogOp->GetLongGadgetValue(GadgetID, 10, 110, 0, &Valid);
00288 
00289     // If it worked, tell the operation
00290     if (Valid)
00291     {
00292         // Set the opdescriptors idea of the current slider position
00293         // and call the operation
00294 //      CurrentSliderPos = 110 - NewPos + 10;
00295         CurrentSliderPos = NewPos;
00296         Invoke();
00297     }
00298 }
00299 
00300 
00301 /********************************************************************************************
00302 
00303 >   OpState QualitySliderDescriptor::GetState(String_256*, OpDescriptor*)
00304 
00305     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00306     Created:    2/11/94
00307     Inputs:     None used
00308     Returns:    Opstate
00309     Purpose:    Makes the opdescriptor always available
00310 
00311 ********************************************************************************************/
00312 
00313 OpState QualitySliderDescriptor::GetState(String_256*, OpDescriptor*)
00314 {
00315     // The state is unchanged
00316     OpState Blobby;
00317     return Blobby;
00318 }
00319 
00320 
00321 
00322 
00323 /********************************************************************************************
00324 
00325 >   void QualitySliderDescriptor::Update()
00326 
00327     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00328     Created:    23/3/95
00329     Purpose:    Updates all the slider controls if the view quality has been changed by an
00330                 outside influence (eg when loading a new document)
00331 
00332 ********************************************************************************************/
00333 
00334 void QualitySliderDescriptor::Update()
00335 {
00336     // Get the "selected" DocView, ie. the view that the user has made top-most.
00337     DocView* pDocView = DocView::GetSelected();
00338     if (pDocView!=NULL)
00339     {
00340         // Find the Quality slider descriptot
00341         OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor( OPTOKEN_QUALITYSLIDER );
00342     
00343         // Update it with values of the Selected DocView.
00344         if (pOpDesc!= NULL)
00345             ((QualitySliderDescriptor*) pOpDesc)->OnQualityChanged(pDocView);
00346     }
00347 }
00348 
00349 
00350 /********************************************************************************************
00351 
00352 >   void QualitySliderDescriptor::OnQualityChanged(DocView* pView)
00353 
00354     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00355     Created:    23/3/95
00356     Inputs:     pView - the docview to look at
00357     Purpose:    Updates all the sliders visible sliders so that they show the changed
00358                 view quality.
00359 
00360 ********************************************************************************************/
00361 
00362 void QualitySliderDescriptor::OnQualityChanged(DocView* pView)
00363 {
00364     // see if it is valid
00365     if (pView != NULL)
00366     {
00367         // Its OK, change the sliders
00368         INT32 NewQuality = pView->RenderQuality.GetQuality();
00369 
00370         // update all slider controls that show the view quality
00371         List Gadgets;
00372         if (BuildGadgetList(&Gadgets))
00373         {
00374             // Found some. Set the controls position according to the quality
00375             GadgetListItem* pGadgetItem = (GadgetListItem*) Gadgets.GetHead();
00376 
00377             while (pGadgetItem!=NULL)
00378             {
00379                 // Set the sliders position
00380                 pGadgetItem->pDialogOp->SetLongGadgetValue(pGadgetItem->gidGadgetID, /*110-NewQuality+10*/ NewQuality);
00381 
00382                 // go find the next gadget
00383                 pGadgetItem = (GadgetListItem*) Gadgets.GetNext(pGadgetItem);
00384             }
00385     
00386             // Clean out the list
00387             Gadgets.DeleteAll();
00388         }
00389     }
00390 }
00391 
00392 /********************************************************************************************
00393 
00394 >   BOOL OpQuality::Init()
00395 
00396     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00397     Created:    2/11/94
00398     Returns:    TRUE if the Quality Op was started ok
00399     Purpose:    Creates all the opDescriptors that call this operation.
00400 
00401 ********************************************************************************************/
00402 
00403 BOOL OpQuality::Init()
00404 {
00405     // Register our default quality preference - we default to maximum quality.
00406     Camelot.DeclareSection( _T("Rendering"), 20 ); 
00407     Quality::DefaultQuality.QualityValue = QUALITY_MAX;
00408     Camelot.DeclarePref( _T("Rendering"), _T("DefaultQuality"), 
00409                         &Quality::DefaultQuality.QualityValue, 10, QUALITY_MAX); 
00410 
00411     // Create a new OpDescriptor for the slider
00412     QualitySliderDescriptor* pOpDesc = new QualitySliderDescriptor(0,
00413                                     _R(IDS_VIEWQUALITY), 
00414                                     CC_RUNTIME_CLASS(OpQuality), 
00415                                     OPTOKEN_QUALITYSLIDER,
00416                                     QualitySliderDescriptor::GetState, 
00417                                     0, 
00418                                     _R(IDBBL_VIEWQUALITYSLIDER),
00419                                     _R(IDC_QUALITYSLIDER),
00420                                     _R(IDC_QUALITYSLIDER));
00421 
00422     // check that it worked
00423     if (pOpDesc==NULL)
00424         return FALSE;
00425 
00426     // and do the same for the menu option descriptors
00427     if (!Operation::RegisterOpDescriptor(
00428                         0,
00429                         _R(IDS_QUALITY_ANTI_ALIASED),
00430                         CC_RUNTIME_CLASS(OpQuality),
00431                         OPTOKEN_QUALITYANTIALIASED,
00432                         OpQuality::GetState,
00433                         0,                              // help ID
00434                         _R(IDBBL_QUALITYANTIALIAS),         // bubble help
00435                         _R(IDD_BARCONTROLSTORE),            // resource ID
00436                         _R(IDC_BTN_WINDOWQUALITYAA),        // control ID
00437                         SYSTEMBAR_WINDOW,               // Bar ID
00438                         TRUE,                           // Recieve system messages
00439                         FALSE,                          // Smart duplicate operation
00440                         TRUE,                           // Clean operation
00441                         0,                              // No vertical counterpart
00442                         0,                              // String for one copy only error
00443                         (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC), // Auto state flags
00444                         TRUE                            // tickable
00445 
00446                         ))
00447         return FALSE;
00448 
00449     if (!Operation::RegisterOpDescriptor(
00450                         0,
00451                         _R(IDS_QUALITY_NORMAL),
00452                         CC_RUNTIME_CLASS(OpQuality),
00453                         OPTOKEN_QUALITYNORMAL,
00454                         OpQuality::GetState,
00455                         0,                              // help ID
00456                         _R(IDBBL_QUALITYNORMAL),            // bubble help
00457                         _R(IDD_BARCONTROLSTORE),            // resource ID
00458                         _R(IDC_BTN_WINDOWQUALITYNORMAL),    // control ID
00459                         SYSTEMBAR_WINDOW,               // Bar ID
00460                         TRUE,                           // Recieve system messages
00461                         FALSE,                          // Smart duplicate operation
00462                         TRUE,                           // Clean operation
00463                         0,                              // No vertical counterpart
00464                         0,                              // String for one copy only error
00465                         (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC), // Auto state flags
00466                         TRUE                            // tickable
00467                         ))
00468         return FALSE;
00469 
00470     if (!Operation::RegisterOpDescriptor(
00471                         0,
00472                         _R(IDS_QUALITY_SIMPLE),
00473                         CC_RUNTIME_CLASS(OpQuality),
00474                         OPTOKEN_QUALITYSIMPLE,
00475                         OpQuality::GetState,
00476                         0,                              // help ID 
00477                         _R(IDBBL_QUALITYSIMPLE),            // bubble help
00478                         _R(IDD_BARCONTROLSTORE),            // resource ID
00479                         _R(IDC_BTN_WINDOWQUALITYSIMPLE),    // control ID
00480                         SYSTEMBAR_WINDOW,               // Bar ID
00481                         TRUE,                           // Recieve system messages
00482                         FALSE,                          // Smart duplicate operation
00483                         TRUE,                           // Clean operation
00484                         0,                              // No vertical counterpart
00485                         0,                              // String for one copy only error
00486                         (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC), // Auto state flags
00487                         TRUE                            // tickable
00488                         ))
00489         return FALSE;
00490 
00491     if (!Operation::RegisterOpDescriptor(
00492                         0,
00493                         _R(IDS_QUALITY_OUTLINE),
00494                         CC_RUNTIME_CLASS(OpQuality),
00495                         OPTOKEN_QUALITYOUTLINE,
00496                         OpQuality::GetState,
00497                         0,                              // help ID 
00498                         _R(IDBBL_QUALITYOUTLINE),           // bubble help
00499                         _R(IDD_BARCONTROLSTORE),            // resource ID
00500                         _R(IDC_BTN_WINDOWQUALITYOUTLINE),   // control ID
00501                         SYSTEMBAR_WINDOW,               // Bar ID
00502                         TRUE,                           // Recieve system messages
00503                         FALSE,                          // Smart duplicate operation
00504                         TRUE,                           // Clean operation
00505                         0,                              // No vertical counterpart
00506                         0,                              // String for one copy only error
00507                         (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC), // Auto state flags
00508                         TRUE                            // tickable
00509                         ))
00510         return FALSE;
00511 
00512     return TRUE;
00513 }
00514 
00515 
00516 // Operations to control Quality options
00517 // there is one operation which is used for all values
00518 
00519 
00520 
00521 /*******************************************************************
00522 
00523 >   void OpQuality::Do(OpDescriptor*)
00524 
00525     Author:     Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
00526     Created:    22/4/94
00527     Inputs:     None
00528     Outputs:    None
00529     Returns:    None
00530     Purpose:    Sets quality level on current view.
00531     Errors:     None
00532 
00533 *******************************************************************/
00534 
00535 void OpQuality::Do(OpDescriptor* OpDesc)
00536 {
00537     // Find out about the view
00538     DocView *pDocView = DocView::GetSelected();
00539     if (pDocView == NULL)
00540         return;
00541 
00542     // Find out the new quality setting
00543     INT32 NewQuality = ConvertToValue(OpDesc);
00544 
00545     // Use this as the new default quality.
00546     Quality::DefaultQuality.SetQuality(NewQuality);
00547 
00548     // tell the selected DocView and get it to redraw itself if it changed
00549     const BOOL Changed = pDocView->RenderQuality.SetQuality(NewQuality);
00550 
00551     // redraw the document
00552     if (Changed)
00553     {
00554         CBitmapCache* pBC = Camelot.GetBitmapCache();
00555 //      pBC->DeInitialise();                        // Brute force cache clear
00556         if ( pBC )
00557             pBC->RemoveLowPriorityBitmaps();        // Remove all cached bitmaps but not more permanent ones...???
00558 
00559         pDocView->ForceRedraw();
00560         BROADCAST_TO_ALL(ScreenChangeMsg());
00561     }
00562     
00563 
00564     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_QUALITYSLIDER);
00565     if (pOpDesc!=NULL)
00566     {
00567         // Found the opdescriptor. Now find all the gadgets associated with it
00568         List Gadgets;
00569         if (pOpDesc->BuildGadgetList(&Gadgets))
00570         {
00571             // Found some. Set the controls position according to the quality
00572             GadgetListItem* pGadgetItem = (GadgetListItem*) Gadgets.GetHead();
00573 
00574             while (pGadgetItem!=NULL)
00575             {
00576                 // Set the sliders position
00577                 pGadgetItem->pDialogOp->SetLongGadgetValue(pGadgetItem->gidGadgetID, NewQuality /*110-NewQuality+10*/);
00578 
00579                 // go find the next gadget
00580                 pGadgetItem = (GadgetListItem*) Gadgets.GetNext(pGadgetItem);
00581             }
00582             
00583             // Clean out the list
00584             Gadgets.DeleteAll();
00585         }
00586     }
00587 
00588     // and finish
00589     End();
00590 }
00591 
00592 /*******************************************************************
00593 
00594 >   OpQuality::OpQuality()
00595 
00596     Author:     Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
00597     Created:    22/4/94
00598     Inputs:
00599     Outputs:
00600     Returns:
00601     Purpose:    Constructor for OpQuality operation. It is not undoable.
00602     Errors:     None
00603 
00604 *******************************************************************/
00605 
00606 OpQuality::OpQuality()
00607 {
00608 }
00609 
00610 
00611 
00612 /*******************************************************************
00613 
00614 >   OpState OpQuality::GetState(String_256*, OpDescriptor*)
00615 
00616     Author:     Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
00617     Created:    7/4/94
00618     Inputs:
00619     Outputs:
00620     Returns:
00621     Purpose:    This item is always available.
00622     Errors:     None
00623 
00624 *******************************************************************/
00625 
00626 OpState OpQuality::GetState(String_256*, OpDescriptor* OpDesc)
00627 {
00628     OpState OpSt;
00629 
00630     const DocView *pDocView = DocView::GetSelected();
00631 
00632     if (
00633         pDocView &&
00634         ( pDocView->RenderQuality.GetQuality() == ConvertToValue( OpDesc ) )
00635        )
00636         OpSt.Ticked = TRUE;
00637 
00638     return OpSt;
00639 }
00640 
00641 /********************************************************************************************
00642 
00643 >   INT32 OpQuality::ConvertToValue( OpDescriptor* OpDesc )
00644 
00645     Author:     Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
00646     Created:    22/4/94
00647     Inputs:     A pointer to an opdescriptor.
00648     Outputs:    -
00649     Returns:    Numeric value for quality based on token in opdescriptor.
00650     Purpose:    This is how we  use one operation for many levels of quality.
00651     Scope:      Private, Static
00652 
00653 ********************************************************************************************/
00654 
00655 INT32 OpQuality::ConvertToValue( OpDescriptor* OpDesc )
00656 {
00657     if( OpDesc->Token == String(OPTOKEN_QUALITYANTIALIASED) )
00658         return QUALITY_LEVEL_ANTI;
00659     
00660     if( OpDesc->Token == String(OPTOKEN_QUALITYNORMAL) )
00661         return QUALITY_LEVEL_NORMAL;
00662     
00663     if (OpDesc->Token == String(OPTOKEN_QUALITYSIMPLE))
00664         return QUALITY_LEVEL_SIMPLE;
00665     
00666     if (OpDesc->Token == String(OPTOKEN_QUALITYOUTLINE))
00667         return QUALITY_LEVEL_OUTLINE;
00668 
00669     if (OpDesc->Token == String(OPTOKEN_QUALITYSLIDER))
00670         return ((QualitySliderDescriptor*)OpDesc)->CurrentSliderPos;
00671 
00672     TRACE( _T("Bad opdesc token %s\n"), (TCHAR *)(OpDesc->Token) );
00673     ENSURE(FALSE, "OpQuality passed bad opdesc");
00674 
00675     return 100;         // default to Normal
00676 }

Generated on Sat Nov 10 03:46:39 2007 for Camelot by  doxygen 1.4.4