OpZoomComboDescriptor Class Reference

OpDescriptor for the zoom tool's combo-box containing scale factors. More...

#include <zoomops.h>

Inheritance diagram for OpZoomComboDescriptor:

OpZoomDescriptor OpDescriptor MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 OpZoomComboDescriptor ()
 Constructs an OpDescriptor for the zoom control's combo-box, which contains a list of percentage zoom factors.
virtual MsgResult Message (Msg *pMsg)
 Despatches a message, if relevant to the appropriate handler for it, after "unpacking" it into a more useful form.

Static Public Member Functions

static BOOL Update (BOOL fRefreshList=FALSE)
 Gets a pointer to the (one and only) OpZoomComboDescriptor in the system, and calls its member function UpdateComboWithViewScale for the "selected" DocView, if any. Available publicly to other zoom tool classes, to be called when they modify a DocView's zoom factor.

Private Member Functions

MsgResult HandleCreateMsg (DialogOp *popdlgThis, CGadgetID gidThis)
 Fills the zoom control's combo-box with a list of percentage scale factors, corresponding to those held in OpZoom::ZoomTable[].
MsgResult HandleViewChangeMsg (DocView *pSelectedDocView)
 Updates the zoom control combo-box with the zoom factor of a DocView as the user moves from view to view.
void OnSelectionChange (OpDescControlMsg *pCtrlMsg, List *pGadgetList)
 Handles the user changing the selection, or typing text, in the zoom factor combo-box. Reads the selected text, checking for "%" or "x" which indicates a percentage zoom factor (absolute) or a multiplier (relative), converts to a number and performs the requested zoom on the selected view.
BOOL RefreshList ()
 Fills the zoom control's combo-box with a list of percentage scale factors and set names, corresponding to those held in OpZoom::ZoomTable[].
BOOL UpdateAllCombos (String_256 *pStr)
 Updates the zoom combo-box(es) with the given text. The function is complicated by design deficiencies in the Operation system!
BOOL UpdateComboWithViewScale (DocView *pDocView)
 Updates the combo-box with the DocView's current percentage zoom factor. This works even if there is more than one combo-box. The function is complicated by design deficiencies in the Operation system!
virtual BOOL IsAvailable ()
 Checks if their is a "selected" DocView, if so you can use the zoom combo on it.

Static Private Member Functions

static BOOL StringToLong (const StringBase &pszIn, INT32 *pnOut)
 Parses the text within the zoom factor combo-box, checking for a percentage factor ("%") or a multiplier factor ("x"), converting it to a number.

Detailed Description

OpDescriptor for the zoom tool's combo-box containing scale factors.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/5/93

Definition at line 554 of file zoomops.h.


Constructor & Destructor Documentation

OpZoomComboDescriptor::OpZoomComboDescriptor  ) 
 

Constructs an OpDescriptor for the zoom control's combo-box, which contains a list of percentage zoom factors.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
class OpZoomDescriptor

Definition at line 2508 of file zoomops.cpp.

02509   : OpZoomDescriptor(OPTOKEN_ZOOMCOMBO, _R(IDS_ZOOMCOMBOSTATUSTEXT), 0, _R(IDBBL_ZOOM_COMBO), _R(IDCB_ZOOM_COMBO_BOX), _R(IDCB_ZOOM_COMBO_BOX))
02510 {
02511     
02512     // Empty.
02513 }


Member Function Documentation

MsgResult OpZoomComboDescriptor::HandleCreateMsg DialogOp popdlgThis,
CGadgetID  gidThis
[private]
 

Fills the zoom control's combo-box with a list of percentage scale factors, corresponding to those held in OpZoom::ZoomTable[].

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/94
Parameters:
popdlgThis points to a DialogOp (a control?) [INPUTS] gidThis gadget ID of control
- [OUTPUTS]
Returns:
A message result (always EAT_MSG)

Errors: -

See also:
OpZoomComboDescriptor::Message; DialogOp::SetStringGadgetValue

Definition at line 2868 of file zoomops.cpp.

02869 {
02870 #if !defined(EXCLUDE_FROM_RALPH)
02871     // Delegate delegate delegate!
02872     if (!RefreshList()) return FAIL;
02873 
02874     // Make sure the visuals reflect all this.
02875     DocView* pDocView = DocView::GetCurrent();
02876     if (pDocView != 0) UpdateComboWithViewScale(pDocView);
02877 #endif
02878     // Processed message successfully.
02879     return EAT_MSG;
02880 }

