PreviewDialog Class Reference

#include <prevwdlg.h>

Inheritance diagram for PreviewDialog:

DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 PreviewDialog ()
 Constructs a Preview Dialog.
 ~PreviewDialog ()
 Destructor.
virtual void DoWithParam (OpDescriptor *pOpDesc, OpParam *pParam)
 Creates and shows a Preview dialog.
virtual MsgResult Message (Msg *Message)
 Handles all the Preview dialog's messages.
virtual BOOL OnIdleEvent (void)
 Used to detect when the mouse has stopped moving Therefore allows us to implement bubble help for the Preview Dialog.
void UpdateBubbleHelp (void)
 Called for Idle events to provide bubble help for the Preview Dialog.
BOOL SetBitmapList (BitmapExportParam *pParam, BOOL SetSlider=TRUE)
 If we need to regenerate our bitmaps while the Preview dialog is open, this function allows us to update our list.
BOOL SetRegeneratedBitmapInList (GIFAnimationExportParam *pParam)
 If we need to regenerate a SINGLE bitmap while the Preview dialog is open, this function allows us to update our Bitmap list.
BOOL SetBitmapToListTail (GIFAnimationExportParam *pParam)
 If we need to (re)generate asingle bitmap while the Preview dialog is open, this function allows us to add the Bitmap to the Tail of the list.
BOOL GetPlayAnimation ()
void SetPlayAnimation (BOOL Value)
INT32 GetBitmapListSize ()
void SetDlgState (BOOL State)
BOOL GetDlgState ()
void SetDocumentAboutToDie (BOOL Val)
void SetGeneratedFrameLayers (BOOL Val)
BOOL GetGeneratedFrameLayers ()
void SetCurrentItem (INT32 Num)
INT32 GetCurrentItem ()
INT32 GetSliderPosition ()
void SetSliderPosition (INT32 Position)
 Set the slider to its correct position.
void SelectCurrentBitmap (UINT32 Position)
 Moves the current item to where the slider has been positioned.
void RestartTimer ()
 If for some reason the timer was stopped, this function will re-start it.
BOOL ReInitDialog ()
 Will reset the initial dialog values. Should be used on an already open dialog box.
BOOL StopPreviewing ()
 Puts the dialog into a stopped state ready to grab the frames or frame.
BOOL SetDialogToIdleState ()
 Ensures that the the dialog is set into an idle state showing a cross in the preview section.
BOOL SelectCurrentFrame (const UINT32 Position)
 Tries to set the current frame to be displayed and ensure that associated items are set e.g. the slider.
void SetDelay (UINT32 newDelay)

Static Public Member Functions

static BOOL Init ()
 Creates an OpDescriptor for a Preview Dialog.
static BOOL GetStatusLineText (String_256 *Result)
static OpState GetState (String_256 *, OpDescriptor *)
 Returns the OpState of the Preview dialogue operation.
static BOOL GetAnimationPropertiesChanged ()
static void SetAnimationPropertiesChanged (const BOOL Val)
static PreviewDialogGetPreviewDialog ()
static void ToggleViaBitmapGallery (BOOL val)

Static Public Attributes

static const UINT32 IDD = _R(IDD_PREVIEWDIALOG)
static const CDlgMode Mode = MODELESS

Protected Member Functions

void RenderControl (ReDrawInfoType *pExtraInfo)
 Renders the current bitmap into the control. This actually consists of:- Render slabbed in border Render items before present bitmap in list to set up background Render current bitmap.
void GridLockRect (DocRect *TheRect, INT32 GridSize)
 GridLocks all 4 coordinates of the rectangle using HalfGridLock Note: stolen from ColourEditDlg rendering routines.
INT32 HalfGridLock (INT32 Position, INT32 GridSize)
 Grid-locks a given plotting poisition to lie over a grid (usually the output device-pixel grid). The result is shifted by half the grid size to grid-lock to the _center_ of a pixel rather than the edges. Note: stolen from ColourEditDlg rendering routines.
BOOL InitDialog ()
 Sets initial dialog values.
BOOL SetUpCallBack ()
 Sets up the call back for this dialog box so that we get timer events and so can animate the bitmap on display.
BOOL DoRegenerateFrames ()
 While previewing an animation, if the Reset button is clicked we need to regrab all the frames. This function invokes the correct Op.
void SetPreviewDialogToIdleState (ReDrawInfoType *pExtraInfo)
 If the preview animation dialog is open, and the user does any of the following:- Changes the current doc. Closes the current doc. Opens a new doc. Then we stop playing the current animation, and set the dialog to a grey background with a cross in the centre.
KernelBitmapGetBitmapItem (INT32 Index)
 Returns the specified bitmap.
