BitmapExportPreviewDialog Class Reference

#include <bmpexprw.h>

Inheritance diagram for BitmapExportPreviewDialog:

DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 BitmapExportPreviewDialog (CWindowID ParentWnd=NULL)
 Constructs a Preview Dialog.
 ~BitmapExportPreviewDialog ()
 Destructor.
BOOL DoWithExportOptions (BitmapExportOptions *pExportOptions, UINT32 Num)
 Receives bitmap export options, which are passed to the export filter to export the document into a temporary disk file. This file is then imported back to be displayed in one of the preview rectangles.
void InitPreviewDialog (BmapPrevDlg *pParentDlg, Filter *pFilter)
 Creates and shows a Preview dialog.
UINT32 GetActiveBitmap ()
void ChangeActiveBitmap (UINT32 Active)
 Sets new active bitmap and makes the frame around it visible (and the one around the other bitmap invisible). The current zoom factor is also updated.
const KernelBitmapGetActiveKernelBmp ()
PreviewTool GetCurrentTool ()
BOOL DoBrowserPreview (BrowserPreviewOptions BrowserOptions)
 Browser previewing. Simply calls GenerateHTMLStub function in the bitmap data object to do the work.
BOOL OnExport (BitmapExportOptions *pExportOptions)
 Alows export of the document into a temp file to be requested on pressing the Export button in the dialog.
virtual MsgResult Message (Msg *Message)
 Handles all the Preview dialog's messages.
virtual void DoCommand (StringBase *CommandID)
 Called when a menu command is selected to perform the respective operation.
void InitialiseBitmapPaletteInformation (BitmapExportOptions *pExportOptions, INT32 Num=0)
 Copies the palette information to the preview image information block. Depending on the value of 'Num' passed in, then either the currently active bitmap, or both the bitmaps are updated.
void SetFilter (Filter *pFilter)
void SetNeedBitmapCopied (BOOL State)

Static Public Member Functions

static OpState GetState (String_256 *, OpDescriptor *)
 Returns the OpState of the Preview dialogue operation.
static BOOL Init ()
 Creates an OpDescriptor for a Preview Dialog.

Static Public Attributes

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

Protected Member Functions

void RenderControl (ReDrawInfoType *pExtraInfo, UINT32 GadgetID)
 The redraw handling for the two draw controls in the dialog. Depending on the zoom flag (m_ZoomRectRender) either the zoom rectangle, or the whole bitmap is drawn in the control.
BOOL InitDialog ()
 Sets initial dialog values.
BOOL SetUpCallBack ()
void DoPush (DocCoord *NewPos)
 Pushes the bitmaps by translating the current view rectangle.
void CalcViewRect (double NewZoomFactor, DocCoord *Pos)
 Calculates a new view rectangle using the zoom factor and the position. Pass a negative value for 'Zoom to Fit'. If null is passed for pos, the centre of the control is assumed.
void DoZoom (DocCoord *NewPos)
 Removes the last zoom rectangle and draws the new one as part of the zoom to rectangle operation.
double FindNearestZoom (BOOL Up)
 Searches the list of the pre-defined zoom factors and finds the one nearest to the current one, but above it (Up == TRUE), or below it (Up = FALSE). Current zoom factor <= the smallest (10%) returns new zoom factor of 10%. Similarly current zoom factor <= the greatest(25601%) returns 25601.
void DrawZoomRect ()
 Draws the zoom rectangle, by setting the zoom flag and invalidating the controls.
void ZoomToRect ()
 Implements zoom to rectangle. The rectangle is defined by m_CurrentPos and m_StartPos. Very small rectangles are treated as click-zooms.
void DisplayZoomFactor ()
 Displays the zoom factor.
void SetCurrentCursor (UINT32 id)
 Sets the cursor depending on the current tool mode and the control.
void DeleteCurrentCursor ()
 Sets the cursor depending on the current tool mode.
void DisplayBitmapInfo ()
 Displays the file and image sizes and the file size difference between the two bitmaps.
void ResetInfo (UINT32 id)
 Resets the bubble help system and displays status text for the control the mouse is over. Called on a mouse operation.
void DoBubbleHelp ()
 Displays bubble help (if any) for the control the mouse is over.
void OnZoomTool ()
 Selects the zoom tool and displays the zoom tool button pressed (and the push tool one) released.
void OnPushTool ()
 Selects the push tool and displays the push tool button pressed (and the zoom tool one) released.
void On1to1 ()
void On100Percent ()
void OnColourSelectorTool ()
 This function is called when the user clicks on the Colour Selector.
INT32 GetPaletteIndexOfColour (ReDrawInfoType *param, CGadgetID Gadget)
void InitFileTypeList ()
 This function is called to initialise the file type drop lists which enables the user to switch the preview image between different file types Also initialises the file type variable in BmapPrevDlg.
void HandleFileTypeListChange (INT32 Index)
 When the user makes a selection from the file type drop-lists, this function carries out any necessary changes required.

Protected Attributes

