adonthell-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Adonthell-commits] CVS: adonthell/src/gui background.cc,NONE,1.1.2.1 ba


From: VENNIN Joel <address@hidden>
Subject: [Adonthell-commits] CVS: adonthell/src/gui background.cc,NONE,1.1.2.1 background.h,NONE,1.1.2.1 base.h,NONE,1.1.2.1 border.cc,1.1.2.2,1.1.2.3 border.h,1.1.2.2,1.1.2.3 event.cc,NONE,1.1.2.1 event.h,NONE,1.1.2.1 image.h,NONE,1.1.2.1 keys.cc,NONE,1.1.2.1 keys.h,NONE,1.1.2.1 object.h,NONE,1.1.2.1 scroll.cc,NONE,1.1.2.1 scroll.h,NONE,1.1.2.1 scrollbar.cc,NONE,1.1.2.1 scrollbar.h,NONE,1.1.2.1 select_list.cc,NONE,1.1.2.1 select_list.h,NONE,1.1.2.1 ttf.cc,NONE,1.1.2.1 ttf.h,NONE,1.1.2.1 types.h,NONE,1.1.2.1 wrappers.h,NONE,1.1.2.1 write.h,NONE,1.1.2.1
Date: Sat, 01 Feb 2003 09:45:36 -0500

Update of /cvsroot/adonthell/adonthell/src/gui
In directory subversions:/tmp/cvs-serv30631/src/gui

Added Files:
      Tag: Branch_road_to_0-4
        background.cc background.h base.h border.cc border.h event.cc 
        event.h image.h keys.cc keys.h object.h scroll.cc scroll.h 
        scrollbar.cc scrollbar.h select_list.cc select_list.h ttf.cc 
        ttf.h types.h wrappers.h write.h 
Log Message:
Actually added the missing files!

For those who wonder, it's Joel and Alex writing here!



--- NEW FILE ---
/*   
   (C) Copyright 2000 Joel Vennin
   Part of the Adonthell Project http://adonthell.linuxgames.com
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details
*/
#include <string.h>
#include "theme.h"
#include "background.h"
#include "base.h"

#include "../game.h"

using namespace gui;

background::background()
{
  wb_=NULL;

  init();

  set_visible_background(false);
  
  set_brightness_background(false);
  
  set_trans_background(true); 
}


background::background(base * wb)
{
  wb_=wb;

  init();

  set_visible_background(false);
  
  set_brightness_background(false);
  
  set_trans_background(true); 
}


background::background(char *rep)
{
  wb_=NULL;
 
  init();

  set_visible_background(false);
  
  set_brightness_background(false);
  
  set_trans_background(true);
  
  background::load(rep);
  
  refresh();
}


background::background(background & wb)
{
  wb_=NULL;

  init();
  
  set_visible_background(false);
  
  set_brightness_background(false);

  set_trans_background(true);

  *this=wb;
  
  refresh();
}


background::~background()
{
  destroy();
}


void background::destroy()
{
  if(background_template_) delete background_template_;
  if(background_) delete background_;
  if(background_brightness_) delete background_brightness_;
  init();
}


void background::init()
{
  background_template_=NULL;
  background_=NULL;
  background_brightness_=NULL;
  background_draw_=NULL;
}


background & background::operator=(background & wb)
{  
  destroy();
  background_template_=new gfx::image();
  *background_template_=*(wb.background_template_);
  background_=new gfx::image();
  background_->set_mask(false);
  background_brightness_= new gfx::image();
  background_brightness_->set_mask(true);
  
  update();
  
  return *this;
  
}


void background::set_background(background & wb)
{
  *this=wb;
  refresh();
}

void background::set_background(theme & wt)
{
  *this=*(wt.my_background);
  refresh();
}

void background::set_brightness_background(bool b)
{
  brightness_=b;
  refresh();
}

void background::refresh()
{
  background_draw_=(brightness_)? background_brightness_ : background_ ;
}

void background::load(char *rep)
{
  destroy();

  std::string basepath = DIRECTORY;
  basepath += BACKGROUND_DIRECTORY;
  basepath += rep;
  basepath += BACKGROUND_FILE; 

  basepath = game::find_file (basepath);
  
  background_template_=new gfx::image();
  background_template_->load_pnm(basepath.c_str ());//new
  
  background_= new gfx::image();
  background_->set_mask(true);
  
  background_brightness_= new gfx::image();
  background_brightness_->set_mask(true);
}


void background::update()
{
  if(!background_template_) return ;
  
  background_->resize(wb_->length(),wb_->height());
  background_->tile(*background_template_);
  background_brightness_->brightness(*background_,BRIGHTNESS_LEVEL);
}


void background::draw(gfx::drawing_area * da)
{
  if(!visible_ || !background_draw_ || !wb_) return; 
  background_draw_->draw(wb_->real_x(),wb_->real_y(),da);
}


void background::set_trans_background(bool b)
{
  if(!background_template_) return;
  if(b)
    {
      background_->set_alpha(130);
      background_brightness_->set_alpha(130);
    }
  else
    {
      background_->set_alpha(255);
      background_brightness_->set_alpha(255);
    }
}

--- NEW FILE ---
/*
   (C) Copyright 2000 Joel Vennin
   Part of the Adonthell Project http://adonthell.linuxgames.com

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details
*/

#ifndef GUI_BACKGROUND_H_
#define GUI_BACKGROUND_H_

#include "../gfx/image.h"
#include "../gfx/drawing_area.h"
#include "types.h"

namespace gui {

  class theme;
  class base;


  
  class background
    {
    public:
      
      background();
      
      background(base *);
      
      background(background &);
      
      background(char * rep);
      
      ~background();
      
      void load(char *);
      
      void update();
      
      void destroy();
      
      void draw(gfx::drawing_area * da =NULL);
      
      void set_visible_background(bool b){visible_=b;}
      
      void set_background(background &);
      
      void set_background(theme & wt);
      
