hlinkdlg.cpp

Go to the documentation of this file.
00001 // $Id: hlinkdlg.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // A sdialog for testing HotLink things
00099 
00100 /*
00101 */
00102 
00103 #include "camtypes.h"
00104 #include "hlinkdlg.h"       //This file's header
00105 
00106 #include "reshlpid.h"       //For CC_HELP_BUTTON
00107 
00108 #include "menuops.h"    
00109 
00110 #include "oilprog.h"
00111 
00112 #include "ccdc.h"           // specific #includes needed for kernel-rendered dialogues
00113 
00114 //#include "app.h"          //for GetApplication() - in camtypes.h [AUTOMATICALLY REMOVED]
00115 //#include "range.h"            //for selection range stuff - in camtypes.h [AUTOMATICALLY REMOVED]
00116 #include "noderend.h"
00117 //#include "barsdlgs.h"     // _R(IDD_BARCONTROLSTORE), _R(IDC_BTN_WEBADDRESSDLG)
00118 
00119 //#include "hotdlg.h"           //The dialog rc file
00120 //#include "hotlink.h"      //The string resource rc file
00121 
00122 //#include "attrmgr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00123 #include "dlgmgr.h"
00124 
00125 #include "webattr.h"
00126 
00127 //#include "range.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00128 
00129 #include "nodetxts.h"
00130 
00131 #include "webaddr.h"
00132 //#include "pathname.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00133 
00134 DECLARE_SOURCE("$Revision: 1282 $");
00135 
00136 CC_IMPLEMENT_DYNCREATE(WebAddressDlg, DialogOp);
00137 
00138 #define new CAM_DEBUG_NEW
00139 
00140 // Set up our static variables
00141 const CDlgMode WebAddressDlg::Mode = MODELESS;
00142 const UINT32 WebAddressDlg::IDD = _R(IDD_WEBADDRESSDLG);
00143 
00144 WebAddressDlg *WebAddressDlg::TheDialog = NULL; 
00145 BOOL WebAddressDlg::DontHandleNextTextMessage=FALSE;
00146 
00147 BOOL WebAddressDlg::ms_fCorrect = TRUE; 
00148 
00149 /*******************************************************************************************
00150 
00151 >   WebAddressDlg::WebAddressDlg() : DialogOp(RenderDlg::IDD, RenderDlg::Mode) 
00152 
00153     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> from Alex
00154     Created:    25/3/97
00155     Purpose:    Constructor
00156 
00157 *******************************************************************************************/
00158 
00159 WebAddressDlg::WebAddressDlg() : 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 }       
00165 
00166 
00167 
00168 /*******************************************************************************************
00169 
00170 >   WebAddressDlg::~WebAddressDlg()
00171 
00172     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> from Alex
00173     Created:    25/3/97
00174     Purpose:    Destructor
00175 
00176 *******************************************************************************************/
00177 
00178 WebAddressDlg::~WebAddressDlg()
00179 {
00180     //Set our member variable pointer to NULL
00181     if (TheDialog == this)
00182         TheDialog = NULL;
00183 } 
00184  
00185 /********************************************************************************************
00186 >   MsgResult WebAddressDlg::Message( Msg* Message)
00187 
00188     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00189     Created:    25/3/97
00190     Inputs:     Message: The incoming message 
00191         
00192     Returns:    DialogOp::Message (Message)
00193 
00194     Purpose:    This is the message handler for the WebAddressDlg. It simply takes the
00195                 message and redirects it to one of our Message Handler functions.
00196      
00197 ********************************************************************************************/
00198 
00199 MsgResult WebAddressDlg::Message( Msg* Message)
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 } 
00276 
00277 /*******************************************************************************************
00278 
00279 >   OpState WebAddressDlg::GetState(String_256*, OpDescriptor*)
00280 
00281     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> after Alex
00282     Created:    25/3/97
00283     Purpose:    Returns the OpState of the dialogue operation
00284 
00285 *******************************************************************************************/
00286 
00287 OpState WebAddressDlg::GetState(String_256*, OpDescriptor*)
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 }
00297 
00298          
00299 
00300 /*******************************************************************************************
00301 
00302 >   BOOL WebAddressDlg::Init()
00303 
00304     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> after Alex
00305     Created:    25/3/97
00306     Returns:    FALSE if it fails (due to lack of memory)
00307     Purpose:    Creates an OpDescriptor for a HotLink Dialog and declares
00308                 some preferences
00309 
00310 *******************************************************************************************/
00311 BOOL WebAddressDlg::Init()
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 }   
00335  
00336       
00337 
00338 
00339 /********************************************************************************************
00340 
00341 >   void WebAddressDlg::Do(OpDescriptor*)
00342 
00343     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> after Jason
00344     Created:    25/3/97
00345 
00346     Purpose:    Opens the dialog if it is closed. Closes it if it is open.
00347         
00348 ********************************************************************************************/
00349 
00350 void WebAddressDlg::Do(OpDescriptor*)
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 }
00367 
00368 /********************************************************************************************
00369 
00370 >   BOOL WebAddressDlg::Create()
00371 
00372     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> after Jason
00373     Created:    25/3/97
00374     Inputs:     -
00375     Outputs:    -
00376     Returns:    FALSE if it fails
00377     Purpose:    Creates a Web Address dialogue box. Fails if DialogOp::Create
00378                 fails to create the box.
00379     Errors:     -
00380     SeeAlso:    -
00381 
00382 ********************************************************************************************/
00383 
00384 BOOL WebAddressDlg::Create()
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 }
00397 
00398 /********************************************************************************************
00399 
00400 >   void WebAddressDlg::DoWithParam(OpDescriptor* pOp, OpParam* pParam)    
00401 
00402     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> after Alex
00403     Created:    25/3/97
00404     Inputs:     OpDescriptor (unused)
00405     Outputs:    -
00406     Returns:    -
00407     Purpose:    Performs the WebAddressDlg operation
00408     Errors:     -
00409     SeeAlso:    -
00410 
00411 ********************************************************************************************/
00412 
00413 void WebAddressDlg::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
00414 {
00415     Do(pOp);
00416 
00417 }
00418 
00419 /********************************************************************************************
00420 
00421     WebAddressDlg message handling functions
00422 
00423     The following group of functions are called from WebAddressDlg::Message
00424     when a message is received.
00425 
00426     They call other functions which do whatever needs to be done.
00427 
00428 ********************************************************************************************/
00429 
00430 
00431 /********************************************************************************************
00432 
00433     void WebAddressDlg::OnCreate()
00434 
00435     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00436     Created:    21/3/97
00437     Inputs:     -
00438     Outputs:    -
00439     Returns:    -
00440     
00441     Purpose:    Handles a message that the dialog has just been created.
00442 
00443     Errors:     -
00444     SeeAlso:    WebAddressDlg::Message()
00445 
00446 ********************************************************************************************/
00447 
00448 void WebAddressDlg::OnCreate()
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 }
00457 
00458 /********************************************************************************************
00459 
00460     void WebAddressDlg::OnAddButtonClicked()
00461 
00462     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00463     Created:    21/3/97
00464     Inputs:     -
00465     Outputs:    -
00466     Returns:    -
00467     
00468     Purpose:    Handles a message that the Add button has been clicked
00469 
00470     Errors:     -
00471     SeeAlso:    WebAddressDlg::Message()
00472 
00473 ********************************************************************************************/
00474 
00475 void WebAddressDlg::OnAddButtonClicked()
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 }
00486 
00487 /********************************************************************************************
00488 
00489     void WebAddressDlg::OnRemoveButtonClicked()
00490 
00491     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00492     Created:    21/3/97
00493     Inputs:     -
00494     Outputs:    -
00495     Returns:    -
00496     
00497     Purpose:    Handles a message that the Remove button has been clicked
00498 
00499     Errors:     -
00500     SeeAlso:    WebAddressDlg::Message()
00501 
00502 ********************************************************************************************/
00503 
00504 void WebAddressDlg::OnRemoveButtonClicked()
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 }
00515 
00516 /********************************************************************************************
00517 
00518     void WebAddressDlg::OnAutoCorrectClicked()
00519 
00520     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00521     Created:    21/3/97
00522     Inputs:     -
00523     Outputs:    -
00524     Returns:    -
00525     
00526     Purpose:    Handles a message that the Auto Correct radio button has been clicked
00527 
00528     Errors:     -
00529     SeeAlso:    WebAddressDlg::Message()
00530 
00531 ********************************************************************************************/
00532 
00533 void WebAddressDlg::OnAutoCorrectClicked()
00534 {   
00535     //Update our member variable
00536     ms_fCorrect=GetCorrect();
00537 }
00538 
00539 
00540 /********************************************************************************************
00541 
00542     void WebAddressDlg::OnDialogChange()
00543 
00544     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00545     Created:    21/3/97
00546     Inputs:     -
00547     Outputs:    -
00548     Returns:    -
00549     
00550     Purpose:    Handles a message that something in the dialog has changed
00551 
00552                 Note that the AutoCorrect switch is independent of the rest
00553                 of the dialog and so changing that doesn't count as changing the dialog.
00554 
00555     Errors:     -
00556     SeeAlso:    WebAddressDlg::Message()
00557 
00558 ********************************************************************************************/
00559 
00560 void WebAddressDlg::OnDialogChange()
00561 {   
00562     //Set the dialog into its changed state
00563     SetDialogChangedState();
00564                             
00565 }
00566 
00567 /********************************************************************************************
00568 
00569     void WebAddressDlg::OnSelectionChange()
00570 
00571     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00572     Created:    21/3/97
00573     Inputs:     -
00574     Outputs:    -
00575     Returns:    -
00576     
00577     Purpose:    Handles a message that there's been a selection change
00578 
00579     Errors:     -
00580     SeeAlso:    WebAddressDlg::Message()
00581 
00582 ********************************************************************************************/
00583 
00584 void WebAddressDlg::OnSelectionChange()
00585 {   
00586     //Put the dialog into its initial state
00587     SetDialogInitialState();
00588                             
00589 }
00590 
00591 
00592 
00593 
00594 
00595 /********************************************************************************************
00596 
00597     WebAddressDlg action functions
00598 
00599     Called by the message handler functions to do whatever needs to be done
00600 
00601 ********************************************************************************************/
00602 
00603 /********************************************************************************************
00604 
00605     void WebAddressDlg::SetDialogInitialState()
00606 
00607     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00608     Created:    21/3/97
00609     Inputs:     -
00610     Outputs:    -
00611     Returns:    -
00612     
00613     Purpose:    Sets up the dialog in its initial state
00614 
00615                 This means:
00616                 a. Calling another member function to set up the controls
00617                    so they reflect the Web Address attribute on the selection
00618                 b. Setting a flag to say that the dialog is in its initial state
00619 
00620 
00621     Errors:     -
00622     SeeAlso:    WebAddressDlg::OnSelectionChange(), WebAddressDlg::OnCreate(), 
00623                 WebAddressDlg::OnAddButtonClicked()
00624 
00625 ********************************************************************************************/
00626 
00627 void WebAddressDlg::SetDialogInitialState()
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 }
00636 
00637 
00638 /********************************************************************************************
00639 
00640     void WebAddressDlg::SetDialogChangedState()
00641 
00642     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00643     Created:    21/3/97
00644     Inputs:     -
00645     Outputs:    -
00646     Returns:    -
00647     
00648     Purpose:    Sets up the dialog once it has been changed.
00649 
00650                 This means:
00651                 - If there is a selection, the ADD/CHANGE button is ungreyed
00652                 - If there is a Web Address on the Selection, the ADD/CHANGE
00653                   button will read "Change", otherwise it will read "Add"
00654                                                               
00655     Errors:     -
00656     SeeAlso:    WebAddressDlg::OnSelectionChange(), WebAddressDlg::OnCreate(), 
00657                 WebAddressDlg::OnAddButtonClicked()
00658 
00659 ********************************************************************************************/
00660 
00661 void WebAddressDlg::SetDialogChangedState()
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 }
00712 
00713 
00714 /********************************************************************************************
00715 
00716     void WebAddressDlg::SetDialogInitialControls()
00717 
00718     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00719     Created:    21/3/97
00720     Inputs:     -
00721     Outputs:    -
00722     Returns:    -
00723     
00724     Purpose:    Sets up the dialog according to what attributes are applied to the
00725                 selection. The cases are:
00726 
00727                 If a single attribute is applied, that attribute will be put into the
00728                 dialog box. The Add button button will be greyed and the Remove button
00729                 will be active.
00730 
00731                 If many attributes are applied, the dialog box edit fields will be
00732                 set to read "<Many>" and both radio buttons will be switched off. The
00733                 Remove button will be active and the Add button will be inactive.
00734 
00735                 If nothing is selected, the dialog box edit fields will be cleared
00736                 and both radio buttons will be switched off. The Add and Remove
00737                 buttons will both be inactive.
00738 
00739                 If the default attribute is applied, the dialog box edit fields
00740                 will be cleared and:
00741                 - if the selection consists only of text, the "rectangle surrounding
00742                   object" radio button will be selected
00743                 - otherwise, the "object shape" radio button will be selected.
00744 
00745                 
00746                                                   
00747 
00748     Errors:     -
00749     SeeAlso:    WebAddressDlg::OnSelectionChange(), WebAddressDlg::OnCreate(), 
00750                 WebAddressDlg::OnAddButtonClicked()
00751 
00752 ********************************************************************************************/
00753 
00754 void WebAddressDlg::SetDialogInitialControls()
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 }
00830 
00831 /********************************************************************************************
00832 
00833     void WebAddressDlg::ApplyWebAddress()
00834 
00835     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00836     Created:    21/3/97
00837     Inputs:     -
00838     Outputs:    -
00839     Returns:    -
00840     
00841     Purpose:    Applies the values in the dialog box to the selection
00842 
00843     Errors:     -
00844     SeeAlso:    -
00845 
00846 ********************************************************************************************/
00847 
00848 void WebAddressDlg::ApplyWebAddress()
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 }
00884 
00885 /********************************************************************************************
00886 
00887     void WebAddressDlg::RemoveWebAddress()
00888 
00889     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00890     Created:    21/3/97
00891     Inputs:     -
00892     Outputs:    -
00893     Returns:    -
00894     
00895     Purpose:    Removes any Web Address which is on the selection (i.e. applies
00896                 the default Web Address to the selection).
00897 
00898     Errors:     -
00899     SeeAlso:    -
00900 
00901 ********************************************************************************************/
00902 
00903 void WebAddressDlg::RemoveWebAddress()
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 }
00924 
00925 /********************************************************************************************
00926 
00927     WebAddressDlg control functions
00928 
00929     Functions that set the dialog box controls or get information from them
00930 
00931 ********************************************************************************************/
00932 
00933 /********************************************************************************************
00934 
00935     void WebAddressDlg::ShowURL(TCHAR* pcURL)
00936 
00937 
00938     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00939     Created:    21/3/97
00940     Inputs:     pcURL - the URL string to show in the field
00941     Outputs:    -
00942 
00943     Returns:    TRUE if no problems
00944     
00945     Purpose:    Shows the URL in the dialog box.
00946 
00947 
00948 
00949     Errors:     -
00950     SeeAlso:    -
00951 
00952   Technical details:
00953     Whenever we set text into an edit field, a "Text changed" message will
00954     be sent round, as if someone had typed into that field. We must ignore
00955     this, so we set a flag to do so.
00956 
00957     This doesn't occur when you set text into a combo box.
00958 
00959     It's a bug in the Dialog Manager and it should really be fixed.
00960 
00961 ********************************************************************************************/
00962 
00963 void WebAddressDlg::ShowURL(TCHAR* pcURL)
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 }
00981 
00982 /********************************************************************************************
00983 
00984     void WebAddressDlg::ShowURL(UINT32 uiURL)
00985 
00986 
00987     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00988     Created:    21/3/97
00989     Inputs:     uiURL - resource number of the URL to show
00990     Outputs:    -
00991 
00992     Returns:    TRUE if no problems
00993     
00994     Purpose:    Shows the URL in the dialog box.
00995 
00996 
00997 
00998     Errors:     -
00999     SeeAlso:    -
01000 
01001   Technical details:
01002     Whenever we set text into an edit field, a "Text changed" message will
01003     be sent round, as if someone had typed into that field. We must ignore
01004     this, so we set a flag to do so.
01005 
01006     This doesn't occur when you set text into a combo box.
01007 
01008     It's a bug in the Dialog Manager and it should really be fixed.
01009 
01010 ********************************************************************************************/
01011 
01012 void WebAddressDlg::ShowURL(UINT32 uiURL)
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 }
01022 
01023 
01024 /********************************************************************************************
01025 
01026     String_256 WebAddressDlg::GetURL()  
01027 
01028     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
01029     Created:    21/3/97
01030     Inputs:     -
01031     Outputs:    -
01032 
01033     Returns:    The string in the URL field
01034     
01035     Purpose:    Finds the value that the URL field contains.
01036                                                   
01037     Errors:     -
01038     SeeAlso:    -
01039 
01040 ********************************************************************************************/
01041 
01042 String_256 WebAddressDlg::GetURL()
01043 {   
01044     return GetStringGadgetValue(_R(IDC_WEBADDRESS_URL));
01045 }
01046 
01047 /********************************************************************************************
01048 
01049     void WebAddressDlg::ShowCorrect(BOOL fValue)
01050 
01051 
01052     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
01053     Created:    21/3/97
01054     Inputs:     fValue - whether to show the correction features as on or off
01055     Outputs:    -
01056 
01057     Returns:    -
01058     
01059     Purpose:    Shows the AutoCorrect state in the dialog.
01060 
01061 
01062 
01063     Errors:     -
01064     SeeAlso:    -
01065 
01066 ********************************************************************************************/
01067 
01068 void WebAddressDlg::ShowCorrect(BOOL fValue)
01069 {   
01070     //Set the switch
01071     SetLongGadgetValue(_R(IDC_WEBADDRESS_CORRECT), fValue);
01072     
01073 }
01074 
01075 
01076 /********************************************************************************************
01077 
01078     BOOL WebAddressDlg::GetCorrect()  
01079 
01080     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
01081     Created:    21/3/97
01082     Inputs:     -
01083     Outputs:    -
01084 
01085     Returns:    The state of the AutoCorrect switch
01086     
01087     Purpose:    Finds the state of the AutoCorrect switch
01088                                                   
01089     Errors:     -
01090     SeeAlso:    -
01091 
01092 ********************************************************************************************/
01093 
01094 BOOL WebAddressDlg::GetCorrect()
01095 {   
01096     return GetLongGadgetValue(_R(IDC_WEBADDRESS_CORRECT), FALSE, TRUE, 0);
01097 }
01098 
01099 
01100 /********************************************************************************************
01101 
01102     void WebAddressDlg::ShowFrame(TCHAR* pcFrame)
01103                                            
01104     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
01105     Created:    21/3/97
01106     Inputs:     pcFrame - the frame string to show in the field
01107     Outputs:    -
01108 
01109     Returns:    TRUE if no problems
01110     
01111     Purpose:    Shows the Frame in the dialog box.
01112 
01113                 Before showing the string, we check to see if is one of the four
01114                 short strings (_self, _top, _parent and _blank) that correspond
01115                 to values in the combo box. If it is, we select the appropriate
01116                 list item in the combo box instead.
01117 
01118     Errors:     -
01119     SeeAlso:    -
01120 
01121 ********************************************************************************************/
01122 
01123 void WebAddressDlg::ShowFrame(TCHAR* pcFrame)
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 }
01161 
01162 /********************************************************************************************
01163 
01164     void WebAddressDlg::ShowFrame(UINT32 uiFrame)
01165 
01166 
01167     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
01168     Created:    21/3/97
01169     Inputs:     uiFrame - resource number of the URL to show
01170     Outputs:    -
01171 
01172     Returns:    TRUE if no problems
01173     
01174     Purpose:    Shows the Frame in the dialog box.
01175 
01176 
01177 
01178     Errors:     -
01179     SeeAlso:    -
01180 
01181 
01182 ********************************************************************************************/
01183 
01184 void WebAddressDlg::ShowFrame(UINT32 uiFrame)
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 }
01194 
01195 
01196 /********************************************************************************************
01197 
01198     String_256 WebAddressDlg::GetFrame()  
01199 
01200     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
01201     Created:    21/3/97
01202     Inputs:     -
01203     Outputs:    -
01204 
01205     Returns:    The string in the Frame combo box or, if the string
01206                 in the combo box is one of our preset strings (such as
01207                 "New window (_blank)"), then we return a shorter
01208                 version of that string ("_blank").
01209     
01210     Purpose:    Finds the value that the Frame combo box contains.
01211                             
01212 
01213     Errors:     -
01214     SeeAlso:    -
01215 
01216   Technical details:
01217 
01218   We could use "GetSelectedValueIndex()" to find if one of our preset strings had
01219   been selected.
01220 
01221   But consider the case where the user selected one of our present strings, then
01222   accidentally clicked in the Frame edit field without changing anythin.
01223 
01224   In this case, the selected value (-1) would tell us that the combo box held
01225   a value that the user had typed in the edit field...not one of the preset strings.
01226 
01227   So, instead, to find if one of our preset strings is in the combo box, we do
01228   a direct string comparison.
01229 
01230 ********************************************************************************************/
01231 
01232 String_256 WebAddressDlg::GetFrame()  
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 }
01257 
01258 /********************************************************************************************
01259 
01260     void WebAddressDlg::ShowClickableArea(UINT32 uiArea)  
01261 
01262     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
01263     Created:    21/3/97
01264     Inputs:     uiArea  A number describing the clickable area to show:
01265                         0   Object shape
01266                         1   Rectangle
01267                         2   Indeterminate
01268     Outputs:    -
01269 
01270     Returns:    -
01271     
01272       Purpose:  Shows the clickable area in the dialog box as follows:
01273 
01274                 0   Object shape radio button is on, rectangle radio button is off
01275                 1   Rectangle radio button is on, object radio button is off
01276                 2   Both radio buttons are off
01277 
01278                             
01279 
01280     Errors:     -
01281     SeeAlso:    -
01282 
01283 ********************************************************************************************/
01284 
01285 void WebAddressDlg::ShowClickableArea(UINT32 uiArea)  
01286 {   
01287     SetLongGadgetValue(_R(IDC_WEBADDRESS_OBJECTSHAPE), (uiArea==0));
01288     SetLongGadgetValue(_R(IDC_WEBADDRESS_RECTANGLE), (uiArea==1));
01289 }
01290 
01291 /********************************************************************************************
01292 
01293     UINT32 WebAddressDlg::GetClickableArea()  
01294 
01295     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
01296     Created:    21/3/97
01297     Inputs:     -
01298     Outputs:    -
01299     Returns:    uiArea  A number describing the clickable area:
01300                         0   Object shape
01301                         1   Rectangle
01302                         2   Indeterminate
01303 
01304     Purpose:    Gets the clickable area shown in the dialog box
01305 
01306                             
01307 
01308     Errors:     -
01309     SeeAlso:    -
01310 
01311 ********************************************************************************************/
01312 
01313 UINT32 WebAddressDlg::GetClickableArea()  
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 }
01326 
01327 /********************************************************************************************
01328 
01329     void WebAddressDlg::EnableAdd(BOOL fValue=TRUE)  
01330 
01331     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
01332     Created:    21/3/97
01333     Inputs:     TRUE to allow the user to add the web address
01334                 FALSE to prevent the user from adding the Web Address
01335     
01336     Outputs:    -
01337 
01338     Returns:    -
01339     
01340     Purpose:    Switches the Add button on or off                           
01341 
01342     Errors:     -
01343     SeeAlso:    -
01344 
01345 ********************************************************************************************/
01346 
01347 void WebAddressDlg::EnableAdd(BOOL fValue)  
01348 {   
01349     EnableGadget(IDOK, fValue);
01350 }
01351 
01352 /********************************************************************************************
01353 
01354     void WebAddressDlg::EnableRemove(BOOL fValue=TRUE)  
01355 
01356     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
01357     Created:    21/3/97
01358     Inputs:     TRUE to allow the user to remove the Web Address
01359                 FALSE to prevent the user from removing the Web Address
01360     
01361     Outputs:    -
01362 
01363     Returns:    -
01364     
01365     Purpose:    Switches the Remove button on or off                            
01366 
01367     Errors:     -
01368     SeeAlso:    -
01369 
01370 ********************************************************************************************/
01371 
01372 void WebAddressDlg::EnableRemove(BOOL fValue)  
01373 {   
01374     EnableGadget(_R(IDC_WEBADDRESS_REMOVE), fValue);
01375 }
01376 
01377 /********************************************************************************************
01378 
01379     void WebAddressDlg::ShowWebAddressOnSelection(BOOL fValue=TRUE)  
01380 
01381     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
01382     Created:    21/3/97
01383     Inputs:     TRUE to tell the user there is a Web Address on the selection
01384                 FALSE to tell the user there is no Web Address on the selection
01385     
01386     Outputs:    -
01387 
01388     Returns:    -
01389     
01390     Purpose:    Changes the text on the Add/Change button to Change if there
01391                 is a Web Address or Add if there isn't.
01392 
01393     Errors:     -
01394     SeeAlso:    -
01395 
01396 ********************************************************************************************/
01397 
01398 void WebAddressDlg::ShowWebAddressOnSelection(BOOL fValue)  
01399 {   
01400     if (fValue)
01401         SetStringGadgetValue(IDOK, _R(IDS_ADDBUTTON_CHANGE));
01402     else
01403         SetStringGadgetValue(IDOK, _R(IDS_ADDBUTTON_ADD));
01404 }
01405 
01406 /********************************************************************************************
01407 
01408     WebAddressDlg toolkit functions
01409 
01410     Protected functions that are called by other WebAddressDlg functions.
01411 
01412 ********************************************************************************************/
01413 
01414 /********************************************************************************************
01415 
01416     WebCommonAttributeResult WebAddressDlg::FindCommonWebAttribute(WebAddressAttribute* pwaaReturn)
01417 
01418     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
01419     Created:    21/3/97
01420     Inputs:     -
01421     Outputs:    pwaaReturn  The caller should set this to point at a WebAddressAttribute
01422                             if they want  a copy of the applied attribute returned.
01423 
01424     Returns:    WCA_DEFAULT The default WebAddressAttribute is applied
01425                             to the entire selection
01426 
01427                 WCA_SINGLE  The same or identical WebAddressAttributes are
01428                             applied to the whole selection
01429 
01430                 WCA_MANY    Different WebAddressAttributes are applied to
01431                             the selection
01432 
01433                 WCA_NOSELECTION
01434                             Nothing is selected
01435     
01436     Purpose:    Finds if the selection has a common Web Address attribute.
01437 
01438                 It does this by calling Range::FindCommonAttribute, then if there's 
01439                 a single attribute applied, doing a quick check to see if that 
01440                 attribute is the default attribute of its type.
01441 
01442     Errors:     -
01443     SeeAlso:    -
01444 
01445 ********************************************************************************************/
01446 
01447 WebCommonAttributeResult WebAddressDlg::FindCommonWebAttribute(WebAddressAttribute* pwaaReturn)
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 }
01497 
01498 
01499 
01500 /********************************************************************************************
01501 
01502     BOOL WebAddressDlg::SelectionConsistsOfText()  
01503 
01504     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
01505     Created:    24/3/97
01506     Inputs:     -
01507     Outputs:    -
01508 
01509     Returns:    TRUE if the selection consists entirely of text objects
01510                 FALSE otherwise
01511     
01512     Purpose:    To find if the selection is entirely text
01513 
01514     Errors:     If there is no selection
01515 
01516     SeeAlso:    Range::ConsistsOf
01517 
01518 ********************************************************************************************/
01519 
01520 BOOL WebAddressDlg::SelectionConsistsOfText()  
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 }

Generated on Sat Nov 10 03:45:30 2007 for Camelot by  doxygen 1.4.4