KernelBitmapGetCurrentBitmap (BOOL GetDetails=TRUE)
 Returns the current bitmap which we should be using.
LayerGetLayerItem (INT32 Index)
 Returns the specified layer.
LayerGetCurrentLayer ()
 Returns the current layer.
void IncrementCurrentBitmap ()
 Moves the current item to be the next bitmap in the list. If we reach the end of the list, it then becomes the first item in the list.
void DecrementCurrentBitmap ()
 Moves the current item to be the previous bitmap in the list. If we reach the start of the list, it then becomes the last item in the list.
UINT32 GetDelayForCurrentBitmap ()
 Returns the delay in centiseconds for the current bitmap.
void SelectFirstBitmap ()
 Selects the first bitmap in our list.
void SelectLastBitmap ()
 Selects the last bitmap in our list.
BOOL SetDlgStateAfterDocChange ()
 If the Preview dialog is open before and after a doument change, then play the animation and set the correct state of the controls.
BOOL SetDlgStateAfterRefresh ()
 When the preview dlg is open, if the refresh button is clicked, this function refreshes the current state of the dialog.
void PreviewDlgPlay ()
 After the play button has been clicked, this functions plays the animation and sets the correct state of the controls.
void PreviewDlgStop ()
 After the Stop button has been cllicked, this functions Stops the animation and sets the correct state of the controls.
void PreviewNextFrame ()
 After the preview next frame button is clicked, if the animation was playing this function stops tha animation, and selects the next frame.
void PreviewPreviousFrame ()
 After the Preview previous frame button is cllicked, if the animation was playing this function stops tha animation, and selects the previous frame.
void SetSliderPosition ()
 This functiion deals with clicks on the Preview dialog slider control.
BOOL ResizeDialogToFitAnimation ()
 Tries to resize the dialog to fit the animation in the preview control.
BOOL RedrawBitmap (KernelBitmap *pBitmapToUse, DocRect *pVirtualSize)
 Redraws the specified bitmap into the render region.
BOOL RedrawCross (DocRect *pVirtualSize, DialogColourInfo *pRedrawColours, INT32 PixelSize)
 Redraws the specified bitmap into the render region.
void OnTimer ()
 This callback function is called when the new frame in the GIF should be displayed. It resets the timer to generate an event for the subsequent frame.

Static Protected Member Functions

static TCHARHelpCallbackHandler (wxWindow *Window, UINT32 Item, void *UserData)
 Help callback handler to provide bubble help for the POreview Diaolg.
static BOOL GetStatusLineText (PreviewDialog *pPrvDlg, UINT32 GadgetID, String_256 *Result)

Protected Attributes

List m_BitmapList
INT32 m_BitmapListSize
INT32 m_CurrentItem
RenderRegionm_pRender
INT32 m_SliderPosition
BOOL m_PlayAnimation
BOOL m_DisplayNextFrame
BOOL m_DisplayPreviousFrame
BOOL m_DocumentAboutToDie
BOOL m_SetPreviewDlgToIdleState
BOOL m_GeneratedFrameLayers
GIFDisposalMethod m_DisposalMethod
GIFDisposalMethod m_CurrentDisposalMethod
DocRect m_AnimationRect
INT32 m_CurrentLoopCount
INT32 m_RequiredLoopCount
PreviewTimer m_Timer

Static Protected Attributes

static BOOL viaBitmapGallery = FALSE
static UINT32 m_Delay = 0
static BOOL m_AnimationPropertiesChanged = FALSE
static PreviewDialogm_pPreviewDialog = NULL

Private Member Functions

 CC_DECLARE_DYNCREATE (PreviewDialog)

Classes

class  PreviewTimer

Detailed Description

Definition at line 157 of file prevwdlg.h.


Constructor & Destructor Documentation

PreviewDialog::PreviewDialog  ) 
 

Constructs a Preview Dialog.

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

Definition at line 243 of file prevwdlg.cpp.

