WebPrefsDlg Class Reference

#include <webprefs.h>

Inheritance diagram for WebPrefsDlg:

NativePrefsDlg DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 WebPrefsDlg ()
 WebPrefsDlg constructor. Creates a non-undoable operation.
BOOL Create ()
 WebPrefsDlg create method.
virtual MsgResult Message (Msg *Message)
 Handles all the web preferences dialog's messages.
BOOL InvokeDialog (SelectionType *Selection, BOOL *Compression)
BOOL InvokeDialog (WebPrefsDlgParam *pPrefs)

Static Public Member Functions

static BOOL Init ()
 WebPrefsDlg Init method.

Protected Member Functions

virtual BOOL CommitDialogValues (void)
 Takes the values in the dialog box and sets the return values accordingly Called when ok is pressed on the dialog box.
virtual BOOL InitDialog (void)
 Sets initial dialog values.

Private Member Functions

BOOL CheckIfCompatibleBitmaps (Document *pDoc)
 Checks if any of the bitmaps in the specified document are JPEGable.

Detailed Description

Definition at line 130 of file webprefs.h.


Constructor & Destructor Documentation

WebPrefsDlg::WebPrefsDlg  ) 
 

WebPrefsDlg constructor. Creates a non-undoable operation.

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

Errors: -

See also:
-

Definition at line 163 of file webprefs.cpp.

00163                           : NativePrefsDlg ( _R(IDD_EXPORTWEBOPTS) )
00164 {
00165     // The base class takes care of all the business.
00166 }


Member Function Documentation

BOOL WebPrefsDlg::CheckIfCompatibleBitmaps Document pDoc  )  [private]
 

Checks if any of the bitmaps in the specified document are JPEGable.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/8/96
Parameters:
pointer to the document to check [INPUTS]
- [OUTPUTS]
Returns:
TRUE if compatible bitmaps are present, else FALSE

Errors: -

See also:
-

Definition at line 437 of file webprefs.cpp.

00438 {
00439     ERROR2IF(pDoc == NULL,FALSE,"WebPrefsDlg::CheckIfCompatibleBitmaps null pDoc");
00440 
00441     BitmapList* pBitmaps = pDoc->GetBitmapList();
00442 
00443     // The bitmap list contains bitmaps which may not actually be being used,
00444     // so lets find the ones that are really being used ...
00445 
00446     BOOL CompatibleBitmapsFound = FALSE;
00447 
00448     if (pBitmaps)
00449     {
00450         // Go through all the bitmaps in the list 
00451         ListItem *Ptr = pBitmaps->GetHead();
00452         while (Ptr != NULL)
00453         {
00454             KernelBitmap* pBmp = (KernelBitmap*)Ptr;
00455 
00456             if (pBmp->IsUsedInDocument(pDoc))
00457             {
00458                 // If it gets here then you've found a bitmap that is being used in the document
00459                 // Check the colour depth of the bitmap, if its JPEGable then set our flag True
00460                 UINT32 Bpp = pBmp->GetBPP();
00461                 // Check if the bitmap has a transparent colour or masking colour present.
00462                 // If so then we may need to change our saving strategy
00463                 INT32 TransparentColour = -1;
00464                 if (Bpp <= 8)
00465                     pBmp->GetTransparencyIndex(&TransparentColour);
00466                 // See if we have a BitmapSource for the bitmap 
00467                 BitmapSource* pSource = NULL;
00468                 BaseBitmapFilter* pDummyFilter;
00469                 BOOL OriginalSourcePresent = pBmp->GetOriginalSource(&pSource, &pDummyFilter);
00470                 
00471                 // Only JPEGable at present, if 24bpp and 8bpp but not 8bpp with a transparent colour
00472                 if (!OriginalSourcePresent && (Bpp == 24 || (Bpp == 8 && TransparentColour == -1)))
00473                     CompatibleBitmapsFound = TRUE;
00474             }
00475             
00476             Ptr = pBitmaps->GetNext(Ptr);
00477         }
00478     }
00479 
00480     return CompatibleBitmapsFound;
00481 }

