WebAddressDlg Class Reference

The new Web Address dialog. More...

#include <hlinkdlg.h>

Inheritance diagram for WebAddressDlg:

DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 WebAddressDlg ()
 Constructor.
 ~WebAddressDlg ()
 Destructor.
void Do (OpDescriptor *)
 Opens the dialog if it is closed. Closes it if it is open.
void DoWithParam (OpDescriptor *pOp, OpParam *pParam)
 Performs the WebAddressDlg operation.
virtual MsgResult Message (Msg *Message)
 This is the message handler for the WebAddressDlg. It simply takes the message and redirects it to one of our Message Handler functions.

Static Public Member Functions

static BOOL Init ()
 Creates an OpDescriptor for a HotLink Dialog and declares some preferences.
static OpState GetState (String_256 *, OpDescriptor *)
 Returns the OpState of the dialogue operation.

Static Public Attributes

static const UINT32 IDD = _R(IDD_WEBADDRESSDLG)
static const CDlgMode Mode = MODELESS
static BOOL ms_fCorrect = TRUE

Protected Member Functions

BOOL Create ()
 Creates a Web Address dialogue box. Fails if DialogOp::Create fails to create the box.
void OnCreate ()
 Handles a message that the dialog has just been created.
void OnAddButtonClicked ()
 Handles a message that the Add button has been clicked.
void OnRemoveButtonClicked ()
 Handles a message that the Remove button has been clicked.
void OnAutoCorrectClicked ()
 Handles a message that the Auto Correct radio button has been clicked.
void OnDialogChange ()
 Handles a message that something in the dialog has changed.
void OnSelectionChange ()
 Handles a message that there's been a selection change.
void SetDialogInitialState ()
 Sets up the dialog in its initial state.
void SetDialogChangedState ()
 Sets up the dialog once it has been changed.
void SetDialogInitialControls ()
 Sets up the dialog according to what attributes are applied to the selection. The cases are:.
void ApplyWebAddress ()
 Applies the values in the dialog box to the selection.
void RemoveWebAddress ()
 Removes any Web Address which is on the selection (i.e. applies the default Web Address to the selection).
void ShowURL (TCHAR *pcURL=NULL)
 Shows the URL in the dialog box.
void ShowURL (UINT32 uiURL)
 Shows the URL in the dialog box.
String_256 GetURL ()
 Finds the value that the URL field contains.
void ShowCorrect (BOOL fValue=TRUE)
 Shows the AutoCorrect state in the dialog.
BOOL GetCorrect ()
 Finds the state of the AutoCorrect switch.
void ShowFrame (TCHAR *pcFrame=NULL)
 Shows the Frame in the dialog box.
void ShowFrame (UINT32 uiFrame)
 Shows the Frame in the dialog box.
String_256 GetFrame ()
 Finds the value that the Frame combo box contains.
void ShowClickableArea (UINT32 uiArea)
 Shows the clickable area in the dialog box as follows:.
UINT32 GetClickableArea ()
 Gets the clickable area shown in the dialog box.
void EnableAdd (BOOL fValue=TRUE)
 Switches the Add button on or off.
void EnableRemove (BOOL fValue=TRUE)
 Switches the Remove button on or off.
void ShowWebAddressOnSelection (BOOL fValue=TRUE)
 Changes the text on the Add/Change button to Change if there is a Web Address or Add if there isn't.
WebCommonAttributeResult FindCommonWebAttribute (WebAddressAttribute *pwaaReturn=NULL)
 Finds if the selection has a common Web Address attribute.
BOOL SelectionConsistsOfText ()
 To find if the selection is entirely text.

Protected Attributes

BOOL fDialogIsInInitialState

Static Protected Attributes

static WebAddressDlgTheDialog = NULL
static BOOL DontHandleNextTextMessage = FALSE

Private Member Functions

 CC_DECLARE_DYNCREATE (WebAddressDlg)

Detailed Description

The new Web Address dialog.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/8/96 - rewritten by Graham 21/3/97
Note that the WebAddressDlg class does not use the WebAddress class in any way! (I did that to confuse you).

Definition at line 156 of file hlinkdlg.h.


Constructor & Destructor Documentation

WebAddressDlg::WebAddressDlg  ) 
 

Constructor.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> from Alex
Date:
25/3/97

Definition at line 159 of file hlinkdlg.cpp.

00159                              : DialogOp(WebAddressDlg::IDD, WebAddressDlg::Mode) 
00160 {
00161     //Set our member variable pointer so it points at ourself
00162     if (TheDialog == NULL)
00163         TheDialog = this;
00164 }       

WebAddressDlg::~WebAddressDlg  ) 
 

Destructor.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> from Alex
Date:
25/3/97

Definition at line 178 of file hlinkdlg.cpp.

00179 {
00180     //Set our member variable pointer to NULL
00181     if (TheDialog == this)
00182         TheDialog = NULL;
00183 } 


Member Function Documentation

void WebAddressDlg::ApplyWebAddress  )  [protected]
 

Applies the values in the dialog box to the selection.

void WebAddressDlg::ApplyWebAddress()

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

Errors: -

See also:
-

Definition at line 848 of file hlinkdlg.cpp.