00243                              : DialogOp(PreviewDialog::IDD, PreviewDialog::Mode), m_Timer(this)
00244 {
00245     m_BitmapListSize            = 0;
00246     m_CurrentItem               = 0;
00247     m_pPreviewDialog            = this;
00248     m_pRender                   = NULL;
00249     m_PlayAnimation             = TRUE;
00250     m_DisplayNextFrame          = FALSE;
00251     m_DisplayPreviousFrame      = FALSE;
00252     m_SliderPosition            = m_BitmapListSize;
00253     m_DocumentAboutToDie        = FALSE;
00254     m_SetPreviewDlgToIdleState  = FALSE;
00255     m_GeneratedFrameLayers      = FALSE;
00256     m_DisposalMethod            = GDM_BACKTOBACK;
00257     m_CurrentDisposalMethod     = GDM_BACKTOBACK;
00258 
00259     m_AnimationRect.MakeEmpty();
00260 
00261     // Reset the loop counts
00262     m_CurrentLoopCount          = 0;    // The loop that we are currently on (default to start)
00263     m_RequiredLoopCount         = 0;    // The loop count that we must reach (default for ever)
00264     
00265     //viaBitmapGallery          = FALSE;        // THIS MUST ALREADY HAVE BEEN SET TO THE CORRECT
00266                                                 // VALUE !!!!!
00267     
00268     // Get the input focus for bubble help.
00269     GetApplication()->RegisterIdleProcessor(IDLEPRIORITY_HIGH, this);
00270 }       

PreviewDialog::~PreviewDialog  ) 
 

Destructor.

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

Definition at line 282 of file prevwdlg.cpp.

00283 {
00284     // clean out the render region, if allocated
00285     if (m_pRender)
00286     {
00287         // Delete the render region and its (dialog) view
00288         // Do it by hand as StopRender should have been called already
00289         delete m_pRender->GetRenderView();
00290         delete m_pRender;
00291 //      DestroyGRenderRegion(m_pRender);
00292         m_pRender = NULL;
00293     }
00294     
00295     // Clean out the list of bitmaps that we were animating
00296     m_BitmapList.DeleteAll();
00297 
00298     // kill the static link to this dialog box
00299     m_pPreviewDialog = NULL;
00300 
00301     // The dialog has been destroyed, remove the input focus.
00302     GetApplication()->RemoveIdleProcessor(IDLEPRIORITY_HIGH, this);
00303 } 


Member Function Documentation

PreviewDialog::CC_DECLARE_DYNCREATE PreviewDialog   )  [private]
 

void PreviewDialog::DecrementCurrentBitmap  )  [protected]
 

Moves the current item to be the previous bitmap in the list. If we reach the start of the list, it then becomes the last item in the list.

Author:
Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/05/97

Definition at line 1637 of file prevwdlg.cpp.

01638 {
01639     //  Local flag to test whether to increment the slider position.
01640 //  BOOL SliderPositionReset = FALSE;
01641 
01642     //  Decrement the bitmap if the user has eitther clicked Play or Previous frame.
01643     if(m_PlayAnimation || m_DisplayPreviousFrame)
01644     {
01645         m_CurrentItem--;
01646         
01647         // Moving backwards so do what?????
01648         m_DisposalMethod = GDM_BACKTOBACK;
01649 
01650         // Activate the slider if we have more than 1 bitmap.
01651         if(m_BitmapListSize > 1)
01652         {
01653             // Increment the slider.
01654             m_SliderPosition++;
01655 
01656             //  If the slider is at the start, then set it to the end.  
01657             if(m_SliderPosition >= m_BitmapListSize + 1)
01658                 m_SliderPosition = 1;       
01659         }
01660 
01661         // Set the slider to the correct position.
01662         SetSliderPosition(m_SliderPosition);
01663     }
01664 
01665     // If we reach the start of the list then wrap around to the end.
01666     if (m_CurrentItem < 0)
01667         m_CurrentItem = (m_BitmapListSize-1);
01668 }

BOOL PreviewDialog::DoRegenerateFrames  )  [protected]
 

While previewing an animation, if the Reset button is clicked we need to regrab all the frames. This function invokes the correct Op.

Author:
Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/05/97
Parameters:
- [INPUTS]
Returns:
True if worked ok, False otherwise

Definition at line 2473 of file prevwdlg.cpp.

