00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 #include "camtypes.h"
00100
00101 #include "bmapprev.h"
00102
00103
00104
00105
00106 #include "bmpexprw.h"
00107 #include "exjpeg.h"
00108
00109
00110 #include "helpuser.h"
00111
00112
00113 #include "layer.h"
00114 #include "lineattr.h"
00115
00116 #include "page.h"
00117 #include "pngfiltr.h"
00118
00119
00120 #include "fileutil.h"
00121 #include "filtrmgr.h"
00122 #include "filtimag.h"
00123
00124
00125 #include "sgliboil.h"
00126 #include "strlist.h"
00127 #include "statline.h"
00128 #include "aprps.h"
00129
00130 #include "ngprop.h"
00131
00132
00133
00134 #include "gpalopt.h"
00135 #include "osrndrgn.h"
00136
00137
00138
00139
00140
00141
00142 DECLARE_SOURCE("$Revision: 1745 $");
00143
00144 CC_IMPLEMENT_DYNCREATE(BmapPrevDlg, DialogTabOp)
00145
00146 #define new CAM_DEBUG_NEW
00147
00148
00149
00150 const CDlgMode BmapPrevDlg::Mode = MODAL;
00151 const UINT32 BmapPrevDlg::IDD = _R(IDD_BMAPPREVDLG);
00152
00153
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
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;
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
00188 return 0;
00189 }
00190
00191 INT32 BmapPrevDlg::GetTransparentColour(INT32 Index)
00192 {
00193
00194 return 0;
00195 }
00196
00197
00198
00199
00200
00201
00202
00203 OpState BmapPrevDlg::GetState(String_256*, OpDescriptor*)
00204 {
00205 OpState OpSt;
00206 return(OpSt);
00207 }
00208
00209
00210
00211
00212
00213
00214
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
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 BOOL BmapPrevDlg::RegisterYourPagesInOrderPlease()
00243 {
00244 BOOL ok = TRUE;
00245
00246
00247 BOOL bExportABitmap = (m_pExportOptions->GetSelectionType() == ABITMAP);
00248
00249 if (bExportABitmap)
00250 {
00251 ok = ok && AddAPage(_R(IDD_TBITMAPOPTIONS));
00252 }
00253 else
00254 {
00255
00256 AddAPage(_R(IDD_PALETTE_TAB));
00257
00258 if (!m_bSlicingImage)
00259 ok = AddAPage(_R(IDD_TBITMAPSIZE));
00260 }
00261
00262
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
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
00275 if (ok && m_bSlicingImage)
00276 {
00277 ok = AddAPage(_R(IDD_TIMAPOPTIONS));
00278 fUsedImapOption = true;
00279 }
00280
00281
00282
00283 if( ok && fUsedImapOption )
00284 ImageMapOnCreate();
00285 #endif
00286
00287 return (ok);
00288 }
00289
00290
00291
00292
00293
00294
00295
00296
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)
00305 , m_MouseInsidePaletteControl(true)
00306 , m_pBubbleWnd(0)
00307 , m_LastCursorOverControlID(0)
00308 , m_pBubbleTimer(0)
00309 {
00310
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;
00330 }
00331
00332
00333
00334 m_bPopularityValuesWanted = TRUE;
00335
00336 m_LockSizeUpdates = FALSE;
00337
00338
00339
00340 }
00341
00342
00343
00344
00345
00346
00347
00348
00349 BmapPrevDlg::~BmapPrevDlg()
00350 {
00351
00352 PORTNOTE("other","Removed BubbleHelpWnd usage")
00353 #if !defined(EXCLUDE_FROM_XARALX)
00354 delete m_pBubbleWnd;
00355 #endif
00356 delete m_pBubbleTimer;
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
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
00382 SetRegInt(palettesKey, TEXT("Display"), m_ColorModelType);
00383 CloseRegKey(palettesKey);
00384 }
00385 CloseRegKey(optionsKey);
00386 }
00387 #endif
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399 }
00400
00401
00402
00403
00404
00405
00406
00407
00408 void BmapPrevDlg::DoWithParam(OpDescriptor*, OpParam* pParam)
00409 {
00410 BOOL ok = TRUE;
00411
00412 ERROR3IF(pParam == NULL, "pParam = NULL");
00413
00414
00415
00416
00417
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
00427 m_pBmpFilter = (BaseBitmapFilter *)(void*)pParam->Param2;
00428
00429
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
00438 m_FilterType = m_pExportOptions->GetFilterType();
00439
00440
00441 if( m_FilterType == JPEG )
00442 m_bPopularityValuesWanted = FALSE;
00443
00444
00445 m_pPreviewDlg = NULL;
00446 m_DialogWnd = NULL;
00447
00448 m_CurrentPreview = 0;
00449 m_bDpiSupported = TRUE;
00450
00451
00452 m_bIsCreateBitmap = FALSE;
00453
00454
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
00467
00468
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
00483
00484
00485 Filter *pFilter = Filter::GetFirst();
00486 while (pFilter != NULL)
00487 {
00488 if ((pFilter->GetFlags().CanExport) &&
00489 (IS_A(pFilter,PNGFilter)))
00490
00491 break;
00492
00493
00494 pFilter = Filter::GetNext(pFilter);
00495 }
00496
00497
00498 if (pFilter == NULL)
00499 ok = FALSE;
00500
00501
00502 PNGExportOptions *pPNGOptions = new PNGExportOptions(PNG, NULL);
00503 if (pPNGOptions == NULL)
00504 ok = FALSE;
00505 else if (ok)
00506 {
00507
00508 pPNGOptions->CopyFromMasked(pMkBOptions);
00509
00510
00511 if (m_pExportOptions)
00512 delete m_pExportOptions;
00513
00514
00515 m_pExportOptions = pPNGOptions;
00516
00517
00518
00519
00520
00521
00522
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
00535
00536
00537
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);
00550 break;
00551
00552 default:
00553 m_bDpiSupported = FALSE;
00554 break;
00555 }
00556
00557
00558 if (ok)
00559 ok = Create();
00560
00561 if (!ok)
00562 {
00563 m_pExportOptions->MarkInvalid();
00564
00565
00566 m_bClickedOnExport = FALSE;
00567 End();
00568 }
00569 }
00570
00571 void BmapPrevDlg::SetButtonsText()
00572 {
00573 CDlgResID PageID = GetCurrentPageID();
00574 TalkToPage(0);
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
00603 SetStringGadgetValue(_R(ID_APPLY_NOW), _R(IDS_PREVIEW_BUTTON));
00604
00605 TalkToPage(PageID);
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();
00613 TalkToPage(0);
00614 EnableGadget(_R(ID_APPLY_NOW), !m_pExportOptions->DoesTempFileMatchExportOptions() );
00615 TalkToPage(PageID);
00616 }
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632 PORTNOTE("other","Removed Windows style function EnumChildProc")
00633 #ifndef EXCLUDE_FROM_XARALX
00634 BOOL CALLBACK EnumChildProc(wxWindow* hChild, LPARAM lParam )
00635 {
00636
00637 ChildWindowParameters* pParam = (ChildWindowParameters*)lParam;
00638 if (pParam == NULL)
00639 return FALSE;
00640
00641
00642 wxWindow* hParent = (wxWindow*)pParam->FirstID;
00643 if (hParent == NULL)
00644 return FALSE;
00645
00646
00647
00648 if (GetParent(hChild) != hParent)
00649 return TRUE;
00650
00651
00652 if (GetParent(hChild) == (wxWindow*) pParam->SecondID)
00653 return TRUE;
00654
00655
00656
00657
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
00674
00675
00676
00677
00678
00679
00680
00681
00682 BOOL BmapPrevDlg::OnCreate()
00683 {
00684
00685 if ((m_FilterType == JPEG) || (m_pExportOptions->GetSelectionType() != ABITMAP))
00686 {
00687 PORTNOTETRACE("other","Preview section NOT setup");
00688 #ifndef EXCLUDE_FROM_XARALX
00689
00690 wxRect Rect;
00691 GetWindowRect(WindowID, &Rect);
00692 #endif
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718 m_pPreviewDlg = new BitmapExportPreviewDialog(WindowID);
00719 ERROR2IF(m_pPreviewDlg == NULL, FALSE, "No preview dialog!");
00720
00721
00722 m_pPreviewDlg->InitPreviewDialog(this, m_pBmpFilter);
00723
00724
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
00731 WindowID->Enable( TRUE );
00732 }
00733
00734
00735 if (m_FilterType != MAKE_BITMAP_FILTER)
00736 {
00737
00738
00739 String_256 Temp = "";
00740 Temp.Load(m_pExportOptions->GetFilterNameStrID());
00741 Temp += String_256(_R(IDN_EXPORTBMPOPTS));
00742
00743 DialogManager::SetTitlebarName(WindowID, &Temp);
00744 }
00745 else
00746 {
00747
00748 String_256 Temp(_R(IDS_MAKEBMPOPTS));
00749 DialogManager::SetTitlebarName(WindowID, &Temp);
00750 }
00751
00752
00753 SetButtonsText();
00754
00755
00756 if (!m_bDpiSupported)
00757 {
00758
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
00782
00783
00784
00785
00786
00787 void BmapPrevDlg::DoBubbleHelp()
00788 {
00789 PORTNOTE("other","Removed registry usage")
00790 #if !defined(EXCLUDE_FROM_XARALX)
00791
00792 delete m_pBubbleWnd;
00793 #endif
00794 m_pBubbleWnd = 0;
00795
00796
00797 if ( !m_LastCursorOverControlID )
00798 return;
00799
00800
00801 UINT32 bubbleID;
00802
00803
00804 if( m_LastCursorOverControlID == _R(IDC_T2_LOCKED_COLOUR) )
00805 {
00806 bubbleID = _R(IDS_LOCKED_COLOUR);
00807 }
00808 else
00809 if( m_LastCursorOverControlID == _R(IDC_T2_WEB_SAFE_COLOUR) )
00810 {
00811 bubbleID = _R(IDS_WEB_SAFE_COLOUR);
00812 }
00813 else
00814 if( m_LastCursorOverControlID == _R(IDC_T2_TRANSPARENT_COLOUR) )
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) )
00825 {
00826 bubbleID = _R(IDS_DELETE_COLOUR);
00827 }
00828 else
00829 if( m_LastCursorOverControlID == _R(IDC_T2_RESTORE_COLOUR) )
00830 {
00831 bubbleID = _R(IDS_RESTORE_COLOUR);
00832 }
00833 else
00834 if( m_LastCursorOverControlID == _R(IDC_T2_SYSTEM_COLOURS) )
00835 {
00836 bubbleID = _R(IDS_SYSTEM_COLOURS);
00837 }
00838 else
00839 {
00840 m_LastCursorOverControlID = 0;
00841 bubbleID = 0;
00842 }
00843
00844
00845 if (bubbleID == 0)
00846 return;
00847
00848
00849 String_256 bubbleText(bubbleID);
00850
00851 PORTNOTE("other","Removed registry usage")
00852 #if !defined(EXCLUDE_FROM_XARALX)
00853
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
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
00869 if (!m_pBubbleWnd->SetText(bubbleText))
00870 return;
00871
00872
00873 m_pBubbleWnd->Show();
00874 #endif
00875 }
00876
00877 void BmapPrevDlg::PrepareBubbleHelp()
00878 {
00879 if (m_pBubbleTimer)
00880 m_pBubbleTimer->Sample();
00881 else
00882 m_pBubbleTimer = new MonotonicTime;
00883
00884 PORTNOTE("other","Removed registry usage")
00885 #if !defined(EXCLUDE_FROM_XARALX)
00886
00887 delete m_pBubbleWnd;
00888 m_pBubbleWnd = 0;
00889 #endif
00890 }
00891
00892 void BmapPrevDlg::UpdateStatusBar(UINT32 id)
00893 {
00894
00895 UINT32 statusTextID;
00896
00897
00898 if( id == _R(IDC_T2_LOCKED_COLOUR) )
00899 {
00900 statusTextID = _R(IDS_LOCKED_COLOUR_STATUS_TEXT);
00901 }
00902 else
00903 if( id == _R(IDC_T2_WEB_SAFE_COLOUR) )
00904 {
00905 statusTextID = _R(IDS_WEB_SAFE_COLOUR_STATUS_TEXT);
00906 }
00907 else
00908 if( id == _R(IDC_T2_TRANSPARENT_COLOUR) )
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) )
00919 {
00920 statusTextID = _R(IDS_DELETE_COLOUR_STATUS_TEXT);
00921 }
00922 else
00923 if( id == _R(IDC_T2_RESTORE_COLOUR) )
00924 {
00925 statusTextID = _R(IDS_RESTORE_COLOUR_STATUS_TEXT);
00926 }
00927 else
00928 if( id == _R(IDC_T2_SYSTEM_COLOURS) )
00929 {
00930 statusTextID = _R(IDS_SYSTEM_COLOURS_STATUS_TEXT);
00931 }
00932 else
00933 {
00934 statusTextID = _R(IDS_BITMAPPREVIEWDIALOG);
00935 }
00936
00937
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
00949
00950
00951
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
00966
00967
00968
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
00983
00984
00985
00986
00987 void BmapPrevDlg::UpdateCurrentTab()
00988 {
00989 CDlgResID PageID = GetCurrentPageID();
00990 if(PageID == _R(IDD_TBITMAPSIZE) )
00991 {
00992
00993
00994 RefreshBitmapSizeTab();
00995 }
00996 else
00997 if(PageID == _R(IDD_PALETTE_TAB) )
00998 {
00999
01000 RefreshPaletteOptionsTab();
01001 }
01002 else
01003 if(PageID == _R(IDD_TIMAPOPTIONS) )
01004 {
01005
01006
01007 RefreshImageMapTab();
01008 }
01009 else
01010 if(PageID == _R(IDD_TBROWSER) )
01011 {
01012
01013
01014 }
01015 else
01016 if(PageID == _R(IDD_TBITMAPOPTIONS) )
01017 {
01018
01019
01020 InitBitmapOptionsTab();
01021 }
01022 else
01023 {
01024
01025 }
01026 }
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037 BOOL BmapPrevDlg::DoPreview()
01038 {
01039
01040
01041
01042 CDlgResID PageID = GetCurrentPageID();
01043 if (m_pPreviewDlg == NULL)
01044 return FALSE;
01045
01046
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
01056
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
01067 if (m_CurrentPreview == 0)
01068 m_CurrentPreview = 1;
01069
01070
01071
01072
01073 }
01074
01075
01076 SetPreviewButtonState(false);
01077
01078
01079 m_PaletteControl.RenderSoon();
01080
01081
01082 TalkToPage(0);
01083 EnableGadget( wxID_OK, fIsExportEnabled );
01084
01085 TalkToPage(PageID);
01086
01087 return ok;
01088 }
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109 MsgResult BmapPrevDlg::Message( Msg* Message)
01110 {
01111
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;
01121
01122
01123
01124
01125
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
01139 delete m_pBubbleTimer;
01140 m_pBubbleTimer = 0;
01141
01142
01143 DoBubbleHelp();
01144 }
01145 }
01146
01147
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
01166 switch (Msg->DlgMsg)
01167 {
01168 case DIM_CREATE:
01169 {
01170 if (!OnCreate())
01171 {
01172 ERROR3("Problem in OnCreate()");
01173 return FAIL;
01174 }
01175
01176
01177
01178
01179
01180
01181 PORTNOTE("other", "Remove bubble help timer usage" );
01182 #if !defined(EXCLUDE_FROM_XARALX)
01183
01184 SetTimer(BUBBLE_HELP_TIMMER_ID, 100);
01185 #endif
01186 break;
01187 }
01188
01189 case DIM_COMMIT:
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();
01197 break;
01198
01199 case DIM_SOFT_COMMIT:
01200 EndDialog = FALSE;
01201 DoPreview();
01202 BmapPrevDlg::m_bClickedOnExport = FALSE;
01203 break;
01204
01205 case DIM_CANCEL:
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
01213 m_pExportOptions->MarkInvalid();
01214 break;
01215
01216 case DIM_LFT_BN_CLICKED:
01217 case DIM_RGT_BN_CLICKED:
01218
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)
01231 {
01232
01233 if (Msg->DlgMsg == DIM_COMMIT)
01234 {
01235
01236
01237
01238 if (m_FilterType == MAKE_BITMAP_FILTER)
01239 {
01240
01241 if (m_pExportOptions->HasTempFile())
01242 {
01243
01244 PathName Path = m_pExportOptions->GetPathName();
01245
01246
01247 if (Path.IsValid())
01248 FileUtil::DeleteFile(&Path);
01249
01250 m_pExportOptions->SetPathName(NULL);
01251 }
01252 }
01253
01254
01255
01256
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
01271 m_pExportOptions->MarkValid();
01272 }
01273 else
01274 {
01275
01276 if (m_FilterType == JPEG)
01277 {
01278
01279 JPEGExportOptions::SetKernelBitmap(NULL);
01280 }
01281 }
01282
01283
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();
01290 }
01291
01292 return DLG_EAT_IF_HUNGRY(Msg);
01293 }
01294
01295
01296
01297
01298
01299
01300
01301
01302 void BmapPrevDlg::OnHelpButtonClicked()
01303 {
01304
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
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342 void BmapPrevDlg::InitPaletteTab()
01343 {
01344
01345 InitPaletteDitheringList();
01346
01347
01348 InitPalettePaletteList();
01349
01350
01351 InitPaletteColourDepthList();
01352
01353
01354 InitPaletteColourModelList();
01355
01356
01357 InitPaletteButtonStrip();
01358
01359
01360 InitPaletteSortList();
01361 }
01362
01363
01364
01365
01366
01367
01368
01369 void BmapPrevDlg::InitPaletteDitheringList()
01370 {
01371
01372
01373 }
01374
01375
01376
01377
01378
01379
01380
01381
01382 void BmapPrevDlg::InitPalettePaletteList()
01383 {
01384
01385 DeleteAllValues( _R(IDC_PALETTE_COMBO) );
01386
01387
01388
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
01398
01399
01400
01401
01402 void BmapPrevDlg::InitPaletteColourDepthList()
01403 {
01404
01405 }
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416 void BmapPrevDlg::InitPaletteColourModelList()
01417 {
01418
01419 DeleteAllValues(_R(IDC_COLOR_MODEL_LIST));
01420
01421
01422
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
01433
01434
01435
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
01450
01451
01452
01453
01454
01455 void BmapPrevDlg::InitPaletteSortList()
01456 {
01457
01458 DeleteAllValues( _R(IDC_T2_SORT_LIST) );
01459
01460
01461
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
01471
01472
01473
01474
01475
01476 void BmapPrevDlg::HandlePaletteTabMsg(DialogMsg* Msg)
01477 {
01478 CDlgResID PageID = GetCurrentPageID();
01479 TalkToPage(_R(IDD_PALETTE_TAB));
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();
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
01542
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
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
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();
01606 break;
01607 }
01608
01609 case DIM_RGT_BN_UP:
01610 {
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
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
01638
01639
01640
01641
01642
01643 void BmapPrevDlg::HandlePaletteDitheringListChange()
01644 {
01645
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
01666 m_pExportOptions->InvalidatePalette();
01667 }
01668
01669
01670
01671
01672
01673
01674
01675 void BmapPrevDlg::HandlePalettePaletteListChange()
01676 {
01677
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
01699
01700 if (m_pExportOptions->GetDither() == XARADITHER_ORDERED)
01701 {
01702 m_pExportOptions->SetDither(XARADITHER_ERROR_DIFFUSION);
01703 }
01704 }
01705 }
01706
01707
01708
01709
01710
01711
01712
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
01731
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;
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
01755
01756
01757
01758 SetPreEditedPaletteColour();
01759 }
01760 SetPreviewButtonState(true);
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);
01769 }
01770 SetPreviewButtonState(true);
01771 }
01772
01773
01774
01775
01776
01777
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);
01784 }
01785
01786
01787
01788
01789
01790
01791
01792 void BmapPrevDlg::HandlePaletteTransparentColourButtonChange()
01793 {
01794 if (m_PaletteControl.GetSelectedColour() != BitmapExportPaletteControl::INVALID_COLOUR_VALUE)
01795 {
01796
01797 if (m_PaletteControl.SetSelectedColourToggleTransparent())
01798 {
01799
01800 if (m_pExportOptions->IsBackgroundTransparent())
01801 m_pExportOptions->SetBackgroundTransparency(FALSE);
01802 }
01803 m_pExportOptions->SetTempFileMatchesExportOptions(FALSE);
01804 SetPreviewButtonState(true);
01805 }
01806 }
01807
01808
01809
01810
01811
01812
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
01821 SetPreviewButtonState(true);
01822 }
01823
01824
01825
01826
01827
01828
01829
01830
01831
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);
01840 }
01841
01842
01843
01844
01845
01846
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);
01853 }
01854
01855
01856
01857
01858
01859
01860
01861
01862 void BmapPrevDlg::HandlePaletteSortListChange()
01863 {
01864
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
01885 }
01886
01887
01888
01889
01890
01891
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);
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;
01927
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;
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);
01968 if (tt >= 0 && tt < 256)
01969 *pColourWeAreChanging = UINT8(tt + 0.5);
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;
01984
01985 if (id == _R(IDC_RED_EDIT))
01986 {
01987 INT32 t;
01988 camSscanf(str, _T("%u"), &t);
01989 newValue = t;
01990 }
01991 else
01992 {
01993 double t;
01994 camSscanf(str, _T("%lf"), &t);
01995 t *= (float)(255.0 / 100.0);
01996 newValue = UINT8(t + 0.5);
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 }
02027
02028
02029 if ((startR != *pR || startG != *pG || startB != *pB))
02030 {
02031
02032 SetPreEditedPaletteColour(startR, startG, startB);
02033
02034 if (!m_PaletteControl.GetSelectedColourLocked())
02035 m_PaletteControl.SetSelectedColourToggleLocked();
02036
02037
02038 m_pExportOptions->SetTempFileMatchesExportOptions(FALSE);
02039 SetPreviewButtonState(true);
02040 }
02041 }
02042
02043
02044
02045
02046
02047
02048
02049
02050 void BmapPrevDlg::RefreshPaletteOptionsTab()
02051 {
02052
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
02072
02073
02074
02075
02076
02077
02078
02079 void BmapPrevDlg::RefreshPaletteLinkedControls()
02080 {
02081 RefreshPaletteColourModelList();
02082 RefreshPaletteButtonStrip();
02083 RefreshPaletteColoursUsedEdit();
02084 RefreshPaletteColoursEdit();
02085 }
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095
02096 void BmapPrevDlg::RefreshPaletteDitheringList()
02097 {
02098
02099 DeleteAllValues(_R(IDC_DITHERING_COMBO));
02100
02101
02102 SetStringGadgetValue( _R(IDC_DITHERING_COMBO), _R(IDS_DITHER_NONE), FALSE);
02103
02104
02105 DWORD dithers = m_pExportOptions->GetSupportedDithers();
02106
02107
02108 if (!dithers)
02109 {
02110 SetSelectedDropListItem(_R(IDC_DITHERING_COMBO), _R(IDS_DITHER_NONE));
02111 }
02112 else
02113 {
02114
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
02144 EnableGadget(_R(IDC_DITHERING_COMBO), dithers != 0);
02145
02146
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
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
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
02185
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
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
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
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
02242
02243
02244
02245
02246
02247
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:
02258 break;
02259 }
02260
02261 EnableGadget(_R(IDC_COLOR_MODEL_LIST), m_pExportOptions->GetSupportsPalette());
02262 }
02263
02264
02265
02266
02267
02268
02269
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
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];
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);
02334 double p = 100.0 / 255.0;
02335 SetDoubleGadgetValue(_R(IDC_GREEN_EDIT), s * p);
02336 SetDoubleGadgetValue(_R(IDC_BLUE_EDIT), v * p);
02337 break;
02338 }
02339 default:
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
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
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
02382 EnableGadget(_R(IDC_T2_LOCKED_COLOUR), m_pExportOptions->GetSupportsPalette());
02383 SetLongGadgetValue(_R(IDC_T2_LOCKED_COLOUR), m_PaletteControl.GetSelectedColourLocked());
02384
02385
02386 EnableGadget(_R(IDC_T2_WEB_SAFE_COLOUR), m_pExportOptions->GetSupportsPalette());
02387 SetLongGadgetValue(_R(IDC_T2_WEB_SAFE_COLOUR), FALSE);
02388
02389
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
02395 EnableGadget(_R(IDC_T2_DELETE_COLOUR), m_pExportOptions->GetSupportsPalette()
02396 && !m_PaletteControl.GetSelectedColourDeleted());
02397 SetLongGadgetValue(_R(IDC_T2_DELETE_COLOUR), FALSE);
02398
02399
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
02406 EnableGadget(_R(IDC_T2_TRANSPARENT_BACKGROUND), m_pExportOptions->GetSupportsTransparency());
02407 SetLongGadgetValue(_R(IDC_T2_TRANSPARENT_BACKGROUND), m_pExportOptions->IsBackgroundTransparent());
02408
02409
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
02449
02450
02451
02452
02453
02454
02455
02456
02457
02458
02459
02460
02461
02462
02463
02464
02465
02466
02467 void BmapPrevDlg::HandleBitmapSizeTabMsg(DialogMsg* Msg)
02468 {
02469 CDlgResID PageID = GetCurrentPageID();
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
02514
02515
02516
02517
02518
02519
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
02610
02611 if (m_bSlicingImage)
02612 return;
02613
02614 m_LockSizeUpdates = TRUE;
02615
02616
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
02630
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
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
02666 if (m_FilterType == MAKE_BITMAP_FILTER)
02667 {
02668
02669 EnableGadget(_R(IDC_T1RADIO3), FALSE);
02670 EnableGadget(_R(IDC_T1RADIO2), FALSE);
02671 EnableGadget(_R(IDC_T1RADIO1), FALSE);
02672 }
02673 else
02674 {
02675
02676
02677
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
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
02709
02710
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
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
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
02749 ExportObjectSize = pSelection->GetBoundingRect();
02750
02751 pSelection->Range::SetRangeControl(rc);
02752 }
02753 else if (m_pExportOptions->GetSelectionType() == SPREAD)
02754 {
02755
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;
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 ,&valid);
02785 if (valid == FALSE)
02786 return;
02787
02788
02789
02790
02791
02792
02793
02794
02795 if (value == m_pExportOptions->GetDPI())
02796 return;
02797
02798 WinRect Rect = GetExportSize(value);
02799
02800
02801 if (Rect.GetWidth() < 1 || Rect.GetWidth() > BMPEXP_MAXWIDTH)
02802 return;
02803
02804
02805 if (Rect.GetHeight() < 1 || Rect.GetHeight() > BMPEXP_MAXHEIGHT)
02806 return;
02807
02808
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
02817 m_pExportOptions->SetPixelOutputSize(Rect.GetWidth(), Rect.GetHeight());
02818
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
02838 double Resolution = ((double) Width * dpi) / ((double) Rect.GetWidth());
02839 if ((Resolution < BMPEXP_MINDPI) || (Resolution > BMPEXP_MAXDPI))
02840 return;
02841
02842
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
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
02886 double Resolution = ((double) Height * dpi) / ((double) Rect.GetHeight());
02887 if ((Resolution < BMPEXP_MINDPI) || (Resolution > BMPEXP_MAXDPI))
02888 return;
02889
02890
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
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
02937 double newDPI = (sf * 96.0) / 100.0;
02938 if ((newDPI < 5.0) || (newDPI > 3000.0))
02939 return;
02940
02941 m_pExportOptions->SetDPI(newDPI);
02942
02943
02944 InitBitmapSizeDPIList();
02945
02946
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
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
02988
02989 void BmapPrevDlg::RefreshBitmapSizeTab()
02990 {
02991 TRACEUSER( "jlh92", _T("BmapPrevDlg::RefreshBitmapSizeTab") );
02992
02993
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
03028
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
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();
03050 TalkToPage(_R(IDD_TBROWSER));
03051
03052 switch(Msg->DlgMsg)
03053 {
03054 case DIM_CREATE:
03055 {
03056 m_bBrowserPreviewTabCreated = true;
03057
03058
03059
03060
03061
03062
03063
03064
03065
03066
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
03073 SetBoolGadgetSelected(_R(IDC_T5CHECK1), PreviewInBrowserTab::g_InfoInHtmlStub);
03074 SetBoolGadgetSelected(_R(IDC_T5CHECK2), PreviewInBrowserTab::g_Imagemap);
03075
03076
03077 EnableGadget(_R(IDC_BROWSER_PREVIEW), FALSE);
03078
03079 break;
03080 }
03081 case DIM_LFT_BN_CLICKED:
03082 {
03083 if( Msg->GadgetID == _R(IDC_IMMEDIATE_BROWSER_PREVIEW) )
03084 {
03085
03086
03087 if (m_pPreviewDlg)
03088 {
03089
03090 BrowserPreviewOptions BrowserOptions;
03091 BrowserPreviewGetOptions(&BrowserOptions);
03092
03093 BOOL ok = TRUE;
03094
03095
03096
03097
03098 if (ok) m_pPreviewDlg->DoBrowserPreview(BrowserOptions);
03099 }
03100 }
03101 else
03102 if( Msg->GadgetID == _R(IDC_BROWSER_PREVIEW) )
03103 {
03104
03105
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
03123
03124
03125
03126
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
03135 return;
03136 }
03137
03138 TalkToPage(_R(IDD_TBROWSER));
03139
03140
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
03152 BOOL Info = GetLongGadgetValue(_R(IDC_T5CHECK1), FALSE, TRUE, 0);
03153
03154
03155 BOOL Imagemap = GetLongGadgetValue(_R(IDC_T5CHECK2), FALSE, TRUE, 0);
03156
03157
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
03167 ImagemapFilterOptions ifoOptionsToUse=imageMap->GetFilterOptions();
03168
03169
03170 ImageMapGetOptions(&ifoOptionsToUse);
03171
03172
03173
03174 PreviewInBrowserTab::g_Background = Bgr;
03175 PreviewInBrowserTab::g_InfoInHtmlStub = Info;
03176 PreviewInBrowserTab::g_Imagemap = Imagemap;
03177
03178
03179
03180
03181
03182 pBrowserOptions->Set(Bgr, Info, Imagemap, ifoOptionsToUse);
03183 #endif
03184 }
03185
03186
03187
03188
03189
03190
03191 void BmapPrevDlg::HandleImageMapTabMsg(DialogMsg* Msg)
03192 {
03193 CDlgResID PageID = GetCurrentPageID();
03194 TalkToPage(_R(IDD_TIMAPOPTIONS));
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
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
03229
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
03242
03243 BOOL bCurrentState = m_pExportOptions->GetCanUseDesignNotes();
03244
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
03270
03271
03272
03273
03274
03275
03276
03277 void BmapPrevDlg::ImageMapOnCreate()
03278 {
03279
03280 TalkToPage(_R(IDD_TIMAPOPTIONS));
03281
03282
03283
03284
03285 wxString DocName = _T("\\") + Document::GetCurrent()->GetPathName();
03286
03287 PORTNOTE("other","Removed UsesDesignNotes - not defined yet")
03288 BOOL bUsesDesignNotes = false;
03289 BOOL bFileSaved = DocName != _("\\");
03290
03291 SetLongGadgetValue( _R(IDC_IMAPTAB_ADDDESIGNNOTE), m_pExportOptions->GetCanUseDesignNotes() );
03292 if( (bUsesDesignNotes && bFileSaved) )
03293 {
03294
03295
03296
03297
03298
03299
03300
03301
03302 HideGadget( _R(IDC_IMAPTAB_STATIC3), TRUE );
03303 HideGadget( _R(IDC_IMAPTAB_STATIC4), TRUE );
03304 }
03305 else
03306 {
03307
03308
03309
03310
03311 if( !bUsesDesignNotes )
03312 {
03313
03314 HideGadget( _R(IDC_IMAPTAB_STATIC3), FALSE );
03315
03316 HideGadget( _R(IDC_IMAPTAB_STATIC4), TRUE );
03317 }
03318 else
03319 {
03320
03321 HideGadget( _R(IDC_IMAPTAB_STATIC4), FALSE );
03322
03323 HideGadget( _R(IDC_IMAPTAB_STATIC3), TRUE );
03324 }
03325 }
03326
03327 if (m_bSlicingImage)
03328 {
03329
03330
03331
03332
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
03342 EnableGadget( _R(IDC_IMAPTAB_DESIGN_NOTES), TRUE );
03343 EnableGadget( _R(IDC_IMAPTAB_ADDDESIGNNOTE), TRUE );
03344
03345
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
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
03366 ImagemapFilterOptions ifoCurrent = pImagemapFilter->GetFilterOptions();
03367
03368
03369 BOOL fFile=ifoCurrent.ExportToFile();
03370
03371 SetLongGadgetValue(_R(IDC_IMAPTAB_EXPORTTOFILE), fFile);
03372
03373
03374 TalkToPage(_R(IDD_TIMAPOPTIONS));
03375
03376
03377
03378
03379
03380
03381
03382
03383
03384
03385
03386
03387
03388
03389
03390
03391
03392
03393
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
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
03437 DeleteAllValues(_R(IDC_IMAPTAB_MAPNAME));
03438
03439
03440
03441
03442 SetLongGadgetValue(_R(IDC_IMAPTAB_INSERT), ifoCurrent.Insert());
03443 SetLongGadgetValue(_R(IDC_IMAPTAB_REPLACE), !ifoCurrent.Insert());
03444
03445
03446
03447
03448 ImageMapOnFileNameChanged();
03449
03450
03451
03452
03453
03454
03455
03456
03457
03458 {
03459
03460
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
03470 SetLongGadgetValue(_R(IDC_IMAPTAB_RECTANGLES), ifoCurrent.ExportAllRectangles());
03471
03472
03473
03474 ImageMapEnableOptions(fFile || m_ClipBoardUsage == CLIPBOARD_IMAGEMAP);
03475
03476
03477
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
03491
03492
03493
03494
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
03503 return;
03504 }
03505
03506 TalkToPage(_R(IDD_TIMAPOPTIONS));
03507
03508
03509 BOOL fFile = GetLongGadgetValue(_R(IDC_IMAPTAB_EXPORTTOFILE), FALSE, TRUE);
03510 BOOL fClipboard = m_ClipBoardUsage == CLIPBOARD_IMAGEMAP;
03511
03512
03513 pOptions->m_fFile=fFile;
03514 pOptions->m_fClipboard=fClipboard;
03515
03516
03517 if (fFile)
03518 {
03519
03520 pOptions->m_pthFile=GetStringGadgetValue(_R(IDC_IMAPTAB_PATH));
03521
03522
03523 if (SGLibOil::FileExists(&(pOptions->m_pthFile)))
03524 {
03525
03526 pOptions->m_fInsert=GetLongGadgetValue(_R(IDC_IMAPTAB_INSERT), FALSE, TRUE);
03527 }
03528 }
03529
03530
03531 if (fFile || fClipboard)
03532 {
03533
03534
03535
03536
03537 pOptions->m_strName=GetStringGadgetValue(_R(IDC_IMAPTAB_MAPNAME));
03538
03539
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
03564 pOptions->m_fAllRectangles=(GetLongGadgetValue(_R(IDC_IMAPTAB_RECTANGLES), 0, 1)==1);
03565 }
03566 }
03567
03568
03569
03570
03571
03572
03573
03574
03575
03576
03577 void BmapPrevDlg::ImageMapOnCommit()
03578 {
03579 PORTNOTETRACE("other","BmapPrevDlg::ImageMapOnCommit - Do nothing");
03580 #ifndef EXCLUDE_FROM_XARALX
03581
03582
03583 if (!m_bImageMapTabCreated)
03584 return;
03585
03586
03587
03588 if (m_bSlicingImage)
03589 return;
03590
03591
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
03601 ImagemapFilterOptions ifoCurrent=pImagemapFilter->GetFilterOptions();
03602
03603
03604 ImageMapGetOptions(&ifoCurrent);
03605
03606
03607
03608 ifoCurrent.m_fReportErrors = TRUE;
03609
03610
03611 pImagemapFilter->SetFilterOptions(ifoCurrent);
03612
03613
03614
03615
03616
03617
03618
03619
03620
03621
03622
03623
03624
03625
03626
03627
03628 #endif
03629 }
03630
03631
03632
03633
03634
03635
03636
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
03647
03648
03649
03650
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
03662
03663
03664
03665
03666
03667
03668
03669 void BmapPrevDlg::ImageMapOnBrowseClicked()
03670 {
03671 PORTNOTETRACE("other","BmapPrevDlg::ImageMapOnBrowseClicked - Do nothing");
03672 #ifndef EXCLUDE_FROM_XARALX
03673
03674 String_256 strFile=GetStringGadgetValue(_R(IDC_IMAPTAB_PATH));
03675 PathName pthFile(strFile);
03676
03677
03678 const TCHAR* pcBuffer=NULL;
03679
03680
03681 if (pthFile.IsValid())
03682
03683 pcBuffer=strFile;
03684
03685
03686
03687
03688 String_256 strFilters(_R(IDS_IMAPTAB_BROWSEFILTERSTRING));
03689
03690
03691 MFCFileDialog dlgSave(FALSE, "htm", pcBuffer, OFN_HIDEREADONLY, (TCHAR*) strFilters);
03692
03693
03694 dlgSave.DoModal();
03695
03696
03697 String_256 strChosen=dlgSave.GetPathName();
03698
03699
03700 TalkToPage(_R(IDD_TIMAPOPTIONS));
03701
03702
03703 SetStringGadgetValue(_R(IDC_IMAPTAB_PATH), strChosen, FALSE, -1);
03704
03705
03706 ImageMapOnFileNameChanged();
03707 #endif
03708 }
03709
03710
03711
03712
03713
03714
03715
03716
03717
03718
03719
03720
03721
03722 void BmapPrevDlg::ImageMapOnFileNameChanged()
03723 {
03724 PORTNOTETRACE("other","BmapPrevDlg::ImageMapOnFileNameChanged - Do nothing");
03725 #ifndef EXCLUDE_FROM_XARALX
03726
03727 if (!m_bImageMapTabCreated)
03728 return;
03729
03730 TalkToPage(_R(IDD_TIMAPOPTIONS));
03731
03732
03733 String_256 strOpen=GetStringGadgetValue(_R(IDC_IMAPTAB_PATH));
03734
03735 PathName pthOpen;
03736
03737
03738 if (pthOpen.SetPathName(strOpen) && SGLibOil::FileExists(&pthOpen))
03739 {
03740
03741
03742
03743 HideGadget(_R(IDC_IMAPTAB_INSERT), FALSE);
03744 HideGadget(_R(IDC_IMAPTAB_REPLACE), FALSE);
03745
03746
03747
03748
03749 List lstStrings;
03750
03751
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
03763
03764
03765
03766 DeleteAllValues(_R(IDC_IMAPTAB_MAPNAME));
03767
03768
03769 StringListItem* pThisItem=(StringListItem*) lstStrings.GetHead();
03770 INT32 i=0;
03771
03772
03773 while (pThisItem)
03774 {
03775
03776 String_256 strToUse=pThisItem->GetString();
03777
03778 SetStringGadgetValue(_R(IDC_IMAPTAB_MAPNAME), strToUse, FALSE, i);
03779
03780
03781 i++;
03782
03783
03784 pThisItem=(StringListItem*) lstStrings.GetNext(pThisItem);
03785 }
03786
03787
03788 lstStrings.DeleteAll();
03789
03790 SetComboListLength(_R(IDC_IMAPTAB_MAPNAME));
03791
03792
03793
03794 String_256 strDefault=pthOpen.GetFileName(FALSE);
03795 SetStringGadgetValue(_R(IDC_IMAPTAB_MAPNAME), strDefault, FALSE, -1);
03796
03797 }
03798 else
03799 {
03800
03801
03802
03803 HideGadget(_R(IDC_IMAPTAB_INSERT), TRUE);
03804 HideGadget(_R(IDC_IMAPTAB_REPLACE), TRUE);
03805 }
03806 #endif
03807 }
03808
03809
03810
03811
03812
03813
03814
03815 void BmapPrevDlg::HandleBitmapOptionsTabMsg(DialogMsg* Msg)
03816 {
03817 CDlgResID PageID = GetCurrentPageID();
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
03864 void BmapPrevDlg::InitBitmapOptionsTab()
03865 {
03866
03867
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
03903
03904
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
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
03947 InitBitmapOptionsTab();
03948
03949 SetPreviewButtonState(true);
03950 }
03951
03952
03953
03954
03955
03956
03957
03958
03959
03960
03961
03962
03963
03964
03965
03966
03967
03968
03969
03970
03971 BOOL BmapPrevDlg::SetSelectedDropListItem( INT32 ListID, INT32 ItemID )
03972 {
03973
03974 INT32 Position = GetPositionOfItemInDropList( ListID, ItemID );
03975
03976 if( Position >= 0 )
03977 {
03978 SetSelectedValueIndex( ListID, Position );
03979 return TRUE;
03980 }
03981 return FALSE;
03982 }
03983
03984 INT32 BmapPrevDlg::GetPositionOfItemInDropList( INT32 ListID, INT32 ItemID )
03985 {
03986
03987 String_256 ListItemString = "";
03988 INT32 Index = -1;
03989 INT32 NumberOfListItems = 0;
03990
03991 GetValueCount( ListID, &NumberOfListItems );
03992
03993 for( INT32 i = 0; i < NumberOfListItems; i++ )
03994 {
03995
03996 ListItemString = GetStringGadgetValue( ListID, NULL, i );
03997
03998 if( ListItemString.IsIdentical( String_256( ItemID ) ) )
03999 return i;
04000 }
04001
04002 return Index;
04003 }
04004
04005
04006
04007
04008
04009
04010
04011 void BmapPrevDlg::SetPreEditedPaletteColour(INT32 r, INT32 g, INT32 b)
04012 {
04013 PORTNOTETRACE("other","BmapPrevDlg::SetPreEditedPaletteColour - Do nothing");
04014 #ifndef EXCLUDE_FROM_XARALX
04015
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
04025
04026
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 }