UnitPropertiesDlg Class Reference

#include <optsunit.h>

Inheritance diagram for UnitPropertiesDlg:

DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 UnitPropertiesDlg ()
 UnitPropertiesDlg constructor. Creates a non-undoable operation.
void DoWithParam (OpDescriptor *, OpParam *pOpParam)
 Creates then opens the dialog in response to a request from the user. The parameter is actually the user unit type to be edited. Errors: -.
void Do (OpDescriptor *)
 Creates then opens the dialog in response to a request from the user.
BOOL Create ()
 UnitPropertiesDlg create method.
virtual MsgResult Message (Msg *Message)
 Handles all the bitmap preferences dialog's messages.

Static Public Member Functions

static BOOL Init ()
 UnitPropertiesDlg Init method.
static OpState GetState (String_256 *, OpDescriptor *)
 UnitPropertiesDlg GetState method.
static BOOL InvokeDialog (UnitType CurrentUserUnitType)
 How to invoke or start a UnitPropertiesDlg box.

Static Public Attributes

static CDlgResID IDD = _R(IDD_OPTS_UNITPROPERTIES)
static const CDlgMode Mode = MODAL

Private Member Functions

BOOL InitDialog ()
 Sets initial dialog values.
BOOL CommitDialogValues ()
 Takes the values in the dialog box and sets the return values accordingly Called when ok is pressed on the dialog box.
void SetUnitToken (CGadgetID ID, UnitType ThisUnitType, INT32 Index=-1, BOOL EndOfList=FALSE)
 Readable function for putting unit token strings in controls. MUST have a valid doc unit list.
BOOL DisplayUserUnitDetails ()
 Displays the unit CurrentUserUnitType in the user-definable area of the dialog. Called when a new unit is made, or when another unit selected from the list of user units. UpdateUnitName added to allow suppression of the unit name updating. As when a new unit is choosen from the user units list, the name is highlighted, and hence overtyping works. If we fill the name in then the hightlighting is removed but overtyping still works! Only do it if user units present.

Private Attributes

UnitType CurrentUserUnitType
DocUnitListpDocUnitList
BOOL * pIsOk

Detailed Description

Definition at line 221 of file optsunit.h.


Constructor & Destructor Documentation

UnitPropertiesDlg::UnitPropertiesDlg  ) 
 

UnitPropertiesDlg constructor. Creates a non-undoable operation.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/11/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1418 of file optsunit.cpp.

01418                                     : DialogOp(UnitPropertiesDlg::IDD, UnitPropertiesDlg::Mode) 
01419 {
01420     // Set up some useful defaults
01421     CurrentUserUnitType = NOTYPE;
01422     pDocUnitList = NULL;
01423     pIsOk = NULL;
01424 }


Member Function Documentation

BOOL UnitPropertiesDlg::CommitDialogValues  )  [private]
 

Takes the values in the dialog box and sets the return values accordingly Called when ok is pressed on the dialog box.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/11/95
Parameters:
pointer to the dialogue box [INPUTS]
- [OUTPUTS]
Returns:
True if values in dialog box ok, False otherwise.

Errors: -

See also:
-

Definition at line 1442 of file optsunit.cpp.