      void set_brightness_background(bool b);
      
      void set_trans_background(bool b);
      
    private:
      background & operator=(background & wb);
      
      void refresh();
      
      void init();
      
      gfx::image * background_template_;
      
      gfx::image * background_;
      
      gfx::image * background_brightness_;
      
      gfx::image * background_draw_;
      
      base * wb_;
      
      bool visible_;
      
      bool brightness_;
      
      bool trans_;
    };
}

#endif

***** Error reading new file: [Errno 2] No such file or directory: 'base.h'


***** Error reading new file: [Errno 2] No such file or directory: 'event.cc'
***** Error reading new file: [Errno 2] No such file or directory: 'event.h'
***** Error reading new file: [Errno 2] No such file or directory: 'image.h'
--- NEW FILE ---
/*
   (C) Copyright 2000, 2001 Joel Vennin
   Part of the Adonthell Project http://adonthell.linuxgames.com

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details
*/

#include "keys.h"

using namespace gui;

SDLKey keys::KEY_ACTIVATE_ENTRY = SDLK_RETURN;

SDLKey keys::KEY_UP = SDLK_PAGEUP;

SDLKey keys::KEY_DOWN = SDLK_PAGEDOWN;

SDLKey keys::KEY_PREVIOUS = SDLK_UP;

SDLKey keys::KEY_NEXT = SDLK_DOWN;

SDLKey keys::KEY_ACTIVATE = SDLK_SPACE;

***** Error reading new file: [Errno 2] No such file or directory: 'keys.h'
***** Error reading new file: [Errno 2] No such file or directory: 'object.h'
--- NEW FILE ---
/*
   (C) Copyright 2000 Joel Vennin
   Part of the Adonthell Project http://adonthell.linuxgames.com

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details
*/

#include "scroll.h"
#include "keys.h"
using namespace gui;

scroll::scroll():scrollbar(this)
{
  
  cursor_y_=0;
  
  max_amplitude_=0;
  
  cur_amplitude_=0;
  
  index_pad_=PAD_DEFAULT;

  set_auto_scrollbar(false);
  
  set_auto_refresh(false);

}


bool scroll::down()
{
  
  if( max_amplitude_ == 0 ) return false;
  
  if( cur_amplitude_ + index_pad_ > max_amplitude_ ) cur_amplitude_ = 
max_amplitude_;  
  else cur_amplitude_ += index_pad_;
  
  update_amplitude();
  
  on_down();
  
  return true;

}


void scroll::resize(u_int16 tl,u_int16 th)
{
  container::resize(tl,th);
  
  find_amplitude();
  
  scrollbar::update_back();
  
  scrollbar::update_bar();
}


bool scroll::up()
{
  if( max_amplitude_==0 ) return false ;
  
  if( cur_amplitude_-index_pad_ < 0) cur_amplitude_ = 0;
  else cur_amplitude_ -= index_pad_;
  
  update_amplitude();
  
  on_up();
  
  return true;
}

void scroll::set_pos (const u_int8 pos) 
{
    cur_amplitude_ = (u_int16)((((float) max_amplitude_) / 255) * pos); 
    update_amplitude(); 
}

void scroll::update_amplitude()
{
  for(lwb::iterator i=list_wb_.begin() ; i!=list_wb_.end() ; i++) 
    {  
      (*i)->pad_y() = -cur_amplitude_ ;  
      (*i)->update_position();
    }
  
  cursor_y_=(u_int16) ( (float) ((float)(height() - scrollbar::height_bar() ) / 
max_amplitude_ ) * cur_amplitude_ );
}


void scroll::set_space_between_border(u_int16 tmp)
{
  
  container::set_space_with_border(tmp);
  
  find_amplitude();
  
  scrollbar::update_bar();

}


void scroll::set_space_between_object(u_int16 tmp)
{
  container::set_space_with_object(tmp);
  
  find_amplitude();
  
  scrollbar::update_bar();
}


void scroll::add(base *wb)
{
  container::add(wb);
  
  find_amplitude();
  
  scrollbar::update_bar();
}


void scroll::remove(base *wb)
{
  container::remove(wb);
  
  find_amplitude();
  
  scrollbar::update_bar();
}


void scroll::remove_all()
{
  container::remove_all();
  
  max_amplitude_=0;
  
  cur_amplitude_=0;
  
  scrollbar::update_bar();
}


void scroll::destroy()
{
  container::destroy();
  
  max_amplitude_=0;
  
  cur_amplitude_=0;
  
  scrollbar::update_bar();
}


bool scroll::draw()
{
  if(base::draw())
    {
      assign_drawing_area(wb_father_); 
      
      background::draw(this);   
      
      for(lwb::iterator i=list_wb_.begin();i!=list_wb_.end();i++)
        (*i)->draw();
      
      scrollbar::draw(wb_father_);

      border::draw(wb_father_);
      
      detach_drawing_area();
      
      return true;
    }
  return false;
}


bool scroll::update()
{
  if(container::update())
    {
      if(auto_scrollbar_)
        {
          u_int16 old = amplitude();
          find_amplitude(); 
          if(old != amplitude())
            {
              scrollbar::set_visible_scrollbar(amplitude()!=0);
              scrollbar::update_bar();
            }
        }
      else if(auto_refresh_) 
        {
          u_int16 old = amplitude(); find_amplitude(); 
          if(old != amplitude())
            scrollbar::update_bar();
        } 
      return true;
    }
  return false;
}


bool scroll::input_update()
{
  if(container::input_update())
    {
      if(focus_object_) return true;
      if(input::is_pushed(keys::KEY_UP)) up();
      if(input::is_pushed(keys::KEY_DOWN)) down();
      return true;
    }
  return false;
}


