bmapprev.cpp

Go to the documentation of this file.
00001 // $Id: bmapprev.cpp 1745 2006-09-08 14:23:18Z luke $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 #include "camtypes.h"  
00100 //#include "bfxatom.h"
00101 #include "bmapprev.h"
00102 //#include "bmpfiltr.h"
00103 //#include "resource.h"
00104 //#include "bmpres.h"       // general bitmap filter based resources
00105 //#include "bmpreres.h"
00106 #include "bmpexprw.h"   // for BitmapExportPreviewDialog
00107 #include "exjpeg.h"
00108 //#include "filtrres.h" // _R(IDS_BMPPREFS_DPITOOSMALL) _R(IDS_BMPPREFS_DPITOOBIG)
00109 //#include "giffiltr.h"
00110 #include "helpuser.h"
00111 //#include "xshelpid.h"
00112 //#include "helppath.h"
00113 #include "layer.h"
00114 #include "lineattr.h"
00115 //#include "makebmp.h"
00116 #include "page.h"
00117 #include "pngfiltr.h"
00118 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00119 //#include "will3.h"
00120 #include "fileutil.h"
00121 #include "filtrmgr.h"   //For FilterManager::FindFilterFromID
00122 #include "filtimag.h"   //The imagemap filter
00123 //#include "resimmap.h" //For imagemap resources
00124 //#include "mfcdlg.h"   
00125 #include "sgliboil.h"   //For SGLibOil::FileExists()
00126 #include "strlist.h"    //For class StringListItem
00127 #include "statline.h"   // for the status line
00128 #include "aprps.h"
00129 //#include "opbevel.h"
00130 #include "ngprop.h"
00131 //#include "dlgcol.h"       // DialogColourInfo
00132 //#include "desnotes.h" //  Design notes
00133 //#include "registry.h"
00134 #include "gpalopt.h"
00135 #include "osrndrgn.h"
00136 //#include "rikdlg.h"       // _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER)
00137 //#include "justin.h"       // for _R(IDS_ZOOM_INFO_FORMAT) a % readout
00138 //#include "oilfltrs.h" // for find filter ext - in camtypes.h [AUTOMATICALLY REMOVED]
00139 //#include "exprwres.h" // for _R(IDS_BITMAPPREVIEWDIALOG)
00140 //#include "units.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00141 
00142 DECLARE_SOURCE("$Revision: 1745 $");
00143 
00144 CC_IMPLEMENT_DYNCREATE(BmapPrevDlg, DialogTabOp)
00145 
00146 #define new CAM_DEBUG_NEW
00147 
00148 //typedef UINT32 JPEG_QUALITY;
00149 
00150 const CDlgMode BmapPrevDlg::Mode    = MODAL;            // Mode of the dialog  
00151 const UINT32 BmapPrevDlg::IDD           = _R(IDD_BMAPPREVDLG);  // Used to uniquely identify the tabbed dialog
00152                                                         // there is no actual resource associated with
00153                                                         // this ID.
00154 #define BUBBLE_TIME             800
00155 #define BUBBLE_HELP_TIMMER_ID   1000
00156 
00157 #define BMPEXP_MAXWIDTH         16383
00158 #define BMPEXP_MAXHEIGHT        16383
00159 #define BMPEXP_MAXDPI           5000
00160 #define BMPEXP_MINDPI           5
00161 
00162 PathName BmapPrevDlg::m_pthExport;
00163 
00164 BOOL BmapPrevDlg::m_bUseExistingPalette         = FALSE;
00165 //ExportFileType BmapPrevDlg::m_OriginalFileType    = GIF_TYPE;
00166 BOOL BmapPrevDlg::m_bClickedOnExport            = FALSE;
00167 BOOL BmapPrevDlg::m_bIsOrderedDither            = TRUE;
00168 BOOL BmapPrevDlg::m_bIsCreateBitmap             = FALSE;
00169 BOOL BmapPrevDlg::m_bSlicingImage               = FALSE;
00170 INT32 BmapPrevDlg::m_NumOfColoursUserAskedFor       = 256;
00171 BitmapExportOptions* BmapPrevDlg::m_pExportOptions = NULL; // static ptr to export options is NULL if it is not handling an export object
00172 
00173 bool BmapPrevDlg::m_MovedWindow = false;
00174 
00175 
00176 struct ChildWindowParameters
00177 {
00178     wxWindow* FirstID;
00179     wxWindow* SecondID;
00180     INT32 Distance;
00181     INT32 TopOffset;
00182 };
00183 
00184 
00185 BOOL BmapPrevDlg::GetNumberOfTransparentColours()
00186 {
00187 //  ASSERT(FALSE);
00188     return 0;
00189 }
00190 
00191 INT32 BmapPrevDlg::GetTransparentColour(INT32 Index)
00192 {
00193 //  ASSERT(FALSE);
00194     return 0;
00195 }
00196 
00197 /********************************************************************************************
00198 >   OpState BmapPrevDlg::GetState(String_256*, OpDescriptor*)
00199     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00200     Created:    17/11/94
00201     Purpose:    The standard GetState fn, does nothing
00202 ********************************************************************************************/
00203 OpState BmapPrevDlg::GetState(String_256*, OpDescriptor*)
00204 {    
00205     OpState OpSt;
00206     return(OpSt);
00207 }
00208          
00209 
00210 /********************************************************************************************
00211 >   BOOL BmapPrevDlg::Init()
00212     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00213     Created:    17/11/94
00214     Purpose:    The standard Init fn for the op. 
00215 ********************************************************************************************/
00216 BOOL BmapPrevDlg::Init()
00217 {  
00218     return (RegisterOpDescriptor(   0,
00219                                     _R(IDS_BMAPPREVDLG), 
00220                                     CC_RUNTIME_CLASS(BmapPrevDlg),
00221                                     OPTOKEN_GIFTABDLG,
00222                                     BmapPrevDlg::GetState));
00223 } 
00224 
00225 /********************************************************************************************
00226 >   virtual BOOL BmapPrevDlg::RegisterYourPagesInOrderPlease()
00227     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00228     Created:    21/11/94
00229     Returns:    return TRUE if all calls to AddAPage returned TRUE
00230     Purpose:    This virtual function will get called to give you a chance to add pages to your
00231                 DialogTabOp. This function will usually make multiple calls to AddAPage to 
00232                 register the initial set of pages to be contained in the tab dialog. The pages
00233                 should all be the same size and be registered in the left to right order in which
00234                 you wish them to appear. 
00235 
00236                 This function get's called directly from the Create method, Don't call it 
00237                 explicitly yourself. If you return FALSE from this method then the Create 
00238                 method will fail. 
00239 
00240     SeeAlso:    DialogTabOp::AddPage, DialogOp::Create
00241 ********************************************************************************************/
00242 BOOL BmapPrevDlg::RegisterYourPagesInOrderPlease()
00243 {
00244     BOOL ok = TRUE;
00245 
00246     // flag indicating we are doing a bitmap export
00247     BOOL bExportABitmap = (m_pExportOptions->GetSelectionType() == ABITMAP);
00248 
00249     if (bExportABitmap)
00250     {
00251         ok = ok && AddAPage(_R(IDD_TBITMAPOPTIONS));
00252     }
00253     else
00254     {
00255         // Not exporting a bitmap from the bitmap gallery
00256         AddAPage(_R(IDD_PALETTE_TAB));
00257     
00258         if (!m_bSlicingImage)
00259             ok = AddAPage(_R(IDD_TBITMAPSIZE));
00260     }
00261 
00262     // add the imagemap and browser pages
00263     bool    fUsedImapOption = false;
00264     if (ok && !bExportABitmap && m_FilterType != MAKE_BITMAP_FILTER && !m_bSlicingImage)
00265     {
00266 PORTNOTE("other","Removed _R(IDD_TIMAPOPTIONS) & _R(IDD_TBROWSER) - isn't wanted yet")
00267 //      ok =  AddAPage(_R(IDD_TBITMAPOPTIONS)) && AddAPage(_R(IDD_TIMAPOPTIONS)) && AddAPage(_R(IDD_TBROWSER));
00268         ok =  AddAPage(_R(IDD_TBITMAPOPTIONS));
00269         fUsedImapOption = true;
00270     }
00271 
00272 PORTNOTE("other","Removed _R(IDD_TIMAPOPTIONS) - isn't wanted yet")
00273 #ifndef EXCLUDE_FROM_XARALX
00274     // design notes stuff on the image map page is needed in image slicing
00275     if (ok && m_bSlicingImage)
00276     {
00277         ok = AddAPage(_R(IDD_TIMAPOPTIONS));
00278         fUsedImapOption = true;
00279     }
00280 
00281     // These needs to be done before the property sheet is sized, else
00282     // it comes out the wrong size
00283     if( ok && fUsedImapOption )
00284         ImageMapOnCreate();
00285 #endif
00286 
00287     return (ok); 
00288 }
00289 
00290 
00291 /********************************************************************************************
00292 >   BmapPrevDlg::BmapPrevDlg(): DialogTabOp(BmapPrevDlg::IDD, BmapPrevDlg::Mode) 
00293     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00294     Created:    17/11/94
00295     Purpose:    The Constructor of the DialogTabOp derived class simply sets modality of the
00296                 dialog, and it's ID.
00297 ********************************************************************************************/
00298 BmapPrevDlg::BmapPrevDlg()
00299   : DialogTabOp(BmapPrevDlg::IDD, BmapPrevDlg::Mode, CC_RUNTIME_CLASS(DialogOp), 0)
00300   , m_pPreviewDlg(NULL)
00301   , m_DialogWnd(NULL)
00302   , m_bImageMapTabCreated(false)
00303   , m_bBrowserPreviewTabCreated(false)
00304   , m_ClipBoardUsage(CLIPBOARD_NONE)    // which of the two clipboard check boxes are set
00305   , m_MouseInsidePaletteControl(true)   // at this point we don't know where the mouse is so this is a safe option
00306   , m_pBubbleWnd(0)                     // used by bubble help
00307   , m_LastCursorOverControlID(0)        // used by bubble help
00308   , m_pBubbleTimer(0)                   // timer is only created when we need it
00309 {
00310     // nasty bit to quickly read the user last used value from the registry
00311     m_ColorModelType = MODEL_INVALID;
00312 PORTNOTE("other","Removed registry usage")
00313 #ifndef EXCLUDE_FROM_XARALX
00314     HKEY optionsKey = OpenRegKeyReadOnly(hAppStateRegKey, TEXT("Options"));
00315     if (optionsKey)
00316     {
00317         HKEY palettesKey = OpenRegKeyReadOnly(optionsKey, TEXT("Palettes"));
00318         if (palettesKey)
00319         {
00320             m_ColorModelType = (ColourTypes)GetRegInt(palettesKey, TEXT("Display"));
00321             CloseRegKey(palettesKey);
00322         }
00323         CloseRegKey(optionsKey);
00324     }
00325 #endif
00326     if (m_ColorModelType != MODEL_RGBHEX    && m_ColorModelType != MODEL_RGBPERCENT && 
00327         m_ColorModelType != MODEL_RGBNUMBER && m_ColorModelType != MODEL_HSV)
00328     {
00329         m_ColorModelType = MODEL_RGBPERCENT;    // fall back value
00330     }
00331 
00332     //  The first time that the dialog appears, we want the palette displayed in 'By Use'
00333     //  mode, so we have to work out the number of times each colour is used in the image.
00334     m_bPopularityValuesWanted = TRUE;
00335 
00336     m_LockSizeUpdates = FALSE;
00337 
00338     // Have to initialise a static variable in the palette right-click menu class.
00339 //  OpPalettePopupCommand::m_pDialog = this;
00340 }
00341 
00342     
00343 /******************************************************************************************
00344 >   BmapPrevDlg::~BmapPrevDlg()
00345     Author:     Alex_Price (Xara Group Ltd) <camelotdev@xara.com>
00346     Created:    09/07/99
00347     Purpose:    Destructor required to reclaim dynamically allocated memory.
00348 ******************************************************************************************/
00349 BmapPrevDlg::~BmapPrevDlg()
00350 {
00351     //  If a bubble-help window exists, then reclaim the memory.
00352 PORTNOTE("other","Removed BubbleHelpWnd usage")
00353 #if !defined(EXCLUDE_FROM_XARALX)
00354     delete m_pBubbleWnd;
00355 #endif
00356     delete m_pBubbleTimer;
00357 /*  
00358     if( m_FilterType == MAKE_BITMAP_FILTER )
00359     {
00360         //  Do nothing at the moment.
00361         //  In this case, we reset the variable later on.
00362     }
00363     else
00364     {
00365         //  Reset the following variable
00366         GRenderOptPalette::UseOldPalette = TRUE;
00367     }
00368 */
00369 PORTNOTE("other","Removed registry usage")
00370 #if !defined(EXCLUDE_FROM_XARALX)
00371     HKEY optionsKey = OpenRegKey( hAppStateRegKey, TEXT("Options") );
00372     if (!optionsKey)
00373         optionsKey = CreateRegKey(hAppStateRegKey, TEXT("Options") );
00374     if (optionsKey)
00375     {
00376         HKEY palettesKey = OpenRegKey(optionsKey, TEXT("Palettes") );
00377         if (!palettesKey)
00378             palettesKey = CreateRegKey(optionsKey, TEXT("Palettes") );
00379         if (palettesKey )
00380         {
00381             //  Set the relevant value in the key.
00382             SetRegInt(palettesKey, TEXT("Display"), m_ColorModelType);
00383             CloseRegKey(palettesKey);
00384         }
00385         CloseRegKey(optionsKey);
00386     }
00387 #endif
00388 /*
00389     // If we are not dealing with the create bitmap copy dialog, then reset all the 
00390     // transparency settings back to their default values.
00391     //
00392     // Graeme (12/7/00) - I've changed this so that it doesn't clear up the
00393     // transparency values when the dialogue is slicing images. This is because it
00394     // kills off the transparency settings before it's finished with them. In this
00395     // case clean-up takes place in OpSlice::Do ().
00396 //  if( !m_bIsCreateBitmap && !m_bSlicingImage )
00397 //      CancelTransparency();
00398 */
00399 }
00400 
00401 
00402 /********************************************************************************************
00403 >   void BmapPrevDlg::DoWithParam(OpDescriptor*, OpParam* pParam)
00404     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00405     Created:    17/11/94
00406     Purpose:    Like all Do functions invokes the BmapPrevDlg
00407 ********************************************************************************************/
00408 void BmapPrevDlg::DoWithParam(OpDescriptor*, OpParam* pParam)
00409 {
00410     BOOL ok = TRUE;
00411 
00412     ERROR3IF(pParam == NULL, "pParam = NULL");
00413 
00414     // remember the options
00415 
00416     // this should be the only place where the export options are deleted
00417     // so delete them if we have a new and valid and different set of options to replace them
00418     if (m_pExportOptions && m_pExportOptions != (BitmapExportOptions *)(void *)pParam->Param1)
00419     {
00420         delete m_pExportOptions;
00421         m_pExportOptions = NULL;
00422     }
00423 
00424     m_pExportOptions = (BitmapExportOptions *)(void*)pParam->Param1;
00425 
00426     // remember the bitmap filter
00427     m_pBmpFilter = (BaseBitmapFilter *)(void*)pParam->Param2;
00428 
00429     // safety check
00430     ERROR3IF((m_pExportOptions == NULL) || (m_pBmpFilter == NULL), "No filter or export options");
00431     if ((m_pExportOptions == NULL) || (m_pBmpFilter == NULL))
00432     {
00433         End();
00434         return;
00435     }
00436 
00437     // get the filter ID
00438     m_FilterType = m_pExportOptions->GetFilterType();
00439     //  The following is to stop the BitmapExportPreviewDialog from trying to
00440     //  generate popularity values when we are exporting a jpeg ( and hence there is no palette );
00441     if( m_FilterType == JPEG )
00442         m_bPopularityValuesWanted = FALSE;
00443 
00444     // iniitialize the preview dialog
00445     m_pPreviewDlg = NULL;
00446     m_DialogWnd = NULL;
00447     
00448     m_CurrentPreview = 0;
00449     m_bDpiSupported = TRUE; 
00450 
00451     // assume for the meantime that we are not doing a create bitmap copy
00452     m_bIsCreateBitmap = FALSE;
00453     
00454     // oh ye virtuals
00455     switch ( m_FilterType ) 
00456     {
00457         case GIF:
00458         case TI_GIF:
00459         {
00460 PORTNOTETRACE("other", "Removed GIFExportOptions check" );
00461 #if !defined(EXCLUDE_FROM_XARALX)
00462             GIFExportOptions* pGIFOptions = (GIFExportOptions*)m_pExportOptions;
00463             ERROR3IF(!pGIFOptions->IS_KIND_OF(GIFExportOptions), "pGIFOptions isn't");
00464 
00465             m_bDpiSupported = FALSE;
00466 //          m_bTransparent = pGIFOptions->WantTransparent();
00467 
00468             // > 8bpp not leled by the gif filter
00469             if (pGIFOptions->GetDepth() > 8)
00470                 pGIFOptions->SetDepth(8);
00471 #endif
00472             break;
00473         }
00474         case MAKE_BITMAP_FILTER:
00475         {
00476 PORTNOTETRACE("other", "Removed MakeBitmapExportOptions check" );
00477 #if !defined(EXCLUDE_FROM_XARALX)
00478             MakeBitmapExportOptions* pMkBOptions = (MakeBitmapExportOptions*)m_pExportOptions;
00479             ERROR3IF(!pMkBOptions->IS_KIND_OF(MakeBitmapExportOptions), "pMkBOptions isn't");
00480 
00481             m_bDpiSupported = TRUE;
00482 //          m_bTransparent = pMkBOptions->WantTransparent();
00483 
00484             // Find the png filter 
00485             Filter *pFilter = Filter::GetFirst();
00486             while (pFilter != NULL)
00487             {
00488                 if ((pFilter->GetFlags().CanExport) && 
00489                     (IS_A(pFilter,PNGFilter)))
00490                     // This is the filter!
00491                     break;
00492 
00493                 // Try the next filter
00494                 pFilter = Filter::GetNext(pFilter);
00495             }
00496 
00497             // check for no filter found
00498             if (pFilter == NULL)
00499                 ok = FALSE;
00500 
00501             // convert the options to png options
00502             PNGExportOptions *pPNGOptions = new PNGExportOptions(PNG, NULL);
00503             if (pPNGOptions == NULL)
00504                 ok = FALSE;
00505             else if (ok)
00506             {
00507                 // copy the values across
00508                 pPNGOptions->CopyFromMasked(pMkBOptions);
00509 
00510                 // delete the old options (these would be the makebitmap ones)
00511                 if (m_pExportOptions)
00512                     delete m_pExportOptions;
00513 
00514                 // set the new png options as current
00515                 m_pExportOptions = pPNGOptions;
00516 
00517                 // remove the export options from this filter
00518                 // which deletes the export options
00519                 //if (m_pBmpFilter)
00520                 //  m_pBmpFilter->SetExportOptions(NULL);
00521 
00522                 // remember the filter
00523                 m_pBmpFilter = (BaseBitmapFilter*)pFilter;
00524 
00525                 m_pBmpFilter->SetExportOptions(pPNGOptions);
00526 
00527             }
00528             m_bIsCreateBitmap = TRUE;
00529 #endif
00530             break;
00531         }
00532         case PNG: 
00533         {
00534 //          PNGExportOptions* pPNGOptions = (PNGExportOptions*)m_pExportOptions;
00535 //          ERROR3IF(!pPNGOptions->IS_KIND_OF(PNGExportOptions), "pPNGOptions isn't");
00536             // 1, 4, 8, 24 and 32 bpp
00537 //          m_bTransparent = pPNGOptions->WantTransparent();
00538 
00539             m_bDpiSupported = TRUE;
00540             break;
00541         }
00542 
00543         case BMP_UNCOMPRESSED:
00544             m_bDpiSupported = TRUE;
00545             break;
00546 
00547         case JPEG:
00548             m_bDpiSupported = TRUE;
00549             m_pExportOptions->SetDepth(24); // init to 24bpp
00550             break;
00551 
00552         default:
00553             m_bDpiSupported = FALSE;
00554             break;
00555     }
00556 
00557     // Create the TAB dialog please
00558     if (ok)
00559         ok = Create(); 
00560 
00561     if (!ok)
00562     {
00563         m_pExportOptions->MarkInvalid();
00564         //  Need to use this to indicate that the user clicked on Cancel after having
00565         //  changed the file type.
00566         m_bClickedOnExport = FALSE;
00567         End(); 
00568     }
00569 } 
00570 
00571 void BmapPrevDlg::SetButtonsText()
00572 {
00573     CDlgResID PageID = GetCurrentPageID();  // Get currently selected Tab id
00574     TalkToPage(0);                      // Select the main tab
00575 
00576     UINT32 ResID;
00577 
00578     if (NamedExportProp::m_fApplyNotExport)
00579         switch (m_CurrentPreview)
00580         {
00581             case 1:     ResID = _R(IDS_PREVIEW_APPLYA);         break;
00582             case 2:     ResID = _R(IDS_PREVIEW_APPLYB);         break;
00583             default:    ResID = _R(IDS_PREVIEW_APPLY);          break;
00584         }
00585     else if (m_FilterType == MAKE_BITMAP_FILTER)
00586         switch (m_CurrentPreview)
00587         {
00588             case 1:     ResID = _R(IDS_PREVIEW_SAVEA);          break;
00589             case 2:     ResID = _R(IDS_PREVIEW_SAVEB);          break;
00590             default:    ResID = _R(IDS_SAVE_BUTTON);            break;
00591         }
00592     else
00593         switch (m_CurrentPreview)
00594         {
00595             case 1:     ResID = _R(IDS_PREVIEW_EXPORTA);        break;
00596             case 2:     ResID = _R(IDS_PREVIEW_EXPORTB);        break;
00597             default:    ResID = _R(IDS_EXPORT_BUTTON);          break;
00598         }
00599 
00600     SetStringGadgetValue(wxID_OK, ResID);
00601     
00602     // Use the tabbed dialogs 'Apply' button as a 'Preview' button
00603     SetStringGadgetValue(_R(ID_APPLY_NOW), _R(IDS_PREVIEW_BUTTON));
00604 
00605     TalkToPage(PageID);         // Select the originally selected tab
00606 }
00607 
00608 void BmapPrevDlg::SetPreviewButtonState(bool enabled)
00609 {
00610     TRACEUSER( "Gerry", _T("SetPreviewButtonState matches = %d\n"), m_pExportOptions->DoesTempFileMatchExportOptions());
00611     
00612     CDlgResID PageID = GetCurrentPageID();      // Get currently selected Tab id
00613     TalkToPage(0);                          // Select the main tab
00614     EnableGadget(_R(ID_APPLY_NOW), !m_pExportOptions->DoesTempFileMatchExportOptions() /*enabled == 1*/);
00615     TalkToPage(PageID);                         // Select the originally selected tab
00616 }
00617 
00618 
00619 /********************************************************************************************
00620 >   BOOL CALLBACK EnumChildProc(wxWindow* hChild, LPARAM lParam )
00621     Author:     Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
00622     Created:    9/07/97
00623     Inputs:     hChild - a child window
00624                 lParam - pointer to some parameters
00625     Purpose:    Windows calls this function in turns, passing a handle each child window.
00626                 Each child window (which is part of the original tabed dialog is moved down
00627                 to leave space for the preview. 
00628     Returns:    TRUE, if successful, FALSE otherwise
00629     See Also:   BmapPrevDlg::OnCreate
00630     NOTE:       This is oily code and should become part of the dialog manager
00631 ********************************************************************************************/
00632 PORTNOTE("other","Removed Windows style function EnumChildProc")
00633 #ifndef EXCLUDE_FROM_XARALX
00634 BOOL CALLBACK EnumChildProc(wxWindow* hChild, LPARAM lParam )
00635 {
00636     // First get our parameters back
00637     ChildWindowParameters* pParam = (ChildWindowParameters*)lParam;
00638     if (pParam == NULL)
00639         return FALSE;
00640 
00641     //Get the ID of our parent window
00642     wxWindow* hParent = (wxWindow*)pParam->FirstID;
00643     if (hParent == NULL)
00644         return FALSE;
00645 
00646     // first find the true parent of the child window
00647     // and then compare the parent with our dialog
00648     if (GetParent(hChild) != hParent)
00649         return TRUE;
00650 
00651     //If this is the Preview dialog child window, return TRUE
00652     if (GetParent(hChild) == (wxWindow*) pParam->SecondID)
00653         return TRUE;
00654 
00655     //move the window
00656 
00657     // get the size of the child window
00658     wxRect Rect;
00659     GetWindowRect(hChild, &Rect);
00660 
00661     wxRect Parent;
00662     GetWindowRect(hParent, &Parent);
00663     
00664     INT32 Offset = pParam->Distance - pParam->TopOffset;
00665     MoveWindow(hChild, Rect.GetLeft() - Parent.GetLeft(), Rect.GetTop() - Parent.GetTop() + Offset,
00666                        Rect.GetRight() - Rect.GetLeft(), Rect.GetBottom() - Rect.GetTop(), TRUE);
00667 
00668     return TRUE;
00669 }
00670 #endif                      
00671 
00672 /********************************************************************************************
00673 >   BOOL BmapPrevDlg::OnCreate()
00674     Author:     Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
00675     Created:    8/7/97
00676     Purpose:    Handles the DIM_CREATE message. Creates the preview dialog and moves the tabs, 
00677                 so the preview dialog goes above them.
00678     Returns:    TRUE, if successful, FALSE otherwise
00679     NOTE:       The window movement code is oily code and should become part of the dialog manager
00680                 along with the above function, EnumChildProc.
00681 ********************************************************************************************/
00682 BOOL BmapPrevDlg::OnCreate()
00683 {
00684     // If we need to add a preview section then go and do it now
00685     if ((m_FilterType == JPEG) || (m_pExportOptions->GetSelectionType() != ABITMAP))
00686     {
00687 PORTNOTETRACE("other","Preview section NOT setup");
00688 #ifndef EXCLUDE_FROM_XARALX
00689         //First get the size of the current window
00690         wxRect Rect;
00691         GetWindowRect(WindowID, &Rect);
00692 #endif
00693 
00694         //Now, the current window contains only the Tabs
00695         //section of the dialog. We need to insert the Preview
00696         //section of the dialog above the Tabs section. This
00697         //means doing the following:
00698 
00699         //1. Increasing the height of the dialog by the
00700         //   height of the Preview section
00701         //2. Moving the Tabs section downwards, by a distance
00702         //   equal to the height of the Preview section
00703         //3. Inserting the Preview section at the top of the
00704         //   dialog
00705 
00706         //Also, if this is the first time the dialog
00707         //has been created, we must recentre the dialog on 
00708         //screen to compensate for the fact that the Preview
00709         //section has been added. We do this at the same
00710         //time as step 1.
00711 
00712         //So...
00713 
00714         //First, we need to get the height of the 
00715         //Preview section
00716 
00717         //To do this, we create the Preview dialog object
00718         m_pPreviewDlg = new BitmapExportPreviewDialog(WindowID);
00719         ERROR2IF(m_pPreviewDlg == NULL, FALSE, "No preview dialog!");
00720 
00721         //And start the dialog up
00722         m_pPreviewDlg->InitPreviewDialog(this, m_pBmpFilter);
00723 
00724         // Get the window ID
00725         m_DialogWnd = m_pPreviewDlg->WindowID;
00726         ERROR2IF(m_DialogWnd == NULL, FALSE, "No preview dialog!");
00727     
00728         DialogManager::MergeDialogs( WindowID, m_pPreviewDlg->WindowID, true );
00729 
00730         // enable our window (which has been disabled when the preview window was created)
00731         WindowID->Enable( TRUE );
00732     }
00733 
00734     // set the title bar
00735     if (m_FilterType != MAKE_BITMAP_FILTER) 
00736     {
00737         // Set up the title of the dialog box according to the passed in string which
00738         // is the name of the filter plus export bitmap options.
00739         String_256 Temp = ""; //*(m_pExportOptions->GetFilterName());
00740         Temp.Load(m_pExportOptions->GetFilterNameStrID()); // which is safer than the ptr into whatever
00741         Temp += String_256(_R(IDN_EXPORTBMPOPTS));
00742 
00743         DialogManager::SetTitlebarName(WindowID, &Temp); // set the title bar for the window
00744     }
00745     else
00746     {
00747         // set up the title string for the MakeBitmap filter
00748         String_256 Temp(_R(IDS_MAKEBMPOPTS));
00749         DialogManager::SetTitlebarName(WindowID, &Temp); // set the title bar
00750     }
00751 
00752     // set the OK and preview button
00753     SetButtonsText();
00754 
00755     // calculate a dpi value if dpi is not supported
00756     if (!m_bDpiSupported)                           // Doesn't support dpi...
00757     {
00758         // and ensure that its always the number of dpi as defined by a pixel unit
00759         DocUnitList* pDocUnitList = DocUnitList::GetCurrentDocUnitList();
00760         ERROR3IF(pDocUnitList == 0, "BmapPrevDlg::OnCreate - no pDocUnitList!");
00761         Unit* pPixelUnit = pDocUnitList->FindUnit(PIXELS);
00762         ERROR3IF(pPixelUnit == 0, "BmapPrevDlg::OnCreate - no pixel units!");
00763         Unit* pInchUnit = pDocUnitList->FindUnit(INCHES);
00764         ERROR3IF(pInchUnit == 0, "BmapPrevDlg::OnCreate - no inch units!");
00765         double newDpi = (pPixelUnit->GetMillipoints() > 0)
00766                             ? pInchUnit->GetMillipoints() / pPixelUnit->GetMillipoints()
00767                             : 96.0;
00768         m_pExportOptions->SetDPI(newDpi);
00769     }
00770 
00771     AddControlsToHelper();
00772 
00773     UpdateCurrentTab();
00774 
00775     m_PaletteControl.Init(GetReadWriteWindowID());
00776 
00777     return TRUE;
00778 }
00779 
00780 /******************************************************************************************
00781 >   void BmapPrevDlg::DoBubbleHelp()
00782     Author:     Alex_Price (Xara Group Ltd) <camelotdev@xara.com>
00783     Created:    14/07/99
00784     Purpose:    This function displays bubble help (if available) for the control
00785                 that the mouse is over
00786 ******************************************************************************************/
00787 void BmapPrevDlg::DoBubbleHelp()
00788 {
00789 PORTNOTE("other","Removed registry usage")
00790 #if !defined(EXCLUDE_FROM_XARALX)
00791     //  If a bubble help window exists from a previous call to this function then delete it
00792     delete m_pBubbleWnd;
00793 #endif
00794     m_pBubbleWnd = 0;
00795     
00796     //  Are we over a control?  This is the case if this variable is non-zero.
00797     if ( !m_LastCursorOverControlID )
00798         return;
00799 
00800     //  This holds the ID of the string we want to display in the bubble-help window.
00801     UINT32 bubbleID;
00802 
00803     //  Get the bubble-help string from the gadget ID.
00804     if( m_LastCursorOverControlID == _R(IDC_T2_LOCKED_COLOUR) )         //  'Locked Colour' button.
00805     {
00806         bubbleID = _R(IDS_LOCKED_COLOUR);
00807     }
00808     else
00809     if( m_LastCursorOverControlID == _R(IDC_T2_WEB_SAFE_COLOUR) )       //  'Web Safe Colour' button.
00810     {
00811         bubbleID = _R(IDS_WEB_SAFE_COLOUR);
00812     }
00813     else
00814     if( m_LastCursorOverControlID == _R(IDC_T2_TRANSPARENT_COLOUR) )    //  'Transparent Colour' button.
00815     {
00816         bubbleID = _R(IDS_TRANSPARENT_COLOUR);
00817     }
00818     else
00819     if( m_LastCursorOverControlID == _R(IDC_T2_TRANSPARENT_BACKGROUND) )
00820     {
00821         bubbleID = _R(IDS_TRANSPARENT_BACKGROUND);
00822     }
00823     else
00824     if( m_LastCursorOverControlID == _R(IDC_T2_DELETE_COLOUR) )         //  'Delete Colour' button.
00825     {
00826         bubbleID = _R(IDS_DELETE_COLOUR);
00827     }
00828     else
00829     if( m_LastCursorOverControlID == _R(IDC_T2_RESTORE_COLOUR) )        //  'Restore Colour' button.
00830     {
00831         bubbleID = _R(IDS_RESTORE_COLOUR);
00832     }
00833     else
00834     if( m_LastCursorOverControlID == _R(IDC_T2_SYSTEM_COLOURS) )        //  'Add System Colors' button.
00835     {
00836         bubbleID = _R(IDS_SYSTEM_COLOURS);
00837     }
00838     else                                                                // Any other control.
00839     {
00840         m_LastCursorOverControlID = 0;
00841         bubbleID = 0;
00842     }
00843 
00844     //  If no bubble-help required, then return.
00845     if (bubbleID == 0)
00846         return;
00847     
00848     //  Load the bubble-help string into a variable.
00849     String_256 bubbleText(bubbleID);
00850 
00851 PORTNOTE("other","Removed registry usage")
00852 #if !defined(EXCLUDE_FROM_XARALX)
00853     //  Make a new bubble help window
00854     m_pBubbleWnd = new BubbleHelpWnd;
00855     if (!m_pBubbleWnd)
00856     {
00857         TRACEALL( _T("Unable to create bubble help window in bitmap export dialog\n"));
00858         return;
00859     }
00860 
00861     // Create the actual window
00862     if (!m_pBubbleWnd->Create())
00863     {
00864         TRACEALL( _T("Could not Init bubble help window in bitmap export dialog\n"));
00865         return;
00866     }
00867 
00868     //  Set the text for the window
00869     if (!m_pBubbleWnd->SetText(bubbleText))
00870         return;  // no bubble help for this item
00871 
00872     //  Show the window
00873     m_pBubbleWnd->Show();
00874 #endif
00875 }
00876 
00877 void BmapPrevDlg::PrepareBubbleHelp()
00878 {
00879     if (m_pBubbleTimer)
00880         m_pBubbleTimer->Sample();           // reuse the timer created on the last mouse move message
00881     else
00882         m_pBubbleTimer = new MonotonicTime; // it is OK for new to fail as this will just return a null
00883                                             // pointer and therefore there will be no bubble help
00884 PORTNOTE("other","Removed registry usage")
00885 #if !defined(EXCLUDE_FROM_XARALX)
00886     // Create a new 
00887     delete m_pBubbleWnd;
00888     m_pBubbleWnd = 0;
00889 #endif
00890 }
00891 
00892 void BmapPrevDlg::UpdateStatusBar(UINT32 id)
00893 {
00894     // now do the status line messages      
00895     UINT32 statusTextID;
00896 
00897     // Find the status message ID from the Gadget ID
00898     if( id == _R(IDC_T2_LOCKED_COLOUR) )            // 'Locked Colour' button
00899     {
00900         statusTextID = _R(IDS_LOCKED_COLOUR_STATUS_TEXT);
00901     }
00902     else
00903     if( id == _R(IDC_T2_WEB_SAFE_COLOUR) )          // 'Web Safe Colour' button
00904     {
00905         statusTextID = _R(IDS_WEB_SAFE_COLOUR_STATUS_TEXT);
00906     }
00907     else
00908     if( id == _R(IDC_T2_TRANSPARENT_COLOUR) )       // 'Transparent Colour' button
00909     {
00910         statusTextID = _R(IDS_TRANSPARENT_COLOUR_STATUS_TEXT);
00911     }
00912     else
00913     if( id == _R(IDC_T2_TRANSPARENT_BACKGROUND) )
00914     {
00915         statusTextID = _R(IDS_TRANSPARENT_BACKGROUND_STATUS_TEXT);
00916     }
00917     else
00918     if( id == _R(IDC_T2_DELETE_COLOUR) )            // 'Delete Colour' button
00919     {
00920         statusTextID = _R(IDS_DELETE_COLOUR_STATUS_TEXT);
00921     }
00922     else
00923     if( id == _R(IDC_T2_RESTORE_COLOUR) )           // 'Restore Colour' button
00924     {
00925         statusTextID = _R(IDS_RESTORE_COLOUR_STATUS_TEXT);
00926     }
00927     else
00928     if( id == _R(IDC_T2_SYSTEM_COLOURS) )           // 'Add System Colours' button
00929     {
00930         statusTextID = _R(IDS_SYSTEM_COLOURS_STATUS_TEXT);
00931     }
00932     else                                            // Nothing - Just show 'Preview...'
00933     {
00934         statusTextID = _R(IDS_BITMAPPREVIEWDIALOG);
00935     }
00936 
00937     //  Put up some status line help
00938     StatusLine* pStatusLine = GetApplication()->GetpStatusLine();
00939     if ( pStatusLine != NULL )
00940     {
00941         String_256  strStatus(statusTextID);
00942         pStatusLine->UpdateText( &strStatus, FALSE );
00943     }
00944 }
00945 
00946 
00947 /********************************************************************************************
00948 >   void BmapPrevDlg::SetPaletteSelection(INT32 index)
00949     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
00950     Created:    11/12/2000
00951     Purpose:    Set the selected colour in the palette control
00952 ********************************************************************************************/
00953 void BmapPrevDlg::SetPaletteSelection(INT32 index)
00954 {
00955     if (GetCurrentPageID() != _R(IDD_PALETTE_TAB))
00956         return;
00957     
00958     ReDrawInfoType info;
00959     GetKernelRenderedGadgetInfo(_R(IDC_T2_PALETTE_CONTROL), &info);
00960     m_PaletteControl.SetSelectedCell(&info, index);
00961     RefreshPaletteLinkedControls();
00962 }
00963 
00964 /********************************************************************************************
00965 >   void BmapPrevDlg::SetPaletteHighlight(INT32 index)
00966     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
00967     Created:    11/12/2000
00968     Purpose:    Set the highlighted colour in the palette control
00969 ********************************************************************************************/
00970 void BmapPrevDlg::SetPaletteHighlight(INT32 index)
00971 {
00972     if (GetCurrentPageID() != _R(IDD_PALETTE_TAB))
00973         return;
00974 
00975     ReDrawInfoType info;
00976     GetKernelRenderedGadgetInfo(_R(IDC_T2_PALETTE_CONTROL), &info);
00977     m_PaletteControl.SetHighlightedCell(&info, index);
00978     RefreshPaletteLinkedControls();
00979 }
00980 
00981 /********************************************************************************************
00982 >   void BmapPrevDlg::UpdateCurrentTab()
00983     Author:     Simon_Knight (Xara Group Ltd) <camelotdev@xara.com>
00984     Created:    6/12/00
00985     Purpose:    Updates the details in the tab to match the export options
00986 ********************************************************************************************/
00987 void BmapPrevDlg::UpdateCurrentTab()
00988 {
00989     CDlgResID PageID = GetCurrentPageID();  // Get currently selected Tab id
00990     if(PageID == _R(IDD_TBITMAPSIZE) )
00991     {
00992         //TRACEUSER( "Simonk", _T("Update tab SIZE\n"));
00993         // Refresh the size tab
00994         RefreshBitmapSizeTab();
00995     }
00996     else
00997     if(PageID == _R(IDD_PALETTE_TAB) )
00998     {
00999         //TRACEUSER( "Simonk", _T("Update tab PALETTE\n"));
01000         RefreshPaletteOptionsTab();
01001     }
01002     else
01003     if(PageID == _R(IDD_TIMAPOPTIONS) )
01004     {
01005         //TRACEUSER( "Simonk", _T("Update tab IMAGE MAP\n"));
01006         // Refresh the image map tab
01007         RefreshImageMapTab();
01008     }
01009     else
01010     if(PageID == _R(IDD_TBROWSER) )
01011     {
01012         //TRACEUSER( "Simonk", _T("Update tab BROWSER\n"));
01013         // Refresh browser tab
01014     }
01015     else
01016     if(PageID == _R(IDD_TBITMAPOPTIONS) )
01017     {
01018         //TRACEUSER( "Simonk", _T("Update tab OPTIONS\n"));
01019         // for this tab the init works just like the refresh
01020         InitBitmapOptionsTab();
01021     }
01022     else
01023     {
01024         //TRACEUSER( "Simonk", _T("Update tab NULL\n"));
01025     }
01026 }
01027 
01028 
01029 /********************************************************************************************
01030 >   BOOL BmapPrevDlg::DoPreview()
01031     Author:     Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
01032     Created:    8/7/97
01033     Purpose:    Handles the Apply button. Gets the export options from the gadgets and passes 
01034                 them to the preview dialog.
01035     Returns:    TRUE, if successful, FALSE otherwise
01036 ********************************************************************************************/
01037 BOOL BmapPrevDlg::DoPreview()
01038 {
01039 
01040     //  TRACEUSER( "Gerry", _T("DoPreview 0x%08x\n"), m_pExportOptions);
01041 
01042     CDlgResID PageID = GetCurrentPageID();  // Get currently selected Tab id
01043     if (m_pPreviewDlg == NULL)
01044         return FALSE;
01045 
01046     // Disable 'Export' button to stop nasty crashes
01047     TalkToPage(0);
01048     bool                fIsExportEnabled = IsGadgetEnabled( wxID_OK );
01049     EnableGadget( wxID_OK, false );
01050     
01051     BOOL ok = (m_pExportOptions != NULL);
01052 
01053     if (ok && !m_pExportOptions->DoesTempFileMatchExportOptions())
01054     {
01055         // Set the flag early as otherwise the set active bitmap call in the OnExport system
01056         // generates a second preivew
01057         m_pExportOptions->SetTempFileMatchesExportOptions(TRUE);
01058 
01059         ok = m_pPreviewDlg->OnExport( m_pExportOptions );
01060     }
01061 
01062     if (!ok) m_pExportOptions->SetTempFileMatchesExportOptions(FALSE);
01063 
01064     if (ok)
01065     {
01066         // if first time set the first bitmap as active
01067         if (m_CurrentPreview == 0)
01068             m_CurrentPreview = 1;
01069 
01070         // now do the automatic browser preview
01071 //      if ((m_pPreviewDlg != NULL) && m_bDoPreviewInBrowser)
01072 //          m_pPreviewDlg->DoBrowserPreview(t_BrowserOptions);
01073     }
01074 
01075     // Disable the preview button as the dialog settings currently match the preview
01076     SetPreviewButtonState(false);
01077 
01078     // Update the palette as it may have been changed when the preview was generated
01079     m_PaletteControl.RenderSoon();
01080 
01081     // Re-enable 'Export' button
01082     TalkToPage(0);
01083     EnableGadget( wxID_OK, fIsExportEnabled );
01084     
01085     TalkToPage(PageID);
01086 
01087     return ok;
01088 }
01089 
01090 
01091 /********************************************************************************************
01092 >   MsgResult BmapPrevDlg::Message( Msg* Message)
01093     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01094     Created:    18/2/94
01095     Inputs:     Message: The message 
01096     Returns:    OK            Message handled ok (return this even if you don't need to 
01097                               respond to the message). 
01098 
01099                 FAIL          Something terrible happened whilst processing the message
01100                               eg. we ran out of memory. You must set ERROR if you
01101                               are returning this value. 
01102 
01103                 EAT_MSG       The Message was handled ok but don't send it to any
01104                               more MessageHandlers. 
01105 
01106     Purpose:    This is the message handler for the BmapPrevDlg
01107 ********************************************************************************************/
01108 
01109 MsgResult BmapPrevDlg::Message( Msg* Message)
01110 {
01111     // handle the message
01112     if (!IS_OUR_DIALOG_MSG(Message))
01113         return OK;
01114 
01115     if (m_DialogWnd != NULL)
01116         m_DialogWnd->Enable( TRUE );
01117     
01118     DialogMsg* Msg = ((DialogMsg*) Message); 
01119 
01120     BOOL EndDialog = FALSE;     // TRUE if we should quit the dialog
01121 //  BOOL CommitValues = FALSE;  // TRUE if we should commit the dialog values
01122 
01123     // Catch mouse move messages for all tabs here so we can do all the bubble help / status
01124     // bar stuff for all the tabs (note: DIM_MOUSE_MOVE still goes to the tabs, this is just
01125     // a hook to process it a little first)
01126     if (Msg->DlgMsg == DIM_MOUSE_MOVE && m_LastCursorOverControlID != Msg->GadgetID)
01127     {
01128         m_LastCursorOverControlID = Msg->GadgetID;
01129 
01130         UpdateStatusBar(Msg->GadgetID);
01131         PrepareBubbleHelp();
01132     }
01133 
01134     if (Msg->DlgMsg == DIM_TIMER)
01135     {
01136         if (m_pBubbleTimer && m_pBubbleTimer->Elapsed(BUBBLE_TIME))
01137         {
01138             // Delete the timer as it is no longer needed
01139             delete m_pBubbleTimer;
01140             m_pBubbleTimer = 0;
01141 
01142             // Show the bubble help window
01143             DoBubbleHelp();
01144         }
01145     }
01146 
01147     // Determine from what page the message originated
01148     if( Msg->PageID == _R(IDD_TBITMAPSIZE) )
01149         HandleBitmapSizeTabMsg(Msg); 
01150     else
01151     if( Msg->PageID == _R(IDD_PALETTE_TAB) )
01152         HandlePaletteTabMsg(Msg);
01153     else
01154     if( Msg->PageID == _R(IDD_TIMAPOPTIONS) )
01155         HandleImageMapTabMsg(Msg); 
01156     else
01157     if( Msg->PageID == _R(IDD_TBROWSER) )
01158         HandleBrowserPreviewTabMsg(Msg); 
01159     else
01160     if( Msg->PageID == _R(IDD_TBITMAPOPTIONS) )
01161         HandleBitmapOptionsTabMsg(Msg);
01162     else
01163     if( Msg->PageID == 0 )
01164     {
01165         // A message generated from the tabbed dialog itself
01166         switch (Msg->DlgMsg)
01167         {
01168             case DIM_CREATE:
01169             {
01170                 if (!OnCreate()) // initialise
01171                 {
01172                     ERROR3("Problem in OnCreate()");
01173                     return FAIL;
01174                 }
01175                 // disable browser preview for now
01176 //              BOOL Old = m_bDoPreviewInBrowser; // remember the value of the flag
01177 //              m_bDoPreviewInBrowser = FALSE; // disable browser preview
01178 //              DoPreview(); // do preview
01179 //              m_bDoPreviewInBrowser = Old; // restore the setting
01180 
01181 PORTNOTE("other", "Remove bubble help timer usage" );
01182 #if !defined(EXCLUDE_FROM_XARALX)
01183             //  Set up the bubble-help timer.
01184                 SetTimer(BUBBLE_HELP_TIMMER_ID, 100);
01185 #endif
01186                 break;
01187             }
01188 
01189             case DIM_COMMIT:        // Close dialog and insert the bitmap in the document
01190                 EndDialog = TRUE;
01191 PORTNOTE("other", "Remove bubble help timer usage" );
01192 #if !defined(EXCLUDE_FROM_XARALX)
01193                 KillTimer(BUBBLE_HELP_TIMMER_ID);
01194 #endif
01195                 BmapPrevDlg::m_bClickedOnExport = TRUE;
01196                 ImageMapOnCommit();     // Save the image map values
01197                 break;
01198 
01199             case DIM_SOFT_COMMIT:       // Update the preview
01200                 EndDialog = FALSE;
01201                 DoPreview();
01202                 BmapPrevDlg::m_bClickedOnExport = FALSE;
01203                 break; 
01204 
01205             case DIM_CANCEL:        // Close dialog and don't insert the bitmap in the document
01206                 EndDialog = TRUE;
01207 PORTNOTE("other", "Remove bubble help timer usage" );
01208 #if !defined(EXCLUDE_FROM_XARALX)
01209                 KillTimer(BUBBLE_HELP_TIMMER_ID);
01210 #endif
01211                 BmapPrevDlg::m_bClickedOnExport = FALSE;
01212                 // we have cancelled so these options are not valid
01213                 m_pExportOptions->MarkInvalid();
01214                 break;
01215 
01216             case DIM_LFT_BN_CLICKED:
01217             case DIM_RGT_BN_CLICKED:
01218                 // If they clicked on the help button
01219                 if (Msg->GadgetID == wxID_HELP)
01220                     OnHelpButtonClicked();
01221                 break;
01222 
01223             default:
01224                 break;
01225         }
01226     }
01227     else
01228         ERROR3("Message from unknown tab dialog page"); 
01229 
01230     if (EndDialog)  // Dialog communication over 
01231     {   
01232         // set the proper state in the export options to indicate which button was clicked
01233         if (Msg->DlgMsg == DIM_COMMIT)
01234         {
01235             //  Now, the ModifiedAfterLastExport variable used to tell us whether the options had
01236             //  been changed since the user last pressed the Preview button. This does not
01237             //  apply now since the preview is always up to date, so we will ignore it.
01238             if (m_FilterType == MAKE_BITMAP_FILTER)
01239             {
01240                 // we need to get rid of any temp files
01241                 if (m_pExportOptions->HasTempFile())
01242                 {
01243                     // get the path name
01244                     PathName Path = m_pExportOptions->GetPathName();
01245 
01246                     // if a valid path, delete it
01247                     if (Path.IsValid())
01248                         FileUtil::DeleteFile(&Path);
01249 
01250                     m_pExportOptions->SetPathName(NULL);
01251                 }
01252             }
01253 
01254             // set the extention as we may have changed file type
01255             // some extentions are in the form jpg,jpeg
01256             // just use the first example
01257             String_256 Ext = m_pExportOptions->FindBitmapFilterForTheseExportOptions()->pOILFilter->FilterExt;
01258             for (INT32 i = 0; i < 256 && Ext[i]; i++)
01259             {
01260                 if (Ext[i] == ',')
01261                 {
01262                     Ext.Remove(i, Ext.Length()-i);
01263                     break;
01264                 }
01265             }
01266             BmapPrevDlg::m_pthExport.SetType ( Ext );
01267 
01268             m_pExportOptions->SetPutHTMLTagOnClipboard(m_ClipBoardUsage == CLIPBOARD_HTML);
01269 
01270             // we have committed these values so mark them as valid
01271             m_pExportOptions->MarkValid();
01272         } // End DIM_COMMIT.
01273         else 
01274         {
01275             // check if jpeg export dialog has been canceled 
01276             if (m_FilterType == JPEG)
01277             {
01278                 // set our KernelBitmap pointer to NULL.
01279                 JPEGExportOptions::SetKernelBitmap(NULL);
01280             }
01281         }
01282 
01283         // tell the preview dialog to shut down         
01284         if (m_DialogWnd != NULL)
01285             BROADCAST_TO_CLASS( DialogMsg(m_DialogWnd, Msg->DlgMsg, 0, 0, 0), DialogOp );
01286         m_DialogWnd = NULL;
01287 
01288         Close();
01289         End();      // End of dialog 
01290     }
01291 
01292     return DLG_EAT_IF_HUNGRY(Msg);   // I return EAT_MSG unless the message needs to be sent to all dialogs 
01293 }
01294 
01295 /********************************************************************************************
01296 >   void BmapPrevDlg::OnHelpButtonClicked()
01297     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
01298     Created:    25/7/97
01299     Purpose:    Called when the help button is clicked.
01300                 Brings up a help page that depends on the filter type being used.
01301 ********************************************************************************************/
01302 void BmapPrevDlg::OnHelpButtonClicked()
01303 {
01304     //Fetch a help page relevant to the filter we're using to export
01305     switch (m_FilterType) 
01306     {
01307         case GIF:
01308         case TI_GIF:
01309             HelpUserTopic(_R(IDS_HELPPATH_Dialog_Bitmap_Export_GIF));
01310             break;
01311         
01312         case PNG:
01313             HelpUserTopic(_R(IDS_HELPPATH_Dialog_Bitmap_Export_PNG));
01314             break;
01315 
01316         case MAKE_BITMAP_FILTER:
01317             HelpUserTopic(_R(IDS_HELPPATH_Command_Create_Bitmap_Copy));
01318             break;
01319         
01320         case BMP_UNCOMPRESSED:
01321             HelpUserTopic(_R(IDS_HELPPATH_Dialog_Bitmap_Export_BMP));
01322             break;
01323 
01324         case JPEG:
01325             HelpUserTopic(_R(IDS_HELPPATH_Dialog_Bitmap_Export_JPEG));
01326             break;
01327     }
01328 }
01329 
01330 // //////////////////////////////////////////////////////////////////////////////////////// //
01331 // //////////////////////////////////////////////////////////////////////////////////////// //
01332 // Palette Options Tab                                                                      //
01333 // //////////////////////////////////////////////////////////////////////////////////////// //
01334 // //////////////////////////////////////////////////////////////////////////////////////// //
01335 
01336 /********************************************************************************************
01337 >   void BmapPrevDlg::InitPaletteTab()
01338     Author:     Craig_Hamilton (Xara Group Ltd) <camelotdev@xara.com>
01339     Created:    6/11/00
01340     Purpose:    Calls methods to intialise the palette tab controls
01341 ********************************************************************************************/
01342 void BmapPrevDlg::InitPaletteTab()
01343 {
01344     // Initialise the dithering list.
01345     InitPaletteDitheringList();
01346 
01347     // Initialise the palette list.
01348     InitPalettePaletteList();
01349 
01350     // Initialise the colour depth list.
01351     InitPaletteColourDepthList();
01352 
01353     // Initialise the colour model list.
01354     InitPaletteColourModelList();
01355 
01356     // Initialise the button strip
01357     InitPaletteButtonStrip();
01358 
01359     // Initialise the palette sort list
01360     InitPaletteSortList();
01361 }
01362 
01363 /********************************************************************************************
01364 >   void BmapPrevDlg::InitPaletteDitheringList()
01365     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
01366     Created:    08/12/2000
01367     Purpose:    Sets up the palette dithering list on creation of the dialog
01368 ********************************************************************************************/
01369 void BmapPrevDlg::InitPaletteDitheringList()
01370 {
01371     // All of this is done in the RefreshPaletteDitherList function as
01372     // the dithering depends on the colour depth etc.
01373 }
01374 
01375 /********************************************************************************************
01376 >   void BmapPrevDlg::InitPalettePaletteList()
01377     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
01378     Created:    08/12/2000
01379     Purpose:    Sets up the palette palette list (browser/optimised/web snap) on creation of
01380                 the dialog
01381 ********************************************************************************************/
01382 void BmapPrevDlg::InitPalettePaletteList()
01383 {
01384     // Make sure the list is empty
01385     DeleteAllValues( _R(IDC_PALETTE_COMBO) );
01386 
01387     //  Add the necessary strings to the list. 
01388     //  This is the complete collection of them.
01389     SetStringGadgetValue( _R(IDC_PALETTE_COMBO), _R(IDS_PALETTE_BROWSER),   FALSE, 0 );
01390     SetStringGadgetValue( _R(IDC_PALETTE_COMBO), _R(IDS_PALETTE_OPTIMISED), FALSE, 1 );
01391     SetStringGadgetValue( _R(IDC_PALETTE_COMBO), _R(IDS_PALETTE_WEB_SNAP),  FALSE, 2 );
01392 
01393     SetComboListLength(_R(IDC_PALETTE_COMBO));
01394 }
01395 
01396 /********************************************************************************************
01397 >   void BmapPrevDlg::InitPaletteColourDepthList()
01398     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
01399     Created:    08/12/2000
01400     Purpose:    Sets up the palette colour depth list on creation of the dialog
01401 ********************************************************************************************/
01402 void BmapPrevDlg::InitPaletteColourDepthList()
01403 {
01404     // This case is handled in the refresh case
01405 }
01406 
01407 /********************************************************************************************
01408 >   void BmapPrevDlg::InitPaletteColourModelList()
01409     Author:     Craig_Hamilton (Xara Group Ltd) <camelotdev@xara.com>
01410     Created:    8/11/00
01411     Purpose:    This initialies the colour model list. We use the member variable
01412                 m_ColorModelType instead of having this data kept in the export options since
01413                 it only has a bearing on how the colour information is represented to the user,
01414                 not how the graphic is exported.
01415 ********************************************************************************************/
01416 void BmapPrevDlg::InitPaletteColourModelList()
01417 {
01418     //  Make sure that the list is empty.
01419     DeleteAllValues(_R(IDC_COLOR_MODEL_LIST));
01420 
01421     //  Add the necessary strings to the list. 
01422     //  This is the complete collection of them.
01423     SetStringGadgetValue( _R(IDC_COLOR_MODEL_LIST), _R(IDS_COLOR_DISPLAY_RGB_HEX),      FALSE, 0 );
01424     SetStringGadgetValue( _R(IDC_COLOR_MODEL_LIST), _R(IDS_COLOR_DISPLAY_RGB_NUMBER),   FALSE, 1 );
01425     SetStringGadgetValue( _R(IDC_COLOR_MODEL_LIST), _R(IDS_COLOR_DISPLAY_RGB_PERCENT),  FALSE, 2 );
01426     SetStringGadgetValue( _R(IDC_COLOR_MODEL_LIST), _R(IDS_COLOR_DISPLAY_HSV),          FALSE, 3 );
01427 
01428     SetComboListLength( _R(IDC_COLOR_MODEL_LIST) );
01429 }
01430 
01431 /********************************************************************************************
01432 >   void BmapPrevDlg::InitPaletteButtonStrip()
01433     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
01434     Created:    08/12/2000
01435     Purpose:    Sets the bitmaps for the buttons on the palette tab on creation of the dialog
01436 ********************************************************************************************/
01437 void BmapPrevDlg::InitPaletteButtonStrip()
01438 {
01439     SetGadgetBitmaps(_R(IDC_T2_LOCKED_COLOUR),          0, 0 );
01440     SetGadgetBitmaps(_R(IDC_T2_WEB_SAFE_COLOUR),        0, 0 );
01441     SetGadgetBitmaps(_R(IDC_T2_TRANSPARENT_COLOUR),     0, 0 );
01442     SetGadgetBitmaps(_R(IDC_T2_TRANSPARENT_BACKGROUND), 0, 0 );
01443     SetGadgetBitmaps(_R(IDC_T2_DELETE_COLOUR),          0, 0 );
01444     SetGadgetBitmaps(_R(IDC_T2_RESTORE_COLOUR),         0, 0 );
01445     SetGadgetBitmaps(_R(IDC_T2_SYSTEM_COLOURS),         0, 0 );
01446 }
01447 
01448 /******************************************************************************************
01449 >   void BmapPrevDlg::InitSortList()
01450     Author:     Alex_Price (Xara Group Ltd) <camelotdev@xara.com>
01451     Created:    21/06/99
01452     Purpose:    Constructs and initialises the sort drop-list in the palette tab on
01453                 creation of the bitmap export dialog.
01454 ******************************************************************************************/
01455 void BmapPrevDlg::InitPaletteSortList()
01456 {
01457     //  Make sure that the list is empty.
01458     DeleteAllValues( _R(IDC_T2_SORT_LIST) );
01459 
01460     //  Add the necessary strings to the list. 
01461     //  This is the complete collection of them.
01462     SetStringGadgetValue( _R(IDC_T2_SORT_LIST), _R(IDS_SORT_BY_USES),       FALSE, 0 );
01463     SetStringGadgetValue( _R(IDC_T2_SORT_LIST), _R(IDS_SORT_BY_LUMINANCE),  FALSE, 1 );
01464     SetStringGadgetValue( _R(IDC_T2_SORT_LIST), _R(IDS_SORT_BY_HUE),        FALSE, 2 );
01465 
01466     SetComboListLength( _R(IDC_T2_SORT_LIST) );
01467 }
01468 
01469 /********************************************************************************************
01470 >   void BmapPrevDlg::HandlePaletteOptionsTabMsg(DialogMsg* Msg)
01471     Author:     Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
01472     Created:    9/7/97
01473     Inputs:     Msg: The message sent from page 1 of the dialog
01474     Purpose:    All messages generated from the tabbed dialog's palette tab get processed here
01475 ********************************************************************************************/
01476 void BmapPrevDlg::HandlePaletteTabMsg(DialogMsg* Msg)
01477 {
01478     CDlgResID PageID = GetCurrentPageID();  // Get currently selected Tab id
01479     TalkToPage(_R(IDD_PALETTE_TAB));  // The Coords Page identifier
01480     switch (Msg->DlgMsg)
01481     {
01482         case DIM_CREATE:
01483         {
01484             InitPaletteTab();
01485             break;
01486         }
01487         case DIM_SELECTION_CHANGED:
01488         {
01489             if( Msg->GadgetID == _R(IDC_DITHERING_COMBO) )
01490                 HandlePaletteDitheringListChange();
01491             else
01492             if( Msg->GadgetID == _R(IDC_PALETTE_COMBO) )
01493                 HandlePalettePaletteListChange();
01494             else
01495             if( Msg->GadgetID == _R(IDC_COLOUR_DEPTH_COMBO) )
01496                 HandlePaletteColourDepthListChange();
01497             else
01498             if( Msg->GadgetID == _R(IDC_T2_SORT_LIST) )
01499                 HandlePaletteSortListChange();
01500             else
01501             if( Msg->GadgetID == _R(IDC_COLOR_MODEL_LIST) )
01502                 HandlePaletteColourModelListChange();
01503 
01504             RefreshPaletteOptionsTab(); // Changes may have had an effect other controls
01505             break;
01506         }
01507 
01508         case DIM_TEXT_CHANGED:
01509             if (PageID != _R(IDD_PALETTE_TAB) || m_LockSizeUpdates)
01510                 break;
01511 
01512         case DIM_KILL_FOCUS:
01513         {
01514             if (Msg->GadgetID == _R(IDC_COLOURS_USED_EDIT))
01515             {
01516                 HandlePaletteColoursUsedChange();
01517                 RefreshPaletteLinkedControls();
01518             }
01519             else
01520             if (Msg->GadgetID == _R(IDC_RED_EDIT) || Msg->GadgetID == _R(IDC_GREEN_EDIT) || Msg->GadgetID == _R(IDC_BLUE_EDIT))
01521             {
01522                 HandlePaletteColourEditChange(Msg->GadgetID);
01523                 ReDrawInfoType info;
01524                 GetKernelRenderedGadgetInfo(_R(IDC_T2_PALETTE_CONTROL), &info);
01525                 m_PaletteControl.RedrawSelectedCell(&info);
01526             }
01527             TalkToPage(PageID);
01528             break;
01529         }
01530 
01531         case DIM_REDRAW:
01532         {
01533             if (Msg->GadgetID == _R(IDC_T2_PALETTE_CONTROL))
01534                 m_PaletteControl.Render(reinterpret_cast<ReDrawInfoType *>(Msg->DlgMsgParam));
01535             TalkToPage(PageID);
01536             break;
01537         }
01538 
01539         case DIM_MOUSE_MOVE:
01540         {
01541             // Need to tell the palette about mouse movement both inside and outsite of the palette control
01542             // (so it knows when to remove the highlight thing)
01543 
01544             INT32 startColour   = m_PaletteControl.GetMouseOverColour();
01545             INT32 endColour = BitmapExportPaletteControl::INVALID_COLOUR_VALUE;
01546 
01547             if (Msg->GadgetID == _R(IDC_T2_PALETTE_CONTROL))
01548             {
01549                 m_MouseInsidePaletteControl = true;
01550                 m_PaletteControl.MsgMouseMove(reinterpret_cast<ReDrawInfoType *>(Msg->DlgMsgParam));
01551                 endColour = m_PaletteControl.GetMouseOverColour();
01552             }
01553             else if (m_MouseInsidePaletteControl == true)
01554             {
01555                 // This is the first mouse move message since the mouse has left the palette
01556                 m_MouseInsidePaletteControl = false;
01557                 ReDrawInfoType info;
01558                 GetKernelRenderedGadgetInfo(_R(IDC_T2_PALETTE_CONTROL), &info);
01559                 m_PaletteControl.SetHighlightedCell(&info, BitmapExportPaletteControl::INVALID_COLOUR_VALUE);
01560             }
01561 
01562             if (startColour != endColour)
01563                 RefreshPaletteColoursEdit();
01564 
01565             TalkToPage(PageID);
01566             break;
01567         }
01568 
01569         case DIM_LFT_BN_DOWN:
01570         {
01571             if (Msg->GadgetID == _R(IDC_T2_PALETTE_CONTROL))
01572             {
01573                 if (m_PaletteControl.MsgMouseLeftButtonDown(reinterpret_cast<ReDrawInfoType *>(Msg->DlgMsgParam)))
01574                 {
01575                     // The message resulted in a change to the selection
01576                     RefreshPaletteLinkedControls();
01577                 }
01578             }
01579             break;
01580         }
01581 
01582         case DIM_LFT_BN_CLICKED:
01583         {
01584             if( Msg->GadgetID == _R(IDC_T2_LOCKED_COLOUR) )
01585                 HandlePaletteLockedColourButtonChange();
01586             else
01587             if( Msg->GadgetID == _R(IDC_T2_WEB_SAFE_COLOUR) )
01588                 HandlePaletteWebSafeColourButtonChange();
01589             else
01590             if( Msg->GadgetID == _R(IDC_T2_TRANSPARENT_BACKGROUND) )
01591                 HandlePaletteTransparentBackgroundButtonChange();
01592             else
01593             if( Msg->GadgetID == _R(IDC_T2_TRANSPARENT_COLOUR) )
01594                 HandlePaletteTransparentColourButtonChange();
01595             else
01596             if( Msg->GadgetID == _R(IDC_T2_DELETE_COLOUR) )
01597                 HandlePaletteDeleteColourButtonChnage();
01598             else
01599             if( Msg->GadgetID == _R(IDC_T2_RESTORE_COLOUR) )
01600                 HandlePaletteRestoreColourButtonChange();
01601             else
01602             if( Msg->GadgetID == _R(IDC_T2_SYSTEM_COLOURS) )
01603                 HandlePaletteSystemColoursButtonChnage();
01604 
01605             RefreshPaletteOptionsTab(); // Changes may have had an effect other controls
01606             break;
01607         }
01608 
01609         case DIM_RGT_BN_UP:
01610         {
01611         /*  
01612             I have disabled the palette right click menu as some of the manipulations it does on the palette are
01613             a bit iffy, for example toggling lockedness only does half the things it needes to (see the handler
01614             for the locking button).  -- Jonathan 22/12/2000
01615 
01616 
01617             if (Msg->GadgetID == _R(IDC_T2_PALETTE_CONTROL))
01618             {
01619                 m_PaletteControl.MsgMouseRightButtonUp(reinterpret_cast<ReDrawInfoType *>(Msg->DlgMsgParam), this);
01620                 RefreshPaletteLinkedControls();
01621             }
01622         */
01623             break;
01624         }
01625 
01626         case DIM_SET_ACTIVE:
01627             UpdateCurrentTab();
01628             break;
01629 
01630         default:
01631             TalkToPage(PageID);
01632             break;
01633     };
01634 }
01635 
01636 /******************************************************************************************
01637 >   void BmapPrevDlg::HandleDitherListChange()
01638     Author:     Alex_Price (Xara Group Ltd) <camelotdev@xara.com>
01639     Created:    16/06/99
01640     Purpose:    When the selection in the Dither drop list changes, this function is 
01641                 called. It does all the necessary work in response to this change.
01642 ******************************************************************************************/
01643 void BmapPrevDlg::HandlePaletteDitheringListChange()
01644 {
01645     //  Get the user's selection
01646     String_16 DitherSelected = GetStringGadgetValue(_R(IDC_DITHERING_COMBO) );
01647 
01648     if( DitherSelected.IsIdentical(String_16(_R(IDS_DITHER_NONE))))
01649     {
01650         m_pExportOptions->SetDither(XARADITHER_NONE);
01651     }
01652     else if( DitherSelected.IsIdentical( String_16( _R(IDS_DITHER_ORDERED))))
01653     {
01654         m_pExportOptions->SetDither(XARADITHER_ORDERED);
01655     }
01656     else if( DitherSelected.IsIdentical( String_16( _R(IDS_DITHER_ERROR_DIFFUSED))))
01657     {
01658         m_pExportOptions->SetDither(XARADITHER_ERROR_DIFFUSION);
01659     }
01660     else
01661     {
01662         ERROR3("Impossible dither type selected");
01663     }
01664 
01665     // Invalidate the palette and therefor force a redraw of the the preview
01666     m_pExportOptions->InvalidatePalette();
01667 }
01668 
01669 /********************************************************************************************
01670 >   void BmapPrevDlg::HandlePalettePaletteListChange()
01671     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
01672     Created:    08/12/2000
01673     Purpose:    Responds to changes in the list of palette types.
01674 ********************************************************************************************/
01675 void BmapPrevDlg::HandlePalettePaletteListChange()
01676 {
01677     //  Get the user's selection
01678     String_16 PaletteSelected = GetStringGadgetValue(_R(IDC_PALETTE_COMBO));
01679 
01680     if(PaletteSelected.IsIdentical(String_16(_R(IDS_PALETTE_BROWSER))))
01681     {
01682         m_pExportOptions->SetToUseBrowserPalette(TRUE);
01683         m_pExportOptions->SetWebSnapPaletteAmount(0);
01684     }
01685     else
01686     {
01687         if(PaletteSelected.IsIdentical( String_16(_R(IDS_PALETTE_OPTIMISED))))
01688         {
01689             m_pExportOptions->SetToUseBrowserPalette(FALSE);
01690             m_pExportOptions->SetWebSnapPaletteAmount(0);
01691         }
01692         else if(PaletteSelected.IsIdentical( String_16(_R(IDS_PALETTE_WEB_SNAP))))
01693         {
01694             m_pExportOptions->SetToUseBrowserPalette(FALSE);
01695             m_pExportOptions->SetWebSnapPaletteAmount(12);
01696         }
01697 
01698         // Quick fix so ordered dithering is not used with palette types other
01699         // than browser
01700         if (m_pExportOptions->GetDither() == XARADITHER_ORDERED)
01701         {
01702             m_pExportOptions->SetDither(XARADITHER_ERROR_DIFFUSION);
01703         }
01704     }
01705 }
01706 
01707 /********************************************************************************************
01708 >   void BmapPrevDlg::HandleColorDepthListChange()
01709     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
01710     Created:    08/11/2000
01711     Purpose:    When the selection in the Color depth drop list changes, this function is 
01712                 called. It does all the necessary work in response to this change.
01713 ********************************************************************************************/
01714 void BmapPrevDlg::HandlePaletteColourDepthListChange()
01715 {
01716     String_32 ColorDepthSelected = GetStringGadgetValue(_R(IDC_COLOUR_DEPTH_COMBO));
01717 
01718     INT32 newDepth;
01719 
01720     if      (ColorDepthSelected.IsIdentical(String_32(_R(IDS_COLOR_DEPTH_32))))
01721         newDepth = 32;
01722     else if (ColorDepthSelected.IsIdentical(String_32(_R(IDS_COLOR_DEPTH_24))))
01723         newDepth = 24;
01724     else if (ColorDepthSelected.IsIdentical(String_32(_R(IDS_COLOR_DEPTH_8))))
01725         newDepth = 8;
01726     else if (ColorDepthSelected.IsIdentical(String_32(_R(IDS_COLOR_DEPTH_4))))
01727     {
01728         newDepth = 4;
01729 
01730         // Quick fix so ordered dithering is not used in 16 colour mode
01731         // as it does not work
01732         if (m_pExportOptions->GetDither() == XARADITHER_ORDERED)
01733         {
01734             m_pExportOptions->SetDither(XARADITHER_ERROR_DIFFUSION);
01735         }
01736 
01737     }
01738     else if (ColorDepthSelected.IsIdentical(String_16(_R(IDS_COLOR_DEPTH_1))))
01739         newDepth = 1;
01740     else
01741     {
01742         ERROR3("Colour depth was not understood");
01743         return; // Give up
01744     }
01745 
01746     m_pExportOptions->SetDepth(newDepth);
01747 }
01748 
01749 void BmapPrevDlg::HandlePaletteLockedColourButtonChange()
01750 {
01751     if (m_PaletteControl.GetSelectedColour() != BitmapExportPaletteControl::INVALID_COLOUR_VALUE)
01752     {
01753         m_PaletteControl.SetSelectedColourToggleLocked();
01754 //      m_pExportOptions->InvalidatePalette(); // unlocking a colour means this colour could become anything
01755 //                                              // locking is safe but we dont check for that
01756 
01757         // set the preedited colour to match the edited colour
01758         SetPreEditedPaletteColour();
01759     }
01760     SetPreviewButtonState(true); // set the preview button
01761 }
01762 
01763 void BmapPrevDlg::HandlePaletteWebSafeColourButtonChange()
01764 {
01765     if (m_PaletteControl.GetSelectedColour() != BitmapExportPaletteControl::INVALID_COLOUR_VALUE)
01766     {
01767         m_PaletteControl.SetSelectedColourWebSafe();
01768         m_pExportOptions->SetTempFileMatchesExportOptions(FALSE); // we have edited the palette
01769     }
01770     SetPreviewButtonState(true); // set the preview button
01771 }
01772 
01773 /********************************************************************************************
01774 >   void BmapPrevDlg::HandleTransparentBackgroundButtonChange()
01775     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
01776     Created:    09/11/2000
01777     Purpose:    Handles a change in the transparency button
01778 ********************************************************************************************/
01779 void BmapPrevDlg::HandlePaletteTransparentBackgroundButtonChange()
01780 {
01781     BOOL TransValue = GetLongGadgetValue(_R(IDC_T2_TRANSPARENT_BACKGROUND), 0, 1 );
01782     m_pExportOptions->SetBackgroundTransparency(TransValue);
01783     SetPreviewButtonState(true); // set the preview button
01784 }
01785 
01786 /********************************************************************************************
01787 >   void BmapPrevDlg::HandlePaletteTransparentColourButtonChange()
01788     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
01789     Created:    08/12/2000
01790     Purpose:    Makes the current selected colour in the palette control transparent.
01791 ********************************************************************************************/
01792 void BmapPrevDlg::HandlePaletteTransparentColourButtonChange()
01793 {
01794     if (m_PaletteControl.GetSelectedColour() != BitmapExportPaletteControl::INVALID_COLOUR_VALUE)
01795     {
01796         // toggle the control for the colour
01797         if (m_PaletteControl.SetSelectedColourToggleTransparent())
01798         {
01799             // the colour toggled was the background colour so turn background transp off if required
01800             if (m_pExportOptions->IsBackgroundTransparent())
01801                 m_pExportOptions->SetBackgroundTransparency(FALSE);
01802         }
01803         m_pExportOptions->SetTempFileMatchesExportOptions(FALSE); // we have edited the palette
01804         SetPreviewButtonState(true); // set the preview button
01805     }
01806 }
01807 
01808 /********************************************************************************************
01809 >   void BmapPrevDlg::HandlePaletteDeleteColourButtonChnage()
01810     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
01811     Created:    08/12/2000
01812     Purpose:    Deletes the currently selected colour in the palette control.
01813 ********************************************************************************************/
01814 void BmapPrevDlg::HandlePaletteDeleteColourButtonChnage()
01815 {
01816     if (m_PaletteControl.GetSelectedColour() != BitmapExportPaletteControl::INVALID_COLOUR_VALUE)
01817         m_PaletteControl.SetSelectedColourToggleDeleted();
01818 
01819     m_pExportOptions->SetTempFileMatchesExportOptions(FALSE);
01820 //  m_pExportOptions->InvalidatePalette();
01821     SetPreviewButtonState(true); // set the preview button
01822 }
01823 
01824 /********************************************************************************************
01825 >   void BmapPrevDlg::HandlePaletteRestoreColourButtonChange()
01826     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
01827     Created:    08/12/2000
01828     Purpose:    Undelete the selected colour in the palette control (this function is the
01829                 same as the delete function as the deleted state is a toggle).  This
01830                 function relies on its button only being enabled when the colour can be
01831                 restored.
01832 ********************************************************************************************/
01833 void BmapPrevDlg::HandlePaletteRestoreColourButtonChange()
01834 {
01835     if (m_PaletteControl.GetSelectedColour() != BitmapExportPaletteControl::INVALID_COLOUR_VALUE)
01836         m_PaletteControl.SetSelectedColourToggleDeleted();
01837 
01838     m_pExportOptions->InvalidatePalette();
01839     SetPreviewButtonState(true); // set the preview button
01840 }
01841 
01842 /********************************************************************************************
01843 >   void BmapPrevDlg::HandlePaletteSystemColoursButtonChnage()
01844     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
01845     Created:    08/12/2000
01846     Purpose:    Responds to the user pressing the system colours button.
01847 ********************************************************************************************/
01848 void BmapPrevDlg::HandlePaletteSystemColoursButtonChnage()
01849 {
01850     m_pExportOptions->SetToUseSystemPalette(GetLongGadgetValue(_R(IDC_T2_SYSTEM_COLOURS), 0, 1));
01851     m_pExportOptions->InvalidatePalette();
01852     SetPreviewButtonState(true); // set the preview button
01853 }
01854 
01855 /********************************************************************************************
01856 >   void BmapPrevDlg::HandlePaletteSortListChange()
01857     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
01858     Created:    08/12/2000
01859     Purpose:    This function responds to the user changing the current sort method and tells
01860                 the palette control about the change.
01861 ********************************************************************************************/
01862 void BmapPrevDlg::HandlePaletteSortListChange()
01863 {
01864     //  Get the user's selection
01865     String_16 sort = GetStringGadgetValue(_R(IDC_T2_SORT_LIST));
01866 
01867     if(sort.IsIdentical(String_16(_R(IDS_SORT_BY_USES))))
01868     {
01869         m_PaletteControl.SetCurrentSortType(BitmapExportPaletteInterface::SORT_USE);
01870     }
01871     else if(sort.IsIdentical( String_16(_R(IDS_SORT_BY_LUMINANCE))))
01872     {
01873         m_PaletteControl.SetCurrentSortType(BitmapExportPaletteInterface::SORT_LUMINANCE);
01874     }
01875     else if(sort.IsIdentical( String_16(_R(IDS_SORT_BY_HUE))))
01876     {
01877         m_PaletteControl.SetCurrentSortType(BitmapExportPaletteInterface::SORT_HUE);
01878     }
01879     else
01880     {
01881         ERROR3("Unknown item selected");
01882     }
01883 
01884 //  m_PaletteControl.RenderSoon();
01885 }
01886 
01887 /********************************************************************************************
01888 >   void BmapPrevDlg::HandlePaletteColourModelListChange()
01889     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
01890     Created:    08/12/2000
01891     Purpose:    Updates m_ColorModelType to take account of a newly selected colour model.
01892 ********************************************************************************************/
01893 void BmapPrevDlg::HandlePaletteColourModelListChange()
01894 {
01895     String_16 sort = GetStringGadgetValue(_R(IDC_COLOR_MODEL_LIST));
01896 
01897     if(sort.IsIdentical(String_16(_R(IDS_COLOR_DISPLAY_RGB_HEX))))
01898         m_ColorModelType = MODEL_RGBHEX;
01899     else if(sort.IsIdentical( String_16(_R(IDS_COLOR_DISPLAY_RGB_NUMBER))))
01900         m_ColorModelType = MODEL_RGBNUMBER;
01901     else if(sort.IsIdentical( String_16(_R(IDS_COLOR_DISPLAY_RGB_PERCENT))))
01902         m_ColorModelType = MODEL_RGBPERCENT;
01903     else if(sort.IsIdentical( String_16(_R(IDS_COLOR_DISPLAY_HSV))))
01904         m_ColorModelType = MODEL_HSV;
01905     else
01906         ERROR3("Unknown item selected");
01907 }
01908 
01909 void BmapPrevDlg::HandlePaletteColoursUsedChange()
01910 {
01911     BOOL valid = FALSE;
01912     INT32 colours = GetLongGadgetValue(_R(IDC_COLOURS_USED_EDIT), 2, 256, 0, &valid);
01913     if (valid)
01914         m_pExportOptions->SetNumberOfUserRequestedColours(colours);
01915 
01916     SetPreviewButtonState(true); // set the preview button
01917 }
01918 
01919 void BmapPrevDlg::HandlePaletteColourEditChange(CGadgetID id)
01920 {
01921     BOOL valid;
01922 
01923     String_256 str = GetStringGadgetValue(id, &valid);
01924 
01925     if (!valid)
01926         return; // don't change the value so when the control is refreshed it is set
01927                 // back to the old value
01928 
01929     ExtendedPalette *palette = BmapPrevDlg::m_pExportOptions->GetExtendedPalette();
01930     ERROR3IF(!palette, "There is no palette - This should never happen");
01931 
01932     BYTE *pR, *pG, *pB;
01933     pR = &(palette->Data[m_PaletteControl.GetSelectedColour()].Red);
01934     pG = &(palette->Data[m_PaletteControl.GetSelectedColour()].Green);
01935     pB = &(palette->Data[m_PaletteControl.GetSelectedColour()].Blue);
01936 
01937     BYTE startR = *pR;
01938     BYTE startG = *pG;
01939     BYTE startB = *pB;
01940 
01941     BYTE *pColourWeAreChanging = NULL;  // not used in HSV mode
01942 
01943     if( id == _R(IDC_RED_EDIT) )
01944         pColourWeAreChanging = pR;
01945     else
01946     if( id == _R(IDC_GREEN_EDIT) )
01947         pColourWeAreChanging = pG;
01948     else
01949     if( id == _R(IDC_BLUE_EDIT) )
01950         pColourWeAreChanging = pB;
01951     
01952     switch (m_ColorModelType)
01953     {
01954         case MODEL_RGBHEX:
01955         {
01956             INT32 t;
01957             camSscanf(str, _T("%x"), &t);
01958             if (t >= 0 && t < 256)
01959                 *pColourWeAreChanging = t;
01960             break;
01961         }
01962 
01963         case MODEL_RGBPERCENT:
01964         {
01965             double t;
01966             camSscanf(str, _T("%lf"), &t);
01967             double tt = t * (255.0 / 100.0); // convert from percent to 0-255
01968             if (tt >= 0 && tt < 256)
01969                 *pColourWeAreChanging = UINT8(tt + 0.5); // adding 0.5 so number rounds to nearest INT32
01970             break;
01971         }
01972         case MODEL_RGBNUMBER:
01973         {
01974             INT32 t;
01975             camSscanf(str, _T("%u"), &t);
01976             if (t >= 0 && t < 256)
01977                 *pColourWeAreChanging = UINT8(t);
01978             break;
01979         }
01980 
01981         case MODEL_HSV:
01982         {
01983             INT32 newValue;                         // New value of colour component
01984 
01985             if (id == _R(IDC_RED_EDIT))                 // H component
01986             {
01987                 INT32 t;                                // temp INT32 varaible
01988                 camSscanf(str, _T("%u"), &t);               // read as an in
01989                 newValue = t;                       // value to be set (check range before setting)
01990             }
01991             else                                    // S & V components
01992             {
01993                 double t;                           // temp float variable (using float to keep sscanf happy)
01994                 camSscanf(str, _T("%lf"), &t);              // read value as a float
01995                 t *= (float)(255.0 / 100.0);        // convert from percent to 0-255
01996                 newValue = UINT8(t + 0.5);                  // value to be set (check range before setting)
01997             }
01998 
01999 
02000             if (newValue >= 0 && ((id == _R(IDC_RED_EDIT) && newValue < 360) || (id != _R(IDC_RED_EDIT) && newValue < 256)))
02001             {
02002                 INT32 h, s, v;
02003                 DocColour colour(*pR, *pG, *pB);
02004                 colour.GetHSVValue(&h, &s, &v);
02005                 if( id == _R(IDC_RED_EDIT) )
02006                     colour.SetHSVValue(newValue, s, v);
02007                 else
02008                 if( id == _R(IDC_GREEN_EDIT) )
02009                     colour.SetHSVValue(h, newValue, v);
02010                 else
02011                 if( id == _R(IDC_BLUE_EDIT) )
02012                     colour.SetHSVValue(h, s, newValue);
02013                 
02014                 INT32 newR, newG, newB;
02015                 colour.GetRGBValue(&newR, &newG, &newB);
02016                 *pR = newR; *pG = newG; *pB = newB;
02017             }
02018             break;
02019         }
02020 
02021         default:
02022         {
02023             ERROR3("You've broken it");
02024             break;
02025         }
02026     } // end of switch (m_ColorModelType)
02027 
02028     // Lock the colour it the user has managed to change it
02029     if ((startR != *pR || startG != *pG || startB != *pB))
02030     {
02031         // set the colour that it was before in the pre edit fields
02032         SetPreEditedPaletteColour(startR, startG, startB);
02033         // lock the colour
02034         if (!m_PaletteControl.GetSelectedColourLocked())
02035             m_PaletteControl.SetSelectedColourToggleLocked();
02036 
02037         // we have edited the palette so the options now longer match the image
02038         m_pExportOptions->SetTempFileMatchesExportOptions(FALSE);
02039         SetPreviewButtonState(true); // set the preview button
02040     }
02041 }
02042 
02043 /********************************************************************************************
02044 >   void BmapPrevDlg::RefreshPaletteOptionsTab()
02045     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
02046     Created:    08/12/2000
02047     Purpose:    This function refreshes the status of all the windows in the palette tab to
02048                 take account of any possible changes.
02049 ********************************************************************************************/
02050 void BmapPrevDlg::RefreshPaletteOptionsTab()
02051 {
02052 //  if (m_pExportOptions->GetSupportsPalette())
02053 //  {
02054         if (!m_pExportOptions->IsPaletteValid())
02055             DoPreview();
02056         else
02057             m_PaletteControl.RenderSoon();
02058 //  }
02059 
02060 
02061     RefreshPaletteDitheringList();
02062     RefreshPalettePaletteList();
02063     RefreshPaletteColourDepthList();
02064     RefreshPaletteSortList();
02065     RefreshPaletteLinkedControls();
02066 
02067     SetPreviewButtonState(true);
02068 }
02069 
02070 /********************************************************************************************
02071 >   void BmapPrevDlg::RefreshPaletteLinkedControls()
02072     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
02073     Created:    08/12/2000
02074     Purpose:    This function refreshes controls on the palette dialog that are in some way
02075                 related to operations on the palette.  This function is used when the user
02076                 changes the selected colour or does anything else that might invalidate these
02077                 controls.
02078 ********************************************************************************************/
02079 void BmapPrevDlg::RefreshPaletteLinkedControls()
02080 {
02081     RefreshPaletteColourModelList();
02082     RefreshPaletteButtonStrip();
02083     RefreshPaletteColoursUsedEdit();
02084     RefreshPaletteColoursEdit();
02085 }
02086 
02087 /********************************************************************************************
02088 >   void BmapPrevDlg::RefreshPaletteDitheringList()
02089     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
02090     Created:    08/12/2000
02091     Purpose:    This function updates the dithering list control on the palette tab.  It has
02092                 to add all the strings to the control again as some changes (for example
02093                 changing the palette type) require different lists of dithering types to be
02094                 shown.
02095 ********************************************************************************************/
02096 void BmapPrevDlg::RefreshPaletteDitheringList()
02097 {
02098     // Make sure the list is empty
02099     DeleteAllValues(_R(IDC_DITHERING_COMBO));
02100 
02101     // Set the first string
02102     SetStringGadgetValue( _R(IDC_DITHERING_COMBO), _R(IDS_DITHER_NONE), FALSE);
02103 
02104     // Find out what types of dithering are currently supported
02105     DWORD dithers = m_pExportOptions->GetSupportedDithers();
02106 
02107     // If there are no dither types supported, stop now
02108     if (!dithers)
02109     {
02110         SetSelectedDropListItem(_R(IDC_DITHERING_COMBO), _R(IDS_DITHER_NONE));
02111     }
02112     else
02113     {
02114         //  Add the necessary strings to the list
02115         if (dithers & BitmapExportOptions::ORDERED_DITHER)
02116             SetStringGadgetValue( _R(IDC_DITHERING_COMBO), _R(IDS_DITHER_ORDERED), FALSE);
02117 
02118         if (dithers & BitmapExportOptions::ERROR_DITHER)
02119             SetStringGadgetValue( _R(IDC_DITHERING_COMBO), _R(IDS_DITHER_ERROR_DIFFUSED), FALSE);
02120 
02121         switch (m_pExportOptions->GetDither())
02122         {
02123             case XARADITHER_ORDERED:
02124             case XARADITHER_ORDERED_GREY:
02125                 SetSelectedDropListItem(_R(IDC_DITHERING_COMBO), _R(IDS_DITHER_ORDERED));
02126                 break;
02127 
02128             case XARADITHER_ERROR_DIFFUSION:
02129                 SetSelectedDropListItem(_R(IDC_DITHERING_COMBO), _R(IDS_DITHER_ERROR_DIFFUSED));
02130                 break;
02131 
02132             case XARADITHER_NONE:
02133                 SetSelectedDropListItem(_R(IDC_DITHERING_COMBO), _R(IDS_DITHER_NONE));
02134                 break;
02135 
02136             default:
02137             case XARADITHER_SIMPLE:
02138                 ERROR3("Unknown dithering type used");
02139                 break;
02140         }
02141     }
02142 
02143     // Enable the control if there are any dithering options
02144     EnableGadget(_R(IDC_DITHERING_COMBO), dithers != 0);
02145 
02146     // Make the drop list the correct length
02147     SetComboListLength( _R(IDC_DITHERING_COMBO) );
02148 }
02149 
02150 void BmapPrevDlg::RefreshPalettePaletteList()
02151 {
02152     if (!m_pExportOptions->GetSupportsPalette())
02153     {
02154         EnableGadget(_R(IDC_PALETTE_COMBO), FALSE);
02155         return;
02156     }
02157     else
02158     {
02159         EnableGadget(_R(IDC_PALETTE_COMBO), TRUE);
02160     }
02161 
02162     // Set the selected item.
02163     if(m_pExportOptions->IsUsingBrowserPalette() == TRUE)
02164         SetSelectedDropListItem(_R(IDC_PALETTE_COMBO), _R(IDS_PALETTE_BROWSER));
02165     else if (m_pExportOptions->GetWebSnapPaletteAmount() > 0)
02166         SetSelectedDropListItem(_R(IDC_PALETTE_COMBO), _R(IDS_PALETTE_WEB_SNAP));
02167     else
02168         SetSelectedDropListItem(_R(IDC_PALETTE_COMBO), _R(IDS_PALETTE_OPTIMISED));
02169 }
02170 
02171 void BmapPrevDlg::RefreshPaletteColourDepthList()
02172 {
02173     // Make sure the list is empty
02174     DeleteAllValues( _R(IDC_COLOUR_DEPTH_COMBO) );
02175 
02176     INT32 nColourDepths = 0;
02177 
02178     DWORD colourDepths = m_pExportOptions->GetSupportedColourDepths();
02179 
02180     if (colourDepths & BitmapExportOptions::COLOUR_32BIT)
02181         SetStringGadgetValue(_R(IDC_COLOUR_DEPTH_COMBO), _R(IDS_COLOR_DEPTH_32), FALSE, nColourDepths++);
02182     if (colourDepths & BitmapExportOptions::COLOUR_24BIT)
02183         SetStringGadgetValue(_R(IDC_COLOUR_DEPTH_COMBO), _R(IDS_COLOR_DEPTH_24), FALSE, nColourDepths++);
02184 //  if (colourDepths & BitmapExportOptions::COLOUR_16BIT)
02185 //      SetStringGadgetValue(_R(IDC_COLOUR_DEPTH_COMBO), _R(IDS_COLOR_DEPTH_16), FALSE, nColourDepths++);
02186     if (colourDepths & BitmapExportOptions::COLOUR_256)
02187         SetStringGadgetValue(_R(IDC_COLOUR_DEPTH_COMBO), _R(IDS_COLOR_DEPTH_8), FALSE, nColourDepths++);
02188     if (colourDepths & BitmapExportOptions::COLOUR_16)
02189         SetStringGadgetValue(_R(IDC_COLOUR_DEPTH_COMBO), _R(IDS_COLOR_DEPTH_4), FALSE, nColourDepths++);
02190     if (colourDepths & BitmapExportOptions::COLOUR_2)
02191         SetStringGadgetValue(_R(IDC_COLOUR_DEPTH_COMBO), _R(IDS_COLOR_DEPTH_1), FALSE, nColourDepths++);
02192 
02193     SetComboListLength(_R(IDC_COLOUR_DEPTH_COMBO));
02194 
02195     switch( m_pExportOptions->GetDepth() )
02196     {
02197         case 1:     SetSelectedDropListItem( _R(IDC_COLOUR_DEPTH_COMBO), _R(IDS_COLOR_DEPTH_1) );   break;
02198         case 4:     SetSelectedDropListItem( _R(IDC_COLOUR_DEPTH_COMBO), _R(IDS_COLOR_DEPTH_4) );   break;
02199         case 8:     SetSelectedDropListItem( _R(IDC_COLOUR_DEPTH_COMBO), _R(IDS_COLOR_DEPTH_8) );   break;
02200         case 24:    SetSelectedDropListItem( _R(IDC_COLOUR_DEPTH_COMBO), _R(IDS_COLOR_DEPTH_24) );  break;
02201         case 32:    SetSelectedDropListItem( _R(IDC_COLOUR_DEPTH_COMBO), _R(IDS_COLOR_DEPTH_32) );  break;
02202         default:    SetSelectedDropListItem( _R(IDC_COLOUR_DEPTH_COMBO), _R(IDS_COLOR_DEPTH_8) );   break;
02203     }
02204 
02205     if (nColourDepths > 1)
02206         EnableGadget(_R(IDC_COLOUR_DEPTH_COMBO), TRUE);
02207 }
02208 
02209 void BmapPrevDlg::RefreshPaletteColoursUsedEdit()
02210 {
02211     BOOL active = m_pExportOptions->GetSupportsPalette();
02212 
02213     EnableGadget(_R(IDC_COLOURS_USED_EDIT), active);
02214 
02215     // the m_LockSizeUpdates is moonlighting as a lock for palette text controls too
02216     m_LockSizeUpdates = TRUE;
02217 
02218     if (active)
02219     {
02220         ExtendedPalette *palette = BmapPrevDlg::m_pExportOptions->GetExtendedPalette();
02221         ERROR3IF(!palette, "There is no palette - This should never happen");
02222 
02223         if (m_pExportOptions->DoesTempFileMatchExportOptions())
02224             // if we are uptodate go with the number of colours in the palette
02225             SetLongGadgetValue(_R(IDC_COLOURS_USED_EDIT), palette->NumberOfColours);
02226 PORTNOTE( "other", "Some very un-kernel stuff is being done, needs movinf to oil" )
02227 #ifndef EXCLUDE_FROM_XARALX
02228         else
02229             // only set the value here if it doesn't has focus
02230             if (::GetFocus() != GetDlgItem(GetReadWriteWindowID(), (INT32)_R(IDC_COLOURS_USED_EDIT)))
02231                 SetLongGadgetValue(_R(IDC_COLOURS_USED_EDIT), m_pExportOptions->GetNumberOfUserRequestedColours());
02232 #endif
02233     }
02234     else
02235         SetStringGadgetValue(_R(IDC_COLOURS_USED_EDIT), String_16(_T("")));
02236 
02237     m_LockSizeUpdates = FALSE;
02238 }
02239 
02240 /********************************************************************************************
02241 >   void BmapPrevDlg::RefreshPaletteColourModelList()
02242     Author:     Craig_Hamilton (Xara Group Ltd) <camelotdev@xara.com>
02243     Created:    08/11/2000
02244     Purpose:    This sets the colour model list. We use the member variable m_ColorModelType
02245                 instead of having this data kept in the export options since it only has a
02246                 bearing on how the colour information is represented to the user, not how the
02247                 graphic is exported.
02248 ********************************************************************************************/
02249 void BmapPrevDlg::RefreshPaletteColourModelList()
02250 {
02251     switch(m_ColorModelType)
02252     {
02253         case MODEL_RGBHEX:      SetSelectedDropListItem(_R(IDC_COLOR_MODEL_LIST), _R(IDS_COLOR_DISPLAY_RGB_HEX) );      break;
02254         case MODEL_RGBNUMBER:   SetSelectedDropListItem(_R(IDC_COLOR_MODEL_LIST), _R(IDS_COLOR_DISPLAY_RGB_NUMBER));    break;
02255         case MODEL_RGBPERCENT:  SetSelectedDropListItem(_R(IDC_COLOR_MODEL_LIST), _R(IDS_COLOR_DISPLAY_RGB_PERCENT));   break;
02256         case MODEL_HSV:         SetSelectedDropListItem(_R(IDC_COLOR_MODEL_LIST), _R(IDS_COLOR_DISPLAY_HSV));           break;
02257         default: // Do nothing
02258             break;
02259     }
02260 
02261     EnableGadget(_R(IDC_COLOR_MODEL_LIST), m_pExportOptions->GetSupportsPalette());
02262 }
02263 
02264 /********************************************************************************************
02265 >   void BmapPrevDlg::RefreshPaletteColoursEdit()
02266     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
02267     Created:    08/12/2000
02268     Purpose:    Set the values of the three colour edit boxes based on the currently selected
02269                 palette entry and on the currently selected colour model.
02270 ********************************************************************************************/
02271 void BmapPrevDlg::RefreshPaletteColoursEdit()
02272 {
02273     BOOL bPalette       = m_pExportOptions->GetSupportsPalette();
02274     BOOL bSelection     = m_PaletteControl.GetSelectedColour()  != BitmapExportPaletteControl::INVALID_COLOUR_VALUE;
02275     BOOL bHighlight     = m_PaletteControl.GetMouseOverColour() != BitmapExportPaletteControl::INVALID_COLOUR_VALUE;
02276 
02277     // the m_LockSizeUpdates is moonlighting as a lock for palette text controls too
02278     m_LockSizeUpdates = TRUE;
02279 
02280     EnableGadget(_R(IDC_RED_EDIT),      bPalette && bSelection && !m_bIsCreateBitmap && !m_bSlicingImage);
02281     EnableGadget(_R(IDC_GREEN_EDIT),    bPalette && bSelection && !m_bIsCreateBitmap && !m_bSlicingImage);
02282     EnableGadget(_R(IDC_BLUE_EDIT),     bPalette && bSelection && !m_bIsCreateBitmap && !m_bSlicingImage);
02283 
02284     if (bPalette && (bSelection || bHighlight))
02285     {
02286         ExtendedPalette *palette = BmapPrevDlg::m_pExportOptions->GetExtendedPalette();
02287         ERROR3IF(!palette, "There is no palette - This should never happen");
02288 
02289         BYTE r, g, b;
02290         if (bHighlight)
02291         {
02292             r = palette->Data[m_PaletteControl.GetMouseOverColour()].Red;
02293             g = palette->Data[m_PaletteControl.GetMouseOverColour()].Green;
02294             b = palette->Data[m_PaletteControl.GetMouseOverColour()].Blue;
02295         }
02296         else
02297         {
02298             r = palette->Data[m_PaletteControl.GetSelectedColour()].Red;
02299             g = palette->Data[m_PaletteControl.GetSelectedColour()].Green;
02300             b = palette->Data[m_PaletteControl.GetSelectedColour()].Blue;
02301         }
02302 
02303         switch (m_ColorModelType)
02304         {
02305             case MODEL_RGBHEX:
02306             {
02307                 TCHAR str[16];  // Temp string buffer (of abitary size)
02308                 camSprintf(str, _T("%02x"), r); SetStringGadgetValue(_R(IDC_RED_EDIT),      String_16(str));
02309                 camSprintf(str, _T("%02x"), g); SetStringGadgetValue(_R(IDC_GREEN_EDIT),    String_16(str));
02310                 camSprintf(str, _T("%02x"), b); SetStringGadgetValue(_R(IDC_BLUE_EDIT),     String_16(str));
02311                 break;
02312             }
02313             case MODEL_RGBPERCENT:
02314             {
02315                 double p = 100.0 / 255.0;
02316                 SetDoubleGadgetValue(_R(IDC_RED_EDIT),      r * p);
02317                 SetDoubleGadgetValue(_R(IDC_GREEN_EDIT),    g * p);
02318                 SetDoubleGadgetValue(_R(IDC_BLUE_EDIT),     b * p);
02319                 break;
02320             }
02321             case MODEL_RGBNUMBER:
02322             {
02323                 SetLongGadgetValue(_R(IDC_RED_EDIT),        r);
02324                 SetLongGadgetValue(_R(IDC_GREEN_EDIT),      g);
02325                 SetLongGadgetValue(_R(IDC_BLUE_EDIT),       b);
02326                 break;
02327             }
02328             case MODEL_HSV:
02329             {
02330                 INT32 h, s, v;
02331                 DocColour colour(r, g, b);
02332                 colour.GetHSVValue(&h, &s, &v);
02333                 SetLongGadgetValue(_R(IDC_RED_EDIT),        h);             // H
02334                 double p = 100.0 / 255.0;
02335                 SetDoubleGadgetValue(_R(IDC_GREEN_EDIT),    s * p);         // S (as percentage)
02336                 SetDoubleGadgetValue(_R(IDC_BLUE_EDIT),     v * p);         // V (as percentage)
02337                 break;
02338             }
02339             default: // Do nothing
02340                 break;
02341         }
02342     }
02343     else
02344     {
02345         SetStringGadgetValue(_R(IDC_RED_EDIT),      String_16(_T("")));
02346         SetStringGadgetValue(_R(IDC_GREEN_EDIT),    String_16(_T("")));
02347         SetStringGadgetValue(_R(IDC_BLUE_EDIT),     String_16(_T("")));
02348     }
02349 
02350     if(m_ColorModelType == MODEL_HSV)
02351     {
02352         //  Display 'H', 'S', and 'V' beside the colour edit boxes
02353         SetStringGadgetValue(_R(IDC_T2STATIC7), _R(IDS_H_LABEL));
02354         SetStringGadgetValue(_R(IDC_T2STATIC8), _R(IDS_S_LABEL));
02355         SetStringGadgetValue(_R(IDC_T2STATIC9), _R(IDS_V_LABEL));
02356     }
02357     else
02358     {
02359         //  Display 'R', 'G', and 'B' beside the colour edit boxes
02360         SetStringGadgetValue(_R(IDC_T2STATIC7), _R(IDS_R_LABEL));
02361         SetStringGadgetValue(_R(IDC_T2STATIC8), _R(IDS_G_LABEL));
02362         SetStringGadgetValue(_R(IDC_T2STATIC9), _R(IDS_B_LABEL));
02363     }
02364 
02365     m_LockSizeUpdates = FALSE;
02366 }
02367 
02368 void BmapPrevDlg::RefreshPaletteButtonStrip()
02369 {
02370     if (m_PaletteControl.GetSelectedColour() == BitmapExportPaletteControl::INVALID_COLOUR_VALUE
02371         || m_bSlicingImage)
02372     {
02373         EnableGadget(_R(IDC_T2_LOCKED_COLOUR),              FALSE);
02374         EnableGadget(_R(IDC_T2_WEB_SAFE_COLOUR),            FALSE);
02375         EnableGadget(_R(IDC_T2_TRANSPARENT_COLOUR),         FALSE);
02376         EnableGadget(_R(IDC_T2_DELETE_COLOUR),              FALSE);
02377         EnableGadget(_R(IDC_T2_RESTORE_COLOUR),             FALSE);
02378     }
02379     else
02380     {
02381         // Locked colour button
02382         EnableGadget(_R(IDC_T2_LOCKED_COLOUR),              m_pExportOptions->GetSupportsPalette());
02383         SetLongGadgetValue(_R(IDC_T2_LOCKED_COLOUR),        m_PaletteControl.GetSelectedColourLocked());
02384 
02385         // Web safe button
02386         EnableGadget(_R(IDC_T2_WEB_SAFE_COLOUR),            m_pExportOptions->GetSupportsPalette());
02387         SetLongGadgetValue(_R(IDC_T2_WEB_SAFE_COLOUR),      FALSE);
02388 
02389         // Make colour transparent button
02390         EnableGadget(_R(IDC_T2_TRANSPARENT_COLOUR),         m_pExportOptions->GetSupportsPalette()
02391                                                             && m_pExportOptions->GetSupportsTransparency());
02392         SetLongGadgetValue(_R(IDC_T2_TRANSPARENT_COLOUR),   m_PaletteControl.GetSelectedColourTransparent());
02393 
02394         // Delete colour button
02395         EnableGadget(_R(IDC_T2_DELETE_COLOUR),              m_pExportOptions->GetSupportsPalette()
02396                                                             && !m_PaletteControl.GetSelectedColourDeleted());
02397         SetLongGadgetValue(_R(IDC_T2_DELETE_COLOUR),        FALSE);
02398 
02399         // Restore colour button
02400         EnableGadget(_R(IDC_T2_RESTORE_COLOUR),             m_pExportOptions->GetSupportsPalette()
02401                                                             && m_PaletteControl.GetSelectedColourDeleted());
02402         SetLongGadgetValue(_R(IDC_T2_RESTORE_COLOUR),       FALSE);
02403     }
02404 
02405     // Make background transparent button
02406     EnableGadget(_R(IDC_T2_TRANSPARENT_BACKGROUND),         m_pExportOptions->GetSupportsTransparency());
02407     SetLongGadgetValue(_R(IDC_T2_TRANSPARENT_BACKGROUND),   m_pExportOptions->IsBackgroundTransparent());
02408 
02409     // System colours button
02410     EnableGadget(_R(IDC_T2_SYSTEM_COLOURS),                 m_pExportOptions->GetSupportsPalette());
02411     SetLongGadgetValue(_R(IDC_T2_SYSTEM_COLOURS),           m_pExportOptions->IsUsingSystemPalette());
02412 }
02413 
02414 void BmapPrevDlg::RefreshPaletteSortList()
02415 {
02416     if (!m_pExportOptions->GetSupportsPalette())
02417     {
02418         EnableGadget(_R(IDC_T2_SORT_LIST), FALSE);
02419         return;
02420     }
02421     else
02422     {
02423         EnableGadget(_R(IDC_T2_SORT_LIST), TRUE);
02424     }
02425     
02426     switch (m_PaletteControl.GetCurrentSortType())
02427     {
02428         case BitmapExportPaletteInterface::SORT_USE:
02429             SetSelectedDropListItem(_R(IDC_T2_SORT_LIST), _R(IDS_SORT_BY_USES));
02430             break;
02431 
02432         case BitmapExportPaletteInterface::SORT_LUMINANCE:
02433             SetSelectedDropListItem(_R(IDC_T2_SORT_LIST), _R(IDS_SORT_BY_LUMINANCE));
02434             break;
02435 
02436         case BitmapExportPaletteInterface::SORT_HUE:
02437             SetSelectedDropListItem(_R(IDC_T2_SORT_LIST), _R(IDS_SORT_BY_HUE));
02438             break;
02439 
02440         default:
02441             ERROR3("How did this happen?");
02442             break;
02443     }
02444 }
02445 
02446 // //////////////////////////////////////////////////////////////////////////////////////// //
02447 // //////////////////////////////////////////////////////////////////////////////////////// //
02448 // Bitmap Size Tab                                                                          //
02449 // //////////////////////////////////////////////////////////////////////////////////////// //
02450 // //////////////////////////////////////////////////////////////////////////////////////// //
02451 
02452 /********************************************************************************************
02453 
02454 >   void BmapPrevDlg::HandleBitmapSizeTabMsg(DialogMsg* Msg)
02455 
02456     Author:     Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
02457     Created:    9/7/97
02458     Inputs:     Msg: The message sent from page 1 of the dialog
02459     Outputs:    -
02460     Returns:    -
02461     Purpose:    All messages generated from the tabbed dialog's page 1 get processed here
02462     Errors:     -
02463     Scope:      private
02464     SeeAlso:    BmapPrevDlg::Message
02465 
02466 ********************************************************************************************/
02467 void BmapPrevDlg::HandleBitmapSizeTabMsg(DialogMsg* Msg)
02468 {
02469     CDlgResID PageID = GetCurrentPageID();  // Get currently selected Tab id
02470     TalkToPage(_R(IDD_TBITMAPSIZE)); 
02471 
02472     TRACEUSER( "jlh92", _T("BmapPrevDlg::HandleBitmapSizeTabMsg") );
02473 
02474     switch (Msg->DlgMsg)
02475     {
02476         case DIM_CREATE:
02477         {
02478             TRACEUSER( "jlh92", _T("BmapPrevDlg::HandleBitmapSizeTabMsg - DIM_CREATE") );
02479             InitBitmapSizeTab();
02480             break;
02481         }
02482 
02483         case DIM_TEXT_CHANGED:
02484         {
02485             TRACEUSER( "jlh92", _T("BmapPrevDlg::HandleBitmapSizeTabMsg - DIM_TEXT_CHANGED") );
02486             if( Msg->GadgetID == _R(IDC_T1EDIT1) )
02487                 HandleBitmapSizeWidthChange();
02488             else
02489             if( Msg->GadgetID == _R(IDC_T1EDIT2) )
02490                 HandleBitmapSizeHeightChange();
02491             else
02492             if( Msg->GadgetID == _R(IDC_T1EDIT3) )
02493                 HandleBitmapSizeScaleFactorChange();
02494             else
02495             if( Msg->GadgetID == _R(IDC_T1COMBO1) ) 
02496                     if (PageID == _R(IDD_TBITMAPSIZE) && !m_LockSizeUpdates)
02497                         HandleBitmapSizeDPIChange();
02498             break;
02499         }
02500 
02501         case DIM_SELECTION_CHANGED:
02502         {
02503             TRACEUSER( "jlh92", _T("BmapPrevDlg::HandleBitmapSizeTabMsg - DIM_SELECTION_CHANGED") );
02504             if( Msg->GadgetID == _R(IDC_T1COMBO1) )
02505                 HandleBitmapSizeDPIChange();
02506             break;
02507         }
02508 
02509         case DIM_LFT_BN_CLICKED:
02510         {
02511 PORTNOTE("other","Hopefully this is no longer needed")
02512 #ifndef EXCLUDE_FROM_XARALX
02513             // This is a nasty hack/bodge
02514             // I keep on getting sent this DIM_LFT_BN_CLICKED msg when the user
02515             // changes views - or shortly after. The user didn't click on
02516             // any of the radio buttons bellow despite the msg saying we did.
02517             // So I check that the cursor is over the control that the user
02518             // has just clicked on before passing the msg to be processed.
02519             // sjk 2/1/01
02520             wxRect r;
02521             wxRect wndpos;
02522             GetGadgetPosition(Msg->GadgetID, &r);
02523             GetWindowRect(GetReadWriteWindowID(), &wndpos);
02524             POINT CurPos;
02525             GetCursorPos(&CurPos);
02526 
02527             BOOL inctrl = FALSE;
02528 
02529             if (CurPos.x >= wndpos.GetLeft() + r.GetLeft() && 
02530                 CurPos.x <= wndpos.GetLeft() + r.GetRight() &&
02531                 CurPos.y >= wndpos.GetTop() + r.GetTop() && 
02532                 CurPos.y <= wndpos.GetTop() + r.GetBottom())
02533                 inctrl = TRUE;
02534 
02535             if (inctrl)
02536             {
02537 #endif
02538                 if( Msg->GadgetID == _R(IDC_T1RADIO2) )
02539                     HandleBitmapSizeAreaToSaveChange(DRAWING);
02540                 else
02541                 if( Msg->GadgetID == _R(IDC_T1RADIO3) )
02542                     HandleBitmapSizeAreaToSaveChange(SELECTION);
02543                 else
02544                 if( Msg->GadgetID == _R(IDC_T1RADIO1) )
02545                     HandleBitmapSizeAreaToSaveChange(SPREAD);
02546                 else
02547                 if( Msg->GadgetID == _R(IDC_T1RADIO_MINIMISE_AA) )
02548                     HandleBitmapSizeAntiAliasingChange(TRUE);
02549                 else
02550                 if( Msg->GadgetID == _R(IDC_T1RADIO_MAINTAIN_AA) )
02551                     HandleBitmapSizeAntiAliasingChange(FALSE);
02552                 else
02553                 if( Msg->GadgetID == _R(IDC_T1_PUTHTMLTAGONCLIPBOARD) )
02554                     HandleBitmapSizePutHTMLChange();
02555 //          }
02556             break;
02557         }
02558 
02559         case DIM_FOCUS_LOST:
02560         {
02561             if( Msg->GadgetID == _R(IDC_T1EDIT1) ||
02562                 Msg->GadgetID == _R(IDC_T1EDIT2) ||
02563                 Msg->GadgetID == _R(IDC_T1COMBO1) )
02564             {
02565                 HandleBitmapSizeDPIChange();
02566             }
02567             TalkToPage(PageID);         
02568             break;
02569         }
02570 
02571         case DIM_SET_ACTIVE:
02572             TRACEUSER( "jlh92", _T("BmapPrevDlg::HandleBitmapSizeTabMsg - DIM_SET_ACTIVE") );
02573             UpdateCurrentTab();
02574             break;
02575 
02576         default:
02577             TalkToPage(PageID);
02578             break;
02579 
02580     }
02581 }
02582 
02583 void BmapPrevDlg::InitBitmapSizeTab()
02584 {
02585     InitBitmapSizeDPIList();
02586 
02587     InitBitmapSizeSelectionRadioGroup();
02588 
02589     InitBitmapSizeAntiAlisingRadioGroup();
02590 
02591     InitBitmapSizePutHTMLTick();
02592 }
02593 
02594 void BmapPrevDlg::InitBitmapSizePutHTMLTick()
02595 {
02596     if (m_FilterType == MAKE_BITMAP_FILTER)
02597     {
02598         HideGadget(_R(IDC_T1_PUTHTMLTAGONCLIPBOARD), TRUE);
02599         HideGadget(_R(IDC_STATIC_HTML), TRUE);
02600     }
02601     else
02602     {
02603         SetLongGadgetValue(_R(IDC_T1_PUTHTMLTAGONCLIPBOARD), m_ClipBoardUsage == CLIPBOARD_HTML);
02604     }
02605 }
02606 
02607 void BmapPrevDlg::InitBitmapSizeDPIList()
02608 {
02609     //  If we are slicing an image, then the controls below are all
02610     //  disabled. Therefore, just return, since we can't do anything else
02611     if (m_bSlicingImage)
02612         return;
02613 
02614     m_LockSizeUpdates = TRUE;
02615 
02616     // Make sure the list is empty
02617     DeleteAllValues(_R(IDC_T1COMBO1));
02618 
02619     bool bHasDPI =  m_pExportOptions->GetFilterNameStrID() != _R(IDN_FILTERNAME_GIF) &&
02620                     m_pExportOptions->GetFilterNameStrID() != _R(IDT_FILTERNAME_BMP);
02621 
02622     if (!bHasDPI)
02623     {
02624         SetStringGadgetValue(_R(IDC_T1COMBO1), _R(IDS_DPI_SCREEN), FALSE, -1);
02625         SetComboListLength(_R(IDC_T1COMBO1));
02626     }
02627     else
02628     {
02629         //  Set the initial value to be displayed from the current export options set.
02630         //  Also, store the depth in a variable which will be used in HandleColorDepthListChange().
02631         double dpi = m_pExportOptions->GetDPI();
02632         if (dpi != 50 && dpi != 75 && dpi != 96 && dpi != 100 && dpi != 150 &&
02633             dpi != 200 && dpi != 200 && dpi != 250 && dpi != 300)
02634             SetDoubleGadgetValue(_R(IDC_T1COMBO1), dpi);
02635         SetLongGadgetValue(_R(IDC_T1COMBO1), 50);
02636         SetLongGadgetValue(_R(IDC_T1COMBO1), 75);
02637         SetLongGadgetValue(_R(IDC_T1COMBO1), 96);
02638         SetLongGadgetValue(_R(IDC_T1COMBO1), 100);
02639         SetLongGadgetValue(_R(IDC_T1COMBO1), 150);
02640         SetLongGadgetValue(_R(IDC_T1COMBO1), 200);
02641         SetLongGadgetValue(_R(IDC_T1COMBO1), 250);
02642         SetLongGadgetValue(_R(IDC_T1COMBO1), 300);
02643 
02644         SetDoubleGadgetValue(_R(IDC_T1COMBO1), dpi, FALSE, -1);
02645 
02646         SetComboListLength(_R(IDC_T1COMBO1));
02647     }
02648 
02649     // gifs and bmps dont really have a dpi value so hide dpi drop down but leave the size
02650     EnableGadget(_R(IDC_T1COMBO1), bHasDPI);
02651     EnableGadget(_R(IDC_T1STATIC2), bHasDPI);
02652 
02653     m_LockSizeUpdates = FALSE;
02654 }
02655 
02656 void BmapPrevDlg::InitBitmapSizeSelectionRadioGroup()
02657 {
02658     BOOL lock = m_LockSizeUpdates;
02659     m_LockSizeUpdates = TRUE;
02660 
02661     SetLongGadgetValue(_R(IDC_T1RADIO1), FALSE);
02662     SetLongGadgetValue(_R(IDC_T1RADIO2), FALSE);
02663     SetLongGadgetValue(_R(IDC_T1RADIO3), FALSE);
02664 
02665     // Set up the save spread/selection radio buttons
02666     if (m_FilterType == MAKE_BITMAP_FILTER)
02667     {
02668         // Disable all buttons
02669         EnableGadget(_R(IDC_T1RADIO3), FALSE);
02670         EnableGadget(_R(IDC_T1RADIO2), FALSE);
02671         EnableGadget(_R(IDC_T1RADIO1), FALSE);
02672     }
02673     else
02674     {
02675         // If selection is True then enable the spread/selection/drawing buttons otherwise
02676         // disable the selection button and allow choice between spread or drawing, drawing
02677         // being the default.
02678         switch (m_pExportOptions->GetSelectionType())
02679         {
02680             case DRAWING:
02681                 SetLongGadgetValue(_R(IDC_T1RADIO2), TRUE);
02682                 break;
02683             case SELECTION:
02684                 SetLongGadgetValue(_R(IDC_T1RADIO3), TRUE);
02685                 break;
02686             default:
02687             case SPREAD:
02688                 SetLongGadgetValue(_R(IDC_T1RADIO1), TRUE);
02689                 break;
02690             case ABITMAP:
02691                 // Disable all buttons
02692                 EnableGadget(_R(IDC_T1RADIO3), FALSE);
02693                 EnableGadget(_R(IDC_T1RADIO2), FALSE);
02694                 EnableGadget(_R(IDC_T1RADIO1), FALSE);
02695                 EnableGadget(_R(IDC_T1COMBO1), FALSE);
02696                 break;
02697         }
02698     }
02699 
02700     m_LockSizeUpdates = lock;
02701 }
02702 
02703 void BmapPrevDlg::InitBitmapSizeAntiAlisingRadioGroup()
02704 {
02705     BOOL lock = m_LockSizeUpdates;
02706     m_LockSizeUpdates = TRUE;
02707 
02708     // If selection is True then enable the spread/selection/drawing buttons otherwise
02709     // disable the selection button and allow choice between spread or drawing, drawing
02710     // being the default.
02711     switch (m_pExportOptions->GetAntiAliasing())
02712     {
02713         case MAINTAIN_SCREEN_AA:
02714             SetLongGadgetValue(_R(IDC_T1RADIO_MAINTAIN_AA), TRUE);
02715             SetLongGadgetValue(_R(IDC_T1RADIO_MINIMISE_AA), FALSE);
02716             break;
02717         case MINIMISE_VISIBLE_AA:
02718             SetLongGadgetValue(_R(IDC_T1RADIO_MAINTAIN_AA), FALSE);
02719             SetLongGadgetValue(_R(IDC_T1RADIO_MINIMISE_AA), TRUE);
02720             break;
02721     }
02722 
02723     m_LockSizeUpdates = lock;
02724 }
02725 
02726 WinRect BmapPrevDlg::GetExportSize(double dpi)
02727 {
02728     SelRange* pSelection = GetApplication()->FindSelection();
02729 
02730     // deal with exporting no selection as the drawing
02731     if (pSelection->Count() == 0 && (m_pExportOptions->GetSelectionType() == SELECTION || m_pExportOptions->GetSelectionType() == ABITMAP))
02732         m_pExportOptions->SetSelectionType(DRAWING);
02733 
02734     DocRect ExportObjectSize;
02735     if (m_pExportOptions->GetSelectionType() == DRAWING)
02736     {
02737         // get the whole drawing size for now
02738         ExportObjectSize = BaseBitmapFilter::GetSizeOfDrawing();
02739 
02740     }
02741     else if (m_pExportOptions->GetSelectionType() == SELECTION || m_pExportOptions->GetSelectionType() == ABITMAP)
02742     {
02743         RangeControl rc     = pSelection->GetRangeControlFlags();
02744         RangeControl rcTemp = rc;
02745         rcTemp.PromoteToParent = TRUE;
02746         pSelection->Range::SetRangeControl(rcTemp);
02747 
02748         // Get the bounding rectangle for the selection
02749         ExportObjectSize = pSelection->GetBoundingRect();
02750 
02751         pSelection->Range::SetRangeControl(rc);
02752     }
02753     else if (m_pExportOptions->GetSelectionType() == SPREAD)
02754     {
02755         // get the whole drawing size for now
02756         ExportObjectSize = BaseBitmapFilter::GetSizeOfSpread(Document::GetSelectedSpread());
02757     }
02758     else if (m_pExportOptions->GetSelectionType() == PAGE)
02759     {
02760         Page *pPage = Document::GetSelectedSpread()->FindFirstPageInSpread(); 
02761         if (pPage)
02762             ExportObjectSize = pPage->GetPageRect();
02763     }
02764 
02765     Matrix Identity;    // default construction is an identity matrix
02766     return OSRenderRegion::BitmapDocRectToWin( Identity, ExportObjectSize, dpi );
02767 }
02768 
02769 
02770 void BmapPrevDlg::HandleBitmapSizeDPIChange()
02771 {
02772     if (m_LockSizeUpdates)
02773         return;
02774 
02775     bool bHasDPI =  m_pExportOptions->GetFilterNameStrID() != _R(IDN_FILTERNAME_GIF) &&
02776                     m_pExportOptions->GetFilterNameStrID() != _R(IDT_FILTERNAME_BMP);
02777     if (!bHasDPI)
02778         return;
02779 
02780         
02781     BOOL valid;
02782 
02783     double value = GetDoubleGadgetValue(_R(IDC_T1COMBO1), BMPEXP_MINDPI, BMPEXP_MAXDPI, 
02784                         0 /*_R(IDS_BMPPREFS_INVALIDDPI)*/ ,&valid);
02785     if (valid == FALSE)
02786         return;
02787 
02788 //  // check if the pixel fields have valid values
02789 //  if (ValidPixels == FALSE)
02790 //  {
02791 //      InformError(_R(IDS_BMPPREFS_DPITOOSMALL));
02792 //      return;
02793 //  }
02794 
02795     if (value == m_pExportOptions->GetDPI())
02796         return;
02797 
02798     WinRect Rect = GetExportSize(value);
02799 
02800     // check the new width
02801     if (Rect.GetWidth() < 1 || Rect.GetWidth() > BMPEXP_MAXWIDTH)
02802         return;
02803 
02804     // and check the new height
02805     if (Rect.GetHeight() < 1 || Rect.GetHeight() > BMPEXP_MAXHEIGHT)
02806         return;
02807 
02808     // If returned value in range then set the new default
02809     m_pExportOptions->SetDPI(value);
02810 
02811     m_LockSizeUpdates = TRUE;
02812     SetLongGadgetValue(_R(IDC_T1EDIT1), Rect.GetWidth());
02813     SetLongGadgetValue(_R(IDC_T1EDIT2), Rect.GetHeight());
02814     m_LockSizeUpdates = FALSE;
02815 
02816     // set the size of the export into the export options
02817     m_pExportOptions->SetPixelOutputSize(Rect.GetWidth(), Rect.GetHeight());
02818     // JPNOTE remove the next line soon
02819     SetPreviewButtonState(true);
02820 }
02821 
02822 void BmapPrevDlg::HandleBitmapSizeWidthChange()
02823 {
02824     if (m_LockSizeUpdates)
02825         return;
02826 
02827     BOOL valid = TRUE;
02828     INT32 Width  = GetLongGadgetValue(_R(IDC_T1EDIT1), 0, BMPEXP_MAXWIDTH, 0, &valid);
02829     if (!valid || Width < 1)
02830         return;
02831 
02832     double dpi = m_pExportOptions->GetDPI();
02833     WinRect Rect = GetExportSize(dpi);
02834     if (dpi < 5 || Rect.GetWidth() == 0)
02835         return;
02836 
02837     // calc the new dpi
02838     double Resolution = ((double) Width * dpi) / ((double) Rect.GetWidth());
02839     if ((Resolution < BMPEXP_MINDPI) || (Resolution > BMPEXP_MAXDPI))
02840         return; // new dpi out of range
02841 
02842     // calc the new height
02843     INT32 Height = (INT32) ceil((Resolution * (double)Rect.GetHeight()) / dpi);
02844 
02845     if (Height < 1 || Height > BMPEXP_MAXHEIGHT)
02846         return;
02847 
02848     m_pExportOptions->SetDPI(Resolution);
02849     m_LockSizeUpdates = TRUE;
02850 
02851     SetLongGadgetValue(_R(IDC_T1EDIT2), Height);
02852 
02853     bool bHasDPI =  m_pExportOptions->GetFilterNameStrID() != _R(IDN_FILTERNAME_GIF) &&
02854                     m_pExportOptions->GetFilterNameStrID() != _R(IDT_FILTERNAME_BMP);
02855     if (bHasDPI)
02856         SetDoubleGadgetValue(_R(IDC_T1COMBO1), Resolution, FALSE, -1);
02857 
02858     bool bHasScaleFactor =  m_pExportOptions->GetFilterNameStrID() == _R(IDN_FILTERNAME_GIF) ||
02859                             m_pExportOptions->GetFilterNameStrID() == _R(IDT_FILTERNAME_BMP);
02860     if (bHasScaleFactor)
02861         RefreshBitmapSizeScaleFactor();
02862     
02863     m_LockSizeUpdates = FALSE;
02864 
02865     // set the size of the export into the export options
02866     m_pExportOptions->SetPixelOutputSize(Width, Height);
02867     SetPreviewButtonState(true);
02868 }
02869 
02870 void BmapPrevDlg::HandleBitmapSizeHeightChange()
02871 {
02872     if (m_LockSizeUpdates)
02873         return;
02874 
02875     BOOL valid = TRUE;
02876     INT32 Height = GetLongGadgetValue(_R(IDC_T1EDIT2), 0, BMPEXP_MAXHEIGHT, 0, &valid);
02877     if (!valid || Height < 1)
02878         return;
02879 
02880     double dpi = m_pExportOptions->GetDPI();
02881     WinRect Rect = GetExportSize(dpi);
02882     if (dpi < BMPEXP_MINDPI || Rect.GetHeight() == 0)
02883         return;
02884 
02885     // calc the new dpi
02886     double Resolution = ((double) Height * dpi) / ((double) Rect.GetHeight());
02887     if ((Resolution < BMPEXP_MINDPI) || (Resolution > BMPEXP_MAXDPI))
02888         return; // new dpi out of range
02889 
02890     // calc the new Width
02891     INT32 Width = (INT32) ceil((Resolution * (double)Rect.GetWidth()) / dpi);
02892 
02893     if (Width < 1 || Width > BMPEXP_MAXWIDTH)
02894         return;
02895 
02896     m_pExportOptions->SetDPI(Resolution);
02897     m_LockSizeUpdates = TRUE;
02898 
02899     SetLongGadgetValue(_R(IDC_T1EDIT1), Width);
02900 
02901     bool bHasDPI =  m_pExportOptions->GetFilterNameStrID() != _R(IDN_FILTERNAME_GIF) &&
02902                     m_pExportOptions->GetFilterNameStrID() != _R(IDT_FILTERNAME_BMP);
02903     if (bHasDPI)
02904         SetDoubleGadgetValue(_R(IDC_T1COMBO1), Resolution, FALSE, -1);
02905 
02906     bool bHasScaleFactor =  m_pExportOptions->GetFilterNameStrID() == _R(IDN_FILTERNAME_GIF) ||
02907                             m_pExportOptions->GetFilterNameStrID() == _R(IDT_FILTERNAME_BMP);
02908     if (bHasScaleFactor)
02909         RefreshBitmapSizeScaleFactor();
02910     
02911     m_LockSizeUpdates = FALSE;
02912 
02913     // set the size of the export into the export options
02914     m_pExportOptions->SetPixelOutputSize(Width, Height);
02915     SetPreviewButtonState(true);
02916 }
02917 
02918 void BmapPrevDlg::HandleBitmapSizeScaleFactorChange()
02919 {
02920     if (m_LockSizeUpdates)
02921         return;
02922 
02923     bool bHasScaleFactor =  m_pExportOptions->GetFilterNameStrID() == _R(IDN_FILTERNAME_GIF) ||
02924                             m_pExportOptions->GetFilterNameStrID() == _R(IDT_FILTERNAME_BMP);
02925     if (!bHasScaleFactor)
02926         return;
02927 
02928     double sf = GetDoubleGadgetValue(_R(IDC_T1EDIT3), 1, 5000);
02929     double dpi = m_pExportOptions->GetDPI();
02930 
02931     WinRect rect = GetExportSize(dpi);
02932 
02933     if (dpi < 5 || rect.GetHeight() == 0)
02934         return;
02935 
02936     // calc the new dpi
02937     double newDPI = (sf * 96.0) / 100.0;
02938     if ((newDPI < 5.0) || (newDPI > 3000.0))
02939         return; // new dpi out of range
02940 
02941     m_pExportOptions->SetDPI(newDPI);
02942 
02943     // Force the size and DPI boxes to update
02944     InitBitmapSizeDPIList();
02945 
02946     // Force width and heigth to update
02947     WinRect wr = GetExportSize(m_pExportOptions->GetDPI());
02948 
02949     m_LockSizeUpdates = TRUE;
02950     SetLongGadgetValue(_R(IDC_T1EDIT1), wr.GetWidth());
02951     SetLongGadgetValue(_R(IDC_T1EDIT2), wr.GetHeight());
02952     m_LockSizeUpdates = FALSE;
02953 
02954     SetPreviewButtonState(true);
02955 }
02956 
02957 void BmapPrevDlg::HandleBitmapSizeAreaToSaveChange(SelectionType type)
02958 {
02959     if (m_LockSizeUpdates)
02960         return;
02961     m_pExportOptions->SetSelectionType(type);
02962     // reset the radio blobs
02963     InitBitmapSizeSelectionRadioGroup();
02964     SetPreviewButtonState(true);
02965 }
02966 
02967 void BmapPrevDlg::HandleBitmapSizeAntiAliasingChange(BOOL DoMinimise)
02968 {
02969     if (m_LockSizeUpdates)
02970         return;
02971     m_pExportOptions->SetAntiAliasing(DoMinimise ? MINIMISE_VISIBLE_AA : MAINTAIN_SCREEN_AA);
02972     InitBitmapSizeAntiAlisingRadioGroup();
02973     SetPreviewButtonState(true);
02974 }
02975 
02976 void BmapPrevDlg::HandleBitmapSizePutHTMLChange()
02977 {
02978     if (m_ClipBoardUsage != CLIPBOARD_HTML)
02979         m_ClipBoardUsage = CLIPBOARD_HTML;
02980     else if (m_ClipBoardUsage == CLIPBOARD_HTML)
02981         m_ClipBoardUsage = CLIPBOARD_NONE;
02982     else
02983         ERROR3("This should not be possible");
02984     InitBitmapSizePutHTMLTick();
02985 }
02986 
02987 // the options may have changed
02988 // update all the ctrls on this tab to show the new options
02989 void BmapPrevDlg::RefreshBitmapSizeTab()
02990 {
02991     TRACEUSER( "jlh92", _T("BmapPrevDlg::RefreshBitmapSizeTab") );
02992 
02993     // set the interlocking dpi controls
02994     m_LockSizeUpdates = TRUE;
02995 
02996     HandleBitmapSizeDPIChange();
02997     
02998     if (m_pPreviewDlg )
02999     {
03000         m_LockSizeUpdates = TRUE;
03001         WinRect wr = GetExportSize(m_pExportOptions->GetDPI());
03002         SetLongGadgetValue(_R(IDC_T1EDIT1), wr.GetWidth());
03003         SetLongGadgetValue(_R(IDC_T1EDIT2), wr.GetHeight());
03004         m_LockSizeUpdates = FALSE;
03005     }
03006     InitBitmapSizePutHTMLTick();
03007     InitBitmapSizeAntiAlisingRadioGroup();
03008     InitBitmapSizeSelectionRadioGroup();
03009     InitBitmapSizeDPIList();
03010 
03011     RefreshBitmapSizeScaleFactor();
03012 
03013     m_LockSizeUpdates = FALSE;
03014 }
03015 
03016 void BmapPrevDlg::RefreshBitmapSizeScaleFactor()
03017 {
03018     bool bHasScaleFactor =  m_pExportOptions->GetFilterNameStrID() == _R(IDN_FILTERNAME_GIF) ||
03019                             m_pExportOptions->GetFilterNameStrID() == _R(IDT_FILTERNAME_BMP);
03020 
03021     EnableGadget(_R(IDC_T1EDIT3), bHasScaleFactor);
03022     EnableGadget(_R(IDC_T1STATIC6), bHasScaleFactor);
03023     EnableGadget(_R(IDC_T1STATIC7), bHasScaleFactor);
03024 
03025     if (bHasScaleFactor)
03026     {
03027         // Bodge alert: To simulate a scale factor with out killing all the dodgy export code
03028         // we are going to use the DPI to do the job.
03029         double sf = (100.0 * m_pExportOptions->GetDPI()) / 96.0;
03030         SetDoubleGadgetValue(_R(IDC_T1EDIT3), sf);
03031     }
03032     else
03033     {
03034         SetDoubleGadgetValue(_R(IDC_T1EDIT3), 100);
03035     }
03036 }
03037 
03038 
03039 // //////////////////////////////////////////////////////////////////////////////////////// //
03040 // //////////////////////////////////////////////////////////////////////////////////////// //
03041 // Browser Preview Tab                                                                      //
03042 // //////////////////////////////////////////////////////////////////////////////////////// //
03043 // //////////////////////////////////////////////////////////////////////////////////////// //
03044 
03045 void BmapPrevDlg::HandleBrowserPreviewTabMsg(DialogMsg* Msg)
03046 {
03047 PORTNOTETRACE("other","BmapPrevDlg::HandleBrowserPreviewTabMsg - Do nothing");
03048 #if !defined(EXCLUDE_FROM_XARALX)
03049     CDlgResID PageID = GetCurrentPageID();  // Get currently selected Tab id
03050     TalkToPage(_R(IDD_TBROWSER));  // The Coords Page identifier
03051 
03052     switch(Msg->DlgMsg)
03053     {
03054         case DIM_CREATE:
03055         {
03056             m_bBrowserPreviewTabCreated = true;
03057             // Initialize these variables with the global values.
03058             // This allows the values to be stored in the program preferences.
03059 //          BrowserBackground Bgr   =   PreviewInBrowserTab::g_Background;
03060 //          BOOL Info               =   PreviewInBrowserTab::g_InfoInHtmlStub;
03061 //          BOOL Imagemap           =   PreviewInBrowserTab::g_Imagemap;
03062 
03063             // Removed - Ranbir. We no longer want to assign thse variables default values. 
03064             //t_BrowserOptions.Get(&Bgr, &Info, &Imagemap);
03065 
03066             // set the background radiobuttons
03067             SetLongGadgetValue(_R(IDC_T5RADIO1), PreviewInBrowserTab::g_Background == BROWSER_BGR_NONE);     
03068             SetLongGadgetValue(_R(IDC_T5RADIO2), PreviewInBrowserTab::g_Background == BROWSER_BGR_DOC);     
03069             SetLongGadgetValue(_R(IDC_T5RADIO3), PreviewInBrowserTab::g_Background == BROWSER_BGR_BITMAP);     
03070             SetLongGadgetValue(_R(IDC_T5RADIO4), PreviewInBrowserTab::g_Background == BROWSER_BGR_CHECKER);     
03071 
03072             // Setup checkboxes
03073             SetBoolGadgetSelected(_R(IDC_T5CHECK1), PreviewInBrowserTab::g_InfoInHtmlStub);     
03074             SetBoolGadgetSelected(_R(IDC_T5CHECK2), PreviewInBrowserTab::g_Imagemap);     
03075 
03076 //          SetBoolGadgetSelected(_R(IDC_BROWSER_PREVIEW), m_bDoPreviewInBrowser);     
03077             EnableGadget(_R(IDC_BROWSER_PREVIEW), FALSE); // as this 'feature' is broken
03078 
03079             break;
03080         }
03081         case DIM_LFT_BN_CLICKED:
03082         {
03083             if( Msg->GadgetID == _R(IDC_IMMEDIATE_BROWSER_PREVIEW) )
03084             {
03085                 // click on the 'Browser Preview' button
03086 
03087                 if (m_pPreviewDlg)
03088                 {
03089                     // get the browser options
03090                     BrowserPreviewOptions BrowserOptions;
03091                     BrowserPreviewGetOptions(&BrowserOptions);                  
03092                     
03093                     BOOL ok = TRUE;
03094                     // Shold check here if we need to regenerate preview and if so do so
03095                     // ok = DoPreview();
03096                     
03097                     // do the browser preview
03098                     if (ok) m_pPreviewDlg->DoBrowserPreview(BrowserOptions);
03099                 }
03100             }
03101             else
03102             if( Msg->GadgetID == _R(IDC_BROWSER_PREVIEW) )
03103             {
03104                 // check whether to do preview in browser
03105 //              m_bDoPreviewInBrowser = GetLongGadgetValue(_R(IDC_BROWSER_PREVIEW), 0, 0);
03106             }
03107         }
03108         break;
03109 
03110         case DIM_SET_ACTIVE:
03111             UpdateCurrentTab();
03112             break;
03113 
03114         default:
03115             TalkToPage(PageID);
03116             break;
03117     }
03118 #endif
03119 }
03120 
03121 /********************************************************************************************
03122 >   void BmapPrevDlg::BrowserPreviewGetOptions(BrowserPreviewOptions  &BrowserOptions)
03123     Author:     Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
03124     Created:    7/7/97
03125     Outputs:    BrowserOptions - receives the browser options stored in the Browser tab's controls
03126     Purpose:    Gets the values of the browser controls.
03127 ********************************************************************************************/
03128 void BmapPrevDlg::BrowserPreviewGetOptions(BrowserPreviewOptions *pBrowserOptions)
03129 {
03130 PORTNOTETRACE("other","BmapPrevDlg::BrowserPreviewGetOptions - Do nothing");
03131 #ifndef EXCLUDE_FROM_XARALX
03132     if (!m_bBrowserPreviewTabCreated)
03133     {
03134         // The tab has not been created so give up
03135         return;
03136     }
03137 
03138     TalkToPage(_R(IDD_TBROWSER));
03139 
03140     // get the background choice
03141     BrowserBackground Bgr = BROWSER_BGR_NONE;
03142     if (GetLongGadgetValue(_R(IDC_T5RADIO1), 0, 0))
03143         Bgr = BROWSER_BGR_NONE;
03144     else if (GetLongGadgetValue(_R(IDC_T5RADIO2), 0, 0))
03145         Bgr = BROWSER_BGR_DOC;
03146     else if (GetLongGadgetValue(_R(IDC_T5RADIO3), 0, 0))
03147         Bgr = BROWSER_BGR_BITMAP;
03148     else if (GetLongGadgetValue(_R(IDC_T5RADIO4), 0, 0))
03149         Bgr = BROWSER_BGR_CHECKER;
03150 
03151     // get the info choice
03152     BOOL Info = GetLongGadgetValue(_R(IDC_T5CHECK1), FALSE, TRUE, 0);
03153 
03154     // get the imagemap choice
03155     BOOL Imagemap = GetLongGadgetValue(_R(IDC_T5CHECK2), FALSE, TRUE, 0);
03156 
03157     //Now get the imagemap options to use. First get a pointer to the Imagemap filter
03158     ImagemapFilter* imageMap = (ImagemapFilter*)Filter::FindFilterFromID(FILTERID_IMAGEMAP);
03159 
03160     if(imageMap==NULL)
03161     {
03162         ERROR2RAW("BmapPrevDlg::GetBrowserOptions - no Imagemap Filter");
03163         return;
03164     }
03165 
03166     //Get the current set of imagemap options from that filter
03167     ImagemapFilterOptions ifoOptionsToUse=imageMap->GetFilterOptions();
03168 
03169     //Now get the options from our imagemap tab
03170     ImageMapGetOptions(&ifoOptionsToUse);
03171 
03172     // Store these new values in the global variables,
03173     // this allows us to save the details in the program preferences.
03174     PreviewInBrowserTab::g_Background       = Bgr;
03175     PreviewInBrowserTab::g_InfoInHtmlStub   = Info;
03176     PreviewInBrowserTab::g_Imagemap         = Imagemap;
03177 
03178 //  // Broadcast a bitmap preview properties changed message.
03179 //  BROADCAST_TO_ALL(BrowserPrvwChgdMsg(BrowserPrvwChgdMsg::BrowserPrvwPropState::PROPERTIES_CHANGED));
03180 
03181     //And set those options into the browser options
03182     pBrowserOptions->Set(Bgr, Info, Imagemap, ifoOptionsToUse);
03183 #endif
03184 }
03185 
03186 // //////////////////////////////////////////////////////////////////////////////////////// //
03187 // //////////////////////////////////////////////////////////////////////////////////////// //
03188 // Image Map Tab                                                                            //
03189 // //////////////////////////////////////////////////////////////////////////////////////// //
03190 // //////////////////////////////////////////////////////////////////////////////////////// //
03191 void BmapPrevDlg::HandleImageMapTabMsg(DialogMsg* Msg)
03192 {
03193     CDlgResID PageID = GetCurrentPageID();  // Get currently selected Tab id
03194     TalkToPage(_R(IDD_TIMAPOPTIONS));  // The Coords Page identifier
03195 
03196     switch(Msg->DlgMsg)
03197     {
03198         case DIM_CREATE:
03199         {
03200             m_bImageMapTabCreated = true;
03201             ImageMapOnCreate();
03202             break;
03203         }
03204 
03205         case DIM_TEXT_CHANGED:
03206         {
03207             if (Msg->GadgetID == _R(IDC_IMAPTAB_PATH))
03208             {
03209                 ImageMapOnFileNameChanged();
03210             }
03211             break;
03212         }
03213 
03214         case DIM_LFT_BN_CLICKED:
03215         {
03216             if( Msg->GadgetID == _R(IDC_IMAPTAB_EXPORTTOCLIPBOARD) ||
03217                 Msg->GadgetID == _R(IDC_IMAPTAB_EXPORTTOFILE) )
03218             {
03219                 //Get the state of the two Export... switches
03220                 BOOL fFile      = GetLongGadgetValue(_R(IDC_IMAPTAB_EXPORTTOFILE), FALSE, TRUE);
03221                 BOOL fClipboard = GetLongGadgetValue(_R(IDC_IMAPTAB_EXPORTTOCLIPBOARD), FALSE, TRUE);
03222 
03223                 if (fClipboard)
03224                     m_ClipBoardUsage = CLIPBOARD_IMAGEMAP;
03225                 else if (m_ClipBoardUsage == CLIPBOARD_IMAGEMAP)
03226                     m_ClipBoardUsage = CLIPBOARD_NONE;
03227 
03228                 //And enable the imagemap options gadgets if either of them is on
03229                 //Otherwise, disable the gadgets
03230                 ImageMapEnableOptions(fFile || fClipboard);
03231                 ImageMapEnableExportToFileOptions(fFile);
03232             }
03233             else
03234             if( Msg->GadgetID == _R(IDC_IMAPTAB_BROWSE) )
03235             {
03236                 ImageMapOnBrowseClicked();
03237             }
03238             else
03239             if( Msg->GadgetID == _R(IDC_IMAPTAB_ADDDESIGNNOTE) )
03240             {
03241                 //  User clicked on the 'Use Design Notes' checkbox
03242 
03243                 BOOL bCurrentState = m_pExportOptions->GetCanUseDesignNotes();
03244                 //  Flip the value of the bitmap export options variable.
03245                 bCurrentState = !bCurrentState;
03246 
03247                 m_pExportOptions->SetCanUseDesignNotes( bCurrentState );
03248 
03249 PORTNOTE("other","SetRegistryFlagForDesignNotes - not defiend yet");
03250 #ifndef EXCLUDE_FROM_XARALX
03251                 SetRegistryFlagForDesignNotes(bCurrentState);
03252 #endif
03253             }
03254             break;
03255         }
03256 
03257         case DIM_SET_ACTIVE:
03258             UpdateCurrentTab();
03259             break;
03260 
03261         default:
03262             TalkToPage(PageID);
03263             break;
03264 
03265     }
03266 }
03267 
03268 /********************************************************************************************
03269 >   void BmapPrevDlg::ImageMapOnCreate()
03270     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
03271     Created:    7/7/97
03272     Purpose:    This function is called when the imagemap tab is first called up by
03273                 the user.
03274 
03275                 It sets up the controls on the tab to appropriate defaults.
03276 ********************************************************************************************/
03277 void BmapPrevDlg::ImageMapOnCreate()
03278 {
03279     //Make sure we're talking to the right page
03280     TalkToPage(_R(IDD_TIMAPOPTIONS));
03281 
03282     //  Set the initial state of the 'Design Notes' checkbox
03283     //  Depending on whether the DreamWeaver programme is available or not, and whether the file
03284     //  has been named or not, we can enable/disable the appropriate controls.
03285     wxString DocName = _T("\\") + Document::GetCurrent()->GetPathName();    //  File name
03286 
03287 PORTNOTE("other","Removed UsesDesignNotes - not defined yet")
03288     BOOL bUsesDesignNotes   = false; //UsesDesignNotes();           //  Is Dreamweaver 3 installed?
03289     BOOL bFileSaved         = DocName != _("\\");           //  Has the current document been saved?
03290 
03291     SetLongGadgetValue( _R(IDC_IMAPTAB_ADDDESIGNNOTE), m_pExportOptions->GetCanUseDesignNotes() );
03292     if( (bUsesDesignNotes && bFileSaved) /*|| !m_pExportOptions->GetCanUseDesignNotes()*/)
03293     {
03294         //  Everything we need is here, so enable both controls
03295         // these controls are always enabled when this  tab is visable - it gives feedback if it is ticked when it shouldn't be
03296         //EnableGadget( _R(IDC_IMAPTAB_DESIGN_NOTES), TRUE );
03297         //EnableGadget( _R(IDC_IMAPTAB_ADDDESIGNNOTE), TRUE );
03298         //  Since the controls are enabled, we must decide whether to
03299         //  tick the checkbox or not.
03300 
03301         //  Make sure that the 2 text labels are hidden
03302         HideGadget( _R(IDC_IMAPTAB_STATIC3), TRUE );
03303         HideGadget( _R(IDC_IMAPTAB_STATIC4), TRUE );
03304     }
03305     else
03306     {
03307         //  Can't do a design note, so disable both controls
03308         //EnableGadget( _R(IDC_IMAPTAB_DESIGN_NOTES), FALSE );
03309         //EnableGadget( _R(IDC_IMAPTAB_ADDDESIGNNOTE), FALSE );
03310         //  Display a text message that informs the user what the problem is.
03311         if( !bUsesDesignNotes )     //  Dreamweaver 3 is not installed
03312         {
03313             //  Show the appropriate text label
03314             HideGadget( _R(IDC_IMAPTAB_STATIC3), FALSE );
03315             //  Hide the other one
03316             HideGadget( _R(IDC_IMAPTAB_STATIC4), TRUE );
03317         }
03318         else    //  Document not saved yet.
03319         {
03320             //  Show the appropriate text label
03321             HideGadget( _R(IDC_IMAPTAB_STATIC4), FALSE );
03322             //  Hide the other one
03323             HideGadget( _R(IDC_IMAPTAB_STATIC3), TRUE );
03324         }
03325     }
03326 
03327     if (m_bSlicingImage)
03328     {
03329         //  If we are doing image slicing, then all the controls 
03330         //  in this tab have to be disabled.
03331 
03332         //  'Export image map to':
03333         EnableGadget(_R(IDC_EXP_IMAPTAB_OPTIONS),       FALSE);
03334         EnableGadget(_R(IDC_IMAPTAB_EXPORTTOCLIPBOARD), FALSE);
03335         EnableGadget(_R(IDC_IMAPTAB_INSERT),            FALSE);
03336         EnableGadget(_R(IDC_IMAPTAB_EXPORTTOFILE),      FALSE);
03337         EnableGadget(_R(IDC_IMAPTAB_REPLACE),           FALSE);
03338         EnableGadget(_R(IDC_IMAPTAB_PATH),              FALSE);
03339         EnableGadget(_R(IDC_IMAPTAB_BROWSE),            FALSE);
03340 
03341         //  'Dreamweaver integration': Should be enabled
03342         EnableGadget( _R(IDC_IMAPTAB_DESIGN_NOTES), TRUE );
03343         EnableGadget( _R(IDC_IMAPTAB_ADDDESIGNNOTE), TRUE );
03344 
03345         //  'Image map options':
03346         EnableGadget( _R(IDC_IMAPTAB_OPTIONS), FALSE );
03347         EnableGadget( _R(IDC_IMAPTAB_STATIC1), FALSE );
03348         EnableGadget( _R(IDC_IMAPTAB_MAPNAME), FALSE );
03349         EnableGadget( _R(IDC_IMAPTAB_STATIC2), FALSE );
03350         EnableGadget( _R(IDC_IMAPTAB_APPROX), FALSE );
03351         EnableGadget( _R(IDC_IMAPTAB_RECTANGLES), FALSE );
03352 
03353         return;
03354     }
03355 
03356     //First find the imagemap filter
03357     ImagemapFilter *pImagemapFilter = (ImagemapFilter*)Filter::FindFilterFromID(FILTERID_IMAGEMAP);
03358 
03359     if(!pImagemapFilter)
03360     {
03361         ERROR2RAW("BmapPrevDlg::OnCreateImagemap - no Imagemap Filter");
03362         return;
03363     }
03364 
03365     //Get the current set of ImagemapFilterOptions
03366     ImagemapFilterOptions ifoCurrent = pImagemapFilter->GetFilterOptions();
03367 
03368     //First get the value for the ExportToFile switch
03369     BOOL fFile=ifoCurrent.ExportToFile();
03370 
03371     SetLongGadgetValue(_R(IDC_IMAPTAB_EXPORTTOFILE),        fFile);
03372 
03373     //And make sure we're on the right page again
03374     TalkToPage(_R(IDD_TIMAPOPTIONS));
03375 
03376 //  //Now the "File name" edit field
03377 //  //Is the bitmap we are exporting the same as the last bitmap we exported?
03378 //  String_256 str1=m_pthExport.GetPath(FALSE);
03379 //  String_256 str2=m_pthLastExport.GetPath(FALSE);
03380 //
03381 //  BOOL fIsSameAsLastExport=(str1==str2);
03382 //
03383 //  if (fIsSameAsLastExport)
03384 //  {
03385 //      //Yes. So use the last imagemap path we exported to
03386 //      String_256 strToUse=m_pthLastImagemapExport.GetPath(FALSE);
03387 //      SetStringGadgetValue(_R(IDC_IMAPTAB_PATH), &strToUse, FALSE, -1);
03388 //  }
03389 //  else
03390 //  {
03391 
03392     //No. So use the same path as the bitmap we are exporting to, with the
03393     //extension changed to "htm"
03394     PathName pthToUse=m_pthExport;
03395 
03396     pthToUse.SetType("htm");
03397     
03398     String_256 strToUse=pthToUse.GetPath(FALSE);
03399     SetStringGadgetValue(_R(IDC_IMAPTAB_PATH), strToUse, FALSE, -1);
03400 
03401 //  }
03402 
03403     //Set up the Approximate... combo box
03404     DeleteAllValues(_R(IDC_IMAPTAB_APPROX));
03405 
03406     SetStringGadgetValue(_R(IDC_IMAPTAB_APPROX), String_256(_R(IDS_IMAGEMAP_APPROX_VERYCLOSELY)), FALSE, 0);
03407     SetStringGadgetValue(_R(IDC_IMAPTAB_APPROX), String_256(_R(IDS_IMAGEMAP_APPROX_CLOSELY)), FALSE, 1);
03408     SetStringGadgetValue(_R(IDC_IMAPTAB_APPROX), String_256(_R(IDS_IMAGEMAP_APPROX_APPROXIMATELY)), FALSE, 2);
03409     SetStringGadgetValue(_R(IDC_IMAPTAB_APPROX), String_256(_R(IDS_IMAGEMAP_APPROX_NOTATALL)), FALSE, 3);
03410     
03411     SetComboListLength(_R(IDC_IMAPTAB_APPROX));
03412 
03413     switch (ifoCurrent.m_ffApprox)
03414     {
03415         case FF_VERYCLOSELY:
03416             SetSelectedValueIndex(_R(IDC_IMAPTAB_APPROX), 0);
03417             break;
03418 
03419         case FF_CLOSELY:
03420             SetSelectedValueIndex(_R(IDC_IMAPTAB_APPROX), 1);
03421             break;
03422 
03423         case FF_APPROXIMATELY:
03424             SetSelectedValueIndex(_R(IDC_IMAPTAB_APPROX), 2);
03425             break;
03426 
03427         case FF_NOTATALL:
03428             SetSelectedValueIndex(_R(IDC_IMAPTAB_APPROX), 3);
03429             break;
03430 
03431         default:
03432             ERROR2RAW("ImagemapDlg::SetOptions - Unrecognised Curve Approx Factor");
03433             break;
03434     }
03435 
03436     //And the "Map Name..." combo box
03437     DeleteAllValues(_R(IDC_IMAPTAB_MAPNAME));
03438 
03439     //Now the Insert/Replace radio buttons
03440     //Note that although we set the values of these controls here, we set
03441     //whether the controls are displayed or not under "OnFileNameChanged" below
03442     SetLongGadgetValue(_R(IDC_IMAPTAB_INSERT), ifoCurrent.Insert());
03443     SetLongGadgetValue(_R(IDC_IMAPTAB_REPLACE), !ifoCurrent.Insert());
03444 
03445     //This function sets up the drop-down list, by parsing the file referred to in the
03446     //pathname edit field, getting the names of any imagemaps referred to in that file
03447     //and putting those names in the drop-down box
03448     ImageMapOnFileNameChanged(); 
03449 
03450     //And now to set up the name that actually appears in the edit field portion 
03451     //of the combo box
03452 //  if (fIsSameAsLastExport)
03453 //  {
03454 //      //Use the last map name
03455 //      SetStringGadgetValue(_R(IDC_IMAPTAB_MAPNAME), &ifoCurrent.m_strName, FALSE, -1);
03456 //  }
03457 //  else
03458     {
03459         //Use the file name of the bitmap, with the extension removed, 
03460         //as the map name
03461         PathName pthToUse=m_pthExport;
03462 
03463         String_256 strToUse=pthToUse.GetFileName(FALSE);
03464         SetStringGadgetValue(_R(IDC_IMAPTAB_MAPNAME), strToUse, FALSE, -1);
03465     }
03466 
03467     SetComboListLength(_R(IDC_IMAPTAB_MAPNAME));
03468     
03469     //And get the rectangle box
03470     SetLongGadgetValue(_R(IDC_IMAPTAB_RECTANGLES), ifoCurrent.ExportAllRectangles());
03471 
03472     //Now if we are exporting an imagemap (either to file or to clipboard)
03473     //then ungrey all the imagemap options. Otherwise grey them all.
03474     ImageMapEnableOptions(fFile || m_ClipBoardUsage == CLIPBOARD_IMAGEMAP);
03475 
03476     //And if we are exporting an imagemap to the file, then ungrey the
03477     //file name edit field and the browse button, otherwise grey them both
03478     ImageMapEnableExportToFileOptions(fFile);
03479 
03480     RefreshImageMapTab();
03481 }
03482 
03483 void BmapPrevDlg::RefreshImageMapTab()
03484 {
03485     SetLongGadgetValue(_R(IDC_IMAPTAB_EXPORTTOCLIPBOARD), m_ClipBoardUsage == CLIPBOARD_IMAGEMAP);
03486 }
03487 
03488 
03489 /********************************************************************************************
03490   > void BmapPrevDlg::ImageMapGetOptions(ImagemapFilterOptions* pOptions)
03491     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
03492     Created:    7/7/97
03493     Purpose:    Gets the values from the Imagemap tab and puts them into
03494                 the pOptions structure.
03495 ********************************************************************************************/
03496 void BmapPrevDlg::ImageMapGetOptions(ImagemapFilterOptions* pOptions)
03497 {
03498     ERROR3IF(m_bSlicingImage, "This should not be called if we are slicing");
03499 
03500     if (!m_bImageMapTabCreated)
03501     {
03502         // The tab has not been created so give up
03503         return;
03504     }
03505 
03506     TalkToPage(_R(IDD_TIMAPOPTIONS)); 
03507 
03508     //Get the values of the ExportToFile and ExportToClipboard buttons
03509     BOOL fFile      = GetLongGadgetValue(_R(IDC_IMAPTAB_EXPORTTOFILE), FALSE, TRUE);
03510     BOOL fClipboard = m_ClipBoardUsage == CLIPBOARD_IMAGEMAP;
03511 
03512     //And set our variables into the options object
03513     pOptions->m_fFile=fFile;
03514     pOptions->m_fClipboard=fClipboard;
03515 
03516     //So, if we are exporting to a file
03517     if (fFile)
03518     {
03519         //Then remember the path to export to
03520         pOptions->m_pthFile=GetStringGadgetValue(_R(IDC_IMAPTAB_PATH));
03521 
03522         //And if that file exists
03523         if (SGLibOil::FileExists(&(pOptions->m_pthFile)))
03524         {
03525             //Then get the values of the insert/replace radio buttons
03526             pOptions->m_fInsert=GetLongGadgetValue(_R(IDC_IMAPTAB_INSERT), FALSE, TRUE);
03527         }
03528     }
03529 
03530     //And if we are exporting either to a file or to the clipboard
03531     if (fFile || fClipboard)
03532     {
03533         //Then get the values from the dialog and set them
03534         //into the ImagemapFilterOptions object
03535 
03536         //The map name
03537         pOptions->m_strName=GetStringGadgetValue(_R(IDC_IMAPTAB_MAPNAME));
03538 
03539         //The "Approximate curves with lines" drop down box
03540         switch (GetSelectedValueIndex(_R(IDC_IMAPTAB_APPROX)))
03541         {
03542             case 0:
03543                 pOptions->m_ffApprox=FF_VERYCLOSELY;
03544                 break;
03545 
03546             case 1:
03547                 pOptions->m_ffApprox=FF_CLOSELY;
03548                 break;
03549 
03550             case 2:
03551                 pOptions->m_ffApprox=FF_APPROXIMATELY;
03552                 break;
03553 
03554             case 3:
03555                 pOptions->m_ffApprox=FF_NOTATALL;
03556                 break;
03557 
03558             default:
03559                 ERROR2RAW("ImagemapDlg::GetOptions - Unrecognised drop-down box index");
03560                 break;
03561         }
03562 
03563         //The "save clickable areas as rectangles" radio button
03564         pOptions->m_fAllRectangles=(GetLongGadgetValue(_R(IDC_IMAPTAB_RECTANGLES), 0, 1)==1);
03565     }
03566 }
03567 
03568 
03569 /********************************************************************************************
03570 >   void BmapPrevDlg::OnCommitImagemap()
03571     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
03572     Created:    7/7/97
03573     Purpose:    This function is called when the OK button is clicked.
03574                 It takes the values from the controls on the imagemap tab and sets
03575                 them back into the Imagemap filter.
03576 ********************************************************************************************/
03577 void BmapPrevDlg::ImageMapOnCommit()
03578 {
03579 PORTNOTETRACE("other","BmapPrevDlg::ImageMapOnCommit - Do nothing");
03580 #ifndef EXCLUDE_FROM_XARALX
03581     // Check if we have opened the tab or not. If we haven't then it is not a good
03582     // idea to get get values from an uninitialised tab!
03583     if (!m_bImageMapTabCreated)
03584         return;
03585 
03586     // we do not do image slicing as well as image map stuff
03587     // one or the other please
03588     if (m_bSlicingImage)
03589         return;
03590         
03591     // Get a pointer to the imagemap filter
03592     ImagemapFilter *pImagemapFilter=(ImagemapFilter*)Filter::FindFilterFromID(FILTERID_IMAGEMAP);
03593 
03594     if(pImagemapFilter==NULL)
03595     {
03596         ERROR2RAW("BmapPrevDlg::OnCommitImagemap - no Imagemap Filter");
03597         return;
03598     }
03599 
03600     //Now get the current set of ImagemapFilterOptions from the Imagemap filter
03601     ImagemapFilterOptions ifoCurrent=pImagemapFilter->GetFilterOptions();
03602 
03603     //And put the values from the imagemap tab into that object
03604     ImageMapGetOptions(&ifoCurrent);
03605 
03606     // If this is not set, the user does not get any warning when they try and
03607     // export with an image map but don't set a web address.
03608     ifoCurrent.m_fReportErrors = TRUE;
03609 
03610     //And set the options back into the filter
03611     pImagemapFilter->SetFilterOptions(ifoCurrent);
03612 /*
03613     //Now, if we are exporting either to a file or to the clipboard
03614     if (ifoCurrent.m_fFile || ifoCurrent.m_fClipboard)
03615     {
03616         //Then update some varialbes
03617 
03618         //Firstly, the last bitmap path we exported to while exporting an imagemap
03619         m_pthLastExport=m_pthExport;
03620 
03621         //Second, the last path we exported an imagemap to
03622         m_pthLastImagemapExport=ifoCurrent.m_pthFile;
03623 
03624         //And thirdly, the last map name
03625         m_strLastMapName=ifoCurrent.m_strName;
03626     }
03627 */
03628 #endif
03629 }
03630 
03631 /********************************************************************************************
03632 >   void BmapPrevDlg::EnableImagemapOptions(BOOL fValue)
03633     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
03634     Created:    7/7/97
03635     Inputs:     fValue - whether to grey or ungrey the Imagemap Options controls
03636     Purpose:    Greys or ungreys all the Imagemap Options controls
03637 ********************************************************************************************/
03638 void BmapPrevDlg::ImageMapEnableOptions(BOOL fValue)
03639 {
03640     EnableGadget(_R(IDC_IMAPTAB_MAPNAME),       fValue);
03641     EnableGadget(_R(IDC_IMAPTAB_APPROX),        fValue);
03642     EnableGadget(_R(IDC_IMAPTAB_RECTANGLES),    fValue);
03643 }
03644 
03645 /********************************************************************************************
03646 >   void BmapPrevDlg::EnableExportToFileOptions(BOOL fValue)
03647     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
03648     Created:    7/7/97
03649     Inputs:     fValue - whether to grey or ungrey the Export To File controls
03650     Purpose:    Greys or ungreys all the Export To File controls
03651 ********************************************************************************************/
03652 void BmapPrevDlg::ImageMapEnableExportToFileOptions(BOOL fValue)
03653 {
03654     EnableGadget(_R(IDC_IMAPTAB_PATH),      fValue);
03655     EnableGadget(_R(IDC_IMAPTAB_BROWSE),    fValue);
03656     EnableGadget(_R(IDC_IMAPTAB_INSERT),    fValue);
03657     EnableGadget(_R(IDC_IMAPTAB_REPLACE),   fValue);
03658 }
03659 
03660 /********************************************************************************************
03661 >   void BmapPrevDlg::ImageMapOnBrowseClicked()
03662     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
03663     Created:    7/7/97
03664     Purpose:    This function is called when the "Browse..." button is clicked.
03665 
03666                 It brings up a file dialog to allow the user to enter a file to save into.
03667                 Then it puts the path the user entered into the pathname field.
03668 ********************************************************************************************/
03669 void BmapPrevDlg::ImageMapOnBrowseClicked()
03670 {
03671 PORTNOTETRACE("other","BmapPrevDlg::ImageMapOnBrowseClicked - Do nothing");
03672 #ifndef EXCLUDE_FROM_XARALX
03673     //First get our default filename from the Path edit field
03674     String_256 strFile=GetStringGadgetValue(_R(IDC_IMAPTAB_PATH));
03675     PathName pthFile(strFile);
03676 
03677     //Now create a text character pointer
03678     const TCHAR* pcBuffer=NULL;
03679 
03680     //And if we have a valid filename
03681     if (pthFile.IsValid())
03682         //Then set that pointer to point at our file name
03683         pcBuffer=strFile;
03684 
03685     //If the filename is not valid, then the text buffer pointer stays at NULL
03686 
03687     //And now get our string which will initialise our filters
03688     String_256 strFilters(_R(IDS_IMAPTAB_BROWSEFILTERSTRING));
03689 
03690     //Now create a Save dialog object
03691     MFCFileDialog dlgSave(FALSE, "htm", pcBuffer, OFN_HIDEREADONLY, (TCHAR*) strFilters);
03692 
03693     //Open it
03694     dlgSave.DoModal();
03695 
03696     //Now get the path name that the user chose
03697     String_256 strChosen=dlgSave.GetPathName();
03698 
03699     //Talk to the right page
03700     TalkToPage(_R(IDD_TIMAPOPTIONS)); 
03701     
03702     //And put that path name string into the filename field
03703     SetStringGadgetValue(_R(IDC_IMAPTAB_PATH), strChosen, FALSE, -1);
03704 
03705     //Then call the function that we call every time the filename changes
03706     ImageMapOnFileNameChanged();
03707 #endif
03708 }
03709 
03710 /********************************************************************************************
03711 >   void BmapPrevDlg::OnFileNameChanged()
03712     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
03713     Created:    7/7/97
03714     Purpose:    This function is called whenever the pathname field changes
03715 
03716                 It checks if the file exists. If so, it
03717 
03718                 a. Brings up the Insert/Replace radio buttons
03719                 b. Parses the file to get the names of all the imagemaps, and
03720                     puts those names in the drop-down list of the Name combo box
03721 ********************************************************************************************/
03722 void BmapPrevDlg::ImageMapOnFileNameChanged()
03723 {
03724 PORTNOTETRACE("other","BmapPrevDlg::ImageMapOnFileNameChanged - Do nothing");
03725 #ifndef EXCLUDE_FROM_XARALX
03726     //Return if the imagemap tab isn't created yet
03727     if (!m_bImageMapTabCreated)
03728         return;
03729 
03730     TalkToPage(_R(IDD_TIMAPOPTIONS));
03731 
03732     //First let's get the path of the file in the edit field
03733     String_256 strOpen=GetStringGadgetValue(_R(IDC_IMAPTAB_PATH));
03734 
03735     PathName pthOpen;
03736 
03737     //If that file exists...
03738     if (pthOpen.SetPathName(strOpen) && SGLibOil::FileExists(&pthOpen))
03739     {
03740         //Yes it does
03741 
03742         //So first display the Insert/Replace radio buttons
03743         HideGadget(_R(IDC_IMAPTAB_INSERT), FALSE);
03744         HideGadget(_R(IDC_IMAPTAB_REPLACE), FALSE);
03745 
03746         //We want to parse this file to find out all the names of imagemaps in it
03747 
03748         //Now create a list to put all the map names in
03749         List lstStrings;
03750 
03751         //First find the imagemap filter
03752         ImagemapFilter *pImagemapFilter = (ImagemapFilter*)Filter::FindFilterFromID(FILTERID_IMAGEMAP);
03753 
03754         if(!pImagemapFilter)
03755         {
03756             ERROR2RAW("BmapPrevDlg::OnCreateImagemap - no Imagemap Filter");
03757             return;
03758         }
03759 
03760         pImagemapFilter->SearchFileForImagemaps(pthOpen, &lstStrings);
03761 
03762         //Now we want to iterate through all the items in the list and put them
03763         //into the Map Name combo box
03764 
03765         //So first clear all items in the combo box
03766         DeleteAllValues(_R(IDC_IMAPTAB_MAPNAME));
03767 
03768         //And get the first item in the list
03769         StringListItem* pThisItem=(StringListItem*) lstStrings.GetHead();
03770         INT32 i=0;
03771 
03772         //And until we get to the end of the list
03773         while (pThisItem)
03774         {
03775             //Add the string into the combo box
03776             String_256 strToUse=pThisItem->GetString();
03777 
03778             SetStringGadgetValue(_R(IDC_IMAPTAB_MAPNAME), strToUse, FALSE, i);
03779 
03780             //And increase our current position
03781             i++;
03782 
03783             //And get the next item
03784             pThisItem=(StringListItem*) lstStrings.GetNext(pThisItem);
03785         }
03786 
03787         //Delete our list
03788         lstStrings.DeleteAll();
03789 
03790         SetComboListLength(_R(IDC_IMAPTAB_MAPNAME)); 
03791 
03792         //And set the default map name into the list, which is the name of the
03793         //bitmap file without the extension
03794         String_256 strDefault=pthOpen.GetFileName(FALSE);
03795         SetStringGadgetValue(_R(IDC_IMAPTAB_MAPNAME), strDefault, FALSE, -1);
03796         
03797     } //END if the file exists
03798     else
03799     {
03800         //No, the file doesn't exist
03801 
03802         //So hide the insert/replace radio buttons
03803         HideGadget(_R(IDC_IMAPTAB_INSERT), TRUE);
03804         HideGadget(_R(IDC_IMAPTAB_REPLACE), TRUE);
03805     }
03806 #endif
03807 }
03808 
03809 // //////////////////////////////////////////////////////////////////////////////////////// //
03810 // //////////////////////////////////////////////////////////////////////////////////////// //
03811 // Bitmap Options Tab                                                                       //
03812 // //////////////////////////////////////////////////////////////////////////////////////// //
03813 // //////////////////////////////////////////////////////////////////////////////////////// //
03814 
03815 void BmapPrevDlg::HandleBitmapOptionsTabMsg(DialogMsg* Msg)
03816 {
03817     CDlgResID PageID = GetCurrentPageID();  // Get currently selected Tab id
03818     TalkToPage(_R(IDD_TBITMAPOPTIONS)); 
03819     switch(Msg->DlgMsg)
03820     {
03821     case DIM_CREATE:
03822         SetGadgetRange( _R(IDC_OPTIONSTAB_JPEG_SLIDER), 0, 100 );
03823         SetGadgetBitmaps( _R(IDC_OPTIONSTAB_JPEG_SLIDER), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER) );
03824         InitBitmapOptionsTab();
03825         break;
03826 
03827     case DIM_LFT_BN_CLICKED:
03828         HandleBitmapOptionsTicks(Msg->GadgetID);
03829         break;
03830 
03831     case DIM_SLIDER_POS_IDLE:
03832     case DIM_SLIDER_POS_SET:
03833         if (m_pExportOptions->GetFilterNameStrID() == _R(IDS_JPG_EXP_FILTERNAME))
03834         {
03835             INT32 SliderPos = GetLongGadgetValue(_R(IDC_OPTIONSTAB_JPEG_SLIDER), 0, 100);
03836             ((JPEGExportOptions*) m_pExportOptions)->SetQuality(100-SliderPos);
03837             HandleBitmapOptionsTicks(Msg->GadgetID);        
03838             DoPreview();
03839         }
03840         break;
03841 
03842     case DIM_SLIDER_POS_CHANGING:
03843         if (m_pExportOptions->GetFilterNameStrID() == _R(IDS_JPG_EXP_FILTERNAME))
03844         {
03845             INT32 SliderPos = GetLongGadgetValue(_R(IDC_OPTIONSTAB_JPEG_SLIDER), 0, 100);
03846             String_256 QualityPercent = "";
03847             QualityPercent.MakeMsg(_R(IDS_ZOOM_INFO_FORMAT), 100-SliderPos);
03848 
03849             SetStringGadgetValue(_R(IDC_OPTIONSTAB_JPEG_TEXT4), QualityPercent);
03850         }
03851         break;
03852 
03853     case DIM_SET_ACTIVE:
03854         UpdateCurrentTab();
03855         break;
03856 
03857     default:
03858         TalkToPage(PageID);
03859         break;
03860     }
03861 }
03862 
03863 // this function ticks the bits dependant on which graphic type we are
03864 void BmapPrevDlg::InitBitmapOptionsTab()
03865 {
03866     // is the slider visible
03867     // this is only shown for jpegs
03868     BOOL ShowSlider = m_pExportOptions->GetFilterNameStrID() == _R(IDS_JPG_EXP_FILTERNAME);
03869 
03870     HideGadget(_R(IDC_OPTIONSTAB_JPEG_TEXT1), !ShowSlider);
03871     HideGadget(_R(IDC_OPTIONSTAB_JPEG_TEXT2), !ShowSlider);
03872     HideGadget(_R(IDC_OPTIONSTAB_JPEG_TEXT3), !ShowSlider);
03873     HideGadget(_R(IDC_OPTIONSTAB_JPEG_TEXT4), !ShowSlider);
03874     HideGadget(_R(IDC_OPTIONSTAB_JPEG_SLIDER), !ShowSlider);
03875 
03876     if (ShowSlider)
03877     {
03878         INT32 Quality = 100-((JPEGExportOptions*) m_pExportOptions)->GetQuality();
03879         SetLongGadgetValue(_R(IDC_OPTIONSTAB_JPEG_SLIDER), Quality);
03880         String_256 QualityPercent = "";
03881         QualityPercent.MakeMsg(_R(IDS_ZOOM_INFO_FORMAT), 100-Quality);
03882 
03883         SetStringGadgetValue(_R(IDC_OPTIONSTAB_JPEG_TEXT4), QualityPercent);
03884     }
03885 
03886     if( m_pExportOptions->GetFilterNameStrID() == _R(IDS_JPG_EXP_FILTERNAME) )
03887     {
03888         SetStringGadgetValue(_R(IDC_OPTIONSTAB_CHECK1), _R(IDS_OPTIONS_TAB_PROGRESSIVE));
03889         SetStringGadgetValue(_R(IDC_OPTIONSTAB_CHECK2), _R(IDS_OPTIONS_TAB_ORIGINAL_JPEG));
03890         HideGadget(_R(IDC_OPTIONSTAB_CHECK1), FALSE);
03891         HideGadget(_R(IDC_OPTIONSTAB_CHECK2), TRUE);
03892         HideGadget(_R(IDC_OPTIONSTAB_CHECK3), TRUE);
03893         SetLongGadgetValue(_R(IDC_OPTIONSTAB_CHECK1), ((JPEGExportOptions*) m_pExportOptions)->DoAsProgressive());
03894     }
03895     else
03896     if( m_pExportOptions->GetFilterNameStrID() == _R(IDT_FILTERNAME_BMP) )
03897     {
03898         HideGadget(_R(IDC_OPTIONSTAB_CHECK1), TRUE);
03899         HideGadget(_R(IDC_OPTIONSTAB_CHECK2), TRUE);
03900         HideGadget(_R(IDC_OPTIONSTAB_CHECK3), TRUE);
03901     }
03902 //  default:
03903 //  case _R(IDN_FILTERNAME_GIF):
03904 //  case _R(IDS_FILTERNAME_PNG):
03905     else
03906     {
03907         SetStringGadgetValue(_R(IDC_OPTIONSTAB_CHECK1), _R(IDS_OPTIONS_TAB_INTERLACED));
03908         SetStringGadgetValue(_R(IDC_OPTIONSTAB_CHECK2), _R(IDS_OPTIONS_TAB_TRANSPARENT));
03909         SetStringGadgetValue(_R(IDC_OPTIONSTAB_CHECK3), _R(IDS_OPTIONS_TAB_LAYERFILES));
03910         HideGadget(_R(IDC_OPTIONSTAB_CHECK1), FALSE);
03911         HideGadget(_R(IDC_OPTIONSTAB_CHECK2), FALSE);
03912         HideGadget(_R(IDC_OPTIONSTAB_CHECK3), FALSE);
03913         SetLongGadgetValue(_R(IDC_OPTIONSTAB_CHECK1), ((MaskedFilterExportOptions*) m_pExportOptions)->WantInterlaced());
03914         SetLongGadgetValue(_R(IDC_OPTIONSTAB_CHECK2), m_pExportOptions->IsBackgroundTransparent());
03915         SetLongGadgetValue(_R(IDC_OPTIONSTAB_CHECK3), m_pExportOptions->GetSeparateLayerFiles());
03916     }
03917 
03918 }
03919 
03920 void BmapPrevDlg::HandleBitmapOptionsTicks(UINT32 tick)
03921 {
03922     BOOL NewState = GetLongGadgetValue(tick,0,1);
03923 
03924     UINT32  idFilterName = m_pExportOptions->GetFilterNameStrID();
03925 
03926     if( idFilterName == _R(IDS_JPG_EXP_FILTERNAME) )
03927     {
03928         if (tick == _R(IDC_OPTIONSTAB_CHECK1))
03929             ((JPEGExportOptions*) m_pExportOptions)->SetMakeProgressive(NewState);
03930     }
03931     else
03932     if( idFilterName == _R(IDT_FILTERNAME_BMP) ) 
03933     {
03934         // Do nothing
03935     }
03936     else
03937     {
03938         if (tick == _R(IDC_OPTIONSTAB_CHECK1))
03939             ((MaskedFilterExportOptions*) m_pExportOptions)->SetMakeInterlaced(NewState);
03940         else if (tick == _R(IDC_OPTIONSTAB_CHECK2))
03941             m_pExportOptions->SetBackgroundTransparency(NewState);
03942         else if (tick == _R(IDC_OPTIONSTAB_CHECK3))
03943             m_pExportOptions->SetSeparateLayerFiles(NewState);
03944     }
03945 
03946     // show the controls as they now are
03947     InitBitmapOptionsTab();
03948     // reset the preview button
03949     SetPreviewButtonState(true);
03950 }
03951 
03952 // //////////////////////////////////////////////////////////////////////////////////////// //
03953 // //////////////////////////////////////////////////////////////////////////////////////// //
03954 // Utility functions                                                                        //
03955 // //////////////////////////////////////////////////////////////////////////////////////// //
03956 // //////////////////////////////////////////////////////////////////////////////////////// //
03957 /*
03958 BOOL BmapPrevDlg::DeleteItemFromDropList( INT32 ListID, INT32 ItemID )
03959 {
03960     //  Look for the item in the list
03961     INT32 Position = GetPositionOfItemInDropList( ListID, ItemID );
03962     //  If found, then remove it from the list
03963     if( Position >= 0 )
03964     {
03965         DeleteValue( ListID, FALSE, Position );
03966         return TRUE;
03967     }
03968     return FALSE;   //  It didn't work
03969 }
03970 */
03971 BOOL BmapPrevDlg::SetSelectedDropListItem( INT32 ListID, INT32 ItemID )
03972 {
03973     //  Is ItemID in the drop list ListID
03974     INT32 Position = GetPositionOfItemInDropList( ListID, ItemID );
03975     //  If we have found it, the select it
03976     if( Position >= 0 )
03977     {
03978         SetSelectedValueIndex( ListID, Position );
03979         return TRUE;
03980     }
03981     return FALSE;   //  It didn't work
03982 }
03983 
03984 INT32 BmapPrevDlg::GetPositionOfItemInDropList( INT32 ListID, INT32 ItemID )
03985 {
03986     //  A few variables.
03987     String_256 ListItemString = "";
03988     INT32 Index = -1;
03989     INT32 NumberOfListItems = 0;
03990     //  Get the number of entries in the list
03991     GetValueCount( ListID, &NumberOfListItems );
03992     //  Go through all the entries, and see if you can find the one which matches.
03993     for( INT32 i = 0; i < NumberOfListItems; i++ )
03994     {
03995         //  Get the string at the specified index.
03996         ListItemString = GetStringGadgetValue( ListID, NULL, i );
03997         //  If this item is the one we want, then return its index now.
03998         if( ListItemString.IsIdentical( String_256( ItemID ) ) )
03999             return i;
04000     }
04001     //  We haven't found the item, so return -1 to say this.
04002     return Index;
04003 }
04004 
04005 // locked colours and edited colours need to store their pre-edited colour
04006 // so that the renderer knows where the original colour would have been before
04007 // the user changed it. see.
04008 // this fn Sets the pre-edited colour of the index to match the existing colour
04009 // or to match the params passed in if any were
04010 // sjk (22/12/00)
04011 void BmapPrevDlg::SetPreEditedPaletteColour(INT32 r, INT32 g, INT32 b)
04012 {
04013 PORTNOTETRACE("other","BmapPrevDlg::SetPreEditedPaletteColour - Do nothing");
04014 #ifndef EXCLUDE_FROM_XARALX
04015     // set the preedited colour to match the edited colour
04016     ExtendedPalette *palette = m_pExportOptions->GetExtendedPalette();
04017     if (palette == NULL)
04018         return;
04019 
04020     INT32 index = m_PaletteControl.GetSelectedColour();
04021     if (index <0 || index >= palette->NumberOfColours)
04022         return;
04023 
04024     // if this value has been edited before (set to something from the default black)
04025     // - dont do it again since it means it has just
04026     // been edited twice and the original is still the original
04027     if (palette->Data[index].PreEditedRed != 0 || palette->Data[index].PreEditedGreen != 0 || palette->Data[index].PreEditedBlue != 0)
04028         return;
04029 
04030     palette->Data[index].PreEditedRed = (r == -1 ? palette->Data[index].Red : r);
04031     palette->Data[index].PreEditedGreen = (g == -1 ? palette->Data[index].Green : g);
04032     palette->Data[index].PreEditedBlue = (b == -1 ? palette->Data[index].Blue : b);
04033 #endif
04034 }

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