[Classes] [Prev] [Next] [Methods]

CAttachment

Methods Index

Heritage
Description
Usage
Enums
Protected Data Members
Friends
Overrides
Public Methods
Constructor, Destructor, and Initializer Methods
Utility Methods
CMouseHandler Overridden Methods
Overridden CDragSource Method for Mouse Interactions.
Protected Methods

CAttachment


Heritage

Superclass: CDragSource

Subclass: CStatusBarAttachment

Helper Class: CAttachmentWindow


Description

CAttachment manages a view object and provides it with attachment capabilities. A view managed by a CAttachment will automatically be placed inside an attachment frame (see CAttachmentFrame) or a floating or detached window (see CAttachmentWindow).

CAttachment also provides drag/drop functionality and pop-up/tear-off functionality to change the location or attachment of the view.


Usage

Use of attachments requires the following steps:

The following code sample shows these steps:

// Create anAttachmentFrame and aButton
CAttachmentFrame *anAttachmentFrame = 
new CAttachmentFrame(this);
NButton *aButton = new NButton(
anAttachmentFrame, CRect(0,0,100,10));

// Create anAttachment

CToolBarAttachment
*anAttachment = new CAttachment(aButton);

// Attach button to top of anAttachmentFrame

anAttachment->Attach(
anAttachmentFrame, ATTACH_TOP);
GetMouseManager()->RegisterMouseHandler(
anAttachment);

// Enable dragging for button to anAttachmentFrame
// (multiple CAttachmentFrame's may be registered
// enabling drag and drop of the button between them)

anAttachment->RegisterSink(anAttachmentFrame);

Enums

Attachment States

AS_INITIAL = 0, Using 0 for internal initial state
AS_ATTACHED, Attached to the side of a window
AS_DETACHED, Detached in a (task) floating window
AS_POPUP, Detached in a pop-up window constrained to a container window


Protected Data Members

BOOLEAN itIsDraggable; Can be dragged?
BOOLEAN itIsDetachable; Can be detached from window?
CView* itsView; View managed for attachment
AttachmentState itsState; Attachment state
RWSortedVector itsFitSizes; Fit sizes for itsView
CAttachmentWindow* itsExternalWindow; Pointer to floating window
CAttachmentWindow* itsInternalWindow; Pointer to attached window
CAttachmentFrame* itsAttachmentFrame; Current frame of attachment
CAttachmentFrame::
AttachmentPoint
itsAttachmentPoint; Point of attachment
BOOLEAN itIsReadyToTearOff; Mouse state flag
CPoint itsDragOffset; Mouse state value
BOOLEAN itIsDeletedUponClose; Delete when window is closed?
BOOLEAN itHasMoved; Mouse state value
static BOOLEAN isTearingOff; Mouse state value


Friends

friend class CAttachmentFrame;
friend class CAttachmentWindow;


Overrides

You can derive specialized CAttachment classes that specialize their behavior for a type of view. For such specializations, you can override GetAllFitSizes() and GetBestSize() to return more appropriate values. The default implementation only returns the CAttachment's view normal size. (You can look at CToolBarAttachment for a sample derivation of CAttachment which defines fit sizes as they apply to the attachment of CToolBar objects.)

CAttachment uses a helper class, CAttachmentWindow, to display views inside a pop-up and floating window. You may override the ConstructInternalWindow() and ConstructExternalWindow() virtual factory methods to install the use of alternative implementations of these windows.


Public Methods

Constructor, Destructor, and Initializer Methods

CAttachment(CView *theView);
CAttachment(const CAttachment& theAttachment);
CAttachment& operator=(const CAttachment& theAttachment);
virtual ~CAttachment(void);
virtual void IAttachment(
BOOLEAN isDeletedUponClose = FALSE);

Utility Methods

virtual const RWSortedVector* GetAllFitSizes(void);
virtual CRect GetBestSize(void);
virtual CRect GetFitSize(
UNITS theDesiredWidth,
UNITS theDesiredHeight);
CRect GetFitSizeFromHeight(
UNITS theMaxHeight,
UNITS theMaxWidth = 0L);
CRect GetFitSizeFromWidth(
UNITS theMaxWidth,
UNITS theMaxHeight = 0L);
CRect GetSizeToFitAttachmentPoint(
CAttachmentFrame* theAttachmentFrame,
CAttachmentFrame::AttachmentPoint theAttachmentPoint);
void Hide(void);
void Show(void);
virtual void  SetSize(const CRect &theRect);
virtual CRect GetSize(void);
virtual void Attach(
CAttachmentFrame* theFrame,
CAttachmentFrame::AttachmentPoint theAttachmentPoint);
virtual void Detach(BOOLEAN hasTitleBar = TRUE);
BOOLEAN IsDetachable(void) const;
void SetDetachable(BOOLEAN canDetach);
virtual void Popup(
CWindow* theWindow,
BOOLEAN hasTitleBar = FALSE);
void PopupAtPoint(
CWindow *theWindow,
CPoint aTopLeft,
BOOLEAN hasTitleBar = TRUE);
AttachmentState GetState(void) const;
virtual BOOLEAN IsDraggable(void) const;
void SetDragging(BOOLEAN isDraggable);
void SetTitle(const CStringRW& theNewTitle);
const CStringRW GetTitle(void) const;
CRect GetBorderSize(
const CRect &theClientRect,
BOOLEAN hasTitleBar);
CAttachmentFrame* GetAttachmentFrame(void);
CView* GetView(void) const;

CMouseHandler Overridden Methods

virtual BOOLEAN DoDown(
CPoint& theLocation,
short& theButton,
BOOLEAN& isShiftKey,
BOOLEAN& isControlKey);
virtual BOOLEAN DoUp(
CPoint& theLocation,
short& theButton,
BOOLEAN& isShiftKey,
BOOLEAN& isControlKey);
virtual BOOLEAN DoMove(
CPoint& theLocation,
short& theButton,
BOOLEAN& isShiftKey,
BOOLEAN& isControlKey);
virtual BOOLEAN DoDouble(
CPoint& theLocation,
short& theButton,
BOOLEAN& isShiftKey,
BOOLEAN& isControlKey);

Overridden CDragSource Method for Mouse Interactions.

virtual void DoDrag(
long theDragCommand,
void* theDragData,
CWindow *theTrapWindow,
CURSOR theDragCursor);

Protected Methods

virtual BOOLEAN TearOff(void);
virtual CRect GetDesiredSize(void);
CPoint GetDragOffset(void);
void   SetDragOffset(CPoint *theDragOffset = NULL);
void SetAttachmentPoint(
CAttachmentFrame::AttachmentPoint theAttachmentPoint);
CAttachmentFrame::AttachmentPoint GetAttachmentPoint(void)const;
BOOLEAN CanAttachTo(const CWindow *theWindow);
void Redraw(void)const;
virtual void InternalAttach(
CAttachmentFrame *theFrame,
CAttachmentFrame::AttachmentPoint theAttachmentPoint);
virtual CAttachmentWindow* ConstructInternalWindow(
CWindow *theEnclosure,
CAttachment *theAttachment,
BOOLEAN hasTitleBar);
virtual CAttachmentWindow* ConstructExternalWindow(
CAttachment *theAttachment,
BOOLEAN hasTitleBar);


[Classes] [Prev] [Next] [Methods]

support@xvt.com


Visit our online help desk for tech support

Copyright © 2009, Providence Software Solutions Inc. All rights reserved.