Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

os::DropdownMenu Class Reference

Edit box with an asociated item-menu. More...

#include <dropdownmenu.h>

Inheritance diagram for os::DropdownMenu::

os::View os::Invoker os::Handler List of all members.

Public Methods

 DropdownMenu (const Rect &cFrame, const char *pzName, uint32 nResizeMask=CF_FOLLOW_LEFT|CF_FOLLOW_TOP, uint32 nFlags=WID_WILL_DRAW|WID_FULL_UPDATE_ON_RESIZE)
 DropdownMenu constructor. More...

 ~DropdownMenu ()
void SetEnable (bool bEnable=true)
bool IsEnabled () const
void SetReadOnly (bool bFlag=true)
 Change the "read-only" status. More...

bool GetReadOnly () const
 Returns the read-only status. More...

void AppendItem (const char *pzString)
 Add a item to the end of the drop down list. More...

void InsertItem (int nPosition, const char *pzString)
 Insert and item at a given position. More...

bool DeleteItem (int nPosition)
 Delete a item. More...

int GetItemCount () const
 Get the item count. More...

void Clear ()
 Delete all items. More...

const std::string & GetItem (int nItem) const
 Get one of the item strings. More...

int GetSelection () const
 Get the current selection. More...

void SetSelection (int nItem, bool bNotify=true)
 Set current selection. More...

const std::string & GetCurrentString () const
void SetCurrentString (const std::string &cString)
void SetMinPreferredSize (int nWidthChars)
int GetMinPreferredSize () const
void SetMaxPreferredSize (int nWidthChars)
int GetMaxPreferredSize () const
void SetSelectionMessage (Message *pcMsg)
 Set the message that will be sendt when the selection changes. More...

MessageGetSelectionMessage () const
 Get a pointer to the current "SelectionChanged" message. More...

void SetSendIntermediateMsg (bool bFlag)
bool GetSendIntermediateMsg () const
void SetEditMessage (Message *pcMsg)
 Set the message sendt when the user changes the content of the edit box. More...

MessageGetEditMessage () const
 Get a pointer to the current "SelectionChanged" message. More...

virtual void HandleMessage (Message *pcMessage)
 Handle events from sub components. More...

virtual void Paint (const Rect &cUpdateRect)
 Called by the system update "damaged" areas of the view. More...

virtual Point GetPreferredSize (bool bLargest) const
virtual void FrameSized (const Point &cDelta)
 Virtual hook called by the system when the view is resized. More...

virtual void MouseDown (const Point &cPosition, uint32 nButtons)
 Hook called by the system when a mouse button is pressed. More...

virtual void KeyDown (const char *pzString, const char *pzRawString, uint32 nQualifiers)
 Hook called by the system when a key is pressed while the view has focus. More...

virtual void AllAttached ()

Friends

class DropdownView

Detailed Description

Description:
See also:
TextView, Invoker
Author:
Kurt Skauen ([email protected])


Constructor & Destructor Documentation

DropdownMenu::DropdownMenu const Rect & cFrame,
const char * pzName,
uint32 nResizeMask = CF_FOLLOW_LEFT | CF_FOLLOW_TOP,
uint32 nFlags = WID_WILL_DRAW | WID_FULL_UPDATE_ON_RESIZE
 

Parameters:
cFrame   - The size and position of the edit box and it's associated button.
pzName   - The identifier passed down to the Handler class (Never rendered)
nResizeMask   - Flags deskribing which edge follows edges of the parent when the parent is resized (Se View::View())
nFlags   - Various flags passed to the View::View() constructor.
See also:
os::View, os::Invoker
Author:
Kurt Skauen ([email protected])

DropdownMenu::~DropdownMenu
 


Member Function Documentation

void DropdownMenu::AllAttached void [virtual]
 

Reimplemented from os::View.

void DropdownMenu::AppendItem const char * pzString
 

Parameters:
pzString   - The string to be appended
See also:
InsertItem(), DeleteItem(), GetItemCount(), GetItem()
Author:
Kurt Skauen ([email protected])

void DropdownMenu::Clear
 

Description:
Delete all the items in the menu
Parameters:
nPosition   - The zero based index of the item to delete.
Returns:
true if an item was deleted, false if the index was out of range.
See also:
AppendItem(), InsertItem(), GetItemCount(), GetItem()
Author:
Kurt Skauen ([email protected])

bool DropdownMenu::DeleteItem int nPosition
 

Description:
Delete the item at the given position
Parameters:
nPosition   - The zero based index of the item to delete.
Returns:
true if an item was deleted, false if the index was out of range.
See also:
AppendItem(), InsertItem(), GetItemCount(), GetItem()
Author:
Kurt Skauen ([email protected])