MsgResult OpZoomComboDescriptor::HandleViewChangeMsg DocView pSelectedDocView  )  [private]
 

Updates the zoom control combo-box with the zoom factor of a DocView as the user moves from view to view.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/94
Parameters:
pSelectedDocView points to the DocView that is now "selected", [INPUTS] or 0 if there isn't a selected view.
Returns:
A message result code (always OK)

Errors: Out of memory

See also:
OpZoomComboDescriptor::UpdateComboWithViewScale; OpZoomComboDescriptor::Message

Definition at line 2637 of file zoomops.cpp.

02638 {
02639 #if !defined(EXCLUDE_FROM_RALPH)
02640     ZoomTool::InvalidateStatusText();
02641     String_256 dummy;
02642     return (pSelectedDocView != 0 
02643                 // There is a new view, so set the combos to the scale factor.
02644                 ? UpdateComboWithViewScale(pSelectedDocView)
02645                 // There is no view, so blank the zoom combos.
02646                 : UpdateAllCombos(&dummy))
02647                         ? OK : FAIL;
02648 #else
02649     return OK;
02650 #endif
02651 }

BOOL OpZoomComboDescriptor::IsAvailable  )  [private, virtual]
 

Checks if their is a "selected" DocView, if so you can use the zoom combo on it.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the zoom combo is available for use, FALSE otherwise.

Errors: -

See also:
OpZoom::GetState; OpZoomDescriptor::IsAvailable

Reimplemented from OpZoomDescriptor.

Definition at line 2531 of file zoomops.cpp.

02532 {
02533     return DocView::GetSelected() != 0;
02534 }

MsgResult OpZoomComboDescriptor::Message Msg pMsg  )  [virtual]
 

Despatches a message, if relevant to the appropriate handler for it, after "unpacking" it into a more useful form.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/94
Parameters:
pMsg a pointer to a kernel message to process [INPUTS]
- [OUTPUTS]
Returns:
A message result code (generally OK)

Errors: -

See also:
OpZoomComboDescriptor::HandleViewChangeMsg; OpZoomComboDescriptor::HandleCreateMsg; OpZoomComboDescriptor::HandleSelectMsg; class DocViewMsg

Reimplemented from OpZoomDescriptor.

Definition at line 2555 of file zoomops.cpp.

02556 {
02557     // Does the message mean that something has happened to the DocView?
02558     if (MESSAGE_IS_A(pMsg, DocViewMsg))
02559     {
02560         DocViewMsg* pViewMsg = (DocViewMsg*) pMsg;
02561         switch (pViewMsg->State)
02562         {
02563             case DocViewMsg::BORN:
02564                 // Initialise our data in the DocView when it is constructed.
02565                 pViewMsg->pDocView->SetZoomTableIndex(cDefaultZoomIndex);
02566                 pViewMsg->pDocView->SetPrevZoomIndex(cUninitZoomIndex);
02567                 return OK;
02568 
02569             case DocViewMsg::SELCHANGED:
02570                 // Handle the selected view changing.
02571                 return HandleViewChangeMsg(pViewMsg->pNewDocView);
02572 
02573             case DocViewMsg::SCALECHANGED:
02574                 // Handle the scale being changed. Since it can be set to anything,
02575                 // say that it is fractional so the field is updated properly.
02576                 pViewMsg->pDocView->SetZoomTableIndex(cFractionalZoomIndex);
02577                 return HandleViewChangeMsg(pViewMsg->pDocView);
02578 
02579             default:
02580                 // Ignore all other messages.
02581                 return OK;
02582         }
02583     }
02584 
02585     // If we have dropped down the combo-box - make sure it is upto date!
02586     if (MESSAGE_IS_A(pMsg, OpDescControlMsg))
02587     {
02588         OpDescControlMsg* pOpDescControlMsg = (OpDescControlMsg*) pMsg;
02589 
02590         if (pOpDescControlMsg->DlgMsg == DIM_LISTDROPPED)
02591         {
02592             if (DocView::GetCurrent() != 0)
02593             {
02594 // We really don't want the name gallery to have any effect on the zoom dropdown...
02595 //              CreateDisplayScan().Scan();
02596                 Update(TRUE);
02597             }
02598         }
02599     }
02600 
02601     // Check if the message is an OpDesc message.
02602     if (!MESSAGE_IS_A(pMsg, OpDescMsg)) return OK;
02603     
02604     // Cast it into the correct type etc.
02605     OpDescMsg* pOpDescMsg = (OpDescMsg*) pMsg;
02606         
02607     // Is it for us?
02608     if (pOpDescMsg->OpDesc != this) return OK;
02609     
02610 
02611 
02612     // Process the message . . .
02613     if (MESSAGE_IS_A(pOpDescMsg, OpDescControlCreateMsg))
02614         return HandleCreateMsg(pOpDescMsg->pDlgOp, pOpDescMsg->SetGadgetID);
02615 
02616     // Let base class do the default.
02617     return OpZoomDescriptor::Message(pMsg);
02618 }