01443 {
01444     ERROR3IF(this == NULL, "UnitPropertiesDlg::CommitDialogValues called after duff initialisation?!");
01445     ERROR2IF(pDocUnitList == NULL,FALSE,"UnitPropertiesDlg::CommitDialogValues called with no doc unit list pointer");
01446 
01447     // Check if the user has selected a valid user unit to edit
01448     // If not do nothing 
01449     if (CurrentUserUnitType != NOTYPE)
01450     {
01451         // Read in the current unit values from the fields available
01452         Unit* pCurUserUnit = NULL;
01453         pCurUserUnit = pDocUnitList->FindUnit(CurrentUserUnitType);
01454 
01455         // General validation BOOLEAN 
01456         BOOL Valid  = FALSE;
01457 
01458         // Is the prefix or suffix radio buttons selected
01459         BOOL Prefix = GetLongGadgetValue(_R(IDC_OPTS_UNITPREFIX), 0, 1, 0, &Valid);
01460 
01461         // Work out the abbreviation that it has been gievn
01462         String_256 SpecifierStr = "";
01463         SpecifierStr = GetStringGadgetValue(_R(IDC_OPTS_UNITSPEC), &Valid);
01464         if (SpecifierStr.Length() == 0)
01465         {
01466             // There is a problem so warn the user that the value is incorrect
01467             InformWarning(_R(IDE_OPTS_BADSPECSTRING));
01468             return FALSE;
01469         }
01470 
01471         // Work out the name that the unit has been given
01472         String_256 TokenStr = "";
01473         TokenStr     = GetStringGadgetValue(_R(IDC_OPTS_UNITTOKEN), &Valid);
01474         if (TokenStr.Length() == 0)
01475         {
01476             // There is a problem so warn the user that the value is incorrect
01477             InformWarning(_R(IDE_OPTS_BADTOKENSTRING));
01478             return FALSE;
01479         }
01480 
01481         // Work out the number of this units that the user has specified as being
01482         // equivalent to the number of specified units.
01483 
01484         // We need to set a maximum value as some things are bound to fall over if not 
01485         // Status line x,y display is usually the first.
01486         const double MaxValue = (double)INT32_MAX;
01487         // Set up useful defaults in case of failure
01488         double NewBaseDenominator = 0.0;
01489         NewBaseDenominator = GetDoubleGadgetValue(_R(IDC_OPTS_NUMNEWUNITS),
01490                                                      0, MaxValue, 
01491                                                      _R(IDE_OPTS_BADUNITDENOMINATOR), &Valid);
01492         // If an invalid value has been entered then exit immeditaely, the user has
01493         // already been warned
01494         if (!Valid)
01495             return FALSE;
01496             
01497         // Must check if zero as this is a very bad value to set and difficult to check above.
01498         if (NewBaseDenominator == 0 )
01499         {
01500             // There is a problem so warn the user that the value is incorrect
01501             InformWarning(_R(IDE_OPTS_BADUNITDENOMINATOR));
01502             return FALSE;
01503         }           
01504 
01505         // Now work out the number of the chosen units that the user has specified as being
01506         // equivalent to this unit. 
01507         // Set up useful defaults in case of failure
01508         double NewBaseNumerator = 0.0;
01509         NewBaseNumerator = GetDoubleGadgetValue(_R(IDC_OPTS_NUMBASEUNITS),
01510                                                  0, MaxValue, 
01511                                                  _R(IDE_OPTS_BADUNITNUMERATOR), &Valid);
01512         // If an invalid value has been entered then exit immeditaely, the user has
01513         // already been warned
01514         if (!Valid)
01515             return FALSE;
01516 
01517         // Must check if zero as this is a very bad value to set and difficult to check above.
01518         if (NewBaseNumerator == 0 )
01519         {
01520             // There is a problem so warn the user that the value is incorrect
01521             InformWarning(_R(IDE_OPTS_BADUNITNUMERATOR));
01522             return FALSE;
01523         }           
01524 
01525         // Work out what unit type has been selected that this user unit is based on  
01526         WORD Index = 0;
01527         UnitType NewBaseUnitType = NOTYPE;
01528         Unit * pBaseUnit = NULL; 
01529         GetValueIndex(_R(IDC_OPTS_BASEUNIT), &Index);
01530         pBaseUnit = pDocUnitList->FindUnit(Index);
01531         if (pBaseUnit)
01532             NewBaseUnitType = pBaseUnit->GetUnitType();
01533 
01534         // As long as we have a valid user unit pointer, go and set the new values in it
01535         //TCHAR* pTokenStr = TokenStr;
01536         //TCHAR* pSpecifierStr = SpecifierStr;
01537         String_32  Str32 = _T("");
01538         if (pCurUserUnit != NULL)
01539         {
01540             BOOL ok = TRUE;
01541             
01542             // Set up the new values that we have verified may be useful new ones to use
01543             pCurUserUnit->SetPrefixState(Prefix);
01544             
01545             //Str32 = pTokenStr;
01546             TokenStr.Left(&Str32, Str32.MaxLength());
01547             ok = pCurUserUnit->SetToken(Str32);
01548             if (!ok)
01549             {
01550                 InformWarning(_R(IDE_OPTS_BADTOKENSTRING));
01551                 return FALSE;
01552             }
01553 
01554             //Str32 = pSpecifierStr;
01555             SpecifierStr.Left(&Str32, Str32.MaxLength());
01556             ok = pCurUserUnit->SetSpecifier(Str32);
01557             if (!ok)
01558             {
01559                 InformWarning(_R(IDE_OPTS_BADSPECSTRING));
01560                 return FALSE;
01561             }
01562 
01563             ok = pCurUserUnit->SetBaseNumerator(NewBaseNumerator);
01564             if (!ok)
01565             {
01566                 InformWarning(_R(IDE_OPTS_BADUNITNUMERATOR));
01567                 return FALSE;
01568             }
01569 
01570             ok = pCurUserUnit->SetBaseDenominator(NewBaseDenominator);
01571             if (!ok)
01572             {
01573                 InformWarning(_R(IDE_OPTS_BADUNITDENOMINATOR));
01574                 return FALSE;
01575             }
01576 
01577             if (NewBaseUnitType != NOTYPE)
01578                 pCurUserUnit->SetBaseUnitType(NewBaseUnitType);
01579 
01580             pDocUnitList->RecalcUnit(pCurUserUnit);
01581             //pDocUnitList->UnitHasChanged(pCurUserUnit->GetUnitType());
01582             pDocUnitList->UnitHasChanged(CurrentUserUnitType);
01583         }
01584     }
01585 
01586     // Everything went swimminlgly and so we can exit in the knowledge that the dialog 
01587     // box can be closed.
01588     return TRUE;
01589 }

