home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IVPORT.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
18KB
|
317 lines
#ifndef _IVPORT_
#define _IVPORT_
/*******************************************************************************
* FILE NAME: ivport.hpp *
* *
* DESCRIPTION: *
* Declaration of the class(es): *
* IViewPort - This class creates a view port window that allows scrolling *
* of a client control or window. *
* *
* COPYRIGHT: *
* Licensed Materials - Property of IBM *
* (C) Copyright IBM Corporation 1992, 1993 *
* All Rights Reserved *
* US Government Users Restricted Rights - Use, duplication, or disclosure *
* restricted by GSA ADP Schedule Contract with IBM Corp. *
* *
* CHANGE HISTORY: *
*******************************************************************************/
#ifndef _ICANVAS_
#include <icanvas.hpp>
#endif
#ifndef _IPOINT_
#include <ipoint.hpp>
#endif
#ifndef _IRECT_
#include <irect.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
// Forward declarations for other classes:
class IColor;
class IScrollBar;
class IViewRectangle;
class IViewPort : public ICanvas {
typedef ICanvas
Inherited;
/*******************************************************************************
* The IViewPort class is used to provide scrolling support for a client *
* window known as the view window. Typically, the view window does not *
* readily support resizing. Because of this, it needs to be scrolled so that *
* clipped information is not lost to the user. Candidate view windows *
* include the following classes: *
* - ICanvas *
* - ISetCanvas *
* - INotebook *
* - IContainer *
* *
* The view window is specified by making it a child window of the view port. *
* The view port is the parent window of the view window. A view port *
* supports only one view window. *
* *
* The IViewPort optionally includes horizontal and vertical scroll bars. The *
* scroll bars can be specified to always be visible, to never be visible, or *
* to only be shown if the size of the view window is larger than the size of *
* the view port window. If the view port has nothing to scroll because the *
* view window is entirely visible, the scroll bars are hidden. *
* *
* Example: *
* myViewPort = new IViewPort(ID_VIEWPORT, myFrame, myFrame); *
* myFrame->setClient(myViewPort); // make it the client area *
* myViewWindow = new MyViewWindow(ID_VIEWWINDOW, myViewPort, myViewPort); *
* // make it the view window by making it a child of the view port *
*******************************************************************************/
public:
class Style; // forward declaration for nested class
/*-------------------------- Constructor/Destructor ----------------------------
| You can construct instances of this class by specifying a window ID, parent |
| and owner windows, an optional position and size, and an optional style. |
| |
| The IViewPort class reserves the use of the following window IDs for child |
| windows that it creates: |
| 0x8000 - Vertical scroll bar. |
| 0x8001 - Horizontal scroll bar. |
| 0x8002 - Scroll rectangle (the window within which the application window |
| is scrolled). |
------------------------------------------------------------------------------*/
IViewPort ( unsigned long windowId,
IWindow* parent,
IWindow* owner,
const IRectangle& initial = IRectangle(),
const Style& style = defaultStyle() );
virtual
~IViewPort ( );
/*--------------------------------- Style --------------------------------------
| The IViewPort::Style nested class provides static members that define the |
| set of valid styles for IViewPort objects. These styles can also be used |
| in conjunction with the styles defined by the nested classes |
| ICanvas::Style and IWindow::Style. For example, you could define an |
| instance of the IViewPort::Style class and initialize it like: |
| IViewPort::Style style = IViewPort::classDefaultStyle | |
| IWindow::saveBits; |
| An object of this type is provided when the IViewPort object is created. |
| A customizable default is used if no styles are specified. Once the |
| object is constructed, IViewPort, ICanvas, and IWindow member functions |
| can be used to set or query the object's style. |
| |
| The declaration of the IViewPort::Style nested class is generated by the |
| INESTEDBITFLAGCLASSDEF2 macro. |
| |
| The valid IViewPort object styles are: |
| alwaysHorizontalScrollBar - This style specifies to never remove the |
| horizontal scroll bar. |
| asNeededHorizontalScrollBar - This style specifies the removal of the |
| horizontal scroll bar when the entire width |
| of the view window is visible and there is |
| no data to scroll horizontally. |
| noHorizontalScrollBar - This style specifies to never show the |
| horizontal scroll bar. |
| alwaysVerticalScrollBar - This style specifies to never remove the |
| vertical scroll bar. |
| asNeededVerticalScrollBar - This style specifies the removal of the |
| vertical scroll bar when the entire height |
| of the view window is visible and there is |
| no data to scroll vertically. |
| noVerticalScrollBar - This style specifies to never show the |
| vertical scroll bar. |
| noViewWindowFill - This style specifies that the view port will |
| not paint the portion of the view rectangle |
| occupied by the view window. This should be |
| specified to optimize overall painting if |
| the view window is known to paint its entire |
| rectangle. |
| classDefaultStyle - Original default style for this class, |
| which is asNeededHorizontalScrollBar | |
| asNeededVerticalScrollBar | |
| IWindow::visible. |
| |
| The following functions provide a means of getting and setting the default |
| style for this class: |
| defaultStyle - Returns the current default style. This is the same |
| as classDefaultStyle unless setDefaultStyle has been |
| called. |
| setDefaultStyle - Sets the default style for all subsequent IViewPort |
| objects. |
------------------------------------------------------------------------------*/
INESTEDBITFLAGCLASSDEF2(Style, IViewPort, IWindow, ICanvas);
// style class definition
static const Style
alwaysHorizontalScrollBar,
asNeededHorizontalScrollBar,
noHorizontalScrollBar,
alwaysVerticalScrollBar,
asNeededVerticalScrollBar,
noVerticalScrollBar,
noViewWindowFill,
classDefaultStyle;
static Style
defaultStyle ( );
static void
setDefaultStyle ( const Style& style );
/*-------------------------------- Accessors -----------------------------------
| These functions provide a means of getting and setting the accessible |
| attributes of instances of this class: |
| viewWindow - Returns the handle of the window bounded by the |
| view port. If more than one child of the view port |
| is found, an exception is thrown. The parent of |
| the view window is changed so that the view window |
| is properly clipped. |
| horizontalScrollBar - Returns the address of the horizontal scroll bar. |
| verticalScrollBar - Returns the address of the vertical scroll bar. |
------------------------------------------------------------------------------*/
virtual IWindowHandle
viewWindow ( );
IScrollBar
*horizontalScrollBar ( ) const,
*verticalScrollBar ( ) const;
/*------------------------- View Window Manipulation ---------------------------
| These functions provide a means of affecting the appearance of the view |
| window in the viewport: |
| scrollViewVerticallyTo - Causes the specified 0-based offset from the |
| top of the view window to be scrolled to the |
| top of the view port. |
| scrollViewHorizontallyTo - Causes the specified 0-based offset from the |
| left edge of the view window to be scrolled to |
| the left edge of the view port. |
| setViewWindowSize - Changes the logical size of the window being |
| scrolled. The logical size does not have to |
| match the real size of the window. |
| viewWindowSize - Returns the logical size of the window being |
| scrolled. If the setViewWindowSize function |
| has not been called to set a logical size, the |
| real size of the view window is returned. |
| viewWindowDrawRectangle - Returns the area of the view window that is |
| currently visible in the view port. |
------------------------------------------------------------------------------*/
virtual IViewPort
&scrollViewVerticallyTo ( unsigned long topOffset ),
&scrollViewHorizontallyTo ( unsigned long leftOffset );
virtual IViewPort
&setViewWindowSize ( const ISize& size );
virtual ISize
viewWindowSize ( ) const;
virtual IRectangle
viewWindowDrawRectangle ( ) const;
/*------------------------------- Enumeration ----------------------------------
| The following enumeration is defined: |
| ColorArea - Enumeration used to specify an area of the view port that can |
| be affected with color. The valid value is: |
| fillBackground - The portion of the view rectangle that is |
| not occupied by the view window. This |
| situation occurs if the size of the view |
| window is smaller than the size of the |
| view port. |
------------------------------------------------------------------------------*/
enum ColorArea {
fillBackground
};
/*---------------------------------- Color -------------------------------------
| These functions set and query the color of the view port: |
| setColor - Sets the specified color of the view port. |
| color - Returns the specified color of the view port. |
------------------------------------------------------------------------------*/
IViewPort
&setColor ( ColorArea area, const IColor& color );
IColor
color ( ColorArea area ) const;
/*-------------------------------- Overrides -----------------------------------
| This class overrides the following inherited function: |
| setLayoutDistorted - Treats a size change like a layout change. |
------------------------------------------------------------------------------*/
virtual IViewPort
&setLayoutDistorted ( unsigned long layoutAttributeOn,
unsigned long layoutAttributeOff );
protected:
/*--------------------------- Protected Overrides ------------------------------
| This class overrides the following protected functions: |
| calcMinimumSize - Returns the recommended minimum size of this IViewPort |
| object. The size is based on the minimum size of the |
| vertical and horizontal scroll bars. |
| layout - Positions the scroll bars and view window. |
------------------------------------------------------------------------------*/
virtual ISize
calcMinimumSize ( ) const;
virtual IViewPort
&layout ( );
/*------------------------------ Implementation --------------------------------
| These functions are used to size and position the scroll bars and view |
| window when the view port is resized or repainted. |
| setupScrollBars - Sizes, shows, and hides scroll bars for the view |
| port window, as appropriate. This function also |
| sets the rectangle that bounds the view window. |
| positionViewWindow - Positions the view window within the view rectangle. |
| setTopLeftViewPoint - Sets the view window coordinate that is displayed |
| in the upper left corner of the view rectangle. |
| topLeftViewPoint - Returns the view window coordinate that is |
| displayed in the upper left corner of the view |
| rectangle. |
------------------------------------------------------------------------------*/
IViewPort
&setupScrollBars ( );
virtual IViewPort
&positionViewWindow ( const IWindowHandle& viewWindow,
const IRectangle& viewRectangle );
IViewPort
&setTopLeftViewPoint ( const IPoint& topLeft );
IPoint
topLeftViewPoint ( ) const;
private:
/*--------------------------------- Private ----------------------------------*/
IViewPort ( const IViewPort& );
IViewPort
&operator= ( const IViewPort& );
static Style
currentDefaultStyle;
Style
vpsClStyle;
IPoint
ptClTopLeftView;
IScrollBar
*psbClVert,
*psbClHorz;
IViewRectangle
*pcvClViewRect;
ISize
sizClViewWindow;
enum Flag { initialized=1, resizeHandlerAdded=2, scrollHandlerAdded=4,
keyboardHandlerAdded=8, paintHandlerAdded=16,
rectanglePaintHandlerAdded=32, useMinimumSizeView=64 };
unsigned long
ulClFlag;
}; // IViewPort
INESTEDBITFLAGCLASSFUNCS(Style, IViewPort);
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
/*----------------------------- Inline Functions -----------------------------*/
#ifndef I_NO_INLINES
#include <ivport.inl>
#endif
#endif /* _IVPORT_ */