BOOL WebPrefsDlg::CommitDialogValues void   )  [protected, virtual]
 

Takes the values in the dialog box and sets the return values accordingly Called when ok is pressed on the dialog box.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/5/96
Parameters:
pointer to the dialogue box [INPUTS]
- [OUTPUTS]
Returns:
True if values in dialog box ok, False otherwise.

Errors: -

See also:
WebPrefsDlg::CommitDialogValues;

Reimplemented from NativePrefsDlg.

Definition at line 184 of file webprefs.cpp.

00185 {
00186     // Ok has been pressed so take the values and set up the static values so that the
00187     // caller can access them
00188 
00189     BOOL Valid = 0; // Flag for validity of value
00190     BOOL State = 0; // Flag for reading the state of gadgets
00191 
00192     // Work out what is currently selected
00193     // Graeme (25/1/00) - Split SetSelType up into SetExportSel and SetViewportSel.
00194     mpParams->SetViewportSel    ( GetExportSelection ( _R(IDC_WEBOPTS_DRAWING)) );  
00195     
00196     // WEBSTER - markn 28/1/97
00197     // Always compress file
00198 #ifndef WEBSTER
00199     BOOL Compression = GetLongGadgetValue(_R(IDC_WEBOPTS_COMPRESS), 0, 1, 0, &Valid);
00200     mpParams->SetCompression(Compression);
00201 #else
00202     mpParams->SetCompression(TRUE);  
00203 #endif // WEBSTER
00204 
00205     // Switch is Remove preview bitmap and so logic is reversed
00206     BOOL ExportPreviewBitmap = !GetLongGadgetValue(_R(IDC_WEBOPTS_PREVIEWBITMAP), 0, 1, 0, &Valid);
00207     mpParams->SetExportPreviewBitmap(ExportPreviewBitmap);
00208 
00209     BOOL ConvertTextToOutlines = GetLongGadgetValue(_R(IDC_WEBOPTS_TEXTOUTLINES), 0, 1, 0, &Valid);
00210     mpParams->SetConvertTextToOutlines(ConvertTextToOutlines);
00211 
00212     // No need to convert blends to outlines anymore, because the compact renderer can cope with
00213     // them now.  (29 today, and wondering whether I should be spending the last days of my twenties doing this)
00214     mpParams->SetConvertBlendsToOutlines(FALSE);
00215     
00216     // WEBSTER - markn 28/1/97
00217     // Always default to non-minimal format
00218 #ifndef WEBSTER
00219     BOOL MinimalWebFormat = GetLongGadgetValue(_R(IDC_WEBOPTS_MINIMAL), 0, 1, 0, &Valid);
00220     mpParams->SetMinimalWebFormat(MinimalWebFormat);
00221 #else
00222     mpParams->SetMinimalWebFormat(FALSE);
00223 #endif // WEBSTER
00224 
00225     // WEBSTER - markn 28/1/97
00226     // Always default to remove invisible layers
00227 #ifndef WEBSTER
00228     BOOL RemoveInvisibleLayers = GetLongGadgetValue(_R(IDC_WEBOPTS_INVISIBLELAYERS), 0, 1, 0, &Valid);
00229     mpParams->SetRemoveInvisibleLayers(RemoveInvisibleLayers);
00230 #else
00231     mpParams->SetRemoveInvisibleLayers(TRUE);
00232 #endif // WEBSTER
00233 
00234     // WEBSTER - markn 28/1/97
00235     // Always default to DON'T remove unused colours
00236 #ifndef WEBSTER
00237     BOOL RemoveUnusedColours = GetLongGadgetValue(_R(IDC_WEBOPTS_UNUSEDCOLOURS), 0, 1, 0, &Valid);
00238     mpParams->SetRemoveUnusedColours(RemoveUnusedColours);
00239 #else
00240     mpParams->SetRemoveUnusedColours(FALSE);
00241 #endif // WEBSTER
00242 
00243     // Get bitmap compression quality slider value
00244     INT32 Quality = 75;
00245     INT32 SliderState = GetLongGadgetValue(_R(IDC_WEBOPTS_QUALITY), 0, 100, 0, &Valid);
00246     if (Valid)
00247     {
00248         // Get that quality setting
00249         Quality = 100 - SliderState; 
00250     }
00251 
00252     BOOL MinimiseBmpSize = GetLongGadgetValue(_R(IDC_WEBOPTS_MINIMISEBITMAPRES), 0, 1, 0, &Valid);
00253     if (!MinimiseBmpSize)
00254     {
00255         // Set the bitmap compression to a large value to indicate none required.
00256         // Actually add 101 to the quality value so we remember the old value and signify that the
00257         // switch is off
00258         mpParams->SetBmpCompression(Quality + 101);
00259     }
00260     else
00261     {
00262         // return the value on the slider to the caller
00263         mpParams->SetBmpCompression(Quality); 
00264     }
00265 
00266     //Added by Graham 21/5/97
00267     //Get the state of the "Put HTML on clipboard" radio button
00268     //This applies in both Webster and camelot
00269     BOOL PutHTMLOnClipboard = GetLongGadgetValue(_R(IDC_WEBOPTS_HTMLTAG), 0, 1, 0, &Valid);
00270     if (Valid)
00271         mpParams->SetHTMLToClipboard(PutHTMLOnClipboard);
00272 
00273 
00274     return NativePrefsDlg::CommitDialogValues ();
00275 }