GRenderRegionm_pRender
BitmapPreviewData BitmapData [2]
KernelBitmappOriginalBitmap [2]
BaseBitmapFilterm_pBmpFilter
BmapPrevDlgm_pParentDlg
MILLIPOINT m_Width
MILLIPOINT m_Height
double m_Scaling
DocRect m_BitmapView
double m_ZoomFactor
UINT32 m_ActiveBitmap
DocCoord m_CurrentPos
DocCoord m_StartPos
PreviewTool m_CurrentTool
BOOL m_Dragging
BOOL m_ZoomRectRender
INT32 m_CurID
UINT32 m_LastCursorOverControlID
MonotonicTime BubbleTimer
BOOL m_BubbleHelpPending
BOOL m_StatusTextChanged
BOOL m_LastAdjustState
BOOL m_MouseOperationStarted
CWindowID m_PreviousWithFocus
BOOL m_bWantCursorRedrawn
BOOL m_bNeedBitmapCopied [2]
INT32 m_TopLevelCursor

Static Protected Attributes

static BitmapExportPreviewDialogm_pBitmapExportPreviewDialog = NULL

Private Member Functions

 CC_DECLARE_DYNCREATE (BitmapExportPreviewDialog)

Detailed Description

Definition at line 133 of file bmpexprw.h.


Constructor & Destructor Documentation

BitmapExportPreviewDialog::BitmapExportPreviewDialog CWindowID  ParentWnd = NULL  ) 
 

Constructs a Preview Dialog.

Author:
Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> (based on code by Neville Humphrys)
Date:
11/4/97

Definition at line 167 of file bmpexprw.cpp.

00168                                                         : DialogOp(BitmapExportPreviewDialog::IDD, 
00169                                                                     BitmapExportPreviewDialog::Mode, 
00170                                                                     0, CC_RUNTIME_CLASS(DialogOp), -1,
00171                                                                     ParentWnd) 
00172 {
00173     m_pBitmapExportPreviewDialog = this;
00174     
00175     m_pRender = NULL;
00176     m_Width = 1;
00177     m_Height = 1;
00178     m_CurrentPos.x = 0;
00179     m_CurrentPos.y = 0;
00180     m_CurrentTool = PREVIEW_PUSH_TOOL;
00181     m_Dragging = FALSE;
00182     m_ZoomRectRender = FALSE;
00183     m_CurID = -1;
00184     m_ActiveBitmap = 0;
00185 
00186 PORTNOTE("other","Removed BubbleHelp")
00187 //  m_LastCursorOverControlID = 0;
00188     m_BubbleHelpPending = TRUE;
00189     m_LastAdjustState = FALSE;
00190     m_MouseOperationStarted = FALSE;
00191     m_PreviousWithFocus = NULL;
00192     m_pBmpFilter = NULL;
00193     m_pParentDlg = NULL;
00194 
00195     m_Scaling = 1.0;
00196     m_ZoomFactor = 100.0;
00197     m_bWantCursorRedrawn = FALSE;
00198 
00199     pOriginalBitmap[0] = NULL;
00200     pOriginalBitmap[1] = NULL;
00201     m_bNeedBitmapCopied[0] = TRUE;
00202     m_bNeedBitmapCopied[1] = TRUE;
00203 }       

BitmapExportPreviewDialog::~BitmapExportPreviewDialog  ) 
 

Destructor.

Author:
Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> (based on code by Neville Humphrys)
Date:
11/4/97

Definition at line 217 of file bmpexprw.cpp.

00218 {
00219     // clean out the render region, if allocated
00220     if (m_pRender)
00221     {
00222         // Delete the render region and its (dialog) view
00223         // Do it by hand as StopRender should have been called already
00224         delete m_pRender->GetRenderView();
00225         delete m_pRender;
00226 //      DestroyGRenderRegion(m_pRender);
00227         m_pRender = NULL;
00228     }
00229 
00230     // check for the same bitmap
00231     if (BitmapData[0].m_pBitmap == BitmapData[1].m_pBitmap)
00232     {
00233         // set the first object's flag so the common data gets deleted
00234         BitmapData[0].m_bIsSameBitmap = FALSE;
00235     }
00236 
00237     // delete the cursor if one is still left
00238     DeleteCurrentCursor();
00239     
00240 PORTNOTE("other","Removed BubbleHelp")
00241 #if !defined(EXCLUDE_FROM_XARALX)
00242     // if there is a bubble help window from a previous call, delete it
00243     if (m_pBubbleWnd != NULL)
00244     {
00245         delete m_pBubbleWnd;
00246         m_pBubbleWnd = NULL;
00247     }
00248 #endif
00249 
00250     // delete the background bitmap file, if one was created
00251     if (BitmapPreviewData::pPagePath != NULL)
00252     {
00253         FileUtil::DeleteFile(BitmapPreviewData::pPagePath);
00254         delete BitmapPreviewData::pPagePath;
00255         BitmapPreviewData::pPagePath = NULL;
00256     }
00257 
00258     // kill the static link to this dialog box
00259     m_pBitmapExportPreviewDialog = NULL;
00260 
00261     //  Get rid of the dynamically allocated KernelBitmap memory, if
00262     //  there has been any.
00263     if( pOriginalBitmap[0] )
00264     {
00265         delete pOriginalBitmap[0];
00266         pOriginalBitmap[0] = NULL; 
00267     }
00268     if( pOriginalBitmap[1] )
00269     {
00270         delete pOriginalBitmap[1];
00271         pOriginalBitmap[1] = NULL; 
00272     }
00273 
00274     // delete the non active export options but keep the active one
00275     // since the active one will be used outside this dlg
00276     // but the inactive one was stored by this dlg and used only here
00277     // See what is active by comparing it with the ptr to the one we
00278     // know we will use "BmapPrevDlg::m_pExportOptions"
00279     if (BitmapData[0].m_pOptions != BmapPrevDlg::m_pExportOptions && BitmapData[0].m_pOptions != NULL)
00280     {
00281         delete BitmapData[0].m_pOptions;
00282         BitmapData[0].m_pOptions = NULL;
00283     }
00284     if (BitmapData[1].m_pOptions != BmapPrevDlg::m_pExportOptions && BitmapData[1].m_pOptions != NULL)
00285     {
00286         delete BitmapData[1].m_pOptions;
00287         BitmapData[1].m_pOptions = NULL;
00288     }
00289 } 