BOOL UnitPropertiesDlg::Create void   )  [virtual]
 

UnitPropertiesDlg create method.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/11/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if successful, else FALSE

Errors: -

See also:
-

Reimplemented from DialogOp.

Definition at line 1858 of file optsunit.cpp.

01859 {                            
01860     ERROR2IF(pDocUnitList == NULL,FALSE,"UnitPropertiesDlg::Create No doc unit list attached to this doc yet");
01861 
01862     if (DialogOp::Create())
01863     { 
01864         // Set the initial control values 
01865         // Dialog now Modal so set up happens in the message handler
01866         //InitDialog(this);
01867 
01868         return TRUE; 
01869     }
01870     else
01871     {
01872         return FALSE; 
01873     }
01874 }

BOOL UnitPropertiesDlg::DisplayUserUnitDetails  )  [private]
 

Displays the unit CurrentUserUnitType in the user-definable area of the dialog. Called when a new unit is made, or when another unit selected from the list of user units. UpdateUnitName added to allow suppression of the unit name updating. As when a new unit is choosen from the user units list, the name is highlighted, and hence overtyping works. If we fill the name in then the hightlighting is removed but overtyping still works! Only do it if user units present.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/11/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
UnitsTab::ShowUnitDetails

Definition at line 2029 of file optsunit.cpp.