BOOL WebPrefsDlg::Create void   )  [virtual]
 

WebPrefsDlg create method.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/5/96
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if successful, else FALSE

Errors: -

See also:
-

Reimplemented from NativePrefsDlg.

Definition at line 416 of file webprefs.cpp.

00417 {                     
00418     // Pass the responsibility to the baseclass.
00419     return NativePrefsDlg::Create ();
00420 }

BOOL WebPrefsDlg::Init void   )  [static]
 

WebPrefsDlg Init method.

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

Errors: -

See also:
-

Reimplemented from NativePrefsDlg.

Definition at line 382 of file webprefs.cpp.

00383 {
00384     BOOL InitOK;
00385 
00386     InitOK = RegisterOpDescriptor(
00387                                 0,                  /* Tool ID */
00388                                 _R(IDS_WEBPREFSDLG),
00389                                 CC_RUNTIME_CLASS(WebPrefsDlg),
00390                                 OPTOKEN_WEBPREFSDLG,
00391                                 GetState,
00392                                 0,                  /* help ID */
00393                                 0,                  /* bubble help */
00394                                 0,                  /* resource ID */
00395                                 0                   /* control ID */
00396                                 );
00397 
00398     return (InitOK);
00399 }

BOOL WebPrefsDlg::InitDialog void   )  [protected, virtual]
 

Sets initial dialog values.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/5/96
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if successful, else FALSE

Errors: -

See also:
-

Reimplemented from NativePrefsDlg.

Definition at line 498 of file webprefs.cpp.