void OpZoomComboDescriptor::OnSelectionChange OpDescControlMsg pCtrlMsg,
List pGadgetList
[private, virtual]
 

Handles the user changing the selection, or typing text, in the zoom factor combo-box. Reads the selected text, checking for "%" or "x" which indicates a percentage zoom factor (absolute) or a multiplier (relative), converts to a number and performs the requested zoom on the selected view.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/7/94
Parameters:
pCtrlMsg --- pointer to the message from a control [INPUTS] pGadgetList --- list of all gadgets associated with this OpDescriptor.
- [OUTPUTS]
Returns:
-

Errors: -

See also:
OpZoomComboDescriptor::StringToLong; OpZoomDescriptor::FakeInvoke

Reimplemented from OpDescriptor.

Definition at line 2903 of file zoomops.cpp.

02904 {
02905 #if !defined(EXCLUDE_FROM_RALPH)
02906     // Check that we have reasonable input.
02907     ERROR3IF(pCtrlMsg == 0 || pCtrlMsg->pDlgOp == 0,
02908                 "No OpDescriptor message in OpZoomComboDescriptor::OnSelectionChange");
02909     if (pCtrlMsg == 0 || pCtrlMsg->pDlgOp == 0) return;
02910 
02911     // Get the selected DocView etc.
02912     DocView* pDocView = DocView::GetCurrent();
02913     ERROR3IF(pDocView == 0,
02914                 "No current DocView in OpZoomComboDescriptor::OnSelectionChange");
02915     if (pDocView == 0) return;
02916 
02917     // If the selected text is actually one of the zoom commands, eg. "(Fit to) Spread",
02918     // then dispatch that to the appropriate handler.
02919     WORD wComboIndex;
02920     pCtrlMsg->pDlgOp->GetValueIndex(pCtrlMsg->SetGadgetID, &wComboIndex);
02921     INT32 nComboIndex = (short) wComboIndex;
02922     switch (nComboIndex)
02923     {
02924         case cFitToSpreadIndex:
02925             FakeInvoke(OPTOKEN_ZOOMSPREAD);
02926             return;
02927 
02928         case cFitToDrawingIndex:
02929             FakeInvoke(OPTOKEN_ZOOMDRAWING);
02930             return;
02931 
02932         case cFitToSelectedIndex:
02933             FakeInvoke(OPTOKEN_ZOOMSELECTED);
02934             return;
02935 
02936         case cPreviousZoomIndex:
02937             FakeInvoke(OPTOKEN_ZOOMPREV);
02938             return;
02939 
02940         case cComboDivider1:
02941         case cComboDivider2:
02942 //          Beep();
02943             wxBell();
02944             OpZoomComboDescriptor::Update();
02945             return;
02946 
02947         default:
02948             break;
02949     }
02950 
02951     // Have we selected a set item from the list?
02952 // We really don't want the name gallery to have any effect on the zoom dropdown...
02953 /*  INT32 n = nComboIndex - cComboDivider2;
02954     if (n > 0)
02955     {
02956         NameGallery *pNameGallery = NameGallery::Instance();
02957         if (pNameGallery)
02958         {
02959             SGUsedNames* pUsedNames = pNameGallery->GetUsedNames();
02960             if (pUsedNames != 0)
02961             {
02962                 SGNameItem* pItem = (SGNameItem*) pUsedNames->GetChild();
02963                 if (pItem != 0)
02964                 {
02965                     for (; pItem != 0; pItem = (SGNameItem*) pItem->GetNext())
02966                         if (!pItem->GetSetBounds().IsEmpty() && --n == 0)
02967                         {
02968                             // Extract the bounds of the chosen set and zoom to them.
02969                             ERROR3IF(!pItem->GetSetBounds().IsValid(),
02970                                 "OpZoomComboDescriptor::OnSelectionChange: invalid bounds");
02971                             OpZoomDescriptor::FakeZoomToRect(pItem->GetSetBounds());
02972                             return;
02973                         }
02974 
02975                     Beep();
02976                     ERROR3("OpZoomComboDescriptor::OnSelectionChange: can't find SGNameItem");
02977                     return;
02978                 }
02979             }
02980         }
02981     }
02982 */
02983 
02984     // Extract the highlighted text.  We pass a pointer to our "StringToLong" function
02985     // that knows how to extract a zoom factor from the user's input.
02986     BOOL bIsValid;
02987     INT32 nPercent = pCtrlMsg->pDlgOp->GetLongGadgetValue(pCtrlMsg->SetGadgetID,
02988                                                          INT32_MIN, INT32_MAX,
02989                                                          _R(IDE_INVALIDZOOMFACTOR),
02990                                                          &bIsValid, StringToLong);
02991     
02992     // Check if the input is valid.  If it isn't then reset the result.  The
02993     // GetStringGadgetValue will have reported the error if the input isn't valid.
02994     if (!bIsValid)
02995     {
02996         UpdateComboWithViewScale(pDocView);
02997         return;
02998     }
02999 
03000     // If the returned value is negative it represents a "multiplier", which must
03001     // first be converted to a percentage.
03002     if (nPercent < 0)
03003     {
03004         INT32 nIndex = pDocView->GetZoomTableIndex();
03005         if (nIndex == cFractionalZoomIndex)
03006             nPercent = -nPercent * ((pDocView->GetViewScale() * 100) + FIXED16(0.5)).MakeInt();
03007         else
03008             nPercent = -nPercent * OpZoom::GetPresetZoomPercent(nIndex);
03009 
03010         // If the zoom factor is larger than the permitted maximum then adjust it.
03011         INT32 nMaxPercent = OpZoom::GetPresetZoomPercent(0);
03012         if (nPercent > nMaxPercent) nPercent = nMaxPercent;
03013     }
03014 
03015     // Begin by assuming the percentage isn't in the table.
03016     INT32 nIndex = cFractionalZoomIndex;
03017 
03018     // Look for the percentage in the zoom factor table.
03019     for (INT32 i = 0; i < cZoomTableSize; i++)
03020     {
03021         if (OpZoom::GetPresetZoomPercent(i) == nPercent)
03022         {
03023             // Found the percentage in the table.
03024             nIndex = i;
03025             break;
03026         }
03027     }
03028 
03029     // Try to create an OpZoom operation.
03030     OpZoom* pZoomOp = new OpZoom;
03031     if (pZoomOp == 0)
03032     {
03033         // We ran out of memory, so sorry.
03034         InformError(_R(IDE_NOMORE_MEMORY));
03035         return;
03036     }
03037 
03038     // Find the mid-point of the view, in work coordinates.
03039     WorkRect wrView = pDocView->GetViewRect();
03040     WorkCoord wcMidView((wrView.lo.x + wrView.hi.x) / 2,
03041                         (wrView.lo.y + wrView.hi.y) / 2);
03042     
03043     // Ask the operation to zoom at this point.
03044     pDocView->SetZoomTableIndex(nIndex);
03045     pZoomOp->ZoomAtPoint(wcMidView, ((FIXED16) (INT32) nPercent) / 100);
03046 #endif
03047 }