00849 {   
00850     //First get the values out of the dialog box
00851     //Note that the function GetFrameComboBoxValue() will compare
00852     //the string in the Frame combo box with the list items.
00853     //If the string is a list item (such as "New window (_blank)")
00854     //the string returned to us will be a short version ("_blank")
00855     String_256 strURL=GetURL();                                                     
00856     
00857     String_256 strFrame=GetFrame();
00858 
00859     BOOL fBounding=(GetClickableArea()==1);
00860 
00861     //Now, create a set of flags which tell us how the Web Address should be corrected
00862     WebCorrectFlags wcfToApply;
00863 
00864     //Since these flags have been created using the default constructor, they
00865     //indicate that the URL should not be corrected at all
00866 
00867     //Now, should we be correcting the URL?
00868     if (ms_fCorrect)
00869     {
00870         //Yes. So set the correction flags to the defaults for this dialog
00871         wcfToApply.SetForWebAddressDialog();
00872     }
00873 
00874     //Now create a Web Address object, which will correct the URL
00875     WebAddress urlToApply(strURL, wcfToApply);
00876 
00877     //And make a new Web Address attribute
00878     AttrWebAddress* pNodeToApply=new AttrWebAddress(urlToApply, fBounding, strFrame);
00879 
00880     //And apply it to the selection
00881     AttributeManager::AttributeSelected((NodeAttribute *) pNodeToApply);
00882 
00883 }

WebAddressDlg::CC_DECLARE_DYNCREATE WebAddressDlg   )  [private]
 

BOOL WebAddressDlg::Create void   )  [protected, virtual]
 

Creates a Web Address dialogue box. Fails if DialogOp::Create fails to create the box.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> after Jason
Date:
25/3/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
FALSE if it fails

Errors: -

See also:
-

Reimplemented from DialogOp.

Definition at line 384 of file hlinkdlg.cpp.

00385 {
00386 
00387     if (TheDialog != this)      // Allow only one instance of this dialogue open at once
00388         return(FALSE);
00389 
00390     if (DialogOp::Create())
00391     { 
00392         return(TRUE);
00393     }
00394 
00395     return(FALSE);
00396 }

void WebAddressDlg::Do OpDescriptor  )  [virtual]
 

Opens the dialog if it is closed. Closes it if it is open.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> after Jason
Date:
25/3/97

Reimplemented from Operation.

Definition at line 350 of file hlinkdlg.cpp.

00351 {
00352     if (TheDialog==NULL || TheDialog==this)
00353     {
00354         if (Create())
00355             Open();
00356         else
00357             End();
00358     }
00359     else
00360     {
00361         TheDialog->Close();
00362         TheDialog->End();   // Kill existing editor
00363 
00364         End();              // Kill ourself
00365     }
00366 }

void WebAddressDlg::DoWithParam OpDescriptor pOp,
OpParam pParam
[virtual]
 

Performs the WebAddressDlg operation.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> after Alex
Date:
25/3/97
Parameters:
OpDescriptor (unused) [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 413 of file hlinkdlg.cpp.

00414 {
00415     Do(pOp);
00416 
00417 }

void WebAddressDlg::EnableAdd BOOL  fValue = TRUE  )  [protected]
 

Switches the Add button on or off.

void WebAddressDlg::EnableAdd(BOOL fValue=TRUE)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
TRUE to allow the user to add the web address [INPUTS] FALSE to prevent the user from adding the Web Address
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1347 of file hlinkdlg.cpp.

01348 {   
01349     EnableGadget(IDOK, fValue);
01350 }

void WebAddressDlg::EnableRemove BOOL  fValue = TRUE  )  [protected]
 

Switches the Remove button on or off.

void WebAddressDlg::EnableRemove(BOOL fValue=TRUE)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
TRUE to allow the user to remove the Web Address [INPUTS] FALSE to prevent the user from removing the Web Address
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1372 of file hlinkdlg.cpp.

01373 {   
01374     EnableGadget(_R(IDC_WEBADDRESS_REMOVE), fValue);
01375 }

WebCommonAttributeResult WebAddressDlg::FindCommonWebAttribute WebAddressAttribute pwaaReturn = NULL  )  [protected]
 

Finds if the selection has a common Web Address attribute.

WebCommonAttributeResult WebAddressDlg::FindCommonWebAttribute(WebAddressAttribute* pwaaReturn)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
- [INPUTS]
pwaaReturn The caller should set this to point at a WebAddressAttribute [OUTPUTS] if they want a copy of the applied attribute returned.
Returns:
WCA_DEFAULT The default WebAddressAttribute is applied to the entire selection
WCA_SINGLE The same or identical WebAddressAttributes are applied to the whole selection

WCA_MANY Different WebAddressAttributes are applied to the selection

WCA_NOSELECTION Nothing is selected

It does this by calling Range::FindCommonAttribute, then if there's a single attribute applied, doing a quick check to see if that attribute is the default attribute of its type.

Returns:
Errors: -
See also:
-

Definition at line 1447 of file hlinkdlg.cpp.