void DropdownMenu::FrameSized const Point & cDelta [virtual]
 

Description:
Overload this member if you need to know when the view is resized.
Note:
This member is called after the view is resized. If you need the old size you can subtract the cDelta calue from the current size.
Parameters:
cDelta   The distance the bottom/right corner was moved relative to the upper/left corner.
See also:
FrameMoved(), SetFrame, ResizeBy(), ResizeTo()
Author:
Kurt Skauen ([email protected])

Reimplemented from os::View.

const std::string & DropdownMenu::GetCurrentString const
 

Message * DropdownMenu::GetEditMessage const
 

Description:
Return the pointer last set by SetEditMessage() or NULL if no message is assigned. If you change the message the changes will be reflected in the following events sendt when the edit box is changed.
Note:
The message is still owned by the DropdownMenu. You should not delete is
Returns:
Pointer to the internel "string-changed" message.
See also:
SetSelectionMessage(), Invoker::SetTarget()
Author:
Kurt Skauen ([email protected])

const std::string & DropdownMenu::GetItem int nItem const
 

Description:
Returns one of the items encapsulated in a stl string.
Parameters:
nItem   - Zero based index of the item to return.
Returns:
const reference to an stl string containing the item string
See also:
GetItemCount(), AppendItem(), InsertItem(), DeleteItem()
Author:
Kurt Skauen ([email protected])

int DropdownMenu::GetItemCount const
 

Returns:
The number of items in the menu
See also:
GetItem(), AppendItem(), InsertItem(), DeleteItem()
Author:
Kurt Skauen ([email protected])

int DropdownMenu::GetMaxPreferredSize const
 

int DropdownMenu::GetMinPreferredSize const
 

Point DropdownMenu::GetPreferredSize bool bLargest const [virtual]
 

Reimplemented from os::View.

bool DropdownMenu::GetReadOnly const
 

Returns:
true if read only, false if read/write.
See also:
SetReadOnly()
Author:
Kurt Skauen ([email protected])

int DropdownMenu::GetSelection const
 

Returns:
The index of the selected item, or -1 if no item is selected.
See also:
SetSelection(), SetSelectionMessage()
Author:
Kurt Skauen ([email protected])

Message * DropdownMenu::GetSelectionMessage const
 

Description:
Return the pointer last set by SetSelectionMessage() or NULL if no message is assigned. If you change the message the changes will be reflected in the following "SelectionChanged" events.
Note:
The message is still owned by the DropdownMenu. You should not delete it.
Returns:
Pointer to the internel "SelectionChanged" message.
See also:
SetSelectionMessage(), Invoker::SetTarget()
Author:
Kurt Skauen ([email protected])

bool DropdownMenu::GetSendIntermediateMsg const
 

void DropdownMenu::HandleMessage Message * pcMessage [virtual]
 

Description:
DropdownMenu overloads Handler::HandleMessage() to be able to comunicate with it's sub components.
See also:
Handler::HandleMessage()
Author:
Kurt Skauen ([email protected])

Reimplemented from os::Handler.

void DropdownMenu::InsertItem int nPosition,
const char * pzString
 

\Description: The new item is inserted before the nPosition'th item.

Parameters:
nPosition   - Zero based index of the item to insert the string in front of
pzString   - The string to be insert
See also:
AppendItem(), DeleteItem(), GetItemCount(), GetItem()
Author:
Kurt Skauen ([email protected])

bool DropdownMenu::IsEnabled const
 

void DropdownMenu::KeyDown const char * pzString,
const char * pzRawString,
uint32 nQualifiers
[virtual]
 

Description:
Overload this member if your view need to handle keyboard input. This member is called to allow the view to handle M_KEY_DOWN messages. The most common members are exctracted from the message and passed as parameters but you might need to obtain the raw message with os::Looper::GetCurrentMessage() and find some members yourself if you the data you needed are not passed in.

For example if you need the raw key-code for the pressed key you will have to lookup the "_raw_key" member from the message.

Parameters:
pzString   String containing a single UTF-8 encoded character. This is the character generated by the pressed key according to the current keymap accounting for any qualifiers that might be pressed.
pzRawString   Same as pzString except that the key is converted without accounting for qualifiers. Ie. if 'A' is pressed while pressing <SHIFT> pzString will contain 'A' and pzRawString will contain 'a'.
nQualifiers   Bitmask describing which qualifiers that was active when the key was pressed.

See also:
KeyUp(), os::Looper::GetCurrentMessage()
Author:
Kurt Skauen ([email protected])

Reimplemented from os::View.

void DropdownMenu::MouseDown const Point & cPosition,
uint32 nButton
[virtual]
 