Member Function Documentation

void BitmapExportPreviewDialog::CalcViewRect double  NewZoomFactor,
DocCoord pos
[protected]
 

Calculates a new view rectangle using the zoom factor and the position. Pass a negative value for 'Zoom to Fit'. If null is passed for pos, the centre of the control is assumed.

Author:
Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/04/97
Parameters:
NewZoomFactor - the new zoom factor [INPUTS] Pos - the click position, indicating the centre of the new view
Returns:
None.

Definition at line 2067 of file bmpexprw.cpp.

02068 {
02069     // get the control size
02070     ReDrawInfoType param;
02071     GetKernelRenderedGadgetInfo(_R(IDC_REDRAW1), &param);
02072     MILLIPOINT w = param.dx;
02073     MILLIPOINT h = param.dy;
02074 
02075     if (NewZoomFactor < 0)      // zoom to fit
02076     {
02077         // calculate zoom factor so that the whole bitmap fits in 
02078         m_ZoomFactor = (double(w)/m_Width < double(h)/m_Height ? 
02079                 (double(w)/m_Width) * 100 : (double(h)/m_Height) * 100);
02080         if (m_ZoomFactor <= 0)
02081             m_ZoomFactor = MIN_ZOOM;
02082 
02083         // scale the bitmap width and height
02084         MILLIPOINT Width  = (MILLIPOINT)((m_Width  * m_ZoomFactor) / 100);
02085         MILLIPOINT Height = (MILLIPOINT)((m_Height * m_ZoomFactor) / 100);
02086 
02087         m_BitmapView.lo.x = w/2 - Width / 2;
02088         m_BitmapView.hi.x = w/2 + Width / 2;
02089         m_BitmapView.lo.y = h/2 - Height / 2;
02090         m_BitmapView.hi.y = h/2 + Height / 2;
02091     }
02092     else 
02093     {
02094         double OldZoomFactor = m_ZoomFactor;
02095 
02096         // set the new zoom factor
02097         m_ZoomFactor = NewZoomFactor;
02098 
02099         // check for zoom factor > MAX_ZOOM
02100         
02101         // check for the first bitmap
02102         if (NewZoomFactor > (double)MAX_ZOOM) 
02103             m_ZoomFactor = (double) MAX_ZOOM;
02104 
02105         // now for the second one
02106         if (m_ZoomFactor * m_Scaling > (double)MAX_ZOOM)
02107             m_ZoomFactor = double(MAX_ZOOM) / m_Scaling;
02108             
02109 
02110         // check for zoom factor < MIN_ZOOM
02111 
02112         // first bitmap
02113         if (m_ZoomFactor < (double)MIN_ZOOM) 
02114             m_ZoomFactor = (double) MIN_ZOOM;
02115 
02116         // the second one
02117         if (m_ZoomFactor * m_Scaling < (double)MIN_ZOOM)
02118             m_ZoomFactor = double(MIN_ZOOM) / m_Scaling;
02119         
02120 
02121         // scale the bitmap width and height
02122         MILLIPOINT Width  = (MILLIPOINT)((m_Width  * m_ZoomFactor) / 100);
02123         MILLIPOINT Height = (MILLIPOINT)((m_Height * m_ZoomFactor) / 100);
02124 
02125         // calculate new view based on the last one
02126 
02127         // find the centre of the view
02128         DocCoord Centre;
02129         Centre.x = (m_BitmapView.hi.x + m_BitmapView.lo.x) / 2;
02130         Centre.y = (m_BitmapView.hi.y + m_BitmapView.lo.y) / 2;
02131 
02132         // scale view
02133         m_BitmapView.lo.x = Centre.x - Width / 2;
02134         m_BitmapView.hi.x = Centre.x + Width / 2;
02135         m_BitmapView.lo.y = Centre.y - Height/ 2;
02136         m_BitmapView.hi.y = Centre.y + Height/ 2;
02137 
02138         
02139         DocCoord Pos;
02140         // if no position passed assume click in the middle of the control
02141         if (pos == NULL)
02142         {
02143             Pos.x = w/2;
02144             Pos.y = h/2; 
02145         }
02146         else 
02147             Pos = *pos;
02148 
02149         // scale the passed point according to the new zoom
02150         DocCoord ScaledPos;
02151         
02152         // test to prevent 'divide by zero' exception
02153         if (OldZoomFactor == 0)
02154             OldZoomFactor = MIN_ZOOM;
02155 
02156         ScaledPos.x = (MILLIPOINT)(Centre.x + (Pos.x - Centre.x) * (m_ZoomFactor / OldZoomFactor));
02157         ScaledPos.y = (MILLIPOINT)(Centre.y + (Pos.y - Centre.y) * (m_ZoomFactor / OldZoomFactor));
02158 
02159         // translate the new view rectangle to be centered on the scaled position
02160         m_BitmapView.Translate(w/2 - ScaledPos.x, h/2 - ScaledPos.y);
02161     }
02162 
02163     // make sure one of the corners is aligned at a pixel
02164 
02165     // get the pixel size in millipoints
02166     MILLIPOINT PixSize = 0;
02167     DocUnitList* pDocUnitList = DocUnitList::GetCurrentDocUnitList();
02168     ERROR3IF(pDocUnitList == NULL, "BmpPrefsDlg::InitDialog() - no pDocUnitList!");
02169     if (pDocUnitList != NULL)
02170     {
02171         Unit* pPixelUnit = pDocUnitList->FindUnit(PIXELS);
02172         ERROR3IF(pPixelUnit == NULL, "BmpPrefsDlg::InitDialog() - no pixel units!");
02173         if (pPixelUnit != NULL)
02174             PixSize = (MILLIPOINT) pPixelUnit->GetMillipoints();
02175     }
02176 
02177     // shift the rectangle, so that the lower left corner is aligned at a pixel boundary
02178     if (PixSize != 0)
02179     {
02180         MILLIPOINT ShiftX = m_BitmapView.lo.x % PixSize;
02181         MILLIPOINT ShiftY = m_BitmapView.lo.y % PixSize;
02182 
02183         m_BitmapView.Translate(-ShiftX, -ShiftY);
02184     }
02185 
02186 
02187     // display the new zoom factor
02188     DisplayZoomFactor();
02189     
02190     // Render the controls
02191     InvalidateGadget(_R(IDC_REDRAW1));
02192     InvalidateGadget(_R(IDC_REDRAW2));
02193 }