01448 {   
01449     //First we need to get the current selection
01450     SelRange* pSelRange=GetApplication()->FindSelection();
01451 
01452     //If pSelRange doesn't exist, return No Selection
01453     if (!pSelRange)
01454         return WCA_NOSELECTION; 
01455     
01456     //Find the common Web Attribute on the selection
01457     Range::CommonAttribResult carResult;
01458     NodeAttribute* pnaApplied;
01459     
01460     carResult=pSelRange->FindCommonAttribute(CC_RUNTIME_CLASS(AttrWebAddress), &pnaApplied);
01461     
01462     //If this function has returned ATTR_NONE or ATTR_MANY, return our
01463     //analogous value
01464     if (carResult==SelRange::ATTR_NONE)
01465         return WCA_NOSELECTION;
01466 
01467     if (carResult==SelRange::ATTR_MANY)
01468         return WCA_MANY;
01469 
01470     //Otherwise, we know we have one Web Address attribute on the selection.
01471 
01472     //We must find out whether it is the default attribute
01473 
01474     //First extract the attribute value from the node we have found
01475     WebAddressAttribute* pWebAddressAttribute=
01476         (WebAddressAttribute*) pnaApplied->GetAttributeValue();
01477 
01478     WebAddressAttribute waaApplied=*pWebAddressAttribute;
01479 
01480     //And if the user wants this value returned, make a copy of it now
01481     if (pwaaReturn)
01482         *pwaaReturn=waaApplied;
01483 
01484     //And get the default Web Address attribute
01485     WebAddressAttribute waaDefault;
01486     if (AttributeManager::GetDefaultAttribute(ATTR_WEBADDRESS, &waaDefault))
01487     {
01488         //If they are the same, return WCA_DEFAULT. 
01489         //If they are different, return WCA_SINGLE
01490         if (!waaApplied.IsDifferent(&waaDefault))
01491             return WCA_DEFAULT;
01492     }
01493     
01494     return WCA_SINGLE;
01495     
01496 }

UINT32 WebAddressDlg::GetClickableArea  )  [protected]
 

Gets the clickable area shown in the dialog box.

UINT32 WebAddressDlg::GetClickableArea()

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
uiArea A number describing the clickable area: 0 Object shape 1 Rectangle 2 Indeterminate

Errors: -

See also:
-

Definition at line 1313 of file hlinkdlg.cpp.

01314 {   
01315     BOOL fObjectShape=GetLongGadgetValue(_R(IDC_WEBADDRESS_OBJECTSHAPE), 0, 0);
01316     BOOL fRectangle=GetLongGadgetValue(_R(IDC_WEBADDRESS_RECTANGLE), 0, 0);
01317 
01318     if (fObjectShape && !fRectangle)
01319         return 0;
01320 
01321     if (!fObjectShape && fRectangle)
01322         return 1;
01323     
01324     return 2;
01325 }

BOOL WebAddressDlg::GetCorrect  )  [protected]
 

Finds the state of the AutoCorrect switch.

BOOL WebAddressDlg::GetCorrect()

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The state of the AutoCorrect switch

Errors: -

See also:
-

Definition at line 1094 of file hlinkdlg.cpp.

01095 {   
01096     return GetLongGadgetValue(_R(IDC_WEBADDRESS_CORRECT), FALSE, TRUE, 0);
01097 }

String_256 WebAddressDlg::GetFrame  )  [protected]
 

Finds the value that the Frame combo box contains.

String_256 WebAddressDlg::GetFrame()

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The string in the Frame combo box or, if the string in the combo box is one of our preset strings (such as "New window (_blank)"), then we return a shorter version of that string ("_blank").

Errors: -

See also:
-
Technical details:

We could use "GetSelectedValueIndex()" to find if one of our preset strings had been selected.

But consider the case where the user selected one of our present strings, then accidentally clicked in the Frame edit field without changing anythin.

In this case, the selected value (-1) would tell us that the combo box held a value that the user had typed in the edit field...not one of the preset strings.

So, instead, to find if one of our preset strings is in the combo box, we do a direct string comparison.

Definition at line 1232 of file hlinkdlg.cpp.

01233 {   
01234     //Get the string from the combo box
01235     String_256 strCombo=GetStringGadgetValue(_R(IDC_WEBADDRESS_FRAME));
01236 
01237     //Check the string to see if it's one we want to stop
01238     if (strCombo==String_256(_R(IDS_WEBADDRESS_COMBO_SELF)))
01239         return String_256(_R(IDS_WEBADDRESS_SHORT_SELF));
01240 
01241     if (strCombo==String_256(_R(IDS_WEBADDRESS_COMBO_PARENT)))
01242         return String_256(_R(IDS_WEBADDRESS_SHORT_PARENT));
01243 
01244     if (strCombo==String_256(_R(IDS_WEBADDRESS_COMBO_TOP)))
01245         return String_256(_R(IDS_WEBADDRESS_SHORT_TOP));
01246 
01247     if (strCombo==String_256(_R(IDS_WEBADDRESS_COMBO_BLANK)))
01248         return String_256(_R(IDS_WEBADDRESS_SHORT_BLANK));
01249     
01250     if (strCombo==String_256(_R(IDS_WEBADDRESS_COMBO_DEFAULT)))
01251         return String_256(_R(IDS_WEBADDRESS_SHORT_DEFAULT));
01252 
01253     //Otherwise, simply return the string
01254     return strCombo;
01255 
01256 }

OpState WebAddressDlg::GetState String_256 ,
OpDescriptor
[static]
 

Returns the OpState of the dialogue operation.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> after Alex
Date:
25/3/97

Definition at line 287 of file hlinkdlg.cpp.