void scroll::find_amplitude()
{
  //search the max y object to calcul the amplitude
  max_amplitude_ = cursor_y_ = cur_amplitude_ = 0;
  
  for(lwb::iterator i=list_wb_.begin() ; i!=list_wb_.end() ; i++) 
    if((*i)->y() + (*i)->height() > height() - space_with_border() && (*i)->y() 
+ (*i)->height() - height() + space_with_border() > max_amplitude_ )
      max_amplitude_ = (*i)->y() + (*i)->height() - height() + 
space_with_border(); 
}

--- NEW FILE ---
/*
   (C) Copyright 2000 Joel Vennin
   Part of the Adonthell Project http://adonthell.linuxgames.com

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details
*/

#ifndef GUI_SCROLL_H_
#define GUI_SCROLL_H_

#include "../input.h"
#include "base.h"
#include "container.h"
#include "scrollbar.h"

namespace gui {
  
  class scroll : public container, public scrollbar
    {
      
    public:
      //constructor x,y,length,height,and a theme
      scroll();
      
      //return difference between the last object and the visual height, I 
think you don't understand, but i know you never use thisfunction just me 
      u_int16 amplitude(){return max_amplitude_;}
      
      /**
       * Add an objet
       */
      virtual void add(base *);
      
      /**
       * Remove an objet
       */
      virtual void remove(base *);
      
      /**
       * remove all 
       */
      virtual void remove_all();
      
      /**
       * resize the scroll 
       */
      void resize(u_int16 tl,u_int16 th);
      
      /**
       * destroy 
       */
      void destroy();
      
      /**
       * draw the objet
       */
      bool draw();
      
      /**
       * update
       */
      bool update();

      /**
       * input update
       */
      bool input_update();
      
      /**
       * define space between border
       */
      void set_space_between_border(u_int16 );
      
      /**
       * define space between objet
       */
      void set_space_between_object(u_int16 );
      
      /**
       * Set pos ??
       */
      virtual void set_pos (const u_int8 pos);
      
      /**
       * return position of the cursor ??
       */
      u_int16 cursor_y(){return cursor_y_;}
      

      /**
       * Define autoscrollbar 
       */
      void set_auto_scrollbar(bool b){auto_scrollbar_=b;}
      
      /**
       * Define autorefresh
       */
      void set_auto_refresh(bool b){auto_refresh_=b;}
      
      /**
       * Define if this objet is brightness
       */
      void set_brightness(bool b) 
{container::set_brightness(b);set_brightness_scrollbar(b);}
      
      /**
       * Define if this objet is transluency
       */
      void set_trans(bool b) {container::set_trans(b); set_trans_scrollbar(b);}
      
      /**
       * Define the pad when scroll
       */
      const static u_int8 PAD_DEFAULT = 5;
      
    protected:
      
      bool up();
      
      bool down();
      
      void find_amplitude();
      
      void update_amplitude();
      
      u_int16 max_amplitude_;
      
      u_int16 cur_amplitude_;
      
      u_int16 index_pad_;
      
      u_int16 cursor_y_;
      
      bool auto_scrollbar_;
      
      bool auto_refresh_;
    };
}
#endif
  



--- NEW FILE ---
/*   
   (C) Copyright 2000 Joel Vennin
   Part of the Adonthell Project http://adonthell.linuxgames.com
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details
*/

#include "theme.h"
#include "scrollbar.h"

using namespace gui;

scrollbar::scrollbar()
{
  wsc_=NULL;
  init();
  set_visible_scrollbar(true);
  set_trans_scrollbar(false);
  set_brightness_scrollbar(false);
  refresh();
}

scrollbar::scrollbar(scroll * wsc)
{
  wsc_=wsc;
  init();
  set_visible_scrollbar(true);
  set_trans_scrollbar(false);
  set_brightness_scrollbar(false);
  refresh();
}

scrollbar::scrollbar(scrollbar & ws)
{
  wsc_=NULL;
  init();
  set_visible_scrollbar(true);
  set_trans_scrollbar(false);
  set_brightness_scrollbar(false);
  *this=ws;
  refresh();
}

scrollbar::scrollbar(char * rep)
{
  wsc_=NULL;
  init();
  set_visible_scrollbar(true);
  set_trans_scrollbar(false);
  set_brightness_scrollbar(false);
  load(rep);
  refresh();
}

scrollbar::~scrollbar()
{
  destroy();
}


void scrollbar::set_scrollbar(scrollbar & ws)
{
  *this=ws;
  refresh();
}

void scrollbar::set_scrollbar(theme & wt)
{
  *this=*(wt.my_scrollbar);
  refresh();
}

void scrollbar::init()
{
  back_bot_=NULL;
  back_mid_=NULL;
  back_top_=NULL;
  bar_top_=NULL;
  bar_bot_=NULL;
  bar_mid_=NULL;
  bar_flex_=NULL;
  bar_=NULL;
  back_=NULL;
  bar_brightness_=NULL;
  back_brightness_=NULL;
  bar_draw_=NULL;
  back_draw_=NULL;
}

scrollbar & scrollbar::operator=(scrollbar & wb)
{
  destroy();
  bar_top_=new gfx::image();
  *bar_top_=*(wb.bar_top_);
  bar_mid_=new gfx::image();
  *bar_mid_=*(wb.bar_mid_);
  bar_bot_=new gfx::image();
  *bar_bot_=*(wb.bar_bot_);
  bar_flex_=new gfx::image();
  *bar_flex_=*(wb.bar_flex_);

  back_top_=new gfx::image();
  *back_top_=*(wb.back_top_);
  back_mid_=new gfx::image();
  *back_mid_=*(wb.back_mid_);
  back_bot_=new gfx::image();
  *back_bot_=*(wb.back_bot_);

  bar_=new gfx::image();
  back_=new gfx::image();
  bar_->set_mask(true);
  back_->set_mask(true);
  

  bar_brightness_ = new gfx::image();
  back_brightness_ = new gfx::image();
  bar_brightness_->set_mask(true);
  back_brightness_->set_mask(true);
  
  update_back();
  update_bar();
  
  return *this;
}



