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

Password:

OBAR.CPP Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

OBAR.CPP

Go to the documentation of this file.
00001 // OBar.cpp: implementation of the Bar class.
00002 //
00004 // kevin 0718
00005 
00006 #include <ALL.H>
00007 #include <OINFO.H>
00008 #include <OVGA.H>
00009 #include <OSYS.H>
00010 #include <OFONT.H>
00011 #include <OIFACE.H>
00012 #include <OMOUSE.H>
00013 #include <ORADIO.H>
00014 #include "OBar.h"
00015 
00016 //-------------- Define static vars ------------//
00017 
00018 static char paint_flag = 0;
00019 
00021 // Construction/Destruction
00023 
00024 Bar::Bar() {
00025 
00026 }
00027 
00028 //------------- End of function Bar::Bar ------------//
00029 
00030 Bar::~Bar() {
00031     deinit();
00032 }
00033 
00034 //------------- End of function Bar::~Bar ------------//
00035 
00036 //-------- Begin of function Bar::init --------//
00042 
00043 void Bar::init( int x1, int y1, int x2, int y2, int barColor) {
00044     font_ptr = &font_chartsm;
00045     bar_x1 = x1;
00046     bar_y1 = (y1 + y2 - font_ptr->font_height) / 2;
00047     bar_x2 = x2;
00048     bar_y2 = (y1 + y2 + font_ptr->font_height) / 2;
00049     bar_width =  x2 - x1;
00050     bar_height = y2 - y1;
00051     bar_color=barColor;
00052     bar_bitmap=NULL;
00053 
00054     init_flag = 1;
00055 }
00056 
00057 //------------- End of function Bar::init ------------//
00058 
00060 //
00061 void Bar::deinit() {
00062 
00063     if (init_flag)
00064         if (bar_bitmap) {
00065             mem_del(bar_bitmap);
00066             bar_bitmap = NULL;
00067         }
00068     init_flag = 0;
00069 }
00070 
00071 //------------- End of function Bar::deinit ------------//
00072 
00074 //
00075 void Bar::paint(void) {
00076     // save area
00077     bar_bitmap=vga_back.save_area(bar_x1,bar_y1,bar_x2,bar_y2+2,bar_bitmap);
00078     // refresh
00079     paint_flag = 1;
00080     refresh();
00081 }
00082 
00083 //------------- End of function Bar::paint ------------//
00084 
00086 //
00087 void Bar::refresh(void) {
00088     vga_back.rest_area(bar_bitmap, 0, 0);
00089     user_interface.bar(bar_x1,bar_y1,bar_x2,bar_y2);
00090     if (!paint_flag)
00091         vga.blt_buf(bar_x1, bar_y1, bar_x2, bar_y2+2);
00092     else
00093         paint_flag = 0;
00094 }
00095 
00096 //------------- End of function Bar::refresh ------------//
00097 
00099 //
00100 // Return: 1-pressed on button, variable updated
00101 //                        0-not pressed on button
00102 //
00103 int Bar::detect() {
00104     if (!init_flag)
00105         return 0;
00106 
00107     //---- Variable update? ----//
00108 
00109     if (mouse.single_click( bar_x1, bar_y1, bar_x2, bar_y2 )) {
00110         return 1;
00111     }
00112 
00113     return 0;
00114 }
00115 
00116 //------------- End of function Bar::detect ------------//

Generated on Fri Aug 23 01:37:14 2002 for VirtualU by doxygen1.2.17