00288 {
00289     OpState OpSt;
00290 
00291     // Tick the menu while the editor is open
00292     if (TheDialog != NULL)
00293         OpSt.Ticked = TRUE;
00294 
00295     return(OpSt);
00296 }

String_256 WebAddressDlg::GetURL  )  [protected]
 

Finds the value that the URL field contains.

String_256 WebAddressDlg::GetURL()

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The string in the URL field

Errors: -

See also:
-

Definition at line 1042 of file hlinkdlg.cpp.

01043 {   
01044     return GetStringGadgetValue(_R(IDC_WEBADDRESS_URL));
01045 }

BOOL WebAddressDlg::Init void   )  [static]
 

Creates an OpDescriptor for a HotLink Dialog and declares some preferences.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> after Alex
Date:
25/3/97
Returns:
FALSE if it fails (due to lack of memory)

Reimplemented from SimpleCCObject.

Definition at line 311 of file hlinkdlg.cpp.

00312 {
00313     if (Camelot.DeclareSection(TEXT("WebAddressDlg"), 2))
00314         Camelot.DeclarePref(TEXT("WebAddressDlg"), TEXT("Correct"), &ms_fCorrect);
00315     
00316     return (RegisterOpDescriptor(0,                             // Tool ID
00317                                 _R(IDS_WEBADDRESS_DLG),                 // String resouirce ID
00318                                 CC_RUNTIME_CLASS(WebAddressDlg),        // Runtime class
00319                                 OPTOKEN_WEBADDRESSDLG,              // Token string
00320                                 WebAddressDlg::GetState,                // GetState function
00321                                 0,                              // Help ID
00322                                 _R(IDBBL_WEBADDRESS),               // Bubble ID
00323                                 _R(IDD_BARCONTROLSTORE),            // Resource ID
00324                                 _R(IDC_BTN_WEBADDRESSDLG),      // Control ID
00325                                 SYSTEMBAR_UTILITIES,            // Bar ID
00326                                 TRUE,                           // Recieve system messages
00327                                 FALSE,                          // Smart duplicate operation
00328                                 TRUE,                           // Clean operation
00329                                 0,                              // No vertical counterpart
00330                                 NULL,
00331                                 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC)
00332                                 )); 
00333                         
00334 }   

MsgResult WebAddressDlg::Message Msg Message  )  [virtual]
 

This is the message handler for the WebAddressDlg. It simply takes the message and redirects it to one of our Message Handler functions.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/3/97
Parameters:
Message,: The incoming message [INPUTS]
Returns:
DialogOp::Message (Message)

Reimplemented from DialogOp.

Definition at line 199 of file hlinkdlg.cpp.

00200 {
00201     BOOL fEndDialog=FALSE;
00202 
00203     //If the message is a dialog message
00204     if (IS_OUR_DIALOG_MSG(Message))
00205     {
00206         //Then work out what it says
00207         DialogMsg* pDialogMsg = ((DialogMsg*) Message); 
00208     
00209         switch (pDialogMsg->DlgMsg)
00210         {
00211             case DIM_CREATE:
00212                 OnCreate();
00213                 break;
00214 
00215             case DIM_COMMIT:
00216                 OnAddButtonClicked();                   
00217                 break;
00218             
00219             case DIM_CANCEL:    
00220                 fEndDialog = TRUE;
00221                 break;
00222 
00223             case DIM_TEXT_CHANGED:
00224                 //This ensures that, when this code changes some text
00225                 //in an edit field, we don't handle the "text changed" message
00226                 if (WebAddressDlg::DontHandleNextTextMessage)
00227                 {
00228                     WebAddressDlg::DontHandleNextTextMessage=FALSE;
00229                 }
00230                 else
00231                     OnDialogChange();
00232 
00233                 break;
00234                 
00235             case DIM_LFT_BN_CLICKED:
00236                 switch(pDialogMsg->GadgetID)
00237                 {
00238                 case _R(IDC_WEBADDRESS_REMOVE):
00239                     OnRemoveButtonClicked();
00240                     break;
00241 
00242                 case _R(IDC_WEBADDRESS_OBJECTSHAPE):
00243                 case _R(IDC_WEBADDRESS_RECTANGLE):
00244                     OnDialogChange();
00245                     break;
00246 
00247                 case _R(IDC_WEBADDRESS_CORRECT):
00248                     OnAutoCorrectClicked();
00249                     break;
00250                 }
00251                 break;
00252 
00253             
00254                 //NB: This means someone has altered the combo box. It doesn't mean
00255                 //the selection has changed!
00256             case DIM_SELECTION_CHANGED: 
00257                 OnDialogChange();
00258                 break;
00259         }
00260     }
00261     else if (MESSAGE_IS_A(Message, SelChangingMsg))
00262     {
00263         if ( ((SelChangingMsg*)Message)->State == SelChangingMsg::SELECTIONCHANGED )
00264             OnSelectionChange();
00265     }
00266         
00267     if (fEndDialog) 
00268     {   
00269         Close();           
00270         End();
00271     }
00272 
00273 
00274     return DialogOp::Message(Message);
00275 } 

void WebAddressDlg::OnAddButtonClicked  )  [protected]
 

Handles a message that the Add button has been clicked.

void WebAddressDlg::OnAddButtonClicked()

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

Errors: -

See also:
WebAddressDlg::Message()

Definition at line 475 of file hlinkdlg.cpp.

