Virtual U.org
Get Personal Training on VU Today
    
Top shadow
 
 register/help
User Name:

Password:

Button class Reference
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Button Class Reference

UI class for drawing buttons. More...

#include <Obutton.h>

List of all members.

Public Types

enum  { STR_BUF_LEN = 40, HELP_CODE_LEN = 8 }

Public Methods

 Button ()
 ~Button ()
void deinit ()
void use_texture ()
void reset ()
void set_font (Font *)
void set_key (unsigned keyCode)
void create (int, int, int, int, int, void *, char=1, char=0)
void set_body (void *)
void set_help_code (char *helpCode)
void create_text (int x1, int y1, int x2, int y2, char *textPtr, char elastic=1, char defIsPushed=0)
void paint_text (int x1, int y1, int x2, int y2, char *textPtr, char elastic=1, char defIsPushed=0)
void create_text (int x1, int y1, char *textPtr, char elastic=1, char defIsPushed=0)
void paint_text (int x1, int y1, char *textPtr, char elastic=1, char defIsPushed=0)
void create_bitmap (int x1, int y1, int x2, int y2, char *iconPtr, char elastic=1, char defIsPushed=0)
void paint_bitmap (int x1, int y1, int x2, int y2, char *iconPtr, char elastic=1, char defIsPushed=0)
void create_bitmapW (int x1, int y1, int x2, int y2, short *iconPtr, char elastic=1, char defIsPushed=0)
void paint_bitmapW (int x1, int y1, int x2, int y2, short *iconPtr, char elastic=1, char defIsPushed=0)
void create_udf (int x1, int y1, int x2, int y2, ButtonFP funcPtr, char elastic=1, char defIsPushed=0)
void paint_udf (int x1, int y1, int x2, int y2, ButtonFP funcPtr, char elastic=1, char defIsPushed=0)
void paint (int=-1, int=1)
int detect (unsigned=0, unsigned=0, int=0, int=0)
void hide (char)
void show ()
void push ()
void pop ()
void disable ()
void enable ()
void wait_press (int inactiveTimeOut=0)

Public Attributes

char is_pushed
char enable_flag
short x1
short y1
short x2
short y2
char init_flag
char button_type
char use_texture_flag
unsigned short button_key
char is_showing
char str_buf [STR_BUF_LEN+1]
void * body_ptr
char elastic
Fontfont_ptr
short * button_bk_bitmap
short * button_up_bitmap
short * button_dn_bitmap
char help_code [HELP_CODE_LEN+1]


Detailed Description

UI class for drawing buttons.

Definition at line 29 of file Obutton.h.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
STR_BUF_LEN 
HELP_CODE_LEN 

Definition at line 31 of file Obutton.h.


Constructor & Destructor Documentation

Button::Button  
 

Definition at line 18 of file Obutton.cpp.

References NULL.

Button::~Button  
 

Definition at line 55 of file Obutton.cpp.

References deinit().


Member Function Documentation

void Button::create int    buttonType,
int    pX1,
int    pY1,
int    pX2,
int    pY2,
void *    bodyPtr,
char    pElastic = 1,
char    defIsPushed = 0
 

Syntax : create(<int>,<int>,<int>,<int>,<int>,<int>,<char>)

<int> buttonType = BUTTON_TEXT (1) - text button, BUTTON_BITMAP (2) - icon button <int> x1, y1 = coordination of the button <int> x2, y2 = coordination of the button <void*> bodyPtr = text or icon pointer or pointer to user defined function, depended on the type of the button allow NULL icon pointer, which no icon will be displayed [int] elastic = Whether the button is elastic Elastic button will pop up immediately when button release Non-elastic button will remain pushed until pop() is called (default : 1)

[int] defIsPushed = default is_pushed : 1-Pushed, 0-Non-pushed (default : 0)

Note : it use the color setting in (vga) and (font_san)

