00001 // $Id: optsscal.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 // Implementation of the Scale/Dimension tab of the options dialog box 00100 00101 /* 00102 00103 */ 00104 00105 #include "camtypes.h" 00106 //WEBSTER-ranbirr-13/11/96 00107 #ifndef WEBSTER 00108 #include "appprefs.h" 00109 //#include "prefsdlg.h" // dialog/gadget ids 00110 //#include "optsres.h" // error strings 00111 #include "optsscal.h" 00112 #include "optsmsgs.h" 00113 //#include "app.h" // Camelot object 00114 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00115 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00116 //#include "nev.h" 00117 //#include "document.h" // document object - in camtypes.h [AUTOMATICALLY REMOVED] 00118 00119 CC_IMPLEMENT_DYNAMIC(ScaleTab, OptionsTabs) 00120 00121 // This is not compulsory, but you may as well put it in so that the correct version 00122 // of your file can be registered in the .exe 00123 DECLARE_SOURCE("$Revision: 1282 $"); 00124 00125 /******************************************************************************************** 00126 00127 > ScaleTab::ScaleTab() 00128 00129 00130 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00131 Created: 24/1/95 00132 Inputs: - 00133 Outputs: - 00134 Returns: - 00135 Purpose: ScaleTab constructor. Creates a non-Scaleable operation 00136 Errors: - 00137 SeeAlso: - 00138 00139 ********************************************************************************************/ 00140 00141 ScaleTab::ScaleTab() 00142 { 00143 pDimScale = NULL; 00144 } 00145 00146 /******************************************************************************************** 00147 00148 > ScaleTab::~ScaleTab() 00149 00150 00151 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00152 Created: 24/1/95 00153 Inputs: - 00154 Outputs: - 00155 Returns: - 00156 Purpose: ScaleTab destructor 00157 Errors: - 00158 SeeAlso: - 00159 00160 ********************************************************************************************/ 00161 00162 ScaleTab::~ScaleTab() 00163 { 00164 } 00165 00166 /******************************************************************************************** 00167 00168 > BOOL ScaleTab::Init() 00169 00170 00171 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00172 Created: 24/1/95 00173 Inputs: - 00174 Outputs: - 00175 Returns: True if initialised ok, False if failed. 00176 Purpose: ScaleTab initialisation routine 00177 Errors: - 00178 SeeAlso: - 00179 00180 ********************************************************************************************/ 00181 00182 BOOL ScaleTab::Init() 00183 { 00184 return TRUE; 00185 } 00186 00187 00188 /****************************************************************************************** 00189 00190 > CDlgResID ScaleTab::GetPageID()() 00191 00192 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00193 Created: 24/1/95 00194 Inputs: - 00195 Outputs: - 00196 Returns: The dialog ID of this tab section. 00197 Purpose: Allows the options dialog code to determine the dialog ID of this section. 00198 Errors: - 00199 SeeAlso: - 00200 00201 ******************************************************************************************/ 00202 00203 CDlgResID ScaleTab::GetPageID() 00204 { 00205 return _R(IDD_OPTSTAB_SCALE); 00206 } 00207 00208 /****************************************************************************************** 00209 00210 > BOOL ScaleTab::IsDocumentOption() 00211 00212 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00213 Created: 24/1/95 00214 Inputs: - 00215 Outputs: - 00216 Returns: Returns True if this tab is a document option. 00217 Purpose: Allows the document options dialog code to determine if this tab belongs 00218 to the group of document options. 00219 Errors: - 00220 SeeAlso: IsProgramOption(); 00221 00222 ******************************************************************************************/ 00223 00224 BOOL ScaleTab::IsDocumentOption() 00225 { 00226 return TRUE; // This tab is not a document option 00227 } 00228 00229 /****************************************************************************************** 00230 00231 > BOOL ScaleTab::IsProgramOption() 00232 00233 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00234 Created: 24/1/95 00235 Inputs: - 00236 Outputs: - 00237 Returns: Returns True if this tab is a program option. 00238 Purpose: Allows the program options dialog code to determine if this tab belongs 00239 to the group of program options. 00240 Errors: - 00241 SeeAlso: IsProgramOption(); 00242 00243 ******************************************************************************************/ 00244 00245 BOOL ScaleTab::IsProgramOption() 00246 { 00247 return TRUE; // This tab is a program option 00248 } 00249 00250 00251 /****************************************************************************************** 00252 00253 > BOOL ScaleTab::CommitSection() 00254 00255 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00256 Created: 24/1/95 00257 Inputs: - 00258 Outputs: - 00259 Returns: True if values in dialog box ok, False otherwise. 00260 Purpose: Takes the values in the Scale section tab of the options dialog box and 00261 sets the associated preference values accordingly 00262 Called when ok is pressed on the dialog box. 00263 Errors: - 00264 SeeAlso: - 00265 00266 ******************************************************************************************/ 00267 00268 BOOL ScaleTab::CommitSection() 00269 { 00270 TRACEUSER( "Neville", _T("commit Scale section\n")); 00271 ERROR3IF(pPrefsDlg == NULL, "ScaleTab::CommitSection called with no dialog pointer"); 00272 00273 BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_SCALE)); // The Scale tab identifier 00274 if (!ok) 00275 return TRUE; // Talk to View failed to return now 00276 00277 // Ok has been pressed so take the values from this section of the dialog box 00278 // Takes the values in the dialog and sets the DimScale object accordingly. 00279 BOOL Valid=TRUE; // Flag for validity of value 00280 // BOOL State=FALSE; // Flag for state of button/switch 00281 BOOL SetOk=TRUE; // Preference value set ok 00282 00283 // Section = Scale settings 00284 00285 // Now check that we have the selected view still, just in case it has switched 00286 // without us being told about it or even we have no current document/view. 00287 // This may be a valid state now, so do not complain about it. 00288 DocView* pCurrentView = DocView::GetSelected(); 00289 if (pCurrentView != NULL) 00290 { 00291 // Only if there is a current view do we read the values. 00292 String_256 DrawingStr; 00293 String_256 RealStr; 00294 //TCHAR* pDrawingStr = DrawingStr; 00295 //TCHAR* pRealStr = RealStr; 00296 BOOL Active; 00297 00298 // Get the values from the dialog box 00299 Active = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_USESCALEFACTOR),0,1,0, &Valid); 00300 DrawingStr = pPrefsDlg->GetStringGadgetValue(_R(IDC_OPTS_DRAWINGSCALE), &Valid); 00301 RealStr = pPrefsDlg->GetStringGadgetValue(_R(IDC_OPTS_REALSCALE), &Valid); 00302 00303 Spread* pSpread = pCurrentView->GetFirstSelectedSpread(); 00304 // If no selected spread then use the visible spread 00305 if (pSpread == NULL) 00306 pSpread = pCurrentView->GetVisibleSpread(); 00307 00308 // Only do the chnage if we have a valid spread pointer and we have changed something. 00309 if ( (pSpread != NULL) && 00310 ( 00311 (OldActiveState != Active) || 00312 (OldDrawingStr != DrawingStr) || 00313 (OldRealStr != RealStr) 00314 ) 00315 ) 00316 { 00317 pDimScale = pSpread->GetPtrDimScale(); 00318 if (pDimScale != NULL) 00319 { 00320 // Only if active is set do we need to try and set new strings 00321 // and hence a new drawing scale 00322 if (Active) 00323 { 00324 // Dim Scales can only be 32 characters long 00325 String_32 DrawingStr32 = _T(""); 00326 String_32 RealStr32 = _T(""); 00327 // Check if read in strings are longer than this 00328 if (DrawingStr.Length() > DrawingStr32.MaxLength()) 00329 { 00330 InformError(_R(IDE_OPTS_INVALIDDRAWSCALE)); 00331 return FALSE; 00332 } 00333 if (RealStr.Length() > RealStr32.MaxLength()) 00334 { 00335 InformError(_R(IDE_OPTS_INVALIDREALSCALE)); 00336 return FALSE; 00337 } 00338 00339 RealStr32 = RealStr; 00340 DrawingStr32 = DrawingStr; 00341 00342 // Try and set these strings as new drawing and real scales strings 00343 SetOk = pDimScale->SetDrawingScaleStr(DrawingStr32); 00344 if (!SetOk) 00345 { 00346 InformError(_R(IDE_OPTS_INVALIDDRAWSCALE)); 00347 return FALSE; 00348 } 00349 00350 SetOk = SetOk && pDimScale->SetRealScaleStr(RealStr32); 00351 if (!SetOk) 00352 { 00353 InformError(_R(IDE_OPTS_INVALIDREALSCALE)); 00354 return FALSE; 00355 } 00356 00357 // Now try to convert these into a new scaling factor 00358 if (SetOk) 00359 SetOk = SetOk && pDimScale->SetScaleFactor(); 00360 00361 // If we failed in any of the conversions then warn the user and fail 00362 if (!SetOk) 00363 { 00364 InformError(_R(IDE_OPTS_INVALIDSCALING)); 00365 return FALSE; 00366 } 00367 } 00368 00369 // Set up a possibly new active state 00370 pDimScale->SetActiveState(Active); 00371 00372 } 00373 00374 // Now tell other users of units/scaling factors that there they are likely 00375 // to need to update any currently displayed units. 00376 Document *pCurrentDoc = (Document *)pSpread->FindOwnerDoc(); 00377 BROADCAST_TO_ALL(OptionsChangingMsg(pCurrentDoc, OptionsChangingMsg::NEWUNITS)); 00378 // unfortunately pScopeDoc is NULL!, and since pCurrentDoc is calulated I thought it ought to use! - Ed 17/10/95 00379 // BROADCAST_TO_ALL(OptionsChangingMsg(pScopeDocument, OptionsChangingMsg::OptionsState::NEWUNITS)); 00380 00381 // Make sure the document is marked as modified. 00382 pCurrentDoc->SetModified(TRUE); 00383 00384 // And note the new states 00385 OldActiveState = Active; 00386 OldDrawingStr = DrawingStr; 00387 OldRealStr = RealStr; 00388 } 00389 } 00390 // else 00391 // ERROR2(FALSE,_R(IDE_OPTS_READPREF_SCALE)); 00392 00393 return TRUE; 00394 } 00395 00396 /******************************************************************************************** 00397 00398 > BOOL ScaleTab::GreySection() 00399 00400 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00401 Created: 4/2/95 00402 Inputs: - 00403 Outputs: - 00404 Returns: - 00405 Purpose: Called when the user has closed all documents 00406 Errors: - 00407 SeeAlso: ScaleTab::UngreySection; 00408 00409 ********************************************************************************************/ 00410 00411 BOOL ScaleTab::GreySection() 00412 { 00413 TRACEUSER( "Neville", _T("GreySection in ScaleTab section\n")); 00414 ERROR2IF(pPrefsDlg == NULL,FALSE,"ScaleTab::GreySection called with no dialog pointer"); 00415 00416 BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_SCALE)); // The ScaleTab identifier 00417 if (!ok) 00418 return TRUE; // Talk to page failed to return now 00419 00420 // Make sure the information field displaying the name of the current document 00421 // is correct. 00422 String_256 DocumentName(_R(IDT_OPTS_SCALING_INFO)); 00423 DocumentName += *GetDocumentName(); 00424 pPrefsDlg->SetStringGadgetValue(_R(IDC_OPTS_INFO), DocumentName); 00425 00426 // Only update if we are not already grey 00427 if (GreyStatus == TRUE) 00428 return TRUE; 00429 00430 // Call our central greying/ungreying function 00431 ok = ChangeControlStatus(FALSE); 00432 00433 GreyStatus = TRUE; 00434 00435 return ok; 00436 } 00437 00438 /******************************************************************************************** 00439 00440 > BOOL ScaleTab::UngreySection() 00441 00442 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00443 Created: 4/2/95 00444 Inputs: - 00445 Outputs: - 00446 Returns: - 00447 Purpose: Called when the user has selected a new document 00448 Errors: - 00449 SeeAlso: ScaleTab::UngreySection; 00450 00451 ********************************************************************************************/ 00452 00453 BOOL ScaleTab::UngreySection() 00454 { 00455 TRACEUSER( "Neville", _T("UngreySection in ScaleTab section\n")); 00456 ERROR2IF(pPrefsDlg == NULL,FALSE,"ScaleTab::UngreySection called with no dialog pointer"); 00457 00458 BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_SCALE)); // The ScaleTab identifier 00459 if (!ok) 00460 return TRUE; // Talk to page failed to return now 00461 00462 // Make sure the information field displaying the name of the current document 00463 // is correct. 00464 String_256 DocumentName(_R(IDT_OPTS_SCALING_INFO)); 00465 DocumentName += *GetDocumentName(); 00466 pPrefsDlg->SetStringGadgetValue(_R(IDC_OPTS_INFO), DocumentName); 00467 00468 // Only update if we are not already ungrey 00469 if (GreyStatus == FALSE) 00470 return TRUE; 00471 00472 // Call our central greying/ungreying function 00473 ok = ChangeControlStatus(TRUE); 00474 00475 GreyStatus = FALSE; 00476 00477 return ok; 00478 } 00479 00480 /******************************************************************************************** 00481 00482 > BOOL ScaleTab::ChangeControlStatus(const BOOL Status) 00483 00484 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00485 Created: 4/2/95 00486 Inputs: - 00487 Outputs: - 00488 Returns: - 00489 Purpose: Called to grey/ungrey all controls on this tab. 00490 Errors: - 00491 SeeAlso: ScaleTab::GreySection; ScaleTab::UngreySection; 00492 00493 ********************************************************************************************/ 00494 00495 BOOL ScaleTab::ChangeControlStatus(const BOOL Status) 00496 { 00497 // Grey/ungrey the information fields 00498 pPrefsDlg->EnableGadget(_R(IDC_OPTS_INFO), Status); 00499 00500 // Grey/ungrey the controlling Switch 00501 pPrefsDlg->EnableGadget(_R(IDC_OPTS_USESCALEFACTOR), Status); 00502 00503 // Grey/ungrey the display fields 00504 pPrefsDlg->EnableGadget(_R(IDC_OPTS_DRAWINGSCALE), Status); 00505 pPrefsDlg->EnableGadget(_R(IDC_OPTS_REALSCALE), Status); 00506 00507 // Grey/ungrey the static text fields accordingly 00508 pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALEGROUP), Status); 00509 pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALEEG), Status); 00510 pPrefsDlg->EnableGadget(_R(IDC_OPTS_REALWORLD), Status); 00511 pPrefsDlg->EnableGadget(_R(IDC_OPTS_DRAWING), Status); 00512 pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALETO), Status); 00513 pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALETO2), Status); 00514 00515 return TRUE; 00516 } 00517 00518 /******************************************************************************************** 00519 00520 > BOOL ScaleTab::UpdateSection(String_256 *DocumentName) 00521 00522 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00523 Created: 4/2/95 00524 Inputs: Name of document 00525 Outputs: - 00526 Returns: - 00527 Purpose: Called when we have switched to a new document and need to update all the 00528 controls on this tab. Should only init the tab if the page is present. 00529 The document name allows the info field on the tab to be filled in correctly. 00530 Errors: - 00531 SeeAlso: ScaleTab::GreySection; ScaleTab::UngreySection; ScaleTab::InitSection; 00532 00533 ********************************************************************************************/ 00534 00535 BOOL ScaleTab::UpdateSection(String_256 *DocumentName) 00536 { 00537 TRACEUSER( "Neville", _T("ScaleTab::UpdateSection\n")); 00538 ERROR2IF(pPrefsDlg == NULL,FALSE,"ScaleTab::UpdateSection called with no dialog pointer"); 00539 00540 BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_SCALE)); // The ScaleTab identifier 00541 if (!ok) 00542 return TRUE; // page not present 00543 00544 // Remove any lists that we have created. 00545 //pPrefsDlg->DeleteAllValues(_R(IDC_OPTS_SIZELIST)); 00546 00547 // Call the normal init section code 00548 return InitSection(); 00549 } 00550 00551 /******************************************************************************************** 00552 00553 > BOOL ScaleTab::HandleMsg(DialogMsg* Msg) 00554 00555 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00556 Created: 24/1/95 00557 Inputs: - 00558 Outputs: - 00559 Returns: - 00560 Purpose: Handles all the Scale options tabs messages 00561 Errors: - 00562 SeeAlso: - 00563 00564 ********************************************************************************************/ 00565 00566 BOOL ScaleTab::HandleMsg(DialogMsg* Msg) 00567 { 00568 TRACEUSER( "Neville", _T("HandleScaleMsg\n")); 00569 ERROR2IF(Msg == NULL,FALSE,"ScaleTab::Message null message received"); 00570 ERROR2IF(pPrefsDlg == NULL,FALSE,"ScaleTab::HandleMsg called with no dialog pointer"); 00571 00572 BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_SCALE)); // The Scale tab identifier 00573 if (!ok) 00574 return TRUE; // page not present 00575 00576 switch(Msg->DlgMsg) 00577 { 00578 case DIM_CREATE: // Initialise controls 00579 GreyStatus = FALSE; // we are ungreyed by default 00580 ok = InitSection(); 00581 if (!ok) 00582 InformError(); 00583 break; 00584 case DIM_LFT_BN_CLICKED: 00585 OptionsTabs::SetApplyNowState(TRUE); 00586 if (Msg->GadgetID == _R(IDC_OPTS_USESCALEFACTOR)) 00587 { 00588 BOOL Valid; 00589 BOOL Active = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_USESCALEFACTOR),0,1,0,&Valid); 00590 // Grey/ungrey the editable fields accordingly 00591 pPrefsDlg->EnableGadget(_R(IDC_OPTS_DRAWINGSCALE), Active); 00592 pPrefsDlg->EnableGadget(_R(IDC_OPTS_REALSCALE), Active); 00593 // Grey/ungrey the static text fields accordingly 00594 pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALEEG), Active); 00595 pPrefsDlg->EnableGadget(_R(IDC_OPTS_REALWORLD), Active); 00596 pPrefsDlg->EnableGadget(_R(IDC_OPTS_DRAWING), Active); 00597 pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALETO), Active); 00598 pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALETO2), Active); 00599 pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALEGROUP), Active); 00600 } 00601 break; 00602 case DIM_SELECTION_CHANGED: 00603 case DIM_TEXT_CHANGED: 00604 OptionsTabs::SetApplyNowState(TRUE); 00605 break; 00606 default: 00607 break; 00608 } 00609 00610 return TRUE; 00611 } 00612 00613 00614 /****************************************************************************************** 00615 00616 > BOOL ScaleTab::InitSection() 00617 00618 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00619 Created: 24/1/95 00620 Inputs: - 00621 Outputs: - 00622 Returns: TRUE if successful, else FALSE 00623 Purpose: Sets initial values for the Scale section of the options dialog box. 00624 This section includes the:- 00625 Errors: - 00626 SeeAlso: AppPrefsDlg; OptionsTabs; 00627 00628 ******************************************************************************************/ 00629 00630 BOOL ScaleTab::InitSection() 00631 { 00632 TRACEUSER( "Neville", _T("ScaleTab::InitSection\n")); 00633 ERROR2IF(pPrefsDlg == NULL,FALSE,"ScaleTab::InitSection called with no dialog pointer"); 00634 00635 // BOOL ReadOk = FALSE; // Flag to say whether the preference value was read ok 00636 00637 // Make sure the information field displaying the name of the current document 00638 // is correct. 00639 String_256 DocumentName(_R(IDT_OPTS_SCALING_INFO)); 00640 DocumentName += *GetDocumentName(); 00641 pPrefsDlg->SetStringGadgetValue(_R(IDC_OPTS_INFO), DocumentName); 00642 00643 // Section = Scale settings 00644 00645 DocView* pSelectedView = DocView::GetSelected(); 00646 // This may now be a valid state so must not error 00647 //ERROR3IF(pSelectedView == NULL,"ScaleTab::InitSection Where's the current view eh?"); 00648 if (pSelectedView != NULL) 00649 { 00650 Spread* pSpread = pSelectedView->GetFirstSelectedSpread(); 00651 00652 // If no selected spread then use the visible spread 00653 if (pSpread == NULL) 00654 pSpread = pSelectedView->GetVisibleSpread(); 00655 00656 // If no selected spread then use the first spread 00657 // Of course, this should not be here but above routines seem to return 00658 // null a bit too often for my liking 00659 if (pSpread == NULL) 00660 { 00661 TRACEUSER( "Neville", _T("ScaleTab::InitSection BODGE! using 1st spread\n")); 00662 Document* pSelectedDoc = Document::GetSelected(); 00663 if (pSelectedDoc !=NULL ) 00664 pSpread = pSelectedDoc->FindFirstSpread(); 00665 } 00666 00667 // Go and get a pointer to the scaling values 00668 if (pSpread != NULL) 00669 { 00670 pDimScale = pSpread->GetPtrDimScale(); 00671 if (pDimScale != NULL) 00672 { 00673 // And now show the initial state of the controls given this 00674 // scaling 00675 ShowScaleDetails(); 00676 } 00677 } 00678 } 00679 else 00680 { 00681 // If no current view then ensure section is greyed 00682 GreySection(); 00683 } 00684 00685 return TRUE; 00686 } 00687 00688 /******************************************************************************************** 00689 00690 > void ScaleTab::ShowScaleDetails() 00691 00692 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00693 Created: 20/6/94 00694 Inputs: - 00695 Outputs: - 00696 Returns: - 00697 Purpose: Shows scale factor details in the dialog 00698 Errors: - 00699 SeeAlso: - 00700 00701 ********************************************************************************************/ 00702 00703 BOOL ScaleTab::ShowScaleDetails() 00704 { 00705 TRACEUSER( "Neville", _T("ScaleTab::ShowScaleDetails\n")); 00706 ERROR2IF(pPrefsDlg == NULL,FALSE,"ScaleTab::ShowScaleDetails called with no dialog pointer"); 00707 ERROR2IF(pDimScale == NULL,FALSE,"ScaleTab::ShowScaleDetails pDimScale is NULL"); 00708 00709 String_32 Str; 00710 00711 // Get current state of dimension scaling to see whether it is active or 00712 // noton this view. 00713 BOOL Active = pDimScale->IsActive(); 00714 pPrefsDlg->SetLongGadgetValue(_R(IDC_OPTS_USESCALEFACTOR), (INT32)Active); 00715 // remember entry states in our class variables 00716 OldActiveState = Active; 00717 00718 Str = pDimScale->GetDrawingScaleStr(); 00719 pPrefsDlg->SetStringGadgetValue(_R(IDC_OPTS_DRAWINGSCALE), Str); 00720 pPrefsDlg->EnableGadget(_R(IDC_OPTS_DRAWINGSCALE), Active); 00721 // remember entry states in our class variables 00722 OldDrawingStr = Str; 00723 00724 Str = pDimScale->GetRealScaleStr(); 00725 pPrefsDlg->SetStringGadgetValue(_R(IDC_OPTS_REALSCALE), Str); 00726 pPrefsDlg->EnableGadget(_R(IDC_OPTS_REALSCALE), Active); 00727 // remember entry states in our class variables 00728 OldRealStr = Str; 00729 00730 // Grey/ungrey the static text fields accordingly 00731 pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALEEG), Active); 00732 pPrefsDlg->EnableGadget(_R(IDC_OPTS_REALWORLD), Active); 00733 pPrefsDlg->EnableGadget(_R(IDC_OPTS_DRAWING), Active); 00734 pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALETO), Active); 00735 pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALETO2), Active); 00736 pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALEGROUP), Active); 00737 00738 return TRUE; 00739 } 00740 00741 #endif //webster