BitmapExportPreviewDialog::CC_DECLARE_DYNCREATE BitmapExportPreviewDialog   )  [private]
 

void BitmapExportPreviewDialog::ChangeActiveBitmap UINT32  Active  ) 
 

Sets new active bitmap and makes the frame around it visible (and the one around the other bitmap invisible). The current zoom factor is also updated.

Author:
Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/04/97
Parameters:
Active - the active bitmap - either 1 or 2 [INPUTS]
Returns:
None.

Definition at line 2348 of file bmpexprw.cpp.

02349 {
02350     ERROR3IF((Active != 1) && (Active != 2),"Invalid active bitmap passed");
02351 
02352     if (m_ActiveBitmap == Active) // no change
02353         return; 
02354 
02355     if (BitmapData[Active - 1].m_pBitmap == NULL)
02356         return; // can't select non-existent bitmap
02357 
02358     // remember it
02359     m_ActiveBitmap = Active;
02360 
02361     // THE export options are the active side of the export dlg
02362     if (BitmapData[m_ActiveBitmap - 1].m_pOptions)
02363     {
02364         // In other places the static pointer is handled carefully - but not here!
02365         BmapPrevDlg::m_pExportOptions = BitmapData[m_ActiveBitmap - 1].m_pOptions;
02366         // the filter should match THE export options
02367         m_pBmpFilter = BmapPrevDlg::m_pExportOptions->FindBitmapFilterForTheseExportOptions();
02368         if (m_pBmpFilter)
02369             m_pBmpFilter->SetExportOptions(BmapPrevDlg::m_pExportOptions);
02370     }
02371     
02372     // define the active one
02373     BOOL ActiveFirst = (Active == 1);
02374 
02375     // The palette sort data is out of date so force it to be regenerated the next time it is used
02376     BitmapExportPaletteInterface::InvalidateSortedPalette();
02377 
02378     // update the tab to reflect the new active side of the dlg
02379     if (m_pParentDlg)
02380         m_pParentDlg->UpdateCurrentTab();
02381 
02382     // update the frame title string
02383     DisplayZoomFactor();
02384 
02385     // hide the frame around the previous active control and show it around the new active one
02386 //  HideGadget(_R(IDC_ACTIVEFRAME1), !ActiveFirst);
02387 //  HideGadget(_R(IDC_ACTIVEFRAME2), ActiveFirst);
02388 
02389     EnableGadget(_R(IDC_ACTIVE1), ActiveFirst);
02390     EnableGadget(_R(IDC_ACTIVE2), !ActiveFirst);
02391     
02392     //  Since the active preview image has changed, have to enable/disable the appropriate
02393     //  file type drop-lists.
02394     //  If we want to have both of the drop-lists disabled, then we can return now.
02395     // cant change the frame if we are a create bitmap option
02396     if (!BmapPrevDlg::m_bIsCreateBitmap)
02397     {
02398         if( Active == 1 )
02399         {
02400             //  If the user has clicked on the first image, need to enable the first list, and
02401             //  disable the second list.
02402             EnableGadget( _R(IDC_FILE_TYPE_LIST),   TRUE );
02403             EnableGadget( _R(IDC_FILE_TYPE_LIST2),  FALSE );
02404         }
02405         else if( Active == 2 )
02406         {
02407             EnableGadget( _R(IDC_FILE_TYPE_LIST),   FALSE );
02408             EnableGadget( _R(IDC_FILE_TYPE_LIST2),  TRUE );
02409         }
02410     }
02411 }