00499 {
00500     ERROR2IF(mpParams == NULL, FALSE, "WebPrefsDlg::InitDialog called after duff initialisation?!");
00501 
00502     // Set up the save spread/selection radio buttons
00503     // Rewritten by Graham 6/8/97
00504 
00505     //First, do we have a selection?
00506     Application * pApp = GetApplication();
00507 
00508     ERROR2IF(pApp == NULL, FALSE,"WebPrefsDlg::InitDialog -  no application!");
00509     
00510     SelRange* pRange = pApp->FindSelection();
00511     
00512     ERROR2IF(pRange == NULL, FALSE,"WebPrefsDlg::InitDialog - no selection range!");
00513     DocRect ClipRect = pRange->GetBoundingRect();
00514     
00515     BOOL fThereIsASelection=!ClipRect.IsEmpty();
00516 
00517     //Now, is there a selection?
00518     if (fThereIsASelection)
00519     {
00520         // Yes. So ungrey both the buttons for selecting the nodes to export.
00521         EnableGadget(_R(IDC_NATIVEOPTS_SELECT), TRUE);
00522         EnableGadget(_R(IDC_NATIVEOPTS_DRAWING), TRUE);
00523 
00524         // Graeme (25-1-00) - and Also the viewport buttons.
00525         EnableGadget(_R(IDC_WEBOPTS_SELECT), TRUE);
00526         EnableGadget(_R(IDC_WEBOPTS_DRAWING), TRUE);
00527 
00528         //Now, which of those buttons should be selected?
00529         switch ( mpParams->GetExportSel () )
00530         {
00531         case SELECTION:
00532             // Choose the export pair of buttons.
00533             SetLongGadgetValue(_R(IDC_NATIVEOPTS_DRAWING), FALSE);
00534             SetLongGadgetValue(_R(IDC_NATIVEOPTS_SELECT), TRUE);
00535             break;
00536 
00537         default:
00538         case DRAWING:
00539             // Choose the export pair of buttons.
00540             SetLongGadgetValue(_R(IDC_NATIVEOPTS_DRAWING), TRUE);
00541             SetLongGadgetValue(_R(IDC_NATIVEOPTS_SELECT), FALSE);
00542             break;
00543         }
00544 
00545         // Graeme (25-1-00) - Repeat for the viewport selection.
00546         switch ( mpParams->GetViewportSel () )
00547         {
00548         case SELECTION:
00549             // Choose the viewport pair of buttons.
00550             SetLongGadgetValue(_R(IDC_WEBOPTS_DRAWING), FALSE);
00551             SetLongGadgetValue(_R(IDC_WEBOPTS_SELECT), TRUE);
00552             break;
00553 
00554         default:
00555         case DRAWING:
00556             // Choose the viewport pair of buttons.
00557             SetLongGadgetValue(_R(IDC_WEBOPTS_DRAWING), TRUE);
00558             SetLongGadgetValue(_R(IDC_WEBOPTS_SELECT), FALSE);
00559             break;
00560         }
00561     }
00562     else
00563     {
00564         //No. So grey the SELECTION button and ungrey
00565         //the DRAWING button
00566         EnableGadget(_R(IDC_NATIVEOPTS_SELECT), FALSE);
00567         EnableGadget(_R(IDC_NATIVEOPTS_DRAWING), TRUE);
00568 
00569         // Graeme (25-1-00) - Added to grey the viewport controls.
00570         EnableGadget(_R(IDC_WEBOPTS_SELECT), FALSE);
00571         EnableGadget(_R(IDC_WEBOPTS_DRAWING), TRUE);
00572 
00573         //And we must select the DRAWING button for the export area controls.
00574         SetLongGadgetValue(_R(IDC_NATIVEOPTS_DRAWING), TRUE);
00575         SetLongGadgetValue(_R(IDC_NATIVEOPTS_SELECT), FALSE);
00576 
00577         // Graeme (25-1-00) - And set the selection for the viewport area.
00578         SetLongGadgetValue(_R(IDC_WEBOPTS_DRAWING), TRUE);
00579         SetLongGadgetValue(_R(IDC_WEBOPTS_SELECT), FALSE);
00580     }
00581 
00582     // Preview bitmap switch is Remove preview bitmap and so is reverse logic
00583     SetLongGadgetValue(_R(IDC_WEBOPTS_PREVIEWBITMAP), !mpParams->GetExportPreviewBitmap());
00584 
00585     SetLongGadgetValue(_R(IDC_WEBOPTS_TEXTOUTLINES), mpParams->GetConvertTextToOutlines());
00586 
00587 #ifndef WEBSTER
00588     // WEBSTER - markn 28/1/97
00589     // Most buttons removed
00590     SetLongGadgetValue(_R(IDC_WEBOPTS_MINIMAL), mpParams->GetMinimalWebFormat());
00591 
00592     SetLongGadgetValue(_R(IDC_WEBOPTS_INVISIBLELAYERS), mpParams->GetRemoveInvisibleLayers());
00593 
00594     SetLongGadgetValue(_R(IDC_WEBOPTS_UNUSEDCOLOURS), mpParams->GetRemoveUnusedColours());
00595 
00596     // These switches are only appropriate if we are not in minimal mode
00597     EnableGadget(_R(IDC_WEBOPTS_INVISIBLELAYERS), !mpParams->GetMinimalWebFormat());
00598     EnableGadget(_R(IDC_WEBOPTS_UNUSEDCOLOURS), !mpParams->GetMinimalWebFormat());
00599 #endif // WEBSTER
00600 
00601     //Graham 21/5/97
00602     //Set the "Put HTML on clipboard switch"
00603     SetLongGadgetValue(_R(IDC_WEBOPTS_HTMLTAG), mpParams->GetHTMLToClipboard());
00604 
00605     // Set up the quality slider and percentage display
00606     INT32 Quality = mpParams->GetBmpCompression();  // Default Quality
00607 
00608     //Graham 8/7/97: If we're in Webster, the default value of the minimise
00609     //bitmap size switch is FALSE. In CorelXARA, it's TRUE.
00610     // This has been removed as it breaks the system. The Quality is what really
00611     // controls this. This means that the user is shown no compression but the quality
00612     // setting means that it will compress! Neville 10/10/97
00613     BOOL MinimiseBmpSize = TRUE;
00614     // If the value is bigger than 100 then minimise bitmap resolution
00615     // is False
00616     if (Quality > 100)
00617     {
00618         // Move the range back down into the 0-100 range
00619         // 101 - 201 means JPEG compression off but this is the old JPEG slider position
00620         Quality -= 101;
00621         // Double checked that we are in the required range
00622         if (Quality < 0 || Quality > 100)
00623             Quality = 100; 
00624         
00625         MinimiseBmpSize = FALSE;
00626     }
00627 
00628     SetLongGadgetValue(_R(IDC_WEBOPTS_MINIMISEBITMAPRES), MinimiseBmpSize);
00629 
00630     // Set the range of the slider control plus a step value of 1
00631     SetGadgetRange(_R(IDC_WEBOPTS_QUALITY), 0, 100, 1);
00632     SetGadgetBitmaps(_R(IDC_WEBOPTS_QUALITY), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
00633     SetLongGadgetValue(_R(IDC_WEBOPTS_QUALITY), 100 - Quality);
00634     
00635     // Set the percentage string
00636     TCHAR Str[32];
00637     String_32 jcf(_R(IDS_PERCENT_FORMAT));
00638     camSprintf(Str, jcf, Quality);
00639     String_32 PercentStr(Str);
00640     SetStringGadgetValue(_R(IDC_WEBOPTS_PERCENT), &PercentStr);
00641 
00642     Document* pDoc = Document::GetSelected();
00643     BOOL CompatibleBitmaps = CheckIfCompatibleBitmaps(pDoc);
00644     if (CompatibleBitmaps)
00645     {
00646         EnableGadget(_R(IDC_WEBOPTS_MINIMISEBITMAPRES), TRUE);
00647     }
00648     else
00649     {
00650         EnableGadget(_R(IDC_WEBOPTS_MINIMISEBITMAPRES), FALSE);
00651         // Force the JPEG slider to be greyed
00652         MinimiseBmpSize = FALSE;
00653     }
00654     
00655     // Grey the slider according to the minimise bitmaps switch
00656     EnableGadget(_R(IDC_WEBOPTS_QUALITY), MinimiseBmpSize);
00657     EnableGadget(_R(IDC_WEBOPTS_PERCENT), MinimiseBmpSize);
00658     EnableGadget(_R(IDC_WEBOPTS_0PERCENT), MinimiseBmpSize);
00659     EnableGadget(_R(IDC_WEBOPTS_100PERCENT), MinimiseBmpSize);
00660 
00661     return TRUE;
00662 }

BOOL WebPrefsDlg::InvokeDialog WebPrefsDlgParam pPrefs  ) 
 