Description:
This member is called from the window thread whenever a mouse button is clicked above the view. You can overload this member if your view need to know about mouse-down events.

A view will not automatically take focus when clicked so if you want that behaviour you must call MakeFocus() from an overloaded version of this member.

The default implementation of this member will call MouseDown() on it's parent view if one exists.

Parameters:
cPosition   Mouse position in the views coordinate system at the time the mouse was pressed.
nButtons   Index of the pressed button. Buttons start at 1 for the left button, 2 for the right button, 3 for the middle button. Additional buttons might be supported by the mouse driver and will then be assigned numbers from 4 and up.

See also:
MouseUp(), MouseMove(), WheelMoved()
Author:
Kurt Skauen ([email protected])

Reimplemented from os::View.

void DropdownMenu::Paint const Rect & cUpdateRect [virtual]
 

Description:
Note:
Warning:
Parameters:
cUpdateRect   A rectangle enclosing all damaged areas. This is just a rough "worst-case", further fine-grained clipping will be performed by the Application Server to avoid updating non-damaged pixels and make the update as fast and flicker-free as possible.

See also:
Invalidate(), Flush()
Author:
Kurt Skauen ([email protected])

Reimplemented from os::View.

void DropdownMenu::SetCurrentString const std::string & cString
 

void DropdownMenu::SetEditMessage Message * pcMsg
 

Description:
The message is sendt everytime the user changes the content of the edit box. Before the message is sendt a boolean member called "final" is added. This member is false when the user is typing into the edit box, and true for the last message sendt when the user hits <ENTER>.

The content of the edit box is not automatically copyed into the item-list. If you f.eks. want to add a new entry to the item list each time the user change the string and hits <ENTER>, you must listen to this message and read out the string with GetCurrentString() and add it to the list with AppendItem() or InsertItem() each time you receive a message with the "final" member equal "true".
Note:
The DropdownMenu overtake the ownership of the message. You should not delete or reference the message after SetSelectionMessage() returns.
Parameters:
pcMsg   - The message to be sendt when the edit box changes.
See also:
GetEditMessage(), SetSelectionMessage(), Invoker::SetTarget(), Invoker::Invoke()
Author:
Kurt Skauen ([email protected])

void DropdownMenu::SetEnable bool bEnable = true
 

void DropdownMenu::SetMaxPreferredSize int nWidthChars
 

void DropdownMenu::SetMinPreferredSize int nWidthChars
 

void DropdownMenu::SetReadOnly bool bFlag = true
 

Description:
When the DropdownMenu is set in read-only mode the user will not be able to edit the contents of the edit box. It will also make the menu open when the user click inside the edit box.
Parameters:
bFlag   - Is true the menu will be read-only, if false it will be read/write.
See also:
GetReadOnly()
Author:
Kurt Skauen ([email protected])

void DropdownMenu::SetSelection int nItem,
bool bNotify = true
 

Description:
The given item will be highlighted when the menu is opened and the item will be copyed into the edit box. If the bNotify parameter is true and the selection differs from the currend the "SelectionMessage" (see SetSelectionMessage()) will be sendt to the target set by SetTarget().
Parameters:
nItem   - The new selection
bNotify   - If true a notification will be sendt if the new selection differ from the current.
See also:
GetSelection(), SetSelectionMessage(), GetSelectionMessage(), Invoker::SetTarget()
Author:
Kurt Skauen ([email protected])

void DropdownMenu::SetSelectionMessage Message * pcMsg
 

Description:
When the selection is changed eighter by the user or by calling SetSelection() with bNotify = true, the DropdownMenu() will clone off the message set with SetSelectionMessage() and send it to it's target by calling Invoker::Invoke().

Before sending the message the two fields "final" and "selection" are added. "final" is a boolean that is true when the user select (click's on) an item from the menu, or if the event was triggered by SetSelection(). "final" is false when the event was triggered by the user moving the mouse over the menu. "selection" is an int32 that contain the new selection.

In addition to those fields comes the fields added by Invoker::Invoke().

If pcMsg is NULL no event will be triggered by changing the selection.

Note:
The DropdownMenu overtake the ownership of the message. You should not delete or reference the message after SetSelectionMessage() returns.
Parameters:
pcMsg   - The message to be sendt when selection changes.
See also:
GetSelectionMessage(), SetEditMessage(), Invoker::SetTarget()
Author:
Kurt Skauen ([email protected])

void DropdownMenu::SetSendIntermediateMsg bool bFlag
 


Friends And Related Function Documentation

friend class DropdownView [friend]
 


Generated at Tue Sep 11 15:27:46 2001 for AtheOS higlevel API by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001