BOOL OpZoomComboDescriptor::RefreshList  )  [private]
 

Fills the zoom control's combo-box with a list of percentage scale factors and set names, corresponding to those held in OpZoom::ZoomTable[].

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/94
Returns:
TRUE if successful.

Errors: Out of memory

See also:
OpZoomComboDescriptor::Message; DialogOp::SetStringGadgetValue

Definition at line 2786 of file zoomops.cpp.

02787 {
02788     List* pList = new List;
02789     ERRORIF(pList == 0, _R(IDE_NOMORE_MEMORY), FALSE);
02790 
02791     // See if the dialogue manager can remember where its controls live, or even
02792     // what identifiers they possess . . .
02793     if (BuildGadgetList(pList))
02794     {   
02795         // Success.  Walk the generated list
02796         ListItem* pListItem = pList->GetHead();
02797         while (pListItem != 0)
02798         {
02799             DialogOp* pBarOp = ((GadgetListItem*) pListItem)->pDialogOp;
02800             CGadgetID gid = ((GadgetListItem*) pListItem)->gidGadgetID;
02801 
02802             // Start with a clean sheet.
02803             pBarOp->DeleteAllValues(gid);
02804 
02805             // Set each percentage zoom factor at successive positions in the combo-box.
02806             String_256 txt;
02807             INT32 i;
02808             for (i = 0; i < cZoomTableSize; i++)
02809             {
02810                 txt.MakeMsg(_R(IDS_ZOOM_INFO_FORMAT), OpZoom::GetPresetZoomPercent(i));
02811                 pBarOp->SetStringGadgetValue(gid, txt, FALSE, i);
02812             }
02813 
02814             // Insert a divider so it all looks nice.
02815             String_256 strDivide(_R(IDS_ZOOM_COMBO_DIVIDER));
02816             pBarOp->SetStringGadgetValue(gid, strDivide, FALSE, i++);
02817 
02818             // Add the text commands after the percentages.
02819             txt.Load(_R(IDS_ZOOMSPREADCOMBOTEXT));
02820             pBarOp->SetStringGadgetValue(gid, txt, FALSE, i++);
02821             txt.Load(_R(IDS_ZOOMDRAWINGCOMBOTEXT));
02822             pBarOp->SetStringGadgetValue(gid, txt, FALSE, i++);
02823 
02824 #ifndef STANDALONE
02825             txt.Load(_R(IDS_ZOOMSELECTEDCOMBOTEXT));
02826             pBarOp->SetStringGadgetValue(gid, txt, FALSE, i++);
02827 #endif
02828 
02829             txt.Load(_R(IDS_ZOOMPREVIOUSCOMBOTEXT));
02830             pBarOp->SetStringGadgetValue(gid, txt, FALSE, i++);
02831 
02832             // Set the required depth of the combo-box when it drops down.
02833             pBarOp->SetComboListLength(gid);
02834 
02835             // Blank the string to start off with
02836             txt=_T("");
02837             pBarOp->SetStringGadgetValue(gid, txt, FALSE, -1);
02838 
02839             // Do the next control in the list, if any.
02840             pListItem = pList->GetNext(pListItem);
02841         }
02842 
02843         pList->DeleteAll();
02844     }
02845 
02846     delete pList;
02847     return TRUE;
02848 }