Definition at line 168 of file Obutton.cpp.

References Vga::active_buf, BUTTON_TEXT, and NULL.

Referenced by create_bitmap(), create_bitmapW(), create_text(), create_udf(), paint_bitmap(), paint_bitmapW(), paint_text(), and paint_udf().

void Button::create_bitmap int    x1,
int    y1,
int    x2,
int    y2,
char *    iconPtr,
char    elastic = 1,
char    defIsPushed = 0
[inline]
 

Definition at line 80 of file Obutton.h.

References BUTTON_BITMAP, create(), elastic, x1, x2, y1, and y2.

void Button::create_bitmapW int    x1,
int    y1,
int    x2,
int    y2,
short *    iconPtr,
char    elastic = 1,
char    defIsPushed = 0
[inline]
 

Definition at line 87 of file Obutton.h.

References BUTTON_BITMAPW, create(), elastic, x1, x2, y1, and y2.

void Button::create_text int    pX1,
int    pY1,
char *    textPtr,
char    pElastic = 1,
char    defIsPushed = 0
 

Given only the top left position of the button, it will calculate the width and height of the button based on the given text and current button font.

Syntax : create(<int>,<int>,<int>,<int>,<int>,<int>,<char>)

<int> x1, y1 = coordination of the button <char*> textPtr = text pointer, depended on the type of the button

[int] elastic = Whether the button is elastic Elastic button will pop up immediately when button release Non-elastic button will remain pushed until pop() is called (default : 1)

[int] defIsPushed = default is_pushed : 1-Pushed, 0-Non-pushed (default : 0)

Definition at line 104 of file Obutton.cpp.

References BUTTON_TEXT.

void Button::create_text int    x1,
int    y1,
int    x2,
int    y2,
char *    textPtr,
char    elastic = 1,
char    defIsPushed = 0
[inline]
 

Definition at line 68 of file Obutton.h.

References BUTTON_TEXT, create(), elastic, x1, x2, y1, and y2.

Referenced by BlackBoard::black_log_report(), Letter::eval_letter_report(), GameSetting::new_game_report(), GameSetting::play_scenario_report(), Finance::report_paint_button(), Optimization::report_stage_1(), Optimization::report_stage_2(), Letter::scen_welcome_letter_report(), Sys::setting_report(), FacultyRes::summary_report_5(), and Letter::welcome_letter_report().

void Button::create_udf int    x1,
int    y1,
int    x2,
int    y2,
ButtonFP    funcPtr,
char    elastic = 1,
char    defIsPushed = 0
[inline]
 

Definition at line 96 of file Obutton.h.

References BUTTON_UDF, ButtonFP, create(), elastic, x1, x2, y1, and y2.

void Button::deinit  
 

Definition at line 40 of file Obutton.cpp.

References mem_del, and NULL.

Referenced by ButtonGroup::deinit_buttons(), free_button_memory(), Finance::report_deinit(), Sys::setting_report_deinit(), FacultyRes::summary_report_deinit(), and ~Button().

int Button::detect unsigned    keyCode1 = 0,
unsigned    keyCode2 = 0,
int    detectRight = 0,
int    suspendPop = 0
 

Detect whether the button has been pressed, if so, act correspondly. Check for left mouse button only

[unsigned] keyCode1 = if the specified key is pressed, emulate button pressed (default : 0)

[unsigned] keyCode2 = if the specified key is pressed, emulate button pressed (default : 0)

[int] detectRight = whether also detect the right button or not (default : 0)

[int] suspendPop = don't pop up the button even it should (defalut : 0)

Return : 1 - if left mouse button pressed 2 - if right mouse button pressed 3 - the key is pressed (only when keyCode is specified) 0 - if not

Definition at line 406 of file Obutton.cpp.

References LEFT_BUTTON, and RIGHT_BUTTON.