void scrollbar::load(char * theme)
{
  destroy();
  char path[255];char tmp[255];
  strcpy(path,DIRECTORY);
  strcat(path,SCROLLBAR_DIRECTORY);
  strcat(path,theme);
  
  bar_=new gfx::image();
  back_=new gfx::image();
  bar_->set_mask(true);
  back_->set_mask(true);

  bar_brightness_ = new gfx::image();
  back_brightness_ = new gfx::image();
  bar_brightness_->set_mask(true);
  back_brightness_->set_mask(true);

  bar_top_=new gfx::image();
  strcpy(tmp,path);
  strcat(tmp,SCROLLBAR_BAR_TOP);
  bar_top_->load_pnm(tmp);
  
  bar_mid_=new gfx::image();
  strcpy(tmp,path);
  strcat(tmp,SCROLLBAR_BAR_MID);
  bar_mid_->load_pnm(tmp);
  
  bar_bot_=new gfx::image();
  strcpy(tmp,path);
  strcat(tmp,SCROLLBAR_BAR_BOT);
  bar_bot_->load_pnm(tmp);
  
  bar_flex_=new gfx::image();
  strcpy(tmp,path);
  strcat(tmp,SCROLLBAR_BAR_FLEX);
  bar_flex_->load_pnm(tmp);

  back_top_=new gfx::image();
  strcpy(tmp,path);
  strcat(tmp,SCROLLBAR_BACK_TOP);
  back_top_->load_pnm(tmp);
  
  back_mid_=new gfx::image();
  strcpy(tmp,path);
  strcat(tmp,SCROLLBAR_BACK_MID);
  back_mid_->load_pnm(tmp);
  
  back_bot_=new gfx::image();
  strcpy(tmp,path);
  strcat(tmp,SCROLLBAR_BACK_BOT);
  back_bot_->load_pnm(tmp); 
}

void scrollbar::update_back()
{
  if(!wsc_ || !back_) return;
  
  back_->resize(back_mid_->length(),wsc_->height());
  back_->tile(*back_mid_);
  
  back_top_->draw(0,0,NULL,back_);
  back_bot_->draw(0,wsc_->height()-back_bot_->height(),NULL,back_);
  
  back_brightness_->brightness(*back_, BRIGHTNESS_LEVEL);
}

void scrollbar::refresh()
{
  if(brightness_)
    {
      bar_draw_=bar_brightness_;
      back_draw_=back_brightness_;
    }
  else
    {
     bar_draw_=bar_;
     back_draw_=back_;
    }
}


void scrollbar::destroy()
{
  if(back_bot_) delete back_bot_;
  if(back_top_) delete back_top_;
  if(back_mid_) delete back_mid_;
  if(bar_bot_) delete bar_bot_;
  if(bar_mid_) delete bar_mid_;
  if(bar_top_) delete bar_top_;
  if(bar_flex_) delete bar_flex_;
  if(bar_) delete bar_;
  if(back_) delete back_;
  if(bar_brightness_) delete bar_brightness_;
  if(back_brightness_) delete back_brightness_;
}


void scrollbar::update_bar()
{
  if(!wsc_ || !bar_) return;
  if (!(wsc_->height() + wsc_->amplitude()))  return; 
  
  u_int16 calcul =  (wsc_->height() * wsc_->height()) / (wsc_->height() + 
wsc_->amplitude()); 
  
  if( calcul > bar_top_->height() + bar_mid_->height() + bar_bot_->height())
    {
      bar_->resize(bar_top_->length(), calcul);
      bar_->tile(*bar_flex_);
      bar_top_->draw(0,0,NULL,bar_);
      bar_bot_->draw(0,bar_->height() - bar_bot_->height(),NULL,bar_);
      bar_mid_->draw(0,(bar_->height() - bar_mid_->height() ) >> 1, NULL,bar_);
    }
  else
    {
      bar_->resize(bar_top_->length(), bar_top_->height() + bar_mid_->height() 
+ bar_bot_->height());
      bar_top_->draw(0,0,NULL,bar_);
      bar_bot_->draw(0,bar_->height() - bar_bot_->height(),NULL,bar_);
      bar_mid_->draw(0,bar_top_->height(),NULL,bar_);
    }
  bar_brightness_->brightness(*bar_,BRIGHTNESS_LEVEL);
}


void scrollbar::draw(gfx::drawing_area * da)
{
  if(!visible_ || !back_draw_ || !bar_draw_) return; 
  back_draw_->draw(wsc_->real_x() + wsc_->length() - back_->length(), 
wsc_->real_y() , da );
  bar_draw_->draw(1 + wsc_->real_x() + wsc_->length() - back_->length(), 
wsc_->real_y() + wsc_->cursor_y() , da);
}

--- NEW FILE ---
/*
   (C) Copyright 2000 Joel Vennin
   Part of the Adonthell Project http://adonthell.linuxgames.com

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details
*/

#ifndef GUI_SCROLLBAR_H_
#define GUI_SCROLLBAR_H_

#include "../gfx/image.h"
#include "../gfx/drawing_area.h"
#include "types.h"

namespace gui {

  class theme;
  class scroll;

  class scrollbar
    {
    public:
      
      scrollbar();
      
      scrollbar(scroll * );
      
      scrollbar(scrollbar &);
      
      scrollbar(char *rep);
      
      ~scrollbar();
      
      void update_bar();
      
      void load(char *);
      
      void update_back();
      
      void destroy();
      
      void set_scrollbar(scrollbar &);
      
      void set_scrollbar(theme  & wt);
      
      void set_visible_scrollbar(bool b) {visible_=b;}
      
      void set_trans_scrollbar(bool b)
        {
          if(!bar_draw_) return;
          if(trans_=b){ bar_draw_->set_alpha(130);back_draw_->set_alpha(130); }
          else{bar_draw_->set_alpha(255);back_draw_->set_alpha(255); }
        }
      
      void set_brightness_scrollbar(bool b){brightness_=b;refresh();}
      
      void draw(gfx::drawing_area * da= NULL);
      
