aprps.cpp

Go to the documentation of this file.
00001 // $Id: aprps.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 
00099 #include "camtypes.h"
00100 
00101 //#include "barsdlgs.h" 
00102 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00103 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "dialogop.h"  - in camtypes.h [AUTOMATICALLY REMOVED]
00105 //#include "optsres.h"  
00106 //#include "will.h"     
00107 //#include "resource.h" 
00108 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 #include "sprdmsg.h"    
00110 #include "optsmsgs.h"   
00111 #include "layer.h"
00112 //#include "nev.h"      
00113 #include "sglayer.h"
00114 //#include "fixmem.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00115 //#include "markn.h"
00116 //#include "jason.h"
00117 #include "layermsg.h"
00118 #include "aprps.h"
00119 //#include "gifdlg.h"
00120 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00121 
00122 //#include "will3.h"
00123 #include "prevwdlg.h"
00124 //#include "simon.h"
00125 //#include "bmpsdlgr.h"
00126 //#include "ollie.h"
00127 //#include "filtrres.h"
00128 #include "filedlgs.h"
00129 //#include "prevwres.h" 
00130 
00131 CC_IMPLEMENT_DYNCREATE  (GIFAnimationPropertyTabsDlg,   DialogTabOp)
00132 CC_IMPLEMENT_DYNCREATE  (FramePropertiesTab,            GIFAnimationPropertyTabs)
00133 CC_IMPLEMENT_DYNCREATE  (AnimationPropertiesTab,        GIFAnimationPropertyTabs)   
00134 CC_IMPLEMENT_DYNCREATE  (AnimationColoursTab,           GIFAnimationPropertyTabs)   
00135 CC_IMPLEMENT_DYNCREATE  (PreviewInBrowserTab,           GIFAnimationPropertyTabs)   
00136 CC_IMPLEMENT_DYNCREATE  (GIFAnimationPropertyTabs,      PropertyTabs)
00137 CC_IMPLEMENT_DYNCREATE  (AnimExOptns,                   GIFAnimationPropertyTabsDlg)
00138 CC_IMPLEMENT_DYNAMIC    (BrowserPrvwChgdMsg,            Msg)
00139 
00140 #define new CAM_DEBUG_NEW
00141 
00142 const   CDlgResID   GIFAnimationPropertyTabsDlg::IDD    = _R(IDD_PROPERTIES);       // Dialog box id
00143         CDlgMode    GIFAnimationPropertyTabsDlg::Mode   = MODELESS;             // This dialog is modeless
00144 
00145         const CDlgResID AnimExOptns::IDD = _R(IDD_OPTIONS_PROPERTIES);              // Dialog box id
00146         CDlgMode    AnimExOptns::Mode    = MODAL;                               // If the dialog is invoked through the options button on the export dialog,            
00147                                                                                 // then this dialog is modeless.                
00148 
00149 GIFAnimationPropertyTabs    *GIFAnimationPropertyTabsDlg::m_pGIFAnimationProperties      = NULL;    // pointer to the tab handling class
00150 GIFAnimationPropertyTabsDlg *GIFAnimationPropertyTabsDlg::m_pGIFAnimationPropertyTabsDlg = NULL; 
00151 
00152 
00153 List            GIFAnimationPropertyTabs::GIFAnimationPropertyTabsList;             // The global list of installed options tabs.
00154 DialogTabOp*    GIFAnimationPropertyTabs::pPropertiesDlg                = NULL;     // link to application options dialog class
00155 UINT32          GIFAnimationPropertyTabs::m_Count                       = 0;        // The number of instances of this dialog.
00156 BOOL            GIFAnimationPropertyTabs::m_IsManyDisplayed             = FALSE;    // Is many displayed in the Delay edit field.
00157 BOOL            GIFAnimationPropertyTabs::m_IncludeFramePropertiesTab   = TRUE;     // Should the frame properties tab be displayed.        
00158 BOOL            GIFAnimationPropertyTabs::m_BrowserPreviewTab           = FALSE;    // This flag allows us to know when to exclude all other tabs.
00159 
00160 // The following are used to open the specific tab in the options dialog box
00161 UINT32 GIFAnimationPropertyTabs::FramePropertiesTabNumber       = 0;                    // Tab number assigned to the frame properties tab.
00162 UINT32 GIFAnimationPropertyTabs::AnimationColoursTabNumber  = 1;                    // Tab number assigned to the animation colours tab.    
00163 UINT32 GIFAnimationPropertyTabs::AnimationPropertiesTabNumber   = 2;                    // Tab number assigned to the animation properties tab.
00164 UINT32 GIFAnimationPropertyTabs::PreviewInBrowserTabNumber  = 3;                    // Tab number assigned to the preview in browser tab.
00165 INT32  GIFAnimationPropertyTabsDlg::m_PageToOpen = -1;                              // The tab page to open at start up.
00166 BOOL GIFAnimationPropertyTabs::m_CurrentApplyNow = FALSE;
00167 BOOL GIFAnimationPropertyTabs::m_ApplyNow = FALSE;
00168 BOOL GIFAnimationPropertyTabs::m_InitMessage = FALSE;   
00169 BOOL GIFAnimationPropertyTabs::m_FrameGalleryOpen = TRUE;
00170 BOOL GIFAnimationPropertyTabs::m_ChangeLayerState = FALSE;
00171 BOOL GIFAnimationPropertyTabs::m_FrameDelayValueChanged = FALSE;
00172 
00173 //BrowserPreviewOptions PreviewInBrowserTab::t_BrowserOptions;
00174 BOOL                    PreviewInBrowserTab::g_InfoInHtmlStub   = TRUE;
00175 BOOL                    PreviewInBrowserTab::g_Imagemap         = TRUE;
00176 BrowserBackground       PreviewInBrowserTab::g_Background       = BROWSER_BGR_NONE;
00177 
00178 
00179 /*****************************************************************************************************************************************************
00180 
00181 >   GIFAnimationPropertyTabsDlg::GIFAnimationPropertyTabsDlg(): DialogTabOp(GIFAnimationPropertyTabsDlg::IDD, GIFAnimationPropertyTabsDlg::Mode) 
00182 
00183     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
00184     Created:    10/06/97
00185     Inputs:     -
00186     Outputs:    -
00187     Returns:    -
00188     Purpose:    GIFAnimationPropertyTabsDlg default constructor. 
00189     
00190 ********************************************************************************************************************************************************/
00191 
00192 GIFAnimationPropertyTabsDlg::GIFAnimationPropertyTabsDlg(): DialogTabOp(GIFAnimationPropertyTabsDlg::IDD, GIFAnimationPropertyTabsDlg::Mode,
00193                                                                         CC_RUNTIME_CLASS(DialogOp), GIFAnimationPropertyTabsDlg::GetPageToOpen())
00194 {
00195     if (m_pGIFAnimationProperties)
00196     {
00197         m_pGIFAnimationProperties->SetApplyNowState(FALSE);     // grey the apply now button
00198         m_pGIFAnimationProperties->SetInitMessageState(FALSE);  // not sending an init message
00199 
00200         // The Document and spread we are supposed to be working on. 
00201         m_pGIFAnimationProperties->pScopeDocument = NULL;           
00202         m_pGIFAnimationProperties->SetCurrentDocAndSpread(NULL);        
00203 
00204         //Increment the count, as another instance of the dialog has been created.
00205         UINT32 Val=1;
00206         m_pGIFAnimationProperties->IncCount(Val);
00207 
00208         // Create a static link to this dialog class.
00209         m_pGIFAnimationPropertyTabsDlg = this;
00210     }
00211 }
00212 
00213 
00214 /*****************************************************************************************************************************************************
00215 
00216 >   GIFAnimationPropertyTabsDlg::GIFAnimationPropertyTabsDlg(): DialogTabOp(GIFAnimationPropertyTabsDlg::IDD, GIFAnimationPropertyTabsDlg::Mode) 
00217 
00218     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
00219     Created:    10/06/97
00220     Inputs:     -
00221     Outputs:    -
00222     Returns:    -
00223     Purpose:    GIFAnimationPropertyTabsDlg constructor. 
00224                 This allows us to specify a new dialog resource id and a different mode. 
00225                 This constructor is overloaded since if the dialog is invoked through the options button 
00226                 on the GIF Export options dialog, then we need to specify a different resouce ID and make the dialog MODAL.
00227     
00228 ********************************************************************************************************************************************************/
00229 
00230 GIFAnimationPropertyTabsDlg::GIFAnimationPropertyTabsDlg(CDlgResID DialogResID, CDlgMode Mode): DialogTabOp(DialogResID, Mode,
00231                                                                         CC_RUNTIME_CLASS(DialogOp), GIFAnimationPropertyTabsDlg::GetPageToOpen())
00232 {
00233     if (m_pGIFAnimationProperties)
00234     {
00235         m_pGIFAnimationProperties->SetApplyNowState(FALSE);     // grey the apply now button
00236         m_pGIFAnimationProperties->SetInitMessageState(FALSE);  // not sending an init message
00237 
00238         // The Document and spread we are supposed to be working on. 
00239         m_pGIFAnimationProperties->pScopeDocument = NULL;           
00240         m_pGIFAnimationProperties->SetCurrentDocAndSpread(NULL);        
00241 
00242         //Increment the count, as another instance of the dialog has been created.
00243         UINT32 Val=1;
00244         m_pGIFAnimationProperties->IncCount(Val);
00245 
00246         // Create a static link to this dialog class.
00247         m_pGIFAnimationPropertyTabsDlg = this;
00248     }
00249 }
00250 
00251 /******************************************************************************************
00252 
00253 >   GIFAnimationPropertyTabsDlg::~GIFAnimationPropertyTabsDlg()
00254     
00255     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
00256     Created:    10/06/97
00257     Inputs:     -
00258     Outputs:    -
00259     returns:    - 
00260     Purpose:    GIFAnimationPropertyTabsDlg destructor.
00261 
00262 ******************************************************************************************/
00263 
00264 GIFAnimationPropertyTabsDlg::~GIFAnimationPropertyTabsDlg()
00265 {
00266     // Ensure we have a valid ptr.
00267     if (m_pGIFAnimationProperties)
00268     {
00269         // Remove the link to the options tabs if all the dialogs have been closed. 
00270         if(m_pGIFAnimationProperties->GetCount() < 1)
00271         {
00272             // Remove the options tabs link to the dialog box class.
00273             m_pGIFAnimationProperties->SetTabbedDlg(NULL);
00274         }
00275 
00276         // A dialog has been destroyed, therefore decrement m_count.
00277         UINT32 Count =1;
00278         m_pGIFAnimationProperties->DecCount(Count);
00279 
00280         // Kill the static link to this dialog class.
00281         m_pGIFAnimationPropertyTabsDlg = NULL;
00282 
00283         // Set this flag to FALSE.
00284         m_pGIFAnimationProperties->SetCurrentApplyNow(FALSE);
00285     }
00286 }
00287 
00288 /********************************************************************************************
00289 
00290 >   BOOL GIFAnimationPropertyTabsDlg::CommitDialogValues()
00291 
00292     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
00293     Created:    10/06/97
00294     Inputs:     -
00295     Outputs:    -
00296     Returns:    True if values in dialog box ok, False otherwise.     
00297     Purpose:    Takes the values in the dialog box and sets the return values accordingly
00298                 Called when ok is pressed on the dialog box.
00299 
00300 *********************************************************************************************/
00301 
00302 BOOL GIFAnimationPropertyTabsDlg::CommitDialogValues()
00303 {
00304     // Ok has been pressed so take the values from the dialog box.
00305     BOOL ok = TRUE;
00306     BOOL ValuesOk = TRUE;
00307 
00308     // Make sure we work on the correct document and spread.
00309     Document *pDocument = Document::GetSelected();
00310     m_pGIFAnimationProperties->SetCurrentDocAndSpread(pDocument);
00311 
00312     // Tell all the tabs to commit their values.
00313     GIFAnimationPropertyTabs *pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetFirst();
00314 
00315     // Continue while we have a valid tab ptr.
00316     while (pGIFAnimationPropertyTabs != NULL)
00317     {
00318         // Only get the tab to commit if it is in use.
00319         if ( pGIFAnimationPropertyTabs->IsPropertyRequired() )
00320         {
00321             // Get the found page to commit its values.
00322             ok = pGIFAnimationPropertyTabs->CommitSection();
00323             if ( ok != TRUE)
00324             {
00325                 if (ok == 2)
00326                     InformError();      
00327 
00328                 // Carry on with other pages.
00329                 ValuesOk = FALSE;   
00330             }
00331             // Set the apply now flag to FALSE.
00332             pGIFAnimationPropertyTabs->SetApplyNowState(FALSE);
00333 
00334             // Grey yhe apply now/ok/Cancel buttons.
00335             pGIFAnimationPropertyTabs->GreyApplyNow();  
00336         }
00337         // Get the next option's tab.
00338         pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetNext(pGIFAnimationPropertyTabs);
00339     }
00340 
00341     // Return whether we found bad values or not.
00342     return ValuesOk;
00343 }
00344 
00345 /*********************************************************************************************************************
00346 
00347 >   MsgResult GIFAnimationPropertyTabsDlg::Message(Msg* Message)
00348     
00349     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
00350     Created:    10/06/97
00351     Inputs:     -
00352     Outputs:    -
00353     Returns:    OK            Message handled ok.
00354                 FAIL          Something terrible happened whilst processing the message.
00355                 EAT_MSG       The Message was handled ok but don't send it to any more MessageHandlers. 
00356         
00357 *************************************************************************************************************************/
00358 
00359 MsgResult GIFAnimationPropertyTabsDlg::Message(Msg* Message)
00360 {
00361     ERROR3IF(Message == NULL,"GIFAnimationPropertyTabsDlg::Message NULL message received");
00362     ERROR3IF(m_pGIFAnimationProperties == NULL,"GIFAnimationPropertyTabsDlg::Message no m_pGIFAnimationProperties ptr");
00363     
00364     // Cope with document changing messages. 
00365     if (MESSAGE_IS_A(Message, DocChangingMsg))
00366     {
00367         DocChangingMsg *TheMsg = (DocChangingMsg *) Message;
00368 
00369         switch ( TheMsg->State )
00370         {
00371             case DocChangingMsg::SELCHANGED:
00372             {
00373                 // In different cases we use different document pointers.
00374                 Document *pDocument = NULL;
00375                 if (TheMsg->State == DocChangingMsg::TITLECHANGED)
00376                 {
00377                     // Document title has changed message.
00378                     pDocument = TheMsg->pChangingDoc;
00379                 }
00380                 else
00381                 {
00382                     // Document selection changed.
00383                     pDocument = TheMsg->pNewDoc;
00384                 }
00385                             
00386                 // Make sure that the tabs know what is the current document and spread to work on.
00387                 m_pGIFAnimationProperties->SetCurrentDocAndSpread(pDocument);
00388 
00389                 // Ensure correct current document units.
00390                 m_pGIFAnimationProperties->SetUpDocUnits();
00391 
00392                 // Is there a new document.
00393                 if (pDocument == NULL)
00394                 {
00395                     // Make sure all the tabs update themselves.
00396                     GIFAnimationPropertyTabs *pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetFirst();
00397 
00398                     while (pGIFAnimationPropertyTabs != NULL)
00399                     {
00400                         // Only get the tab to update if it is in use.
00401                         if ( pGIFAnimationPropertyTabs->IsPropertyRequired() )
00402                         {
00403                             // Get that tab to update itself.
00404                             pGIFAnimationPropertyTabs->GreySection();
00405                         }
00406 
00407                         // Get the next option's tab.
00408                         pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetNext(pGIFAnimationPropertyTabs);
00409                     }
00410                 }
00411                 else
00412                 {
00413                     // Make sure all the tabs update themselves.
00414                     GIFAnimationPropertyTabs *pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetFirst();
00415 
00416                     while (pGIFAnimationPropertyTabs != NULL)
00417                     {
00418                         // Only get the tab to update if it is currently in use.
00419                         if ( pGIFAnimationPropertyTabs->IsPropertyRequired() )
00420                         {
00421                             // Get this tab to update itself.
00422                             pGIFAnimationPropertyTabs->UngreySection();
00423                         }
00424                         // Get the next option's tab.
00425                         pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetNext(pGIFAnimationPropertyTabs);
00426                     }
00427                 }
00428             }
00429             break;
00430             
00431             // This message is sent when a new or just opened document is stable.
00432             case DocChangingMsg::BORNANDSTABLE:
00433             {
00434                 // Get the changing document pointer.
00435                 Document *pDocument = NULL;
00436                 pDocument = TheMsg->pChangingDoc;
00437                 if (pDocument != NULL)
00438                 {
00439                     // Ensure all the tabs update themsleves.
00440                     m_pGIFAnimationProperties->SetCurrentDocAndSpread(pDocument);
00441 
00442                     GIFAnimationPropertyTabs *pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetFirst();
00443 
00444                     while (pGIFAnimationPropertyTabs != NULL)
00445                     {
00446                         // Only get the tab to update if it is in use
00447                         if ( pGIFAnimationPropertyTabs->IsPropertyRequired() )
00448                         {
00449                             // Get that tab to update itself.
00450                             pGIFAnimationPropertyTabs->UpdateSection();
00451                         }
00452 
00453                         // Get the next options tab.
00454                         pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetNext(pGIFAnimationPropertyTabs);
00455                     }
00456                 }
00457             }
00458             break;
00459 
00460             default:
00461                 break;
00462         }
00463     }
00464 
00465     // Cope with document view changing messages so that we allow all the tabs to update themselves when switching to a new view.
00466     if (MESSAGE_IS_A(Message, DocViewMsg))
00467     {
00468         DocViewMsg *TheMsg = (DocViewMsg *) Message;
00469 
00470         switch ( TheMsg->State )
00471         {
00472             case DocViewMsg::SELCHANGED:
00473             {
00474                 if (TheMsg->pNewDocView != NULL)
00475                 {
00476                     // Ensure all the tabs update themsleves.
00477                     Document *pDocument = TheMsg->pNewDocView->GetDoc();
00478                     m_pGIFAnimationProperties->SetCurrentDocAndSpread(pDocument);
00479 
00480                     GIFAnimationPropertyTabs *pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetFirst();
00481 
00482                     while (pGIFAnimationPropertyTabs != NULL)
00483                     {
00484                         // Only get the tab to update if it is in use.
00485                         if ( pGIFAnimationPropertyTabs->IsPropertyRequired() )
00486                         {
00487                             // Get that tab to update itself.
00488                             pGIFAnimationPropertyTabs->UpdateSection();
00489                         }
00490 
00491                         // Get the next option's tab.
00492                         pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetNext(pGIFAnimationPropertyTabs);
00493                     }
00494                 }
00495             }
00496             break;
00497 
00498             default:
00499                 break;
00500         }
00501     }
00502 
00503     // Cope with document view changing messages so that we allow all the tabs to update themselves when switching to a new view.
00504     if (MESSAGE_IS_A(Message, SpreadMsg))
00505     {
00506         SpreadMsg *TheMsg = (SpreadMsg *) Message;
00507 
00508         switch ( TheMsg->Reason )
00509         {
00510             // The selected spread has changed
00511             case SpreadMsg::SELCHANGED:
00512             {
00513                 if (TheMsg->pNewSpread != NULL)
00514                 {
00515                     // Ensure all the tabs update themselves.
00516                     Document *pDocument = (Document *)TheMsg->pNewSpread->FindOwnerDoc();
00517                     m_pGIFAnimationProperties->SetCurrentDocAndSpread(pDocument);
00518 
00519                     GIFAnimationPropertyTabs *pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetFirst();
00520 
00521                     while (pGIFAnimationPropertyTabs != NULL)
00522                     {
00523                         // Only get the tab to update if it is in use.
00524                         if ( pGIFAnimationPropertyTabs->IsPropertyRequired() )
00525                         {
00526                             // Get that tab to update itself.
00527                             pGIFAnimationPropertyTabs->UpdateLayerSection();
00528                         }
00529 
00530                         // Get the next option's tab.
00531                         pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetNext(pGIFAnimationPropertyTabs);
00532                     }
00533                 }
00534             }
00535             break;
00536 
00537             case SpreadMsg::ANIMATIONPROPERTIESCHANGED:
00538             {
00539                 GIFAnimationPropertyTabs *pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetFirst();
00540 
00541                     while (pGIFAnimationPropertyTabs != NULL)
00542                     {
00543                         // Only get the tab to update if it is in use.
00544                         if ( pGIFAnimationPropertyTabs->IsPropertyRequired() )
00545                         {
00546                             // Get that tab to update itself.
00547                             pGIFAnimationPropertyTabs->UpdateLayerSection();
00548                         }
00549                         // Get the next option's tab.
00550                         pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetNext(pGIFAnimationPropertyTabs);
00551                     }
00552             }
00553             break;
00554 
00555             default:
00556                 break;
00557         }
00558     }
00559 
00560     // Handle a layer changing message.
00561     if (MESSAGE_IS_A(Message, LayerMsg))
00562     {
00563         LayerMsg *TheMsg = (LayerMsg *) Message;
00564 
00565         switch ( TheMsg->Reason )
00566         {
00567             // The active layer has changed.
00568             case LayerMsg::ACTIVE_LAYER_CHANGED:
00569             {
00570                 if (TheMsg->pNewLayer != NULL)
00571                 {
00572                     // Ensure all the tabs update themsleves.
00573                     m_pGIFAnimationProperties->SetActiveLayer(TheMsg->pNewLayer);
00574 
00575                     // While Loop flag.
00576 //                  BOOL FoundPage = FALSE;
00577 
00578                     GIFAnimationPropertyTabs *pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetFirst();
00579 
00580                     while (pGIFAnimationPropertyTabs != NULL)
00581                     {
00582                         //  Get the page Id.
00583                         CDlgResID PageId = pGIFAnimationPropertyTabs->GetPageID();
00584 
00585                         // For Layer messages we only update the frame properties tab.
00586                         if (PageId == _R(IDD_TAB_FRAME_PROPERTIES) || PageId == _R(IDD_TAB_ANIMATION_PROPERTIES))
00587                         {
00588                             // Only get the tab to update if it is in use.
00589                             if ( pGIFAnimationPropertyTabs->IsPropertyRequired() )
00590                             {
00591                                 // Get that tab to update itself.
00592                                 pGIFAnimationPropertyTabs->UpdateLayerSection();
00593 
00594                                 // Exit the while loop 
00595                             //  FoundPage = TRUE;
00596                             }
00597                         }
00598                         // Get the next option's tab.
00599                         pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetNext(pGIFAnimationPropertyTabs);
00600                     }
00601                 }
00602             }
00603             break;
00604 
00605             // The active layer has been updated.
00606             case LayerMsg::UPDATE_ACTIVE_LAYER:
00607             {
00608                 // While Loop flag.
00609                 BOOL FoundPage = FALSE;
00610 
00611                 // Ensure all the tabs update themsleves.
00612                 m_pGIFAnimationProperties->SetActiveLayer(TheMsg->pNewLayer);
00613 
00614                 GIFAnimationPropertyTabs *pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetFirst();
00615 
00616                 while (pGIFAnimationPropertyTabs != NULL && !FoundPage)
00617                 {
00618                     //  Get the page Id.
00619                     CDlgResID PageId = pGIFAnimationPropertyTabs->GetPageID();
00620 
00621                     // For Layer messages we only update the frame properties tab.
00622                     if (PageId == _R(IDD_TAB_FRAME_PROPERTIES))
00623                     {
00624                         // Only get the tab to update if it is in use.
00625                         if ( pGIFAnimationPropertyTabs->IsPropertyRequired() )
00626                         {
00627                             // Get that tab to update itself.
00628                             pGIFAnimationPropertyTabs->UpdateLayerSection();
00629 
00630                             // Exit the loop.
00631                             FoundPage = TRUE;
00632                         }
00633                     }
00634                     // Get the next option's tab.
00635                     pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetNext(pGIFAnimationPropertyTabs);
00636                 }
00637                 break;
00638             }
00639             default:
00640                 break;
00641         }
00642     }
00643 
00644     // The Browser Preview options have changed.
00645     if (MESSAGE_IS_A(Message, BrowserPrvwChgdMsg))
00646     {
00647         BrowserPrvwChgdMsg *TheMsg = (BrowserPrvwChgdMsg *) Message;
00648 
00649         switch ( TheMsg->State )
00650         {
00651             case BrowserPrvwChgdMsg::PROPERTIES_CHANGED:
00652             {
00653                 // The properties have changed, so update the Browser preview tab.
00654 
00655                 // While Loop flag.
00656                 BOOL FoundPage = FALSE;
00657 
00658                 // Get a ptr to the first tab.
00659                 GIFAnimationPropertyTabs *pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetFirst();
00660 
00661                 // Loop untill we get aptr to the Preview in browser tab.
00662                 while (pGIFAnimationPropertyTabs != NULL && !FoundPage)
00663                 {
00664                     //  Get the page Id.
00665                     CDlgResID PageId = pGIFAnimationPropertyTabs->GetPageID();
00666 
00667                     // For bitmap preview properties changed messages we only update the Browser preview tab.
00668                     if (PageId == _R(IDD_TAB_PREVIEW_IN_BROWSER))
00669                     {
00670                         // Only get the tab to update if it is in use.
00671                         if ( pGIFAnimationPropertyTabs->IsPropertyRequired() )
00672                         {
00673                             // Get that tab to update itself.
00674                             pGIFAnimationPropertyTabs->UpdateLayerSection();
00675 
00676                             // Exit the while loop 
00677                             FoundPage = TRUE;
00678                         }
00679                     }
00680                     // Get the next option's tab.
00681                     pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetNext(pGIFAnimationPropertyTabs);
00682                 }
00683                 break;
00684             }
00685             default:
00686                 break;
00687         }
00688     }
00689 
00690     // Handle messages for the dialog box.
00691     if (IS_OUR_DIALOG_MSG(Message))
00692     {
00693         DialogMsg* Msg = (DialogMsg*)Message;
00694 
00695         MsgResult Result;
00696 
00697         // Main handler for dialog type messages
00698         BOOL EndDialog = FALSE;                                         // TRUE if we should quit the dialog
00699         BOOL CommitValues = FALSE;                                      // TRUE if we should commit the dialog values
00700         /*BOOL OldApplyNow =*/ m_pGIFAnimationProperties->GetApplyNowState();   // Old ApplyNow button state  
00701 
00702         // Make sure that the tabs know what is the current document and spread to work on.
00703         Document *pDocument = Document::GetSelected();
00704         m_pGIFAnimationProperties->SetCurrentDocAndSpread(pDocument);
00705 
00706         // Make sure that the current document units are correct.
00707         m_pGIFAnimationProperties->SetUpDocUnits();
00708             
00709         // Check if sending init/create message and if so set flag True.
00710         // If True then do not ungrey the ApplyNow button on changing messages
00711         if (Msg->DlgMsg == DIM_CREATE)
00712             m_pGIFAnimationProperties->SetInitMessageState(TRUE);               
00713 
00714         // If the message is not for the main winndow then try the tab pages.
00715         BOOL FoundPage = FALSE;
00716 
00717         if (Msg->PageID != 0)
00718         {
00719             //Go through all the tabs declared to the system and see if the message is for that page.
00720             GIFAnimationPropertyTabs *pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetFirst();
00721 
00722             while (pGIFAnimationPropertyTabs != NULL&& !FoundPage)
00723             {
00724                 CDlgResID PageId = pGIFAnimationPropertyTabs->GetPageID();
00725                 if (PageId == Msg->PageID)
00726                 {
00727                     // Found the correct page so stop the search and send the message to that page
00728                     pGIFAnimationPropertyTabs->HandleMsg(Msg);
00729                     FoundPage = TRUE;
00730                 }
00731                 // Get the next tab.
00732                 pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetNext(pGIFAnimationPropertyTabs);                           
00733             }
00734         }   
00735         else
00736         {
00737             // Main page window
00738             switch (Msg->DlgMsg)
00739             {
00740                 case DIM_CREATE:
00741                     if (Msg->DlgMsg == DIM_CREATE)                  
00742                     {
00743                         //  When the dialog first starts up, only the first tab is initialised. When you change a value
00744                         //  on this tab and press ok/apply, this causes problems.
00745                         //  So, make sure that all the tabs are created
00746                         GIFAnimationPropertyTabs *pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetFirst();
00747 
00748                         while (pGIFAnimationPropertyTabs != NULL)
00749                         {
00750                             //  Send the message to the page
00751                             pGIFAnimationPropertyTabs->HandleMsg(Msg);
00752                         
00753                             //  Get the next tab.
00754                             pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetNext(pGIFAnimationPropertyTabs);
00755                         }
00756                     }
00757                     break;
00758 
00759                 case DIM_COMMIT:        
00760                     EndDialog = TRUE;
00761                     CommitValues = TRUE;
00762                 break;
00763 
00764                 case DIM_SOFT_COMMIT:   
00765                 {
00766                     CommitValues = TRUE;
00767                     m_pGIFAnimationProperties->SetApplyNowState(TRUE);
00768                 }
00769                 break;
00770 
00771                 case DIM_CANCEL:        
00772                 {
00773                     EndDialog = TRUE;
00774                 }
00775                 break;
00776 
00777                 default:
00778                     break;
00779                 }
00780             }
00781 
00782         // Commit values here.
00783         if (CommitValues)
00784         {
00785             BOOL ok = CommitDialogValues();
00786             if (!ok)
00787             {
00788                 EndDialog = FALSE;  
00789             }
00790         }
00791 
00792         // Pass the message back to the Base class.
00793         Result = DialogTabOp::Message(Message);
00794 
00795         // End dialog here
00796         if (EndDialog) 
00797         {
00798             // We can only look at static variables here
00799             // Remove the link to the options tabs if all dialogs have been cloosed. 
00800             if(m_pGIFAnimationProperties->GetCount() < 1)
00801             {
00802                 // Make sure that we remove our options tabs link to the dialog box class as the dialog will now be destroyed.
00803                 m_pGIFAnimationProperties->SetTabbedDlg(NULL);
00804             }
00805             return OK;
00806         }
00807         
00808         // Check if we have been sending an init/create message, if so then set the flag False.
00809         if (Msg->DlgMsg == DIM_CREATE)
00810             m_pGIFAnimationProperties->SetInitMessageState(FALSE);              
00811                     
00812         return Result;
00813     }
00814     return DialogTabOp::Message(Message);
00815 }
00816 
00817 /***************************************************************************************************************
00818 
00819   > OpState GIFAnimationPropertyTabsDlg::GetState(String_256*, OpDescriptor*)
00820 
00821     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
00822     Created:    10/06/97
00823     Inputs:     -
00824     Outputs:    -
00825     Returns:    -
00826     Purpose:    GIFAnimationPropertyTabsDlg GetState method.
00827 
00828 ****************************************************************************************************************/
00829 
00830 OpState GIFAnimationPropertyTabsDlg::GetState(String_256*, OpDescriptor*)
00831 {    
00832     OpState OpSt;
00833 
00834     // If the pointer is non-null grey the menu option. 
00835     if (m_pGIFAnimationProperties && m_pGIFAnimationProperties->GetTabbedDlg() != NULL)
00836         OpSt.Greyed = TRUE;
00837     
00838     return(OpSt);
00839 }
00840 
00841 /******************************************************************************************
00842 
00843 >   BOOL GIFAnimationPropertyTabsDlg::Init()
00844 
00845     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
00846     Created:    10/06/97
00847     Inputs:     -
00848     Outputs:    -
00849     Returns:    -
00850     
00851 ******************************************************************************************/
00852 
00853 BOOL GIFAnimationPropertyTabsDlg::Init()
00854 {
00855     BOOL InitOK;
00856 
00857     // Register ourselves with the dialog system.
00858     InitOK = RegisterOpDescriptor(
00859                                 0,                                                          // Tool ID                                                              
00860                                 _R(IDS_ANIMATION_TAB_DLG),                                      // String resource ID
00861                                 CC_RUNTIME_CLASS(GIFAnimationPropertyTabsDlg),              // Runtime class
00862                                 OPTOKEN_GIFANIMPROPERTYTABS,                                // Token string
00863                                 GetState,                                                   // GetState function
00864                                 0,                                                          // help ID
00865                                 0,                                                          // bubble help
00866                                 0, //_R(IDD_BARCONTROLSTORE),                                   // resource ID
00867                                 0, //_R(IDC_BTN_OPTIONSDLG),                                    // control ID
00868                                 SYSTEMBAR_ILLEGAL,                                          // Bar ID
00869                                 TRUE,                                                       // Recieve system messages
00870                                 FALSE,                                                      // Smart duplicate operation
00871                                 TRUE,                                                       // Clean operation
00872                                 0,                                                          // No vertical counterpart
00873                                 _R(IDS_ANIMATION_TAB_DLG_ONE),                                  // String for one copy only error
00874                                 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC)   // Auto state flags
00875                                 );
00876 
00877     // Set up any animation property tabs that are required and get a link to them.
00878     InitOK = InitOK && GIFAnimationPropertyTabs::InitGIFAnimationPropertyTabs();    
00879     m_pGIFAnimationProperties = GIFAnimationPropertyTabs::GetFirst();
00880 
00881     return (InitOK);
00882 }
00883 
00884 
00885 /******************************************************************************************
00886 
00887 >   void GIFAnimationPropertyTabsDlg::Deinit()
00888 
00889     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
00890     Created:    10/06/97
00891     Inputs:     -
00892     Outputs:    -
00893     Returns:    -
00894     
00895 ******************************************************************************************/
00896 
00897 void GIFAnimationPropertyTabsDlg::Deinit()
00898 {
00899     // Remove all options tabs which have been declared to the system.
00900     GIFAnimationPropertyTabs::DeinitGIFAnimationPropertyTabs(); 
00901     m_pGIFAnimationProperties = NULL;
00902 }
00903 
00904 
00905 /******************************************************************************************
00906 
00907 >   void GIFAnimationPropertyTabsDlg::Do(OpDescriptor*)
00908 
00909     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
00910     Created:    10/06/97
00911     Inputs:     -
00912     Outputs:    -
00913     Returns:    -
00914     Purpose:    Creates then opens the dialog in response to a request from the user.
00915     
00916 ******************************************************************************************/
00917 
00918 void GIFAnimationPropertyTabsDlg::Do(OpDescriptor*)
00919 {
00920     BOOL ok = FALSE;
00921 
00922     if (m_pGIFAnimationProperties == NULL)
00923     {
00924         // Could not create the dialog box.
00925         ERROR3("GIFAnimationPropertyTabsDlg::Do no AnimationProperties present");
00926         End();
00927     }
00928 
00929     //Set up the name that the main dialog page will use.
00930     String_256 Temp(_R(IDS_ANIMATION_TAB_DLG)); 
00931     TitleString = Temp;
00932     SetName(&TitleString);
00933     
00934     // Make sure that our options tabs have a link to the dialog box class
00935     GIFAnimationPropertyTabs::SetTabbedDlg(this);
00936 //  m_pGIFAnimationProperties->SetApplyNowState(TRUE);
00937 
00938     // Force the dialog box to be created, as it is non-modal it must be opened if the create works ok.
00939     ok = Create();      
00940 
00941     // Make sure we know the current document and spread to work on.
00942     Document *pDocument = Document::GetSelected();
00943     m_pGIFAnimationProperties->SetCurrentDocAndSpread(pDocument);
00944 
00945     if ( ok )
00946     {
00947         Open(); 
00948 
00949         // Grey out the apply now button. 
00950         m_pGIFAnimationProperties->SetInitMessageState(FALSE);
00951         m_pGIFAnimationProperties->SetApplyNowState(FALSE);
00952         m_pGIFAnimationProperties->GreyApplyNow();      
00953     }
00954     else
00955     {
00956         // Something went wrong!
00957         InformError();              
00958         End();                      
00959     }                   
00960 }
00961 
00962 /******************************************************************************************
00963 
00964 >   BOOL GIFAnimationPropertyTabsDlg::RegisterYourPagesInOrderPlease()
00965 
00966     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
00967     Created:    10/06/97
00968     Inputs:     -
00969     Outputs:    -
00970     Returns:    return TRUE if all calls to AddAPage returned TRUE, else FALSE
00971     Purpose:    This function will get called to give us  a chance to add our 
00972                 pages to the DialogTabOp. 
00973 
00974 ******************************************************************************************/
00975 
00976 BOOL GIFAnimationPropertyTabsDlg::RegisterYourPagesInOrderPlease()
00977 {
00978     BOOL ok = TRUE;
00979 
00980     // Get the first tab.
00981     GIFAnimationPropertyTabs *pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetFirst();
00982 
00983     while (pGIFAnimationPropertyTabs != NULL)
00984     {
00985         if ( pGIFAnimationPropertyTabs->IsPropertyRequired() )
00986         {
00987             CDlgResID PageId = pGIFAnimationPropertyTabs->GetPageID();
00988             ok = ok && AddAPage(PageId);
00989         }
00990 
00991         // Get next.
00992         pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetNext(pGIFAnimationPropertyTabs);
00993     }
00994 
00995     return (ok); 
00996 }
00997 
00998 /******************************************************************************************
00999 
01000 >   GIFAnimationPropertyTabs * GIFAnimationPropertyTabsDlg::GetLayerPropertiesTabs()
01001 
01002     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01003     Created:    10/06/97
01004     Inputs:     -
01005     Outputs:    -
01006     Returns:    Pointer to the animation property tabs handling class.
01007     
01008 ******************************************************************************************/
01009 
01010 GIFAnimationPropertyTabs * GIFAnimationPropertyTabsDlg::GetGIFAnimationPropertiesTabs()
01011 {
01012     return m_pGIFAnimationProperties;
01013 }
01014 
01015 /********************************************************************************************
01016 
01017 >   GIFAnimationPropertyTabs::GIFAnimationPropertyTabs()
01018     
01019     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01020     Created:    10/06/97
01021     Purpose:    Constructor.
01022 
01023 ********************************************************************************************/
01024 
01025 GIFAnimationPropertyTabs::GIFAnimationPropertyTabs()
01026 {
01027     pPropertiesDlg              = NULL;
01028     m_NoFrameLayers             = FALSE;    
01029     m_IgnoreTextChangeMsg       = FALSE;
01030 }
01031 
01032 
01033 /********************************************************************************************
01034 
01035 >   GIFAnimationPropertyTabs::Init()
01036 
01037     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01038     Created:    10/06/97
01039     
01040 ********************************************************************************************/
01041 
01042 BOOL GIFAnimationPropertyTabs::Init()
01043 {
01044     // Do nothing for now.
01045     return TRUE;
01046 }
01047 
01048 /******************************************************************************************/
01049 
01050 /******************************************************************************************/
01051 
01052 #define ADD_LAYERPROPERTY(Classname)                                                \
01053     /* Create, initialise and install the specified tab to the options system */    \
01054     pGIFAnimationProperty = new Classname;                                          \
01055     if (pGIFAnimationProperty == NULL) return FALSE;                                \
01056                                                                                     \
01057     if (!pGIFAnimationProperty->Init())                                             \
01058     {                                                                               \
01059         /* Error occured - report it and stop trying to initialise options tab. */  \
01060         delete pGIFAnimationProperty;                                               \
01061         InformError();                                                              \
01062         return TRUE;                                                                \
01063     }                                                                               \
01064                                                                                     \
01065     GIFAnimationPropertyTabsList.AddTail(pGIFAnimationProperty);
01066 
01067 /********************************************************************************************
01068 
01069 >   BOOL GIFAnimationPropertyTabs::InitGIFAnimationPropertyTabs()
01070 
01071     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01072     Created:    10/06/97
01073     Returns:    TRUE if initialised ok, FALSE if not.
01074     Purpose:    Scans all GIFAnimationPropertyTabs to find out which Tabs are available,
01075                 creates and holds them in a list.
01076 
01077 ********************************************************************************************/
01078 
01079 BOOL GIFAnimationPropertyTabs::InitGIFAnimationPropertyTabs()
01080 {
01081     //Find the Tabs.
01082     GIFAnimationPropertyTabs *pGIFAnimationProperty = NULL;
01083 
01084     ADD_LAYERPROPERTY(FramePropertiesTab)           // Frame Properties tab
01085     ADD_LAYERPROPERTY(AnimationColoursTab)          // Animation colours tab.
01086     ADD_LAYERPROPERTY(AnimationPropertiesTab)       // Animation properties tab                   
01087     ADD_LAYERPROPERTY(PreviewInBrowserTab)          // Preview in Browser tab.
01088 /*  
01089     // Loop variable.
01090     INT32 i = 0;
01091 
01092     // Go through the tabs declared to the system
01093     pGIFAnimationProperty = GIFAnimationPropertyTabs::GetFirst();
01094 
01095     while (pGIFAnimationProperty != NULL)
01096     {
01097         // Include the tab only if it is a document based option.
01098         if ( pGIFAnimationProperty->IsPropertyRequired() )
01099         {
01100             switch (pGIFAnimationProperty->GetPageID())
01101             {
01102                 case _R(IDD_TAB_FRAME_PROPERTIES):
01103                     FramePropertiesTabNumber = i;
01104                     break;
01105                 
01106                 case _R(IDD_TAB_ANIMATION_PROPERTIES):
01107                      AnimationPropertiesTabNumber = i;
01108                     break;                      
01109                     
01110                 case _R(IDD_TAB_ANIMATION_COLOURS):
01111                      AnimationColoursTabNumber = i;
01112                     break;                  
01113                     
01114                 case _R(IDD_TAB_PREVIEW_IN_BROWSER):
01115                      PreviewInBrowserTabNumber = i;
01116                     break;                  
01117         }   
01118             i++ ;
01119         }
01120         // Get the next tab.
01121         pGIFAnimationProperty = GIFAnimationPropertyTabs::GetNext(pGIFAnimationProperty);
01122     }
01123 */
01124     return TRUE;
01125 }   
01126 
01127 /********************************************************************************************
01128 
01129 >   static void GIFAnimationPropertyTabs::DeinitGIFAnimationPropertyTabs()
01130 
01131     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01132     Created:    10/06/97
01133     Purpose:    Destroy all the Tab objects.
01134     
01135 ********************************************************************************************/
01136 
01137 void GIFAnimationPropertyTabs::DeinitGIFAnimationPropertyTabs()
01138 {
01139 //  GIFAnimationPropertyTabs *pGIFAnimationProperty = NULL;
01140 
01141     // Remove all the Tabs.
01142     GIFAnimationPropertyTabsList.DeleteAll();
01143 
01144     return;
01145 }
01146 
01147 /********************************************************************************************
01148 
01149 >   BOOL GIFAnimationPropertyTabs::DeclareGIFAnimationProperty(GIFAnimationPropertyTabs *pGIFAnimationProperty)
01150 
01151     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01152     Created:    10/06/97
01153     Inputs:     A pointer to a new GIFAnimationPropertyTabs class.
01154     Returns:    True if tab declared, False if something went wrong. 
01155     Purpose:    Function to declare a new tab.
01156 
01157 ********************************************************************************************/
01158 
01159 BOOL GIFAnimationPropertyTabs::DeclareGIFAnimationProperty(GIFAnimationPropertyTabs *pGIFAnimationProperty)
01160 {
01161     if (pGIFAnimationProperty == NULL) return FALSE;
01162 
01163     if (!pGIFAnimationProperty->Init())
01164     {
01165         InformError();
01166         return TRUE;
01167     }
01168     GIFAnimationPropertyTabsList.AddTail(pGIFAnimationProperty);
01169     
01170     return TRUE;
01171 }
01172 
01173 /********************************************************************************************
01174 
01175 >   virtual DialogTabOp * GIFAnimationPropertyTabs::GetTabbedDlg()
01176 
01177     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01178     Created:    10/06/97
01179     Returns:    Pointer to the main dialog box used by this GIFAnimationPropertyTabs.       
01180     Purpose:    Let the base class know where the dialog box handling class is.
01181     
01182 ********************************************************************************************/
01183 
01184 DialogTabOp * GIFAnimationPropertyTabs::GetTabbedDlg()
01185 {
01186     // return a pointer to the main dialog box.
01187     return GIFAnimationPropertyTabs::pPropertiesDlg;
01188 }
01189 
01190 /********************************************************************************************
01191 
01192 >   stataic BOOL GIFAnimationPropertyTabs::SetTabbedDlg(DialogTabOp * pDlg)
01193 
01194     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01195     Created:    10/06/97
01196     Returns:    Pointer to the main dialog box used by GIFAnimationPropertyTabs.
01197     
01198 ********************************************************************************************/
01199 
01200 BOOL GIFAnimationPropertyTabs::SetTabbedDlg(DialogTabOp * pDlg)
01201 {
01202     // Return a pointer to the main dialog box.
01203     pPropertiesDlg = pDlg;
01204     
01205     return TRUE;
01206 }
01207 
01208 /********************************************************************************************
01209 
01210 >   static GIFAnimationPropertyTabs *GIFAnimationPropertyTabs::GetFirst()
01211 
01212     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01213     Created:    10/06/97
01214     Returns:    Pointer to the first Tab, or NULL if none.
01215 
01216 ********************************************************************************************/
01217 
01218 GIFAnimationPropertyTabs *GIFAnimationPropertyTabs::GetFirst()
01219 {
01220     return (GIFAnimationPropertyTabs *) GIFAnimationPropertyTabsList.GetHead();
01221 }
01222 
01223 /**************************************************************************************************************************
01224 
01225 >   static GIFAnimationPropertyTabs *GIFAnimationPropertyTabs::GetNext(GIFAnimationropertyTabs *pGIFAnimationPropertyTabs)
01226 
01227     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01228     Created:    10/06/97
01229     Inputs:     pGIFAnimationPropertyTabs - pointer to the GIFAnimationPropertyTabs to be used to get the following
01230                 GIFAnimationPropertyTabs.
01231     Returns:    Pointer to the next GIFAnimationPropertyTabs.
01232 
01233 ***************************************************************************************************************************/
01234 
01235 GIFAnimationPropertyTabs *GIFAnimationPropertyTabs::GetNext(GIFAnimationPropertyTabs *pGIFAnimationPropertyTabs)
01236 {
01237     return (GIFAnimationPropertyTabs *) GIFAnimationPropertyTabsList.GetNext(pGIFAnimationPropertyTabs);
01238 }
01239 
01240 
01241 /********************************************************************************************
01242 
01243 >   virtual BOOL GIFAnimationPropertyTabs::GetApplyNowState() const
01244 
01245     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01246     Created:    10/06/97
01247     Inputs:     -
01248     Outputs:    -
01249     Returns:    The current ApplyNow state, either True or False.
01250 
01251 ********************************************************************************************/
01252 
01253 BOOL GIFAnimationPropertyTabs::GetApplyNowState()
01254 {
01255     return m_ApplyNow;
01256 } 
01257 
01258 /********************************************************************************************
01259 
01260 >   virtual BOOL GIFAnimationPropertyTabs::SetApplyNowState(BOOL NewState)
01261 
01262     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01263     Created:    10/06/97
01264     Inputs:     NewState:- A new ApplyNow flag state.
01265     Outputs:    -
01266     Returns:    The old ApplyNow state, either True or False.
01267     Purpose:    Allows the setting of a new ApplyNow state.
01268     
01269 ********************************************************************************************/
01270 
01271 BOOL GIFAnimationPropertyTabs::SetApplyNowState(BOOL NewState)
01272 {
01273     //BOOL OldState = m_ApplyNow;       // Note current old state.
01274 
01275     if (!m_InitMessage)
01276         m_ApplyNow = NewState;      // Set up the required new state.   
01277 
01278     //return OldState;              // return old state. 
01279     return m_ApplyNow;
01280 }
01281 
01282 /********************************************************************************************
01283 
01284 >   BOOL GIFAnimationPropertyTabs::GetInitMessageState() const
01285 
01286     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01287     Created:    10/06/97
01288     Inputs:     -
01289     Outputs:    -
01290     Returns:    The current ApplInitMessageyNow state as either True or False.
01291     
01292 ********************************************************************************************/
01293 
01294 BOOL GIFAnimationPropertyTabs::GetInitMessageState()
01295 {
01296     return m_InitMessage;
01297 } 
01298 
01299 /********************************************************************************************
01300 
01301 >   virtual BOOL GIFAnimationPropertyTabs::SetInitMessageState(BOOL NewState)
01302 
01303     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01304     Created:    10/06/97
01305     Inputs:     New InitMessage state.
01306     Outputs:    -
01307     Returns:    The old InitMessage state as either True or False.
01308     Purpose:    Allows the setting of a new InitMessage state.
01309     
01310 ********************************************************************************************/
01311 
01312 BOOL GIFAnimationPropertyTabs::SetInitMessageState(BOOL NewState)
01313 {
01314     BOOL OldState = m_InitMessage;      // Note current old state.
01315 
01316     m_InitMessage = NewState;           // Set up the required new state.
01317     
01318     return OldState;                    // Return the old state.
01319 }
01320 
01321 /******************************************************************************************
01322 
01323 >   CDlgResID GIFAnimationPropertyTabs::GetPageID()()
01324 
01325     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01326     Created:    10/06/97
01327     Inputs:     -
01328     Outputs:    -
01329     Returns:    The dialog ID of this tab section.    
01330 
01331 ******************************************************************************************/
01332 
01333 CDlgResID GIFAnimationPropertyTabs::GetPageID()
01334 {
01335     return 0;
01336 }
01337 
01338 /******************************************************************************************
01339 
01340 >   BOOL GIFAnimationPropertyTabs::CommitSection()
01341 
01342     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01343     Created:    10/06/97
01344     Inputs:     -
01345     Outputs:    -
01346     Returns:    True if values in dialog box ok, False otherwise.     
01347                                 
01348 ******************************************************************************************/
01349 
01350 BOOL GIFAnimationPropertyTabs::CommitSection()
01351 {
01352     return TRUE;
01353 }
01354 
01355 /********************************************************************************************
01356 
01357 >   BOOL GIFAnimationPropertyTabs::HandleMsg(DialogMsg* Msg)
01358 
01359     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01360     Created:    10/06/97
01361     Inputs:     -
01362     Outputs:    -
01363     Returns:    -
01364     Purpose:    Handles all the messages for this property tab.
01365                 
01366 ********************************************************************************************/
01367 
01368 BOOL GIFAnimationPropertyTabs::HandleMsg(DialogMsg* Msg)
01369 {
01370     return TRUE;
01371 }  
01372 
01373 /******************************************************************************************
01374 
01375 >   BOOL GIFAnimationPropertyTabs::InitSection()
01376 
01377     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01378     Created:    10/06/97
01379     Inputs:     -
01380     Outputs:    -
01381     Returns:    TRUE if successful, else FALSE.
01382         
01383 ******************************************************************************************/
01384 
01385 BOOL GIFAnimationPropertyTabs::InitSection()
01386 {
01387     return TRUE;
01388 }  
01389 
01390 
01391 /******************************************************************************************
01392 
01393 >   BOOL AnimationPropertiesTabs::SameflDelayValues()
01394 
01395     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01396     Created:    10/06/97
01397     Inputs:     -
01398     Outputs:    -
01399     Returns:    TRUE if all the frame layers have the same delay value, else FALSE.
01400     
01401 ******************************************************************************************/
01402 
01403 BOOL GIFAnimationPropertyTabs::SameflDelayValues()
01404 {
01405     BOOL NumOfLayers = 0;           // The number of frame layers in the current sperad.
01406     INT32 i = 0;                        // loop variable.
01407     BOOL SameDelayValues = TRUE;    // Flag to indicate whether all the frame layer delay values are the same.
01408     Layer* pLayer = NULL;           // Ptr to the frame/active layer.
01409     m_NoFrameLayers = FALSE;    
01410     
01411     // Get a ptr to the first frame layer.
01412     pLayer = pSpread->FindFirstFrameLayer();
01413 
01414     // Check for a NULL ptr.
01415     if(!pLayer)
01416     {
01417         // If this is a new default document, then a NULL frame layer will be returned.
01418         // In that case get a ptr to the first layer.
01419         pLayer = pSpread->FindFirstLayer();
01420 
01421         // Again, check for a NULL ptr.
01422         if(!pLayer)
01423             return FALSE;
01424         else
01425             m_NoFrameLayers = TRUE;     // At this moment there are no frame layers.
01426     }
01427 
01428     // How many frame layers do we have.
01429     while (pLayer)
01430     {
01431         // How many layers do we have?
01432         if(m_NoFrameLayers)
01433         {
01434             pLayer = pLayer->FindNextLayer();
01435             NumOfLayers++;
01436         }
01437         else
01438         {
01439             // How many frame layers do we have?
01440             pLayer = pLayer->FindNextFrameLayer();
01441 
01442             NumOfLayers++;
01443         }
01444     }
01445     
01446     // If there is a single layer, then return TRUE, since then there is only a single delay value.
01447     if(NumOfLayers == 1)
01448         return TRUE;
01449 
01450     // Create a temporary buffer to store all the layer delay values.
01451     DWORD *pDelay = new DWORD[NumOfLayers];
01452 
01453     // Error check.
01454     if(!pDelay)
01455         return FALSE;   // Failed to allocate the memory.
01456     
01457     // If there are frame layers, get the first frame layer.
01458     if(!m_NoFrameLayers)
01459         pLayer = pSpread->FindFirstFrameLayer();
01460     else
01461         pLayer = pSpread->FindFirstLayer();
01462 
01463     // Error check.
01464     if(!pLayer)
01465         return FALSE;   // Failed to allocate the memory.
01466 
01467     // In the buffer make a note of all the frame layer delay values.
01468     while (pLayer)
01469     {
01470         // Get the delay value for this layer.
01471         pDelay[i++] = pLayer->GetFrameDelay();
01472 
01473         // If there are frame layers, get the next frame layer.
01474         if(!m_NoFrameLayers)
01475             pLayer = pLayer->FindNextFrameLayer();
01476         else
01477             pLayer = pLayer->FindNextLayer();
01478     }
01479 
01480     // Compare all the frame layer delay values.
01481     for(i=0; i<NumOfLayers; i++)
01482     {
01483         for(INT32 n=0; n<NumOfLayers; n++)
01484         {
01485             if (pDelay[i] != pDelay[n])
01486             {
01487                 // If the delay values differ, set this flag to false.
01488                 SameDelayValues = FALSE;        
01489             }
01490         }
01491     }
01492     // Delete the buffer.
01493     delete [] pDelay;
01494     
01495     // Return the flag value.
01496     return SameDelayValues;
01497 }
01498 
01499 
01500 
01501 
01502 
01503                 /********************************************************************************/
01504                 /**********************                                     *********************/
01505                 /**********************     Class:- AnimationColoursTab     *********************/
01506                 /**********************                                     *********************/
01507                 /********************************************************************************/  
01508 
01509 
01510 
01511 
01512 
01513 
01514 /********************************************************************************************
01515 
01516 >   AnimationColoursTab::AnimationColoursTab() 
01517 
01518 
01519     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01520     Created:    10/06/97
01521     Inputs:     -   
01522     Outputs:    -
01523     Returns:    -
01524     Purpose:    AnimationColoursTab constructor.
01525     
01526 ********************************************************************************************/
01527 
01528 AnimationColoursTab::AnimationColoursTab()
01529 {   
01530     // Does nothing at present.
01531 }            
01532 
01533 /********************************************************************************************
01534 
01535 >   AnimationColoursTab::~AnimationColoursTab()
01536 
01537 
01538     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01539     Created:    10/06/97
01540     Inputs:     -
01541     Outputs:    -
01542     Returns:    -
01543     Purpose:    AnimationColoursTab destructor.
01544 
01545 ********************************************************************************************/
01546                                                                                 
01547 AnimationColoursTab::~AnimationColoursTab()
01548 {   
01549     // Does nothing at present.
01550 }        
01551 
01552 /********************************************************************************************
01553 
01554 >   BOOL AnimationColoursTab::Init()
01555 
01556 
01557     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01558     Created:    10/06/97
01559     Inputs:     -
01560     Outputs:    -
01561     Returns:    True if initialised ok, False if failed.
01562     
01563 ********************************************************************************************/
01564                                                                                 
01565 BOOL AnimationColoursTab::Init()
01566 {   
01567     return TRUE;
01568 }        
01569 
01570 /******************************************************************************************
01571 
01572 >   CDlgResID AnimationColoursTab::GetPageID()()
01573 
01574     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01575     Created:    10/06/97
01576     Inputs:     -
01577     Outputs:    -
01578     Returns:    The dialog ID of this tab section.    
01579     
01580 ******************************************************************************************/
01581 
01582 CDlgResID AnimationColoursTab::GetPageID()
01583 {
01584     return _R(IDD_TAB_ANIMATION_COLOURS);
01585 }
01586 
01587 /******************************************************************************************
01588 
01589 >   BOOL AnimationColoursTab::IsPropertyRequired()
01590 
01591     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01592     Created:    10/06/97
01593     Returns:    Returns True if this tab is a program option.     
01594     
01595 ******************************************************************************************/
01596 
01597 BOOL AnimationColoursTab::IsPropertyRequired()
01598 {
01599     //  If the dialog has been invoked via the options button on the Export dialog box,
01600     //  then hide this tab.
01601     if (GetBrowserPreviewTab())
01602         return FALSE;
01603     else
01604         return TRUE;    // This tab is required     
01605 }
01606 
01607 
01608 /******************************************************************************************
01609 
01610 >   BOOL AnimationColoursTab::CommitSection()
01611 
01612     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01613     Created:    10/06/97
01614     Inputs:     -
01615     Outputs:    -
01616     Returns:    True if values in dialog box ok, False otherwise.     
01617     Purpose:    Takes the values in the Animation colours tab. 
01618                 Called when ok or apply now is pressed on the main dialog box.
01619 
01620 ******************************************************************************************/
01621 
01622 BOOL AnimationColoursTab::CommitSection()
01623 {
01624     ERROR2IF(pPropertiesDlg == NULL,FALSE,"animationColoursTab::CommitSection called with a NULL dialog pointer");
01625 
01626     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
01627     if (!ok)
01628         return TRUE;            
01629 
01630     // Have any animation colour properties changed?
01631     if (pSpread && HavePropertiesChanged())
01632     {
01633         PALETTE_COLOURS PalCols;            // Browser/Optimized palette.
01634         WEB_PALETTE     WebPal;             // Global/Local palette.    
01635         DITHER          Dither;             // Current dither type.
01636         DWORD           CurNumColsInPal;    // The current number of colours in the palette.
01637         BOOL            Transparency;   // Whether or not we're transparent.
01638 
01639         // Find the specified Palette type.
01640         if (pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAME_GLOBALBROWSER)))
01641         {
01642             PalCols =   PALCOL_BROWSER;
01643             WebPal  =   PAL_GLOBAL;     
01644         }
01645         else if (pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAME_GLOBALOPTIMISED)))
01646         {
01647             WebPal  = PAL_GLOBAL;
01648             PalCols = PALCOL_OPTIMIZED;     
01649         }
01650         else if(pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAME_LOCALOPT)))
01651         {
01652             WebPal  = PAL_LOCAL;
01653             PalCols = PALCOL_OPTIMIZED;     
01654         }
01655 
01656         // Find the specified Dither type.
01657         if (pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAME_DIFFUSION)))
01658             Dither = XARADITHER_ERROR_DIFFUSION;
01659 
01660         else if (pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAME_ORDDITHER)))
01661             Dither = XARADITHER_ORDERED_GREY;
01662         
01663         else if (pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAME_NODITHER)))
01664             Dither = XARADITHER_NONE;
01665 
01666         // Find the specified number of colours in the palette.
01667         BOOL Valid = FALSE;
01668         CurNumColsInPal = pPropertiesDlg->GetLongGadgetValue(_R(IDC_FRAME_NUMCOLOURS), 2, 256, 0,&Valid);
01669 
01670         // If invalid input, display error message.
01671         if (!Valid)
01672         {
01673             String_256 ErrMsg;
01674             ErrMsg.MakeMsg(_R(IDS_BMPPREFS_NUMCOLSWRONG),2,256);
01675             Error::SetError(0,ErrMsg,0);
01676             InformError();
01677 
01678             return FALSE;
01679         }
01680 
01681         // Find out whether we're transparent or not.
01682         Transparency = pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAME_TRANSPARENCY));
01683 
01684 PORTNOTE("other", "Remove FrameSGallery");
01685 #ifndef EXCLUDE_FROM_XARALX
01686         // Check that all visible layers are actually frame layers
01687         FrameSGallery::EnsureFrameLayerIntegrity(pSpread);
01688 #endif
01689         // Set the new animation colour prefterences in the spread.
01690         pSpread->SetAnimationColours( Dither, WebPal, PalCols, CurNumColsInPal, Transparency);
01691 
01692         // Mark all the frame layers as edited.
01693         Layer* pLayer = pSpread->FindFirstFrameLayer();
01694 
01695         while (pLayer != NULL)
01696         {
01697             // Mark this layer as edited.
01698             pLayer->SetEdited(TRUE);
01699 
01700             // Move to the next frame layer in the spread.
01701             pLayer = pLayer->FindNextFrameLayer();
01702         }               
01703 
01704         // Mark the document as edited.
01705         // Get a ptr to the current document.
01706         Document* pDoc = Document::GetCurrent();
01707 
01708         // Set this document as edited.
01709         if(pDoc)
01710             pDoc->SetModified(TRUE);
01711         
01712         // Is the animation playing.
01713         if (PreviewDialog::GetPreviewDialog())
01714         {
01715             // Stop the animation and regenerate our frames.
01716             //PreviewDialog::SetAnimationPropertiesChanged(TRUE);
01717 
01718             // Invoke the op.
01719             OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_FRAME_GRABALLFRAMES); 
01720             if (pOpDesc != NULL)
01721                 pOpDesc->Invoke();
01722             else
01723             {
01724                 ERROR3("Couldn't find OPTOKEN_FRAME_GRABALLFRAMES op descriptor");
01725             }
01726         }
01727     }
01728 
01729     // Everything ok.
01730     return TRUE;
01731 }
01732 
01733 /********************************************************************************************
01734 
01735 >   BOOL AnimationColoursTab::GreySection()
01736 
01737     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01738     Created:    10/06/97
01739     Inputs:     -
01740     Outputs:    -
01741     Returns:    -
01742     Purpose:    Called when the user has closed all documents.
01743 
01744 ********************************************************************************************/
01745 
01746 BOOL AnimationColoursTab::GreySection()
01747 {
01748     ERROR2IF(pPropertiesDlg == NULL,FALSE,"AnimationcoloursTab::GreySection called with no dialog pointer");
01749 
01750     //Ensure we are talking to the correct page.
01751     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
01752     if (!ok)
01753         return TRUE;
01754 
01755     // Only update if we are not already grey. 
01756     if (m_GreyStatus == TRUE)
01757         return TRUE;
01758 
01759     // Set the correct state of the controls.
01760     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_GLOBALBROWSER),   FALSE);
01761     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_GLOBALOPTIMISED), FALSE);
01762     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_LOCALOPT),        FALSE);
01763     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_NUMCOLOURS),      FALSE);
01764     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_NODITHER),        FALSE);
01765     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_ORDDITHER),       FALSE);
01766     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_DIFFUSION),       FALSE);
01767     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_TRANSPARENCY),    FALSE);
01768 
01769     // Call the central greying/ungreying function
01770     ok = ChangeControlStatus(FALSE);    
01771     
01772     // Set the correct grey status
01773     m_GreyStatus = TRUE;
01774     SetApplyNowState(FALSE);
01775     
01776     // Everything ok.
01777     return ok;
01778 } 
01779 
01780 /********************************************************************************************
01781 
01782 >   BOOL AnimationColoursTab::UngreySection()
01783 
01784     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01785     Created:    10/06/97
01786     Inputs:     -
01787     Outputs:    -
01788     Returns:    -
01789     Purpose:    Called when the user has selected a new document.
01790 
01791 ********************************************************************************************/
01792 
01793 BOOL AnimationColoursTab::UngreySection()
01794 {
01795     ERROR2IF(pPropertiesDlg == NULL,FALSE,"AnimationColoursTab::UngreySection called with a NULL dialog pointer");
01796 
01797     // Ensure we are talking to the correct page.
01798     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
01799     if (!ok)
01800         return TRUE;
01801 
01802     // Only update if we are not already ungrey. 
01803     if (m_GreyStatus == FALSE)
01804         return TRUE;
01805 
01806     // Set the correct state of the controls.
01807     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_GLOBALBROWSER),   TRUE);
01808     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_GLOBALOPTIMISED), TRUE);
01809     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_LOCALOPT),        TRUE);
01810     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_NUMCOLOURS),      TRUE);
01811     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_NODITHER),        TRUE);
01812     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_ORDDITHER),       TRUE);
01813     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_DIFFUSION),       TRUE);
01814     pPropertiesDlg->EnableGadget(_R(IDC_FRAME_TRANSPARENCY),    TRUE);
01815 
01816     // Call the central greying/ungreying function
01817     ok = ChangeControlStatus(TRUE); 
01818     
01819     m_GreyStatus = FALSE;
01820 
01821     return ok;
01822 }
01823 
01824 /********************************************************************************************
01825 
01826 >   BOOL AnimationColoursTab::ChangeControlStatus(const BOOL Status)
01827 
01828     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01829     Created:    10/06/97
01830     Inputs:     -
01831     Outputs:    -
01832     Returns:    -
01833     Purpose:    Called to grey/ungrey all controls on this tab. 
01834 
01835 ********************************************************************************************/
01836 
01837 
01838 BOOL AnimationColoursTab::ChangeControlStatus(const BOOL Status)
01839 {
01840     
01841     // Grey the apply now/ok/cancel buttons.
01842     AnimationColoursTab::GreyApplyNow();
01843     
01844     return TRUE;
01845 }           
01846 
01847 
01848 /********************************************************************************************
01849 
01850 >   BOOL AnimationColoursTab::UpdateSection()
01851 
01852     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01853     Created:    10/06/97
01854     Returns:    -
01855     Purpose:    Called when we have switched to a new document and need to update all the 
01856                 controls on this tab. 
01857     
01858 ********************************************************************************************/
01859 
01860 BOOL AnimationColoursTab::UpdateSection()
01861 {
01862     ERROR2IF(pPropertiesDlg == NULL,FALSE,"AnimationColoursTab::UpdateSection called with a NULL dialog pointer");
01863 
01864     // Ensure we talk to the correct page.
01865     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
01866     if (!ok)
01867         return TRUE;        
01868 
01869     // Show the correct details.
01870     ShowDetails();
01871 
01872     return TRUE;
01873 }
01874 
01875 /********************************************************************************************
01876 
01877 >   BOOL AnimationColoursTab::ShowDetails()
01878 
01879     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01880     Created:    10/06/97
01881     Inputs:     -
01882     Outputs:    -
01883     Returns:    -
01884     Purpose:    Shows the details of the associated SPREAD in this tab.
01885     
01886 ********************************************************************************************/
01887 
01888 BOOL AnimationColoursTab::ShowDetails()
01889 {
01890     ERROR2IF(pPropertiesDlg == NULL,FALSE,"AnimationColoursTab::ShowDetails called with a NULL dialog pointer");
01891 
01892     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
01893     if (!ok)
01894         return TRUE;        
01895 
01896     if (pSpread != NULL)
01897     {
01898         // Ignore all DIM_TEXT_CHANGED msgs which are sent from this function.
01899         SetIgnoreTextChangeMsg(TRUE);
01900 
01901         // Retrieve the Animation details for the current spread.
01902         AnimPropertiesParam* pParam = &pSpread->GetSpreadAnimPropertiesParam();
01903 
01904         if(pParam)
01905         {
01906             // Set the correct dithering.
01907             DITHER Dither = pParam->GetDither();    
01908 
01909             switch(Dither)
01910             {
01911                 case XARADITHER_NONE:
01912                 {
01913                     // Select the no dither radio button.
01914                     pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_NODITHER),TRUE);
01915     
01916                     // The remaining dither radio buttons should not be selected.
01917                     pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_ORDDITHER),FALSE);
01918                     pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_DIFFUSION),FALSE);
01919                 }
01920                 break;
01921 
01922                 case XARADITHER_ORDERED_GREY:
01923                 {
01924                     // Select the ordered dither radio button.
01925                     pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_ORDDITHER),TRUE);
01926 
01927                     // The remaining dither radio buttons should not be selected.
01928                     pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_DIFFUSION),FALSE);
01929                     pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_NODITHER),FALSE);
01930                 }
01931                 break;
01932 
01933                 case XARADITHER_ERROR_DIFFUSION:
01934                 {
01935                     // Select the error diffusion radio button.
01936                     pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_DIFFUSION),TRUE);                    
01937 
01938                     // The remaining dither radio buttons should not be selected.
01939                     pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_NODITHER),FALSE);
01940                     pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_ORDDITHER),FALSE);
01941                 }
01942                 break;
01943                 default:
01944                 {
01945                     // Select the ordered dither radio button.
01946                     pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_ORDDITHER),TRUE);                        
01947 
01948                     // The remaining dither radio buttons should not be selected.
01949                     pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_DIFFUSION),FALSE);
01950                     pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_NODITHER),FALSE);
01951                 }
01952                 break;
01953             }
01954 
01955             // Set the correct transparency setting.
01956             pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_TRANSPARENCY), pParam->GetIsBackGroundTransp());
01957 
01958             // Set the correct Palette details.
01959             PALETTE_COLOURS PalCols = pParam->GetPaletteCols();     // Palette colours.
01960             WEB_PALETTE WebPal = pParam->GetPalette();              // Palette type.    
01961             BOOL Optimized = FALSE;                                 // Has the optimized palette switch been selected.
01962             BOOL GlobalBrowserPalette = FALSE;                      // Is the gloab browser palette option selected.
01963             
01964             // Global Browser Palette.
01965             if(WebPal == PAL_GLOBAL && PalCols == PALCOL_BROWSER)
01966             {
01967                 // Select the global browser pallette radio button.
01968                 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_GLOBALBROWSER),TRUE);
01969                 GlobalBrowserPalette = TRUE;
01970 
01971                 // The remaining radio buttons should not be selected.
01972                 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_GLOBALOPTIMISED),FALSE);
01973                 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_LOCALOPT),FALSE);                
01974             }
01975             
01976             // Global Optimized Palette.
01977             if(WebPal == PAL_GLOBAL && PalCols == PALCOL_OPTIMIZED)
01978             {
01979                 // Select the Global Optimized Palette.
01980                 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_GLOBALOPTIMISED),TRUE);
01981                 Optimized = TRUE;
01982                 
01983                 // The remaining radio buttons should not be selected.
01984                 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_GLOBALBROWSER),FALSE);
01985                 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_LOCALOPT),FALSE);                
01986             }
01987             
01988             // Optimized Palette.
01989             if(WebPal == PAL_LOCAL && PalCols == PALCOL_OPTIMIZED)
01990             {
01991                 //Select the Optimized Palette.
01992                 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_LOCALOPT),TRUE);
01993                 Optimized = TRUE;
01994 
01995                 // The remaining radio buttons should not be selected.
01996                 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_GLOBALBROWSER),FALSE);
01997                 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_GLOBALOPTIMISED),FALSE);
01998             }
01999 
02000             // If the palette is optimized grey out the ordered dither switch.
02001             if(Optimized)
02002             {
02003                 // Grey the ordered dither switch.
02004                 pPropertiesDlg->EnableGadget(_R(IDC_FRAME_ORDDITHER),FALSE);
02005 
02006                 // Ungrey the 'Number of colours in Palette' editable field.
02007                 pPropertiesDlg->EnableGadget(_R(IDC_FRAME_NUMCOLOURS), TRUE);
02008 
02009                 // If the ordered dither option was selected, select the error diffusion option.
02010                 if(Dither == XARADITHER_ORDERED_GREY)
02011                     pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_DIFFUSION),TRUE);
02012             }
02013 
02014             // Set the correct "Number of colours in Palette" editable field.
02015             // If the 'Global browser palette' switch is selected, then the "Number of colours in palette" editable field is greyed.
02016             if(GlobalBrowserPalette)
02017             {
02018                 DWORD NumColsInPalette = pParam->GetNumColsInPalette();
02019                 pPropertiesDlg->SetLongGadgetValue(_R(IDC_FRAME_NUMCOLOURS), NumColsInPalette);
02020                 pPropertiesDlg->EnableGadget(_R(IDC_FRAME_NUMCOLOURS), FALSE);
02021             }
02022             else
02023             {
02024                 DWORD NumColsInPalette = pParam->GetNumColsInPalette();
02025                 pPropertiesDlg->SetLongGadgetValue(_R(IDC_FRAME_NUMCOLOURS), NumColsInPalette);
02026             }
02027         }
02028     }
02029 
02030     // We once again wish to deal with DIM_TEXT_CHANGED msgs.
02031     SetIgnoreTextChangeMsg(FALSE);
02032 
02033     // Set the controls to the correct state. 
02034     ChangeControlStatus(!m_GreyStatus);
02035     return TRUE;
02036 }
02037 
02038 /*************************************************************************************************************************
02039 
02040 >   BOOL AnimationColoursTab::UpdateLayerSection()
02041 
02042     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02043     Created:    10/06/97
02044     Inputs:     -
02045     Outputs:    -
02046     Returns:    TRUE if ok, FALSE otherwise
02047     Purpose:    Called when the spread-related section of the tab should be updated.
02048 
02049 ***************************************************************************************************************************/
02050 BOOL AnimationColoursTab::UpdateLayerSection()
02051 {
02052     ERROR2IF(pPropertiesDlg == NULL,FALSE,"AnimationColoursTab::UpdateLayerSection() called with a NULL dialog pointer");
02053 
02054     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
02055     if (!ok)
02056         return TRUE;    
02057 
02058     // Display the details in this tab.
02059     ShowDetails();
02060         
02061     // Everything ok.
02062     return TRUE;
02063 }
02064 
02065 /********************************************************************************************
02066 
02067 >   BOOL AnimationColoursTab::HandleMsg(DialogMsg* Msg)
02068 
02069     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02070     Created:    10/06/97
02071     Inputs:     -
02072     Outputs:    -
02073     Returns:    -
02074     Purpose:    Handles all the messages for this Animation colours tab.
02075 
02076 ********************************************************************************************/
02077 
02078 BOOL AnimationColoursTab::HandleMsg(DialogMsg* Msg)
02079 {
02080     ERROR2IF(Msg == NULL,FALSE,"AnimationColoursTab::Message null message received");
02081     ERROR2IF(pPropertiesDlg == NULL,FALSE,"AnimationColoursTab::HandleMsg called with a NULL dialog pointer");
02082 
02083     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
02084     if (!ok)
02085         return TRUE;    
02086 
02087     switch(Msg->DlgMsg)
02088     {
02089         case DIM_CREATE:        
02090             m_GreyStatus = FALSE;   
02091             ok = InitSection();
02092             if (!ok)
02093                 InformError();
02094             break;
02095 
02096         case DIM_LFT_BN_CLICKED:
02097         {
02098             HavePropertiesChanged();
02099 
02100             // Set the correct state of the applynow flag.
02101             AnimationColoursTab::SetApplyNowState(TRUE);
02102 
02103             // Ungrey the apply/ok/cancel buttons.
02104             AnimationColoursTab::UngreyApplyNow();
02105         }   
02106         break;
02107 
02108         case DIM_SELECTION_CHANGED: 
02109         {
02110             if(AnimationColoursTab::GetApplyNowState())
02111             {
02112                 // Ungrey the apply/ok/cancel buttons.
02113                 AnimationColoursTab::UngreyApplyNow();
02114             }
02115         }
02116         break;
02117 
02118         case DIM_TEXT_CHANGED:
02119         {
02120             // Do we want to deal with text change msgs?
02121             if(!GetIgnoreTextChangeMsg())
02122             {
02123                 // Have the animation properties changed?
02124                 if(HavePropertiesChanged())
02125                 {
02126                     AnimationColoursTab::SetApplyNowState(TRUE);
02127 
02128                     // Ungrey the apply/ok/cancel buttons.
02129                     AnimationColoursTab::UngreyApplyNow();
02130                 }
02131             }
02132         }
02133         break;
02134 
02135         case DIM_SET_ACTIVE:
02136         {
02137             if(AnimationColoursTab::GetApplyNowState())
02138             {
02139                 // Ungrey the apply/ok/cancel buttons.
02140                 AnimationColoursTab::UngreyApplyNow();
02141             }
02142         }
02143         break;
02144 
02145         default:
02146             break;
02147     }
02148     return TRUE;
02149 }  
02150 
02151 /**********************************************************************************************
02152 
02153 >   BOOL AnimationColoursTab::UpdateApplyState()
02154 
02155     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02156     Created:    10/06/97
02157     Inputs:     -
02158     Outputs:    -
02159     Returns:    TRUE if ok, FALSE otherwise
02160     Purpose:    This changes the 'Apply now' state based on the settings of the active spread
02161                 and the settings in this tab.
02162                 If the settings are the same, the 'Apply state' is FALSE, else it is TRUE.
02163     
02164 ************************************************************************************************/
02165 
02166 BOOL AnimationColoursTab::UpdateApplyState()
02167 {
02168     ERROR2IF(pPropertiesDlg == NULL,FALSE,"animationColoursTab::CommitSection called with a NULL dialog pointer");
02169 /*
02170     // Ensure we talk ot the correct page.
02171     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
02172     if (!ok)
02173         return TRUE;
02174 
02175     // Have the properties for this tab changed.
02176     if (pSpread != NULL)
02177         AnimationColoursTab::SetApplyNowState(HavePropertiesChanged());
02178 
02179     // The new state for the 'Apply/ok/Cancel' buttons.
02180     BOOL NewApplyNowState = AnimationColoursTab::GetApplyNowState();
02181 
02182     // If the properties for this tab have changed, then ungrey the apply now button.
02183     if (NewApplyNowState || GetCurrentApplyNow())
02184     {
02185             // Ungrey the apply/ok/cancel buttons.
02186             AnimationColoursTab::UngreyApplyNow();
02187     }
02188 */  
02189     // Everything ok.
02190     return TRUE;
02191 }
02192 
02193 /*************************************************************************************************************************
02194 
02195 >   BOOL AnimationColoursTab::HavePropertiesChanged()
02196 
02197     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02198     Created:    10/06/97
02199     Inputs:     -
02200     Outputs:    -
02201     Returns:    TRUE if settings in the dlg are different to those in the spread else FALSE.
02202     
02203 ****************************************************************************************************************************/
02204 
02205 BOOL AnimationColoursTab::HavePropertiesChanged()
02206 {
02207     ERROR2IF(pPropertiesDlg == NULL,FALSE,"animationColoursTab::HavePropertiesChanged called with a NULL dialog pointer");
02208 
02209     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
02210     if (!ok)
02211         return TRUE;
02212 
02213     // Get the current details from animation colours tab.
02214 
02215     PALETTE_COLOURS CurPalCols;                         // Browser/Optimized palette.
02216     WEB_PALETTE     CurWebPal;                          // Global/Local palette.    
02217     DWORD           CurNumColsInPal         = 256;      // The current number of colours in the palette.
02218     BOOL            Global_Browser_Palette  = FALSE;    // Has the Global browser palette switch been selected.
02219     BOOL            Optimized               = FALSE;    // Has the optimized palette switch been selected.
02220     UINT32          CurPaletteType          = 0;        // The current palette type.
02221     UINT32          PaletteType             = 0;        // The palette type stored in the current spread.
02222 
02223 
02224     // Find the selected palette type.
02225     // Global Browser
02226     if (pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAME_GLOBALBROWSER)))
02227     {
02228         CurPalCols      =   PALCOL_BROWSER;
02229         CurWebPal       =   PAL_GLOBAL;
02230         CurPaletteType  =   1;
02231         Global_Browser_Palette = TRUE;
02232     }
02233     // Global Optimized
02234     else if (pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAME_GLOBALOPTIMISED)))
02235     {
02236         CurWebPal       = PAL_GLOBAL;
02237         CurPalCols      = PALCOL_OPTIMIZED;
02238         Optimized       = TRUE;     
02239         CurPaletteType  = 2;
02240         Global_Browser_Palette = FALSE;
02241     }
02242     // Local Optimized
02243     else if(pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAME_LOCALOPT)))
02244     {
02245         CurWebPal       = PAL_LOCAL;
02246         CurPalCols      = PALCOL_OPTIMIZED;
02247         Optimized       = TRUE;
02248         CurPaletteType  = 3;
02249         Global_Browser_Palette = FALSE;
02250     }
02251 
02252     // If the 'Global browser palette' switch is selected, then the 'Number of colours in palette' editable field is greyed.
02253     if(Global_Browser_Palette)
02254         pPropertiesDlg->EnableGadget(_R(IDC_FRAME_NUMCOLOURS), FALSE);
02255     else
02256         // Ungrey the 'Number of colours in Palette' editable field.
02257         pPropertiesDlg->EnableGadget(_R(IDC_FRAME_NUMCOLOURS), TRUE);
02258 
02259     //Find the 'Number of colours in palette' setting.
02260     CurNumColsInPal = pPropertiesDlg->GetLongGadgetValue(_R(IDC_FRAME_NUMCOLOURS), 0, 256, _R(IDS_BMPPREFS_INVALIDDELAY) ,NULL);
02261 
02262     // Get the current dither type.
02263     DITHER CurDither = XARADITHER_NONE;
02264     if (pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAME_DIFFUSION)))
02265         CurDither = XARADITHER_ERROR_DIFFUSION;
02266 
02267     else if (pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAME_ORDDITHER)))
02268         CurDither = XARADITHER_ORDERED_GREY;
02269         
02270     else if (pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAME_NODITHER)))
02271         CurDither = XARADITHER_NONE;
02272     
02273     // If the palette is optimized grey out the ordered dither option.
02274     if(Optimized)
02275     {
02276         pPropertiesDlg->EnableGadget(_R(IDC_FRAME_ORDDITHER),FALSE);
02277 
02278         // If the ordered dither option was selected, select the error diffusion option.
02279         if(CurDither == XARADITHER_ORDERED_GREY)
02280             pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAME_DIFFUSION),TRUE);
02281             pPropertiesDlg->SetLongGadgetValue(_R(IDC_FRAME_ORDDITHER), FALSE);         
02282     }
02283     else
02284         pPropertiesDlg->EnableGadget(_R(IDC_FRAME_ORDDITHER),TRUE);
02285 
02286     // Get the background transparency setting.
02287     BOOL CurTransparency = pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAME_TRANSPARENCY));
02288 
02289     // Retrieve the Animation details for the CURRENT spread.
02290     AnimPropertiesParam* pParam = &pSpread->GetSpreadAnimPropertiesParam();
02291 
02292     ERROR2IF(pParam == NULL,FALSE,"AnimationColoursTab::HavePropertiesChanged makes reference to a NULL ptr!");
02293 
02294     // Get the dither type for the current spread.
02295     DITHER Dither = pParam->GetDither();
02296 
02297     // Get the transparency setting for the current spread.
02298     BOOL Transparency = pParam->GetIsBackGroundTransp();
02299 
02300     // Get the palette type for the current spread.
02301     PALETTE_COLOURS PalCols = pParam->GetPaletteCols();
02302     WEB_PALETTE WebPal = pParam->GetPalette();
02303 
02304     // Set the correct palette type.
02305     if(PalCols == PALCOL_BROWSER && WebPal == PAL_GLOBAL)
02306         PaletteType = 1;
02307         
02308     else if(PalCols == PALCOL_OPTIMIZED && WebPal == PAL_GLOBAL)
02309         PaletteType = 2;
02310             
02311     else if(PalCols ==  PALCOL_OPTIMIZED && WebPal == PAL_LOCAL)
02312         PaletteType = 3;
02313     
02314     // Get the number of colours in the palette  for the current spread.
02315     DWORD NumColsInPal = pParam->GetNumColsInPalette();
02316 
02317     // Compare the new preferences to those stored in the spread.
02318     return
02319         ((CurDither      != Dither)         ||
02320         (CurTransparency != Transparency)   ||
02321         (CurPaletteType  != PaletteType)    ||
02322         (CurNumColsInPal != NumColsInPal));         
02323 }
02324 
02325 /******************************************************************************************
02326 
02327 >   BOOL AnimationColoursTab::InitSection()
02328 
02329     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02330     Created:    10/06/97
02331     Inputs:     -
02332     Outputs:    -
02333     Returns:    TRUE if successful, else FALSE
02334     Purpose:    Sets initial values for this tab on the animation properties dialog box.
02335 
02336 ******************************************************************************************/
02337 
02338 BOOL AnimationColoursTab::InitSection()
02339 {
02340     ERROR2IF(pPropertiesDlg == NULL,FALSE,"AnimationColoursTab::InitSection called with a NULL dialog pointer");
02341 
02342     // Get a ptr to the current document.
02343     Document* pDoc = Document::GetCurrent();
02344 
02345     // If there is no document, then grey the tab.
02346     if(!pDoc)
02347     {
02348         GreySection();
02349         return (TRUE);
02350     }
02351 
02352     ShowDetails();
02353     return TRUE;
02354 }
02355 
02356 
02357 
02358 
02359                 /********************************************************************************/
02360                 /**********************                                     *********************/
02361                 /**********************     Class:- AnimationPropertiesTab  *********************/
02362                 /**********************                                     *********************/
02363                 /*********************************************************************************/
02364 
02365 
02366 
02367 
02368 
02369 /********************************************************************************************
02370 
02371 >   AnimationPropertiesTab::AnimationPropertiesTab() 
02372 
02373 
02374     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02375     Created:    10/06/97
02376     Inputs:     -   
02377     Outputs:    -
02378     Returns:    -
02379     Purpose:    AnimationPropertiesTab constructor. 
02380 
02381 ********************************************************************************************/
02382 
02383 AnimationPropertiesTab::AnimationPropertiesTab()
02384 {       
02385 }            
02386 
02387 /********************************************************************************************
02388 
02389 >   AnimationPropertiesTab::~AnimationPropertiesTab()
02390 
02391 
02392     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02393     Created:    10/06/97
02394     Inputs:     -
02395     Outputs:    -
02396     Returns:    -
02397     Purpose:    AnimationPropertiesTab destructor
02398 
02399 ********************************************************************************************/
02400                                                                                 
02401 AnimationPropertiesTab::~AnimationPropertiesTab()
02402 {       
02403 }        
02404 
02405 /********************************************************************************************
02406 
02407 >   BOOL AnimationPropertiesTab::Init()
02408 
02409 
02410     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02411     Created:    10/06/97
02412     Inputs:     -
02413     Outputs:    -
02414     Returns:    True if initialised ok, False if failed.
02415     Purpose:    AnimationPropertiesTab init routine.
02416     
02417 ********************************************************************************************/
02418                                                                                 
02419 BOOL AnimationPropertiesTab::Init()
02420 {   
02421     return TRUE;
02422 }        
02423 
02424 /******************************************************************************************
02425 
02426 >   CDlgResID AnimationPropertiesTab::GetPageID()()
02427 
02428     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02429     Created:    10/06/97
02430     Inputs:     -
02431     Outputs:    -
02432     Returns:    The dialog ID of this tab section.    
02433     Purpose:    Allows the options dialog code to determine the dialog ID of this section.
02434     
02435 ******************************************************************************************/
02436 
02437 CDlgResID AnimationPropertiesTab::GetPageID()
02438 {
02439     return _R(IDD_TAB_ANIMATION_PROPERTIES);
02440 }
02441 
02442 /******************************************************************************************
02443 
02444 >   BOOL AnimationPropertiesTab::IsPropertyRequired()
02445 
02446     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02447     Created:    10/06/97
02448     Returns:    Returns True if this tab is a program option.     
02449     Purpose:    Allows the Animation properties to determine if this tab is required.
02450 
02451 ******************************************************************************************/
02452 
02453 BOOL AnimationPropertiesTab::IsPropertyRequired()
02454 {
02455     //  If the dialog has been invoked via the options button on the Export dialog box,
02456     //  then hide this tab.
02457     if (GetBrowserPreviewTab())
02458         return FALSE;
02459     else
02460         return TRUE;    // This tab is required         
02461 }
02462 
02463 
02464 /**********************************************************************************************************************
02465 
02466 >   BOOL AnimationPropertiesTab::CommitSection()
02467 
02468     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02469     Created:    10/06/97
02470     Inputs:     -
02471     Outputs:    -
02472     Returns:    True if values in dialog the box are ok, False otherwise.     
02473     Purpose:    Takes the values in this tab of the Animation properties dialog box.
02474                 Called when ok or apply is clicked on the main dialog box.
02475     
02476 **************************************************************************************************************************/
02477 
02478 BOOL AnimationPropertiesTab::CommitSection()
02479 {
02480     ERROR2IF(pPropertiesDlg == NULL,FALSE,"AnimationPropertiesTab::CommitSection called with a NULL dialog pointer");
02481 
02482     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
02483     if (!ok)
02484         return TRUE;        
02485 
02486     // Only do the op if we have a layer with a different set of properties.
02487     if (pSpread && HavePropertiesChanged(TRUE))
02488     {
02489         // Retrieve the values from the animation properties tab dialog.
02490         DWORD   Delay = 0;
02491         BOOL    DelayValid = FALSE;
02492         BOOL    LoopValid   = FALSE;
02493         BOOL    PropertiesChanged = FALSE;  // Flag to indicate that the properties have changed and the new entries are valid.
02494 
02495         BOOL    Loop_Continously = pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_ANIMOPTS_LOOP));
02496         DWORD   Loop  = pPropertiesDlg->GetLongGadgetValue(_R(IDC_ANIMOPTS_ITERATIONS), 0, 65535, _R(IDS_BMPPREFS_INVALIDLOOP) ,&LoopValid);
02497                 
02498         // If the loop is invalid, return FALSE.
02499         if(!LoopValid)
02500             return FALSE;
02501         
02502         // Only check the delay edit field value if "Many" is not currently displayed.
02503         if(!m_IsManyDisplayed)
02504             Delay = pPropertiesDlg->GetLongGadgetValue(_R(IDC_ANIMTAB_DELAY), 0, 65535, _R(IDS_BMPPREFS_INVALIDDELAY) ,&DelayValid);
02505 
02506         // The GetLongGadgetValue function returns a Zero delay value when nothing is displayed 
02507         // in the 'Display each frame for:' edit field, we should therefore display a zero value.
02508         if(Delay == 0 && !m_IsManyDisplayed)
02509             pPropertiesDlg->SetLongGadgetValue(_R(IDC_ANIMTAB_DELAY), 0);   
02510 
02511         // If the delay is invalid, return FALSE.
02512         if(!DelayValid && !m_IsManyDisplayed)
02513             return FALSE;
02514 
02515         // If the 'Loop Continously' check box is ticked, then set the loop value to zero.
02516         if(Loop_Continously)
02517             Loop = 0;
02518 
02519 PORTNOTE("other", "Remove FrameSGallery");
02520 #ifndef EXCLUDE_FROM_XARALX
02521         // Check that all visible layers are actually frame layers.
02522         FrameSGallery::EnsureFrameLayerIntegrity(pSpread);
02523 #endif
02524         // Pass the new loop value to the spread.
02525         pSpread->SetAnimationLoop(Loop);
02526 
02527         //If we get this far, then the animation details have changed and the new entries are valid.
02528         PropertiesChanged = TRUE;
02529 
02530         // If 'Many' is not displayed, then pass on our new delay value.
02531         if(!m_IsManyDisplayed)
02532         {
02533             // Pass the new delay value to the spread.
02534             pSpread->SetAnimationDelay(Delay);
02535 
02536             // This is a global delay value, therefore, set this value in the frame layer and associated OILbitmap.
02537             SetGlobalDelay(pSpread, Delay);
02538         }
02539             
02540         //  If the Preview dialog is open, regenerate all the bitmaps in the animation.
02541         if (PreviewDialog::GetPreviewDialog())
02542         {
02543             // Make sure the preview dialog is not in a greyed state.
02544             // Get our static pointer to the Preview Dialog.
02545             PreviewDialog* pPreviewDlg = PreviewDialog::GetPreviewDialog();
02546 
02547             // Check, for a NULL ptr.
02548             if(pPreviewDlg)
02549             {
02550                 // If the dlg is not in a greyed state, invoke the OP.
02551                 if(!pPreviewDlg->GetDlgState()) 
02552                 {
02553                     // Invoke the op.
02554                     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_FRAME_GRABALLFRAMES); 
02555                     if (pOpDesc != NULL)
02556                         pOpDesc->Invoke();
02557                     else
02558                     {
02559                         ERROR3("Couldn't find OPTOKEN_FRAME_GRABALLFRAMES op descriptor");
02560                     }
02561                 }
02562             }
02563         }
02564         
02565         // Update the display information in frame gallery.
02566         Layer* pLayer = pSpread->FindFirstFrameLayer();
02567         while (pLayer != NULL)
02568         {
02569             // This is just as a double check
02570             if (!pLayer->IsBackground() && !pLayer->IsGuide() &&
02571                 !pLayer->IsPageBackground())
02572             {
02573                 // Tell the frame gallery to update its display of the frame
02574                 BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::REDRAW_LAYER));
02575             }
02576 
02577             // Move to the next frame layer in the animation
02578             pLayer = pLayer->FindNextFrameLayer();
02579         }               
02580         // Update the information in the frame properties tab.
02581         // Find the active layer.
02582         pLayer = pSpread->FindActiveLayer();
02583 
02584         // Boradcast the message.
02585         BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::UPDATE_ACTIVE_LAYER));          
02586 
02587         //The new delay entry is valid.
02588         PropertiesChanged = TRUE;
02589         
02590         // If the animation properties have changed and the new entries are valid, mark the doc. as modified.
02591         if(PropertiesChanged)
02592         {
02593             // Get a ptr to the current document.
02594             Document* pDoc = Document::GetCurrent();
02595 
02596             // Set this document as edited.
02597             if(pDoc)
02598                 pDoc->SetModified(TRUE);            
02599         }
02600     }
02601     // If the delay value for any particular frame layer has changed, then we may need to 
02602     // alter the value displayed in the 'Display each frame for' edit field.
02603     if(GetFrameDelayValueChanged())
02604     {
02605         // At this point check to ensure the 'Display each frame for' edit field is displaying the correct value.
02606         if(SameflDelayValues())
02607         {
02608             // All the frame layers have the same delay value.
02609             // Take the delay value from the first layer.
02610             // Get a ptr to the first layer.
02611             Layer* pLayer = pSpread->FindFirstLayer();
02612 
02613             // Ensure we have valid spread and Layer pointers.
02614             if (pSpread && pLayer) 
02615             {
02616                 // Get the delay value for the frame layer.
02617                 DWORD GlobalDelay = pLayer->GetFrameDelay();
02618 
02619                 // Set this frame layer delay value as the new global delay value.
02620                 pSpread->SetAnimationDelay(GlobalDelay);
02621 
02622                 // Display this value in the delay edit field for this tab.
02623                 pPropertiesDlg->SetLongGadgetValue(_R(IDC_ANIMTAB_DELAY), pLayer->GetFrameDelay()); 
02624             }
02625         }
02626         else
02627         {
02628             // The delay values differ, display "MANY" in the delay edit field.
02629             pPropertiesDlg->SetStringGadgetValue(_R(IDC_ANIMTAB_DELAY), _R(IDS_MANY));
02630         }   
02631 
02632         // We have taken all the neccessary actions, so set this this flag back to false.
02633         SetFrameDelayValueChanged(FALSE);   
02634     }
02635 
02636     // Everything ok!
02637     return TRUE;
02638 }
02639 
02640 /***********************************************************************************************************
02641 
02642 >   BOOL AnimationPropertiesTab::SetGlobalDelay(Spread* pSpread, DWORD Delay)
02643 
02644     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02645     Created:    10/06/97
02646     Inputs:     pSpread:-   A ptr to the currenT spread.
02647                 Delay:-     The delay value to store in the layer/OiLBitmap.
02648     Outputs:    -
02649     Returns:    TRUE if successful, else false.
02650     Purpose:    The delay value in the animation properties tab has changed.  
02651                 This is a global value therefore set this value in the frame layer and associated OILbitmap.
02652         
02653 ***************************************************************************************************************/
02654 
02655 BOOL AnimationPropertiesTab::SetGlobalDelay(Spread *pSpread, DWORD Delay)
02656 {
02657     ERROR2IF(pSpread == NULL,FALSE,"AnimationPropertiesTab::SetGlobalDelay called with NULL Spread pointer");
02658 
02659     // Get a ptr to the first frame layer.
02660     Layer* pLayer = pSpread->FindFirstFrameLayer();
02661     
02662     if(!pLayer)
02663         return FALSE;   // No frame layer.
02664 
02665     // Iterate through the list of layers.
02666     while (pLayer)
02667     {
02668         // Get the kernel bitmap associated with this frame layer. 
02669         // It might be the generated one
02670         KernelBitmap* pKernelBitmap = pLayer->GetGeneratedBitmap();
02671         // or if not present, may be a referenced one, i.e. single node bitmap on the layer
02672         if (pKernelBitmap == NULL)
02673             pKernelBitmap = pLayer->GetReferencedBitmap();
02674 
02675         // Is there a bitmap on this layer?
02676         if(pKernelBitmap != NULL)
02677         {
02678             // Get the OILBitmap assciated with this kernel bitmap.
02679             OILBitmap* pOILBitmap = pKernelBitmap->GetActualBitmap();
02680             if (pOILBitmap == NULL)
02681                 return FALSE;
02682 
02683             // Set the delay value in the OILBitmap.
02684             pOILBitmap->SetBitmapAnimDelay(Delay);
02685         }
02686 
02687         // Set the delay value in the layer.
02688         pLayer->SetFrameDelay(Delay);
02689     
02690         // Get the next frame layer.
02691         pLayer = pLayer->FindNextFrameLayer();
02692     }
02693     
02694     return TRUE;
02695 }
02696 
02697 
02698 
02699 /***************************************************************************************************************
02700 
02701 >   BOOL AnimationPropertiesTab::GreySection()
02702 
02703     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02704     Created:    10/06/97
02705     Inputs:     -
02706     Outputs:    -
02707     Returns:    -
02708     Purpose:    Called when all documents have been closed.
02709     
02710 ********************************************************************************************/
02711 
02712 BOOL AnimationPropertiesTab::GreySection()
02713 {
02714     ERROR2IF(pPropertiesDlg == NULL,FALSE,"animationPropertiesTab::GreySection called with no dialog pointer");
02715 
02716     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
02717     if (!ok)
02718         return TRUE;    
02719 
02720     // Only update if we are not already grey 
02721     if (m_GreyStatus == TRUE)
02722         return TRUE;
02723 
02724     // Set the correct control status.
02725     pPropertiesDlg->EnableGadget(_R(IDC_ANIMOPTS_ITERATIONS),   FALSE);
02726     pPropertiesDlg->EnableGadget(_R(IDC_ANIMOPTS_LOOP),         FALSE);
02727     pPropertiesDlg->EnableGadget(_R(IDC_ANIMTAB_DELAY),         FALSE);
02728 
02729     // Call our central greying/ungreying function
02730     ok = ChangeControlStatus(FALSE);
02731     
02732     m_GreyStatus = TRUE;
02733     SetApplyNowState(FALSE);
02734 
02735     return ok;
02736 } 
02737 
02738 /********************************************************************************************
02739 
02740 >   BOOL AnimationPropertiesTab::UngreySection()
02741 
02742     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02743     Created:    10/06/97
02744     Inputs:     -
02745     Outputs:    -
02746     Returns:    -
02747     Purpose:    Called when a new document has been selected.
02748     
02749 ********************************************************************************************/
02750 
02751 BOOL AnimationPropertiesTab::UngreySection()
02752 {
02753     ERROR2IF(pPropertiesDlg == NULL,FALSE,"animationpropertiseTab::UngreySection called with no dialog pointer");
02754 
02755     // Ensure we are talking to the correct page.
02756     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());  
02757     if (!ok)
02758         return TRUE;    
02759 
02760     // Only update if we are not already ungrey 
02761     if (m_GreyStatus == FALSE)
02762         return TRUE;
02763 
02764     // Set the correct control status.
02765     pPropertiesDlg->EnableGadget(_R(IDC_ANIMOPTS_ITERATIONS),   TRUE);
02766     pPropertiesDlg->EnableGadget(_R(IDC_ANIMOPTS_LOOP),         TRUE);
02767     pPropertiesDlg->EnableGadget(_R(IDC_ANIMTAB_DELAY),         TRUE);
02768 
02769     // Call our central greying/ungreying function
02770     ok = ChangeControlStatus(TRUE);
02771     
02772     // Set the correct control grey status.
02773     m_GreyStatus = FALSE;
02774 
02775     return ok;
02776 }
02777 
02778 /********************************************************************************************
02779 
02780 >   BOOL AnimationPropertiesTab::ChangeControlStatus(const BOOL Status)
02781 
02782     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02783     Created:    10/06/97
02784     Inputs:     -
02785     Outputs:    -
02786     Returns:    -
02787     Purpose:    Called to grey/ungrey all controls on this tab. 
02788 
02789 ********************************************************************************************/
02790 
02791 BOOL AnimationPropertiesTab::ChangeControlStatus(const BOOL Status)
02792 {
02793     // Grey the apply/ok/cancel buttons.
02794     AnimationPropertiesTab::GreyApplyNow();
02795         
02796     return TRUE;
02797 }           
02798 
02799 /****************************************************************************************************************
02800 
02801 >   BOOL AnimationPropertiesTab::UpdateSection()
02802 
02803     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02804     Created:    10/06/97
02805     Returns:    -
02806     Purpose:    Called when we have switched to a new document and need to update all the 
02807                 controls on this tab.           
02808     
02809 ******************************************************************************************************************/
02810 
02811 BOOL AnimationPropertiesTab::UpdateSection()
02812 {
02813     ERROR2IF(pPropertiesDlg == NULL,FALSE,"animationPropertiesTab::UpdateSection called with no dialog pointer");
02814 
02815     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
02816     if (!ok)
02817         return TRUE;    
02818 
02819     // Display the details for this tab.
02820     ShowDetails();
02821         
02822     // Everythig ok.
02823     return TRUE;
02824 }
02825 
02826 /********************************************************************************************
02827 
02828 >   BOOL AnimationPropertiesTab::ShowDetails()
02829 
02830     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02831     Created:    10/06/97
02832     Inputs:     -
02833     Outputs:    -
02834     Returns:    -
02835     Purpose:    Shows the details of the associated spread in this tab.
02836     
02837 ********************************************************************************************/
02838 
02839 BOOL AnimationPropertiesTab::ShowDetails()
02840 {
02841     ERROR2IF(pPropertiesDlg == NULL,FALSE,"animationpropertiseTab::ShowDetails called with no dialog pointer");
02842 
02843     // Ensure we talk to the correct page.
02844     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
02845     if (!ok)
02846         return TRUE;        
02847     
02848     // Ensure we have a valid spread ptr.
02849     if (pSpread)
02850     {
02851         // Ignore all DIM_TEXT_CHANGED msgs which are sent from this function.
02852         SetIgnoreTextChangeMsg(TRUE);
02853 
02854         // Retrieve the Animation details for the current spread.
02855         AnimPropertiesParam* pParam = &pSpread->GetSpreadAnimPropertiesParam();
02856         
02857         if(pParam)
02858         {
02859             // Do all the frame layers have the same delay value.
02860             if(SameflDelayValues())
02861             {
02862                 // No frame layers exist.
02863                 if(m_NoFrameLayers) 
02864                 {
02865                     // Take the delay value from the first layer.
02866                     Layer* pLayer = pSpread->FindFirstLayer();
02867                     if (pLayer)
02868                     {
02869                         // Get the delay value for the frame layer.
02870                         DWORD GlobalDelay = pLayer->GetFrameDelay();
02871 
02872                         // Set this frame layer delay value as the new global delay value.
02873                         pSpread->SetAnimationDelay(GlobalDelay);
02874 
02875                         // Display this value in the delay edit field for this tab.
02876                         pPropertiesDlg->SetLongGadgetValue(_R(IDC_ANIMTAB_DELAY), pLayer->GetFrameDelay()); 
02877                     }
02878 
02879                 }
02880                 else
02881                 {
02882                     // If yes, then Set the numeric value in the "Display each frame for" edit field.
02883                     // Take the delay value from the first frame layer, since all the layers have the same delay value.
02884                     Layer* pLayer = pSpread->FindFirstFrameLayer();
02885                     if (pLayer)
02886                     {
02887 PORTNOTE("other", "Remove FrameSGallery");
02888 #ifndef EXCLUDE_FROM_XARALX
02889                         // Check that all visible layers are actually frame layers
02890                         FrameSGallery::EnsureFrameLayerIntegrity(pSpread);
02891 #endif
02892                         // Get the delay value for the frame layer.
02893                         DWORD GlobalDelay = pLayer->GetFrameDelay();
02894 
02895                         // Set this frame layer delay value as the new global delay value.
02896                         pSpread->SetAnimationDelay(GlobalDelay);
02897 
02898                         // Display this value in the delay edit field for this tab.
02899                         pPropertiesDlg->SetLongGadgetValue(_R(IDC_ANIMTAB_DELAY), pLayer->GetFrameDelay()); 
02900                     }               
02901                 }
02902             }
02903             else
02904             {
02905                 // The delay values differ, display "MANY" in the delay edit field.
02906                 pPropertiesDlg->SetStringGadgetValue(_R(IDC_ANIMTAB_DELAY), _R(IDS_MANY));                                                  
02907             }
02908 
02909             // Now Set the "Loop for" details.
02910             DWORD Loop = pParam->GetAnimLoop();
02911 
02912             // If the Loop value is zero, grey the loop edit field and check the loop cont. field.
02913             if(Loop == 0)
02914             {
02915                 // Set a value of 1 in the field as zero is a bad value to display
02916                 pPropertiesDlg->SetLongGadgetValue(_R(IDC_ANIMOPTS_ITERATIONS), 1);
02917                 pPropertiesDlg->EnableGadget(_R(IDC_ANIMOPTS_ITERATIONS), FALSE);
02918                 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_ANIMOPTS_LOOP), TRUE);
02919             }
02920             else
02921             {
02922                 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_ANIMOPTS_LOOP), FALSE);
02923                 pPropertiesDlg->SetLongGadgetValue(_R(IDC_ANIMOPTS_ITERATIONS), Loop);
02924             }
02925         }
02926     }
02927 
02928     // We once again wish to deal with DIM_TEXT_CHANGED msgs.
02929     SetIgnoreTextChangeMsg(FALSE);
02930 
02931     // Set the controls to the correct state. 
02932     ChangeControlStatus(!m_GreyStatus);
02933 
02934     // Everything ok.
02935     return TRUE;
02936 }
02937 
02938 /**************************************************************************************************************************
02939 
02940 >   BOOL AnimationPropertiesTab::UpdateLayerSection()
02941 
02942     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02943     Created:    10/06/97
02944     Inputs:     -
02945     Outputs:    -
02946     Returns:    TRUE if ok, FALSE otherwise
02947     Purpose:    Called when the spread-related section of the tab should be updated.
02948 
02949 ***************************************************************************************************************************/
02950 
02951 BOOL AnimationPropertiesTab::UpdateLayerSection()
02952 {
02953     ERROR2IF(pPropertiesDlg == NULL,FALSE,"AnimationPropertiesTab::UpdateLayerSection() called with a NULL dialog pointer");
02954 
02955     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
02956     if (!ok)
02957         return TRUE;    
02958 
02959     // Display the details for this tab.
02960     ShowDetails();
02961     
02962     // Everything OK.
02963     return TRUE;
02964 }
02965 
02966 /********************************************************************************************
02967 
02968 >   BOOL AnimationPropertiesTab::HandleMsg(DialogMsg* Msg)
02969 
02970     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
02971     Created:    10/06/97
02972     Inputs:     -
02973     Outputs:    -
02974     Returns:    -
02975     Purpose:    Handles all the messages for this animation property tab.
02976     
02977 ********************************************************************************************/
02978 
02979 BOOL AnimationPropertiesTab::HandleMsg(DialogMsg* Msg)
02980 {
02981     ERROR2IF(Msg == NULL,FALSE,"AnimationPropertiesTab::Message Null message received");
02982     ERROR2IF(pPropertiesDlg == NULL,FALSE,"AnimationPropertiesTab::HandleMsg called with no dialog pointer");
02983 
02984     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
02985     if (!ok)
02986         return TRUE;
02987 
02988     // Get this tab to update itself. Send it an active layer has changed msg.
02989     //Layer* pNewActiveLayer = pSpread->FindActiveLayer();
02990     switch(Msg->DlgMsg)
02991     {
02992         case DIM_CREATE:    
02993         {
02994             m_GreyStatus = FALSE;   
02995             ok = InitSection();
02996             // Grey the apply/ok/cancel buttons.
02997             AnimationPropertiesTab::GreyApplyNow();
02998             if (!ok)
02999                 InformError();
03000         }
03001         break;
03002 
03003         case DIM_LFT_BN_CLICKED:
03004         {
03005             if(Msg->GadgetID == _R(IDC_ANIMOPTS_LOOP))
03006             {
03007                 // If the "Loop continously" control box is ticked, grey the "Loop" ed field.
03008                 BOOL Value = pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_ANIMOPTS_LOOP));
03009                 if (Value)
03010                     pPropertiesDlg->EnableGadget(_R(IDC_ANIMOPTS_ITERATIONS), FALSE);
03011                 else
03012                     pPropertiesDlg->EnableGadget(_R(IDC_ANIMOPTS_ITERATIONS), TRUE);                                
03013             }
03014 
03015             AnimationPropertiesTab::SetApplyNowState(TRUE);
03016 
03017             // Ungrey the apply/ok/cancel buttons.
03018             AnimationPropertiesTab::UngreyApplyNow();
03019         }
03020         break;
03021 
03022         case DIM_SELECTION_CHANGED:
03023         {
03024             if(AnimationPropertiesTab::GetApplyNowState())
03025             {
03026                 // Grey the apply/ok/cancel buttons.
03027                 AnimationPropertiesTab::UngreyApplyNow();
03028             }
03029         }
03030         break;
03031 
03032         case DIM_TEXT_CHANGED:
03033         {
03034             // Do we want to deal with text change msgs?
03035             if(!GetIgnoreTextChangeMsg())
03036             {
03037                 // Have the animation properties changed?
03038                 if(HavePropertiesChanged())
03039                 {
03040                     // Set the correct state of the m_ApplyNow flag.
03041                     AnimationPropertiesTab::SetApplyNowState(TRUE);
03042 
03043                     // Grey the apply/ok/cancel buttons.
03044                     AnimationPropertiesTab::UngreyApplyNow();
03045 
03046                     // Force the m_FrameDelayValueChanged flag to FALSE.
03047                     SetFrameDelayValueChanged(FALSE);
03048                 }
03049             }
03050         }
03051         break;
03052 
03053         case DIM_SET_ACTIVE:
03054         {
03055             if(AnimationPropertiesTab::GetApplyNowState())
03056             {
03057                 // Grey the apply/ok/cancel buttons.
03058                 AnimationPropertiesTab::UngreyApplyNow();
03059             }
03060         }
03061         break;
03062 
03063         default:
03064             break;
03065     }   
03066     return TRUE;
03067 }  
03068 
03069 /***********************************************************************************************************************
03070 
03071 >   BOOL AnimationPropertiesTab::UpdateApplyState()
03072 
03073     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03074     Created:    10/06/97
03075     Inputs:     -
03076     Outputs:    -
03077     Returns:    TRUE if ok, FALSE otherwise
03078     Purpose:    This changes the 'Apply now' state based on the settings of the active layer
03079                 and the settings in this tab.
03080                 If the settings are the same, the 'Apply state' is FALSE, else it is TRUE.
03081     
03082 **************************************************************************************************************************/
03083 
03084 BOOL AnimationPropertiesTab::UpdateApplyState()
03085 {
03086     ERROR2IF(pPropertiesDlg == NULL,FALSE,"animationColoursTab::CommitSection called with a NULL dialog pointer");
03087 /*
03088     // Ensure we talk to the correct page.
03089     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
03090     if (!ok)
03091         return TRUE;
03092 
03093     // Have the properties for this tab changed.
03094     if (pSpread != NULL)
03095         AnimationPropertiesTab::SetApplyNowState(HavePropertiesChanged());
03096 
03097     // The new state for the 'Apply/ok/Cancel' buttons.
03098     BOOL NewApplyNowState = AnimationPropertiesTab::GetApplyNowState();
03099 
03100     // If the properties for this tab have changed, then un grey the apply now button.
03101     if (NewApplyNowState  || GetCurrentApplyNow())
03102     {
03103         // Ungrey the apply/ok/cancel buttons.
03104         AnimationPropertiesTab::UngreyApplyNow();
03105     }
03106     else
03107     {
03108         // Grey the apply/ok/cancel buttons.
03109         AnimationPropertiesTab::GreyApplyNow();
03110     }
03111 */
03112     // Everything ok.
03113     return TRUE;
03114 }
03115 
03116 /***********************************************************************************************************************
03117 
03118 >   BOOL AnimationPropertiesTab::HavePropertiesChanged()
03119 
03120     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03121     Created:    10/06/97
03122     Inputs:     ValidateDelayValue - Flag to determine when we need to validate the delay value.
03123                 Defaults to false.
03124     Outputs:    -
03125     Returns:    TRUE if settings in the dlg are different to the given layer's settings, else FALSE.
03126     Purpose:    Central place for comparing settings in the dlg against the settings of a Spread
03127     
03128 *************************************************************************************************************************/
03129 
03130 BOOL AnimationPropertiesTab::HavePropertiesChanged(BOOL ValidateDelayValue)
03131 {
03132     ERROR2IF(pPropertiesDlg == NULL,FALSE,"AnimationPropertiessTab::CommitSection called with a NULL dialog pointer");
03133 
03134     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
03135     if (!ok)
03136         return TRUE;
03137 
03138 //  BOOL UseLocalFrameDelayValues = FALSE;  // Flag to determine whether local frame delay values are being used.
03139     UINT32 CurrentDelay = 0;                    //Current delay setting in the animation properties tab. 
03140 
03141     // Retrieve the details stored in the current spread.
03142     AnimPropertiesParam* pParam = &pSpread->GetSpreadAnimPropertiesParam();
03143          
03144     // Get the delay/loop values.
03145     DWORD Loop  = pParam->GetAnimLoop();
03146     DWORD Delay = pParam->GetGlobalAnimDelay();
03147 
03148     // Retreive the current delay/Loop details from the dlg.
03149     BOOL    CurrentLoop_Continously = pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_ANIMOPTS_LOOP));
03150     DWORD   CurrentLoop  = pPropertiesDlg->GetLongGadgetValue(_R(IDC_ANIMOPTS_ITERATIONS), 0, 65535, _R(IDS_BMPPREFS_INVALIDLOOP) ,NULL);
03151         
03152     // If "Many" is displayed in the "Delay for" edit field, then we do not want to read the value.
03153     String_256 StrDelay = pPropertiesDlg->GetStringGadgetValue(_R(IDC_ANIMTAB_DELAY), NULL);
03154     INT32 result = camStrnicmp(StrDelay, _T("Many"), 4);
03155             
03156     // Is 'Many' displayed in the delay edit field?
03157     if(result == 0)
03158     {
03159         // Set the flag to TRUE.
03160         m_IsManyDisplayed = TRUE;               
03161 
03162         // Bug fix. 'Many' is displayed in the edit field.
03163         // However, the global delay value is still set to a specific value e.g. 20cs.
03164         // Therefore, if the user sets a new global delay value, and specifies it as say 20cs,
03165         // we then perceive that no change has occurred. Therefore, force the delay value to
03166         // a value greater than 65535.
03167         pSpread->SetAnimationDelay(65536);
03168 
03169         // 'Many' is displayed, therefore set the Current Delay value to the value stored in the spread.
03170         CurrentDelay = Delay;
03171     }
03172     else
03173     {
03174         // 'Many' is not displayed, therefore set the flag to FALSE.
03175         m_IsManyDisplayed = FALSE;
03176 
03177         // Do we want to validate the delay input.
03178         if(ValidateDelayValue)
03179         {
03180             // Get the current delay input.
03181             BOOL DelayValid = FALSE;
03182             CurrentDelay = pPropertiesDlg->GetLongGadgetValue(_R(IDC_ANIMTAB_DELAY), 0, 65535, _R(IDS_BMPPREFS_INVALIDDELAY) ,&DelayValid);
03183 
03184             // If the delay value is invalid, then go no further!
03185             if(!DelayValid)
03186                 return FALSE;
03187         }
03188         else
03189         {
03190             // Get the current delay input.
03191             CurrentDelay = pPropertiesDlg->GetLongGadgetValue(_R(IDC_ANIMTAB_DELAY), 0, 65535, _R(IDS_BMPPREFS_INVALIDDELAY) ,NULL);
03192         }
03193     }
03194 
03195     // If this switch has been ticked, then set the current loop to a zero value.
03196     if(CurrentLoop_Continously)
03197         CurrentLoop = 0;
03198 
03199     // Compare the current values, against those stored in the spread.
03200     return ((CurrentDelay   != Delay)   || 
03201             (CurrentLoop    != Loop));  
03202 }
03203 
03204 /******************************************************************************************
03205 
03206 >   BOOL AnimationPropertiesTab::InitSection()
03207 
03208     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03209     Created:    10/06/97
03210     Inputs:     -
03211     Outputs:    -
03212     Returns:    TRUE if successful, else FALSE
03213     Purpose:    Sets initial values for this tab on the Animation properties dialog box.
03214 
03215 ******************************************************************************************/
03216 
03217 BOOL AnimationPropertiesTab::InitSection()
03218 {
03219     ERROR2IF(pPropertiesDlg == NULL,FALSE,"AnimationPropertiesTab::InitSection called with no dialog pointer");
03220 
03221     // Get a ptr to the current document.
03222     Document* pDoc = Document::GetCurrent();
03223 
03224     // If there is no document, then grey the tab.
03225     if(!pDoc)
03226     {
03227         GreySection();
03228         return (TRUE);
03229     }
03230 
03231     ShowDetails();
03232 
03233     return TRUE;
03234 }
03235 
03236 
03237 
03238 
03239 
03240                 /********************************************************************************/
03241                 /**********************                                     *********************/
03242                 /**********************     Class:- FramePropertiesTab      *********************/
03243                 /**********************                                     *********************/
03244                 /********************************************************************************/  
03245 
03246 
03247 
03248 
03249 /********************************************************************************************
03250 
03251 >   FramePropertiesTab::FramePropertiesTab()
03252 
03253 
03254     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03255     Created:    10/06/97
03256     Inputs:     -   
03257     Outputs:    -
03258     Returns:    -
03259     Purpose:    FramePropertiesTab constructor. 
03260     
03261 ********************************************************************************************/
03262 
03263 FramePropertiesTab::FramePropertiesTab()
03264 {   
03265     //  Does nothing at present.
03266 }            
03267 
03268 /********************************************************************************************
03269 
03270 >   FramePropertiesTab::~FramePropertiesTab()
03271 
03272     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03273     Created:    10/06/97
03274     Inputs:     -
03275     Outputs:    -
03276     Returns:    -
03277     Purpose:    FramePropertiesTab destructor.
03278     
03279 ********************************************************************************************/
03280                                                                                 
03281 FramePropertiesTab::~FramePropertiesTab()
03282 {   
03283 }        
03284 
03285 /********************************************************************************************
03286 
03287 >   BOOL FramePropertiesTab::Init()
03288 
03289     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03290     Created:    10/06/97
03291     Inputs:     -
03292     Outputs:    -
03293     Returns:    True if initialised ok, False if failed.
03294     Purpose:    FramePropertiesTab init routine
03295     
03296 ********************************************************************************************/
03297                                                                                 
03298 BOOL FramePropertiesTab::Init()
03299 {   
03300     return TRUE;
03301 }        
03302 
03303 /******************************************************************************************
03304 
03305 >   CDlgResID FramePropertiesTab::GetPageID()()
03306 
03307     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03308     Created:    10/06/97
03309     Inputs:     -
03310     Outputs:    -
03311     Returns:    The dialog ID of this tab section.    
03312     Purpose:    Allows the options dialog code to determine the dialog ID of this section.
03313     
03314 ******************************************************************************************/
03315 
03316 CDlgResID FramePropertiesTab::GetPageID()
03317 {
03318     return _R(IDD_TAB_FRAME_PROPERTIES); 
03319 }
03320 
03321 /******************************************************************************************
03322 
03323 >   BOOL FramePropertiesTab::IsPropertyRequired()
03324 
03325     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03326     Created:    10/06/97
03327     Returns:    Returns True if this tab is a program option.     
03328     Purpose:    Allows the Frame properties to determine if this tab is required.
03329 
03330 ******************************************************************************************/
03331 
03332 BOOL FramePropertiesTab::IsPropertyRequired()
03333 {
03334     //  If the dialog has been invoked via the options button on the Export dialog box,
03335     //  then hide the frame properties tab.
03336     if (!GetIncludeFramePropertiesTab() || GetBrowserPreviewTab())
03337         return FALSE;
03338     else
03339         return TRUE;    // This tab is required 
03340 }
03341 
03342 
03343 /******************************************************************************************
03344 
03345 >   BOOL FramePropertiesTab::CommitSection()
03346 
03347     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03348     Created:    10/06/97
03349     Inputs:     -
03350     Outputs:    -
03351     Returns:    True if values in dialog box ok, False otherwise.     
03352     Purpose:    Takes the values in this tab of the layer properties dialog box.
03353                 Called when ok or apply now is pressed on the main dialog box.
03354 
03355 ******************************************************************************************/
03356 
03357 BOOL FramePropertiesTab::CommitSection()
03358 {
03359     ERROR2IF(pPropertiesDlg == NULL,FALSE,"FramePropertiesTab::CommitSection called with no dialog pointer");
03360 
03361     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
03362     if (!ok)
03363         return TRUE;    
03364 
03365     // Get a ptr to the active frame layer.
03366     Layer* pLayer = pSpread->FindActiveLayer();
03367 
03368     // Only do the op if we have a frame layer with a different set of properties.
03369     if (pLayer != NULL && HavePropertiesChanged(pLayer, TRUE))
03370     {
03371         DWORD Delay = 0;                    // The delay value set for this frame layer.
03372         String_256 FrameLayerName;          // The Name for this frame layer.
03373         UINT32 AreDelayValuesSame = FALSE;  // Flag to indicate whether the frame layer delay values are the same.
03374 
03375         // Pass these new values onto the Frame layer.
03376         FrameLayerName  = pPropertiesDlg->GetStringGadgetValue(_R(IDC_FRAMETAB_NAME),NULL); 
03377         BOOL DelayValid = FALSE;
03378         Delay = pPropertiesDlg->GetLongGadgetValue(_R(IDC_FRAMETAB_DELAY), 0, 65535, _R(IDS_BMPPREFS_INVALIDDELAY) ,&DelayValid);
03379 
03380         // If the delay value is invalid, then go no further!
03381         if(!DelayValid)
03382             return FALSE;
03383 
03384         // Are either of these check boxes selected.
03385         BOOL Overlay = pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAMETAB_OVERLAY));
03386         BOOL Solid = pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAMETAB_SOLID));
03387 
03388         // If the background and overlay flags are both set, force the ovrelay flag to false.
03389         // This is possible since the overlay check box may be greyed but at the same time be ticked.
03390         if(Solid && Overlay)
03391             Overlay = FALSE;
03392 
03393         // Is the "Show frame" check box ticked.
03394         BOOL IsHidden = pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAMETAB_SHOWFRAME));
03395 
03396         // Set the correct state of the layer IsHidden flag.
03397         if(IsHidden)
03398             pLayer->SetHiddenFrame(FALSE);
03399         else
03400             pLayer->SetHiddenFrame(TRUE);
03401 
03402         // Check if we are changing the solid (background) layer flag. If we are then
03403         // mark all dependent frames as edited.
03404         if (pLayer->IsSolid() != Solid)
03405         {
03406             // Mark all frames above this as edited until we reach the last frame
03407             // OR we hit a solid/background layer.
03408             Layer * pFrame = pLayer->FindNextFrameLayer();
03409             while (pFrame != NULL && !pFrame->IsSolid())
03410             {
03411                 // Mark that frame as edited
03412                 pFrame->SetEdited(TRUE);
03413                 pFrame = pFrame->FindNextFrameLayer();
03414             }
03415         }
03416 
03417         // Pass the new data onto the layer.
03418         pLayer->SetSolid(Solid);
03419         pLayer->SetOverlay(Overlay);
03420         pLayer->SetFrameDelay(Delay);
03421         pLayer->SetLayerID(FrameLayerName);
03422         
03423         // Mark the document as edited.
03424         // First get a ptr to the current document.
03425         Document* pDoc = Document::GetCurrent();
03426 
03427         // Set this document as edited.
03428         if(pDoc)
03429             pDoc->SetModified(TRUE);                    
03430 
03431         // Mark this layer as edited.
03432         pLayer->SetEdited(TRUE);
03433 
03434 #ifdef _DEBUG
03435         // Tell the frame gallery to update its display of the frame
03436         BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::REDRAW_LAYER));
03437 #endif
03438 
03439         // Get the OILBitmap Bitmap associated with this frame layer and set its delay value and Name details.
03440         // First find the kernel bitmap.
03441         // It might be the generated one
03442         KernelBitmap* pKernelBitmap = pLayer->GetGeneratedBitmap();
03443         // or if not present, may be a referenced one, i.e. single node bitmap on the layer.
03444         if (pKernelBitmap == NULL)
03445             pKernelBitmap = pLayer->GetReferencedBitmap();
03446 
03447         // Check for an empty frame layer. 
03448         if(pKernelBitmap == NULL)
03449         {
03450             //if the frame layer delay values for this animation are no longer the same, force the animation properties tab to update itself.
03451             if(!SameflDelayValues())
03452                 BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::UPDATE_ACTIVE_LAYER));
03453             else
03454                 AreDelayValuesSame = TRUE;
03455 
03456             // Currently "Many" is displayed in the animation propertiess tab, but the frame propertiess tab delay
03457             // values have changed to give all the frame layers the same delay value. Therfore, update the animation properties tab.
03458             if(AreDelayValuesSame && m_IsManyDisplayed)
03459                 BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::UPDATE_ACTIVE_LAYER));
03460             
03461             // Force a redraw of the frame gallery. Allows us to update frame layer Name/Delay details.
03462             BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::REDRAW_LAYER));
03463 
03464             return TRUE;
03465         }
03466         
03467         // Get the OILBitmap assciated with this kernel bitmap.
03468         OILBitmap* pOILBitmap = pKernelBitmap->GetActualBitmap();
03469         if (pOILBitmap == NULL)
03470         {
03471 
03472             //if the frame layer delay values for this animation are no longer the same, force the animation properties tab to update itself.
03473             if(!SameflDelayValues())
03474                 BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::UPDATE_ACTIVE_LAYER));
03475             else
03476                 AreDelayValuesSame = TRUE;
03477 
03478             // Currently "Many" is displayed in the animation propertiess tab, but the frame propertiess tab delay
03479             // values have changed to give all the frame layers the same delay value. Therfore, update the animation properties tab.
03480             if(AreDelayValuesSame && m_IsManyDisplayed)
03481                 BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::UPDATE_ACTIVE_LAYER));
03482                         
03483             // Force a redraw of the frame gallery. Allows us to update frame layer Name/Delay details.
03484             BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::REDRAW_LAYER));
03485 
03486             return TRUE;
03487         }
03488 
03489         // Set the delay value in the OILBitmap.
03490         pOILBitmap->SetBitmapAnimDelay(Delay);
03491 
03492         // Set the name in the OILBitmap.
03493         pOILBitmap->SetName(FrameLayerName);
03494 
03495 PORTNOTE("other", "Disabled OpGrabFrame")
03496 #ifndef EXCLUDE_FROM_XARALX
03497         if (PreviewDialog::GetPreviewDialog())
03498         {
03499             OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_FRAME_GRABFRAME); 
03500             GIFAnimationExportParam Param;
03501             if (pOpDesc != NULL)
03502                 pOpDesc->Invoke(&Param);
03503             else
03504             {
03505                 ERROR3("Couldn't find OPTOKEN_FRAME_GRABALLFRAMES op descriptor");
03506             }
03507         }
03508 #endif
03509 
03510         //if the frame layer delay values for this animation are no longer the same, force the animation properties tab to update itself.
03511         if(!SameflDelayValues())
03512             BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::UPDATE_ACTIVE_LAYER));
03513         else
03514             AreDelayValuesSame = TRUE;
03515 
03516         // Currently "Many" is displayed in the animation propertiess tab, a change to the frame properties tab delay
03517         // value has caused all the frame layers to have the same delay value. Therfore, update the animation properties tab.
03518         if(AreDelayValuesSame && m_IsManyDisplayed)
03519             BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::UPDATE_ACTIVE_LAYER));
03520     }
03521 
03522     // Force a redraw of the frame gallery.
03523     BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::REDRAW_LAYER));
03524 
03525     // Everything is OK!
03526     return TRUE;
03527 }
03528 
03529 /********************************************************************************************
03530 
03531 >   BOOL FramePropertiesTab::GreySection()
03532 
03533     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03534     Created:    10/06/97
03535     Inputs:     -
03536     Outputs:    -
03537     Returns:    -
03538     Purpose:    Called when all documents are closed.
03539     
03540 ********************************************************************************************/
03541 
03542 BOOL FramePropertiesTab::GreySection()
03543 {
03544     ERROR2IF(pPropertiesDlg == NULL,FALSE,"FramePropertiesTab::GreySection called with no dialog pointer");
03545 
03546     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
03547     if (!ok)
03548         return TRUE;    
03549 
03550     // Only update if we are not already grey 
03551     if (m_GreyStatus == TRUE)
03552         return TRUE;
03553 
03554     // Set thewse two controls here, fixes a bug.
03555     pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_DELAY),FALSE);
03556     pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_SHOWFRAME),FALSE);
03557 
03558     // Call our central greying/ungreying function
03559     ok = ChangeControlStatus(FALSE);
03560     
03561     // Set the correct grey status.
03562     m_GreyStatus = TRUE;
03563     SetApplyNowState(FALSE);
03564 
03565     return ok;
03566 } 
03567 
03568 /********************************************************************************************
03569 
03570 >   BOOL FramePropertiesTab::UngreySection()
03571 
03572     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03573     Created:    10/06/97
03574     Inputs:     -
03575     Outputs:    -
03576     Returns:    -
03577     Purpose:    Called when the user has selected a new document. 
03578     
03579 ********************************************************************************************/
03580 
03581 BOOL FramePropertiesTab::UngreySection()
03582 {
03583     ERROR2IF(pPropertiesDlg == NULL,FALSE,"FramePropertiesTab::UngreySection called with no dialog pointer");
03584 
03585     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());  // The FramePropertiesTab identifier
03586     if (!ok)
03587         return TRUE;    
03588 
03589     // Only update if we are not already ungrey 
03590     if (m_GreyStatus == FALSE)
03591         return TRUE;
03592 
03593     // Grey the controls on the frame properties tab.
03594     pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_SHOWFRAME),TRUE);
03595     pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_NAME),TRUE);
03596     pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_SOLID),TRUE);
03597     pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_DELAY),TRUE);
03598     pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_SHOWFRAME),TRUE);
03599         
03600     // Set the correct grey status.
03601     m_GreyStatus = FALSE;
03602 
03603     return ok;
03604 }
03605 
03606 /***************************************************************************************************************
03607 
03608 >   BOOL FramePropertiesTab::ChangeControlStatus(const BOOL Status)
03609 
03610     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03611     Created:    10/06/97
03612     Inputs:     Status - Flag to determine whether to grey/ungrey the controls.
03613                 IgnoreOverlay - If we wish to ignore this field, this parameter is set TRUE, defaults FALSE. 
03614     Outputs:    -
03615     Returns:    -
03616     Purpose:    Called to grey/ungrey controls on this tab. 
03617     
03618 *****************************************************************************************************************/
03619 
03620 BOOL FramePropertiesTab::ChangeControlStatus(const BOOL Status, BOOL IgnoreOverlay)
03621 {
03622     // Set the controls to the correct state.
03623     pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_NAME),Status);
03624     pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_SOLID),Status);
03625 
03626     // In some cases we do not want change the status of this check box.
03627 
03628     if(!IgnoreOverlay)
03629         pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_OVERLAY),Status);
03630 
03631     // Determine whether the apply now/ok/canel buttons should be greyed/ungreyed.
03632     // Ensure a vlaid spread ptr.
03633     if(pSpread)
03634     {
03635         // Get a ptr to the active layer.
03636         Layer* pLayer = pSpread->FindActiveLayer();
03637 
03638         // Ensure a valid layer ptr.
03639         if(pLayer)
03640         {
03641             // Have the properties changed for this layer.
03642             if(HavePropertiesChanged(pLayer))
03643             {
03644                 // Grey the apply now/ok/cancel buttons.
03645                 FramePropertiesTab::UngreyApplyNow();
03646             }
03647 //          else
03648                 // Grey the apply now/ok/cancel buttons.
03649 //              FramePropertiesTab::GreyApplyNow();
03650         }
03651     }
03652     else
03653     {
03654         // Grey the apply now/ok/cancel buttons.
03655         FramePropertiesTab::GreyApplyNow();
03656     }
03657     
03658     // Everything ok.
03659     return TRUE;
03660 }           
03661 
03662 /********************************************************************************************
03663 
03664   > BOOL FramePropertiesTab::UpdateSection()
03665 
03666     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03667     Created:    10/06/97
03668     Returns:    -
03669     Purpose:    Called when we have switched to a new document and need to update all the 
03670                 controls on this tab.
03671             
03672 ********************************************************************************************/
03673 
03674 BOOL FramePropertiesTab::UpdateSection()
03675 {
03676     ERROR2IF(pPropertiesDlg == NULL,FALSE,"FramePropertiesTab::UpdateSection called with no dialog pointer");
03677 
03678     // Ensure we talk to the correct page.
03679     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
03680     if (!ok)
03681         return TRUE;        
03682 
03683     // Display the correct details.
03684     ShowDetails();
03685 
03686     // Everything ok.
03687     return TRUE;
03688 }
03689 
03690 /********************************************************************************************
03691 
03692 >   BOOL FramePropertiesTab::ShowDetails()
03693 
03694     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03695     Created:    10/06/97
03696     Inputs:     -
03697     Outputs:    -
03698     Returns:    -
03699     Purpose:    Shows the details of the associated layer in this tab.
03700     
03701 ********************************************************************************************/
03702 
03703 BOOL FramePropertiesTab::ShowDetails()
03704 {
03705     ERROR2IF(pPropertiesDlg == NULL,FALSE,"FramePropertiseTab::ShowDetails called with a NULL dialog pointer");
03706 
03707     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
03708     if (!ok)
03709         return TRUE;        
03710 
03711     // Ensure we have a valid spread ptr.
03712     if(!pSpread)
03713         return FALSE;
03714 
03715     // Get a ptr to the active layer.
03716     Layer* pLayer = pSpread->FindActiveLayer();
03717 
03718     // Check for a NULL ptr.
03719     if(!pLayer)
03720         return FALSE;
03721 
03722     // Ignore all DIM_TEXT_CHANGED msgs which are sent from this function.
03723     SetIgnoreTextChangeMsg(TRUE);
03724 
03725     // Set the dialog detais
03726     // Set the layer Layer Name.
03727     pPropertiesDlg->SetStringGadgetValue(_R(IDC_FRAMETAB_NAME), pLayer->GetLayerID());
03728 
03729     // Set the "Background" check box.
03730     pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAMETAB_SOLID), pLayer->IsSolid());
03731 
03732     // If the "Background" check box is ticked, grey the "Overlay" check box field.
03733     BOOL BackGroundSelected = FALSE;        // Is the "Background" check box ticked.
03734     if(pLayer->IsSolid())
03735         BackGroundSelected = TRUE;
03736 
03737     // The backgoround check box is ticked.
03738     if(BackGroundSelected)
03739     {
03740         // Grey the "Overlay" check box.
03741         pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_OVERLAY), FALSE);
03742     }
03743     else
03744     {
03745         // Set the "Overlay" check box to the correct state.
03746         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAMETAB_OVERLAY), pLayer->IsOverlay());           
03747     }
03748 
03749     // Set the "Frame Delay" edit field.
03750     pPropertiesDlg->SetLongGadgetValue(_R(IDC_FRAMETAB_DELAY), pLayer->GetFrameDelay());            
03751     
03752     // Is the frame hidden?
03753     BOOL IsHidden = pLayer->IsHiddenFrame();
03754 
03755     // The frame is not hidden.
03756     if(!IsHidden)
03757     {
03758         // Ungrey the 'Delay this frame for' check box.
03759         pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_DELAY), TRUE);
03760 
03761         // Pass this value onto the control.
03762         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAMETAB_SHOWFRAME), TRUE);
03763     }
03764     else
03765     {
03766         // The frame is hidden.
03767         // Pass this value onto the control.
03768         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAMETAB_SHOWFRAME), FALSE);
03769 
03770         // Grey the 'Delay this frame for' check box.
03771         pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_DELAY), FALSE);
03772     }
03773 
03774     // Set the controls to the correct state. 
03775     // If the "Backgorund" check box is selected then we have already determined the state of the "Overlay" check box.
03776     // Therefore setting the second parameter TRUE ensures we do not change the status of this control.
03777     if(BackGroundSelected)
03778         ChangeControlStatus(!m_GreyStatus, TRUE);
03779     else
03780         ChangeControlStatus(!m_GreyStatus);
03781 
03782     // We once again wish to deal with DIM_TEXT_CHANGED msgs.
03783     SetIgnoreTextChangeMsg(FALSE);
03784 
03785     // Everything ok.
03786     return TRUE;
03787 }
03788 
03789 /****************************************************************************************************************************
03790 
03791 >   BOOL FramePropertiesTab::UpdateLayerSection()
03792 
03793     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03794     Created:    10/06/97
03795     Inputs:     -
03796     Outputs:    -
03797     Returns:    TRUE if ok, FALSE otherwise
03798     Purpose:    Called when the layer-related section of the tab should be updated.
03799     
03800 ******************************************************************************************************************************/
03801 
03802 BOOL FramePropertiesTab::UpdateLayerSection()
03803 {
03804     ERROR2IF(pPropertiesDlg == NULL,FALSE,"FramePropertiesTab::UpdateLayerSection() called with a NULL dialog pointer");
03805 
03806     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
03807     if (!ok)
03808         return TRUE;    
03809 
03810     // When the frame gallery is opening an UPDATE_ACTIVE_LAYER message is sent. 
03811     // We wish to ignore the message, therefore this flag will be set to false.
03812     if(m_FrameGalleryOpen && !m_ChangeLayerState)
03813         ShowDetails();
03814 
03815     // This flag is only true when the active layer state has been
03816     // changed from within the frame gallery. At all other times we
03817     // invoke the Showdetails function above.
03818     if(m_ChangeLayerState)
03819         ChangeLayerState();
03820 
03821     // Everything ok.
03822     return TRUE;
03823 }
03824 
03825 /****************************************************************************************************************************
03826 
03827 >   BOOL FramePropertiesTab::ChangeLayerState()
03828 
03829     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03830     Created:    10/06/97
03831     Inputs:     -
03832     Outputs:    -
03833     Returns:    TRUE if ok, FALSE otherwise
03834     Purpose:    Called when the layer state has been changed from within the frame gallery, 
03835                 this function updates the controls of the frame properties tab.
03836     
03837 ******************************************************************************************************************************/
03838 BOOL FramePropertiesTab::ChangeLayerState()
03839 {
03840     ERROR2IF(pPropertiesDlg == NULL,FALSE,"FramePropertiesTab::UpdateLayerSection() called with a NULL dialog pointer");
03841 
03842     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
03843     if (!ok)
03844         return TRUE;    
03845 
03846     // Ensure we have a valid spread ptr.
03847     if(!pSpread)
03848         return FALSE;
03849 
03850     // Get a ptr to the active layer.
03851     Layer* pLayer = pSpread->FindActiveLayer();
03852 
03853     // Check for a NULL ptr.
03854     if(!pLayer)
03855         return FALSE;
03856 
03857     // Is the Solid or Overlay flag selected?
03858 
03859     // If the "Background" check box is ticked, grey the "Overlay" check box field.
03860     if(pLayer->IsSolid())
03861     {
03862 
03863         // Set the "Background" check box to the correct state.
03864         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAMETAB_SOLID), TRUE);            
03865 
03866         // Grey the "Overlay" check box.
03867         pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_OVERLAY), FALSE);
03868     }
03869     else
03870     {
03871         // Set the "Background" check box to the correct state.
03872         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAMETAB_SOLID), FALSE);           
03873 
03874         // Ungrey the "Overlay" check box.
03875         pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_OVERLAY), TRUE);
03876 
03877     }
03878 
03879     // Is the overlay check box ticked?
03880     if(pLayer->IsOverlay()) 
03881     {
03882         // Set the "Background" check box to the correct state.
03883         pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_SOLID), TRUE);         
03884 
03885         // Set the "Overlay" check box to the correct state.
03886         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAMETAB_OVERLAY), TRUE);          
03887     }
03888     else
03889     {
03890         // Set the "Overlay" check box to the correct state.
03891         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_FRAMETAB_OVERLAY), FALSE);         
03892     }
03893 
03894     // Set the correct state of the flag.
03895     FramePropertiesTab::SetApplyNowState(TRUE);
03896 
03897     // Ungrey the apply/ok/cancel buttons.
03898     FramePropertiesTab::UngreyApplyNow();
03899 
03900     // Everything ok.
03901     return TRUE;
03902 }
03903 
03904 
03905 /********************************************************************************************
03906 
03907 >   BOOL FramePropertiesTab::HandleMsg(DialogMsg* Msg)
03908 
03909     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03910     Created:    10/06/97
03911     Inputs:     -
03912     Outputs:    -
03913     Returns:    -
03914     Purpose:    Handles all the messages for this frame property tab.
03915     
03916 ********************************************************************************************/
03917 
03918 BOOL FramePropertiesTab::HandleMsg(DialogMsg* Msg)
03919 {
03920     ERROR2IF(Msg == NULL,FALSE,"FramePropertiesTab::Message null message received");
03921     ERROR2IF(pPropertiesDlg == NULL,FALSE,"FramePropertiesTab::HandleMsg called with no dialog pointer");
03922 
03923     // Talk to the correct page.
03924     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
03925     if (!ok)
03926         return TRUE;        
03927 
03928     switch(Msg->DlgMsg)
03929     {
03930         case DIM_CREATE:    
03931             m_GreyStatus = FALSE;
03932             ok = InitSection();
03933             if (!ok)
03934                 InformError();
03935             break;
03936 
03937         case DIM_LFT_BN_CLICKED:
03938         {
03939             if (FALSE) {}
03940             else if (Msg->GadgetID ==_R(IDC_FRAMETAB_SOLID))
03941             {
03942                 // If the "Background" check box is ticked, grey the "Overlay" check box.
03943                 BOOL Value = pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAMETAB_SOLID));
03944                 if (Value)
03945                 {
03946                     // Grey the 'Overlay' check box.
03947                     pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_OVERLAY), FALSE);
03948                 }
03949                 else
03950                 {
03951                     // Ungrey the 'Overlay' check box.
03952                     pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_OVERLAY), TRUE);                               
03953                 }
03954             }
03955             else if (Msg->GadgetID == _R(IDC_FRAMETAB_SHOWFRAME))
03956             {
03957                 // If the "Show frame" check box is ticked, grey the "Disaply this frame for" check box.
03958                 BOOL Value = pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAMETAB_SHOWFRAME));
03959 
03960                 // Get a ptr to the active layer.
03961                 Layer* pLayer = pSpread->FindActiveLayer();
03962 
03963                 // Ensure we have a valid ptr.
03964                 if( pLayer)
03965                 {
03966                     // The 'Show frame' check box is ticked.
03967                     if(Value)
03968                     {
03969                         // Ungrey the 'Delay this frame for' check box.
03970                         pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_DELAY), TRUE);
03971     
03972                         // Pass this value onto the layer. This is necessary as when we force the frame gallery 
03973                         // to update itself, it takes the value stored in the layer. 
03974                         //pLayer->SetHiddenFrame(FALSE);
03975                     }
03976                     else
03977                     {
03978                         // Grey the 'Delay this frame for' check box.  
03979                         pPropertiesDlg->EnableGadget(_R(IDC_FRAMETAB_DELAY), FALSE);
03980     
03981                         // Pass this value onto the layer. This is necessary as when we force the frame gallery 
03982                         // to update itself, it takes the value stored in the layer. 
03983                         //pLayer->SetHiddenFrame(TRUE);
03984                     }
03985     
03986                     // Tell the frame gallery to update its display of the frame.
03987                     // We do this to update the right click pop-up menu.
03988                     BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::REDRAW_LAYER));
03989                 }
03990             }
03991             
03992             // Set the correct state of the flag.
03993             FramePropertiesTab::SetApplyNowState(TRUE);
03994 
03995             // Ungrey the apply/ok/cancel buttons.
03996             FramePropertiesTab::UngreyApplyNow();
03997             
03998         }
03999         break;
04000 
04001         case DIM_SELECTION_CHANGED:
04002         {
04003             if(FramePropertiesTab::GetApplyNowState())
04004             {
04005                 // Ungrey the apply/ok/cancel buttons.
04006                 FramePropertiesTab::UngreyApplyNow();   
04007             }           
04008         }
04009         break;
04010 
04011         case DIM_TEXT_CHANGED:
04012         {
04013             // Do we want to deal with text change msgs?
04014             if(!GetIgnoreTextChangeMsg())
04015             {
04016                 // Get a ptr to the active layer.
04017                 Layer* pLayer = pSpread->FindActiveLayer();
04018 
04019                 // Ensure we have a valid layer ptr.
04020                 if (pLayer)
04021                 {
04022                     // Have the frame properties changed?
04023                     if(HavePropertiesChanged(pLayer))
04024                     {
04025                         // Set the correct state of the m_ApplyNow flag.
04026                         FramePropertiesTab::SetApplyNowState(TRUE);
04027 
04028                         // Ungrey the apply/ok/cancel buttons.
04029                         FramePropertiesTab::UngreyApplyNow();
04030                     }
04031                 }
04032 
04033                 // We need to make a note of this value change, 
04034                 // this impacts on the value displayed in the delay 
04035                 // edit field in the animation properties tab.
04036                 SetFrameDelayValueChanged(TRUE);
04037             }
04038         }
04039         break;
04040 
04041         case DIM_SET_ACTIVE:
04042         {
04043             if(FramePropertiesTab::GetApplyNowState())
04044             {
04045                 // Ungrey the apply/ok/cancel buttons.
04046                 FramePropertiesTab::UngreyApplyNow();   
04047             }           
04048         }
04049         break;
04050 
04051         default:
04052             break;
04053     }
04054     return TRUE;
04055 }  
04056 
04057 /******************************************************************************************
04058 
04059 >   BOOL FramePropertiesTab::UpdateApplyState()
04060 
04061     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04062     Created:    10/06/97
04063     Inputs:     -
04064     Outputs:    -
04065     Returns:    TRUE if ok, FALSE otherwise
04066     Purpose:    This changes the 'Apply now' state based on the settings of the active layer
04067                 and the settings in this tab.
04068                 If the settings are the same, the 'Apply state' is FALSE, else it are TRUE
04069     
04070 ******************************************************************************************/
04071 
04072 BOOL FramePropertiesTab::UpdateApplyState()
04073 {
04074 /*
04075     ERROR2IF(pPropertiesDlg == NULL,FALSE,"animationColoursTab::CommitSection called with a NULL dialog pointer");
04076 
04077     // Ensure we talk to the correct page.
04078     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
04079     if (!ok)
04080         return TRUE;
04081 
04082     // Ensure we have an active layer.
04083     Layer* pLayer = GetActiveLayer();
04084 
04085     // Have the properties for this changed.
04086     if (pLayer != NULL)
04087         FramePropertiesTab::SetApplyNowState(HavePropertiesChanged(pLayer));
04088 
04089     // The new state for the 'Apply/ok/Cancel' buttons.
04090     BOOL NewApplyNowState = FramePropertiesTab::GetApplyNowState();
04091 
04092     // If the properties for this tab have changed, then ungrey the apply now button.
04093     if (NewApplyNowState  || GetCurrentApplyNow())
04094     {
04095         // Ungrey the apply/ok/cancel buttons.
04096         FramePropertiesTab::UngreyApplyNow();
04097     }
04098 */
04099     // Everything ok.
04100     return TRUE;
04101 }
04102 
04103 /**************************************************************************************************************************
04104 
04105 >   BOOL FramePropertiesTab::HavePropertiesChanged(Layer* pLayer)
04106 
04107     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04108     Created:    10/06/97
04109     Inputs:     pLayer - ptr to a layer
04110                 ValidateDelayValue - Flag to determine when we need to validate the delay value.
04111                 Defaults to false.
04112     Outputs:    -
04113     Returns:    TRUE if settings in the dlg are different to the given layer's settings, else FALSE
04114     
04115 ****************************************************************************************************************************/
04116 
04117 BOOL FramePropertiesTab::HavePropertiesChanged(Layer* pLayer, BOOL ValidateDelayValue)
04118 {
04119     ERROR2IF(pPropertiesDlg == NULL,FALSE,"FramePropertiesTab::HavePropertiesChanged called with a NULL dialog pointer");
04120 
04121     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
04122     if (!ok)
04123         return TRUE;
04124 
04125     // Get the current values from the tab.
04126     BOOL        CurBackground   =   pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAMETAB_SOLID));
04127     BOOL        CurOverlay      =   pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAMETAB_OVERLAY));
04128     String_256  CurName         =   pPropertiesDlg->GetStringGadgetValue(_R(IDC_FRAMETAB_NAME),NULL);
04129     BOOL        CurIsHidden     =   pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_FRAMETAB_SHOWFRAME));
04130     DWORD       CurDelay = 0;
04131 
04132     // Do we want to validate the delay input.
04133     if(ValidateDelayValue)
04134     {
04135         BOOL DelayValid = FALSE;
04136         CurDelay = pPropertiesDlg->GetLongGadgetValue(_R(IDC_FRAMETAB_DELAY), 0, 65535, _R(IDS_BMPPREFS_INVALIDDELAY) ,&DelayValid);
04137 
04138         // If the delay value is invalid, then go no further!
04139         if(!DelayValid)
04140             return FALSE;
04141     }
04142     else
04143     {
04144         CurDelay = pPropertiesDlg->GetLongGadgetValue(_R(IDC_FRAMETAB_DELAY), 0, 65535, _R(IDS_BMPPREFS_INVALIDDELAY) ,NULL);
04145     }   
04146 
04147     // If the check box is selected, then the frame is not hidden.
04148     if(CurIsHidden)
04149         CurIsHidden = FALSE;
04150     else
04151         CurIsHidden = TRUE;
04152 
04153     // If the background and overlay flags have both been set, then force the ovrelay flag to false.
04154     // This can occur since the overlay check box may be greyed but at the same time be ticked.
04155     if(CurBackground && CurOverlay)
04156         CurOverlay = FALSE;
04157 
04158     // Get the values stored in the frame layer.
04159     BOOL        Background  =   pLayer->IsSolid();
04160     BOOL        Overlay     =   pLayer->IsOverlay();
04161     String_256  Name        =   pLayer->GetLayerID();
04162     DWORD       Delay       =   pLayer->GetFrameDelay();
04163     BOOL        IsHidden    =   pLayer->IsHiddenFrame();
04164 
04165     // Compare the current values against those stored in the frame layer.
04166     return ((Background != CurBackground)   || 
04167             (Overlay    != CurOverlay)      ||
04168             (Name       != CurName)         ||
04169             (Delay      != CurDelay)        ||
04170             (IsHidden   != CurIsHidden ));  
04171 }
04172 
04173 /***************************************************************************************************************
04174 
04175 >   BOOL FramePropertiesTab::InitSection()
04176 
04177     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04178     Created:    10/06/97
04179     Inputs:     -
04180     Outputs:    -
04181     Returns:    TRUE if successful, else FALSE
04182     Purpose:    Sets initial values for this tab on the animation properties dialog box.
04183     
04184 *****************************************************************************************************************/
04185 
04186 BOOL FramePropertiesTab::InitSection()
04187 {
04188     ERROR2IF(pPropertiesDlg == NULL,FALSE,"FramePropertiesTab::InitSection called with no dialog pointer");
04189 
04190     // Get a ptr to the current document.
04191     Document* pDoc = Document::GetCurrent();
04192 
04193     // If there is no document, then grey the tab.
04194     if(!pDoc)
04195     {
04196         GreySection();
04197         return (TRUE);
04198     }
04199 
04200     // Display the details for this tab.
04201     ShowDetails();
04202 
04203     return TRUE;
04204 }
04205 
04206 
04207                         /**********************************************************************
04208 
04209                             Animation Export Options dialog class.  
04210                             This class is derived off GIFAnimationPropertyTabsDlg,
04211                             this allows us to invoke two instances' of the same dialog.
04212 
04213                         ***********************************************************************/
04214 
04215 
04216 
04217 
04218 
04219 /******************************************************************************************
04220 
04221 >   BOOL AnimExOptns::Init()
04222 
04223     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04224     Created:    10/06/97
04225     Inputs:     -
04226     Outputs:    -
04227     Returns:    -
04228     
04229 ******************************************************************************************/
04230 
04231 BOOL AnimExOptns::Init()
04232 {
04233     BOOL InitOK;
04234 
04235     // Register ourselves with the dialog system.
04236     InitOK = RegisterOpDescriptor(
04237                                 0,                                                          // Tool ID                                                              
04238                                 _R(IDS_ANIMATION_TAB_DLG),                                      // String resource ID
04239                                 CC_RUNTIME_CLASS(AnimExOptns),                              // Runtime class
04240                                 OPTOKEN_EXPORTGIFANIMTABSDLG,                               // Token string
04241                                 GetState,                                                   // GetState function
04242                                 0,                                                          // help ID
04243                                 0,                                                          // bubble help
04244                                 0, //_R(IDD_BARCONTROLSTORE),                                   // resource ID
04245                                 0, //_R(IDC_BTN_OPTIONSDLG),                                    // control ID
04246                                 SYSTEMBAR_ILLEGAL,                                          // Bar ID
04247                                 TRUE,                                                       // Recieve system messages
04248                                 FALSE,                                                      // Smart duplicate operation
04249                                 TRUE,                                                           // Clean operation
04250                                 0,                                                      // No vertical counterpart
04251                                 _R(IDS_ANIMATION_TAB_DLG_ONE),                                  // String for one copy only error
04252                                 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC)   // Auto state flags
04253                                 );
04254     return (InitOK);
04255 }
04256 
04257 
04258 
04259 /*****************************************************************************************************************************************************
04260 
04261 >   AnimExOptns::AnimExOptns(): GIFAnimationPropertyTabsDlg(GIFAnimationPropertyTabsDlg::IDD, GIFAnimationPropertyTabsDlg::Mode) 
04262 
04263     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04264     Created:    10/06/97
04265     Inputs:     -
04266     Outputs:    -
04267     Returns:    -
04268     Purpose:    AnimExOptns constructor. 
04269     
04270 ********************************************************************************************************************************************************/
04271 
04272 AnimExOptns::AnimExOptns():GIFAnimationPropertyTabsDlg(AnimExOptns::IDD, AnimExOptns::Mode)
04273 {
04274     // Base class does all the work.
04275 }
04276 
04277 
04278 /***************************************************************************************************************
04279 
04280 >   AnimExOptns::~AnimExOptns()
04281     
04282     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04283     Created:    10/06/97
04284     Inputs:     -
04285     Outputs:    -
04286     returns:    - 
04287     Purpose:    AnimExOptns destructor.
04288 
04289 *****************************************************************************************************************/
04290 
04291 AnimExOptns::~AnimExOptns()
04292 {
04293     // As the dialog is dying, set this flag TRUE, therefore if the Full animation properties dialog is invoked, 
04294     // we will include all the tabs registered to the system.
04295 
04296     // Ensure the dialog still exists.
04297     if(m_pGIFAnimationProperties)
04298     {
04299         // Set any necessary flags to the correct state.
04300         m_pGIFAnimationProperties->SetIncludeFramePropertiesTab(TRUE);
04301         m_pGIFAnimationProperties->SetBrowserPreviewTab(FALSE); 
04302     }
04303 }
04304 
04305 /******************************************************************************************
04306 
04307 >   void AnimExOptns::Do(OpDescriptor*)
04308 
04309     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04310     Created:    10/06/97
04311     Inputs:     -
04312     Outputs:    -
04313     Returns:    -
04314     Purpose:    Creates then opens the dialog in response to a request from the user.
04315                     
04316 ******************************************************************************************/
04317 
04318 void AnimExOptns::Do( OpDescriptor * pOpDesc ) 
04319 {
04320 //  BOOL ok = FALSE;
04321 
04322     if (m_pGIFAnimationProperties == NULL)
04323     {
04324         // Could not create the dialog box.
04325         ERROR3("GIFAnimationPropertyTabsDlg::Do no AnimationProperties present");
04326         End();
04327     }
04328 
04329     //Set up the name that the main dialog page will use.
04330     String_256 Temp(_R(IDS_ANIMATION_EXPORT_OPTIONS)); 
04331     TitleString = Temp;
04332     SetName(&TitleString);
04333     
04334     // Make sure that our options tabs have a link to the dialog box class
04335     GIFAnimationPropertyTabs::SetTabbedDlg(this);
04336 
04337     // Force the apply now/ok buttons to a grey state.
04338     m_pGIFAnimationProperties->SetApplyNowState(FALSE);
04339 
04340     // On start up ungrey the OK button.
04341     m_pGIFAnimationProperties->SetOkState(TRUE);
04342 
04343     // Force the dialog box to be created and displayed.
04344     Create();       
04345 };
04346 
04347 /*********************************************************************************************************************
04348 
04349 >   MsgResult GIFAnimationPropertyTabsDlg::Message(Msg* Message)
04350     
04351     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04352     Created:    10/06/97
04353     Inputs:     -
04354     Outputs:    -
04355     Returns:    OK            Message handled ok.
04356                 FAIL          Something terrible happened whilst processing the message.
04357                 EAT_MSG       The Message was handled ok but don't send it to any more MessageHandlers. 
04358         
04359 *************************************************************************************************************************/
04360 
04361 MsgResult AnimExOptns::Message(Msg* Message)
04362 {
04363     ERROR3IF(Message == NULL,"AnimExOptns::Message NULL message received");
04364 
04365     if (IS_OUR_DIALOG_MSG(Message))
04366     {
04367         DialogMsg* Msg = (DialogMsg*)Message;
04368 
04369         MsgResult Result;
04370 
04371         // Main handler for dialog type messages
04372         BOOL EndDialog = FALSE;                                         // TRUE if we should quit the dialog
04373         BOOL CommitValues = FALSE;                                      // TRUE if we should commit the dialog values
04374         /*BOOL OldApplyNow =*/ m_pGIFAnimationProperties->GetApplyNowState();   // Old ApplyNow button state  
04375 
04376         // Make sure that the tabs know what is the current document and spread to work on.
04377         Document *pDocument = Document::GetSelected();
04378         m_pGIFAnimationProperties->SetCurrentDocAndSpread(pDocument);
04379 
04380         // Make sure that the current document units are correct.
04381         m_pGIFAnimationProperties->SetUpDocUnits();
04382             
04383         // Check if sending init/create message and if so set flag True.
04384         // If True then do not ungrey the ApplyNow button on changing messages
04385         if (Msg->DlgMsg == DIM_CREATE)
04386             m_pGIFAnimationProperties->SetInitMessageState(TRUE);               
04387 
04388         // If the message is not for the main winndow then try the tab pages. 
04389         BOOL FoundPage = FALSE;
04390 
04391         if (Msg->PageID != 0)
04392         {
04393             //Go through all the tabs declared to the system and see if the message is for that page.
04394             GIFAnimationPropertyTabs *pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetFirst();
04395 
04396             while (pGIFAnimationPropertyTabs != NULL&& !FoundPage)
04397             {
04398                 CDlgResID PageId = pGIFAnimationPropertyTabs->GetPageID();
04399                 if (PageId == Msg->PageID)
04400                 {
04401                     // Found the correct page so stop the search and send the message to that page
04402                     pGIFAnimationPropertyTabs->HandleMsg(Msg);
04403                     FoundPage = TRUE;
04404                 }
04405                 // Get the next option's tab.
04406                 pGIFAnimationPropertyTabs = GIFAnimationPropertyTabs::GetNext(pGIFAnimationPropertyTabs);                           
04407             }
04408         }   
04409         else
04410         {
04411             // Main page window
04412             switch (Msg->DlgMsg)
04413             {
04414                 case DIM_COMMIT:        
04415                     EndDialog = TRUE;
04416                     CommitValues = TRUE;
04417                 break;
04418 
04419                 case DIM_SOFT_COMMIT:   
04420                 {
04421                     CommitValues = TRUE;
04422                     m_pGIFAnimationProperties->SetApplyNowState(TRUE);
04423                 }
04424                 break;
04425 
04426                 case DIM_CANCEL:        
04427                     EndDialog = TRUE;
04428                     break;
04429 
04430                 default:
04431                     break;
04432             }
04433         }
04434 
04435         // Commit values here.
04436         if (CommitValues)
04437         {
04438             BOOL ok = CommitDialogValues();
04439             if (!ok)
04440             {
04441                 EndDialog = FALSE;  
04442             }
04443         }
04444         
04445         // Pass the message back to the Base class.
04446         Result = DialogTabOp::Message(Message);
04447 
04448         // End dialog here
04449         if (EndDialog) 
04450         {
04451             Close();        
04452             End();          
04453 
04454             // Remove the link to the options tabs if all dialogs have been cloosed. 
04455             if(m_pGIFAnimationProperties->GetCount() < 1)
04456             {
04457                 // Make sure that we remove our options tabs link to the dialog box class as the dialog will now be destroyed.
04458                 m_pGIFAnimationProperties->SetTabbedDlg(NULL);
04459             }
04460         }
04461         
04462         // Check if we have been sending an init/create message, if so then set the flag False.
04463         if (Msg->DlgMsg == DIM_CREATE)
04464             m_pGIFAnimationProperties->SetInitMessageState(FALSE);
04465                     
04466         //return DialogTabOp::Message(Message);
04467         return Result;
04468     }
04469     else
04470     {
04471         //Pass the message onto the base class message handler.
04472         return GIFAnimationPropertyTabsDlg::Message(Message);
04473     }
04474 }
04475 
04476 
04477 
04478 
04479 
04480 
04481 
04482                         /************************************************************/
04483                         /************************************************************
04484 
04485                                 
04486                                       PPREVIEW IN BROWSER TAB
04487 
04488 
04489                         **************************************************************
04490                         **************************************************************/
04491 
04492 
04493 
04494 
04495 
04496 
04497 
04498 
04499 
04500 
04501 
04502 /********************************************************************************************
04503 
04504 >   PreviewInBrowserTab::PreviewInBrowserTab() 
04505 
04506 
04507     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04508     Created:    10/06/97
04509     Inputs:     -   
04510     Outputs:    -
04511     Returns:    -
04512     Purpose:    PreviewInBrowserTab constructor.
04513     
04514 ********************************************************************************************/
04515 
04516 PreviewInBrowserTab::PreviewInBrowserTab()
04517 {   
04518     // Does nothing at present.
04519 }            
04520 
04521 /********************************************************************************************
04522 
04523 >   PreviewInBrowserTab::~PreviewInBrowserTab()
04524 
04525 
04526     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04527     Created:    10/06/97
04528     Inputs:     -
04529     Outputs:    -
04530     Returns:    -
04531     Purpose:    AnimationColoursTab destructor.
04532 
04533 ********************************************************************************************/
04534                                                                                 
04535 PreviewInBrowserTab::~PreviewInBrowserTab()
04536 {   
04537 }        
04538 
04539 /********************************************************************************************
04540 
04541 >   BOOL PreviewInBrowserTab::Init()
04542 
04543 
04544     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04545     Created:    10/06/97
04546     Inputs:     -
04547     Outputs:    -
04548     Returns:    True if initialised ok, False if failed.
04549     
04550 ********************************************************************************************/
04551                                                                                 
04552 BOOL PreviewInBrowserTab::Init()
04553 {   
04554     return TRUE;
04555 }        
04556 
04557 /******************************************************************************************
04558 
04559 >   CDlgResID PreviewInBrowserTab::GetPageID()()
04560 
04561     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04562     Created:    10/06/97
04563     Inputs:     -
04564     Outputs:    -
04565     Returns:    The dialog ID of this tab section.    
04566     
04567 ******************************************************************************************/
04568 
04569 CDlgResID PreviewInBrowserTab::GetPageID()
04570 {
04571     return _R(IDD_TAB_PREVIEW_IN_BROWSER);
04572 }
04573 
04574 /******************************************************************************************
04575 
04576 >   BOOL PreviewInBrowserTab::IsPropertyRequired()
04577 
04578     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04579     Created:    10/06/97
04580     Returns:    Returns True if this tab is a program option.     
04581     
04582 ******************************************************************************************/
04583 
04584 BOOL PreviewInBrowserTab::IsPropertyRequired()
04585 {
04586     return TRUE;    // This tab is required 
04587 }
04588 
04589 
04590 /******************************************************************************************
04591 
04592 >   BOOL PreviewInBrowserTab::CommitSection()
04593 
04594     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04595     Created:    10/06/97
04596     Inputs:     -
04597     Outputs:    -
04598     Returns:    True if values in dialog box ok, False otherwise.     
04599     Purpose:    Takes the values in the Animation colours tab. 
04600                 Called when ok or apply now is pressed on the main dialog box.
04601 
04602 ******************************************************************************************/
04603 
04604 BOOL PreviewInBrowserTab::CommitSection()
04605 {
04606     ERROR2IF(pPropertiesDlg == NULL,FALSE,"PreviewInBrowserTab::CommitSection called with a NULL dialog pointer");
04607 
04608     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
04609     if (!ok)
04610         return TRUE;            
04611 
04612     // Have the preview in browser tab properties changed?
04613     if (HavePropertiesChanged())
04614     {
04615         //  Get the new details.
04616         BrowserBackground Bgr = BROWSER_BGR_NONE;
04617 
04618         if(pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_PLAINBKGND)))     
04619             Bgr = BROWSER_BGR_NONE;
04620 
04621         else if (pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_DOCBKGND)))
04622             Bgr = BROWSER_BGR_DOC;
04623     
04624         else if (pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_CHQBKGND)))
04625             Bgr = BROWSER_BGR_CHECKER;
04626     
04627         BOOL Info = pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_HTMLSTUB));
04628 
04629         // Store these new details in the global variables.
04630         g_Background = Bgr; 
04631         g_InfoInHtmlStub =Info;
04632     }
04633     
04634     // Everything ok.
04635     return TRUE;
04636 }
04637 
04638 
04639 /*************************************************************************************************************************
04640 
04641 >   BOOL PreviewInBrowserTab::HavePropertiesChanged()
04642 
04643     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04644     Created:    10/06/97
04645     Inputs:     -
04646     Outputs:    -
04647     Returns:    TRUE if settings in the dlg are different to those in the spread else FALSE.
04648     
04649 ****************************************************************************************************************************/
04650 
04651 BOOL PreviewInBrowserTab::HavePropertiesChanged()
04652 {
04653     ERROR2IF(pPropertiesDlg == NULL,FALSE,"PreviewInBrowserTab::HavePropertiesChanged called with a NULL dialog pointer");
04654 
04655     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
04656     if (!ok)
04657         return TRUE;
04658 
04659     // Get the current details.
04660     BrowserBackground Bgr = BROWSER_BGR_NONE;
04661 
04662     if(pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_PLAINBKGND)))     
04663         Bgr = BROWSER_BGR_NONE;
04664 
04665     else if (pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_DOCBKGND)))
04666         Bgr = BROWSER_BGR_DOC;
04667     
04668     else if (pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_CHQBKGND)))
04669         Bgr = BROWSER_BGR_CHECKER;
04670     
04671     BOOL Info = pPropertiesDlg->GetBoolGadgetSelected(_R(IDC_HTMLSTUB));
04672 
04673     // Compare the new details to those stored in the global variables.
04674     return
04675     ((  Bgr != g_Background) ||
04676     (   Info != g_InfoInHtmlStub));         
04677 }
04678 
04679 /********************************************************************************************
04680 
04681 >   BOOL PreviewInBrowserTab::GreySection()
04682 
04683     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04684     Created:    10/06/97
04685     Inputs:     -
04686     Outputs:    -
04687     Returns:    -
04688     Purpose:    Called when the user has closed all documents.
04689 
04690 ********************************************************************************************/
04691 
04692 BOOL PreviewInBrowserTab::GreySection()
04693 {
04694     ERROR2IF(pPropertiesDlg == NULL,FALSE,"PreviewInBrowserTab::GreySection called with no dialog pointer");
04695 
04696     //Ensure we are talking to the correct page.
04697     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
04698     if (!ok)
04699         return TRUE;
04700 
04701     // Only update if we are not already grey. 
04702     if (m_GreyStatus == TRUE)
04703         return TRUE;
04704 
04705     // Call the central greying/ungreying function
04706     ok = ChangeControlStatus(FALSE);    
04707 
04708     // Set the correct grey status
04709     m_GreyStatus = TRUE;
04710     SetApplyNowState(FALSE);
04711 
04712     return ok;
04713 } 
04714 
04715 /********************************************************************************************
04716 
04717 >   BOOL PreviewInBrowserTab::UngreySection()
04718 
04719     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04720     Created:    10/06/97
04721     Inputs:     -
04722     Outputs:    -
04723     Returns:    -
04724     Purpose:    Called when the user has selected a new document.
04725 
04726 ********************************************************************************************/
04727 
04728 BOOL PreviewInBrowserTab::UngreySection()
04729 {
04730     ERROR2IF(pPropertiesDlg == NULL,FALSE,"PreviewInBrowserTab::UngreySection called with a NULL dialog pointer");
04731 
04732     // Ensure we are talking to the correct page.
04733     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
04734     if (!ok)
04735         return TRUE;
04736 
04737     // Only update if we are not already ungrey. 
04738     if (m_GreyStatus == FALSE)
04739         return TRUE;
04740 
04741     // Call the central greying/ungreying function
04742     ok = ChangeControlStatus(TRUE); 
04743     
04744     m_GreyStatus = FALSE;
04745 
04746     return ok;
04747 }
04748 
04749 /********************************************************************************************
04750 
04751 >   BOOL PreviewInBrowserTab::ChangeControlStatus(const BOOL Status)
04752 
04753     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04754     Created:    10/06/97
04755     Inputs:     -
04756     Outputs:    -
04757     Returns:    -
04758     Purpose:    Called to grey/ungrey all controls on this tab. 
04759 
04760 ********************************************************************************************/
04761 
04762 
04763 BOOL PreviewInBrowserTab::ChangeControlStatus(const BOOL Status)
04764 {
04765     pPropertiesDlg->EnableGadget(_R(IDC_PLAINBKGND),    Status);
04766     pPropertiesDlg->EnableGadget(_R(IDC_DOCBKGND),      Status);
04767     pPropertiesDlg->EnableGadget(_R(IDC_CHQBKGND),      Status);
04768     pPropertiesDlg->EnableGadget(_R(IDC_GIF_BITMAPPREVIEW), Status);
04769     pPropertiesDlg->EnableGadget(_R(IDC_HTMLSTUB),      Status);
04770 //  pPropertiesDlg->EnableGadget(_R(IDC_GIF_T5CHECK2),      Status);
04771 
04772     // Grey the apply now/ok/cancel buttons.
04773     PreviewInBrowserTab::GreyApplyNow();
04774     return TRUE;
04775 }           
04776 
04777 
04778 /**********************************************************************************************************************
04779 
04780 >   BOOL PreviewInBrowserTab::UpdateSection()
04781 
04782     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04783     Created:    10/06/97
04784     Returns:    -
04785     Purpose:    Called when we have switched to a new document and need to update all the 
04786                 controls on this tab. 
04787     
04788 *************************************************************************************************************************/
04789 
04790 BOOL PreviewInBrowserTab::UpdateSection()
04791 {
04792     ERROR2IF(pPropertiesDlg == NULL,FALSE,"PreviewInBrowserTab::UpdateSection called with a NULL dialog pointer");
04793 
04794     // Ensure we a re talking to the correct page.
04795     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
04796     if (!ok)
04797         return TRUE;        
04798 
04799     // Show the correct details.
04800     ShowDetails();
04801 
04802     return TRUE;
04803 }
04804 
04805 /********************************************************************************************
04806 
04807 >   BOOL PreviewInBrowserTab::ShowDetails()
04808 
04809     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04810     Created:    10/06/97
04811     Inputs:     -
04812     Outputs:    -
04813     Returns:    -
04814     Purpose:    Shows the details of the associated SPREAD in this tab.
04815     
04816 ********************************************************************************************/
04817 
04818 BOOL PreviewInBrowserTab::ShowDetails()
04819 {
04820     ERROR2IF(pPropertiesDlg == NULL,FALSE,"PreviewInBrowserTab::ShowDetails called with a NULL dialog pointer");
04821 
04822     // Talk to the correct page.
04823     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
04824     if (!ok)
04825         return TRUE;        
04826 
04827     BrowserBackground Bgr = g_Background;   // Get the background details.
04828     BOOL Info = g_InfoInHtmlStub;           // Get the Include 'file info within HTML stub' details.
04829 
04830     // Selelct the correct 'background' radio button.
04831     if(Bgr == BROWSER_BGR_NONE)
04832     {
04833         // Check this radio button.
04834         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_PLAINBKGND), TRUE);
04835 
04836         // Uncheck all other radio buttons in this group.
04837         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_DOCBKGND), FALSE);
04838         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_CHQBKGND), FALSE);
04839     }
04840             
04841     else if (Bgr ==  BROWSER_BGR_DOC)
04842     {
04843         // Check this radio button.
04844         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_DOCBKGND), TRUE);
04845 
04846         // Uncheck all other radio buttons in this group.
04847         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_PLAINBKGND), FALSE);
04848         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_CHQBKGND), FALSE);
04849     }
04850         
04851     else if (Bgr == BROWSER_BGR_CHECKER)
04852     {
04853         // Check this radio button.
04854         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_CHQBKGND), TRUE);     
04855 
04856         // Uncheck all other radio buttons in this group.
04857         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_PLAINBKGND), FALSE);
04858         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_DOCBKGND), FALSE);
04859     }
04860                     
04861     else if (Bgr == BROWSER_BGR_BITMAP)
04862     {
04863         // In the Bitmap Preview diagram, the user selected this radio button. 
04864         // In the animation properties dialog, this radio button has not been included.
04865         // We therfore, force the selection to BROWSER_BGR_NONE
04866         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_PLAINBKGND), TRUE);    
04867 
04868         // Uncheck all other radio buttons in this group.
04869         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_DOCBKGND), FALSE);
04870         pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_CHQBKGND), FALSE);
04871 
04872         // Make a note of this new selection.
04873         g_Background = BROWSER_BGR_BITMAP;
04874     }   
04875 
04876     // Set the correct state of the 'Include file info within HTML stub' check box.
04877     pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_HTMLSTUB), Info == TRUE);
04878 
04879     // Everything ok.
04880     return TRUE;
04881 }
04882 
04883 /*************************************************************************************************************************
04884 
04885 >   BOOL PreviewInBrowserTab::UpdateLayerSection()
04886 
04887     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04888     Created:    10/06/97
04889     Inputs:     -
04890     Outputs:    -
04891     Returns:    TRUE if ok, FALSE otherwise
04892     Purpose:    Called when the spread-related section of the tab should be updated.
04893 
04894 ***************************************************************************************************************************/
04895 BOOL PreviewInBrowserTab::UpdateLayerSection()
04896 {
04897     ERROR2IF(pPropertiesDlg == NULL,FALSE,"PreviewInBrowserTab::UpdateLayerSection() called with a NULL dialog pointer");
04898 
04899     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
04900     if (!ok)
04901         return TRUE;    
04902 
04903     // Display the details in this tab.
04904     ShowDetails();
04905     
04906     // Everything OK.
04907     return TRUE;
04908 }
04909 
04910 /********************************************************************************************
04911 
04912 >   BOOL PreviewInBrowserTab::HandleMsg(DialogMsg* Msg)
04913 
04914     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com> (from stefan code)
04915     Created:    10/06/97
04916     Inputs:     -
04917     Outputs:    -
04918     Returns:    -
04919     Purpose:    Handles all the messages for this Animation colours tab.
04920 
04921 ********************************************************************************************/
04922 
04923 BOOL PreviewInBrowserTab::HandleMsg(DialogMsg* Msg)
04924 {
04925     ERROR2IF(Msg == NULL,FALSE,"PreviewInBrowserTab::Message null message received");
04926     ERROR2IF(pPropertiesDlg == NULL,FALSE,"PreviewInBrowserTab::HandleMsg called with a NULL dialog pointer");
04927 
04928     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
04929     if (!ok)
04930         return TRUE;    
04931 
04932     // Handle the message.
04933     switch(Msg->DlgMsg)
04934     {
04935         case DIM_CREATE:
04936         {
04937             // Set the Grey status flag to FALSE.
04938             m_GreyStatus = FALSE;   
04939 
04940             // Perform the necessary initialization. 
04941             ok = InitSection();
04942             if (!ok)
04943                 InformError();
04944 
04945             // Get the global settnigs.
04946             BrowserBackground Bgr = g_Background;
04947             BOOL Info = g_InfoInHtmlStub;
04948             
04949             // Set the background radiobuttons.
04950             if(Bgr == BROWSER_BGR_NONE)
04951                 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_PLAINBKGND), TRUE);
04952             
04953             else if (Bgr ==  BROWSER_BGR_DOC)
04954                 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_DOCBKGND), TRUE);
04955             
04956             else if (Bgr == BROWSER_BGR_CHECKER)
04957                 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_CHQBKGND), TRUE);     
04958                     
04959             else if (Bgr == BROWSER_BGR_BITMAP)
04960             {
04961                 // In the Bitmap Preview diagram, the user selected this radio button. 
04962                 // In the animation properties dialog, this radio button has not been included.
04963                 // We therfore, force the selection to BROWSER_BGR_NONE
04964                 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_PLAINBKGND), TRUE);    
04965 
04966                 // Make a note of this new selection.
04967                 g_Background = BROWSER_BGR_BITMAP;
04968             }
04969                             
04970             // Setup the checkboxes.
04971             pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_HTMLSTUB), Info == TRUE);     
04972 
04973             break;
04974         }
04975 
04976         case DIM_LFT_BN_CLICKED:
04977         {
04978             if (FALSE) {}
04979             else if (Msg->GadgetID == _R(IDC_GIF_BITMAPPREVIEW))
04980             {
04981                 // A Click on the 'Browser Preview' button
04982 
04983 PORTNOTE("other", "Disabled BrowserPreviewOptions")
04984 #ifndef EXCLUDE_FROM_XARALX
04985                 // The op cannot be invoked if the current doc. is empty.
04986                 // Return false if the document is empty.
04987                 String_256 ShadeReason;
04988                 OpState State = OpGrabAllFrames::GetState(&ShadeReason, NULL);
04989 
04990                 if (State.Greyed)
04991                 {
04992                     // The current doc, is empty, inform the user.
04993                     InformError(_R(IDS_NOFRAMESTOPREVIEW));
04994                 }
04995                 else
04996                 {
04997                     // Preview the animtion in the browser.
04998                     // Store the current browser options here.
04999                     BrowserPreviewOptions BrowserOptions;
05000 
05001                     // Get the browser options
05002                     GetBrowserValues(&BrowserOptions);      
05003 
05004                     // Invoke the OP to preview the animation.
05005                     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_FRAME_BROWSERPREVIEW); 
05006 
05007                     if (pOpDesc != NULL)
05008                     pOpDesc->Invoke();
05009                 }
05010 #endif
05011             }
05012             else if (Msg->GadgetID == _R(IDC_PLAINBKGND))
05013             {
05014                 // Set the correct state of the applynow flag.
05015                 PreviewInBrowserTab::SetApplyNowState(TRUE);
05016 
05017                 // Ungrey the apply/ok/cancel buttons.
05018                 PreviewInBrowserTab::UngreyApplyNow();
05019             }
05020             else if (Msg->GadgetID == _R(IDC_DOCBKGND))
05021             {
05022                 // Set the correct state of the applynow flag.
05023                 PreviewInBrowserTab::SetApplyNowState(TRUE);
05024 
05025                 // Ungrey the apply/ok/cancel buttons.
05026                 PreviewInBrowserTab::UngreyApplyNow();
05027             }
05028             else if (Msg->GadgetID == _R(IDC_CHQBKGND))
05029             {
05030                 // Set the correct state of the applynow flag.
05031                 PreviewInBrowserTab::SetApplyNowState(TRUE);
05032 
05033                 // Ungrey the apply/ok/cancel buttons.
05034                 PreviewInBrowserTab::UngreyApplyNow();
05035             }
05036             else if (Msg->GadgetID == _R(IDC_GIF_BITMAPPREVIEW))
05037             {
05038                 // Set the correct state of the applynow flag.
05039                 PreviewInBrowserTab::SetApplyNowState(TRUE);
05040 
05041                 // Ungrey the apply/ok/cancel buttons.
05042                 PreviewInBrowserTab::UngreyApplyNow();
05043             }
05044         }
05045         break;
05046 
05047         case DIM_SET_ACTIVE:
05048         {
05049             //Force the  Apply now/ok buttons into a grey state.
05050             //PreviewInBrowserTab::GreyApplyNow();
05051             if(PreviewInBrowserTab::GetApplyNowState())
05052             {
05053                 // Ungrey the apply/ok/cancel buttons.
05054                 PreviewInBrowserTab::UngreyApplyNow();  
05055             }           
05056         }           
05057         break;
05058 
05059         default:
05060             break;
05061     }
05062     return TRUE;
05063 }  
05064 
05065 
05066 /********************************************************************************************
05067 
05068 >   void PreviewInBrowserTab::GetBrowserValues(BrowserPreviewOptions  *pBrowserOptions)
05069 
05070 
05071     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com> (from stefan code)
05072     Created:    10/06/97
05073     Inputs:     -
05074     Outputs:    BrowserOptions - receives the browser options stored in the Browser tab's controls
05075     Returns:    TRUE if successful, else FALSE.
05076     Purpose:    - Gets the values of the browser controls.
05077     
05078 ********************************************************************************************/
05079 
05080 BOOL PreviewInBrowserTab::GetBrowserValues(BrowserPreviewOptions  *pBrowserOptions)
05081 {
05082     ERROR2IF(pPropertiesDlg == NULL,FALSE,"PreviewInBrowserTab::HandleMsg called with a NULL dialog pointer");
05083 
05084 /*  // talk to the browser tab
05085     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
05086     if (!ok)
05087         return TRUE; */
05088 
05089     // Take the current settings from the tab
05090     // Talk to page done in CommitSection
05091     CommitSection();
05092 
05093     // Force the image map flag to false.
05094 PORTNOTE("other", "Disabled BrowserPreviewOptions")
05095 #ifndef EXCLUDE_FROM_XARALX
05096     BOOL Imagemap = FALSE;
05097 
05098     // Make a note of the options.
05099     pBrowserOptions->Set(g_Background, g_InfoInHtmlStub, Imagemap);
05100 #endif
05101 
05102     // Everything ok.
05103     return TRUE;
05104 }
05105 
05106 
05107 /********************************************************************************************************************
05108 
05109 >   BOOL PreviewInBrowserTab::UpdateApplyState()
05110 
05111     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
05112     Created:    10/06/97
05113     Inputs:     -
05114     Outputs:    -
05115     Returns:    TRUE if ok, FALSE otherwise
05116     Purpose:    This changes the 'Apply now' state based on the settings of the active spread
05117                 and the settings in this tab.
05118                 If the settings are the same, the 'Apply state' is FALSE, else it is TRUE.
05119     
05120 **********************************************************************************************************************/
05121 
05122 BOOL PreviewInBrowserTab::UpdateApplyState()
05123 {
05124     ERROR2IF(pPropertiesDlg == NULL,FALSE,"PreviewInBrowserTab::UpdateApplyState called with a NULL dialog pointer");
05125 /*
05126     // Ensure we talk ot the correct page.
05127     BOOL ok = pPropertiesDlg->TalkToPage(GetPageID());
05128     if (!ok)
05129         return TRUE;
05130 
05131     // What is the current state of the buttons.
05132     BOOL ApplyState = GetApplyNow();
05133 
05134     if(!GetCurrentApplyNow())
05135     {
05136         // Make a note of the state.
05137         SetCurrentApplyNow(ApplyState);
05138     }
05139 
05140     //Force the  Apply now/ok buttons into a grey state.
05141     PreviewInBrowserTab::GreyApplyNow();
05142 
05143     // Set the status to GREY.
05144     PreviewInBrowserTab::SetApplyNowState(FALSE); 
05145 */
05146     // Everything ok.
05147     return TRUE;
05148 }
05149 
05150 /******************************************************************************************
05151 
05152 >   BOOL PreviewInBrowserTab::InitSection()
05153 
05154     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
05155     Created:    10/06/97
05156     Inputs:     -
05157     Outputs:    -
05158     Returns:    TRUE if successful, else FALSE
05159     Purpose:    Sets initial values for this tab on the animation properties dialog box.
05160 
05161 ******************************************************************************************/
05162 
05163 BOOL PreviewInBrowserTab::InitSection()
05164 {
05165     ERROR2IF(pPropertiesDlg == NULL,FALSE,"PreviewInBrowserTab::InitSection called with a NULL dialog pointer");
05166 
05167     // Get a ptr to the current document.
05168     Document* pDoc = Document::GetCurrent();
05169 
05170     // If there is no document, then grey the tab.
05171     if(!pDoc)
05172     {
05173         GreySection();
05174         return (TRUE);
05175     }
05176 
05177     // Display the details.
05178     ShowDetails();
05179 
05180     //Everything ok.
05181     return TRUE;
05182 }
05183 
05184 /********************************************************************************************
05185 
05186 >   static BOOL PreviewInBrowserTab::Declare()
05187 
05188     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
05189     Created:    10/06/97
05190     Returns:    TRUE if successfully declared preferences
05191                 FALSE otherwise
05192     Purpose:    To declare preferences associated with the bitmap preview properties.
05193 
05194 ********************************************************************************************/
05195 
05196 BOOL PreviewInBrowserTab::Declare()
05197 {
05198     if (Camelot.DeclareSection(_T("Browser Preview"), 5))
05199     {
05200         Camelot.DeclarePref( NULL, _T("BrowserBackground"), (INT32*)&g_Background, 0, 3 );
05201         Camelot.DeclarePref( NULL, _T("IncludeImageMap"), &g_Imagemap, 0, 1 );
05202         Camelot.DeclarePref( NULL, _T("IncludeInfoInHTMLStub"), &g_InfoInHtmlStub, 0, 1 );
05203     }
05204 
05205     // All ok
05206     return TRUE;
05207 }
05208 
05209                         
05210 
05211                         

Generated on Sat Nov 10 03:44:11 2007 for Camelot by  doxygen 1.4.4