Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

NDK_XX::ListItem Class Reference

#include <ndk++.h>

Inheritance diagram for NDK_XX::ListItem:

NDK_XX::Button NDK_XX::Label NDK_XX::Control NDK_XX::CheckButton NDK_XX::MenuItem NDK_XX::RadioButton List of all members.

Public Methods

 ListItem (Control *parent, int id, const string &title,int lines, int cols, int y, int x, int style=tabstop|notify)
void set_text (const string &txt)
 Usualy, a control in a dialog has some kind of text on it...

void set_check (bool new_state=true)
 set/unset check mark

bool is_checked () const
 is this item selected?

void set_user_data (void *data)
void * get_user_data () const
ListItem & operator= (const ListItemData &lha)

Protected Methods

int driver (int key)
virtual void show_state (bool ref=false)
 specialized on children

void refresh_text ()
 Update the text we present on the viewport.

virtual int state_size () const
 specialized on children

int action ()
 Hidden from public use.


Protected Attributes

void * user_data

Friends

class ListBox

Constructor & Destructor Documentation

NDK_XX::ListItem::ListItem Control   parent,
int    id,
const string &    title,
int    lines,
int    cols,
int    y,
int    x,
int    style = tabstop|notify
 

ListItem Constructor See parameters for class Control

Definition at line 495 of file ndk++.cc.

00499         :Button(parent,id, title,lines,cols,y,x,style),user_data(0)
00500 {
00501 }


Member Function Documentation

int NDK_XX::ListItem::action   [inline, protected, virtual]
 

Hidden from public use.

Implements NDK_XX::Button.

Definition at line 914 of file ndk++.h.

00918 : public ListItem

int NDK_XX::ListItem::driver int    key [protected, virtual]
 

get a chance at processing the key, before parent does

Reimplemented from NDK_XX::Button.

Reimplemented in NDK_XX::MenuItem.

Definition at line 505 of file ndk++.cc.

References is_checked(), and set_check().

Referenced by NDK_XX::ListBox::driver().

00506 {
00507     int result= FALSE;
00508     switch(key) {
00509         case ' ':
00510             set_check(!is_checked());
00511             result=TRUE;
00512             break;
00513 #ifdef NCURSES_MOUSE_VERSION
00514         case KEY_MOUSE:
00515         {
00516             MEVENT  event;
00517             getmouse(&event);
00518             if ((event.bstate & (BUTTON1_CLICKED|BUTTON1_DOUBLE_CLICKED|BUTTON1_TRIPLE_CLICKED))
00519             && wenclose(w,event.y, event.x))
00520             {   // we react only if the click was in the userwin, that means
00521                 // inside the menu display area or at the decoration window.
00522                 set_check(!is_checked());
00523                 result=TRUE;
00524             }
00525         }
00526 #endif /* NCURSES_MOUSE_VERSION */
00527         default:
00528             break;
00529     }
00530     return result;
00531 }

void* NDK_XX::ListItem::get_user_data   const [inline]
 

Definition at line 885 of file ndk++.h.

00885 {return 3;};

bool NDK_XX::ListItem::is_checked   const [inline]
 

is this item selected?

Definition at line 882 of file ndk++.h.

Referenced by driver().

00885 {return 3;};

ListItem & NDK_XX::ListItem::operator= const ListItemData   lha
 

Definition at line 546 of file ndk++.cc.

References NDK_XX::ListItemData::get_ctrl_id(), NDK_XX::ListItemData::get_state(), NDK_XX::ListItemData::get_style(), NDK_XX::ListItemData::get_text(), NDK_XX::ListItemData::get_user_data(), NDK_XX::ListItemData::is_default(), NDK_XX::Control::set_ctrl_id(), NDK_XX::Button::set_default(), NDK_XX::Control::set_states(), NDK_XX::Control::set_styles(), set_text(), set_user_data(), NDK_XX::Control::states, and NDK_XX::Control::styles.

00547 {
00548     set_text(rha.get_text());
00549     set_ctrl_id(rha.get_ctrl_id());
00550     set_styles(styles(rha.get_style()));
00551     set_states(states(rha.get_state()));
00552     set_default(rha.is_default());
00553     set_user_data(rha.get_user_data());
00554     return *this;
00555 }

void NDK_XX::ListItem::refresh_text   [inline, protected, virtual]
 

Update the text we present on the viewport.

Reimplemented from NDK_XX::Label.

Definition at line 904 of file ndk++.h.

Referenced by set_text().

00904         {
00905         }
00906 
00907 protected:
00908     friend class MenuItem;

void NDK_XX::ListItem::set_check bool    new_state = true [inline]
 

set/unset check mark

Definition at line 873 of file ndk++.h.

References NDK_XX::Label::text.

Referenced by driver(), NDK_XX::ListBox::move_down(), NDK_XX::ListBox::move_up(), and NDK_XX::ListBox::set_cur_sel().

00875          :
00876 
00877     void show_state(bool ref=false){
00878         if(!text.empty()){
00879             if(is_checked()) addstr(0,0, "[x]");
            else addstr(0,0, "[ ]");

void NDK_XX::ListItem::set_text const string &    txt [virtual]
 

Usualy, a control in a dialog has some kind of text on it...

Reimplemented from NDK_XX::Label.

Definition at line 535 of file ndk++.cc.

References refresh_text(), and NDK_XX::Label::text.

Referenced by NDK_XX::CheckButton::CheckButton(), NDK_XX::MenuItem::MenuItem(), operator=(), and NDK_XX::RadioButton::RadioButton().

00536 {
00537     string new_text= v; //.substr(0,width()); 
00538     text = new_text;
00539     refresh_text();
00540     move(0,0);
00541     refresh();
00542 }

void NDK_XX::ListItem::set_user_data void *    data [inline]
 

Definition at line 884 of file ndk++.h.

Referenced by operator=().

00885 {return 3;};

virtual void NDK_XX::ListItem::show_state bool    ref = false [inline, protected, virtual]
 

specialized on children

Reimplemented in NDK_XX::RadioButton, and NDK_XX::CheckButton.

Definition at line 895 of file ndk++.h.

References NDK_XX::MenuItemData::pMenuItem.

00895       :
00896     /**
00897         MenuItemData Constructor
00898         See parameters for class ListItemData
00899     */
00900     MenuItemData(const string &txt,int id=-1
00901                         ,int style=Control::tabstop|Control::notify
00902                         ,int state=0,void *data=0)
        :ListItemData(txt,id,style,state,data),pMenuItem(0)

virtual int NDK_XX::ListItem::state_size   const [inline, protected, virtual]
 

specialized on children

Reimplemented in NDK_XX::RadioButton, and NDK_XX::CheckButton.

Definition at line 911 of file ndk++.h.

References NDK_XX::MenuItemData::pMenuItem.

00918 : public ListItem


Friends And Related Function Documentation

friend class ListBox [friend]
 

Definition at line 860 of file ndk++.h.


Member Data Documentation

void* NDK_XX::ListItem::user_data [protected]
 

Definition at line 890 of file ndk++.h.


The documentation for this class was generated from the following files:
Generated on Thu Oct 10 16:02:19 2002 by doxygen1.2.17