02030 {                            
02031     ERROR2IF(this == NULL,FALSE,"UnitPropertiesDlg::DisplayUserUnitDetails called with no dialog pointer");
02032     ERROR2IF(pDocUnitList == NULL,FALSE,"UnitPropertiesDlg::DisplayUserUnitDetails called with no doc unit list pointer");
02033 
02034     if (CurrentUserUnitType != NOTYPE)
02035     {
02036         Unit* pCurUserUnit = pDocUnitList->FindUnit(CurrentUserUnitType);
02037         ERROR2IF(pCurUserUnit == NULL,FALSE,"UnitPropertiesDlg::DisplayUserUnitDetails current user unit pointer null");
02038 
02039         String_32 Str;
02040         //TCHAR* p = Str;
02041         String_256 Str256;
02042         //TCHAR* p256 = Str256;
02043         
02044         // Show the name of the user's unit
02045         Str = pCurUserUnit->GetSpecifier();
02046         Str256 = Str;
02047         SetStringGadgetValue(_R(IDC_OPTS_UNITSPEC), Str256);
02048 
02049         // Set up the prefix/suffix state for this user's unit.
02050         BOOL PrefixState = FALSE;
02051         BOOL SuffixState = TRUE;
02052         if (pCurUserUnit->IsPrefix())
02053         {
02054             PrefixState = TRUE;
02055             SuffixState = FALSE;    
02056         }
02057         else
02058         {
02059             PrefixState = FALSE;
02060             SuffixState = TRUE; 
02061         } 
02062         SetLongGadgetValue(_R(IDC_OPTS_UNITPREFIX), PrefixState);
02063         SetLongGadgetValue(_R(IDC_OPTS_UNITSUFFIX), SuffixState);
02064 
02065         // Show the chosen equivalent settings
02066         // Set up useful defaults in case of failure
02067         double NewBaseNumerator = pCurUserUnit->GetBaseNumerator();
02068         double NewBaseDenominator = pCurUserUnit->GetBaseDenominator();
02069         SetDoubleGadgetValue(_R(IDC_OPTS_NUMBASEUNITS), NewBaseNumerator);
02070         SetDoubleGadgetValue(_R(IDC_OPTS_NUMNEWUNITS), NewBaseDenominator);
02071 
02072         // Update the name
02073         SetUnitToken(_R(IDC_OPTS_UNITTOKEN),  CurrentUserUnitType, -1);
02074         SetUnitToken(_R(IDC_OPTS_UNITTOKEN2), CurrentUserUnitType, 0, TRUE);
02075 
02076         // Now work out which item to select on the menu
02077         UnitType BaseUnit = pCurUserUnit->GetBaseUnitType();
02078         INT32 BaseUnitIndex = pDocUnitList->FindUnitIndex(BaseUnit);
02079         SetSelectedValueIndex(_R(IDC_OPTS_BASEUNIT), BaseUnitIndex);
02080     }
02081     else
02082     {
02083         // Blank everything as unit is NOTYPE
02084         String_256 Str256 = "";
02085 
02086         SetStringGadgetValue(_R(IDC_OPTS_UNITTOKEN),    Str256);
02087         SetStringGadgetValue(_R(IDC_OPTS_UNITTOKEN2),   Str256);
02088         SetStringGadgetValue(_R(IDC_OPTS_UNITSPEC),     Str256);
02089         SetStringGadgetValue(_R(IDC_OPTS_NUMNEWUNITS),  Str256);
02090         SetStringGadgetValue(_R(IDC_OPTS_NUMBASEUNITS), Str256);
02091         SetStringGadgetValue(_R(IDC_OPTS_BASEUNIT),     Str256);
02092     }
02093 
02094     return TRUE;
02095 }           

void UnitPropertiesDlg::Do OpDescriptor  )  [virtual]
 

Creates then opens the dialog in response to a request from the user.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/11/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 1894 of file optsunit.cpp.

01895 {
01896     BOOL ok;
01897     
01898     // Get a current document unit list
01899     Document * pDocument = Document::GetSelected();
01900     ERROR3IF(pDocument == NULL,"UnitPropertiesDlg::DoWithParam No selected document");
01901 
01902     // Set up some useful defaults
01903     pDocUnitList = NULL;
01904     pIsOk = NULL;
01905     
01906     if (pDocument)
01907         pDocUnitList = pDocument->GetDocUnitList();
01908     ERROR3IF(pDocUnitList == NULL,"UnitPropertiesDlg::DoWithParam No doc unit list attached to this doc yet");
01909 
01910     // Force a decent CurrentUserUnitType
01911     CurrentUserUnitType = NOTYPE;
01912 
01913     // Force the dialog box to be created, as it is modal it will be opened via a message
01914     ok = Create();
01915 
01916     if ( !ok )
01917     {
01918         // Could not create the dialog box so call inform error 
01919         InformError();
01920         End();         // End the operation 
01921     }
01922 }

void UnitPropertiesDlg::DoWithParam OpDescriptor ,
OpParam pOpParam
[virtual]
 

Creates then opens the dialog in response to a request from the user. The parameter is actually the user unit type to be edited. Errors: -.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/11/95
Parameters:
OpDescriptor - Not Used. [INPUTS] pOpParam->Param1 - The user unit type to be edited. pOpParam->Param2 - Should be a pointer to a BOOL that will hold the result of the operation.
- [OUTPUTS]
Returns:
-
See also:
-

Reimplemented from Operation.

Definition at line 1942 of file optsunit.cpp.