void BitmapExportPreviewDialog::DeleteCurrentCursor  )  [protected]
 

Sets the cursor depending on the current tool mode.

Author:
Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
Date:
07/5/97

Definition at line 410 of file bmpexprw.cpp.

00411 {
00412     // pop the cursor from the stack
00413     if (m_CurID != -1)
00414         delete CursorStack::GPop(m_CurID);
00415     m_CurID = -1;
00416 }

void BitmapExportPreviewDialog::DisplayBitmapInfo  )  [protected]
 

Displays the file and image sizes and the file size difference between the two bitmaps.

Author:
Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/5/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 2478 of file bmpexprw.cpp.

02479 {
02480     if ((BitmapData[0].m_pBitmap == NULL) || (BitmapData[1].m_pBitmap == NULL))
02481     {
02482         // no bitmap yet
02483         EnableGadget(_R(IDC_IMAGESIZE1), FALSE);
02484         EnableGadget(_R(IDC_IMAGESIZE2), FALSE);
02485         EnableGadget(_R(IDC_FILESIZE1), FALSE);
02486         EnableGadget(_R(IDC_FILESIZE2), FALSE);
02487         HideGadget(_R(IDC_FILEDIFF1), TRUE);
02488         HideGadget(_R(IDC_FILEDIFF2), TRUE);
02489         return;
02490     }
02491 
02492     EnableGadget(_R(IDC_IMAGESIZE1), m_ActiveBitmap == 1);
02493     EnableGadget(_R(IDC_IMAGESIZE2), m_ActiveBitmap == 2);
02494     EnableGadget(_R(IDC_FILESIZE1), m_ActiveBitmap == 1);
02495     EnableGadget(_R(IDC_FILESIZE2), m_ActiveBitmap == 2);
02496 
02497     String_64 ImageSize;
02498     String_64 FileSize;
02499     
02500     // for the first image
02501     BitmapData[0].GenerateBitmapInfoStrings(ImageSize, FileSize, TRUE);
02502     SetStringGadgetValue(_R(IDC_IMAGESIZE1), ImageSize);
02503     SetStringGadgetValue(_R(IDC_FILESIZE1), FileSize);
02504 
02505     // for the second image
02506     BitmapData[1].GenerateBitmapInfoStrings(ImageSize, FileSize, TRUE);
02507     SetStringGadgetValue(_R(IDC_IMAGESIZE2), ImageSize);
02508     SetStringGadgetValue(_R(IDC_FILESIZE2), FileSize);
02509 
02510     // now set the file difference
02511 
02512     // calc the file difference
02513     INT32 diff = BitmapData[0].m_FileSize - BitmapData[1].m_FileSize;
02514 
02515     // display only for the selected bitmap
02516     HideGadget(_R(IDC_FILEDIFF1), m_ActiveBitmap != 1);
02517     HideGadget(_R(IDC_FILEDIFF2), m_ActiveBitmap != 2);
02518 
02519     String_64 FileDiff(_R(IDS_FILE_DIFF));
02520 
02521     if (diff != 0)
02522     {
02523         String_32 s;
02524         s.MakeMsg(_R(IDS_FILE_DIFF_BYTES), abs(diff));
02525         FileDiff += s;
02526     }
02527 
02528     if (m_ActiveBitmap == 1)
02529     {
02530         if (diff > 0)
02531             FileDiff += String_16(_R(IDS_LARGER));
02532         else if (diff < 0)
02533             FileDiff += String_16(_R(IDS_SMALLER));
02534         else
02535             FileDiff += String_16(_R(IDS_SAMESIZE));
02536 
02537         SetStringGadgetValue(_R(IDC_FILEDIFF1),FileDiff);
02538     }
02539     else
02540     {
02541         if (diff < 0)
02542             FileDiff += String_16(_R(IDS_LARGER));
02543         else if (diff > 0)
02544             FileDiff += String_16(_R(IDS_SMALLER));
02545         else
02546             FileDiff += String_16(_R(IDS_SAMESIZE));
02547 
02548         SetStringGadgetValue(_R(IDC_FILEDIFF2),FileDiff);
02549     }
02550 }

void BitmapExportPreviewDialog::DisplayZoomFactor  )  [protected]
 

Displays the zoom factor.

Author:
Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/04/97
Parameters:
None. [INPUTS]
Returns:
None.

Definition at line 2427 of file bmpexprw.cpp.