      u_int16 height_bar(){if(bar_) return bar_->height();return 0;}
      
    private:
      
      void init();
      
      void refresh();
      
      scrollbar & operator=(scrollbar &);
      
      gfx::image * back_bot_;
      gfx::image * back_mid_;
      gfx::image * back_top_;
      gfx::image * bar_top_;
      gfx::image * bar_bot_;
      gfx::image * bar_mid_;
      gfx::image * bar_flex_;
  
      gfx::image * bar_;
      gfx::image * back_;
      
      gfx::image * bar_brightness_;
      gfx::image * back_brightness_;
      
      gfx::image * bar_draw_;
      gfx::image * back_draw_;
      
      bool visible_;
      bool brightness_;
      bool trans_;
      
      scroll * wsc_;
    };
}
#endif

***** Error reading new file: [Errno 2] No such file or directory: 
'select_list.cc'
***** Error reading new file: [Errno 2] No such file or directory: 
'select_list.h'
--- NEW FILE ---
/*
   (C) Copyright 2002 Joel Vennin
   Part of the Adonthell Project http://adonthell.linuxgames.com

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details
*/

#include <iostream>

#include "gfx/image.h"
#include "font.h"


win_ttf::win_ttf ()
{
    // by default no file,  so no valid font
    my_valid = false;  
    // init color
    set_color (0, 0, 0);   
    // set default size
    set_size (12);
    // set_default dpi 
    set_dpi (72); 
}


bool win_ttf::load (const std::string & filename)
{
    int error; 
    close (); 
    
    // copy the new filename
    my_filename = filename;     
    my_valid = false; 
    
    // Initialise library
    error = FT_Init_FreeType( &my_library ); 
    if (error) 
    {
        std::cout << "FONT : Initialisation error!\n"; 
        return false;
    }
    
    // load TTF font in face
    error = FT_New_Face( my_library, my_filename.c_str () , 0, &my_face );
    if ( error == FT_Err_Unknown_File_Format )
    {
        std::cout << "FONT : Unknown font format\n";
        close (); 
        return false; 
    }
    else if ( error )
    {
        std::cout << "FONT : Error undefined\n";
        close (); 
        return false; 
    }

    // Check if the font is no scalable
    // WARNING : Implement in the futur
    if (my_face->num_fixed_sizes)
      {
        std::cout << "FONT : Fixed font not only supported\n"; 
        close ();
        return false; 
      }
    
    my_valid = true; 
    return true; 
}


bool win_ttf::build ()
{
  FT_Set_Char_Size( my_face, my_size << 6, my_size << 6, my_dpi, my_dpi);
  return true; 
}

inline void win_ttf::set_dpi (int i) { my_dpi = i; }

inline void win_ttf::set_size (int i) { my_size = i; }


void win_ttf::close ()
{
    if (!my_valid) return; 
    FT_Done_Face(my_face);
    FT_Done_FreeType(my_library); 
}

--- NEW FILE ---
/*
  (C) Copyright 2002 Joel Vennin
   Part of the Adonthell Project http://adonthell.linuxgames.com

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details
*/


/**
 * @file   font.h
 * @author Joel Vennin <address@hidden>
 * 
 * @brief  Declares the font TFF class.
 * 
 * 
 */
#ifndef TTF__H_
#define TTF__H_

#include <string>  
#include <vector> 

#include <ft2build.h>
#include FT_FREETYPE_H
#include "types.h"
#include "gfx/drawing_area.h"
#include "gfx/surface.h"
#include "gfx/image.h"


class win_ttf
{
 public:
  /**
   * Default constructor 
   */
  win_ttf ();

  /**
   * Destructor
   */
  ~win_ttf ();

  
  /**
   * Load a TTF file. But do not a build !
   */  
  bool load (const std::string & filename);
  

  /**
   * Build the font with cur configuration (size, color, dpi) 
   * After build, you can draw some text;) 
   */
  bool build ();

  /** Set dots per inch
   * You must set to 72 or 96,  Why ? see documentation on www.freetype.org
   *
   * @param dots per inch
   */ 
  inline void set_dpi (int);
  
  
  /** Set police size
   *
   * @param font size 
   */
  inline void set_size (int size); 
  
  
  /** Set color
   *
   * @param r : red color
   * @param g : green color
   * @param b : blue color
   */
  void set_color (u_int8 r, u_int8 g, u_int8 b);
  

 
  private:
  

  /* copy bitmap to image */
  void copy_bitmap_to_image (u_int8 * bitmap_data, gfx::image * dest, s_int16 
dx, s_int16 dy); 
  
  /* close the library and face */
  void close (); 
  
  int UTF8_to_UNICODE(u_int16 * unicode, const char *utf8, int len);
  
  /* filename of the font */
  std::string my_filename; 
  
  /* valid font,  true if valid */
  bool my_valid; 
  
  /* library FT */
  FT_Library my_library; 
  
  /* FT_Face */
  FT_Face my_face;
  
  /* dpi, dots-per-inch */
  int my_dpi;
  
  /* size */
  u_int16 my_size;
  
  /* color variable */
  u_int8 my_r, my_g, my_b;  
};


#endif

***** Error reading new file: [Errno 2] No such file or directory: 'types.h'
--- NEW FILE ---

/* 
   %include "win_font.h"
   %include "win_theme.h"
   %include "win_base.h"
   %include "win_container.h"
   %include "win_label.h"
   %include "win_image.h"
   %include "win_scrolled.h"
   %include "win_select.h"
*/
%include "win_manager.h"
 

class win_font{

 private:
  void erase();
  void init_in_table();
  
  bool table_core[WIN_NB_TABLE_CHAR];

  image * table;  
  
  u_int8 height_;
  u_int8 length_; //just for space bar
 
 public:
  
  win_font(char *);
  
  ~win_font();
  
  void load(char *);
  
  bool in_table(u_int16 tmp);

  //win_font & operator=(win_font &);
  
  u_int16 height(){return height_;}
  
