bfxitem.cpp

Go to the documentation of this file.
00001 // $Id: bfxitem.cpp 1282 2006-06-09 09:46:49Z alex $
00002 //
00003 // BfxPlugIn implementation file
00004 // This implementes a Bfx plug-in item.
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 #include "camtypes.h"
00103 
00104 #include "bfxitem.h"
00105 //#include "app.h"      // GetApplication - in camtypes.h [AUTOMATICALLY REMOVED]
00106 
00107 //#include "plugres.h"  // _R(IDS_PLUGIN_)....
00108 #include "wbitmap.h"    // WinBitmap
00109 //#include "dibutil.h"  // DIBUtil - in camtypes.h [AUTOMATICALLY REMOVED]
00110 #include "bmpcomp.h"    // BitmapList
00111 //#include "fixmem.h"       // CCMalloc, CCFree
00112 //#include "progress.h" // Progress
00113 
00114 #include "bfxdlg2.h"    // BfxPlugInDlg
00115 
00116 // Place any IMPLEMENT type statements here
00117 CC_IMPLEMENT_DYNAMIC(BfxPlugIn, PlugInItem)
00118 CC_IMPLEMENT_DYNAMIC(BfxSpecialEffects, BfxPlugIn)
00119 CC_IMPLEMENT_DYNAMIC(BfxBrightnessContrast, BfxPlugIn)
00120 CC_IMPLEMENT_DYNAMIC(BfxResize, BfxPlugIn)
00121 CC_IMPLEMENT_DYNAMIC(BfxFlipAndRotate, BfxPlugIn)
00122 CC_IMPLEMENT_DYNAMIC(BfxColourDepth, BfxPlugIn)
00123 
00124 // We want better memory tracking
00125 #define new CAM_DEBUG_NEW
00126 
00127 /**************************************************************************************
00128 
00129 >   BfxPlugIn::BfxPlugIn()
00130 
00131     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00132     Created:    4/3/97
00133     Purpose:    Constructor for BfxPlugIn. 
00134 
00135 **************************************************************************************/
00136 
00137 BfxPlugIn::BfxPlugIn()
00138 {
00139 }
00140 
00141 /**************************************************************************************
00142 
00143 >   BfxPlugIn::~BfxPlugIn()
00144 
00145     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00146     Created:    4/3/97
00147     Purpose:    Destructor for BfxPlugIn. 
00148 
00149 **************************************************************************************/
00150 
00151 BfxPlugIn::~BfxPlugIn()
00152 {
00153 }
00154 
00155 /**************************************************************************************
00156 
00157 >   virtual String_32 BfxPlugIn::GetUniqueID() const
00158 
00159     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00160     Created:    4/3/97
00161     Returns:    A string containing a filetype. 
00162     Purpose:    A string which defines the unique identifier for the plug-ins that this
00163                 handler is interested in.
00164                 In this case being Bfx it is 'BFX:'.
00165 
00166 **************************************************************************************/
00167 
00168 String_32 BfxPlugIn::GetUniqueID() const
00169 {
00170     return TEXT("BFX:");
00171 }
00172 
00173 /**************************************************************************************
00174 
00175 >   virtual TypeOfPlugIn BfxPlugIn::GetTypeOfPlugIn() const
00176 
00177     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00178     Created:    4/3/97
00179     Returns:    Type of the plug-in. 
00180     Purpose:    A unique type for the plug-ins that this handler is interested in.
00181                 In this case being Bfx it is PLUGIN_BFX.
00182 
00183 **************************************************************************************/
00184 
00185 TypeOfPlugIn BfxPlugIn::GetTypeOfPlugIn() const
00186 {
00187     return PLUGIN_BFX;
00188 }
00189 
00190 /**************************************************************************************
00191 
00192 >   virtual BOOL BfxPlugIn::Apply(KernelBitmap *pInputBitmap, Document* pDocument,
00193                                   KernelBitmap **ppOutputBitmap = NULL)
00194 
00195     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00196     Created:    4/3/97
00197     Inputs:     pInputBitmap    the bitmap to apply the effect to
00198                 pDocument       the document this bitmap is in
00199     Outputs:    ppOutputBitmap  if specified, a pointer to the output bitmap generated
00200     Returns:    True if works ok, False otherwise.
00201     Purpose:    Applies a plug-in's bitmap effect to the specified bitmap. 
00202 
00203 **************************************************************************************/
00204 
00205 BOOL BfxPlugIn::Apply(KernelBitmap *pInputBitmap, Document* pDocument,
00206                       KernelBitmap **ppOutputBitmap)
00207 {
00208     ERROR2IF(pInputBitmap == NULL, FALSE, "BfxPlugIn::Apply null bitmap specified!");
00209     ERROR2IF(pDocument == NULL, FALSE, "BfxPlugIn::Apply null document specified!");
00210 
00211     KernelBitmap * pBmp = NULL;
00212     BOOL ok = ApplyBitmapEffect(pInputBitmap, pDocument, &pBmp);
00213 
00214     if (ppOutputBitmap)
00215         *ppOutputBitmap = pBmp;
00216     
00217     return ok;
00218 }
00219 
00220 /**************************************************************************************
00221 
00222 >   virtual BOOL BfxPlugIn::IsBitmapModeOk(INT32 ColourDepth)
00223 
00224     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00225     Created:    4/3/97
00226     Inputs:     ColourDepth     the colour depth or bits per pixel of the bitmap
00227                 GreyScale       only relevent if bitmap is 8bpp, True if greyscale
00228     Returns:    True if the bitmap is compatible and False otherwise.
00229     Purpose:    Checks to see if a plug-in can cope with the specified colour depth.
00230 
00231 **************************************************************************************/
00232 
00233 BOOL BfxPlugIn::IsBitmapModeOk(INT32 ColourDepth, BOOL GreyScale)
00234 {
00235     // Passed the checks ok so return TRUE
00236     return TRUE;
00237 }
00238 
00239 
00240 /**************************************************************************************
00241 
00242 >   BOOL BfxPlugIn::ApplyBitmapEffect(KernelBitmap *pInputBitmap, Document* pDocument,
00243                                       KernelBitmap **ppOutputBitmap = NULL)
00244 
00245     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00246     Created:    4/3/97
00247     Inputs:     pInputBitmap    the bitmap to apply the effect to
00248                 pDocument       the document this bitmap is in
00249     Outputs:    ppOutputBitmap  if specified, a pointer to the output bitmap generated
00250     Returns:    True if works ok, False otherwise.
00251     Purpose:    Applies a plug-in's bitmap effect to the specified bitmap.
00252 
00253 **************************************************************************************/
00254 
00255 BOOL BfxPlugIn::ApplyBitmapEffect(KernelBitmap *pInputBitmap, Document* pDocument,
00256                                   KernelBitmap **ppOutputBitmap)
00257 {
00258     ERROR2IF(pInputBitmap == NULL, FALSE, "BfxPlugIn::Apply null bitmap specified!");
00259 
00260     if (!pInputBitmap->DestroyXPEInfo())
00261         return FALSE;
00262 
00263     OpParam Param;
00264     Param.Param1 = (INT32)pInputBitmap;
00265     Param.Param2 = (INT32)pDocument;
00266     // give it a variable to return the result i.e. ok/cancel in
00267     BOOL ok = FALSE;
00268     Param.Output = &ok;
00269     // Obtain a pointer to the op descriptor for the create operation 
00270     OpDescriptor* pOpDesc = GetOpDescriptor();
00271     ERROR2IF(pOpDesc==NULL,FALSE,"Failed to find the BfxPlugInDlg OpDescriptor");
00272 
00273     // Only one live instance of the operation is allowed. It's probably a dialog 
00274     if (!MessageHandler::MessageHandlerExists(CC_RUNTIME_CLASS(BfxPlugInDlg)))
00275     {
00276         pOpDesc->Invoke(&Param);         
00277 
00278         // **** Warning ****
00279         // This assumes that the dialog box is modal and so the OpParam is still around
00280         // rather than having been deleted 
00281         // return the output bitmap to the caller
00282         if (ppOutputBitmap)
00283             *ppOutputBitmap = (KernelBitmap*)Param.Param1;
00284         // return the result i.e. ok/cancel to the caller
00285         return ok;
00286     }
00287 /*  else
00288     {
00289         BROADCAST_TO_CLASS(BfxMsg(pBitmap),DialogOp);   
00290     }   */
00291 
00292     // Everything seemed to work ok
00293     return TRUE;
00294 }
00295 
00296 /**************************************************************************************
00297 
00298 >   virtual BOOL BfxPlugIn::Apply(WinBitmap *pInputDIB, WinBitmap * pOutputDIB) 
00299 
00300     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00301     Created:    4/3/97
00302     Inputs:     pInputDIB       the source bitmap
00303     Outputs:    pOutputDib  the destination bitmap
00304     Returns:    True if works ok, False otherwise.
00305     Purpose:    Ask a plug-in to strut its stuff and do its work taking the pDib as a
00306                 source and pOutputDIB as the result.
00307                 If ApplyLast is True then asks a plug-in to strut its stuff again
00308                 using the same parameters as last time. Once again doing its work
00309                 taking the pDib as a source and pOutputDIB as the result.
00310                 Assumes pDib and pOutputDib already allocated and are the same size etc.
00311 
00312 **************************************************************************************/
00313 
00314 /* BOOL BfxPlugIn::Apply(WinBitmap *pInputDIB, WinBitmap * pOutputDIB) 
00315 {
00316     ERROR2IF(pInputDIB == NULL || pOutputDIB == NULL,FALSE,"Input bitmaps not specified correctly");
00317 
00318 
00319     return ok;
00320 } */
00321 
00322 /**************************************************************************************
00324 **************************************************************************************/
00325 
00326 /**************************************************************************************
00328 **************************************************************************************/
00329 
00330 /**************************************************************************************
00331 
00332 >   BfxBrightnessContrast::BfxBrightnessContrast()
00333 
00334     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00335     Created:    5/3/97
00336     Purpose:    Constructor for a BfxBrightnessContrast plug-in. 
00337 
00338 **************************************************************************************/
00339 
00340 BfxBrightnessContrast::BfxBrightnessContrast()
00341 {
00342     SetFamilyName(_R(IDS_BFXDLG));
00343     SetPlugInName(_R(IDS_BFXPLUGINDLG_BRIGHTNESS));
00344 
00345     //SetFilterName(TEXT("Fred"));
00346     //SetModuleName(TEXT("Jim"));
00347 }
00348 
00349 /**************************************************************************************
00350 
00351 >   virtual OpDescriptor * BfxBrightnessContrast::GetOpDescriptor()
00352 
00353     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00354     Created:    5/3/97
00355     Returns:    the OpDescriptor for the connected dialog box operation
00356     Purpose:    Returns the OpDescriptor for the dialog box connected with this bfx
00357                 plug-in ready to be invoked.
00358 
00359 **************************************************************************************/
00360 
00361 OpDescriptor * BfxBrightnessContrast::GetOpDescriptor()
00362 {
00363     return OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(BfxBrightnessContrastDlg));
00364 }
00365 
00366 /**************************************************************************************
00368 **************************************************************************************/
00369 
00370 /**************************************************************************************
00371 
00372 >   BfxSpecialEffects::BfxSpecialEffects()
00373 
00374     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00375     Created:    5/3/97
00376     Purpose:    Constructor for a BfxSpecialEffects plug-in. 
00377 
00378 **************************************************************************************/
00379 
00380 BfxSpecialEffects::BfxSpecialEffects()
00381 {
00382     SetFamilyName(_R(IDS_BFXDLG));
00383     SetPlugInName(_R(IDS_BFXPLUGINDLG_SPECIAL));
00384 }
00385 
00386 /**************************************************************************************
00387 
00388 >   virtual OpDescriptor * BfxSpecialEffects::GetOpDescriptor()
00389 
00390     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00391     Created:    5/3/97
00392     Returns:    the OpDescriptor for the connected dialog box operation
00393     Purpose:    Returns the OpDescriptor for the dialog box connected with this bfx
00394                 plug-in ready to be invoked.
00395 
00396 **************************************************************************************/
00397 
00398 OpDescriptor * BfxSpecialEffects::GetOpDescriptor()
00399 {
00400     return OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(BfxSpecialEffectsDlg));
00401 }
00402 
00403 /**************************************************************************************
00405 **************************************************************************************/
00406 
00407 /**************************************************************************************
00408 
00409 >   BfxResize::BfxResize()
00410 
00411     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00412     Created:    5/3/97
00413     Purpose:    Constructor for a BfxResize plug-in. 
00414 
00415 **************************************************************************************/
00416 
00417 BfxResize::BfxResize()
00418 {
00419     SetFamilyName(_R(IDS_BFXDLG));
00420     SetPlugInName(_R(IDS_BFXPLUGINDLG_RESIZE));
00421 }
00422 
00423 /**************************************************************************************
00424 
00425 >   virtual OpDescriptor * BfxResize::GetOpDescriptor()
00426 
00427     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00428     Created:    5/3/97
00429     Returns:    the OpDescriptor for the connected dialog box operation
00430     Purpose:    Returns the OpDescriptor for the dialog box connected with this bfx
00431                 plug-in ready to be invoked.
00432 
00433 **************************************************************************************/
00434 
00435 OpDescriptor * BfxResize::GetOpDescriptor()
00436 {
00437     return OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(BfxResizeDlg));
00438 }
00439 
00440 /**************************************************************************************
00442 **************************************************************************************/
00443 
00444 /**************************************************************************************
00445 
00446 >   BfxFlipAndRotate::BfxFlipAndRotate()
00447 
00448     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00449     Created:    5/3/97
00450     Purpose:    Constructor for a BfxFlipAndRotate plug-in. 
00451 
00452 **************************************************************************************/
00453 
00454 BfxFlipAndRotate::BfxFlipAndRotate()
00455 {
00456     SetFamilyName(_R(IDS_BFXDLG));
00457     SetPlugInName(_R(IDS_BFXPLUGINDLG_FLIP));
00458 }
00459 
00460 /**************************************************************************************
00461 
00462 >   virtual OpDescriptor * BfxFlipAndRotate::GetOpDescriptor()
00463 
00464     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00465     Created:    5/3/97
00466     Returns:    the OpDescriptor for the connected dialog box operation
00467     Purpose:    Returns the OpDescriptor for the dialog box connected with this bfx
00468                 plug-in ready to be invoked.
00469 
00470 **************************************************************************************/
00471 
00472 OpDescriptor * BfxFlipAndRotate::GetOpDescriptor()
00473 {
00474     return OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(BfxFlipAndRotateDlg));
00475 }
00476 
00477 /**************************************************************************************
00479 **************************************************************************************/
00480 
00481 /**************************************************************************************
00482 
00483 >   BfxColourDepth::BfxColourDepth()
00484 
00485     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00486     Created:    5/3/97
00487     Purpose:    Constructor for a BfxColourDepth plug-in. 
00488 
00489 **************************************************************************************/
00490 
00491 BfxColourDepth::BfxColourDepth()
00492 {
00493     SetFamilyName(_R(IDS_BFXDLG));
00494     SetPlugInName(_R(IDS_BFXPLUGINDLG_COLOUR));
00495 }
00496 
00497 /**************************************************************************************
00498 
00499 >   virtual OpDescriptor * BfxColourDepth::GetOpDescriptor()
00500 
00501     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00502     Created:    5/3/97
00503     Returns:    the OpDescriptor for the connected dialog box operation
00504     Purpose:    Returns the OpDescriptor for the dialog box connected with this bfx
00505                 plug-in ready to be invoked.
00506 
00507 **************************************************************************************/
00508 
00509 OpDescriptor * BfxColourDepth::GetOpDescriptor()
00510 {
00511     return OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(BfxColourDepthDlg));
00512 }

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