00476 {   
00477     //Apply the current Web Address to the selection
00478     ApplyWebAddress();
00479     
00480     //Set up the dialog in its initial state
00481     SetDialogInitialState();
00482 
00483     //And throw away the keyboard focus
00484     DialogManager::DefaultKeyboardFocus();
00485 }

void WebAddressDlg::OnAutoCorrectClicked  )  [protected]
 

Handles a message that the Auto Correct radio button has been clicked.

void WebAddressDlg::OnAutoCorrectClicked()

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

Errors: -

See also:
WebAddressDlg::Message()

Definition at line 533 of file hlinkdlg.cpp.

00534 {   
00535     //Update our member variable
00536     ms_fCorrect=GetCorrect();
00537 }

void WebAddressDlg::OnCreate  )  [protected]
 

Handles a message that the dialog has just been created.

void WebAddressDlg::OnCreate()

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

Errors: -

See also:
WebAddressDlg::Message()

Definition at line 448 of file hlinkdlg.cpp.

00449 {   
00450     //Set up the dialog in its initial state
00451     SetDialogInitialState();
00452 
00453     //And put the keyboard focus in the URL edit field
00454     SetKeyboardFocus(_R(IDC_WEBADDRESS_URL));
00455     HighlightText(_R(IDC_WEBADDRESS_URL));
00456 }

void WebAddressDlg::OnDialogChange  )  [protected]
 

Handles a message that something in the dialog has changed.

void WebAddressDlg::OnDialogChange()

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
Note that the AutoCorrect switch is independent of the rest of the dialog and so changing that doesn't count as changing the dialog.

Returns:
Errors: -
See also:
WebAddressDlg::Message()

Definition at line 560 of file hlinkdlg.cpp.

00561 {   
00562     //Set the dialog into its changed state
00563     SetDialogChangedState();
00564                             
00565 }

void WebAddressDlg::OnRemoveButtonClicked  )  [protected]
 

Handles a message that the Remove button has been clicked.

void WebAddressDlg::OnRemoveButtonClicked()

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

Errors: -

See also:
WebAddressDlg::Message()

Definition at line 504 of file hlinkdlg.cpp.

00505 {   
00506     //Remove the Web Address from the current selection
00507     RemoveWebAddress();
00508     
00509     //Set up the dialog in its initial state
00510     SetDialogInitialState();
00511 
00512     //And throw away the keyboard focus
00513     DialogManager::DefaultKeyboardFocus();
00514 }

void WebAddressDlg::OnSelectionChange  )  [protected]
 

Handles a message that there's been a selection change.

void WebAddressDlg::OnSelectionChange()

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

Errors: -

See also:
WebAddressDlg::Message()

Definition at line 584 of file hlinkdlg.cpp.

00585 {   
00586     //Put the dialog into its initial state
00587     SetDialogInitialState();
00588                             
00589 }

void WebAddressDlg::RemoveWebAddress  )  [protected]
 

Removes any Web Address which is on the selection (i.e. applies the default Web Address to the selection).

void WebAddressDlg::RemoveWebAddress()

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

Errors: -

See also:
-

Definition at line 903 of file hlinkdlg.cpp.

00904 {       
00905     //Simply get the default Web Address
00906     WebAddressAttribute waaDefault;
00907 
00908     if (AttributeManager::GetDefaultAttribute(ATTR_WEBADDRESS, &waaDefault))
00909     {
00910         //Make it into an AttrWebAddress
00911         AttrWebAddress* pNodeToApply=new AttrWebAddress();
00912         
00913         if (pNodeToApply)
00914         {
00915             pNodeToApply->Value=waaDefault;
00916 
00917             //And apply it to the selection
00918             AttributeManager::AttributeSelected((NodeAttribute *) pNodeToApply);
00919         }
00920     }
00921 
00922 
00923 }

BOOL WebAddressDlg::SelectionConsistsOfText  )  [protected]
 

To find if the selection is entirely text.

BOOL WebAddressDlg::SelectionConsistsOfText()

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/3/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the selection consists entirely of text objects FALSE otherwise

Errors: If there is no selection

See also:
Range::ConsistsOf

Definition at line 1520 of file hlinkdlg.cpp.

01521 {   
01522     //First get the current selection
01523     SelRange* pSelection=GetApplication()->FindSelection();
01524         
01525     //And use the Range::ConsistsOf function to find whether the selection
01526     //is entirely text.
01527 
01528     if (pSelection)
01529         return pSelection->ConsistsOf(CC_RUNTIME_CLASS(BaseTextClass));
01530     else
01531         return FALSE;
01532 }

void WebAddressDlg::SetDialogChangedState  )  [protected]
 

Sets up the dialog once it has been changed.

void WebAddressDlg::SetDialogChangedState()

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
This means:
  • If there is a selection, the ADD/CHANGE button is ungreyed
  • If there is a Web Address on the Selection, the ADD/CHANGE button will read "Change", otherwise it will read "Add"

Returns:
Errors: -
See also:
WebAddressDlg::OnSelectionChange(), WebAddressDlg::OnCreate(), WebAddressDlg::OnAddButtonClicked()

Definition at line 661 of file hlinkdlg.cpp.

