adonthell-commits
[Top][All Lists]
Advanced

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

[Adonthell-commits] CVS: adonthell/src atk_theme.cc,NONE,1.1.2.1 atk_the


From: VENNIN Joel <address@hidden>
Subject: [Adonthell-commits] CVS: adonthell/src atk_theme.cc,NONE,1.1.2.1 atk_theme.h,NONE,1.1.2.1 Makefile.am,1.80.2.24,1.80.2.25 atk_border.cc,1.1.2.1,1.1.2.2 atk_border.h,1.1.2.1,1.1.2.2 atk_border_template.cc,1.1.2.1,1.1.2.2 atk_border_template.h,1.1.2.1,1.1.2.2 joltest.cc,1.1.2.7,1.1.2.8
Date: Fri, 03 May 2002 07:42:55 -0400

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

Modified Files:
      Tag: Branch_road_to_0-4
        Makefile.am atk_border.cc atk_border.h atk_border_template.cc 
        atk_border_template.h joltest.cc 
Added Files:
      Tag: Branch_road_to_0-4
        atk_theme.cc atk_theme.h 
Log Message:
Add theme support and stuff on atk_border



--- NEW FILE ---
#include "atk_theme.h"


atk_theme::atk_theme ()
{
    
}


void atk_theme::load (const std::string & filename)
{
    /* init hash_map border */
    destroy (); 
    
    /* open file with gz stream */
    igzstream fd;
    
    if (!fd.open (filename))
    {
        std::cerr << "error atk_theme::load " <<  filename << std::endl;
        return; 
    }

    /* load name */
    name_ <<  fd; 
    
    /* start to read number of border */
    u_int8 nb_border;
    nb_border << fd; 

    // std::cout << nb_border << std::endl; 
    
    atk_border_template * tmp; 
    for (u_int8 i = 0; i < nb_border; i++)
    {
        tmp =  new atk_border_template ();
        tmp->load (fd);
        add_border (tmp); 
    }
    
    /* close the fd */
    fd.close (); 
}



void atk_theme::save (const std::string & filename)
{
    /* open a gz output stream */
    ogzstream fd;
    if (!fd.open (filename))
    {
        std::cerr << "error atk_theme::save " <<  filename << std::endl;
        return;  
    }

    /* save name */
    name_ >> fd; 
    
    /* save number of border */
    u_int8 nb_border = border_.size ();
    nb_border >> fd;

    for (std::hash_map <std::string, atk_border_template * >::iterator it = 
border_.begin (); it  != border_.end (); it++)
        it->second->save (fd); 
    
    fd.close (); 
}


std::string atk_theme::get_name () const
{
    return name_; 
}


void atk_theme::set_name (const std::string & name)
{
    name_ =  name; 
}


void atk_theme::add_border (atk_border_template * border)
{
    border_[border->get_name () ] =  border; 
}


void atk_theme::remove_border (const std::string & name)
{
    std::hash_map <std::string, atk_border_template * >::iterator it = 
border_.find (name);
    if ( it ==  border_.end ()) return;
    delete it->second;
    border_.erase (it); 
}


void atk_theme::destroy ()
{
     // free border
    for (std::hash_map <std::string, atk_border_template * >::iterator it = 
border_.begin (); it  != border_.end (); it++)
        delete it->second;
    border_.clear (); 
}


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



void atk_theme::display_info () 
{
    std::cout << "Theme name : " << name_ << std::endl;
    std::cout << "List of border : \n"; 

     
    for (std::hash_map <std::string, atk_border_template * >::iterator it = 
border_.begin (); it  != border_.end (); it++)
        it->second->display_info (); 
}






***** Error reading new file: [Errno 2] No such file or directory: 'atk_theme.h'
Index: Makefile.am
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Makefile.am,v
retrieving revision 1.80.2.24
retrieving revision 1.80.2.25
diff -C2 -r1.80.2.24 -r1.80.2.25
*** Makefile.am 11 Apr 2002 14:08:42 -0000      1.80.2.24
--- Makefile.am 3 May 2002 11:42:53 -0000       1.80.2.25
***************
*** 73,82 ****
  libgui_a_SOURCES = atk_box.cc atk_misc.cc atk_container.cc atk_label.cc \
        atk_font.cc atk_widget.cc atk_fixed.cc callback_sig.cc \