01943 {
01944     ERROR3IF(pOpParam == NULL, "UnitPropertiesDlg::DoWithParam - NULL Param passed in");
01945 
01946     // Get a current document unit list
01947     Document * pDocument = Document::GetSelected();
01948     ERROR3IF(pDocument == NULL,"UnitPropertiesDlg::DoWithParam No selected document");
01949 
01950     // Get the unit list attached to the current document
01951     pDocUnitList = NULL;
01952     if (pDocument)
01953         pDocUnitList = pDocument->GetDocUnitList();
01954     ERROR3IF(pDocUnitList == NULL,"UnitPropertiesDlg::DoWithParam No doc unit list attached to this doc yet");
01955 
01956     // Use the OpParam that has been passed in to us
01957     // Force a decent CurrentUserUnitType
01958     CurrentUserUnitType = NOTYPE;
01959     UnitType * pCurUserUnitType = (UnitType*) (void *) pOpParam->Param1;
01960     pIsOk = (BOOL*) (void *) pOpParam->Param2;
01961 
01962     CurrentUserUnitType = *pCurUserUnitType;
01963 
01964     BOOL ok;
01965     
01966     // Force the dialog box to be created, as it is modal it will be opened via a message
01967     ok = Create();
01968 
01969     if ( !ok )
01970     {
01971         // Could not create the dialog box so call inform error 
01972         InformError();
01973         End();         // End the operation 
01974 
01975         *pIsOk = FALSE; // flag a bad return
01976     }
01977 }

OpState UnitPropertiesDlg::GetState String_256 ,
OpDescriptor
[static]
 

UnitPropertiesDlg GetState method.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/11/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1753 of file optsunit.cpp.

01754 {    
01755     OpState OpSt;
01756     return(OpSt);
01757 }

BOOL UnitPropertiesDlg::Init void   )  [static]
 

UnitPropertiesDlg Init method.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/11/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from SimpleCCObject.

Definition at line 1813 of file optsunit.cpp.

01814 {
01815     BOOL InitOK;
01816 
01817     InitOK = RegisterOpDescriptor(
01818                                 0,                              // Tool ID
01819                                 _R(IDS_UNITPROPERTIESDLG),              // String resource ID
01820                                 CC_RUNTIME_CLASS(UnitPropertiesDlg),    // Runtime class
01821                                 OPTOKEN_UNITPROPERTIESDLG,      // Token string
01822                                 GetState,                       // GetState function
01823                                 0,                              // help ID
01824                                 0,                              // bubble help
01825                                 0,                              // resource ID
01826                                 0,                              // control ID
01827                                 SYSTEMBAR_ILLEGAL,              // Bar ID
01828                                 TRUE,                           // Recieve system messages
01829                                 FALSE,                          // Smart duplicate operation
01830                                 TRUE,                           // Clean operation
01831                                 0,                              // No vertical counterpart
01832                                 _R(IDS_UNITPROPERTIESDLG_ONE),      // String for one copy only error
01833                                 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC) // Auto state flags
01834                                 );
01835 
01836     return (InitOK);
01837 }

BOOL UnitPropertiesDlg::InitDialog  )  [private]
 

Sets initial dialog values.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/11/95
Parameters:
pointer to the dialog box [INPUTS]
- [OUTPUTS]
Returns:
TRUE if successful, else FALSE

Errors: -

See also:
-

Definition at line 1774 of file optsunit.cpp.

01775 {
01776     ERROR3IF(this == NULL, "UnitPropertiesDlg::InitDialog called after duff initialisation?!");
01777 
01778     // Fill in the based on unit list with all the current units that are available
01779     INT32 i;
01780     Unit* pUnit = NULL;
01781 
01782     DeleteAllValues(_R(IDC_OPTS_BASEUNIT));
01783 
01784     UnitType ThisUnitType = NOTYPE;
01785     for (i = 0; i < pDocUnitList->GetNumUnits(); i++)
01786     {
01787         pUnit = pDocUnitList->FindUnit(i);
01788         ThisUnitType = pUnit->GetUnitType();
01789         SetUnitToken(_R(IDC_OPTS_BASEUNIT), ThisUnitType, i);
01790     }
01791 
01792     DisplayUserUnitDetails();
01793 
01794     return TRUE;
01795 }