02474 {
02475     // When in stop mode, we should try and regrab the frame being displayed
02476     // When in play mode, we should grab the entire animation
02477     // If we were in stand by mode then grab the active frame.
02478 
02479 PORTNOTE("other", "Disabled BrowserPreviewOptions")
02480 #ifndef EXCLUDE_FROM_XARALX
02481     // Return false if the document is empty.
02482     String_256 ShadeReason;
02483     OpState State = OpGrabAllFrames::GetState(&ShadeReason, NULL);
02484     if (State.Greyed)
02485     {
02486         if(!m_SetPreviewDlgToIdleState)
02487             //Set the dlg to an idle state.
02488             m_SetPreviewDlgToIdleState = TRUE;
02489 
02490         // Force the gadget to be repainted.
02491         m_pPreviewDialog->InvalidateGadget(_R(IDC_REDRAW_ME));
02492         return FALSE;           
02493     }
02494 #endif
02495     
02496     // Temp flags to remember whether the animation was playing/How may layers existed
02497     // before all the frames were regenerated.
02498     BOOL AnimationPlaying = FALSE;
02499     //UINT32 PreRefreshNumberOfLayers = m_BitmapListSize;
02500     BOOL IdleState = m_SetPreviewDlgToIdleState;
02501     
02502     // If we are not in an idle state already then ensure that we are playing we are stopped
02503     if (!m_SetPreviewDlgToIdleState)
02504     {
02505         // Stop the animation.
02506         if (m_PlayAnimation)
02507         {
02508             StopPreviewing();
02509 
02510             AnimationPlaying = TRUE;
02511         }
02512     }
02513 
02514     // Set the dlg idle flag back to false.
02515     m_SetPreviewDlgToIdleState = FALSE;
02516     
02517     // Are we in single bitmap mode?
02518     BOOL SingleBitmapMode = (m_BitmapListSize == 1);
02519 
02520     // If we were playing or idle then grab all frames
02521     //if (AnimationPlaying || IdleState)
02522     // If we are in an idle state or we are in multiple bitmap mode then
02523     // refresh = grab all frames
02524     if (IdleState || !SingleBitmapMode)
02525     {
02526         // If we were playing or idle then ensure that we restart in play mode
02527         if (AnimationPlaying || IdleState)
02528             m_PlayAnimation = TRUE;
02529         else
02530             m_PlayAnimation = FALSE;
02531 
02532         OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_FRAME_GRABALLFRAMES); 
02533         if (pOpDesc != NULL)
02534             pOpDesc->Invoke();
02535         else
02536         {
02537             ERROR3("Couldn't find OPTOKEN_FRAME_GRABALLFRAMES op descriptor");
02538         }
02539     }
02540     else
02541     {
02542         // We were showing a single frame so try and refresh this layer
02543         // and show it again.
02544         Layer * pLayerToRefresh = NULL;
02545         KernelBitmap * pBitmap = GetCurrentBitmap();
02546         if (pBitmap != NULL)
02547         {
02548             // Search through the layers for this bitmap and then try and regenerate it
02549             // If we don't find it then regnerate the active layer
02550             Spread * pSpread = Document::GetSelectedSpread();
02551             if (pSpread)
02552             {
02553                 Layer * pLayer = pSpread->FindFirstFrameLayer();
02554                 BOOL Found = FALSE;
02555                 while (pLayer != NULL && !Found)
02556                 {
02557                     KernelBitmap * pLayerBitmap = pLayer->GetGeneratedBitmap();
02558                     if (pLayerBitmap == pBitmap)
02559                     {
02560                         pLayerToRefresh = pLayer;
02561                         Found = TRUE;
02562                     }
02563                     
02564                     pLayer = pLayer->FindNextFrameLayer();
02565                 }
02566             }
02567         }
02568 
02569         // Ensure that we restart in stop mode
02570         m_PlayAnimation = FALSE;
02571 
02572         OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_FRAME_GRABFRAME); 
02573         // Pass in pLayerToRefresh as a possible layer to refresh
02574         if (pOpDesc != NULL)
02575         {
02576             OpParam Param;
02577             Param.Param1 = (void *)pLayerToRefresh;
02578             pOpDesc->Invoke(&Param);
02579         }
02580         else
02581         {
02582             ERROR3("Couldn't find OPTOKEN_FRAME_GRABALLFRAMES op descriptor");
02583         }
02584     }
02585 
02586     // The ops should call us back to set everything up.
02587 
02588     // We will just ensure that these are set correctly
02589     // Set the flags to the correct state.
02590     m_DocumentAboutToDie        =   FALSE;
02591     m_SetPreviewDlgToIdleState  =   FALSE;
02592 
02593     // Reset the loop counts
02594     m_CurrentLoopCount          = 0;    // The loop that we are currently on (default to start)
02595     m_RequiredLoopCount         = 0;    // The loop count that we must reach (default for ever)
02596 
02597     // Through a document change, the timer may not be ticking.
02598     // If it has been stopped, then re-start.
02599     RestartTimer();
02600 
02601     return TRUE;
02602 }

void PreviewDialog::DoWithParam OpDescriptor pOpDesc,
OpParam pParam
[virtual]
 

Creates and shows a Preview dialog.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/4/97
Parameters:
pOpDesc The OpDescriptor being invoked [INPUTS] pParam The parameters being passed in

Reimplemented from Operation.

Definition at line 1961 of file prevwdlg.cpp.