02428 {
02429     // get the "Selected" string
02430     String_32 Sel(_R(IDS_PREVIEW_SELECTED));
02431 
02432     // for the first image
02433     String_32 Str1;
02434     Str1.MakeMsg(_R(IDS_PREVIEW_IMAGEA), (UINT32)(m_ZoomFactor + 0.5));
02435     if (m_ActiveBitmap == 1)
02436     {
02437         Str1 += Sel;
02438         EnableGadget(_R(IDC_ACTIVE1), TRUE);
02439     }
02440     else
02441         EnableGadget(_R(IDC_ACTIVE1), FALSE);
02442 
02443     SetStringGadgetValue(_R(IDC_ACTIVE1),Str1);
02444     InvalidateGadget(_R(IDC_FILE_TYPE_LIST)); // so the outline is not drawn over the top of the drop down
02445 
02446     // for the second image
02447     Str1.MakeMsg(_R(IDS_PREVIEW_IMAGEB), UINT32(m_ZoomFactor * m_Scaling + 0.5));
02448     if (m_ActiveBitmap == 2)
02449     {
02450         Str1 += Sel;
02451         EnableGadget(_R(IDC_ACTIVE2), TRUE);
02452     }
02453     else
02454         EnableGadget(_R(IDC_ACTIVE2), FALSE);
02455 
02456     SetStringGadgetValue(_R(IDC_ACTIVE2),Str1);
02457     InvalidateGadget(_R(IDC_FILE_TYPE_LIST2)); // so the outline is not drawn over the top of the drop down
02458 
02459     DisplayBitmapInfo();
02460 }

BOOL BitmapExportPreviewDialog::DoBrowserPreview BrowserPreviewOptions  BrowserOptions  ) 
 

Browser previewing. Simply calls GenerateHTMLStub function in the bitmap data object to do the work.

> BOOL BitmapExportPreviewDialog::DoBrowserPreview(BrowserPreviewOptions BrowserOptions)

Author:
Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/7/97
Parameters:
BrowserOptions - options to be used when generating the html page [INPUTS]
- [OUTPUTS]
Returns:
TRUE if successful, FALSE otherwise

Definition at line 1319 of file bmpexprw.cpp.

01320 {
01321     if ((m_ActiveBitmap == 1) || (m_ActiveBitmap == 2))
01322         return BitmapData[m_ActiveBitmap - 1].GenerateHTMLStub(BrowserOptions);
01323     else
01324         return FALSE;
01325 }

void BitmapExportPreviewDialog::DoBubbleHelp  )  [protected]
 

Displays bubble help (if any) for the control the mouse is over.

Author:
Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/5/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 595 of file bmpexprw.cpp.

00596 {
00597 PORTNOTE("other","Removed BubbleHelp")
00598 #if !defined(EXCLUDE_FROM_XARALX)
00599     // if there is a bubble help window from a previous call, delete it
00600     if (m_pBubbleWnd != NULL)
00601     {
00602         delete m_pBubbleWnd;
00603         m_pBubbleWnd = NULL;
00604     }
00605 #endif
00606     
00607     // check if we are over a control
00608     if (!m_LastCursorOverControlID)
00609         return;
00610 
00611     UINT32 BubbleID = 0;
00612 
00613     // find the bubble text ID from the Gadget ID
00614     if( m_LastCursorOverControlID == _R(IDC_ZOOM_TOOL) )
00615         BubbleID = _R(IDS_PREVIEW_ZOOM_TOOL);
00616     else
00617     if( m_LastCursorOverControlID == _R(IDC_PUSH_TOOL) )
00618         BubbleID = _R(IDS_PREVIEW_PUSH_TOOL);
00619     else
00620     if( m_LastCursorOverControlID == _R(IDC_ZOOM_TO_FIT) )
00621         BubbleID = _R(IDS_PREVIEW_ZOOM_TO_FIT);
00622     else
00623     if( m_LastCursorOverControlID == _R(IDC_100PERCENT) )
00624         BubbleID = _R(IDS_PREVIEW_ZOOM_TO_100);
00625     else
00626     if( m_LastCursorOverControlID == _R(IDC_1TO1) )
00627         BubbleID = _R(IDS_PREVIEW_1TO1);
00628     else
00629     if( m_LastCursorOverControlID == _R(IDC_COLOUR_SELECTOR) )
00630         BubbleID = _R(IDS_PREVIEW_COLOUR_SELECTOR);
00631     else
00632         m_LastCursorOverControlID = 0;
00633 
00634     // no bubble found
00635     if (BubbleID == 0)
00636         return;
00637     
00638 PORTNOTE("other","Removed BubbleHelp")
00639 #ifndef EXCLUDE_FROM_XARALX
00641     String_256 BubbleText(BubbleID);
00642 
00643     // Make a new bubble help window
00644     try
00645     {
00646         m_pBubbleWnd = new BubbleHelpWnd;
00647     }
00648     catch( CMemoryException )
00649     {
00650         TRACEALL( _T("Unable to create bubble help window!\n"));
00651         return;
00652     }
00653 
00654     // Create the actual window
00655     if (!m_pBubbleWnd->Create())
00656     {
00657         TRACEALL( _T("Could not Init bubble help window\n"));
00658         return;
00659     }
00660 
00661     // set the text
00662     if (!m_pBubbleWnd->SetText(BubbleText))
00663         return;  // no bubble help for this item
00664 
00665     // display the window
00666     m_pBubbleWnd->Show();
00667 #endif
00668 }

