[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Adonthell-commits] CVS: adonthell/src/gui .cvsignore, NONE, 1.1 Makefil
From: |
VENNIN Joel <address@hidden> |
Subject: |
[Adonthell-commits] CVS: adonthell/src/gui .cvsignore, NONE, 1.1 Makefile.am, NONE, 1.1 base.cc, NONE, 1.1 base.h, NONE, 1.1 container.cc, NONE, 1.1 container.h, NONE, 1.1 |
Date: |
Mon, 28 Jul 2003 08:48:44 -0400 |
Update of /cvsroot/adonthell/adonthell/src/gui
In directory subversions:/tmp/cvs-serv6005
Added Files:
.cvsignore Makefile.am base.cc base.h container.cc container.h
Log Message:
Import new source for the GUI.
--- NEW FILE ---
.deps
.libs
Makefile
Makefile.in
*.la
*.lo
--- NEW FILE ---
CXXFLAGS += -I$(top_srcdir)/src/
DEFAULT_INCLUDES = -I$(srcdir) -I$(top_builddir)
pkgincludeinputdir = $(pkgincludedir)/gui
pkgincludeinput_HEADERS = \
base.h \
container.h
lib_LTLIBRARIES = libadonthell_gui.la
libadonthell_gui_la_SOURCES = \
base.cc \
container.cc
libadonthell_gui_la_CXXFLAGS = -DPKGLIBDIR=\"$(pkglibdir)\"
libadonthell_gui_la_LIBADD = -L$(top_builddir)/src/base/ -ladonthell_base \
-L$(top_builddir)/src/input/ -ladonthell_input \
-L$(top_builddir)/src/gfx/ -ladonthell_gfx \
-lstdc++
--- NEW FILE ---
#include "gfx/screen.h"
#include "gfx/surface.h"
#include "gui/container.h"
#include "gui/base.h"
using namespace gui;
base::base (): drawing_area ()
{
m_parent = NULL;
m_x = m_y = m_padx = m_pady = 0;
m_visible = m_enable = true;
}
void base::setLocation (s_int16 nx, s_int16 ny)
{
m_x = nx;
m_y = ny;
updatePosition ();
}
void base::setSize (u_int16 nl, u_int16 nh)
{
gfx::drawing_area::resize (nl, nh);
updateSize ();
}
void base::updatePosition ()
{
if (m_parent)
gfx::drawing_area::move (m_parent->getRealX () + getX () + getPadX (),
m_parent->getRealY () + getY () + getPadY ());
else gfx::drawing_area::move (getX () + getPadX (), getY () + getPadY ());
}
bool base::update ()
{
return true;
}
bool base::draw ()
{
if (m_visible)
{
return drawContents ();
}
return false;
}
bool base::drawContents ()
{
gfx::surface * s = gfx::screen::get_surface();
if (s == NULL) return false;
//top
s->draw_line (getRealX(), getRealY(),
getRealX () + getLength () - 1, getRealY (), 0x888899, this);
//bottom
s->draw_line (getRealX(), getRealY() + getHeight () - 1,
getRealX () + getLength () - 1, getRealY () + getHeight () - 1,
0x888899, this);
//left
s->draw_line (getRealX(), getRealY(),
getRealX (), getRealY () + getHeight () - 1, 0x888899, this);
//right
s->draw_line (getRealX() + getLength () - 1, getRealY(),
getRealX () + getLength () - 1, getRealY () + getHeight () - 1,
0x888899, this);
return true;
}
void base::updateSize ()
{
}
void base::setParent (container * parent)
{
m_parent = parent;
updatePosition ();
}
gfx::drawing_area * base::getParentDrawingArea ()
{
if (m_parent) return m_parent->getDrawingArea ();
return getDrawingArea ();
}
base::~base ()
{
if (m_parent) m_parent->removeChild (this);
}
--- NEW FILE ---
#ifndef GUI_BASE_H_
#define GUI_BASE_H_
#include "gfx/drawing_area.h"
namespace gui {
class container;
class base : protected gfx::drawing_area
{
public:
base ();
s_int16 getX () const
{ return m_x; }
s_int16 getY () const
{ return m_y; }
s_int16 getPadX () const
{ return m_padx; }
s_int16 getPadY () const
{ return m_pady; }
s_int16 getRealX () const
{ return gfx::drawing_area::x (); }
s_int16 getRealY () const
{ return gfx::drawing_area::y (); }
u_int16 getHeight () const
{ return gfx::drawing_area::height (); }
u_int16 getLength () const
{ return gfx::drawing_area::length (); }
virtual void setLocation (s_int16 nx, s_int16 ny);
virtual bool update ();
bool draw (); //gfx::drawing_area * da);
virtual bool drawContents ();
void assignArea (gfx::drawing_area * da)
{ this->assign_drawing_area (da); }
void detachArea ()
{ this->detach_drawing_area (); }
virtual void updatePosition ();
virtual void updateSize ();
void setSize (u_int16 nl, u_int16 nh);
void setVisible (const bool b)
{ m_visible = b; }
bool isVisible () const
{ return m_visible;}
void setEnable (const bool b)
{ m_enable = b; }
bool isEnable () const
{ return m_enable; }
void setParent (container * parent);
container * getParent ()
{ return m_parent; }
gfx::drawing_area * getDrawingArea ()
{ return (gfx::drawing_area*) this; }
gfx::drawing_area * getParentDrawingArea ();
virtual ~base ();
protected:
s_int16 m_x; //virtual position
s_int16 m_y; //virutal position
s_int16 m_padx; // x padding
s_int16 m_pady; // y padding
bool m_visible; //if the object is visible
// bool m_focus; // if the object has focus
bool m_enable; // if the object is enable
container * m_parent; // a pointer to his parent
private:
};
}
#endif
--- NEW FILE ---
#include "gui/container.h"
using namespace gui;
void container::addChild (base * m)
{
m_childs.push_back (m);
m->setParent (this);
m->updatePosition ();
// WARNING: I think update layout must be called manually
// because if there is a lot's of childs it can take a long time ...
updateLayout ();
}
void container::removeChild (base * m)
{
m_childs.remove (m);
m->setParent (NULL);
m->updatePosition ();
updateLayout ();
}
void container::updatePosition ()
{
base::updatePosition (); // update his position
for (ListChild::iterator i = m_childs.begin (); i!= m_childs.end (); ++i)
(*i)->updatePosition ();
}
void container::updateLayout ()
{
// by default no layout ...
// we can imagine a solution with a pluggable system
// to set a specific manage
}
void container::destroyAll ()
{
for (ListChild::iterator i = m_childs.begin (); i!= m_childs.end (); ++i)
delete *i;
m_childs.clear ();
}
bool container::drawContents ()
{
if (base::drawContents ())
{
for (ListChild::iterator i = m_childs.begin (); i!= m_childs.end (); ++i)
{
(*i)->assignArea (this);
(*i)->draw ();
(*i)->detachArea ();
}
}
return false;
}
container::~container ()
{
destroyAll ();
if (m_parent) m_parent->removeChild (this);
}
--- NEW FILE ---
#ifndef GUI_PARENT_H_
#define GUI_PARENT_H_
#include<list>
#include "gui/base.h"
namespace gui {
class container : public base
{
public:
virtual void addChild (base * m);
virtual void removeChild (base * m);
virtual void updatePosition ();
virtual void updateLayout ();
virtual bool drawContents ();
void destroyAll ();
virtual ~container ();
protected:
typedef std::list <base * > ListChild;
ListChild m_childs;
};
}
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Adonthell-commits] CVS: adonthell/src/gui .cvsignore, NONE, 1.1 Makefile.am, NONE, 1.1 base.cc, NONE, 1.1 base.h, NONE, 1.1 container.cc, NONE, 1.1 container.h, NONE, 1.1,
VENNIN Joel <address@hidden> <=
- Prev by Date:
[Adonthell-commits] CVS: adonthell/src/gfx/sdl surface_sdl.cc, 1.3, 1.4
- Next by Date:
[Adonthell-commits] CVS: adonthell/test guitest.py, NONE, 1.1 Makefile.am, 1.2, 1.3
- Previous by thread:
[Adonthell-commits] CVS: adonthell/src/gfx/sdl surface_sdl.cc, 1.3, 1.4
- Next by thread:
[Adonthell-commits] CVS: adonthell/test guitest.py, NONE, 1.1 Makefile.am, 1.2, 1.3
- Index(es):