01962 {
01963     TRACEUSER( "Neville", _T("PreviewDialog::DoWithParam\n"));
01964 
01965     // Check out the parameter that we should be being passed
01966     if (pParam == NULL)
01967     {
01968         ERROR2RAW("OpMenuExport::DoWithParam bad params");
01969         FailAndExecute();
01970         End();
01971         return;
01972     }
01973     
01974     BitmapExportParam* pExportParam = (BitmapExportParam*) pParam;
01975     ERROR3IF(!pExportParam->IS_KIND_OF(BitmapExportParam), "OpParam passed is not a BitmapExportParam");
01976 
01977     if (pExportParam->GetBitmapCount() == 0)
01978     {
01979         ERROR2RAW("OpMenuExport::DoWithParam no bitmaps to preview");
01980         FailAndExecute();
01981         End();
01982         return;
01983     }               
01984 
01985     // Take a copy of the list of bitmaps passed in
01986     // Don't set the slider position as we haven't constructed the dialog yet!
01987     SetBitmapList(pExportParam, FALSE);
01988 
01989     // Has more than one frame layer been generated.
01990     if(m_BitmapListSize > 1)
01991         m_GeneratedFrameLayers = TRUE;
01992 
01993     // Force the dialog box to be created.
01994     // If it is non-modal it must be opened if the create works ok.
01995     // If it is modal then don't call the open
01996     if (Create())
01997     {
01998         // If dialog is not Modal do this now
01999         // Otherwise set up happens in the message handler
02000         if (Mode == MODELESS)
02001         {
02002             // Try to resize the dialog box so that the current animation fits
02003             ResizeDialogToFitAnimation();
02004 
02005             // Set the initial control values 
02006             InitDialog();
02007 
02008             // If modeless then call open Open()
02009             Open();
02010         
02011             // Set up the call back so we get timer events
02012             SetUpCallBack();
02013         }
02014     }
02015     else
02016     {
02017         TRACE( _T("Failed to create Render Demo Dialog\n"));
02018         // Could not create the dialog box so call inform error 
02019         InformError();                      // Show user the error
02020         End();                              // End the operation 
02021     }
02022 
02023     return;
02024 }

static BOOL PreviewDialog::GetAnimationPropertiesChanged  )  [inline, static]
 

Definition at line 180 of file prevwdlg.h.

00180 { return m_AnimationPropertiesChanged; }

KernelBitmap * PreviewDialog::GetBitmapItem INT32  Index  )  [protected]
 

Returns the specified bitmap.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/6/97
Parameters:
Index the index of the bitmap in the list to get [INPUTS]

Definition at line 1437 of file prevwdlg.cpp.

01438 {
01439     // If beyond the end of the list or the start then return nothing found
01440     if (Index >= m_BitmapListSize || Index < 0)
01441         return NULL;
01442 
01443     // Search through the list for the nth item
01444     AnimatedBitmapItem * pCurrentItem = (AnimatedBitmapItem *)m_BitmapList.GetHead();
01445     INT32 Count = 0;
01446     while (pCurrentItem)
01447     {
01448         if (Count == Index)
01449         {
01450             return pCurrentItem->GetBitmap();
01451         }
01452 
01453         Count ++;
01454 
01455         // Get the next item in the list
01456         pCurrentItem = (AnimatedBitmapItem *)m_BitmapList.GetNext(pCurrentItem);
01457     }
01458 
01459     // Nothing found
01460     return NULL;
01461 }

INT32 PreviewDialog::GetBitmapListSize  )  [inline]
 

Definition at line 192 of file prevwdlg.h.

00192 { return  m_BitmapListSize; }

KernelBitmap * PreviewDialog::GetCurrentBitmap BOOL  GetDetails = TRUE  )  [protected]
 

Returns the current bitmap which we should be using.

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

Definition at line 1473 of file prevwdlg.cpp.

01474 {
01475     KernelBitmap * pBitmapToUse = NULL;
01476 
01477     // If beyond the end of the list then wrap around to the start
01478     if (m_CurrentItem >= m_BitmapListSize)
01479         m_CurrentItem = 0;
01480 
01481     // Search through the list for the nth item
01482     AnimatedBitmapItem * pCurrentItem = (AnimatedBitmapItem *)m_BitmapList.GetHead();
01483     INT32 Count = 0;
01484     while (pCurrentItem)
01485     {
01486         if (Count == m_CurrentItem)
01487         {
01488             pBitmapToUse = pCurrentItem->GetBitmap();
01489             break;
01490         }
01491 
01492         Count ++;
01493 
01494         // Get the next item in the list
01495         pCurrentItem = (AnimatedBitmapItem *)m_BitmapList.GetNext(pCurrentItem);
01496     }
01497 
01498     // Note the disposal method for this bitmap for the next time around
01499     if (pBitmapToUse && GetDetails)
01500     {
01501         m_CurrentDisposalMethod = pBitmapToUse->GetAnimationRestoreType();
01502 
01503         // Set up the frame/layer name control to be the bitmap name
01504         String_256 Name = pBitmapToUse->GetName();
01505         SetStringGadgetValue(_R(IDC_PREVIEW_FRAMENAME), Name);
01506     }
01507 
01508     return pBitmapToUse;
01509 }