void BitmapExportPreviewDialog::DoCommand StringBase CommandID  )  [virtual]
 

Called when a menu command is selected to perform the respective operation.

Author:
Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/5/97
Parameters:
CommandID - the token of the menu selected command [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 3056 of file bmpexprw.cpp.

03057 {
03058     if (*CommandID == (PCTSTR)OPTOKEN_PREVIEW_ZOOM_TOOL)
03059         OnZoomTool(); // "Zoom Tool"
03060     else if (*CommandID == (PCTSTR)OPTOKEN_PREVIEW_PUSH_TOOL)
03061         OnPushTool(); // "Push Tool"
03062     else if (*CommandID == (PCTSTR)OPTOKEN_PREVIEW_COLOUR_SELECTOR_TOOL)
03063         OnColourSelectorTool(); // 'Colour Selector'
03064     else if (*CommandID == (PCTSTR)OPTOKEN_PREVIEW_ZOOM_TO_FIT)
03065         CalcViewRect(-1, NULL); //"Zoom to Fit"
03066     else if (*CommandID == (PCTSTR)OPTOKEN_PREVIEW_ZOOM_TO_100)
03067         On100Percent(); // "Zoom to 100%"
03068     else if (*CommandID == (PCTSTR)OPTOKEN_PREVIEW_1TO1)
03069         On1to1(); // "Zoom to 100%"
03070     else if (*CommandID == (PCTSTR)OPTOKEN_PREVIEW_HELP)
03071     {
03072         // call the parent dialog to do the help 
03073         if (m_pParentDlg != NULL)
03074             m_pParentDlg->OnHelpButtonClicked();
03075     }
03076 }

void BitmapExportPreviewDialog::DoPush DocCoord NewPos  )  [protected]
 

Pushes the bitmaps by translating the current view rectangle.

Author:
Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/04/97
Parameters:
NewPos - the new mouse position (in millipoints) [INPUTS]
Returns:
None.

Definition at line 2209 of file bmpexprw.cpp.

02210 {
02211     // translate the view 
02212     DocCoord diff(NewPos->x - m_CurrentPos.x, NewPos->y - m_CurrentPos.y);
02213     m_BitmapView.Translate(diff.x, diff.y);
02214 
02215     // remember the new position
02216     m_CurrentPos = *NewPos;
02217 
02218     // Render the controls
02219     InvalidateGadget(_R(IDC_REDRAW1));
02220     InvalidateGadget(_R(IDC_REDRAW2));
02221     PaintGadgetNow(_R(IDC_REDRAW1));
02222     PaintGadgetNow(_R(IDC_REDRAW2));
02223 }

BOOL BitmapExportPreviewDialog::DoWithExportOptions BitmapExportOptions pOptions,
UINT32  Num
 

Receives bitmap export options, which are passed to the export filter to export the document into a temporary disk file. This file is then imported back to be displayed in one of the preview rectangles.

Author:
Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/5/97
Parameters:
pExportOptions - pointer to bitmap export options [INPUTS] Num - in which preview box to set the bitmap (either 1, or 2)
- [OUTPUTS]
Returns:
TRUE if successful, FALSE otherwise

Definition at line 2670 of file bmpexprw.cpp.