BOOL UnitPropertiesDlg::InvokeDialog UnitType  CurrentUserUnitType  )  [static]
 

How to invoke or start a UnitPropertiesDlg box.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/11/95
Parameters:
The UnitType of the user unit to edit. [INPUTS]
- [OUTPUTS]
Returns:
True if Ok used or False if Cancel used.

Errors: -

See also:
-

Definition at line 1383 of file optsunit.cpp.

01384 {
01385     OpDescriptor *pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_UNITPROPERTIESDLG);
01386 
01387     ERROR3IF(pOpDesc == NULL,"UnitPropertiesDlg::InvokeDialog is unable to find the UnitPropertiesDlg OpDescriptor");
01388 
01389     // Actually start up the user units properties dialog box.
01390     // Send in some useful paramters
01391     BOOL IsEditOK = FALSE;
01392     UnitType CurUserUnitType = CurrentUserUnitType;
01393     OpParam Params((void *)&CurUserUnitType, (void *)&IsEditOK);
01394     if (pOpDesc != NULL)
01395         pOpDesc->Invoke(&Params);
01396 
01397     return IsEditOK;
01398 }

MsgResult UnitPropertiesDlg::Message Msg Message  )  [virtual]
 

Handles all the bitmap preferences dialog's messages.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/11/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from DialogOp.

Definition at line 1607 of file optsunit.cpp.

01608 {
01609     ERROR3IF(this == NULL, "UnitPropertiesDlg::Message - Null this!");
01610     ERROR3IF(Message == NULL, "UnitPropertiesDlg::Message - Parameters not been set up");
01611 
01612     if (IS_OUR_DIALOG_MSG(Message))
01613     {
01614         DialogMsg* Msg = (DialogMsg*)Message;
01615 
01616         MsgResult Result;
01617 
01618         BOOL EndDialog = FALSE;     // TRUE if we should quit the dialog
01619 
01620         // Should now handle the required messages that we respond to
01621         switch (Msg->DlgMsg)
01622         {
01623             case DIM_CREATE:
01624                 {
01625                     InitDialog();
01626                 }
01627             break;
01628 
01629             case DIM_COMMIT:
01630                 {
01631                     // (ok) accept all changes that the user has made to the settings
01632                     BOOL ok;
01633                     ok = CommitDialogValues();
01634                     if (ok)
01635                     {
01636                         // Values found ok so quit dialogue
01637                         EndDialog = TRUE;               // Flag to close and end
01638                         if (pIsOk)
01639                             *pIsOk = TRUE;              // flag an ok return
01640                     }
01641                     else
01642                         Msg->DlgMsg = DIM_NONE;
01643                 }
01644             break;
01645 
01646             case DIM_CANCEL:
01647                 // Cancel all changes that the user has made to the settings
01648                 EndDialog = TRUE;   // Flag to close and end
01649                 if (pIsOk)
01650                     *pIsOk = FALSE; // flag a bad return
01651             break;
01652 
01653 //          case DIM_LFT_BN_CLICKED:
01654 //              // A control on the dialog box has been clicked...
01655 //              switch (Msg->GadgetID)
01656 //              {
01657 //                  case _R(IDC_BMPOPTS_SPREAD):
01658 //                  break;
01659 //              }
01660 //          break; // DIM_LFT_BN_CLICKED        
01661 //
01662             case DIM_SELECTION_CHANGED:
01663             {
01664                 // A control on the dialog box has been typed in...
01665                 //ERROR2IF(pDocUnitList == NULL,FALSE,"UnitsTab::HandleMsg called with no doc unit list");
01666                 
01667                 WORD Index = 0;
01668                 Unit* pUnit = NULL;
01669                 Unit* pCurUserUnit = NULL;
01670 
01671                 if (Msg->GadgetID == _R(IDC_OPTS_BASEUNIT))
01672                 {
01673                     // The user has chosen a new base unit
01674                     GetValueIndex(_R(IDC_OPTS_BASEUNIT),&Index);
01675                     pUnit        = pDocUnitList->FindUnit(Index);
01676                     pCurUserUnit = pDocUnitList->FindUnit(CurrentUserUnitType);
01677                     if (pUnit->GetUnitType() == CurrentUserUnitType)
01678                     {
01679                         // Warn the user that this is the current unit
01680                         Error::SetError(_R(IDS_UNITERROR_BASEISCURRENT),0);
01681                         InformError();
01682                         // And reselect the old one unit type in the list
01683                         UnitType BaseUnit = pCurUserUnit->GetBaseUnitType(); 
01684                         INT32 BaseUnitIndex = pDocUnitList->FindUnitIndex(BaseUnit);
01685                         SetSelectedValueIndex(_R(IDC_OPTS_BASEUNIT), BaseUnitIndex);
01686                     }
01687                     else if (pDocUnitList->IsDescendent(pUnit,CurrentUserUnitType))
01688                     {
01689                         // Warn the user that the selected unit is a descendent
01690                         Error::SetError(_R(IDS_UNITERROR_BASEISDESCENDENT),0);
01691                         InformError();
01692                         // And reselect the old one unit type in the list
01693                         UnitType BaseUnit = pCurUserUnit->GetBaseUnitType();
01694                         INT32 BaseUnitIndex = pDocUnitList->FindUnitIndex(BaseUnit);
01695                         SetSelectedValueIndex(_R(IDC_OPTS_BASEUNIT), BaseUnitIndex);
01696                     }
01697                     // Otherwise selection is ok so do nothing
01698                 }
01699             }
01700             break; // DIM_SELECTION_CHANGED
01701 
01702             case DIM_TEXT_CHANGED:
01703                 if (Msg->GadgetID == _R(IDC_OPTS_UNITTOKEN))
01704                 {
01705                     // User is editing the main user unit name
01706                     // Update the text in the X <UnitsName> are equivalent to ... field 
01707                     BOOL Valid;
01708                     String_256 TokenStr = GetStringGadgetValue(_R(IDC_OPTS_UNITTOKEN),&Valid);
01709                     SetStringGadgetValue(_R(IDC_OPTS_UNITTOKEN2),TokenStr);
01710                 }
01711                 break;  // DIM_TEXT_CHANGED
01712 
01713             default:
01714                 break;
01715         }
01716 
01717         // Must do this before the Close and End
01718         Result = DialogOp::Message(Message);
01719 
01720 // Commented out as base class closes the dialog in LX.
01721 #if 0
01722         // End dialog here
01723         if (EndDialog) 
01724         {
01725             Close();                // Hide the dialog box
01726             End();                  // Finish the operation
01727         }
01728 #endif
01729 
01730         // The message was for our dialog box so return that we have handled it, if necessary
01731         return Result;
01732     }
01733 
01734     return DialogOp::Message(Message); 
01735 }

