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

NDK_XX::Button Class Reference

#include <ndk++.h>

Inheritance diagram for NDK_XX::Button:

NDK_XX::Label NDK_XX::Control NDK_XX::ListItem NDK_XX::PushButton NDK_XX::Tab NDK_XX::CheckButton NDK_XX::MenuItem NDK_XX::RadioButton NDK_XX::PropDlgPushButton List of all members.

Public Methods

 Button (Control *parent, int id, const string &title,int lines, int cols, int y, int x,int style=tabstop|notify)
void activate ()
 Draw as active (i.e.,with bold frame).

void deactivate ()
 Draw as inactive (i.e.,with normal frame).

virtual int action ()=0
 action fired when user presses Enter

void set_default (bool t_or_f=true)
 Set this button as the default choice.

bool is_default () const

Protected Methods

int driver (int key)

Protected Attributes

bool default_choice

Constructor & Destructor Documentation

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

Button Constructor See parameters for class Control

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

00341         :Label(parent,id,title,lines,cols,y,x,style)
00342 {
00343 }


Member Function Documentation

virtual int NDK_XX::Button::action   [pure virtual]
 

action fired when user presses Enter

Implemented in NDK_XX::PushButton, NDK_XX::ListItem, and NDK_XX::Tab.

Referenced by driver().

void NDK_XX::Button::activate   [virtual]
 

Draw as active (i.e.,with bold frame).

Reimplemented from NDK_XX::Label.

Reimplemented in NDK_XX::Tab.

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

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

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

00379 {
00380     Control::activate();
00381     attron(A_BOLD);
00382     set_text(text);
00383     refresh();
00384     
00385 }

void NDK_XX::Button::deactivate   [virtual]
 

Draw as inactive (i.e.,with normal frame).

Reimplemented from NDK_XX::Label.

Reimplemented in NDK_XX::Tab.

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

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

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

00390 {
00391     Control::deactivate();
00392     attroff(A_BOLD);
00393     set_text(text);
00394 }

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

get a chance at processing the key, before parent does

Reimplemented from NDK_XX::Control.

Reimplemented in NDK_XX::PropDlgPushButton, NDK_XX::ListItem, NDK_XX::MenuItem, and NDK_XX::Tab.

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

References action(), NDK_XX::Control::clicked_inside(), and KEY_ENTER.

00348 {
00349     int result= FALSE;
00350     switch(key) {
00351         case KEY_ENTER: result = action();  break;
00352 #ifdef NCURSES_MOUSE_VERSION
00353         case KEY_MOUSE:
00354         {
00355             MEVENT  event;
00356             getmouse(&event);
00357             int ry = event.y, rx = event.x; /* screen coordinates */
00358             if (mouse_trafo(&ry,&rx,FALSE)){
00359                 if((event.bstate & (    BUTTON1_CLICKED|
00360                                     BUTTON1_DOUBLE_CLICKED|
00361                                     BUTTON1_TRIPLE_CLICKED))
00362                     && clicked_inside(ry, rx)){
00363                     // we react only if the click was in the userwin, that means
00364                     // inside the menu display area or at the decoration window.
00365                     result=action();
00366                 }
00367             }
00368             break;
00369         }
00370 #endif
00371         default:    result = Label::driver(key); break;
00372     }
00373     return result;
00374 }

bool NDK_XX::Button::is_default   const [inline]
 

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

References NDK_XX::ListItemData::ctrl_id, NDK_XX::ListItemData::field_state, NDK_XX::ListItemData::field_style, NDK_XX::ListItemData::text, and NDK_XX::ListItemData::user_data.

Referenced by NDK_XX::ListItemData::operator=().

00696 :text(txt),ctrl_id(id),field_style(style)

void NDK_XX::Button::set_default bool    t_or_f = true [inline]
 

Set this button as the default choice.

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

Referenced by NDK_XX::ListItem::operator=().


Member Data Documentation

bool NDK_XX::Button::default_choice [protected]
 

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

Referenced by NDK_XX::Edit::refresh_text().


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