INT32 PreviewDialog::GetCurrentItem  )  [inline]
 

Definition at line 199 of file prevwdlg.h.

00199 { return m_CurrentItem;                 }

Layer * PreviewDialog::GetCurrentLayer  )  [protected]
 

Returns the current layer.

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

Definition at line 1379 of file prevwdlg.cpp.

01380 {
01381     // If beyond the end of the list then wrap around to the start
01382     if (m_CurrentItem >= m_BitmapListSize)
01383         m_CurrentItem = 0;
01384 
01385     // get the item associated with this index
01386     return GetLayerItem(m_CurrentItem); 
01387 }

UINT32 PreviewDialog::GetDelayForCurrentBitmap  )  [protected]
 

Returns the delay in centiseconds for the current bitmap.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/4/97
Returns:
Delay in centiseconds.

Definition at line 1878 of file prevwdlg.cpp.

01879 {
01880     if (!viaBitmapGallery)
01881     {
01882         UINT32 Delay = 0;
01883         KernelBitmap * pBitmap = GetCurrentBitmap(FALSE);
01884         if (pBitmap)
01885         {
01886             // Ask the bitmap for its stored delay
01887             Delay = pBitmap->GetDelay();
01888             // If the delay specified is zero then use the default
01889             if (Delay == 0)
01890                 Delay = 10;
01891         }
01892 
01893         return Delay;
01894     }
01895     else
01896     {
01897         return (100);       // we wan't a longer delay ....
01898     }
01899 }

BOOL PreviewDialog::GetDlgState  )  [inline]
 

Definition at line 194 of file prevwdlg.h.

00194 { return m_SetPreviewDlgToIdleState;    }

BOOL PreviewDialog::GetGeneratedFrameLayers  )  [inline]
 

Definition at line 197 of file prevwdlg.h.

00197 { return m_GeneratedFrameLayers;        }               

Layer * PreviewDialog::GetLayerItem INT32  Index  )  [protected]
 

Returns the specified layer.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/6/97
Parameters:
Index the index of the layer in the list to get [INPUTS]

Definition at line 1400 of file prevwdlg.cpp.

01401 {
01402     // If beyond the end of the list or the start then return nothing found
01403     if (Index >= m_BitmapListSize || Index < 0)
01404         return NULL;
01405 
01406     // Search through the list for the nth item
01407     AnimatedBitmapItem * pCurrentItem = (AnimatedBitmapItem *)m_BitmapList.GetHead();
01408     INT32 Count = 0;
01409     while (pCurrentItem)
01410     {
01411         if (Count == Index)
01412         {
01413             return pCurrentItem->GetLayer();
01414         }
01415 
01416         Count ++;
01417 
01418         // Get the next item in the list
01419         pCurrentItem = (AnimatedBitmapItem *)m_BitmapList.GetNext(pCurrentItem);
01420     }
01421 
01422     // Nothing found
01423     return NULL;
01424 }

BOOL PreviewDialog::GetPlayAnimation  )  [inline]
 

Definition at line 190 of file prevwdlg.h.

00190 { return m_PlayAnimation;   }

static PreviewDialog* PreviewDialog::GetPreviewDialog  )  [inline, static]
 

Definition at line 187 of file prevwdlg.h.

00187 { return m_pPreviewDialog; }                                                

INT32 PreviewDialog::GetSliderPosition  )  [inline]
 

Definition at line 200 of file prevwdlg.h.

00200 { return m_SliderPosition;              }

OpState PreviewDialog::GetState String_256 ,
OpDescriptor
[static]
 

Returns the OpState of the Preview dialogue operation.

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

Definition at line 1912 of file prevwdlg.cpp.

01913 {
01914     return OpState(FALSE, FALSE);
01915 }

BOOL PreviewDialog::GetStatusLineText PreviewDialog pPrvDlg,
UINT32  GadgetID,
String_256 Result
[static, protected]
 

Author:
Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/05/97
Parameters:
pPrvDlg - Points to the current Preview Dialog. [INPUTS] GadgetID - indicates the gadget for which you want status bar help.
If return value is TRUE, Result is updated with an appropriate help string. [OUTPUTS]
Returns:
-

Definition at line 2440 of file prevwdlg.cpp.