  u_int16 length(){return length_;}
  
  image * cursor;
  
};


#define win_event_ACTIVATE  1
#define win_event_UNACTIVATE   2
#define win_event_UPDATE   3
#define win_event_DRAW   4
#define win_event_DRAW_ON_VISIBLE   5
#define win_event_ACTIVATE_KEY   6
#define win_event_SELECT   7
#define win_event_UNSELECT   8
#define win_event_KEYBOARD   9
#define win_event_SCROLL_UP   10
#define win_event_SCROLL_DOWN   11
#define win_event_NEXT   12
#define win_event_PREVIOUS   13
#define win_event_CLOSE  14
#define win_event_DESTROY  15

class win_event
{
 public:
  
  win_event(){return_code_=0;}

  //Use this function to set a callback function
  void set_return_code (int rc) 
    { return_code_ = rc; }
    
  bool update();
  
  void py_signal_connect (PyObject *pyfunc, int signal, PyObject *args = NULL); 


  /*****************************************************/
  /*****************************************************/
  //DESTRUCTOR
  virtual ~win_event();
  
 protected:
  // the python callbacks connected to the window
  vector<py_callback *> py_callbacks;   
  
  
  Functor0 callback_[20];
  Functor0wRet<bool> callback_destroy_;
  Functor1<int> callback_quit_;
  
  
  int return_code_;
  
  //execute the callback function
  virtual void on_activate(){ if(callback_[ACTIVATE]) (callback_[ACTIVATE])();}
  virtual void on_unactivate(){ if(callback_[UNACTIVATE]) 
(callback_[UNACTIVATE])();}
  
  virtual void on_update() { if(callback_[UPDATE]) (callback_[UPDATE])();}
  
  virtual void on_draw_visible(){ if(callback_[DRAW_ON_VISIBLE]) 
(callback_[DRAW_ON_VISIBLE])();}
  virtual void on_draw(){ if(callback_[DRAW]) (callback_[DRAW])();}
  
  virtual void on_activate_key(){ if(callback_[ACTIVATE_KEY]) 
(callback_[ACTIVATE_KEY])();}
  virtual void on_select(){ if(callback_[SELECT]) (callback_[SELECT])();}
  virtual void on_unselect(){ if(callback_[UNSELECT]) (callback_[UNSELECT])();}
  
  virtual void on_up(){if(callback_[SCROLL_UP]) (callback_[SCROLL_UP])();}
  virtual void on_down(){if(callback_[SCROLL_DOWN]) (callback_[SCROLL_DOWN])();}
  
  virtual void on_next(){if(callback_[NEXT]) (callback_[NEXT])();}
  virtual void on_previous(){if(callback_[PREVIOUS]) (callback_[PREVIOUS])(); }
}; 


#define win_border_MINI 0
#define win_border_NORMAL 1

class win_border
{
 public:
  
  win_border();

  ~win_border();
  
  void load(char *,char *);
  
  void update();
  
  void destroy();

  void draw(drawing_area * da);
  
  void set_visible_border(bool b){visible_border_=b;}
  
  void set_brightness_border(bool b);
  
  void set_border(win_theme & wth, u_int8 size = win_border::NORMAL);

  void set_trans_border(bool b);//{trans_=b;}

  u_int16 length_border();
  
  u_int16 height_border();

 private:
  
  void init();

  void refresh();
  
  image * h_border_template_;
  
  image * v_border_template_;
  
  image * border_[NB_BORDER_IMAGE];
  
  image * border_brightness_[NB_BORDER_IMAGE];

  image ** border_draw_;

  bool visible_border_;
  
  bool brightness_;

  u_int8 trans_;

  win_base * wb_;
};


class win_background
{
 public:
  
  win_background();
  
  ~win_background();
  
  void load(char *);
  
  void update();
  
  void destroy();

  void draw(drawing_area * da =NULL);

  void set_visible_background(bool b){visible_=b;}

  void set_background(win_theme &);
  
  void set_brightness_background(bool b);
  
  void set_trans_background(bool b);//{trans_=b;}
  
 private:   
  void refresh();

  void init();
  
  image * background_template_;
  
  image * background_;
  
  image * background_brightness_;
  
  image * background_draw_;
  
  win_base * wb_;
  
  bool visible_;

  bool brightness_;

  bool trans_;
};


  #define win_base_ALIGN_NONE  0
  #define win_base_ALIGN_LEFT  1
  #define win_base_ALIGN_CENTER  2
  #define win_base_ALIGN_RIGHT  3