BOOL WebPrefsDlg::InvokeDialog SelectionType Selection,
BOOL *  Compression
 

MsgResult WebPrefsDlg::Message Msg Message  )  [virtual]
 

Handles all the web preferences dialog's messages.

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

Errors: -

See also:
-

Reimplemented from NativePrefsDlg.

Definition at line 293 of file webprefs.cpp.

00294 {
00295     if (IS_OUR_DIALOG_MSG(Message) && mpParams)
00296     {
00297         DialogMsg* Msg = (DialogMsg*)Message;
00298 
00299         // Should now handle the required messages that we respond to
00300         switch (Msg->DlgMsg)
00301         {
00302             case DIM_LFT_BN_CLICKED:
00303                 // A control on the dialog box has been clicked...
00304                 switch (Msg->GadgetID)
00305                 {
00306                     case _R(IDC_WEBOPTS_MINIMISEBITMAPRES):
00307                     {
00308                         BOOL Valid = TRUE;
00309                         BOOL MinimiseBmpSize = GetLongGadgetValue(_R(IDC_WEBOPTS_MINIMISEBITMAPRES), 0, 1, 0, &Valid);
00310 
00311                         // Grey the slider according to the minimise bitmaps switch
00312                         EnableGadget(_R(IDC_WEBOPTS_QUALITY), MinimiseBmpSize);
00313                         EnableGadget(_R(IDC_WEBOPTS_PERCENT), MinimiseBmpSize);
00314                         EnableGadget(_R(IDC_WEBOPTS_0PERCENT), MinimiseBmpSize);
00315                         EnableGadget(_R(IDC_WEBOPTS_100PERCENT), MinimiseBmpSize);
00316                     }
00317                     break;
00318 
00319 // WEBSTER - Graham 8/7/97
00320 // No left button click handing needed for this button
00321 #ifndef WEBSTER
00322 
00323                     case _R(IDC_WEBOPTS_MINIMAL):
00324                     {
00325                         BOOL Valid = TRUE;
00326                         BOOL MinimalWebFormat = GetLongGadgetValue(_R(IDC_WEBOPTS_MINIMAL), 0, 1, 0, &Valid);
00327 
00328                         // These switches are only appropriate if we are not in minimal mode
00329                         EnableGadget(_R(IDC_WEBOPTS_INVISIBLELAYERS), !MinimalWebFormat);
00330                         EnableGadget(_R(IDC_WEBOPTS_UNUSEDCOLOURS), !MinimalWebFormat);
00331                     }
00332                     break;
00333 #endif // WEBSTER
00334                 }
00335 
00336 
00337             break; // DIM_LFT_BN_CLICKED        
00338 
00339             case DIM_SLIDER_POS_CHANGING:
00340                 // special message for the JPEG qualty control
00341                 // Messages to all the controls, handled individually
00342                 switch (Msg->GadgetID)
00343                 {
00344                     case _R(IDC_WEBOPTS_QUALITY):
00345                     {
00346                         // Find the current quality scroller's position
00347                         TCHAR Str[32];
00348                         BOOL Valid;
00349                         INT32 Result = GetLongGadgetValue(_R(IDC_WEBOPTS_QUALITY), 0, 100, 0, &Valid);
00350                         Result = 100 - Result;
00351 
00352                         // Build the Percentage string and set it
00353                         String_32 jcf(_R(IDS_PERCENT_FORMAT));
00354                         wsprintf(Str, jcf, (INT32) Result);
00355                         String_32 PercentStr(Str);
00356                         SetStringGadgetValue(_R(IDC_WEBOPTS_PERCENT), &PercentStr);
00357                     }
00358                     break;
00359                 }
00360             break; // DIM_SLIDER_POS_CHANGING       
00361         }
00362     }
00363 
00364     return NativePrefsDlg::Message(Message); 
00365 }


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