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

CListBox

Methods Index

Heritage
Description
Usage
Environment
Protected Data Members
Public Methods
Constructor, Destructor, and Initializer Methods
Example
Text Item Utility
List Box Sizing
Inherited Utility Methods
Selecting Routines
Inherited Methods
TDI Enabling Methods
Protected Methods

CListBox


Heritage

Superclass: CScroller

Subclasses: None


Description

CListBox objects display a box containing a list of selectable text items. The box can have horizontal and vertical scrollbars. To select an item inside the list box, the user clicks the mouse on it.


Usage

Create an instance of this class, initialize it, and register it with an enclosure. Items can be dynamically added, removed, activated, or disabled. The items are numbered, starting at 0, from the top down.

All items passed to the object to be inserted into the list are assumed to be pointers to character strings. That is, the initializing routine takes an ordered list of CStrings.

When the list box is sized, or when a font is changed, the final size of the list box's viewing rectangle can optionally be adjusted so that an integral number of lines can be viewed. This option assures that a line will not be cut halfway through or halfway clipped at the bottom of the list.


Environment

The border of the list box is drawn with the pen; its interior is painted with the brush. The text items are drawn in the background color, but, when selected, are drawn in the foreground color. The environment properties of the scrollbars are system-defined. You can set the color and pattern of both the pen and the brush. Also, you can set the pen width. Finally, you can set the foreground and background colors.


Protected Data Members

RWOrdered* itsItems; List that stores the actual text strings
CFixedGrid* itsGrid; Grid used to display items
BOOLEAN itIsDragging; whether the mouse is being dragged
UNITS itsSuggestedHeight; Saves unrounded suggested height for listbox.
BOOLEAN itsClipsHalfLines Determines if a line is half visible when scrolling
BOOLEAN itIsHit; Keeps track of mouse event state


Public Methods

Constructor, Destructor, and Initializer Methods

CListBox(CSubview* theEnclosure, 
const CRect& theRegion);
CListBox(CWindow* theScrollableWindow,
UNITS theVirtualWidth = 0,
UNITS theVirtualHeight = 0);
CListBox(const CListBox& theListBox);
CListBox& operator=(const CListBox& theListBox);
virtual ~CListBox(void);
BOOLEAN IListBox(
const CStringCollection* theItems = NULL,
BOOLEAN hasHorizontalScrollBar = FALSE,
BOOLEAN hasVerticalScrollBar = TRUE,
BOOLEAN isThumbTracking = TRUE,
long theSingleClickCommand = NULLcmd,
long theDoubleClickCommand = NULLcmd,
BOOLEAN isVisible = TRUE,
long theGlue = NULLSTICKY);

Example

CListBox*  aListBox = new CListBox(this,
CRect(200,250,350,350));
RWOrdered *anItem = new RWOrdered();

CStringRWC str1("line 1");
anItem->insert(&str1);

CStringRWC str2("line 2");
anItem->insert(&str2);

CStringRWC str3("line 3");
anItem->insert(&str3);

CStringCollection aCollection(*anItem);
aListBox->IListBox(&aCollection);
aListBox->DoDraw();

Text Item Utility

virtual void InsertLine(const CStringRW& theItem, 
int thePosition, BOOLEAN replace = TRUE);
virtual void RemoveLine(int thePosition);
virtual int GetNumberOfLines(void) const;
virtual int GetSelectedLine(void) const;
virtual void SelectLine(int theLine);
virtual void DeselectLine(void);
virtual CStringRW GetLine(int thePosition) const;
virtual int GetLine(const CStringRW& theName) const;
virtual void ScrollUntilVisible(int thePosition);

List Box Sizing

virtual BOOLEAN IsHeightSelfAdjusted(void);
virtual void SelfAdjustHeight(BOOLEAN isHeightSelfAdjusted);

Inherited Utility Methods

virtual void Key(const CKey& theKey);
virtual void VScroll(SCROLL_CONTROL theEventType, 
UNITS theThumbPosition);
virtual void Size(const CRect& theNewSize);
virtual void DoSize(const CRect& theNewSize);

Selecting Routines

virtual CView* FindEventTarget(const CPoint& theLocation) const;
virtual void MouseDown(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
virtual void MouseUp(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
virtual void MouseMove(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
virtual void MouseDouble(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);

Inherited Methods

virtual void DoSetFont(const CFont &theNewFont,
BOOLEAN isUpdate = FALSE);
virtual void SetFont(const CFont &theNewFont, 
BOOLEAN isUpdate = FALSE);
virtual void DoSetSizing(BOOLEAN isSizable);
virtual void DoSetDragging(BOOLEAN isDraggable);
virtual void SetGlue(GLUETYPE theGlue);

TDI Enabling Methods

virtual void SetSelectedView(CView* theSelectedView);
virtual void DoCommand(long theCommand, 
void* theData = NULL);
virtual void DoUpdateModel(long theControllerId, 
long theCommand, const CModel* theModel);

Protected Methods

void SizeLines(UNITS theWidth, UNITS theHeight);
void ResetDimensions(void);
void ScrollLines(CPoint theLocation);
CView* GetSelectedItem(int theIncrement);
void TdiNotifyItems(long theCommand, RWOrdered* theViews);


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

support@xvt.com


Visit our online help desk for tech support

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