02671 {
02672     ERROR3IF(pOptions == NULL,"NULL Export options parameter passed");
02673     ERROR3IF((Num != 1) && (Num != 2), "Invalid num of preview rectangle passed");
02674 
02675 /*  // set the filter to match the new options
02676     // if it hasn't been set for some reason
02677 
02678   if (m_pBmpFilter == NULL)
02679         m_pBmpFilter = pOptions->FindBitmapFilterForTheseExportOptions();
02680 */
02681     // test for bitmap filter
02682     if ((m_pBmpFilter == NULL) || (!m_pBmpFilter->IS_KIND_OF(BaseBitmapFilter)))
02683     {
02684         InformError(_R(IDT_CANT_FIND_FILTER));
02685         return FALSE;
02686     }
02687 
02688     // create a disk file
02689     CCDiskFile TempDiskFile(1024, FALSE, TRUE);
02690     
02691     // create a temp file 
02692     PathName TempPath = FileUtil::GetTemporaryPathName();
02693 
02694     // If we want any change of re-importing IM based filters, they need an extension
02695     if( m_pBmpFilter->GetFilterType() == IMAGEMAGICK )
02696         TempPath.SetType( ((ImageMagickFilter*)m_pBmpFilter)->GetExtension() );
02697 
02698 // Set flag telling exporter that we are NOT exporting a temporary file!
02699 pOptions->SetTempFileFlag(TRUE);
02700 
02701     BOOL ok = TRUE;
02702 
02703     Progress    SlowJob;
02704 
02705     try  // to export the document to the temp file
02706     {
02707         //no need for preview bitmap
02708         m_pBmpFilter->IncludePreviewBmp(FALSE);
02709 
02710         // try to export the document
02711         BOOL ExportedOK = TRUE;
02712 
02713         if (pOptions->GetSelectionType() != ABITMAP)
02714         {
02715             // export the document
02716             ExportedOK = m_pBmpFilter->DoExportWithOptions(this, &TempDiskFile, &TempPath, 
02717                                                     Document::GetCurrent(), pOptions);
02718         }
02719         else
02720         {
02721             ERROR3IF(!pOptions->IS_KIND_OF(JPEGExportOptions),"Bad bitmap export options type");
02722             JPEGExportOptions *pJPEGOptions = (JPEGExportOptions *)pOptions;
02723 
02724             // get the bitmap to export from the options
02725             KernelBitmap* pBitmap = pJPEGOptions->GetKernelBitmap();
02726             
02727             if (pBitmap != NULL)
02728             {
02729                 // export the bitmap
02730                 ExportedOK = ((JPEGExportFilter *)m_pBmpFilter)->DoExportBitmapWithOptions(this, 
02731                                                 &TempDiskFile, &TempPath, pBitmap, pJPEGOptions);
02732 
02733                 //restore the pointer to the bitmap, which got cleared during the export
02734                 if (ExportedOK)
02735                     pJPEGOptions->SetKernelBitmap(pBitmap);
02736             }
02737             else
02738             {
02739                 ok = FALSE;
02740             }
02741         }
02742 
02743         if (!ExportedOK)
02744         {
02745             UINT32 ErrNo = Error::GetErrorNumber();
02746             // Something went a bit wrong - tell the user what it was.
02747             // Supress the error if it was the 'user has cancelled one'
02748             if ((ErrNo != _R(IDN_USER_CANCELLED)) && ( ErrNo != _R(IDW_CANCELEXPORT)))
02749             {
02750                 InformError();
02751                 m_pBmpFilter->DeleteExportFile(&TempDiskFile);
02752             }
02753             else
02754             {
02755                 // otherwise remove the error so it won't get reported
02756                 Error::ClearError();
02757             }
02758 
02759             return FALSE;
02760         }
02761     }
02762     // See if there was a file io error
02763     catch( CFileException )
02764     {
02765         UINT32 ErrNo = Error::GetErrorNumber();
02766         // Report the error if no one else did
02767         if ((ErrNo != _R(IDN_USER_CANCELLED)) && (ErrNo != _R(IDW_CANCELEXPORT)) && 
02768             (ErrNo != _R(IDW_CANCELLEDBMPEXPORT)))
02769         {
02770             InformError();
02771         }
02772         else
02773             Error::ClearError();    // otherwise remove the error so it won't get reported
02774 
02775         // Make sure that the file is closed and deleted
02776         try
02777         {
02778             // First try and delete it (tries to close it first)
02779             if (m_pBmpFilter)
02780                 m_pBmpFilter->DeleteExportFile(&TempDiskFile);
02781 
02782             // Double check to make sure it is closed.
02783             if (TempDiskFile.isOpen())
02784                 TempDiskFile.close();
02785         }
02786         catch( CFileException )
02787         {
02788             // Failed to close the file - not much we can do about it really
02789         }
02790 
02791         return FALSE;
02792     }
02793 
02794     if (ok)
02795     {
02796         // try to import the temporary file
02797 
02798         // close it first 
02799         if (TempDiskFile.isOpen())
02800             TempDiskFile.close();
02801 
02802         // open it back for reading
02803         ok = TempDiskFile.open(TempPath, ios::in | ios::binary);
02804 
02805         // Make sure we have a generic filter!
02806         GenericFilter *pGenericFilter = Filter::GetGenericFilter();
02807 
02808         if (ok && pGenericFilter != NULL)
02809         {
02810             // remember the file size
02811             UINT32 FileSize = TempDiskFile.Size();
02812 
02813             // find the best filter for the import
02814             Filter *pImportFilter = pGenericFilter->GetBestFilter(&TempDiskFile);
02815             KernelBitmap *pKernelBitmap;
02816 
02817             // we only handle bitmap filters
02818             if (pImportFilter && !pImportFilter->IS_KIND_OF(BaseBitmapFilter))
02819             {
02820                 // not a bitmap filter 
02821                 pImportFilter = NULL;
02822             }
02823 
02824             // import the file
02825             if (pImportFilter != NULL)
02826             {
02827                 // Setup import DPI from export options (this means we get the same resolution bitmap from
02828                 // a PDF)
02829                 ((BaseBitmapFilter *)pImportFilter)->SetImportDPI( pOptions->GetDPI() );
02830 
02831                 // Set the preview bitmap flag to avoid adding the bitmap to the global bitmap list
02832                 ((BaseBitmapFilter *)pImportFilter)->SetPreviewBitmap(TRUE);
02833 
02834                 ok = pImportFilter->ImportBitmap(&TempDiskFile, &pKernelBitmap);
02835 
02836                 // Set it back
02837                 ((BaseBitmapFilter *)pImportFilter)->SetPreviewBitmap(FALSE);
02838 
02839                 // close the file
02840                 TempDiskFile.close();
02841 
02842                 if (ok)
02843                 {
02844                     // check if the bitmap is the same size, so the current view can be preserved
02845                     BOOL NeedDefaultZoom = TRUE; 
02846                     KernelBitmap *pBmp =