[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Adonthell-commits] CVS: adonthell/src/gui Makefile.am,1.1.2.5,1.1.2.6 b
From: |
VENNIN Joel <address@hidden> |
Subject: |
[Adonthell-commits] CVS: adonthell/src/gui Makefile.am,1.1.2.5,1.1.2.6 base.h,1.1.2.2,1.1.2.3 event.h,1.1.2.2,1.1.2.3 label.cc,1.1.2.1,1.1.2.2 label.h,1.1.2.2,1.1.2.3 label_input.cc,1.1.2.1,1.1.2.2 label_input.h,1.1.2.1,1.1.2.2 write.h,1.1.2.1,NONE |
Date: |
Mon, 17 Feb 2003 12:13:17 -0500 |
Update of /cvsroot/adonthell/adonthell/src/gui
In directory subversions:/tmp/cvs-serv31011/gui
Modified Files:
Tag: Branch_road_to_0-4
Makefile.am base.h event.h label.cc label.h label_input.cc
label_input.h
Removed Files:
Tag: Branch_road_to_0-4
write.h
Log Message:
Remove some files, update some code.
Last commit before TTF support.
Index: Makefile.am
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gui/Attic/Makefile.am,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -r1.1.2.5 -r1.1.2.6
*** Makefile.am 1 Feb 2003 14:39:40 -0000 1.1.2.5
--- Makefile.am 17 Feb 2003 17:13:14 -0000 1.1.2.6
***************
*** 4,11 ****
container.cc font.cc keys.cc \
manager.cc scrollbar.cc scroll.cc select_list.cc theme.cc \
! event.cc \
! font.h image.h label.h \
scrollbar.h scroll.h select_list.h theme.h keys.h event.h types.h \
! write.h manager.h object.h window.h mapview.h
CPPFLAGS = -I$(srcdir)/.. $(SDL_DEFS) $(SDL_CFLAGS) $(FT2_CFLAGS) $(PY_CFLAGS)
--- 4,11 ----
container.cc font.cc keys.cc \
manager.cc scrollbar.cc scroll.cc select_list.cc theme.cc \
! event.cc label.cc label_input.cc\
! font.h image.h label.h label_input.h\
scrollbar.h scroll.h select_list.h theme.h keys.h event.h types.h \
! manager.h object.h gui.h
CPPFLAGS = -I$(srcdir)/.. $(SDL_DEFS) $(SDL_CFLAGS) $(FT2_CFLAGS) $(PY_CFLAGS)
Index: base.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gui/Attic/base.h,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -r1.1.2.2 -r1.1.2.3
*** base.h 2 Feb 2003 23:29:11 -0000 1.1.2.2
--- base.h 17 Feb 2003 17:13:14 -0000 1.1.2.3
***************
*** 28,32 ****
#include "types.h"
! #include "input/listener.h"
#include "event.h"
--- 28,32 ----
#include "types.h"
! //#include "input/listener.h"
#include "event.h"
***************
*** 52,56 ****
* to the surface they should be drawn.
*/
! class base: public event, public border, public gfx::drawing_area, public
background, protected input::listener
{
public:
--- 52,56 ----
* to the surface they should be drawn.
*/
! class base: public event, public border, public gfx::drawing_area, public
background
{
public:
Index: event.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gui/Attic/event.h,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -r1.1.2.2 -r1.1.2.3
*** event.h 2 Feb 2003 23:29:12 -0000 1.1.2.2
--- event.h 17 Feb 2003 17:13:14 -0000 1.1.2.3
***************
*** 16,24 ****
#define GUI_EVENT_H_
#include "Python.h"
#include "python/callback.h"
#include <vector>
! #include "types.h"
#include "callback.h"
--- 16,25 ----
#define GUI_EVENT_H_
+
#include "Python.h"
#include "python/callback.h"
#include <vector>
! #include "../types.h"
#include "callback.h"
Index: label.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gui/Attic/label.cc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** label.cc 2 Jul 2002 07:20:30 -0000 1.1.2.1
--- label.cc 17 Feb 2003 17:13:14 -0000 1.1.2.2
***************
*** 2,6 ****
$Id$
! (C) Copyright 2002 Joel Vennin
Part of the Adonthell Project http://adonthell.linuxgames.com
--- 2,6 ----
$Id$
! (C) Copyright 2000/2001 Joel Vennin
Part of the Adonthell Project http://adonthell.linuxgames.com
***************
*** 17,132 ****
using namespace gui;
! label::label () : font_(NULL)
! {
}
! void label::set_text (const std::string & text)
{
- text_ = text;
- transform_in_line ();
}
! std::string & label::get_text ()
{
! return text_;
}
! void label::set_font (font & font)
{
! font_ = &font;
}
! font * label::get_font () const
{
! return font_;
}
! label::~label ()
{
! // normaly it's not necessary
! line_.clear ();
}
! void label::transform_in_line ()
{
! line_.clear ();
! u_int32 begin = 0;
! u_int32 end = 0;
! while (end < text_.length ())
{
! if (text_[end] == '\n' || end == text_.length () - 1)
{
! line_.push_back (text_.substr (begin, end - begin));
! begin = end + 1;
}
! end++;
! }
}
! void label::realize ()
{
! if (!font_) return;
! u_int32 max_line_size = 0;
! u_int32 tmp_x;
! u_int32 tmp_y;
! u_int16 i;
! // find the max line size
! for (i = 0; i < line_.size (); i++)
! if ((tmp_x = font_->get_length_of (line_[i])) > max_line_size)
! max_line_size = tmp_x;
! // calcul the height
! tmp_y = font_->get_size () * (i);
! // check if we must change size of this widget
! if (tmp_x + (get_x_padding () << 1) > get_length () && tmp_y +
(get_y_padding () << 1) > get_height ())
! set_size (tmp_x + (get_x_padding () << 1) , tmp_y + (get_y_padding ()
<< 1) );
! else if (tmp_x + (get_x_padding () << 1) > get_length ()) set_size
(tmp_x + (get_x_padding () << 1) ,get_height ());
! else if (tmp_y + (get_y_padding () << 1) > get_height ()) set_size
(get_length (), tmp_y + (get_y_padding () << 1) );
}
! bool label::draw (gfx::drawing_area * da, gfx::surface * sf)
{
! if (!misc::draw (da, sf)) return false;
! if (!font_) return false;
! s_int32 y_to_start;
! s_int32 x_to_start;
!
! // check y position to start draw
! if (get_y_alignment () == TOP) y_to_start = get_y_real () + get_y_padding
();
! else if (get_y_alignment () == BOTTOM) y_to_start = get_y_real () +
get_height () - (font_->get_size () * (line_.size ())) - get_y_padding ();
! else y_to_start = get_y_real () + (get_height () - (font_->get_size () *
(line_.size ()))) >> 1;
! for (u_int16 i = 0; i < line_.size (); i++)
{
- // search x_to_start position
- if (get_x_alignment () == LEFT) x_to_start = get_x_real () +
get_x_padding ();
- else if (get_x_alignment () == RIGHT) x_to_start = get_x_real () +
get_length () - font_->get_length_of (line_[i]) - get_x_padding ();
- else x_to_start = get_x_real () + ((get_length () -
font_->get_length_of (line_[i])) >> 1);
! // draw each line
! font_->draw (line_[i], x_to_start, y_to_start, da, sf);
!
! // go to next line
! y_to_start += font_->get_size ();
}
! return true;
}
--- 17,633 ----
using namespace gui;
! //define number of cycle of the cursour blink
! u_int16 label::cursor_blink_cycle = 75;
!
! /**
! Constructor
! */
! label::label ()
! {
! // i've no font at the beginning
! my_font_ = NULL;
!
! // init the cursor and the text vector
! init_vec_cursor ();
!
! // set my default form
! set_form (NOTHING);
!
! set_cursor_visible (false);
!
! set_cursor_moveable (false);
!
! cursor_cur_blink_ = 0;
!
! set_mask (true);
}
! /**
! Destructor
! */
! label::~label ()
{
}
! /**
! Set the font
! */
! void label::set_font (font & font)
{
! my_font_ = &font;
! // build (true);
}
! /**
! Set the text
! */
! void label::set_text (const std::string & text)
! {
! // init the vector and the cursor
! init_vec_cursor ();
!
! my_old_cursor_ = my_cursor_;
!
! // set the text
! my_text_ = text;
! my_cursor_.idx = my_text_.length ();
!
! // build the vector
! build (true);
! }
!
!
!
! /**
! Add text
! */
! void label::add_text (const std::string & text)
{
! my_old_cursor_ = my_cursor_;
!
! if (my_old_cursor_.idx == my_text_.length ())
! {
! my_text_ += text;
! my_cursor_.idx = my_text_.length ();
! }
! else my_text_.insert (my_cursor_.idx, text);
!
! build (false);
}
! /**
! REsize the label
! */
! void label::resize (u_int16 l, u_int16 h)
{
! image::resize (l, h);
! set_text (my_text_);
}
! /**
! Set the form
! */
! void label::set_form (const u_int8 form)
{
! my_form_ = form;
! build (true);
}
! /**
! Init vector and cursor
! */
! void label::init_vec_cursor ()
{
! // init the cursor
! my_cursor_.pos_x = my_cursor_.pos_y = my_cursor_.line = my_cursor_.idx =
0;
!
! // init the vector
! my_vect_.clear ();
! // create a line in the vector
! Sline_text tmp;
! tmp.pos_x = tmp.idx_beg = tmp.idx_end = 0;
!
! // add the new line at the beginning of the vector
! my_vect_.push_back (tmp);
!
! // the beginning of the display line, 0 is the first line
! start_line_ = 0;
! }
!
!
!
! /**
! Update the vector
! start : it's the index where the function must start to update
! */
! void label::build (const bool erase_all)
! {
! if (my_font_ == NULL) return;
! set_mask (false);
! switch (my_form_)
{
! case NOTHING :
! build_form_nothing ();
! update_cursor ();
! draw_string (!erase_all);
! break;
!
! case AUTO_HEIGHT :
! build_form_auto_height ();
! update_cursor ();
! draw_string (!erase_all);
! break;
!
! case AUTO_SIZE :
! build_form_auto_size ();
! update_cursor ();
! draw_string (false);
! break;
! }
! set_mask (true);
! }
!
!
!
! /**
! Set if cursor is visible
! */
! inline void label::set_cursor_visible (const bool b)
! {
! visible_cursor_ = b;
! }
!
!
! /**
! Set the cursor moveable with arrow
! */
! inline void label::set_cursor_moveable (const bool b)
! {
! moveable_cursor_ = b;
! }
!
!
! /**
! Build the label when the form set top nothing
! */
! void label::build_form_nothing ()
! {
! // temporary variable
! u_int16 j, word_length, word_length_pix, start_idx;
!
! // temporary line
! Sline_text line_tmp;
!
! // we start at the beginning index of cursor line
! line_tmp.idx_beg = my_vect_[my_old_cursor_.line].idx_beg;
! line_tmp.pos_x = 0;
!
! // we start always at the begin index of the line
! start_idx = line_tmp.idx_beg;
!
! // erase the vector
! std::vector <Sline_text>::iterator ii = my_vect_.begin ();
! u_int16 i = 0;
! while (i != my_old_cursor_.line) { i++; ii++; }
! my_vect_.erase (ii, my_vect_.end ());
!
!
! while (start_idx < my_text_.length () )
! {
! // if cur letter is an \n
! if (my_text_[start_idx] == '\n')
{
! // the last index of this line
! line_tmp.idx_end = start_idx;
!
! // add to the vector line
! my_vect_.push_back (line_tmp);
!
! // init a Sline_text
! line_tmp.pos_x = 0;
! line_tmp.idx_beg = ++start_idx;
}
! else if (my_text_[start_idx] == ' ')
! {
! if ((*my_font_) [' '].length () + line_tmp.pos_x > length ())
! {
! line_tmp.idx_end = start_idx;
!
! // add to the vector line
! my_vect_.push_back (line_tmp);
!
! // init a Sline_text
! line_tmp.pos_x = 0;
! line_tmp.idx_beg = ++start_idx;
!
! } else
! {
! line_tmp.pos_x += (*my_font_) [' '].length ();
! start_idx++;
! }
! }
! else
! {
! // find a word
!
! switch (find_word (start_idx, word_length, word_length_pix,
line_tmp.pos_x))
! {
! case 0 : // enough place
! line_tmp.pos_x += word_length_pix;
! break;
!
! case 1 : // enough place, but return at the next line
! // here we erase end of the last line
!
! if (length () && height ())
! {
!
! lock ();
! fillrect (line_tmp.pos_x,
! (my_vect_.size () - start_line_) *
my_font_->height (),
! length () - line_tmp.pos_x,
! my_font_->height (), gfx::screen::trans_col
() );
! unlock ();
! }
! line_tmp.idx_end = (start_idx - word_length) - 1;
! my_vect_.push_back (line_tmp);
!
! line_tmp.pos_x = word_length_pix;
! line_tmp.idx_beg = start_idx - word_length;
!
! break;
!
! case 2 : // not enough place
!
! j = start_idx - word_length;
! while (j < start_idx)
! {
! if (line_tmp.pos_x + (*my_font_) [my_text_[j]].length
() > length ())
! {
! line_tmp.idx_end = j - 1;
! my_vect_.push_back (line_tmp);
!
! line_tmp.pos_x = 0;
! line_tmp.idx_beg = j;
! }
! line_tmp.pos_x += (*my_font_) [my_text_[j]].length
();
! j++;
! }
! break;
! }
! }
! }
!
! // it is the last line
! line_tmp.idx_end = start_idx - 1;
! my_vect_.push_back (line_tmp);
}
! void label::build_form_auto_height ()
{
! // it's the same
! build_form_nothing ();
! // now verify if it's always the same size
! u_int16 new_size = my_vect_.size () * my_font_->height ();
! if (new_size != height ())
! {
! image tmp;
! tmp.resize (length (), new_size);
! tmp.lock ();
! tmp.fillrect (0, 0, length (), new_size, gfx::screen::trans_col ());
! tmp.unlock ();
! draw (0, 0, 0, 0, length (), my_old_cursor_.pos_y + my_font_->height
(), NULL, &tmp);
! image::resize (length (), new_size);
! tmp.draw (0, 0, NULL, this);
! }
! }
!
!
! void label::build_form_auto_size ()
! {
! // find the max height and the max length
!
! // clear the vector_
! my_vect_.clear ();
+ // temporary line
+ Sline_text line_tmp;
+
+ line_tmp.pos_x = 0;
+ line_tmp.idx_beg = 0;
+ u_int16 i = 0, max_length = 0;
+
+ while ( i < my_text_.size ())
+ {
+ if (my_text_[i] == '\n')
+ {
+ if (line_tmp.pos_x > max_length) max_length = line_tmp.pos_x;
+ line_tmp.idx_end = i;
+ my_vect_.push_back (line_tmp);
+
+ line_tmp.idx_beg = i+1;
+ line_tmp.pos_x = 0;
+ }
+ else
+ {
+ line_tmp.pos_x += (*my_font_) [my_text_[i]].length ();
+ }
+ i++;
+ }
+
+ if (line_tmp.pos_x > max_length) max_length = line_tmp.pos_x;
+ // the last line
+ line_tmp.idx_end = i-1;
+ my_vect_.push_back (line_tmp);
+
+ // now resize the label
+ image::resize (max_length, my_vect_.size () * my_font_->height ());
+ }
! void label::clean_surface (const bool erase_all)
! {
! if (length () && height ())
! {
! if ( my_cursor_.idx != my_text_.length ())
! {
! lock ();
! fillrect ( my_old_cursor_.pos_x, my_old_cursor_.pos_y, length ()
- my_old_cursor_.pos_x,
! my_font_->height (), gfx::screen::trans_col ());
! fillrect (0, my_old_cursor_.pos_y + my_font_->height (), length
(),
! height () -my_old_cursor_.pos_y + my_font_->height (),
gfx::screen::trans_col ());
! unlock ();
! } else if (erase_all)
! {
! lock ();
! fillrect (0, 0, length (), height (), gfx::screen::trans_col ());
! unlock ();
! }
! }
}
!
!
! // find a word
! // index : the word begin at the index
! // wlength : size of word
! // wlengthpix : size of word in pixel
! // length :
!
! // return 0 if enough size for this word, 1 if enough but must return on the
next line, 2 if the word is bigger than the length
! u_int8 label::find_word (u_int16 & index, u_int16 & wlength, u_int16 &
wlengthpix, const u_int16 rlength)
{
! wlength = 0;
! wlengthpix = 0;
! while (index < my_text_.length () && my_text_[index] != ' ' &&
my_text_[index] != '\n')
! {
! wlength++;
! wlengthpix += (*my_font_) [my_text_[index]].length ();
! index++;
! }
!
! // if size of word is bigger than the length of label
! if (wlengthpix < length () - rlength) return 0;
! else if (wlengthpix < length ()) return 1;
! return 2;
! }
!
!
! void label::update_cursor ()
! {
! // find the cursor position
! bool b = false;
!
! // init the blink cursor
! cursor_cur_blink_ = cursor_blink_cycle;
!
! // find the iterator line where is the cursor
! while (!b && my_cursor_.line < my_vect_.size () )
! {
! if (my_cursor_.idx >= my_vect_[my_cursor_.line].idx_beg &&
! my_cursor_.idx <= my_vect_[my_cursor_.line].idx_end ) b = true;
! else if (my_cursor_.idx > my_vect_[my_cursor_.line].idx_end)
! {
! if (my_cursor_.line == my_vect_.size () - 1) b = true;
! else my_cursor_.line++;
! }
! else if (my_cursor_.idx < my_vect_[my_cursor_.line].idx_beg)
! {
! my_cursor_.line--;
! }
! }
!
! // now find the x position of the cursor
! my_cursor_.pos_x = 0;
!
! u_int16 j = my_vect_[my_cursor_.line].idx_beg;
! while (j != my_cursor_.idx) my_cursor_.pos_x+= (*my_font_)
[my_text_[j++]].length ();
! // find y position
! my_cursor_.pos_y = (my_cursor_.line - start_line_) * my_font_->height ();
!
! if (my_cursor_.pos_y > height ())
{
!
! }
! }
!
!
!
! // if bool is false redraw all, if bool is true redraw just at beginning of
the cursor
! void label::draw_string (const bool at_cursor)
! {
! u_int16 tmp_start_line;
! u_int16 tx = 0, ty = 0;
! u_int16 idx_cur_line, j;
!
! // if not at cursor, we erase all
! clean_surface (!at_cursor);
!
! if (at_cursor)
! {
! tmp_start_line = my_old_cursor_.line;
! tx = my_old_cursor_.pos_x;
! idx_cur_line = my_old_cursor_.idx;
! ty = (tmp_start_line - start_line_) * my_font_->height ();
! }
! else
! {
! tmp_start_line = start_line_;
! idx_cur_line = my_vect_[tmp_start_line].idx_beg;
! }
!
! // draw the first line
! for (j = idx_cur_line;
! j < my_vect_[tmp_start_line].idx_end + 1 ;
! j++)
! {
! (*my_font_) [my_text_[j]].draw (tx, ty, NULL, this);
! tx += (*my_font_) [my_text_[j]].length ();
! }
! ty += my_font_->height ();
! tmp_start_line++;
!
!
! // draw another line
! while (tmp_start_line < my_vect_.size ())
! {
! tx = 0;
! for (j = my_vect_[tmp_start_line].idx_beg;
! j < my_vect_[tmp_start_line].idx_end + 1 ;
! j++)
! {
! (*my_font_) [my_text_[j]].draw (tx, ty, NULL, this);
! tx += (*my_font_) [my_text_[j]].length ();
! }
! ty += my_font_->height ();
! tmp_start_line++;
! }
! }
!
!
! bool label::update ()
! {
! if (visible_cursor_)
! {
! if (! (height () && length ())) return true;
! if (cursor_cur_blink_ == cursor_blink_cycle)
! {
! cursor_draw ();
! cursor_cur_blink_ = 0;
! }else if (cursor_cur_blink_ == (cursor_blink_cycle >> 1))
! cursor_undraw ();
! cursor_cur_blink_++;
! }
! return true;
! }
!
!
!
! void label::cursor_draw ()
! {
! // draw the cursor
! if (my_cursor_.idx == my_text_.length () || my_text_[my_cursor_.idx] ==
'\n')
! my_font_->cursor->draw (my_cursor_.pos_x, my_cursor_.pos_y,NULL,
this);
! else
! my_font_->cursor->draw (my_cursor_.pos_x, my_cursor_.pos_y,0, 0,
! (*my_font_) [my_text_[my_cursor_.idx]].length
(),
! my_font_->height (), NULL, this);
! }
!
!
!
! void label::cursor_undraw ()
! {
! // draw letter instead
! if (my_cursor_.idx == my_text_.length () || my_text_[my_cursor_.idx] ==
'\n')
! {
! lock ();
! fillrect(my_cursor_.pos_x, my_cursor_.pos_y,
! my_font_->cursor->length () ,
! my_font_->cursor->height(),
! gfx::screen::trans_col());
! unlock ();
! }
! else (*my_font_) [my_text_[my_cursor_.idx]].draw (my_cursor_.pos_x,
my_cursor_.pos_y, NULL, this);
! }
!
!
! bool label::input_update ()
! {
! if(input::has_been_pushed(KEY_CURSOR_NEXT))
! {
! if (! (height () && length ())) return true;
! cursor_undraw ();
! cursor_next ();
}
! else if (input::has_been_pushed(KEY_CURSOR_PREVIOUS))
! {
! if (! (height () && length ())) return false;
! cursor_undraw ();
! cursor_previous ();
! }
!
!
!
! return true;
}
+
+
+ void label::cursor_next ()
+ {
+ if (!moveable_cursor_) return;
+ if (my_cursor_.idx < my_text_.length ())
+ {
+ my_cursor_.idx++;
+ update_cursor ();
+ }
+ }
+
+
+ void label::cursor_previous ()
+ {
+ if (!moveable_cursor_) return;
+ if (my_cursor_.idx >0)
+ {
+ my_cursor_.idx--;
+ update_cursor ();
+ }
+ }
+
+
+ const std::string label::text_string () const
+ {
+ return my_text_;
+ }
+
+ const char * label::text_char () const
+ {
+ return my_text_.c_str ();
+ }
+
+
+
+
+
+
+
+
Index: label.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gui/Attic/label.h,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -r1.1.2.2 -r1.1.2.3
*** label.h 1 Feb 2003 14:39:40 -0000 1.1.2.2
--- label.h 17 Feb 2003 17:13:14 -0000 1.1.2.3
***************
*** 1,4 ****
/*
! $Id$
(C) Copyright 2000/2001 Joel Vennin
--- 1,4 ----
/*
!
(C) Copyright 2000/2001 Joel Vennin
***************
*** 13,24 ****
*/
! #ifndef WIN_LABEL_H_
! #define WIN_LABEL_H_
!
! #include "win_object.h"
! #include "label.h"
! typedef win_object<label> win_label;
#endif
--- 13,248 ----
*/
! #ifndef LABEL_H_
! #define LABEL_H_
! #include <vector>
! #include <string>
+ #include "gfx/image.h"
+ #include "input.h"
+ #include "font.h"
+
+ namespace gui {
+
+ class label: public gfx::image
+ {
+ public :
+ /**
+ Constructor
+ by default, cursor is not moveable, cursor is not visible, and
the form is set as NOTHING, the default size is (0, 0)
+ */
+ label ();
+
+ /**
+ Destructor
+ */
+ ~label ();
+
+ /**
+ * Set the font
+ * @param font: a font
+ */
+ void set_font (font & font);
+
+
+ /**
+ * Set the text
+ * @param text: set the text
+ */
+ void set_text (const std::string & text);
+
+
+ /**
+ * Add text
+ */
+ void add_text (const std::string & text);
+
+ /**
+ Set the form of the display
+ NOTHING, AUTO_SIZE, AUTO_HEIGHT
+ */
+ inline void set_form (const u_int8 form);
+
+ /**
+ Set visible cursor
+ */
+ inline void set_cursor_visible (const bool b);
+
+ /**
+ Set if the cursor can be moved with arrow key
+ */
+ inline void set_cursor_moveable (const bool b);
+
+ /**
+ Update the label
+ */
+ bool update ();
+
+ /**
+ Update input label, you can move the cursor if the cursor is moveable
+ */
+ bool input_update ();
+
+ /**
+ Get the text in string
+ */
+ const std::string text_string () const;
+
+ /**
+ Get the text in char
+ */
+ const char * text_char () const;
+
+ /**
+ Resize the label
+ */
+ void resize (u_int16 l, u_int16 h);
+
+
+ #ifdef SWIG
+
+ #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;
+
+ #endif
+
+ #ifndef SWIG
+
+ static const u_int8 NOTHING = 0;
+ static const u_int8 AUTO_HEIGHT = 1;
+ static const u_int8 AUTO_SIZE = 2;
+
+
+ const static SDLKey KEY_CURSOR_NEXT = SDLK_RIGHT;
+ const static SDLKey KEY_CURSOR_PREVIOUS = SDLK_LEFT;
+
+
+
+ protected :
+
+ struct Sline_text
+ {
+ u_int16 idx_beg;
+ s_int16 idx_end;
+ u_int16 pos_x;
+ };
+
+ struct Scursor
+ {
+ u_int16 pos_x;
+ u_int16 pos_y;
+ u_int16 idx;
+ u_int16 line;
+ };
+
+ /**
+ Init vector and cursor, don't erase my_text_
+ */
+ void init_vec_cursor ();
+
+
+ /**
+ Build label
+
+ */
+ void build(const bool erase_all);
+
+
+ /**
+
+ */
+ void build_form_nothing ();
+
+
+ /**
+
+ */
+ void build_form_auto_height ();
+
+ /**
+ */
+ void build_form_auto_size();
+
+ /**
+
+ */
+ void clean_surface (const bool erase_all);
+
+ /**
+ */
+ u_int8 find_word (u_int16 & index, u_int16 & wlength, u_int16 &
wlengthpix, const u_int16 rlength);
+
+ /**
+ */
+ void draw_string (const bool at_cursor);
+
+
+ /**
+
+ */
+ void update_cursor ();
+
+ /**
+ */
+ void cursor_next ();
+
+ /**
+ */
+
+ void cursor_previous ();
+
+ /**
+ */
+ void cursor_draw ();
+
+ void cursor_undraw ();
+
+
+ // my_font
+ font * my_font_;
+
+
+ // my text
+ std::string my_text_;
+
+ // form display
+ u_int8 my_form_;
+
+
+ // visible cursor
+ bool visible_cursor_;
+
+ // moveable_cursor
+ bool moveable_cursor_;
+
+
+ u_int16 cursor_cur_blink_;
+
+
+ static u_int16 cursor_blink_cycle;
+
+ // my cursor
+ Scursor my_cursor_;
+
+ // my old cursor
+ Scursor my_old_cursor_;
+
+ // it is a vector which represent each line in the label
+ std::vector<Sline_text> my_vect_;
+
+ u_int16 start_line_;
+
#endif
+ // it's the endif of swig
+
+ };
+ }
+ #endif
+
+
+
Index: label_input.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gui/Attic/label_input.cc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** label_input.cc 1 Feb 2003 17:17:37 -0000 1.1.2.1
--- label_input.cc 17 Feb 2003 17:13:14 -0000 1.1.2.2
***************
*** 16,19 ****
--- 16,21 ----
#include "label_input.h"
+ using namespace gui;
+
label_input::label_input () : label ()
{
***************
*** 50,54 ****
fillrect (my_cursor_.pos_x, my_cursor_.pos_y,
(*my_font_) [my_text_[my_cursor_.idx]].length (),
! my_font_->height (), screen::trans_col ());
unlock ();
--- 52,56 ----
fillrect (my_cursor_.pos_x, my_cursor_.pos_y,
(*my_font_) [my_text_[my_cursor_.idx]].length (),
! my_font_->height (), gfx::screen::trans_col ());
unlock ();
Index: label_input.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gui/Attic/label_input.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** label_input.h 1 Feb 2003 17:17:37 -0000 1.1.2.1
--- label_input.h 17 Feb 2003 17:13:14 -0000 1.1.2.2
***************
*** 17,44 ****
#include "label.h"
!
! class label_input : public label
! {
! public:
! /**
! Constructor
! Initialize to : cursor_moveable, cursor_visible and editable
! */
! label_input ();
!
! /**
! Set the label input in editable
! */
! void set_editable (const bool);
!
! /**
Input update
! */
! bool input_update();
!
! protected:
! bool editable_;
! };
!
#endif
--- 17,45 ----
#include "label.h"
! namespace gui {
!
! class label_input : public gui::label
! {
! public:
! /**
! Constructor
! Initialize to : cursor_moveable, cursor_visible and editable
! */
! label_input ();
!
! /**
! Set the label input in editable
! */
! void set_editable (const bool);
!
! /**
Input update
! */
! bool input_update();
!
! protected:
! bool editable_;
! };
! }
#endif
--- write.h DELETED ---
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Adonthell-commits] CVS: adonthell/src/gui Makefile.am,1.1.2.5,1.1.2.6 base.h,1.1.2.2,1.1.2.3 event.h,1.1.2.2,1.1.2.3 label.cc,1.1.2.1,1.1.2.2 label.h,1.1.2.2,1.1.2.3 label_input.cc,1.1.2.1,1.1.2.2 label_input.h,1.1.2.1,1.1.2.2 write.h,1.1.2.1,NONE,
VENNIN Joel <address@hidden> <=
- Prev by Date:
[Adonthell-commits] CVS: adonthell/src label.cc,1.8,NONE label.h,1.5,NONE
- Next by Date:
[Adonthell-commits] CVS: adonthell/src time_event.cc,1.5,1.6
- Previous by thread:
[Adonthell-commits] CVS: adonthell/src label.cc,1.8,NONE label.h,1.5,NONE
- Next by thread:
[Adonthell-commits] CVS: adonthell/src time_event.cc,1.5,1.6
- Index(es):