BfxPlugInOp Class Reference

Operation so that a BFX plug-ins can be invoked and used. More...

#include <bfxop.h>

Inheritance diagram for BfxPlugInOp:

PlugInOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 BfxPlugInOp ()
 Constructor for BfxPlugInOp operation. It is not undoable.
virtual void Do (OpDescriptor *)
 Invokes the plug-in specified by the OpDescriptor.

Static Public Member Functions

static BOOL Init ()
 Creates all the opDescriptors that call this operation.
static OpState GetState (String_256 *, OpDescriptor *)
 To provide greying and ticking functionality for the operation. Assumes only working on Bfx plug-ins. Not that this should make much difference at present.
static BOOL CheckBitmapWithPlugIn (const String_256 &OpName, BOOL IncludeUniqueName=TRUE, BOOL IncludeUndoAbleSig=FALSE)
 To ask the plug-in which matches the OpName whether the bitmap is ok. Assumes only working on Bfx plug-ins. Not that this should make much difference at present.
static BOOL SetBitmapAndDocument (KernelBitmap *pBitmap, Document *pDocument)
 Provides the parameters that the operation will apply to.

Private Member Functions

 CC_DECLARE_DYNCREATE (BfxPlugInOp)

Static Private Attributes

static KernelBitmapm_pBitmap = NULL
static Documentm_pDocument = NULL

Detailed Description

Operation so that a BFX plug-ins can be invoked and used.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/3/97

Definition at line 118 of file bfxop.h.


Constructor & Destructor Documentation

BfxPlugInOp::BfxPlugInOp  ) 
 

Constructor for BfxPlugInOp operation. It is not undoable.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/3/97
Parameters:
[INPUTS] 
[OUTPUTS] 
Returns:

Errors: None

Definition at line 138 of file bfxop.cpp.

00139 {
00140 }


Member Function Documentation

BfxPlugInOp::CC_DECLARE_DYNCREATE BfxPlugInOp   )  [private]
 

BOOL BfxPlugInOp::CheckBitmapWithPlugIn const String_256 OpName,
BOOL  IncludeUniqueName = TRUE,
BOOL  IncludeUndoAbleSig = FALSE
[static]
 

To ask the plug-in which matches the OpName whether the bitmap is ok. Assumes only working on Bfx plug-ins. Not that this should make much difference at present.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/3/97
Parameters:
OpName - the name of the OpToken being requested. [INPUTS] IncludeUniqueName - Set to True (Default) if want the unique name of the plug-in added to the OpToken IncludeUndoAbleSig - Set to True is want the unique undoable sig added to the OpToken. (Default = FALSE.)
Returns:
True if the item is ok with the plug-in, False otherwise

Errors: None

Definition at line 187 of file bfxop.cpp.

00189 {
00190     // If no bitmap then always return False
00191     if (m_pBitmap == NULL)
00192         return FALSE;
00193 
00194     // Search the plug-ins list for the specified plug-in and check
00195     // that this colour depth is ok with it
00196     INT32 ColourDepth = m_pBitmap->GetBPP();
00197     BOOL GreyScale = m_pBitmap->IsGreyscale();
00198     PlugInManager* pManager = GetApplication()->GetPlugInManager();
00199     if (pManager)
00200     {
00201         PlugInItem * pPlugIn = pManager->GetFirstPlugIn();
00202         String_32 OpToken;
00203         // Add the unique undo signature
00204         String_32 UndoSig(TEXT(PLUGIN_UNDO_SIG));
00205         while (pPlugIn)
00206         {
00207             // If we are to include the unique name in the test then do so
00208             if (IncludeUniqueName)
00209                 OpToken = pPlugIn->GetUniqueID();
00210             else
00211                 OpToken.Empty();
00212             if (IncludeUndoAbleSig)
00213                 OpToken += UndoSig;
00214             OpToken += pPlugIn->GetPlugInName();
00215             if (OpName == OpToken)
00216             {
00217                 // Ask the plug-in item whether it likes this colour depth
00218                 // Returns True if likes it, False otherwise, so we must negate this to
00219                 // set the greyed state.
00220                 return pPlugIn->IsBitmapModeOk(ColourDepth, GreyScale);
00221             }
00222             
00223             pPlugIn = pManager->GetNextPlugIn(pPlugIn);
00224         }
00225     }
00226 
00227     // Cannot find plug-in so return False
00228     return FALSE;
00229 }

void BfxPlugInOp::Do OpDescriptor pOpDesc  )  [virtual]
 

Invokes the plug-in specified by the OpDescriptor.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/3/97
Parameters:
pOpDesc the OpDescriptor of the item to invoke [INPUTS]
None [OUTPUTS]
Returns:
None

Errors: if no OpDescriptor is supplied

Reimplemented from PlugInOp.

Definition at line 295 of file bfxop.cpp.