class win_base: public win_event, public win_border, public drawing_area, 
public win_background
{
 public:
  
  /**
   * Default constructor:
   *    - not visible
   *    - x,y equals to 0
   *    - not focus
   *    - not activate
   *    - not brightness
   *    - not transluency
   *    - can be selected
   *    - alignement is ALIGN_NONE
   */
  win_base();
  
  /**
   * Return the relative horizontal position of the win_*.
   * @return horizontal position of the win_*.
   */
  s_int16 x() const 
    {return x_;}

  
  /**
   * Return the relative vertical position of the win_*.
   * @return vertical position of the win_*.
   */
  s_int16 y() const 
    {return y_;}
  

  /**
   * Return the pad horizontal position of the win_*.
   * @return the pad horizontal position of the win_*.
   */
  s_int16 & pad_x() 
    {return pad_x_;}
  
  
  /**
   * Return the pad vertical position of the win_*.
   * @return the pad vertical position of the win_*.
   */
  s_int16 & pad_y() 
    {return pad_y_;}

  
   /**
   * Return the horizontal position of the win_*.
   * @return the horizontal position of the win_*.
   */
  s_int16 real_x() const 
    {return drawing_area::x();}
  
  
  /**
   * Return the vertical position of the win_*.
   * @return the vertical position of the win_*.
   */
  s_int16 real_y() const 
    {return drawing_area::y();}
  

  /** Move the win_*.
   *  @param tx new horizontal position.
   *  @param ty new vertical position.
   */  
  virtual void move(s_int16 tx,s_int16 ty);
  

   /** Rezise the win_*.
    *  @param tl new horizontal position.
    *  @param th new vertical position.
    */  
  virtual void resize(u_int16 tl, u_int16 th);
  
  
  /** Test if win_* is visible
   *  @return true if visible else false 
   */
  bool is_visible() const 
    {return visible_;}
  
  
  /** Set the visible parameter
   * @param b true if the win_* should be visible, false otherwise
   */
  void set_visible(const bool b) 
    {visible_=b;}
  

  /** Test if win_* is activated
   *  @return true if activate else false 
   */
  bool is_activate() const
    {return activate_;}
  
  
  /** Set the activate parameter
   * When a win_* is setup on, the keys queue is cleared
   *
   * @param b true if the win_* should be visible, false otherwise
   */
  void set_activate(const bool b)
    {if(activate_=b) {on_activate();input::clear_keys_queue();}else 
on_unactivate();}
  
  
  /** Test if win_* has focus on
   *  @return true if focus on else false 
   */
  bool is_focus()const 
    {return focus_;}
  
  
  /** Set the focus parameter
   * @param b true if the win_* should be focus on, false otherwise
   */
  void set_focus(const bool b)
    {focus_=b;}
  
  
  /** Test if win_* has focus on
   *  @return true if focus on else false 
   */
  bool is_trans() const 
    {return trans_;}
  
  
  /** Set the transluency parameter
   * @param b true if the win_* should be ins transluency, false otherwise
   */
  virtual void set_trans(const bool b)
    {set_trans_border(trans_ = b);set_trans_background(b);}

  
  /** Test if win_* is in brightness
   *  @return true if in brightness else false 
   */
  bool is_brightness() const
    {return brightness_;}
  
  
  /** Set the transluency parameter
   * @param b true if the win_* should be in transluency, false otherwise
   */
  virtual void set_brightness(const bool b)
    {set_brightness_border(brightness_ = b);set_brightness_background(b);}

  
  /** Set alignement of win_*
   * @param a can be, ALIGN_NONE, ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT
   */
  void set_align(const u_int8 a)
    {align_=a;update_align();}
  
  
  /** Return alignment of win_*
   * @return align_ parameter
   */
  u_int8 align() const {return align_;}
  
  
  /** Test if win_* can be selected
   * @return true if it can be selected, false otherwise
   */
  bool is_can_be_selected() const 
    {return can_be_selected_;}
  
  
  /** Set the object to be selected
   * A win_obj can be selectable or not when it is inside a win_select
   * @param b true if the object can be selected inside a win_select., false 
otherwise
   */
  void set_can_be_selected(const bool b) 
    {can_be_selected_ = b;}
  
  
  /** Update process
   *  @return true if update is successful, false otherwise 
   */
  virtual bool update();
  
  
  /** Draw process
   * @return true if draw is successful, false otherwise
   */
  virtual bool draw();
  
  
  /** Input Update process 
   * @ 
   */
  virtual bool input_update();

  virtual ~win_base();
      
 protected:

  virtual void update_position();
  
  void update_align();

  void set_container(win_container * wc);
  
  

  s_int16 x_;

  s_int16 y_;
  
  s_int16 pad_x_;
  
  s_int16 pad_y_;

  u_int8 align_;

  bool visible_;
  
  bool focus_;

  bool activate_;
  
  bool brightness_;

  bool trans_;

  bool can_be_selected_;

  win_container * wb_father_;
  
}; 
  #define win_container_SPACE_WITH_BORDER  10
  #define win_container_SPACE_WITH_OBJECT  10
  
  #define win_container_LIST_LAYOUT  1
  #define win_container_NO_LAYOUT  0

class win_container : public win_base
{
 public:
  
  win_container();
  
  void move(s_int16, s_int16);
  
  void resize(u_int16, u_int16);

  virtual void add(win_base *);

  virtual void remove(win_base *);

  virtual void remove_all();

  virtual void destroy();

  virtual ~win_container();
  
  virtual bool update();

  virtual bool input_update();
  
  virtual bool draw();
  
  void set_visible_all(bool b);
  
  virtual void set_brightness(bool b);

  virtual void set_trans(bool b);

  virtual void set_space_with_border(u_int16 
b){space_with_border_=b;update_layout();}
  
  virtual void set_space_with_object(u_int16 
o){space_with_object_=o;update_layout();}
  
  u_int16 space_with_border(){return space_with_border_;}
  
  u_int16 space_with_object(){return space_with_object_;}

  void set_layout(u_int8 l){layout_=l;update_layout();}
  
  void set_focus_object(win_base * f);
  
  win_base * focus_object(){return focus_object_;}

 protected:
  
  void update_position();
  void update_layout();
  
  u_int16 space_with_object_;
  u_int16 space_with_border_;
  u_int8 layout_;

  lwb list_wb_;

  win_base * focus_object_;
  
};



class win_image : public image, public win_base
{
public:
  win_image(); 
  ~win_image(); 
  bool draw(); 
  bool update(); 
  bool input_update(); 
  void set_brightness(bool b); 
  void set_trans(bool b); 
  void pack(); 
  void set_auto_refresh(bool b);   
}; 


#define label_NOTHING 0
#define label_AUTO_HEIGHT 1
#define label_AUTO_SIZE 2

#define label_KEY_CURSOR_NEXT SDLK_RIGHT
#define label_KEY_CURSOR_PREVIOUS SDLK_LEFT

class label: public image
{
 public:
  label();
  
  const string & text_string(){return text_;}
  const char * text_char(){return text_.c_str();} 

  void set_text(string str);
  
  void add_text(const string & str);
  
  void set_font(win_font & font);
  
  void set_form(const u_int8);
     
  void set_cursor_visible (const bool b){cursor_ = b;}
  
  void set_cursor_moveable(const bool b){cursor_moveable_ = b;}