BOOL OpZoomComboDescriptor::StringToLong const StringBase strIn,
INT32 *  pnOut
[static, private]
 

Parses the text within the zoom factor combo-box, checking for a percentage factor ("%") or a multiplier factor ("x"), converting it to a number.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/7/94
Parameters:
pstrIn --- pointer to the string containing text [INPUTS] pnOut --- pointer to the number which will contain the result
- [OUTPUTS]
Returns:
TRUE if the text is successfully parsed, FALSE otherwise.

Errors: -

See also:
OpZoomComboDescriptor::OnSelectionChange; DialogOp::GetLongGadgetValue

Definition at line 3066 of file zoomops.cpp.

03067 {
03068     const StringBase * pstrIn = &strIn;
03069     ERROR2IF(pstrIn == 0 || pnOut == 0, FALSE,
03070             "No parameter(s) in OpZoomComboDescriptor::StringToLong");
03071 
03072     // Remove any leading or trailing whitespace.  psczStart is set to point to first non-
03073     // whitespace character (or the terminating null), pszEnd points to the last.  If the
03074     // string is entirely whitespace these two will cross over, and we return FALSE.
03075     const TCHAR* psczStart = (const TCHAR*) *pstrIn;
03076     const TCHAR* psczForward = psczStart;
03077     const TCHAR* psczBack = psczStart + pstrIn->Length() - 1;
03078 
03079     while (StringBase::IsSpace(*psczForward))
03080         psczForward = camStrinc(psczForward);
03081     
03082     while (psczBack > psczForward && StringBase::IsSpace(*psczBack))
03083         psczBack = camStrdec(psczStart, psczBack);
03084     
03085     if (psczForward >= psczBack) return FALSE;
03086 
03087     // Check if the string ends with a '%' or an 'x'.  If it is an 'x' then the number
03088     // is a multipler, eg. "2 x" (two times).  If it is a '%', or not there at all,
03089     // then it represents a percentage.
03090     BOOL bIsMultiplier = FALSE;
03091     if (*psczBack == TEXT('x') || *psczBack == TEXT('X'))
03092     {
03093         // Parse a multiplier.  Skip over the 'x'.
03094         psczBack--;
03095         bIsMultiplier = TRUE;
03096     }
03097     else if (*psczBack == TEXT('%'))
03098     {
03099         // Parse a percentage.  Skip over the '%'
03100         psczBack--;
03101     }
03102     else if (!StringBase::IsNumeric(*psczBack))
03103     {
03104         // Can't recognise the format - not a number.
03105         return FALSE;
03106     }
03107 
03108     // Make a working copy of what is left of the string.
03109     String_256 strWork;
03110     pstrIn->Mid(&strWork, (INT32) (psczForward - psczStart),
03111                 (INT32) (psczBack - psczForward) + 1);
03112 
03113     // Convert the remaining text into a number and return it.  Percentages and
03114     // multipliers cannot be negative or zero (especially as multipliers are returned
03115     // back as negative to distinguish them from percentages).
03116     if (!Convert::StringToLong(strWork, pnOut) || *pnOut <= 0) return FALSE;
03117     
03118     // Make sure it's within allowed bounds.
03119     INT32 nMaxPercent = OpZoom::GetPresetZoomPercent(0);
03120     INT32 nMinPercent = OpZoom::GetPresetZoomPercent(cZoomTableSize - 1);
03121 
03122     if (*pnOut > nMaxPercent) *pnOut = nMaxPercent;
03123     if (*pnOut < nMinPercent && !bIsMultiplier) *pnOut = nMinPercent;    
03124     if (bIsMultiplier) *pnOut = -(*pnOut);
03125 
03126     return TRUE;
03127 }