00296 {
00297     if (pOpDesc == NULL || m_pBitmap == NULL || m_pDocument == NULL)
00298     {
00299         ERROR3("BfxPlugInOp::Do null OpDescriptor/bitmap/document");
00300         FailAndExecute(); 
00301         End();
00302         return;
00303     }
00304     //ERROR3("PlugInOp - do");
00305 
00306     // Search the plug-ins list for the specified plug-in and invoke it
00307     PlugInManager* pManager = GetApplication()->GetPlugInManager();
00308     if (pManager == NULL)
00309         return;
00310 
00311     PlugInItem * pPlugIn = pManager->GetFirstPlugIn();
00312 
00313     String_32 OpToken;
00314     while (pPlugIn)
00315     {
00316         OpToken = pPlugIn->GetUniqueID();
00317         OpToken += pPlugIn->GetPlugInName();
00318         if (pOpDesc->Token == OpToken)
00319         {
00320             BOOL ok = pPlugIn->Apply(m_pBitmap, m_pDocument);
00321             if (!ok)
00322             {
00323                 FailAndExecute(); 
00324             }
00325                 
00326             // and finish as we have done our work
00327             End();
00328             return;
00329         }
00330 
00331         pPlugIn = pManager->GetNextPlugIn(pPlugIn);
00332     }
00333 
00334     // We must have failed to find the plug-in operation so fail and finish
00335     ERROR3("BfxPlugInOp::Do Failed to find plug-in operation");
00336     FailAndExecute(); 
00337     End();
00338 }

OpState BfxPlugInOp::GetState String_256 pDesc,
OpDescriptor pOpDesc
[static]
 

To provide greying and ticking functionality for the operation. Assumes only working on Bfx plug-ins. Not that this should make much difference at present.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/3/97
Parameters:
pOpDesc - the OpDescriptor being used. [INPUTS]
pDesc - if MenuItem is enabled Then return the name of the operation to [OUTPUTS] be undone Else return the reason why it is disabled
Returns:
OpState the state of the operation

Errors: None

Reimplemented from PlugInOp.

Definition at line 249 of file bfxop.cpp.

00250 {
00251     // At present, this item is always available unless there is
00252     // no bitmap and document to apply it to.
00253     OpState OpSt;
00254     if (m_pBitmap == NULL || m_pDocument == NULL)
00255         OpSt.Greyed = TRUE;
00256 
00257     if (m_pBitmap)
00258     {
00259         // If there is a bitmap then we are always available
00260         OpSt.Greyed = FALSE;
00261 
00262 /*      // If we have a valid bitmap then checks that it is of the correct type
00263         INT32 ColourDepth = m_pBitmap->GetBPP();
00264 
00265         // Only allow bitmaps of 24bpp or of 8bpp greyscale
00266         if (ColourDepth == 24 || (ColourDepth == 8 && m_pBitmap->IsGreyscale()))
00267         {
00268             // Check the bitmap depth with the plug-in itself
00269             // Returns True if likes it, False otherwise, so we must negate this to
00270             // set the greyed state.
00271             OpSt.Greyed = !CheckBitmapWithPlugIn(pOpDesc->Token);
00272         }
00273         else
00274             OpSt.Greyed = TRUE;
00275 */
00276     }
00277 
00278     return OpSt;
00279 }

BOOL BfxPlugInOp::Init void   )  [static]
 

Creates all the opDescriptors that call this operation.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/3/97
Returns:
TRUE if the Op was started ok

Reimplemented from PlugInOp.

Definition at line 153 of file bfxop.cpp.

00154 {
00155     BOOL ok = TRUE;
00156     // Set up some standard operations
00157 /*  ok = ok && RegisterOpToken(OPTOKEN_Bfx_PLUGINS, _R(IDS_Bfx_PLUGINS),
00158                                CC_RUNTIME_CLASS(BfxPlugInOp), BfxPlugInOp::GetState);
00159     ok = ok && RegisterOpToken(OPTOKEN_Bfx_APPLYLAST, _R(IDS_Bfx_APPLYLAST),
00160                                CC_RUNTIME_CLASS(BfxPlugInOp), BfxPlugInOp::GetState);
00161 */
00162     return ok;
00163 }

BOOL BfxPlugInOp::SetBitmapAndDocument KernelBitmap pBitmap,
Document pDocument
[static]
 

Provides the parameters that the operation will apply to.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/3/97
Parameters:
pBitmap the bitmap to apply the effect to [INPUTS] pDocument the document the bitmap is stored in

Definition at line 352 of file bfxop.cpp.

00353 {
00354     m_pBitmap = pBitmap;
00355     m_pDocument = pDocument;
00356     return TRUE;
00357 }


Member Data Documentation

KernelBitmap * BfxPlugInOp::m_pBitmap = NULL [static, private]
 

Definition at line 140 of file bfxop.h.

Document * BfxPlugInOp::m_pDocument = NULL [static, private]
 

Definition at line 141 of file bfxop.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:51:12 2007 for Camelot by  doxygen 1.4.4