02441 {
02442     if (GadgetID == _R(IDC_PREVIEW_PLAY))
02443     {
02444         *Result = String_256(_R(IDS_PREVIEWST_PLAY));
02445     }
02446     else if (GadgetID == _R(IDC_PREVIEW_STOP))
02447     {
02448         *Result = String_256(_R(IDS_PREVIEWST_STOP));
02449     }
02450     else if (GadgetID == _R(IDC_PREVIEW_NEXTFRAME))
02451     {
02452         *Result = String_256(_R(IDS_PREVIEW_NEXTFRAME));
02453     }
02454     else if (GadgetID == _R(IDC_PREVIEW_PREVFRAME))
02455     {
02456         *Result = String_256(_R(IDS_PREVIEW_PREVFRAME));
02457     }
02458     return TRUE;
02459 }

BOOL PreviewDialog::GetStatusLineText String_256 Result  )  [static]
 

Author:
Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com> (Based on Jason code)
Date:
21/05/97
Parameters:
*Result - The String to recieve the status line text. [INPUTS] Outputs The Status Line string to use, or NULL if not available. Returns TRUE if successful, else false.

Definition at line 2371 of file prevwdlg.cpp.

02372 {
02373 PORTNOTE("other", "Disabled bitmap preview dialog live status text")
02374 #ifndef EXCLUDE_FROM_XARALX
02375     ERROR3IF(Result == NULL, "Illegal NULL param");
02376         
02377     PreviewDialog* pPreviewDlg = m_pPreviewDialog;
02378 
02379     if (pPreviewDlg == NULL)
02380         return(FALSE);
02381 
02382     // Find the main editor window
02383     CWindowID TheWindow = (CWindowID)pPreviewDlg->WindowID;
02384     if (TheWindow == NULL)
02385         return(FALSE);
02386 
02387     // Get the cursor position in screen coords
02388     POINT TempPos;
02389     if (!::GetCursorPos(&TempPos))
02390         return(FALSE);
02391 
02392     // Convert to client coords in the main window
02393     ScreenToClient(TheWindow, &TempPos);
02394 
02395     // See if this is over the main window or any child, get it's CWindowID
02396     CPoint Pos(TempPos);    
02397     CWindowID WindowUnderPointer = ::ChildWindowFromPoint(TheWindow, Pos);
02398     if (WindowUnderPointer == NULL)
02399         return(FALSE);
02400 
02401     // Make sure that hidden windows do not provide status help!
02402     INT32 WindowStyle = ::GetWindowLong(WindowUnderPointer, GWL_STYLE);
02403     if ((WindowStyle & WS_VISIBLE) == 0)
02404         return(FALSE);
02405 
02406     // If the pointer is over main window background, return standard help
02407     if (WindowUnderPointer == TheWindow)
02408         return(GetStatusLineText(pPreviewDlg, 0, Result));
02409 
02410     // Otherwise, see if we can find help for the specific gadget
02411     CWindowID hGadget;
02412     INT32 i = 0;
02413     while (BubbleHelp[i].Gadget != NULL)
02414     {
02415         hGadget = GetDlgItem(TheWindow, BubbleHelp[i].Gadget);
02416         if (WindowUnderPointer == hGadget && GetStatusLineText(pPreviewDlg, BubbleHelp[i].Gadget, Result))
02417             return(TRUE);
02418         i++;
02419     }
02420     return FALSE;
02421 #else
02422     return TRUE;
02423 #endif
02424 }

void PreviewDialog::GridLockRect DocRect TheRect,
INT32  GridSize
[protected]
 

GridLocks all 4 coordinates of the rectangle using HalfGridLock Note: stolen from ColourEditDlg rendering routines.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> from Jason code in coldlog.cpp
Date:
28/7/97
Parameters:
TheRect - A MILLIPOINT DocRect to be grid-locked [INPUTS] GridSize - the size of the grid to lock to, in millipoints
TheRect is updated as appropriate [OUTPUTS]

Definition at line 1361 of file prevwdlg.cpp.

01362 {
01363     TheRect->lo.x = HalfGridLock(TheRect->lo.x, GridSize);
01364     TheRect->lo.y = HalfGridLock(TheRect->lo.y, GridSize);
01365     TheRect->hi.x = HalfGridLock(TheRect->hi.x, GridSize);
01366     TheRect->hi.y = HalfGridLock(TheRect->hi.y, GridSize);
01367 }

INT32 PreviewDialog::HalfGridLock INT32  Position,
INT32  GridSize
[inline, protected]
 