void UnitPropertiesDlg::SetUnitToken CGadgetID  ID,
UnitType  ThisUnitType,
INT32  Index = -1,
BOOL  EndOfList = FALSE
[private]
 

Readable function for putting unit token strings in controls. MUST have a valid doc unit list.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/7/94
Parameters:
ID = the ID of the control to put the unit token in [INPUTS] ThisUnitType = the type of the unit whose token you want putting in the control Index = index into a drop list (-1 = main field) EndOfList - if TRUE, item is stuck on end of list, regardless of Index
- [OUTPUTS]
Returns:
-
See also:
-

Definition at line 1998 of file optsunit.cpp.

01999 {
02000     if (pDocUnitList)
02001     {
02002         String_32 Str = pDocUnitList->GetToken(ThisUnitType);
02003         String_256 Str256 = Str;
02004         SetStringGadgetValue(ID, Str256, EndOfList, Index);
02005     }
02006 }


Member Data Documentation

UnitType UnitPropertiesDlg::CurrentUserUnitType [private]
 

Definition at line 248 of file optsunit.h.

CDlgResID UnitPropertiesDlg::IDD = _R(IDD_OPTS_UNITPROPERTIES) [static]
 

Definition at line 238 of file optsunit.h.

const CDlgMode UnitPropertiesDlg::Mode = MODAL [static]
 

Definition at line 239 of file optsunit.h.

DocUnitList* UnitPropertiesDlg::pDocUnitList [private]
 

Definition at line 249 of file optsunit.h.

BOOL* UnitPropertiesDlg::pIsOk [private]
 

Definition at line 250 of file optsunit.h.


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