!       atk_bin.cc atk_manager.cc \
        callback_slot.h atk_box.h atk_misc.h atk_container.h \
        atk_label.h atk_font.h atk_widget.h atk_fixed.h \
        atk_bin.h atk_window.h atk_manager.h atk_window.cc\
        atk_border_template.h atk_border_template.cc \
!       atk_border.cc atk_border.h \
        callback_sig.h 
  
--- 73,82 ----
  libgui_a_SOURCES = atk_box.cc atk_misc.cc atk_container.cc atk_label.cc \
        atk_font.cc atk_widget.cc atk_fixed.cc callback_sig.cc \
!       atk_bin.cc atk_manager.cc atk_theme.cc\
        callback_slot.h atk_box.h atk_misc.h atk_container.h \
        atk_label.h atk_font.h atk_widget.h atk_fixed.h \
        atk_bin.h atk_window.h atk_manager.h atk_window.cc\
        atk_border_template.h atk_border_template.cc \
!       atk_border.cc atk_border.h atk_theme.h\
        callback_sig.h 
  

Index: atk_border.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/atk_border.cc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** atk_border.cc       5 Apr 2002 19:59:19 -0000       1.1.2.1
--- atk_border.cc       3 May 2002 11:42:53 -0000       1.1.2.2
***************
*** 20,24 ****
  {    
      /*init tab */
!     for (int i = 0; i < 8; i++)
      {
          img_[i] = NULL; 
--- 20,24 ----
  {    
      /*init tab */
!     for (int i = 0; i < atk_border_template::_LAST; i++)
      {
          img_[i] = NULL; 
***************
*** 58,62 ****
  void atk_border::clear ()
  {
!     for (int i = 0; i < 8; i++)
      {
          delete img_[i];
--- 58,62 ----
  void atk_border::clear ()
  {
!     for (int i = 0; i < atk_border_template::_LAST; i++)
      {
          delete img_[i];
***************
*** 73,76 ****
--- 73,81 ----
      return btempl_; 
  }
+ 
+ 
+ 
+ 
+ 
  
  

Index: atk_border.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/atk_border.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** atk_border.h        5 Apr 2002 19:59:19 -0000       1.1.2.1
--- atk_border.h        3 May 2002 11:42:53 -0000       1.1.2.2
***************
*** 85,92 ****
  
      /* image with no brightness */
!     image * img_[8];
  
      /* image with brightness */
!     image * imgbright_[8];
  
      /* image use to draw */
--- 85,92 ----
  
      /* image with no brightness */
!     image * img_[atk_border_template::_LAST];
  
      /* image with brightness */
!     image * imgbright_[atk_border_template::_LAST];
  
      /* image use to draw */

Index: atk_border_template.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/atk_border_template.cc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** atk_border_template.cc      5 Apr 2002 19:59:19 -0000       1.1.2.1
--- atk_border_template.cc      3 May 2002 11:42:53 -0000       1.1.2.2
***************
*** 20,33 ****
  atk_border_template::atk_border_template ()
  {
!     for (int i = 0; i < 8; i++) img_[i] = NULL; 
  }
  
  
! void atk_border_template::load (igzstream is)
  {
      // free memory before
      destroy ();
      
!     for (int i = 0; i < 8; i++)
      {
          img_[i] = new image;
--- 20,34 ----
  atk_border_template::atk_border_template ()
  {
!     for (int i = 0; i < _LAST; i++) img_[i] = NULL; 
  }
  
  
! void atk_border_template::load (igzstream & is)
  {
      // free memory before
      destroy ();
+     name_ << is ; 
      
!     for (int i = 0; i < _LAST; i++)
      {
          img_[i] = new image;
***************
*** 37,43 ****
  
  
! void atk_border_template::save (ogzstream os)
  {
!     for (int i = 0; i < 8; i++) 
          img_[i]->put (os); 
  }
--- 38,45 ----
  
  
! void atk_border_template::save (ogzstream & os)
  {
!     name_ >> os; 
!     for (int i = 0; i < _LAST; i++) 
          img_[i]->put (os); 
  }
***************
*** 50,58 ****
  
  
  
  
  void atk_border_template::destroy ()
  {
!     for (int i = 0; i < 8; i++)
      {
          delete img_[i];
--- 52,74 ----
  
  
+ void atk_border_template::set (u_int8 type, image * img)
+ {
+     if (img_[type]  != NULL) delete img_[type];
+     img_[type] =  img; 
+ }
+ 
+ 
+ void atk_border_template::set (u_int8 type, std::string filename)
+ {
+     image * img = new image;
+     if ( img->load_pnm (filename) < 0)
+         std::cout << "Error on load image " << filename <<  " in 
atk_border_template::set \n"; 
+     set (type, img); 
+ }
  
  
  void atk_border_template::destroy ()
  {
!     for (int i = 0; i < _LAST; i++)
      {
          delete img_[i];
***************
*** 66,69 ****
--- 82,113 ----
      destroy (); 
  }
+ 
+ 
+ std::string atk_border_template::get_name () const
+ {
+     return name_; 
+ }
+ 
+ 
+ void atk_border_template::set_name (const std::string & name)
+ {
+     name_ =  name; 
+ }
+ 
+ 
+ void atk_border_template::display_info () const
+ {
+     std::cout << "border name : " << name_ << std::endl;
+     std::cout << "List of image : \n";
+ 
+     for (int i =  0; i < _LAST;  i++)
+         if ( img_[i]  !=  NULL) std::cout << "image " << i << " : " <<  
img_[i]->length ()
+                                           << "x" << img_[i]->height () << 
std::endl; 
+     
+ }
+ 
+ 
+ 
+ 
  
  

Index: atk_border_template.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/atk_border_template.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** atk_border_template.h       5 Apr 2002 19:59:19 -0000       1.1.2.1
--- atk_border_template.h       3 May 2002 11:42:53 -0000       1.1.2.2
***************
*** 43,47 ****
       * read a stream to load image
       */
!     void load (igzstream is);  
      
      
--- 43,47 ----
       * read a stream to load image
       */
!     void load (igzstream & is);  
      
      
***************
*** 49,54 ****
       * write image into the stream
       */
!     void save (ogzstream os); 
  
      
      
--- 49,68 ----
       * write image into the stream
       */
!     void save (ogzstream & os); 
  
+ 
+     
+     /**
+      * get name of the border
+      * @return name of the border
+      */
+     std::string get_name () const;
+ 
+ 
+     /**
+      * set name of the border
+      * @param name :  name of the border
+      */
+     void set_name (const std::string & name); 
      
      
***************
*** 60,63 ****
--- 74,98 ----
      image * get (u_int8);
  
+ 
+     /**
+      * set a image
+      * @param type of the image (corner,  border ...)
+      * @param img :  the image
+      */
+     void set (u_int8 type, image * img);  
+ 
+     
+     /**
+      * set a image
+      * @param type of the image (corner,  border ...)
+      * @param filename : filename of the image (filename must be only a pnm 
file) 
+      */
+     void set (u_int8 type, std::string filename);  
+ 
+ 
+     /**
+      * write in standart ouput border information 
+      */
+     void display_info () const;
      
  
***************
*** 70,77 ****
      typedef enum
          {
!             BORDER_TOP = 0, BORDER_BOTTOM, BORDER_LEFT, BORDER_RIGHT,
!             CORNER_TL, CORNER_TR, CORNER_BL, CORNER_BR
          } border_type;
!     
  protected :
  
--- 105,112 ----
      typedef enum
          {
!             B_TOP = 0, B_BOTTOM, B_LEFT, B_RIGHT,
!             C_TL, C_TR, C_BL, C_BR, C_EXIT,  C_RESIZE, _LAST
          } border_type;
!    
  protected :
  
***************
*** 84,89 ****
      
      /* a tab with image */
!     image * img_[8]; 
!     
  private : 
      
--- 119,127 ----
      
      /* a tab with image */
!     image * img_[_LAST]; 
! 
! 
!     /* name of the border */
!     std::string name_; 
  private : 
      
***************
*** 92,93 ****
--- 130,135 ----
  
  #endif
+ 
+ 
+ 
+ 

Index: joltest.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/joltest.cc,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -r1.1.2.7 -r1.1.2.8
*** joltest.cc  5 Apr 2002 19:59:19 -0000       1.1.2.7
--- joltest.cc  3 May 2002 11:42:53 -0000       1.1.2.8
***************
*** 11,14 ****
--- 11,16 ----
  #include "atk_manager.h"
  #include "atk_window.h"
+ #include "atk_border_template.h"
+ #include "atk_theme.h"
  #include "gametime.h"
  
***************
*** 16,23 ****
  int main (int argc, char * argv[]) 
  {
      screen::init ();
      screen::set_video_mode (640, 480, 16); 
      screen::clear (); 
!     
      
      atk_manager manager;  
--- 18,26 ----
  int main (int argc, char * argv[]) 
  {
+ 
      screen::init ();
      screen::set_video_mode (640, 480, 16); 
      screen::clear (); 
!     /*
      
      atk_manager manager;  
***************
*** 91,94 ****
--- 94,98 ----
      input_manager::cleanup();
      
+   */
      
      /* 
***************
*** 178,182 ****
--- 182,245 ----
      delete box; 
  */
+ 
+     /**
+      * SAVE A THEME
+      */
+     /*
+       atk_theme theme;
+     theme.set_name ("silverleaf");
+     
+     atk_border_template *  border;
+     border =  new atk_border_template; 
+     border->set_name ("mini"); 
+     border->set (atk_border_template::B_TOP, "silverleaf/mini/h_border.pnm");
+     border->set (atk_border_template::B_BOTTOM, 
"silverleaf/mini/h_border.pnm");
+     border->set (atk_border_template::B_LEFT, "silverleaf/mini/v_border.pnm");
+     border->set (atk_border_template::B_RIGHT, 
"silverleaf/mini/v_border.pnm");
+     border->set (atk_border_template::C_TL, 
"silverleaf/mini/corner_top_left.pnm");
+     border->set (atk_border_template::C_TR, 
"silverleaf/mini/corner_top_right.pnm");
+     border->set (atk_border_template::C_BL, 
"silverleaf/mini/corner_bottom_left.pnm");
+     border->set (atk_border_template::C_BR, 
"silverleaf/mini/corner_bottom_right.pnm");
+     border->set (atk_border_template::C_EXIT, 
"silverleaf/mini/corner_top_left.pnm");
+     border->set (atk_border_template::C_RESIZE, 
"silverleaf/mini/corner_bottom_right.pnm");
+     theme.add_border (border);
+     
+     border =  new atk_border_template; 
+     border->set_name ("normal"); 
+     border->set (atk_border_template::B_TOP, 
"silverleaf/normal/h_border.pnm");
+     border->set (atk_border_template::B_BOTTOM, 
"silverleaf/normal/h_border.pnm");
+     border->set (atk_border_template::B_LEFT, 
"silverleaf/normal/v_border.pnm");
+     border->set (atk_border_template::B_RIGHT, 
"silverleaf/normal/v_border.pnm");
+     border->set (atk_border_template::C_TL, 
"silverleaf/normal/corner_top_left.pnm");
+     border->set (atk_border_template::C_TR, 
"silverleaf/normal/corner_top_right.pnm");
+     border->set (atk_border_template::C_BL, 
"silverleaf/normal/corner_bottom_left.pnm");
+     border->set (atk_border_template::C_BR, 
"silverleaf/normal/corner_bottom_right.pnm");
+     border->set (atk_border_template::C_EXIT, 
"silverleaf/normal/corner_top_left.pnm");
+     border->set (atk_border_template::C_RESIZE, 
"silverleaf/normal/corner_bottom_right.pnm");
+     theme.add_border (border); 
+ 
+     
+     theme.save ("adontest/silverleaf.theme"); 
+ 
+     theme.display_info (); 
+     
+     */
+     
+     /**
+      * load a theme
+      **/
+     
+       atk_theme theme;
+ 
+       theme.load ("adontest/original.theme");  
+       theme.display_info (); 
+ 
+       std::cout << "\n\nLoad another theme\n\n"; 
+       
+       theme.load ("adontest/silverleaf.theme");
+       theme.display_info (); 
+ 
      return 0; 
+     
  }
  




reply via email to

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