00662 {   
00663     
00664     //If the dialog is still in its initial state...
00665     if (fDialogIsInInitialState)
00666     {
00667         //Then we need to change some things
00668 
00669         //First, let's find the state of the Web Address attributes applied to the 
00670         //selection
00671         WebCommonAttributeResult aasApplied=FindCommonWebAttribute();
00672 
00673         //If anything at all is selected
00674         if (aasApplied!=WCA_NOSELECTION)
00675         {
00676             //Then we need to ungrey the Add/Change button
00677             EnableAdd(TRUE);
00678 
00679             //We also need to clear any intermediate values from the dialog
00680 
00681             //If the URL field says <MANY>, clear that field
00682             if (GetURL()==String_256(_R(IDS_WEBADDRESSDLG_MANY)))
00683                 ShowURL();
00684 
00685             //If the Frame field says <MANY>, put "self" into that field
00686             if (GetFrame()==String_256(_R(IDS_WEBADDRESSDLG_MANY)))
00687                 ShowFrame(String_256(_R(IDS_WEBADDRESS_COMBO_SELF)));
00688 
00689             //If the clickable area is indeterminate, show the
00690             //recommended value for the selection in the radio buttons
00691             if (GetClickableArea()==2)
00692                 ShowClickableArea(SelectionConsistsOfText());
00693         }
00694 
00695 
00696 
00697         //If there is no Web Address on the selection, tell the user
00698         //so
00699         if (aasApplied==WCA_DEFAULT)
00700             ShowWebAddressOnSelection(FALSE);
00701                                                 
00702         //If there is any sort of Web Address on the selection, tell the
00703         //user
00704         if (aasApplied==WCA_SINGLE || aasApplied==WCA_MANY)
00705             ShowWebAddressOnSelection(TRUE);
00706         
00707     }
00708 
00709     //The dialog is no longer in its initial state
00710     fDialogIsInInitialState=FALSE;
00711 }

void WebAddressDlg::SetDialogInitialControls  )  [protected]
 

Sets up the dialog according to what attributes are applied to the selection. The cases are:.

void WebAddressDlg::SetDialogInitialControls()

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
If a single attribute is applied, that attribute will be put into the dialog box. The Add button button will be greyed and the Remove button will be active.

If many attributes are applied, the dialog box edit fields will be set to read "<Many>" and both radio buttons will be switched off. The Remove button will be active and the Add button will be inactive.

If nothing is selected, the dialog box edit fields will be cleared and both radio buttons will be switched off. The Add and Remove buttons will both be inactive.

If the default attribute is applied, the dialog box edit fields will be cleared and:

  • if the selection consists only of text, the "rectangle surrounding object" radio button will be selected
  • otherwise, the "object shape" radio button will be selected.

Returns:
Errors: -
See also:
WebAddressDlg::OnSelectionChange(), WebAddressDlg::OnCreate(), WebAddressDlg::OnAddButtonClicked()

Definition at line 754 of file hlinkdlg.cpp.

00755 {   
00756     //First, we want to know what the WebAddressAttribute applied to the selection
00757     //is.
00758 
00759     //This variable will hold that attribute
00760     WebAddressAttribute waaApplied;
00761 
00762     //Then call this function to find the state of the WebAddressAttribute(s)
00763     //applied to the selection
00764     WebCommonAttributeResult aasApplied=FindCommonWebAttribute(&waaApplied);
00765                                  
00766     //Edit field and combo box
00767 
00768     //First set up the combo box list
00769     DeleteAllValues(_R(IDC_WEBADDRESS_FRAME));
00770     
00771     SetStringGadgetValue(_R(IDC_WEBADDRESS_FRAME), _R(IDS_WEBADDRESS_COMBO_SELF), FALSE, 0);
00772     SetStringGadgetValue(_R(IDC_WEBADDRESS_FRAME), _R(IDS_WEBADDRESS_COMBO_PARENT), FALSE, 1);
00773     SetStringGadgetValue(_R(IDC_WEBADDRESS_FRAME), _R(IDS_WEBADDRESS_COMBO_TOP), FALSE, 2);
00774     SetStringGadgetValue(_R(IDC_WEBADDRESS_FRAME), _R(IDS_WEBADDRESS_COMBO_BLANK), FALSE, 3);
00775     SetStringGadgetValue(_R(IDC_WEBADDRESS_FRAME), _R(IDS_WEBADDRESS_COMBO_DEFAULT), FALSE, 4);
00776 
00777     SetComboListLength(_R(IDC_WEBADDRESS_FRAME));
00778 
00779     // If a single attribute is applied or the default attribute
00780     // is applied, set it into the edit fields
00781     if (aasApplied==WCA_SINGLE || aasApplied==WCA_DEFAULT)
00782     {
00783         ShowURL(waaApplied.m_url.GetWebAddress());
00784         ShowFrame(waaApplied.m_pcFrame);
00785     }
00786 
00787     //If many attributes are applied, put <Many> into the edit fields
00788     if (aasApplied==WCA_MANY)
00789     {
00790         ShowURL(String_256(_R(IDS_WEBADDRESSDLG_MANY)));
00791         ShowFrame(String_256(_R(IDS_WEBADDRESSDLG_MANY)));
00792     }
00793 
00794     //If nothing is selected, clear the edit fields
00795     if (aasApplied==WCA_NOSELECTION)
00796     {
00797         ShowURL();
00798         ShowFrame();
00799     }
00800 
00801     //Radio buttons
00802 
00803     //If a single attribute is applied, set the radio buttons accordingly
00804     if (aasApplied==WCA_SINGLE)
00805         ShowClickableArea(waaApplied.m_fBounding); 
00806     
00807     //If many attributes are applied, or if nothing is selected,
00808     //give the radio buttons an indeterminate value
00809     if (aasApplied==WCA_MANY || aasApplied==WCA_NOSELECTION)
00810         ShowClickableArea(2);
00811     
00812     //If the default attribute is applied to the selection...
00813     if (aasApplied==WCA_DEFAULT)
00814         //Then if the selection consists only of text, set the "Rectangle" radio button.
00815         //Otherwise, set the "Object shape" radio button
00816         ShowClickableArea(SelectionConsistsOfText());
00817 
00818     //AutoCorrect switch
00819     ShowCorrect(ms_fCorrect);
00820 
00821     //Buttons
00822 
00823     //Grey the Add/Change button
00824     EnableAdd(FALSE);
00825 
00826     //If one or many attributes are applied to the selection, enable the Remove button.
00827     //Otherwise, grey the Remove button
00828     EnableRemove((aasApplied==WCA_SINGLE || aasApplied==WCA_MANY));
00829 }