Referenced by BlackBoard::black_log_detect(), Letter::eval_letter_detect(), Finance::report_detect(), Letter::scen_welcome_letter_detect(), Sys::setting_report_detect(), and Letter::welcome_letter_detect().

void Button::disable   [inline]
 

Definition at line 114 of file Obutton.h.

References enable_flag, and paint().

Referenced by Letter::eval_letter_report(), and Letter::welcome_letter_report().

void Button::enable   [inline]
 

Definition at line 119 of file Obutton.h.

References enable_flag, and paint().

void Button::hide char    backColor
 

Hide and disable the button

Syntax : hide(char)

<char> backColor = background color

Definition at line 241 of file Obutton.cpp.

References Vga::active_buf.

void Button::paint int    defIsPushed = -1,
int    repaintBody = 1
 

[int] defIsPushed = default is_pushed : 1-Pushed, 0-Non-pushed (default : is_pushed)

[int] repaintBody = repaint the button body or only repaint panel sides (default : 1), 0 when called by detect()

Definition at line 275 of file Obutton.cpp.

References Vga::active_buf, and V_WHITE.

Referenced by BlackBoard::black_log_report(), disable(), enable(), Letter::eval_letter_report(), GameSetting::new_game_report(), paint_bitmap(), paint_bitmapW(), paint_text(), paint_udf(), GameSetting::play_scenario_report(), pop(), push(), Finance::report_paint_button(), Sys::setting_report(), FacultyRes::summary_report_5(), and Letter::welcome_letter_report().

void Button::paint_bitmap int    x1,
int    y1,
int    x2,
int    y2,
char *    iconPtr,
char    elastic = 1,
char    defIsPushed = 0
[inline]
 

Definition at line 83 of file Obutton.h.

References BUTTON_BITMAP, create(), elastic, paint(), x1, x2, y1, and y2.

void Button::paint_bitmapW int    x1,
int    y1,
int    x2,
int    y2,
short *    iconPtr,
char    elastic = 1,
char    defIsPushed = 0
[inline]
 

Definition at line 90 of file Obutton.h.

References BUTTON_BITMAPW, create(), elastic, paint(), x1, x2, y1, and y2.

void Button::paint_text int    pX1,
int    pY1,
char *    textPtr,
char    pElastic = 1,
char    defIsPushed = 0
 

Given only the top left position of the button, it will calculate the width and height of the button based on the given text and current button font.

Syntax : create(<int>,<int>,<int>,<int>,<int>,<int>,<char>)

<int> x1, y1 = coordination of the button <char*> textPtr = text pointer, depended on the type of the button

[int] elastic = Whether the button is elastic Elastic button will pop up immediately when button release Non-elastic button will remain pushed until pop() is called (default : 1)

[int] defIsPushed = default is_pushed : 1-Pushed, 0-Non-pushed (default : 0)

Note : it use the color setting in (vga) and (font_san)

Definition at line 136 of file Obutton.cpp.

References BUTTON_TEXT.

void Button::paint_text int    x1,
int    y1,
int    x2,
int    y2,
char *    textPtr,
char    elastic = 1,
char    defIsPushed = 0
[inline]
 

Definition at line 71 of file Obutton.h.

References BUTTON_TEXT, create(), elastic, paint(), x1, x2, y1, and y2.

void Button::paint_udf int    x1,
int    y1,
int    x2,
int    y2,
ButtonFP    funcPtr,
char    elastic = 1,
char    defIsPushed = 0
[inline]
 

Definition at line 99 of file Obutton.h.

References BUTTON_UDF, ButtonFP, create(), elastic, paint(), x1, x2, y1, and y2.

void Button::pop   [inline]
 

Definition at line 112 of file Obutton.h.

References paint().

Referenced by Sys::setting_report(), and Sys::setting_report_detect().

void Button::push   [inline]
 

Definition at line 111 of file Obutton.h.

References is_pushed, and paint().

Referenced by Sys::setting_report(), and Sys::setting_report_detect().

