• Main Page
  • Related Pages
  • Classes
  • Files
  • File List
  • File Members

win_base.cc

00001 /* 
00002    $Id: win_base.cc,v 1.4 2004/10/25 06:55:01 ksterker Exp $ 
00003 
00004    (C) Copyright 2000, 2001 Joel Vennin
00005    Part of the Adonthell Project http://adonthell.linuxgames.com
00006    
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011    
00012    See the COPYING file for more details
00013 */
00014 
00015 
00016 #include "win_base.h"
00017 #include "win_manager.h"
00018 #include "win_container.h"
00019 
00020 win_base::win_base(): win_border(this),win_background(this)
00021 {
00022   manager_ = NULL;
00023   
00024   wb_father_= NULL;
00025   
00026   pad_y_ = pad_x_ = 0;
00027   
00028   move(0,0);
00029   
00030   set_visible(false);
00031 
00032   set_focus(false);
00033 
00034   set_activate(false);
00035   
00036   set_brightness(false);
00037   
00038   set_trans(false);
00039 
00040   set_can_be_selected(true);
00041 
00042   set_align(ALIGN_NONE);
00043 }
00044 
00045 win_base::~win_base()
00046 {
00047     if (manager_) manager_->remove (this);
00048     manager_ = NULL;
00049 }
00050 
00051 void win_base::set_container(win_container * wc)
00052 {
00053   wb_father_=wc;
00054   
00055   update_position();
00056   
00057   update_align();
00058 }
00059 
00060 void win_base::update_position()
00061 {
00062   
00063   if(wb_father_) {
00064     drawing_area::move(wb_father_->real_x() + x() + pad_x(), wb_father_->real_y() + y() + pad_y() );
00065   }
00066   else {
00067     drawing_area::move( x() + pad_x(), y() + pad_y() );        
00068   }
00069 }
00070 
00071 void win_base::move(s_int16 tx, s_int16 ty)
00072 {
00073   
00074   x_= tx;
00075   
00076   y_= ty;
00077   
00078   update_position();
00079 }
00080 
00081 void win_base::resize(u_int16 tl, u_int16 th)
00082 {
00083   drawing_area::resize(tl, th);
00084   
00085   win_border::update();
00086   
00087   win_background::update();
00088 }
00089 
00090 bool win_base::update()
00091 {
00092     if(win_event::update())
00093     {
00094       // if(focus_) ADDME: ajouter l'appel a update_input 
00095       on_update();
00096       
00097       return true;
00098     }
00099   return false;
00100 }
00101 
00102 bool win_base::input_update()
00103 {
00104   return (focus_ && activate_);
00105 }
00106 
00107 bool win_base::draw()
00108 {
00109   on_draw();
00110   
00111   if(visible_) on_draw_visible();
00112   
00113   return visible_;
00114 }
00115 
00116 
00117 
00118 void win_base::update_align()
00119 { 
00120   switch(align_)
00121     {
00122     case ALIGN_LEFT:
00123       move((wb_father_) ? ((win_container*)wb_father_)->space_with_border() : 0 , y() );
00124       break;
00125     case ALIGN_RIGHT:
00126       move(((wb_father_) ? wb_father_->length() : screen::length())-((wb_father_)?((win_container*)wb_father_)->space_with_border() : 0 ) - length() , y() );
00127       break;
00128     case ALIGN_CENTER:
00129       if(((wb_father_)?wb_father_->length():screen::length())>length()) 
00130     move((((wb_father_)?wb_father_->length():screen::length()) - length()) >>1,y());
00131       break;
00132     }
00133 }
00134 
00135 void win_base::set_manager (win_manager *m)
00136 {
00137     manager_ = m;
00138 }
00139 

Generated on Fri Mar 18 2011 for Adonthell by  doxygen 1.7.1