void WebAddressDlg::SetDialogInitialState  )  [protected]
 

Sets up the dialog in its initial state.

void WebAddressDlg::SetDialogInitialState()

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
This means: a. Calling another member function to set up the controls so they reflect the Web Address attribute on the selection b. Setting a flag to say that the dialog is in its initial state

Returns:
Errors: -
See also:
WebAddressDlg::OnSelectionChange(), WebAddressDlg::OnCreate(), WebAddressDlg::OnAddButtonClicked()

Definition at line 627 of file hlinkdlg.cpp.

00628 {   
00629     //Set the controls up in their correct initial state
00630     SetDialogInitialControls();
00631 
00632     //And set a flag to say the dialog is in its initial state
00633     fDialogIsInInitialState=TRUE;
00634 
00635 }

void WebAddressDlg::ShowClickableArea UINT32  uiArea  )  [protected]
 

Shows the clickable area in the dialog box as follows:.

void WebAddressDlg::ShowClickableArea(UINT32 uiArea)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
uiArea A number describing the clickable area to show: [INPUTS] 0 Object shape 1 Rectangle 2 Indeterminate
- [OUTPUTS]
Returns:
-
0 Object shape radio button is on, rectangle radio button is off 1 Rectangle radio button is on, object radio button is off 2 Both radio buttons are off

Returns:
Errors: -
See also:
-

Definition at line 1285 of file hlinkdlg.cpp.

01286 {   
01287     SetLongGadgetValue(_R(IDC_WEBADDRESS_OBJECTSHAPE), (uiArea==0));
01288     SetLongGadgetValue(_R(IDC_WEBADDRESS_RECTANGLE), (uiArea==1));
01289 }

void WebAddressDlg::ShowCorrect BOOL  fValue = TRUE  )  [protected]
 

Shows the AutoCorrect state in the dialog.

void WebAddressDlg::ShowCorrect(BOOL fValue)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
fValue - whether to show the correction features as on or off [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1068 of file hlinkdlg.cpp.

01069 {   
01070     //Set the switch
01071     SetLongGadgetValue(_R(IDC_WEBADDRESS_CORRECT), fValue);
01072     
01073 }

void WebAddressDlg::ShowFrame UINT32  uiFrame  )  [protected]
 

Shows the Frame in the dialog box.

void WebAddressDlg::ShowFrame(UINT32 uiFrame)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
uiFrame - resource number of the URL to show [INPUTS]
- [OUTPUTS]
Returns:
TRUE if no problems

Errors: -

See also:
-

Definition at line 1184 of file hlinkdlg.cpp.

01185 {   
01186     //First set a flag to ensure we don't handle the "Text changed" message
01187     //that will occur when we change the edit field.
01188     WebAddressDlg::DontHandleNextTextMessage=TRUE;
01189 
01190     //Simply set the string
01191     SetStringGadgetValue(_R(IDC_WEBADDRESS_FRAME), uiFrame, FALSE, -1);
01192     
01193 }

void WebAddressDlg::ShowFrame TCHAR pcFrame = NULL  )  [protected]
 

Shows the Frame in the dialog box.

void WebAddressDlg::ShowFrame(TCHAR* pcFrame)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
pcFrame - the frame string to show in the field [INPUTS]
- [OUTPUTS]
Returns:
TRUE if no problems
Before showing the string, we check to see if is one of the four short strings (_self, _top, _parent and _blank) that correspond to values in the combo box. If it is, we select the appropriate list item in the combo box instead.

Returns:
Errors: -
See also:
-

Definition at line 1123 of file hlinkdlg.cpp.

