| Methods Index |
CSubviewSubclasses:
CMenuButton
CButton objects are CSubviews that have push or toggle button behavior. These objects have the same look-and-feel on all platforms. Unlike native buttons (NButtons), CButton objects have the ability to send notification (via the DoCommand mechanism) both when the cursor enters or leaves the CButton and when a mouse button is pressed down or released over the CButton.A togglable
CButton has the following three states: TS_UP, TS_DOWN, and TS_UNKNOWN. If the button is clicked while in the TS_UNKNOWN state, it shifts to the TS_DOWN state.Although
CButtons are typically used for displaying a portable image inside a button, they may enclosure any CView-derived object. Note, however, that CNativeView-derived classes do not behave properly inside a CButton because the native view still receives events.
CButton class provides two convenience constructors for common usage. The class provides one constructor for creating a CButton that contains text (CStringRW) and one for creating a CButton that contains a portable image (CImage).You can also instantiate
CButtons as a CSubview to which you can add other CView-derived objects.All
CButton constructors have an isTogglable argument, which indicates whether the button acts like a push button or a toggle button.See Also: For an example of implementing status bar help for
CButtons, see
the Usage section of CMenuButton.
Environment
CButton objects do not react to a change in their CEnvironment. The colors used to render the button may be specified in the IButton initializer method. However, CSubviews that are enclosed by a CButton react to a change in their CEnvironment.
Enums
ToggleState
TS_UP
Toggle button is in up state
TS_DOWN
Toggle button is in down state
TS_UNKNOWN
Toggle button is in unknown state (neither up nor down)
Protected Data Members
Public Methods
Constructor, Destructor, and Initializer Methods
CButton(CSubview *theEnclosure,
const CRect &theSize,
BOOLEAN isTogglable = FALSE);
CButton of size theSize with enclosure theEnclosure. The isTogglable argument indicates whether the CButton acts like a push button or a toggle button. By default, CButtons are push buttons.This constructor is generally followed by creation of other
CView objects that have the CButton as their enclosure. You should however use this constructor only when constructing a CButton that contains views other then CText or CPicture objects. XVT provides convenience constructors for these common construction cases.
CButton(CSubview *theEnclosure,
const CPoint &theTopLeft, // autosized to theText
const CStringRW &theText
BOOLEAN isTogglable = FALSE);
CButton object that contains text. This constructor creates a CText object, places it in the new CButton, and sizes the CButton to the text.
CButton(CSubview *theEnclosure,
const CPoint &theTopLeft, // autosized to theImage
const CImage &theImage,
BOOLEAN isTogglable = FALSE);
CButton object that contains a portable image. This constructor creates a CPicture object, places it in the new CButton, and sizes the CButton to the image.
CButton(const CButton &theButton);
theButton's attributes. Note that a button's colors and commands are copied, but they are not contained subviews. Attributes copied from the inherited CSubview copy constructor are also copied.
CButton & operator = (const CButton &theButton);
CSubview assignment operator are also copied.
virtual ~CButton();
CButton destructor. Deletes button and all nested subviews.
void IButton(COLOR theDarkBorder = COLOR_BLACK,
COLOR theLightShadowColor = COLOR_WHITE,
COLOR theDarkShadowColor = COLOR_GRAY,
COLOR theFlatColor = COLOR_LTGRAY);
CButton class. This method is used to set the colors with which CButton are rendered.
CButton class overrides the MouseUp, MouseDown, MouseMove, and MouseDouble methods from CSubview and translates them into "events" that are meaningful to a button. Specifically, this class translates these methods into DoIn, DoOut, DoUp, and DoDown events. The following is the possible sequence of synthesized events:
DoIn event is sent
DoIn event is followed by a DoDown event
DoDown event is sent
DoUp event is sent
DoOut event is sent
DoIn, DoOut events for a CButton:
CButton object with the mouse button up
CButtons, and then the cursor is dragged into and out of button
CButtons, and then the cursor is dragged into a button, the mouse button is released, and the cursor is moved out of the button
DoIn, DoDown, DoOut events for a CButton:
CButton object, the cursor is dragged into the button, and then it is dragged out of the button, without releasing mouse button
DoIn, DoDown, DoUp, DoOut events for a CButton:
CButton, then the cursor is dragged into the button, the mouse button is then release in the button, and cursor is moved out of the button
CButton always receives a DoIn before a DoOut, DoUp, or DoDown
event.
virtual void MouseUp(CPoint theLocation,Translates a
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
MouseUp event into a DoUp event.
virtual void MouseDown(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
MouseDown event into a DoDown event (and possibly a DoIn event).
virtual void MouseMove(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
MouseMove event into DoIn (and possibly DoDown) and DoOut events.
virtual void MouseDouble(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
MouseDouble event as a MouseDown event, which is how CButton objects respond to MouseDouble events.
virtual BOOLEAN IsInButton(CPoint theLocation);
TRUE if theLocation is in the CButton.
virtual void DoIn(void);
virtual void DoOut(void);
virtual void DoUp(void);
virtual void DoDown(void);
DoUp event has been received for the button.
virtual void DoDraw(
const CRect &theClippingRegion = MAXRect);
CButton's contents to inside the button border.
virtual void Draw(const CRect &theClippingRegion);
virtual void AddSubview(const CView* theSubview);
theSubview by the width of the button border. If necessary, this method also sets itDrawsBackground to TRUE.
virtual void Size(const CRect& theNewSize);
itDrawsBackground to TRUE if it is needed.
virtual void Key(const CKey& theKey);
thekey represents the character key that was pressed, including the Shift and Control key states, when the key was pressed.
virtual void SetTitle(const CStringRW& the NewTitle);
theNewTitle.
virtual BOOLEAN ClassCanGetKeyFocus(void) const;
CView::ClassCanGetKeyFocus to return TRUE.
virtual CView * FindEventTarget(
const CPoint &theLoc) const;
CButton; subviews enclosed by a CButton do not receive events.
virtual CView * FindDeepSubview(const CPoint &theLoc) const;
CButton; subviews enclosed by a CButton do not receive events.Note: On some platforms, you cannot stop enclosed native views from receiving events, and the native views consume events before XVT-Power++ receives them. Therefore, you should not place native views inside of
CButton objects.
virtual void SetTogglable(BOOLEAN isTogglable);
CButton object togglable according to the isTogglable parameter.
virtual BOOLEAN IsTogglable(void) const;
TRUE if button is togglable, and FALSE otherwise.
virtual ToggleState GetToggleState(void) const;
CButton. The possible returned states are as follows:
CButton::TS_UP CButton::TS_DOWN CButton::TS_UNKNOWN This method is not meaningful for non-togglable
CButtons.
virtual void SetToggleState(ToggleState theState);
CButton to theState parameter.The possible states are as follows:
CButton::TS_UP
CButton::TS_DOWN
CButton::TS_UNKNOWNThis method has no effect on non-togglable
CButtons.
virtual void SetEnabled(BOOLEAN isEnabled,
BOOLEAN isUpdated);
isEnabled if needed, and invalidates the button if isUpdated is TRUE.
virtual void SizeToFit(void);
CButton so that it is the minimum size that includes all of its subviews. This method also moves the CButton subviews up and left in the CButton, as far as possible, while maintaining their relationship to each other.
void SetCommands(long theUpCommand = NULLcmd,
long theDownCommand = NULLcmd,
long theInCommand = NULLcmd,
long theOutCommand = NULLcmd);
void SetDownCommand(long theCommand);
CButton receives a DoDown event.
long GetDownCommand(void) const;
CButton receives a DoDown event.
void SetUpCommand(long theCommand);
CButton receives a DoUp event.
long GetUpCommand(void) const;
CButton receives a DoUp event.
void SetInCommand(long theCommand);
CButton receives a DoIn event.
long GetInCommand(void) const;
CButton receives a DoIn event.
void SetOutCommand(long theCommand);
CButton receives a DoOut event.
long GetOutCommand(void) const;
CButton receives a DoOut event.
virtual int GetBorderPixels(void) const;
CButton border.
virtual int GetTopLeftBorderPixels(void) const;
virtual void DoCommand(long theCommand,
void* theData = NULL);
CView::DoCommand to provide handling for TDI commands.
virtual void DoUpdateModel(long theControllerId,
long theCommand, const CModel* theModel);
CView::DoUpdateModel to provide handling of TDI messages.
void CopyInternals(const CButton &theButton);
void SubviewsDoSetOrigin(int theHOffset, int theVOffset);
virtual BOOLEAN NeedsDoOut(void);
DoOut events by subclasses.
virtual vo id InternalDoDraw(
const CRect &theClippingRegion = MAXRect);
DoDraw method, but this method does not draw the button's border.
CButton. To provide a new button class with a different button border look, simply override the methods described below as needed.
virtual void IndicateIn(void);
CButton is not to provide any visual feedback.
virtual void DrawBorder(void);
CButton. By default, this border is a black rectangle with grey corners.
virtual void DrawDisabled(void);
CButton, this method "grays-out" the entire button.
virtual void DrawUp(void);
Draw method.
virtual void DrawDown(void);
Draw method.
virtual void DrawPressed(void);
Draw method. The "pressed" state occurs when a togglable CButton is pressed (the mouse button is held down).
virtual void DrawUnknown(void);
Draw method.
virtual void DoUpAction(void);
DoUp event is sent. By default, this method calls the DoCommand method with itsCommand (if not NULLcmd).
virtual void DoDownAction(void);
DoDown event is sent. By default, this method calls the DoCommand method with itsDownCommand (if not NULLcmd).
virtual void DoInAction(void);
DoIn event is sent. By default, this method calls the DoCommand method with itsInCommand (if not NULLcmd).
virtual void DoOutAction(void);
DoOut event is sent. By default, this method calls the DoCommand method with itsOutCommand (if not NULLcmd).
virtual void InternalUp(void);
DoUp event. This method also toggles the state for togglable buttons.
virtual void InternalDown(void);
DoDown event.