#include <zoomops.h>
Inheritance diagram for OpZoomDescriptor:
Public Member Functions | |
OpZoomDescriptor (const TCHAR *pcszToken, UINT32 wStatusID, UINT32 wHelpID, UINT32 wBubbleID, UINT32 resourceID=0, UINT32 controlID=0) | |
Constructs the base class of the OpZoom's OpDescriptors. | |
virtual MsgResult | Message (Msg *pMsg) |
Default message despatcher for OpZoomDescriptor derivatives. Passes button messages to HandleButtonMsg (virtual). | |
virtual BOOL | IsAvailable () |
Default "GetState"-like function for OpZoomDescriptor derivatives. | |
virtual BOOL | DoZoom (OpZoom *pZoomOp) |
Is the base zoom descriptor class function for performing a zoom operation. It does this by calling (virtual) GetSpread to find the spread to zoom in on, then (virtual) GetRect to find the rectangle within the spread. The (virtual) function AdjustRect is called to modify the resultant rectangle. Derived classes can override these functions to customise the effects of particular zoom operation. Performs the zoom, after saving the current zoom settings, then updates the zoom combo box. Similar button to HandleButtonMsg but is designed to be called by the Do() operator in OpZoom and hence from keyboard short-cuts or menu operations. | |
Static Public Member Functions | |
static void | FakeInvoke (TCHAR *pszToken) |
"Fakes" a button message for OpDescriptor classes derived from OpZoomDescriptor. Searches for the OpDescriptor associated with the specified token. If it finds it then casts it to an OpZoomDescriptor*, checks if the associated button isn't greyed, and if not, calls its HandleButtonMsg function. Finally it makes sure that the percentage scale factor of the selected DocView is updated in the zoom combo box. | |
static void | FakeZoomToRect (const DocRect &rect) |
"Fakes" a button message for the ZoomRect OpDescriptor, using the specified, rectangle. | |
Protected Member Functions | |
virtual Spread * | GetSpread (DocView *pDocView) const |
Gets a spread given a DocView. | |
virtual DocRect | GetRect (Spread *pSpread) |
Gets a rectangle given a spread. | |
virtual void | AdjustRect (DocRect *pRect) const |
In the base class version inflates the given document rectangle by 5% in each direction. | |
virtual MsgResult | HandleButtonMsg (DialogOp *popdlgThis, CGadgetID gidThis) |
Handles a button click message, by calling (virtual) GetSpread to find the spread to zoom in on, then (virtual) GetRect to find the rectangle within the spread. The (virtual) function AdjustRect is called to modify the resultant rectangle. Derived classes can override these functions to customise the effects of particular buttons. Performs the zoom, after saving the current zoom settings, then updates the zoom combo box. | |
Static Protected Member Functions | |
static OpState | GetState (String_256 *psName, OpDescriptor *popdCandidate) |
Returns the state that this zoom operation should appear in the menus or as a buttom, for example - greyed out, or ticked. |
Definition at line 415 of file zoomops.h.
|
Constructs the base class of the OpZoom's OpDescriptors.
Definition at line 1597 of file zoomops.cpp. 01599 : OpDescriptor(0, // tool ID 01600 wStatusID, // string ID of text in status bar 01601 CC_RUNTIME_CLASS(OpZoom), 01602 (TCHAR*) pcszToken, 01603 GetState, 01604 wHelpID, // help link ID 01605 wBubbleID, // bubble help string ID 01606 resourceID, 01607 controlID, 01608 TRUE) // wants to receive messages 01609 { 01610 // Empty. 01611 }
|
|
In the base class version inflates the given document rectangle by 5% in each direction.
Reimplemented in OpZoomFitSpreadDescriptor, and OpZoomFitSelectedDescriptor. Definition at line 1884 of file zoomops.cpp. 01885 { 01886 INT32 xinc = pRect->Width() / 20; // find 5% of the width and height 01887 INT32 yinc = pRect->Height() / 20; 01888 if (xinc < 1) xinc = 1; // make sure we inflate by some amount 01889 if (yinc < 1) yinc = 1; 01890 pRect->lo.x -= xinc; // inflate the given rectangle 01891 pRect->lo.y -= yinc; 01892 pRect->hi.x += xinc; 01893 pRect->hi.y += yinc; 01894 }
|
|
Is the base zoom descriptor class function for performing a zoom operation. It does this by calling (virtual) GetSpread to find the spread to zoom in on, then (virtual) GetRect to find the rectangle within the spread. The (virtual) function AdjustRect is called to modify the resultant rectangle. Derived classes can override these functions to customise the effects of particular zoom operation. Performs the zoom, after saving the current zoom settings, then updates the zoom combo box. Similar button to HandleButtonMsg but is designed to be called by the Do() operator in OpZoom and hence from keyboard short-cuts or menu operations.
Reimplemented in OpZoomPrevZoomDescriptor. Definition at line 1761 of file zoomops.cpp. 01762 { 01763 ERROR2IF(pZoomOp == 0, FALSE, "OpZoomDescriptor::DoZoom called with no operation"); 01764 01765 // Get the current view. 01766 DocView* pDocView = DocView::GetCurrent(); 01767 ERROR3IF(pDocView == 0, "No current DocView in OpZoomDescriptor::HandleButtonMsg"); 01768 if (pDocView == 0) 01769 return FAIL; 01770 01771 // Find the relevant spread, if any. 01772 Spread* pSpread = GetSpread(pDocView); 01773 ERROR3IF(pSpread == 0, "No relevant spread - can't do zoom\n"); 01774 if (pSpread == 0) 01775 return FAIL; 01776 01777 // Find the relevant zoom rectangle. 01778 DocRect drBounds = GetRect(pSpread); 01779 ERROR3IF(drBounds.IsEmpty(), "Relevant rectangle is empty - can't do zoom\n"); 01780 01781 // Allow derived class to adjust the document rectangle if it so desires. 01782 AdjustRect(&drBounds); 01783 01784 // Do the zoom, the scaling factor of which will not appear in the zoom op's table. 01785 pZoomOp->ZoomInOnRect(pSpread, drBounds); 01786 01787 return TRUE; 01788 }
|
|
"Fakes" a button message for OpDescriptor classes derived from OpZoomDescriptor. Searches for the OpDescriptor associated with the specified token. If it finds it then casts it to an OpZoomDescriptor*, checks if the associated button isn't greyed, and if not, calls its HandleButtonMsg function. Finally it makes sure that the percentage scale factor of the selected DocView is updated in the zoom combo box.
Definition at line 1916 of file zoomops.cpp. 01917 { 01918 // Try to find the OpDescriptor. 01919 OpZoomDescriptor* pZoomOpDesc = (OpZoomDescriptor*) FindOpDescriptor(pszToken); 01920 01921 // If that worked then call its button handler. 01922 if (pZoomOpDesc != 0 && pZoomOpDesc->IsAvailable()) 01923 { 01924 pZoomOpDesc->HandleButtonMsg(0, 0); 01925 } 01926 #ifndef RALPH 01927 else 01928 { 01929 // If it didn't then refresh the zoom combo with some percentages. 01930 // Beep(); 01931 wxBell(); 01932 OpZoomComboDescriptor::Update(); 01933 } 01934 #endif 01935 }
|
|
"Fakes" a button message for the ZoomRect OpDescriptor, using the specified, rectangle.
Definition at line 1952 of file zoomops.cpp. 01953 { 01954 // Try to find the OpDescriptor. 01955 OpZoomDescriptor* pZoomOpDesc = (OpZoomDescriptor*) FindOpDescriptor(OPTOKEN_ZOOMRECT); 01956 01957 // If that worked then call its button handler. 01958 if (pZoomOpDesc != 0) 01959 { 01960 ((OpZoomFitRectDescriptor*) pZoomOpDesc)->SetZoomRect(rect); 01961 pZoomOpDesc->HandleButtonMsg(0, 0); 01962 } 01963 }
|
|
Gets a rectangle given a spread.
Reimplemented in OpZoomFitSpreadDescriptor, OpZoomFitDrawingDescriptor, OpZoomFitSelectedDescriptor, and OpZoomFitRectDescriptor. Definition at line 1863 of file zoomops.cpp. 01864 { 01865 return pSpread->GetBoundingRect(); 01866 }
|
|
Gets a spread given a DocView.
Reimplemented in OpZoomFitSelectedDescriptor. Definition at line 1841 of file zoomops.cpp. 01842 { 01843 PORTNOTE("spread", "Multi-spread warning!") 01844 return pDocView->GetDoc()->FindFirstSpread(); 01845 }
|
|
Returns the state that this zoom operation should appear in the menus or as a buttom, for example - greyed out, or ticked.
Definition at line 1631 of file zoomops.cpp. 01632 { 01633 BOOL fCanDo = ((OpZoomDescriptor*) pOpDesc)->IsAvailable(); 01634 /* TRACEUSER( "JustinF", _T("OpZoomDescriptor::GetState for %-12s (0x%lX) - %-8s at %lu ms\n"), 01635 (LPCTSTR) pOpDesc->Token, 01636 (UINT32) pOpDesc, 01637 (LPCTSTR) (fCanDo ? TEXT("OK") : TEXT("Greyed")), 01638 (UINT32) ::GetTickCount()); 01639 */ return OpState(FALSE, !fCanDo); 01640 }
|
|
Handles a button click message, by calling (virtual) GetSpread to find the spread to zoom in on, then (virtual) GetRect to find the rectangle within the spread. The (virtual) function AdjustRect is called to modify the resultant rectangle. Derived classes can override these functions to customise the effects of particular buttons. Performs the zoom, after saving the current zoom settings, then updates the zoom combo box.
Reimplemented in OpZoomPrevZoomDescriptor. Definition at line 1812 of file zoomops.cpp. 01813 { 01814 // Try to create an instance of the zoom operation. 01815 OpZoom* pZoomOp = new OpZoom; 01816 ERRORIF(pZoomOp == 0, _R(IDE_NOMORE_MEMORY), FAIL); 01817 01818 // Do the zoom, the scaling factor of which will not appear in the zoom op's table. 01819 // DoZoom will End the operation 01820 BOOL ok = DoZoom(pZoomOp); 01821 if (!ok) return FAIL; 01822 return OK; 01823 }
|
|
Default "GetState"-like function for OpZoomDescriptor derivatives.
Reimplemented in OpZoomPrevZoomDescriptor, and OpZoomComboDescriptor. Definition at line 1659 of file zoomops.cpp. 01660 { 01661 // Try to get the "selected" view. 01662 DocView* pDocView = DocView::GetCurrent(); 01663 if (pDocView == 0) 01664 { 01665 // TRACEUSER( "JustinF", _T("\tNo current DocView in OpZoomDescriptor::IsAvailable\n")); 01666 return FALSE; 01667 } 01668 01669 // Find the relevant spread, if any. 01670 Spread* pSpread = GetSpread(pDocView); 01671 if (pSpread == 0) 01672 { 01673 // TRACEUSER( "JustinF", _T("\tNo relevant spread in OpZoomDescriptor::IsAvailable\n")); 01674 return FALSE; 01675 } 01676 01677 DocRect ZoomRect = GetRect(pSpread); 01678 BOOL Empty = ZoomRect.IsEmpty(); 01679 #ifdef _DEBUG 01680 // Is there actually no relevant rectangle within the spread to zoom on? 01681 if (Empty) 01682 { 01683 // TRACEUSER( "JustinF", _T("\tEmpty rectangle in OpZoomDescriptor::IsAvailable\n")); 01684 } 01685 #endif 01686 01687 // Find the relevant zoom rectangle, if any. 01688 return !Empty; 01689 }
|
|
Default message despatcher for OpZoomDescriptor derivatives. Passes button messages to HandleButtonMsg (virtual).
Reimplemented from OpDescriptor. Reimplemented in OpZoomComboDescriptor. Definition at line 1707 of file zoomops.cpp. 01708 { 01709 // Check if the message is an OpDesc message. 01710 if (!MESSAGE_IS_A(pMsg, OpDescMsg)) return OK; 01711 01712 // Cast it into the correct type etc. 01713 OpDescMsg* pOpDescMsg = (OpDescMsg*) pMsg; 01714 01715 // Process the message . . . 01716 if (pOpDescMsg->OpDesc == this && MESSAGE_IS_A(pOpDescMsg, OpDescControlMsg)) 01717 { 01718 // Cast to a control message, unpack, and despatch to the handler. 01719 OpDescControlMsg* pControlMsg = (OpDescControlMsg*) pOpDescMsg; 01720 if (pControlMsg->DlgMsg == DIM_LFT_BN_CLICKED) 01721 { 01722 if (IsAvailable()) 01723 return HandleButtonMsg(pControlMsg->pDlgOp, pOpDescMsg->SetGadgetID); 01724 #if !defined(EXCLUDE_FROM_RALPH) 01725 else 01726 // Beep(); 01727 wxBell(); 01728 #endif 01729 } 01730 } 01731 01732 // Let the base class do its stuff on the message. 01733 return OpDescriptor::Message(pMsg); 01734 }
|