#include <fimagdlg.h>
Inheritance diagram for ImagemapDlg:
Public Member Functions | |
ImagemapDlg () | |
Default constructor. | |
void | DoWithParam (OpDescriptor *, OpParam *Param) |
Creates then opens the dialog in response to a request from the user and allows values to be passed in and returned to the caller via the ImagemapDlgParam class. | |
void | Do (OpDescriptor *) |
Creates then opens the dialog in response to a request from the user. | |
virtual MsgResult | Message (Msg *Message) |
Handles all messages. | |
Static Public Member Functions | |
static BOOL | Init () |
ImagemapDlg Init method. | |
static BOOL | InvokeDialog (ImagemapFilterOptions *pifoDefault, List *plstNames=NULL) |
Starts up the Imagemap Export Options dialog box. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
ImagemapDlg GetState method. | |
Static Public Attributes | |
static CDlgResID | IDD = _R(IDD_EXPORT_IMAGEMAP) |
static const CDlgMode | Mode = MODAL |
Protected Member Functions | |
void | OnCreate () |
Handles a message that the dialog has just been created. | |
void | OnCommit () |
Handles a message that the "Export" button has been clicked. | |
void | OnAreaSelectionClicked () |
Handles a message that the "Area for imagemap - Selection" button has been clicked. | |
void | OnAreaDrawingClicked () |
Handles a message that the "Area for imagemap - Drawing" button has been clicked. | |
void | OnWidthChanged () |
Handles a message that the user has typed in the "Width" field. | |
void | OnHeightChanged () |
Handles a message that the user has typed in the "Height" field. | |
void | SetOptions (ImagemapFilterOptions ifoSet) |
Sets some ImagemapFilterOptions into the dialog. | |
ImagemapFilterOptions | GetOptions () |
Gets a set of imagemap filter options from the dialog. | |
void | SetDPI (SelectionType stExportArea, double dDPI) |
Sets the Width and Height fields according to the DPI and the Export Area. | |
double | GetDPI (SelectionType stExportArea) |
Gets the DPI as shown in the dialog box by the Width and Height fields. | |
void | SetMemberVariables (ImagemapFilterOptions ifoOptions) |
Sets up our internal member variables based on the contents of ifoOptions. | |
Protected Attributes | |
double | m_dWidthHeightRatio |
Static Protected Attributes | |
static ImagemapFilterOptions | ms_Options = ImagemapFilterOptions() |
static List * | ms_plstNames = NULL |
static BOOL | DontHandleNextMessage = FALSE |
static BOOL | DialogWasCancelled = FALSE |
Definition at line 126 of file fimagdlg.h.
|
Default constructor.
Definition at line 198 of file fimagdlg.cpp. 00198 : DialogOp(ImagemapDlg::IDD, ImagemapDlg::Mode) 00199 { 00200 00201 }
|
|
Creates then opens the dialog in response to a request from the user.
Reimplemented from Operation. Definition at line 922 of file fimagdlg.cpp. 00923 { 00924 BOOL ok; 00925 00926 // Force the dialog box to be created, as it is modal it will be opened via a message 00927 ok = Create(); 00928 00929 if ( !ok ) 00930 { 00931 // Could not create the dialog box so call inform error 00932 InformError(); 00933 End(); 00934 } 00935 }
|
|
Creates then opens the dialog in response to a request from the user and allows values to be passed in and returned to the caller via the ImagemapDlgParam class.
Reimplemented from Operation. Definition at line 954 of file fimagdlg.cpp. 00955 { 00956 BOOL ok; 00957 00958 // Force the dialog box to be created, as it is modal it will be opened via a message 00959 ok = Create(); 00960 00961 if ( !ok ) 00962 { 00963 // Could not create the dialog box so call inform error 00964 InformError(); 00965 End(); // End the operation 00966 } 00967 }
|
|
Gets the DPI as shown in the dialog box by the Width and Height fields. double ImagemapDlg::GetDPI(SelectionType stExportArea)
Definition at line 778 of file fimagdlg.cpp. 00779 { 00780 //This variable will hold the value to return 00781 //It is 96 by default 00782 double dDPI=BMPFilter::GetDefaultExportDPI(); 00783 00784 //First we need to get the bounding box of the area to export 00785 DocRect rectBounds=ImagemapFilterOptions::GetSizeOfExportArea(stExportArea); 00786 00787 //So, get the width of the area to export in millipoints 00788 INT32 lMillipointWidth=rectBounds.Width(); 00789 00790 //Now get the value of the width fields, which will be 00791 //the width of the area to export in pixels 00792 INT32 lPixelWidth=GetLongGadgetValue(_R(IDC_IMAGEMAP_WIDTH), rectBounds.Width(), -INT32_MAX, INT32_MAX); 00793 00794 //Is the width in pixels greater than zero? 00795 if (lPixelWidth>0) 00796 { 00797 //Yes. So get the DPI from the ratio between the pixel height and the pixel width, 00798 //rounded upwards 00799 dDPI=((double) lPixelWidth * 72000.0)/((double) lMillipointWidth); 00800 00801 //Is that DPI within reasonable bounds? 00802 if (dDPI<0) 00803 dDPI=BMPFilter::GetDefaultExportDPI(); 00804 00805 } 00806 00807 //And return that value 00808 return dDPI; 00809 }
|
|
Gets a set of imagemap filter options from the dialog. ImagemapFilterOptions ImagemapDlg::GetOptions()
Definition at line 671 of file fimagdlg.cpp. 00672 { 00673 //This variable will hold the imagemap filter options to return. Base these options 00674 //on the options we were given 00675 ImagemapFilterOptions ifoGet=ms_Options; 00676 00677 //Get the map name 00678 ifoGet.m_strName=GetStringGadgetValue(_R(IDC_IMAGEMAP_MAPNAME)); 00679 00680 //Get the "Approximate curves with lines" drop down box 00681 switch (GetSelectedValueIndex(_R(IDC_IMAGEMAP_APPROX))) 00682 { 00683 case 0: 00684 ifoGet.m_ffApprox=FF_VERYCLOSELY; 00685 break; 00686 00687 case 1: 00688 ifoGet.m_ffApprox=FF_CLOSELY; 00689 break; 00690 00691 case 2: 00692 ifoGet.m_ffApprox=FF_APPROXIMATELY; 00693 break; 00694 00695 default: 00696 ERROR3("ImagemapDlg::GetOptions - invalid flattening factor"); 00697 00698 case 3: 00699 ifoGet.m_ffApprox=FF_NOTATALL; 00700 break; 00701 00702 } 00703 00704 //Get the Area For Imagemap radio buttons 00705 if (GetLongGadgetValue(_R(IDC_IMAGEMAP_AREA_SELECTION), 0, 1)==1) 00706 ifoGet.m_stExportArea=SELECTION; 00707 else 00708 ifoGet.m_stExportArea=DRAWING; 00709 00710 //Get the DPI from the Width and Height and the Area For Imagemap 00711 ifoGet.m_dDPI=GetDPI(ifoGet.m_stExportArea); 00712 00713 //Get the "save clickable areas as rectangles" 00714 ifoGet.m_fAllRectangles=(GetLongGadgetValue(_R(IDC_IMAGEMAP_ALLRECTANGLES), 0, 1)==1); 00715 00716 //Get the "copy imagemap to clipboard" 00717 ifoGet.m_fClipboard=(GetLongGadgetValue(_R(IDC_IMAGEMAP_CLIPBOARD), 0 ,1)==1); 00718 00719 //And return our new set of imagemap options 00720 return ifoGet; 00721 }
|
|
ImagemapDlg GetState method.
Definition at line 863 of file fimagdlg.cpp. 00864 { 00865 OpState OpSt; 00866 return(OpSt); 00867 }
|
|
ImagemapDlg Init method.
Reimplemented from SimpleCCObject. Definition at line 887 of file fimagdlg.cpp. 00888 { 00889 BOOL InitOK; 00890 00891 InitOK = RegisterOpDescriptor( 00892 0, /* Tool ID */ 00893 _R(IDS_IMAGEMAPDLG), 00894 CC_RUNTIME_CLASS(ImagemapDlg), 00895 OPTOKEN_IMAGEMAPDLG, 00896 GetState, 00897 _R(IDH_Dialog_Image_Map_Export_Options), /* help ID */ 00898 0, /* bubble help */ 00899 0, /* resource ID */ 00900 0 /* control ID */ 00901 ); 00902 00903 return (InitOK); 00904 }
|
|
Starts up the Imagemap Export Options dialog box.
Definition at line 159 of file fimagdlg.cpp. 00160 { 00161 // Make a local copy of the options 00162 ms_Options=*pifoDefault; 00163 ms_plstNames=plstNames; 00164 00165 //Say that the dialog wasn't cancelled 00166 DialogWasCancelled=FALSE; 00167 00168 //Find the dialog's op descriptor 00169 OpDescriptor *OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(ImagemapDlg)); 00170 00171 //And start up the dialog 00172 if (OpDesc != NULL) 00173 OpDesc->Invoke(); 00174 00175 //And return the options we've got back 00176 *pifoDefault=ms_Options; 00177 00178 return !DialogWasCancelled; 00179 }
|
|
Handles all messages.
Reimplemented from DialogOp. Definition at line 223 of file fimagdlg.cpp. 00224 { 00225 //If the message came from within our dialog 00226 if (IS_OUR_DIALOG_MSG(Message)) 00227 { 00228 //Then cast it into a dialog message and handle it 00229 DialogMsg* Msg = (DialogMsg*)Message; 00230 00231 //If this flag gets set, we should close the dialog 00232 BOOL EndDialog = FALSE; 00233 00234 //Now pass the message to a message handling function 00235 switch (Msg->DlgMsg) 00236 { 00237 case DIM_CREATE: 00238 OnCreate(); 00239 break; 00240 00241 case DIM_COMMIT: 00242 OnCommit(); 00243 EndDialog=TRUE; 00244 break; 00245 00246 case DIM_CANCEL: 00247 DialogWasCancelled=TRUE; 00248 EndDialog = TRUE; 00249 break; 00250 00251 case DIM_LFT_BN_CLICKED: 00252 // A control on the dialog box has been clicked... 00253 switch (Msg->GadgetID) 00254 { 00255 case _R(IDC_IMAGEMAP_AREA_SELECTION): 00256 OnAreaSelectionClicked(); 00257 break; 00258 00259 case _R(IDC_IMAGEMAP_AREA_DRAWING): 00260 OnAreaDrawingClicked(); 00261 break; 00262 } 00263 break; 00264 00265 case DIM_TEXT_CHANGED: 00266 // The user has typed in an edit field 00267 switch (Msg->GadgetID) 00268 { 00269 case _R(IDC_IMAGEMAP_WIDTH): 00270 if (ImagemapDlg::DontHandleNextMessage) 00271 ImagemapDlg::DontHandleNextMessage=FALSE; 00272 else 00273 OnWidthChanged(); 00274 break; 00275 00276 case _R(IDC_IMAGEMAP_HEIGHT): 00277 if (ImagemapDlg::DontHandleNextMessage) 00278 ImagemapDlg::DontHandleNextMessage=FALSE; 00279 else 00280 OnHeightChanged(); 00281 break; 00282 } 00283 break; 00284 00285 } 00286 00287 //And end the dialog if necessary 00288 if (EndDialog) 00289 { 00290 Close(); 00291 End(); 00292 } 00293 } 00294 00295 //Now pass the message down to the base class 00296 return DialogOp::Message(Message); 00297 }
|
|
Handles a message that the "Area for imagemap - Drawing" button has been clicked. void ImagemapDlg::OnAreaDrawingClicked()
Definition at line 410 of file fimagdlg.cpp. 00411 { 00412 //Make sure the "Area for imagemap - Selection" button is off 00413 SetLongGadgetValue(_R(IDC_IMAGEMAP_AREA_SELECTION), FALSE); 00414 00415 //And set the width and height fields to reflect the width 00416 //and height of the drawing scaled by 96 DPI 00417 SetDPI(DRAWING, BMPFilter::GetDefaultExportDPI()); 00418 }
|
|
Handles a message that the "Area for imagemap - Selection" button has been clicked. void ImagemapDlg::OnAreaSelectionClicked()
Definition at line 382 of file fimagdlg.cpp. 00383 { 00384 //Make sure the "Area for imagemap - Drawing" button is off 00385 SetLongGadgetValue(_R(IDC_IMAGEMAP_AREA_DRAWING), FALSE); 00386 00387 //And set the width and height fields to reflect the width 00388 //and height of the selection scaled by 96 DPI 00389 SetDPI(SELECTION, BMPFilter::GetDefaultExportDPI()); 00390 }
|
|
Handles a message that the "Export" button has been clicked.
Definition at line 357 of file fimagdlg.cpp. 00358 { 00359 //Get the values from the dialog box and 00360 //put them into our ImagemapFilterOptions member variable 00361 ms_Options=GetOptions(); 00362 }
|
|
Handles a message that the dialog has just been created.
Definition at line 328 of file fimagdlg.cpp. 00329 { 00330 //Set up the controls from our ImagemapFilterOptions member variables 00331 SetOptions(ms_Options); 00332 00333 //Set up our internal member variables 00334 SetMemberVariables(ms_Options); 00335 00336 //And put the keyboard focus in the Map Name field 00337 SetKeyboardFocus(_R(IDC_IMAGEMAP_MAPNAME)); 00338 }
|
|
Handles a message that the user has typed in the "Height" field. void ImagemapDlg::OnHeightChanged()
Definition at line 481 of file fimagdlg.cpp. 00482 { 00483 //First we set up a flag to find if the value in the Height field 00484 //is a valid value 00485 BOOL fValid=TRUE; 00486 00487 //Get the value of the height field and find out the value 00488 //is between 1 and our maximum pixel width 00489 INT32 lHeight = GetLongGadgetValue(_R(IDC_IMAGEMAP_HEIGHT), 1, PIXELWIDTH_MAX, NULL ,&fValid); 00490 00491 //Set the width to zero by default 00492 INT32 lWidth=0; 00493 00494 //If the height is valid... 00495 if (fValid) 00496 { 00497 //Then get the width by multiplying our height by the width height 00498 //ratio, rounding to the nearest integer 00499 lWidth=(INT32) ((lHeight*m_dWidthHeightRatio)+0.5); 00500 } 00501 00502 //And set our width into the dialog 00503 ImagemapDlg::DontHandleNextMessage=TRUE; 00504 SetLongGadgetValue(_R(IDC_IMAGEMAP_WIDTH), lWidth); 00505 }
|
|
Handles a message that the user has typed in the "Width" field. void ImagemapDlg::OnWidthChanged()
Definition at line 437 of file fimagdlg.cpp. 00438 { 00439 //First we set up a flag to find if the value in the Width field 00440 //is a valid value 00441 BOOL fValid=TRUE; 00442 00443 //Get the value of the width field and find out the value 00444 //is between 1 and the maximum for a INT32 type 00445 INT32 lWidth = GetLongGadgetValue(_R(IDC_IMAGEMAP_WIDTH), 1, PIXELWIDTH_MAX, NULL ,&fValid); 00446 00447 //Set the height to zero by default 00448 INT32 lHeight=0; 00449 00450 //If the width is valid... 00451 if (fValid) 00452 { 00453 //Then get the height by dividing our width by the width height 00454 //ratio, rounding to the nearest integer 00455 lHeight=(INT32) ((lWidth/m_dWidthHeightRatio)+0.5); 00456 } 00457 00458 //And set our height into the dialog 00459 ImagemapDlg::DontHandleNextMessage=TRUE; 00460 SetLongGadgetValue(_R(IDC_IMAGEMAP_HEIGHT), lHeight); 00461 00462 }
|
|
Sets the Width and Height fields according to the DPI and the Export Area. void ImagemapDlg::SetDPI(SelectionType stExportArea, double dDPI)
Definition at line 741 of file fimagdlg.cpp. 00742 { 00743 //First we need to get the bounding box of the area to export 00744 DocRect rectBounds=ImagemapFilterOptions::GetSizeOfExportArea(stExportArea); 00745 00746 //And scale it by the DPI we have been given. The easiest 00747 //way to do this is to use this function 00748 Matrix Identity; 00749 WinRect Rect = OSRenderRegion::BitmapDocRectToWin( Identity, rectBounds, dDPI ); 00750 00751 //Then set the result into the width and height fields 00752 ImagemapDlg::DontHandleNextMessage=TRUE; 00753 SetLongGadgetValue(_R(IDC_IMAGEMAP_WIDTH), Rect.Width()); 00754 00755 ImagemapDlg::DontHandleNextMessage=TRUE; 00756 SetLongGadgetValue(_R(IDC_IMAGEMAP_HEIGHT), Rect.Height()); 00757 }
|
|
Sets up our internal member variables based on the contents of ifoOptions. void ImagemapDlg::SetMemberVariables(ImagemapFilterOptions ifoOptions)
Definition at line 833 of file fimagdlg.cpp. 00834 { 00835 //Get the size of the area to export 00836 DocRect rectExportSize=ImagemapFilterOptions::GetSizeOfExportArea(ifoOptions.m_stExportArea); 00837 00838 //Then get the ratio of its width and height 00839 m_dWidthHeightRatio=((double) rectExportSize.Width())/((double) rectExportSize.Height()); 00840 }
|
|
Sets some ImagemapFilterOptions into the dialog. void ImagemapDlg::SetOptions(ImagemapFilterOptions ifoSet)
Definition at line 531 of file fimagdlg.cpp. 00532 { 00533 //First let's set the options which we should get from ifoSet. 00534 //These are the controls which remember the values which the user set 00535 //for the last export. 00536 00537 //Set the "save clickable areas as rectangles" 00538 SetLongGadgetValue(_R(IDC_IMAGEMAP_ALLRECTANGLES), ifoSet.m_fAllRectangles); 00539 00540 //Set the "copy imagemap to clipboard" 00541 SetLongGadgetValue(_R(IDC_IMAGEMAP_CLIPBOARD), ifoSet.m_fClipboard); 00542 00543 //Set up the "Approximate curves with lines" drop down box 00544 DeleteAllValues(_R(IDC_IMAGEMAP_APPROX)); 00545 00546 SetStringGadgetValue(_R(IDC_IMAGEMAP_APPROX), &String_256(_R(IDS_IMAGEMAP_APPROX_VERYCLOSELY)), FALSE, 0); 00547 SetStringGadgetValue(_R(IDC_IMAGEMAP_APPROX), &String_256(_R(IDS_IMAGEMAP_APPROX_CLOSELY)), FALSE, 1); 00548 SetStringGadgetValue(_R(IDC_IMAGEMAP_APPROX), &String_256(_R(IDS_IMAGEMAP_APPROX_APPROXIMATELY)), FALSE, 2); 00549 SetStringGadgetValue(_R(IDC_IMAGEMAP_APPROX), &String_256(_R(IDS_IMAGEMAP_APPROX_NOTATALL)), FALSE, 3); 00550 00551 SetComboListLength(_R(IDC_IMAGEMAP_APPROX)); 00552 00553 //And choose the appropriate value 00554 switch (ifoSet.m_ffApprox) 00555 { 00556 case FF_VERYCLOSELY: 00557 SetSelectedValueIndex(_R(IDC_IMAGEMAP_APPROX), 0); 00558 break; 00559 00560 case FF_CLOSELY: 00561 SetSelectedValueIndex(_R(IDC_IMAGEMAP_APPROX), 1); 00562 break; 00563 00564 case FF_APPROXIMATELY: 00565 SetSelectedValueIndex(_R(IDC_IMAGEMAP_APPROX), 2); 00566 break; 00567 00568 default: 00569 ERROR3("ImagemapDlg::SetOptions - invalid flattening factor"); 00570 00571 case FF_NOTATALL: 00572 SetSelectedValueIndex(_R(IDC_IMAGEMAP_APPROX), 3); 00573 break; 00574 00575 00576 00577 } 00578 00579 //Now, let's set up the remaining controls with default values. These 00580 //controls do not remember their settings between exports 00581 00582 //The "Map Name" combo box 00583 00584 //First delete all the values that were previously in this box 00585 DeleteAllValues(_R(IDC_IMAGEMAP_MAPNAME)); 00586 00587 //Have we been passed a list of names to put in the combo box? 00588 if (ms_plstNames) 00589 { 00590 //Yes. So go through them, one by one, putting them into the combo box 00591 StringListItem* psliThis=(StringListItem*) ms_plstNames->GetHead(); 00592 00593 INT32 iListPos=0; 00594 00595 while (psliThis!=NULL) 00596 { 00597 String_256 strToSet=psliThis->GetString(); 00598 00599 SetStringGadgetValue(_R(IDC_IMAGEMAP_MAPNAME), &strToSet, FALSE, iListPos); 00600 00601 iListPos++; 00602 00603 psliThis=(StringListItem*) ms_plstNames->GetNext(psliThis); 00604 } 00605 00606 //And select the first item 00607 SetSelectedValueIndex(_R(IDC_IMAGEMAP_MAPNAME),0); 00608 00609 } 00610 else 00611 //No. So simply set a default name into the combo box 00612 SetStringGadgetValue(_R(IDC_IMAGEMAP_MAPNAME), &String_256(_R(IDS_IMAGEMAP_DEFAULTMAPNAME)), FALSE,-1); 00613 00614 00615 00616 SetComboListLength(_R(IDC_IMAGEMAP_MAPNAME)); 00617 00618 //Set the Area For Imagemap radio buttons according to whether there is a selection 00619 //or not 00620 00621 //Is there a selection? 00622 SelRange* pSelRange=GetApplication()->FindSelection(); 00623 00624 if (pSelRange && !pSelRange->IsEmpty()) 00625 { 00626 //Yes. So enable the selection radio button (in case it was disabled before) 00627 EnableGadget(_R(IDC_IMAGEMAP_AREA_SELECTION), TRUE); 00628 00629 //And select it 00630 SetLongGadgetValue(_R(IDC_IMAGEMAP_AREA_SELECTION), TRUE); 00631 SetLongGadgetValue(_R(IDC_IMAGEMAP_AREA_DRAWING), FALSE); 00632 00633 //And set the width and height fields to reflect the width 00634 //and height of the selection scaled by 96 DPI 00635 SetDPI(SELECTION, BMPFilter::GetDefaultExportDPI()); 00636 } 00637 else 00638 { 00639 //No. So disable the selection radio button 00640 EnableGadget(_R(IDC_IMAGEMAP_AREA_SELECTION), FALSE); 00641 00642 //And select the drawing radio button 00643 SetLongGadgetValue(_R(IDC_IMAGEMAP_AREA_SELECTION), FALSE); 00644 SetLongGadgetValue(_R(IDC_IMAGEMAP_AREA_DRAWING), TRUE); 00645 00646 //And set the width and height fields to reflect the width 00647 //and height of the drawing scaled by 96 DPI 00648 SetDPI(DRAWING, BMPFilter::GetDefaultExportDPI()); 00649 00650 } 00651 00652 }
|
|
Definition at line 179 of file fimagdlg.h. |
|
Definition at line 177 of file fimagdlg.h. |
|
Definition at line 184 of file fimagdlg.h. |
|
Definition at line 176 of file fimagdlg.h. |
|
Definition at line 185 of file fimagdlg.h. |
|
Definition at line 173 of file fimagdlg.h. |
|
Definition at line 174 of file fimagdlg.h. |