BOOL OpZoomComboDescriptor::Update BOOL  fRefreshList = FALSE  )  [static]
 

Gets a pointer to the (one and only) OpZoomComboDescriptor in the system, and calls its member function UpdateComboWithViewScale for the "selected" DocView, if any. Available publicly to other zoom tool classes, to be called when they modify a DocView's zoom factor.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/94
Parameters:
fRefreshList --- if TRUE then regenerate all items in the [INPUTS] list (by default, just regenerate the item shown in the edit field).
Returns:
FALSE if there's an error.

Errors: Out of memory.

See also:
OpZoomComboDescriptor::UpdatecomboWithViewScale; OpDescriptor::FindOpDescriptor; DocView::GetSelected

Definition at line 3149 of file zoomops.cpp.

03150 {
03151     // Get the "selected" DocView, ie. the view that the user has made top-most.
03152     DocView* pDocView = DocView::GetCurrent();
03153     ERROR3IF(pDocView == 0, "No current DocView in OpZoomComboDescriptor::Update");
03154     if (pDocView == 0) return FALSE;
03155 
03156 // WEBSTER - markn 15/1/97
03157 // No rulers in Webster
03158 #ifndef WEBSTER
03159 #if !defined(EXCLUDE_FROM_RALPH)
03160     // update the rulers after every scale change
03161     if (pDocView->GetpRulerPair()) pDocView->GetpRulerPair()->Update();
03162 #endif
03163 #endif // WEBSTER
03164 
03165     // Find the one and only OpZoomComboDescriptor object.
03166     OpDescriptor* popd = OpDescriptor::FindOpDescriptor(OPTOKEN_ZOOMCOMBO);
03167     ERROR3IF(popd == 0, "Can't find OpZoomComboDescriptor in "
03168                          "OpZoomFitSelectedDescriptor::HandleButtonMsg");
03169     if (popd == 0) return FALSE;
03170     
03171     // Update it with values of the Selected DocView.
03172     OpZoomComboDescriptor* pCombo = (OpZoomComboDescriptor*) popd;
03173     if (fRefreshList && !pCombo->RefreshList()) return FALSE;
03174     return pCombo->UpdateComboWithViewScale(pDocView);
03175 
03176 }

BOOL OpZoomComboDescriptor::UpdateAllCombos String_256 pStr  )  [private]
 

Updates the zoom combo-box(es) with the given text. The function is complicated by design deficiencies in the Operation system!

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/94
Parameters:
pStr the text to be placed in all zoom combos [INPUTS]
Returns:
TRUE if successful.

Errors: Out of memory

Errors: -