01124 {   
01125     //Is pcFrame NULL?
01126     if (pcFrame==NULL)
01127         //Yes. So set a blank string in the frame field
01128         SetStringGadgetValue(_R(IDC_WEBADDRESS_FRAME), &String_256(""), FALSE, -1);
01129     else
01130     {
01131         //No.
01132 
01133         //First put the string into one of Camelot's string classes
01134         String_256 strFrame=pcFrame;
01135 
01136         //And check to see if the string is one of our short strings
01137         //This if/else statement is basically a large switch statement
01138                     
01139         if (strFrame==String_256(_R(IDS_WEBADDRESS_SHORT_SELF)))
01140             SetSelectedValueIndex(_R(IDC_WEBADDRESS_FRAME), 0);
01141 
01142         else if (strFrame==String_256(_R(IDS_WEBADDRESS_SHORT_PARENT)))
01143             SetSelectedValueIndex(_R(IDC_WEBADDRESS_FRAME), 1);
01144 
01145         else if (strFrame==String_256(_R(IDS_WEBADDRESS_SHORT_TOP)))
01146             SetSelectedValueIndex(_R(IDC_WEBADDRESS_FRAME), 2);
01147 
01148         else if (strFrame==String_256(_R(IDS_WEBADDRESS_SHORT_BLANK)))
01149             SetSelectedValueIndex(_R(IDC_WEBADDRESS_FRAME), 3);
01150 
01151         else if (strFrame==String_256(_R(IDS_WEBADDRESS_SHORT_DEFAULT)))
01152             SetSelectedValueIndex(_R(IDC_WEBADDRESS_FRAME), 4);
01153 
01154         else
01155             //Otherwise, set the string in the edit field
01156             SetStringGadgetValue(_R(IDC_WEBADDRESS_FRAME), &strFrame, FALSE, -1);
01157         
01158     }
01159             
01160 }

void WebAddressDlg::ShowURL UINT32  uiURL  )  [protected]
 

Shows the URL in the dialog box.

void WebAddressDlg::ShowURL(UINT32 uiURL)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
uiURL - resource number of the URL to show [INPUTS]
- [OUTPUTS]
Returns:
TRUE if no problems

Errors: -

See also:
-
Technical details: Whenever we set text into an edit field, a "Text changed" message will be sent round, as if someone had typed into that field. We must ignore this, so we set a flag to do so.

This doesn't occur when you set text into a combo box.

It's a bug in the Dialog Manager and it should really be fixed.

Definition at line 1012 of file hlinkdlg.cpp.

01013 {   
01014     //First set a flag to ensure we don't handle the "Text changed" message
01015     //that will occur when we change the edit field.
01016     WebAddressDlg::DontHandleNextTextMessage=TRUE;
01017 
01018     //Simply set the string
01019     SetStringGadgetValue(_R(IDC_WEBADDRESS_URL), uiURL, FALSE, -1);
01020     
01021 }

void WebAddressDlg::ShowURL TCHAR pcURL = NULL  )  [protected]
 

Shows the URL in the dialog box.

void WebAddressDlg::ShowURL(TCHAR* pcURL)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
pcURL - the URL string to show in the field [INPUTS]
- [OUTPUTS]
Returns:
TRUE if no problems

Errors: -

See also:
-
Technical details: Whenever we set text into an edit field, a "Text changed" message will be sent round, as if someone had typed into that field. We must ignore this, so we set a flag to do so.

This doesn't occur when you set text into a combo box.

It's a bug in the Dialog Manager and it should really be fixed.

Definition at line 963 of file hlinkdlg.cpp.

00964 {   
00965     //First set a flag to ensure we don't handle the "Text changed" message
00966     //that will occur when we change the edit field.
00967     WebAddressDlg::DontHandleNextTextMessage=TRUE;
00968 
00969     //Is pcURL NULL?
00970     if (pcURL==NULL)
00971         //Yes. So set a blank string in the edit field
00972         SetStringGadgetValue(_R(IDC_WEBADDRESS_URL), &String_256(""), FALSE, -1);
00973     else
00974     {
00975         //No. So set the string we have been given in the edit field
00976         String_256 strToSet=pcURL;
00977         SetStringGadgetValue(_R(IDC_WEBADDRESS_URL), &strToSet, FALSE, -1);
00978     }
00979     
00980 }

void WebAddressDlg::ShowWebAddressOnSelection BOOL  fValue = TRUE  )  [protected]
 

Changes the text on the Add/Change button to Change if there is a Web Address or Add if there isn't.

void WebAddressDlg::ShowWebAddressOnSelection(BOOL fValue=TRUE)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/97
Parameters:
TRUE to tell the user there is a Web Address on the selection [INPUTS] FALSE to tell the user there is no Web Address on the selection
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1398 of file hlinkdlg.cpp.

01399 {   
01400     if (fValue)
01401         SetStringGadgetValue(IDOK, _R(IDS_ADDBUTTON_CHANGE));
01402     else
01403         SetStringGadgetValue(IDOK, _R(IDS_ADDBUTTON_ADD));
01404 }


Member Data Documentation

BOOL WebAddressDlg::DontHandleNextTextMessage = FALSE [static, protected]
 

Definition at line 230 of file hlinkdlg.h.

BOOL WebAddressDlg::fDialogIsInInitialState [protected]
 

Definition at line 231 of file hlinkdlg.h.

const UINT32 WebAddressDlg::IDD = _R(IDD_WEBADDRESSDLG) [static]
 

Definition at line 234 of file hlinkdlg.h.

const CDlgMode WebAddressDlg::Mode = MODELESS [static]
 

Definition at line 235 of file hlinkdlg.h.

BOOL WebAddressDlg::ms_fCorrect = TRUE [static]
 

Definition at line 239 of file hlinkdlg.h.

WebAddressDlg * WebAddressDlg::TheDialog = NULL [static, protected]
 

Definition at line 229 of file hlinkdlg.h.


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