  void resize(const u_int16 l,const u_int16 h);
 
  bool update();

  bool input_update();
 
 protected:
  
  void check_form();
  
  void form_auto_size();
  
  void form_auto_height();
  
  void form_nothing();
  
  void cursor_next();
  
  void cursor_previous();
  
  u_int8 word_place( u_int16 & cur_line_size, u_int16 & word_size );
  
  void find_word(u_int16 & begin,u_int16 &length, u_int16 & size_pix);
  
  //the text
  string text_;
  
  //the size of text
  u_int16 text_size_;
  
  //start to begin at the index
  u_int16 text_index_begin_;
  
  //it's the last letter which was drawing
  u_int16 text_index_end_;
  
  u_int16 cursor_pos_;
  
  bool cursor_;
  
  //set cursor visible
  bool cursor_visible_;
  
  //set cursor moveable
  bool cursor_moveable_;

  static u_int16 cursor_blink_speed_;
  
  u_int16 cursor_blink_cur_;

  bool text_eot_;

  //the font
  win_font * font_;
  
  //the style text displayed
  u_int8 form_;

 private: 
};


class win_label : public label, public win_base
{
public:
  win_label(); 
  ~win_label(); 
  bool draw(); 
  bool update(); 
  bool input_update(); 
  void set_brightness(bool b); 
  void set_trans(bool b); 
  void pack(); 
  void set_auto_refresh(bool b);   
}; 


class label_input : public label
{
 public:
    
  bool input_update();
  
 protected:
  void insert(const u_int16 pos, const char * letter);

   
};

class win_write : public label_input, public win_base
{
public:
  win_write(); 
  ~win_write(); 
  bool draw(); 
  bool update(); 
  bool input_update(); 
  void set_brightness(bool b); 
  void set_trans(bool b); 
  void pack(); 
  void set_auto_refresh(bool b);   
}; 


class win_mapview : public mapview, public win_base
{
public:
  win_mapview(); 
  ~win_mapview(); 
  bool draw(); 
  bool update(); 
  bool input_update(); 
  void set_brightness(bool b); 
  void set_trans(bool b); 
  void pack(); 
  void set_auto_refresh(bool b);   
}; 

class win_scrollbar
{
 public:
    
  win_scrollbar(char *rep);
  
  ~win_scrollbar();
  
  void update_bar();
  
  void load(char *);
  
  void update_back();
  
  void destroy();
  
  void set_scrollbar(win_theme  & wt);
  
  void set_visible_scrollbar(bool b)
    {visible_=b;}
  
  void set_trans_scrollbar(bool b)
    {
      if(!bar_draw_) return;
      if(trans_=b){ bar_draw_->set_alpha(130);back_draw_->set_alpha(130); }
      else{bar_draw_->set_alpha(255);back_draw_->set_alpha(255); }
    }
  
  void set_brightness_scrollbar(bool b){brightness_=b;refresh();}
  
  void draw(drawing_area * da= NULL);
  
  u_int16 height_bar(){if(bar_) return bar_->height();return 0;}

 private:
  
  void init();
  
  void refresh();
   
  image * back_bot_;
  image * back_mid_;
  image * back_top_;
  image * bar_top_;
  image * bar_bot_;
  image * bar_mid_;
  image * bar_flex_;
  
  image * bar_;
  image * back_;
  
  image * bar_brightness_;
  image * back_brightness_;
  
  image * bar_draw_;
  image * back_draw_;

  bool visible_;
  bool brightness_;
  bool trans_;

  win_scroll * wsc_;
  
};


#define win_scroll_PAD_DEFAULT 5

class win_scroll : public win_container, public win_scrollbar
{
  
 public:
  //constructor x,y,length,height,and a theme
  win_scroll();
  
  //return difference between the last object and the visual height, I think 
you don't understand, but i know you never use thisfunction just me 
  u_int16 amplitude(){return max_amplitude_;}
  
  virtual void add(win_base *);
  
  virtual void remove(win_base *);
  
  virtual void remove_all();
  
  void resize(u_int16 tl,u_int16 th);
  
  void destroy();
  
  bool draw();
  
  bool update();
  
  bool input_update();

  void set_space_between_border(u_int16 );
  
  void set_space_between_object(u_int16 );
 
  u_int16 cursor_y(){return cursor_y_;}
  
  void set_auto_scrollbar(bool b){auto_scrollbar_=b;}
  
  void set_auto_refresh(bool b){auto_refresh_=b;}

  void set_brightness(bool b) 
{win_container::set_brightness(b);set_brightness_scrollbar(b);}
    
  void set_trans(bool b) {win_container::set_trans(b); set_trans_scrollbar(b);}

 

 protected:

  bool up();
  
  bool down();

  void find_amplitude();
  
  void update_amplitude();
  
  u_int16 max_amplitude_;
  
  u_int16 cur_amplitude_;
  
  u_int16 index_pad_;
  
  u_int16 cursor_y_;
  
  bool auto_scrollbar_;

  bool auto_refresh_;
};



#define win_select_MODE_BORDER 0
  
#define win_select_MODE_BRIGHTNESS 1

class win_select : public win_scroll
{
 public:
  
  win_select();

  bool input_update();
  
  void add(win_base * w);
  
  void remove(win_base * w);

  void remove_all();
  
  void set_mode(const u_int8 mode){mode_ = mode;}
  
  void set_border_select(win_border * border){border_select_ = border;}
  
  void set_circle(const bool b) {circle_ = b;}
  bool is_circle(){return circle_;}

  void set_default();

  void set_default_object(const win_base * wb);

  void set_default_position(const u_int16 pos);

  win_base * get_selected_object();
  
  u_int16 get_selected_position();

  
};



class win_theme
{
  
 public:
  
  win_theme(char *);
  
  ~win_theme();
  
  void destroy();
};









***** Error reading new file: [Errno 2] No such file or directory: 'write.h'




reply via email to

[Prev in Thread] Current Thread [Next in Thread]