void Button::reset   [inline]
 

Definition at line 59 of file Obutton.h.

References init_flag.

void Button::set_body void *    bodyPtr
 

<void*> bodyPtr = text or icon pointer or pointer to user defined function,

Definition at line 217 of file Obutton.cpp.

References BUTTON_TEXT, and NULL.

void Button::set_font Font   fontPtr
 

Set the font of the button, if not set, default use font_san.

<Font*> fontPtr = pointer to the font

Definition at line 77 of file Obutton.cpp.

void Button::set_help_code char *    helpCode
 

Definition at line 63 of file Obutton.cpp.

References NULL.

void Button::set_key unsigned    keyCode [inline]
 

Definition at line 61 of file Obutton.h.

References button_key.

void Button::show  
 

Show a button hiden by hide().

Definition at line 258 of file Obutton.cpp.

void Button::use_texture   [inline]
 

Definition at line 57 of file Obutton.h.

References use_texture_flag.

void Button::wait_press int    timeOut = 0
 

Wait for user to press the button

[int] timeOut - 1=enable inactive timeout 0=disable inactive timeout (default : 1 )

Definition at line 498 of file Obutton.cpp.

References KEY_ESC, and KEY_RETURN.


Member Data Documentation

void* Button::body_ptr
 

Definition at line 44 of file Obutton.h.

short* Button::button_bk_bitmap
 

Definition at line 47 of file Obutton.h.

short* Button::button_dn_bitmap
 

Definition at line 49 of file Obutton.h.

unsigned short Button::button_key
 

Definition at line 40 of file Obutton.h.

Referenced by set_key().

char Button::button_type
 

Definition at line 38 of file Obutton.h.

short* Button::button_up_bitmap
 

Definition at line 48 of file Obutton.h.

char Button::elastic
 

Definition at line 45 of file Obutton.h.

Referenced by create_bitmap(), create_bitmapW(), create_text(), create_udf(), paint_bitmap(), paint_bitmapW(), paint_text(), and paint_udf().

char Button::enable_flag
 

Definition at line 34 of file Obutton.h.

Referenced by disable(), and enable().

Font* Button::font_ptr
 

Definition at line 46 of file Obutton.h.

char Button::help_code[HELP_CODE_LEN+1]
 

Definition at line 50 of file Obutton.h.

char Button::init_flag
 

Definition at line 37 of file Obutton.h.

Referenced by reset().

char Button::is_pushed
 

Definition at line 33 of file Obutton.h.

Referenced by push().

char Button::is_showing
 

Definition at line 41 of file Obutton.h.

char Button::str_buf[STR_BUF_LEN+1]
 

Definition at line 43 of file Obutton.h.

char Button::use_texture_flag
 

Definition at line 39 of file Obutton.h.

Referenced by use_texture().

short Button::x1
 

Definition at line 35 of file Obutton.h.

Referenced by create_bitmap(), create_bitmapW(), create_text(), create_udf(), paint_bitmap(), paint_bitmapW(), paint_text(), and paint_udf().

short Button::x2
 

Definition at line 35 of file Obutton.h.

Referenced by create_bitmap(), create_bitmapW(), create_text(), create_udf(), paint_bitmap(), paint_bitmapW(), paint_text(), and paint_udf().

short Button::y1
 

Definition at line 35 of file Obutton.h.

Referenced by create_bitmap(), create_bitmapW(), create_text(), create_udf(), paint_bitmap(), paint_bitmapW(), paint_text(), and paint_udf().

short Button::y2
 

Definition at line 35 of file Obutton.h.

Referenced by create_bitmap(), create_bitmapW(), create_text(), create_udf(), paint_bitmap(), paint_bitmapW(), paint_text(), and paint_udf().


The documentation for this class was generated from the following files:
Generated on Fri Aug 23 01:39:02 2002 for VirtualU by doxygen1.2.17