See also:
OpDescriptor::BuildGadgetList; DocView::GetZoomTableIndex

Definition at line 2669 of file zoomops.cpp.

02670 {
02671 #if !defined(EXCLUDE_FROM_RALPH)
02672     // We must set the combos to something!
02673     ERROR3IF(pStr == 0, "No parameter in OpZoomComboDescriptor::UpdateAllCombos");
02674 
02675     // Create a list for the dialogue manager to put gadget ID's on.
02676     List* pGadgetList = new List;
02677     ERRORIF(pGadgetList == 0, _R(IDE_NOMORE_MEMORY), FALSE);
02678 
02679     // See if the dialogue manager can remember where its controls live, or even
02680     // what identifiers they possess . . .
02681     if (BuildGadgetList(pGadgetList))
02682     {   
02683         // Success.  Walk the generated list
02684         ListItem* pListItem = pGadgetList->GetHead();
02685         while (pListItem != 0)
02686         {
02687             // Set the edit field of each gadget (which according to Simon will all be
02688             // combo-boxes) to the given percentage text.
02689             GadgetListItem* pGadgetItem = (GadgetListItem*) pListItem;
02690             pGadgetItem->pDialogOp->SetStringGadgetValue(pGadgetItem->gidGadgetID,
02691                                                             *pStr,
02692                                                             FALSE,
02693                                                             -1);
02694 
02695             // This can be useful when bamboozled by the Operations system . . .
02696 /*          TRACEUSER( "JustinF", _T("\t\tUpdating zoom combo at 0x%lX (GID# %lX)\n"),
02697                         (UINT32) pGadgetItem, (UINT32) pGadgetItem->gidGadgetID);
02698 */      
02699             // Do the next control in the list, if any.
02700             pListItem = pGadgetList->GetNext(pListItem);
02701         }
02702     }
02703 /*  else
02704     {
02705         // Something went wrong!
02706         TRACEUSER( "JustinF", _T("Couldn't build gadget list in ")
02707                              "OpZoomComboDescriptor::UpdateAllCombos!\n");
02708     }
02709 */
02710     // Don't forget to delete the list afterwards!
02711     pGadgetList->DeleteAll();
02712     delete pGadgetList;
02713 #endif
02714 
02715     return TRUE;
02716 }

BOOL OpZoomComboDescriptor::UpdateComboWithViewScale DocView pDocView  )  [private]
 

Updates the combo-box with the DocView's current percentage zoom factor. This works even if there is more than one combo-box. The function is complicated by design deficiencies in the Operation system!

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/94
Parameters:
pDocView the DocView whose zoom factor will appear in the [INPUTS] zoom control's combo-box.
Returns:
TRUE if successful.

Errors: Out of memory

Errors: -

See also:
OpDescriptor::BuildGadgetList; DocView::GetZoomTableIndex

Definition at line 2736 of file zoomops.cpp.

02737 {
02738     // Get the DocView's scale percentage.  If it's -1 then we must calculate the
02739     // percentage from the raw scale factor, otherwise we can look it up.
02740     INT32 nScalePercent;
02741     String_256 txt;
02742 
02743     if (pDocView)
02744     {
02745         INT32 nTableIndex = pDocView->GetZoomTableIndex();
02746         if (nTableIndex == cUninitZoomIndex)
02747         {
02748             // This value is set by DocView's constructor, and means that the view has not
02749             // been given a ZoomTableIndex yet.  Give it the default, ie. 100%.
02750             pDocView->SetZoomTableIndex(nTableIndex = cDefaultZoomIndex);
02751             nScalePercent = OpZoom::GetPresetZoomPercent(nTableIndex);
02752         }
02753         else if (nTableIndex == cFractionalZoomIndex)
02754         {
02755             // Convert from a fixed16 scale factor to a percentage.  This must be rounded
02756             // to the nearest percent.
02757             nScalePercent = ((pDocView->GetViewScale() * 100) + FIXED16_DBL(0.5)).MakeInt();
02758         }
02759         else
02760         {
02761             nScalePercent = OpZoom::GetPresetZoomPercent(nTableIndex);
02762         }
02763     
02764         // Convert the percentage to a formatted text string.
02765         txt.MakeMsg(_R(IDS_ZOOM_INFO_FORMAT), nScalePercent);
02766     }
02767 
02768     // Update all existing zoom combos with the text.
02769     return UpdateAllCombos(&txt);
02770 }


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