Grid-locks a given plotting poisition to lie over a grid (usually the output device-pixel grid). The result is shifted by half the grid size to grid-lock to the _center_ of a pixel rather than the edges. Note: stolen from ColourEditDlg rendering routines.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> from Jason code in coldlog.cpp
Date:
28/7/97
Parameters:
Position - The X/Y position, in millipoints [INPUTS] GridSize - the size of the grid to lock to, in millipoints
Returns:
Position, locked (by rounding) to a grid of the given size, and offset by half a grid.

Definition at line 1317 of file prevwdlg.cpp.

01318 {
01319     // By truncating down to the nearest grid point, and adding half the grid value,
01320     // we achieve rounding to the nearest offset-grid position. 
01321 
01322     // NOTE:
01323     // The original algorithm incorrectly rounded negative numbers towards
01324     // zero. Negative numbers should be rounded towards negative infinity.
01325     // The algorithm has been corrected by always rounding a positive number
01326     // and restoring the original sign of the number after rounding.
01327 
01328     BOOL bNegative = FALSE;             // Assume the number is positive
01329 
01330     if (Position < 0)                   // If the number if not positive
01331     {                                   // note the fact and make positive
01332         bNegative   = TRUE;
01333         Position    = -Position;
01334     }
01335 
01336     Position -= Position % GridSize;
01337     Position += GridSize / 2;
01338 
01339     if (bNegative)                      // If the number was negative
01340         Position = -Position;           // restore the sign
01341 
01342     return (Position);
01343 }

TCHAR * PreviewDialog::HelpCallbackHandler wxWindow *  Window,
UINT32  Item,
void *  UserData
[static, protected]
 

Help callback handler to provide bubble help for the POreview Diaolg.

Author:
Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com> (Based onn Jason code)
Date:
21/05/97
Parameters:
Window - The window to get help for [INPUTS] Item - The control to get help for UserData - User-supplied data (not used)
Returns:
The bubble help string to use, or NULL if no help is available.

Definition at line 2316 of file prevwdlg.cpp.

02317 {
02318     static String_256 HelpStringStore;
02319     BOOL ReturnVal = FALSE;
02320 
02321     PreviewDialog* pPreviewDlg = m_pPreviewDialog;
02322     if (pPreviewDlg == NULL)
02323         return(NULL);
02324 
02325     if (Item == _R(IDC_PREVIEW_PLAY))
02326     {
02327         HelpStringStore = String_256(_R(IDS_PREVIEWBH_PLAY));
02328         ReturnVal = TRUE;
02329     }
02330     else if (Item == _R(IDC_PREVIEW_STOP))
02331     {
02332         HelpStringStore = String_256(_R(IDS_PREVIEWBH_STOP));
02333         ReturnVal = TRUE;
02334     }
02335     else if (Item == _R(IDC_PREVIEW_NEXTFRAME))
02336     {
02337         HelpStringStore = String_256(_R(IDS_PREVIEWBH_NEXTFRAME));
02338         ReturnVal = TRUE;
02339     }
02340     else if (Item == _R(IDC_PREVIEW_PREVFRAME))
02341     {
02342         HelpStringStore = String_256(_R(IDS_PREVIEWBH_PREVFRAME));
02343         ReturnVal = TRUE;
02344     }
02345     else if (Item == _R(IDC_PREVIEW_SLIDER))
02346     {
02347         HelpStringStore = String_256(_R(IDS_PREVIEWBH_SLIDER));
02348         ReturnVal = TRUE;
02349     }
02350 
02351     if (ReturnVal)
02352         return((TCHAR *) HelpStringStore);
02353 
02354     return(NULL);
02355     
02356 }

void PreviewDialog::IncrementCurrentBitmap  )  [protected]
 

Moves the current item to be the next bitmap in the list. If we reach the end of the list, it then becomes the first item in the list.

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

Definition at line 1523 of file prevwdlg.cpp.

01524 {
01525     // Local flag to test whether to increment the slider position.
01526 //  BOOL SliderPositionReset = FALSE;
01527 
01528     // Increment the Bitmap if the user has clicked either Play or NextFrame.
01529     if (m_PlayAnimation || m_DisplayNextFrame )
01530     {
01531         m_CurrentItem++;
01532 
01533         // Moving forward so note the current disposal method as the new one
01534         m_DisposalMethod = m_CurrentDisposalMethod;
01535 
01536         // Only activate the slider if we have more than 1 bitmap.
01537         if(m_BitmapListSize > 1)
01538         {
01539             // Decrement the slider.
01540             m_SliderPosition--;
01541 
01542             // If the slider is set to the end, place it back at the start.
01543             if (m_SliderPosition <= 0)
01544                 m_SliderPosition = m_BitmapListSize;    
01545         }   
01546 
01547         // Set the slider to the correct position.
01548         SetSliderPosition(m_SliderPosition);
01549     }
01550