added Notebook
This commit is contained in:
parent
0e0e9e164f
commit
00d2670b10
livesupport/modules/widgets
etc
include/LiveSupport/Widgets
src
BlueBin.cxxButton.cxxButtonImages.cxxComboBoxText.cxxImageButton.cxxNotebook.cxxTestWindow.cxxTestWindow.hWidgetFactory.cxx
var/tabButton
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: maroy $
|
||||
# Version : $Revision: 1.8 $
|
||||
# Version : $Revision: 1.9 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/etc/Makefile.in,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -113,7 +113,9 @@ WIDGETS_LIB_OBJS = ${TMP_DIR}/ImageButton.o \
|
|||
${TMP_DIR}/EntryBin.o \
|
||||
${TMP_DIR}/WhiteWindow.o \
|
||||
${TMP_DIR}/CornerImages.o \
|
||||
${TMP_DIR}/ButtonImages.o \
|
||||
${TMP_DIR}/ComboBoxText.o \
|
||||
${TMP_DIR}/Notebook.o \
|
||||
${TMP_DIR}/WidgetFactory.o
|
||||
TEST_EXE_OBJS = ${TMP_DIR}/TestWindow.o \
|
||||
${TMP_DIR}/main.o
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/Button.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -44,6 +44,7 @@
|
|||
#include <gtkmm/label.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Widgets/ButtonImages.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
|
@ -63,7 +64,7 @@ using namespace LiveSupport::Core;
|
|||
* A button holding a text.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.3 $
|
||||
* @version $Revision: 1.4 $
|
||||
*/
|
||||
class Button : public Gtk::Button
|
||||
{
|
||||
|
@ -73,6 +74,11 @@ class Button : public Gtk::Button
|
|||
*/
|
||||
typedef enum { passiveState, rollState, selectedState } State;
|
||||
|
||||
/**
|
||||
* The font definition used in the button.
|
||||
*/
|
||||
static const std::string fontDefinition;
|
||||
|
||||
/**
|
||||
* The Gdk::Window object, used to draw inside this button.
|
||||
*/
|
||||
|
@ -84,9 +90,14 @@ class Button : public Gtk::Button
|
|||
Glib::RefPtr<Gdk::GC> gc;
|
||||
|
||||
/**
|
||||
* The text displayed inside the button.
|
||||
* The widget inside the button.
|
||||
*/
|
||||
Gtk::Label * label;
|
||||
Gtk::Widget * child;
|
||||
|
||||
/**
|
||||
* The text label for the button.
|
||||
*/
|
||||
Glib::ustring label;
|
||||
|
||||
/**
|
||||
* The state of the button.
|
||||
|
@ -94,34 +105,15 @@ class Button : public Gtk::Button
|
|||
State state;
|
||||
|
||||
/**
|
||||
* The left image for the passive state of the button.
|
||||
* The non-interactive state of the button
|
||||
* (not rollover, either passive or selected)
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> passiveImageLeft;
|
||||
State stationaryState;
|
||||
|
||||
/**
|
||||
* The center image for the passive state of the button.
|
||||
* The button images.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> passiveImageCenter;
|
||||
|
||||
/**
|
||||
* The right image for the passive state of the button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> passiveImageRight;
|
||||
|
||||
/**
|
||||
* The left image of the button, when the mouse hovers above it.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImageLeft;
|
||||
|
||||
/**
|
||||
* The center image of the button, when the mouse hovers above it.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImageCenter;
|
||||
|
||||
/**
|
||||
* The right image of the button, when the mouse hovers above it.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImageRight;
|
||||
Ptr<ButtonImages>::Ref buttonImages;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
|
@ -240,34 +232,19 @@ class Button : public Gtk::Button
|
|||
* Constructor, with only one state.
|
||||
*
|
||||
* @param label the text to display in the button
|
||||
* @param leftImage the left image for the button
|
||||
* @param centerImage the center image for the button
|
||||
* @param rightImage the right image for the button
|
||||
* @param buttonImages the images of the button
|
||||
*/
|
||||
Button(const Glib::ustring & label,
|
||||
Glib::RefPtr<Gdk::Pixbuf> leftImage,
|
||||
Glib::RefPtr<Gdk::Pixbuf> centerImage,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rightImage) throw ();
|
||||
Ptr<ButtonImages>::Ref buttonImages) throw ();
|
||||
|
||||
/**
|
||||
* Constructor, with a rollover state.
|
||||
* Passive and rollover images are expected to be of the same size.
|
||||
* Constructor, with only one state.
|
||||
*
|
||||
* @param label the text to display in the button
|
||||
* @param passiveImageLeft the left image for the button, passive
|
||||
* @param passiveImageCenter the center image for the button, passive
|
||||
* @param passiveImageRight the right image for the button, passive
|
||||
* @param rollImageLeft the left image for the button, onmouseover
|
||||
* @param rollImageCenter the center image for the button, onmouseover
|
||||
* @param rollImageRight the right image for the button, onmouseover
|
||||
* @param child the widget that should be displayed inside the button.
|
||||
* @param buttonImages the images of the button
|
||||
*/
|
||||
Button(const Glib::ustring & label,
|
||||
Glib::RefPtr<Gdk::Pixbuf> passiveImageLeft,
|
||||
Glib::RefPtr<Gdk::Pixbuf> passiveImageCenter,
|
||||
Glib::RefPtr<Gdk::Pixbuf> passiveImageRight,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImageLeft,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImageCenter,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImageRight) throw ();
|
||||
Button(Gtk::Widget * child,
|
||||
Ptr<ButtonImages>::Ref buttonImages) throw ();
|
||||
|
||||
/**
|
||||
* A virtual destructor.
|
||||
|
@ -283,7 +260,13 @@ class Button : public Gtk::Button
|
|||
virtual void
|
||||
set_label(const Glib::ustring & label) throw ()
|
||||
{
|
||||
this->label->set_label(label);
|
||||
if (child && child->is_managed_()) {
|
||||
delete child;
|
||||
}
|
||||
this->label = label;
|
||||
child = Gtk::manage(new Gtk::Label(label));
|
||||
child->modify_font(Pango::FontDescription(fontDefinition));
|
||||
child->set_parent(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -294,7 +277,27 @@ class Button : public Gtk::Button
|
|||
Glib::ustring
|
||||
get_label(void) const throw ()
|
||||
{
|
||||
return this->label->get_label();
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the state of the button to selected.
|
||||
*/
|
||||
void
|
||||
select(void) throw ()
|
||||
{
|
||||
state = selectedState;
|
||||
stationaryState = selectedState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the state of the button to passive.
|
||||
*/
|
||||
void
|
||||
unselect(void) throw ()
|
||||
{
|
||||
state = passiveState;
|
||||
stationaryState = passiveState;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,200 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/ButtonImages.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef LiveSupport_Widgets_ButtonImages_h
|
||||
#define LiveSupport_Widgets_ButtonImages_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "gdkmm/pixbuf.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Widgets {
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* A helper class to hold a set of images related to buttons.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class ButtonImages
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* Load an image relative the path, and signal error if not found.
|
||||
*
|
||||
* @param path the path to find the image for.
|
||||
* @param imageName the name of the image, relative to path
|
||||
* @return the loaded image
|
||||
* @exception std::invalid_argument if the image was not found
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf>
|
||||
loadImage(const std::string path,
|
||||
const std::string imageName)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* The passive left image for the button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> passiveImageLeft;
|
||||
|
||||
/**
|
||||
* The passive center image for the button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> passiveImageCenter;
|
||||
|
||||
/**
|
||||
* The passive right image for the button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> passiveImageRight;
|
||||
|
||||
/**
|
||||
* The rollover left image for the button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImageLeft;
|
||||
|
||||
/**
|
||||
* The rollover center image for the button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImageCenter;
|
||||
|
||||
/**
|
||||
* The rollover right image for the button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImageRight;
|
||||
|
||||
/**
|
||||
* The selected left image for the button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> selectedImageLeft;
|
||||
|
||||
/**
|
||||
* The selected center image for the button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> selectedImageCenter;
|
||||
|
||||
/**
|
||||
* The selected right image for the button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> selectedImageRight;
|
||||
|
||||
/**
|
||||
* The default constructor.
|
||||
*/
|
||||
ButtonImages(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with image references.
|
||||
* If any of the images is not available, the result is undefined.
|
||||
*
|
||||
* @param passiveImageLeft the passive left image
|
||||
* @param passiveImageCenter the passive center image
|
||||
* @param passiveImageRight the passive right image
|
||||
* @param rollImageLeft the left rollover image
|
||||
* @param rollImageCenter the center rollover image
|
||||
* @param rollImageRight the right rollover image
|
||||
* @param selectedImageLeft the left rollover image
|
||||
* @param selectedImageCenter the center rollover image
|
||||
* @param selectedImageRight the right rollover image
|
||||
*/
|
||||
ButtonImages(Glib::RefPtr<Gdk::Pixbuf> passiveImageLeft,
|
||||
Glib::RefPtr<Gdk::Pixbuf> passiveImageCenter,
|
||||
Glib::RefPtr<Gdk::Pixbuf> passiveImageRight,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImageLeft,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImageCenter,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImageRight,
|
||||
Glib::RefPtr<Gdk::Pixbuf> selectedImageLeft,
|
||||
Glib::RefPtr<Gdk::Pixbuf> selectedImageCenter,
|
||||
Glib::RefPtr<Gdk::Pixbuf> selectedImageRight)
|
||||
throw ()
|
||||
{
|
||||
this->passiveImageLeft = passiveImageLeft;
|
||||
this->passiveImageCenter = passiveImageCenter;
|
||||
this->passiveImageRight = passiveImageRight;
|
||||
this->rollImageLeft = rollImageLeft;
|
||||
this->rollImageCenter = rollImageCenter;
|
||||
this->rollImageRight = rollImageRight;
|
||||
this->selectedImageLeft = selectedImageLeft;
|
||||
this->selectedImageCenter = selectedImageCenter;
|
||||
this->selectedImageRight = selectedImageRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor based on a path, where all the images can be loaded
|
||||
* from.
|
||||
*
|
||||
* @param path the path where all the images can be loaded from.
|
||||
*/
|
||||
ButtonImages(const std::string path) throw ();
|
||||
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
virtual
|
||||
~ButtonImages(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Widgets
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // LiveSupport_Widgets_ButtonImages_h
|
||||
|
|
@ -0,0 +1,326 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/Notebook.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef LiveSupport_Widgets_Notebook_h
|
||||
#define LiveSupport_Widgets_Notebook_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <gtkmm/table.h>
|
||||
#include <gtkmm/buttonbox.h>
|
||||
#include <gtkmm/alignment.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Widgets/CornerImages.h"
|
||||
#include "LiveSupport/Widgets/ImageButton.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Widgets {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* A container holding a range of children, showing one a time, in tabs.
|
||||
*
|
||||
* After adding pages to a Notebook object, call the function pagesAdded().
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class Notebook : public Gtk::Alignment
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* A container class, holding all that is needed to represent
|
||||
* a page in the notepad.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class Page
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* The Notebook this page is contained in.
|
||||
*/
|
||||
Notebook * notebook;
|
||||
|
||||
/**
|
||||
* The index of the page.
|
||||
*/
|
||||
unsigned int index;
|
||||
|
||||
/**
|
||||
* The container for the widget.
|
||||
*/
|
||||
Gtk::Alignment * container;
|
||||
|
||||
/**
|
||||
* The contents of the page.
|
||||
*/
|
||||
Gtk::Widget * widget;
|
||||
|
||||
/**
|
||||
* The button of the page.
|
||||
*/
|
||||
Button * button;
|
||||
|
||||
/**
|
||||
* Signal handler for the tab button clicked.
|
||||
*/
|
||||
virtual void
|
||||
onTabClicked(void) throw ()
|
||||
{
|
||||
notebook->activatePage(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param notebook the notebook this page is contained in.
|
||||
* @param index the index of the page.
|
||||
* @param widget the widget of the page.
|
||||
* @param button the button of the page.
|
||||
*/
|
||||
Page(Notebook * notebook,
|
||||
unsigned int index,
|
||||
Gtk::Widget * widget,
|
||||
Button * button) throw ()
|
||||
{
|
||||
this->notebook = notebook;
|
||||
this->index = index;
|
||||
this->widget = widget;
|
||||
this->button = button;
|
||||
|
||||
container = new Gtk::Alignment;
|
||||
container->add(*widget);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual
|
||||
~Page(void) throw ()
|
||||
{
|
||||
delete container;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The list type, for the list of pages.
|
||||
*/
|
||||
typedef std::vector<Page*> PageList;
|
||||
|
||||
/**
|
||||
* The list of pages in the notebook.
|
||||
*/
|
||||
PageList pageList;
|
||||
|
||||
/**
|
||||
* The layout of the window.
|
||||
*/
|
||||
Gtk::Table * layout;
|
||||
|
||||
/**
|
||||
* The horizontal box holding the tabs.
|
||||
*/
|
||||
Gtk::HBox * tabBox;
|
||||
|
||||
/**
|
||||
* The container for the displaying a page at a time.
|
||||
*/
|
||||
Gtk::Alignment * pageHolder;
|
||||
|
||||
/**
|
||||
* The index of the current active page.
|
||||
*/
|
||||
unsigned int activePage;
|
||||
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Handle the size request event.
|
||||
*
|
||||
* @param requisition the size request, also being the ouptut
|
||||
* parameter.
|
||||
*/
|
||||
virtual void
|
||||
on_size_request(Gtk::Requisition* requisition)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Handle the size allocate event.
|
||||
*
|
||||
* @param allocation the allocated size.
|
||||
*/
|
||||
virtual void
|
||||
on_size_allocate(Gtk::Allocation& allocation)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Handle the map event.
|
||||
*/
|
||||
virtual void
|
||||
on_map() throw ();
|
||||
|
||||
/**
|
||||
* Handle the unmap event.
|
||||
*/
|
||||
virtual void
|
||||
on_unmap() throw ();
|
||||
|
||||
/**
|
||||
* Handle the realize event.
|
||||
*/
|
||||
virtual void
|
||||
on_realize() throw ();
|
||||
|
||||
/**
|
||||
* Handle the unrealize event.
|
||||
*/
|
||||
virtual void
|
||||
on_unrealize() throw ();
|
||||
|
||||
/**
|
||||
* Handle the expose event.
|
||||
*
|
||||
* @param event the actual expose event recieved.
|
||||
* @return true if something was drawn (?)
|
||||
*/
|
||||
virtual bool
|
||||
on_expose_event(GdkEventExpose* event) throw ();
|
||||
|
||||
/**
|
||||
* Execute a function on all children of this container.
|
||||
*
|
||||
* @param includeInternals true if the callback function should
|
||||
* also be called on the internals, false otherwise.
|
||||
* @param callback the callback function to execute on the children.
|
||||
* @param callbackData the data passed to the callback function.
|
||||
*/
|
||||
virtual void
|
||||
forall_vfunc(gboolean includeInternals,
|
||||
GtkCallback callback,
|
||||
gpointer callbackData)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Handle the add event.
|
||||
*
|
||||
* @param child the child being added to the widget.
|
||||
*/
|
||||
virtual void
|
||||
on_add(Gtk::Widget* child) throw ();
|
||||
|
||||
/**
|
||||
* Handle the remove event.
|
||||
*
|
||||
* @param child the child to remove from the widget.
|
||||
*/
|
||||
virtual void
|
||||
on_remove(Gtk::Widget* child) throw ();
|
||||
|
||||
/**
|
||||
* Tell what kind of children this container accepts.
|
||||
*
|
||||
* @return the type of children this container accepts.
|
||||
*/
|
||||
virtual GtkType
|
||||
child_type_vfunc() const throw ();
|
||||
|
||||
/**
|
||||
* Call this function after finished adding pages to this object.
|
||||
* This call will make the object prepare the visuals to display.
|
||||
*/
|
||||
virtual void
|
||||
pagesAdded(void) throw ();
|
||||
|
||||
/**
|
||||
* Make a specific page active.
|
||||
*
|
||||
* @param pageNo the index of the page to make active.
|
||||
*/
|
||||
virtual void
|
||||
activatePage(unsigned int pageNo) throw ();
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
Notebook() throw ();
|
||||
|
||||
/**
|
||||
* A virtual destructor.
|
||||
*/
|
||||
virtual
|
||||
~Notebook(void) throw ();
|
||||
|
||||
/**
|
||||
* Append a page to the notebook.
|
||||
*
|
||||
* @param widget the widget that is the page itself.
|
||||
* @param label the label of the page.
|
||||
*/
|
||||
void
|
||||
appendPage(Gtk::Widget & widget,
|
||||
const Glib::ustring & label) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Widgets
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // LiveSupport_Widgets_Notebook_h
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.6 $
|
||||
Version : $Revision: 1.7 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -45,6 +45,7 @@
|
|||
#include "LiveSupport/Core/Configurable.h"
|
||||
|
||||
#include "LiveSupport/Widgets/CornerImages.h"
|
||||
#include "LiveSupport/Widgets/ButtonImages.h"
|
||||
#include "LiveSupport/Widgets/Button.h"
|
||||
#include "LiveSupport/Widgets/ImageButton.h"
|
||||
#include "LiveSupport/Widgets/ComboBoxText.h"
|
||||
|
@ -84,7 +85,7 @@ using namespace LiveSupport::Core;
|
|||
* </code></pre>
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.6 $
|
||||
* @version $Revision: 1.7 $
|
||||
*/
|
||||
class WidgetFactory :
|
||||
virtual public Configurable
|
||||
|
@ -93,7 +94,12 @@ class WidgetFactory :
|
|||
/**
|
||||
* The types of available buttons.
|
||||
*/
|
||||
typedef enum { deleteButton } ButtonType;
|
||||
typedef enum { pushButton, tabButton } ButtonType;
|
||||
|
||||
/**
|
||||
* The types of available image buttons.
|
||||
*/
|
||||
typedef enum { deleteButton } ImageButtonType;
|
||||
|
||||
|
||||
private:
|
||||
|
@ -113,34 +119,14 @@ class WidgetFactory :
|
|||
std::string path;
|
||||
|
||||
/**
|
||||
* The passive left image for the button.
|
||||
* The images for the standard button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> buttonPassiveImageLeft;
|
||||
Ptr<ButtonImages>::Ref buttonImages;
|
||||
|
||||
/**
|
||||
* The passive center image for the button.
|
||||
* The images for the tab button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> buttonPassiveImageCenter;
|
||||
|
||||
/**
|
||||
* The passive right image for the button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> buttonPassiveImageRight;
|
||||
|
||||
/**
|
||||
* The rollover left image for the button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> buttonRollImageLeft;
|
||||
|
||||
/**
|
||||
* The rollover center image for the button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> buttonRollImageCenter;
|
||||
|
||||
/**
|
||||
* The rollover right image for the button.
|
||||
*/
|
||||
Glib::RefPtr<Gdk::Pixbuf> buttonRollImageRight;
|
||||
Ptr<ButtonImages>::Ref tabButtonImages;
|
||||
|
||||
/**
|
||||
* The corner images for the blue bin.
|
||||
|
@ -245,10 +231,13 @@ class WidgetFactory :
|
|||
* object properly.
|
||||
*
|
||||
* @param label the label shown inside the button.
|
||||
* @param type the type of the button to create
|
||||
* @return a button with the specified label.
|
||||
*/
|
||||
Button *
|
||||
createButton(const Glib::ustring & label) throw ();
|
||||
createButton(const Glib::ustring & label,
|
||||
ButtonType type = pushButton)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Create a stock button.
|
||||
|
@ -259,7 +248,7 @@ class WidgetFactory :
|
|||
* @return a button of the requested type, or 0
|
||||
*/
|
||||
ImageButton *
|
||||
createButton(ButtonType type) throw ();
|
||||
createButton(ImageButtonType type) throw ();
|
||||
|
||||
/**
|
||||
* Create a combo box, that holds text entries.
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/BlueBin.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -225,6 +225,8 @@ BlueBin :: on_unmap() throw ()
|
|||
void
|
||||
BlueBin :: on_realize() throw ()
|
||||
{
|
||||
// trick to make GTK-- allocate a window for the later get_window() call
|
||||
set_flags(Gtk::NO_WINDOW);
|
||||
Gtk::Bin::on_realize();
|
||||
|
||||
if (!gdkWindow) {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/Button.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -44,6 +44,11 @@ using namespace LiveSupport::Widgets;
|
|||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The font definition used by the button.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string Button :: fontDefinition = "Bitstream Vera 10";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -54,51 +59,35 @@ using namespace LiveSupport::Widgets;
|
|||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Button :: Button(const Glib::ustring & label,
|
||||
Glib::RefPtr<Gdk::Pixbuf> leftImage,
|
||||
Glib::RefPtr<Gdk::Pixbuf> centerImage,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rightImage)
|
||||
Ptr<ButtonImages>::Ref buttonImages)
|
||||
throw ()
|
||||
{
|
||||
set_flags(Gtk::NO_WINDOW);
|
||||
|
||||
state = passiveState;
|
||||
this->passiveImageLeft = leftImage;
|
||||
this->passiveImageCenter = centerImage;
|
||||
this->passiveImageRight = rightImage;
|
||||
this->rollImageLeft.clear();
|
||||
this->rollImageCenter.clear();
|
||||
this->rollImageRight.clear();
|
||||
stationaryState = passiveState;
|
||||
this->buttonImages = buttonImages;
|
||||
|
||||
this->label = Gtk::manage(new Gtk::Label(label));
|
||||
this->label->set_parent(*this);
|
||||
this->child = Gtk::manage(new Gtk::Label(label));
|
||||
this->child->modify_font(Pango::FontDescription(fontDefinition));
|
||||
this->child->set_parent(*this);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Button :: Button(const Glib::ustring & label,
|
||||
Glib::RefPtr<Gdk::Pixbuf> passiveImageLeft,
|
||||
Glib::RefPtr<Gdk::Pixbuf> passiveImageCenter,
|
||||
Glib::RefPtr<Gdk::Pixbuf> passiveImageRight,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImageLeft,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImageCenter,
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImageRight)
|
||||
Button :: Button(Gtk::Widget * child,
|
||||
Ptr<ButtonImages>::Ref buttonImages)
|
||||
throw ()
|
||||
{
|
||||
set_flags(Gtk::NO_WINDOW);
|
||||
|
||||
state = passiveState;
|
||||
this->passiveImageLeft = passiveImageLeft;
|
||||
this->passiveImageCenter = passiveImageCenter;
|
||||
this->passiveImageRight = passiveImageRight;
|
||||
this->rollImageLeft = rollImageLeft;
|
||||
this->rollImageCenter = rollImageCenter;
|
||||
this->rollImageRight = rollImageRight;
|
||||
this->buttonImages = buttonImages;
|
||||
|
||||
this->label = Gtk::manage(new Gtk::Label(label));
|
||||
this->label->modify_font(Pango::FontDescription("Bitstream Vera 10"));
|
||||
this->label->set_parent(*this);
|
||||
this->child = Gtk::manage(child);
|
||||
this->child->set_parent(*this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -118,12 +107,12 @@ Button :: on_size_request(Gtk::Requisition* requisition) throw ()
|
|||
{
|
||||
*requisition = Gtk::Requisition();
|
||||
|
||||
Gtk::Requisition labelRequisition = label->size_request();;
|
||||
Gtk::Requisition childRequisition = child->size_request();;
|
||||
|
||||
requisition->width = passiveImageLeft->get_width()
|
||||
+ labelRequisition.width
|
||||
+ passiveImageRight->get_width();
|
||||
requisition->height = passiveImageCenter->get_height();
|
||||
requisition->width = buttonImages->passiveImageLeft->get_width()
|
||||
+ childRequisition.width
|
||||
+ buttonImages->passiveImageRight->get_width();
|
||||
requisition->height = buttonImages->passiveImageCenter->get_height();
|
||||
}
|
||||
|
||||
|
||||
|
@ -135,7 +124,7 @@ Button :: on_size_request(Gtk::Requisition* requisition) throw ()
|
|||
void
|
||||
Button :: on_size_allocate(Gtk::Allocation& allocation) throw ()
|
||||
{
|
||||
allocation.set_height(passiveImageCenter->get_height());
|
||||
allocation.set_height(buttonImages->passiveImageCenter->get_height());
|
||||
set_allocation(allocation);
|
||||
|
||||
if (gdkWindow) {
|
||||
|
@ -145,18 +134,18 @@ Button :: on_size_allocate(Gtk::Allocation& allocation) throw ()
|
|||
allocation.get_height() );
|
||||
}
|
||||
|
||||
Gtk::Allocation labelAlloc;
|
||||
Gtk::Allocation childAlloc;
|
||||
|
||||
labelAlloc.set_x(passiveImageLeft->get_width());
|
||||
labelAlloc.set_y((allocation.get_height()
|
||||
- passiveImageCenter->get_height())
|
||||
childAlloc.set_x(buttonImages->passiveImageLeft->get_width());
|
||||
childAlloc.set_y((allocation.get_height()
|
||||
- buttonImages->passiveImageCenter->get_height())
|
||||
/ 2);
|
||||
labelAlloc.set_width(allocation.get_width()
|
||||
- passiveImageLeft->get_width()
|
||||
- passiveImageRight->get_width());
|
||||
labelAlloc.set_height(passiveImageCenter->get_height());
|
||||
childAlloc.set_width(allocation.get_width()
|
||||
- buttonImages->passiveImageLeft->get_width()
|
||||
- buttonImages->passiveImageRight->get_width());
|
||||
childAlloc.set_height(buttonImages->passiveImageCenter->get_height());
|
||||
|
||||
label->size_allocate(labelAlloc);
|
||||
child->size_allocate(childAlloc);
|
||||
|
||||
Gtk::Button::on_size_allocate(allocation);
|
||||
}
|
||||
|
@ -171,7 +160,7 @@ Button :: forall_vfunc(gboolean includeInternals,
|
|||
GtkCallback callback,
|
||||
gpointer callbackData) throw ()
|
||||
{
|
||||
callback((GtkWidget*) label->gobj(), callbackData);
|
||||
callback((GtkWidget*) child->gobj(), callbackData);
|
||||
}
|
||||
|
||||
|
||||
|
@ -232,6 +221,8 @@ Button :: on_unmap() throw ()
|
|||
void
|
||||
Button :: on_realize() throw ()
|
||||
{
|
||||
// trick to make GTK-- allocate a window for the later get_window() call
|
||||
set_flags(Gtk::NO_WINDOW);
|
||||
Gtk::Button::on_realize();
|
||||
|
||||
if (!gdkWindow) {
|
||||
|
@ -301,17 +292,33 @@ Button :: on_expose_event(GdkEventExpose* event) throw ()
|
|||
switch (state) {
|
||||
case passiveState:
|
||||
default:
|
||||
leftImage = passiveImageLeft;
|
||||
centerImage = passiveImageCenter;
|
||||
rightImage = passiveImageRight;
|
||||
leftImage = buttonImages->passiveImageLeft;
|
||||
centerImage = buttonImages->passiveImageCenter;
|
||||
rightImage = buttonImages->passiveImageRight;
|
||||
break;
|
||||
|
||||
case rollState:
|
||||
leftImage = rollImageLeft ? rollImageLeft : passiveImageLeft;
|
||||
centerImage = rollImageCenter ? rollImageCenter
|
||||
: passiveImageCenter;
|
||||
rightImage = rollImageRight ? rollImageRight
|
||||
: passiveImageRight;
|
||||
leftImage = buttonImages->rollImageLeft
|
||||
? buttonImages->rollImageLeft
|
||||
: buttonImages->passiveImageLeft;
|
||||
centerImage = buttonImages->rollImageCenter
|
||||
? buttonImages->rollImageCenter
|
||||
: buttonImages->passiveImageCenter;
|
||||
rightImage = buttonImages->rollImageRight
|
||||
? buttonImages->rollImageRight
|
||||
: buttonImages->passiveImageRight;
|
||||
break;
|
||||
|
||||
case selectedState:
|
||||
leftImage = buttonImages->selectedImageLeft
|
||||
? buttonImages->selectedImageLeft
|
||||
: buttonImages->passiveImageLeft;
|
||||
centerImage = buttonImages->selectedImageCenter
|
||||
? buttonImages->selectedImageCenter
|
||||
: buttonImages->passiveImageCenter;
|
||||
rightImage = buttonImages->selectedImageRight
|
||||
? buttonImages->selectedImageRight
|
||||
: buttonImages->passiveImageRight;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -384,7 +391,7 @@ Button :: on_enter(void) throw ()
|
|||
void
|
||||
Button :: on_leave(void) throw ()
|
||||
{
|
||||
state = passiveState;
|
||||
state = stationaryState;
|
||||
|
||||
Gtk::Button::on_leave();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,135 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ButtonImages.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include "LiveSupport/Widgets/ButtonImages.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Widgets;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/**
|
||||
* The name of the passive left image.
|
||||
*/
|
||||
static const std::string passiveLeftName = "left.png";
|
||||
|
||||
/**
|
||||
* The name of the passive center image.
|
||||
*/
|
||||
static const std::string passiveCenterName = "center.png";
|
||||
|
||||
/**
|
||||
* The name of the passive right image.
|
||||
*/
|
||||
static const std::string passiveRightName = "right.png";
|
||||
|
||||
/**
|
||||
* The name of the rollover left image
|
||||
*/
|
||||
static const std::string rollLeftName = "leftRoll.png";
|
||||
|
||||
/**
|
||||
* The name of the rollover center image
|
||||
*/
|
||||
static const std::string rollCenterName = "centerRoll.png";
|
||||
|
||||
/**
|
||||
* The name of the rollover right image
|
||||
*/
|
||||
static const std::string rollRightName = "rightRoll.png";
|
||||
|
||||
/**
|
||||
* The name of the selected left image
|
||||
*/
|
||||
static const std::string selectedLeftName = "leftSel.png";
|
||||
|
||||
/**
|
||||
* The name of the selected center image
|
||||
*/
|
||||
static const std::string selectedCenterName = "centerSel.png";
|
||||
|
||||
/**
|
||||
* The name of the selected right image
|
||||
*/
|
||||
static const std::string selectedRightName = "rightSel.png";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constructor, based on relative path
|
||||
*----------------------------------------------------------------------------*/
|
||||
ButtonImages :: ButtonImages(const std::string path)
|
||||
throw ()
|
||||
{
|
||||
try {
|
||||
passiveImageLeft = loadImage(path, passiveLeftName);
|
||||
passiveImageCenter = loadImage(path, passiveCenterName);
|
||||
passiveImageRight = loadImage(path, passiveRightName);
|
||||
rollImageLeft = loadImage(path, rollLeftName);
|
||||
rollImageCenter = loadImage(path, rollCenterName);
|
||||
rollImageRight = loadImage(path, rollRightName);
|
||||
selectedImageLeft = loadImage(path, selectedLeftName);
|
||||
selectedImageCenter = loadImage(path, selectedCenterName);
|
||||
selectedImageRight = loadImage(path, selectedRightName);
|
||||
} catch (std::invalid_argument &e) {
|
||||
// just ignore, it's not polite to through exceptions from constructors
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Load an image
|
||||
*----------------------------------------------------------------------------*/
|
||||
Glib::RefPtr<Gdk::Pixbuf>
|
||||
ButtonImages :: loadImage(const std::string path,
|
||||
const std::string imageName)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
Glib::RefPtr<Gdk::Pixbuf> image;
|
||||
|
||||
if (!(image = Gdk::Pixbuf::create_from_file(path + imageName))) {
|
||||
throw std::invalid_argument("Missing " + image);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ComboBoxText.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -233,6 +233,8 @@ ComboBoxText :: on_unmap() throw ()
|
|||
void
|
||||
ComboBoxText :: on_realize() throw ()
|
||||
{
|
||||
// trick to make GTK-- allocate a window for the later get_window() call
|
||||
set_flags(Gtk::NO_WINDOW);
|
||||
Gtk::ComboBoxText::on_realize();
|
||||
|
||||
if (!gdkWindow) {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ImageButton.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -191,6 +191,8 @@ ImageButton :: on_unmap() throw ()
|
|||
void
|
||||
ImageButton :: on_realize() throw ()
|
||||
{
|
||||
// trick to make GTK-- allocate a window for the later get_window() call
|
||||
set_flags(Gtk::NO_WINDOW);
|
||||
Gtk::Button::on_realize();
|
||||
|
||||
if (!gdkWindow) {
|
||||
|
|
|
@ -0,0 +1,294 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/Notebook.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
||||
#include "LiveSupport/Widgets/Notebook.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Widgets;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Notebook :: Notebook(void) throw ()
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
layout = Gtk::manage(new Gtk::Table());
|
||||
tabBox = Gtk::manage(new Gtk::HBox());
|
||||
pageHolder = Gtk::manage(new Gtk::Alignment());
|
||||
|
||||
layout->attach(*tabBox, 0, 1, 0, 1);
|
||||
layout->attach(*pageHolder, 0, 1, 1, 2);
|
||||
|
||||
add(*layout);
|
||||
|
||||
// show all
|
||||
show_all();
|
||||
|
||||
activePage = 0;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Notebook :: ~Notebook(void) throw ()
|
||||
{
|
||||
while (!pageList.empty()) {
|
||||
Page * page = pageList.back();
|
||||
pageList.pop_back();
|
||||
delete page;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Handle the size request event.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Notebook :: on_size_request(Gtk::Requisition* requisition) throw ()
|
||||
{
|
||||
*requisition = Gtk::Requisition();
|
||||
|
||||
Gtk::Requisition tabBoxRequisition = tabBox->size_request();;
|
||||
|
||||
// get the required size from the label
|
||||
Gtk::Requisition tabRequisition;
|
||||
|
||||
// iterate through the menu elements, and get the biggest size
|
||||
PageList::iterator it = pageList.begin();
|
||||
PageList::iterator end = pageList.end();
|
||||
while (it != end) {
|
||||
Page * page = *it;
|
||||
Gtk::Requisition pageRequisition = page->container->size_request();
|
||||
if (tabRequisition.width < pageRequisition.width) {
|
||||
tabRequisition.width = pageRequisition.width;
|
||||
}
|
||||
if (tabRequisition.height < pageRequisition.height) {
|
||||
tabRequisition.height = pageRequisition.height;
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
requisition->width = tabBoxRequisition.width + tabRequisition.width;
|
||||
requisition->height = tabBoxRequisition.height + tabRequisition.height;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Handle the size allocate event.
|
||||
* We will not be given heights or widths less than we have requested,
|
||||
* though we might get more.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Notebook :: on_size_allocate(Gtk::Allocation& allocation) throw ()
|
||||
{
|
||||
Gtk::Alignment::on_size_allocate(allocation);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute a function on all the children.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Notebook :: forall_vfunc(gboolean includeInternals,
|
||||
GtkCallback callback,
|
||||
gpointer callbackData) throw ()
|
||||
{
|
||||
Gtk::Alignment::forall_vfunc(includeInternals, callback, callbackData);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Handle the add child widget event.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Notebook :: on_add(Gtk::Widget* child) throw ()
|
||||
{
|
||||
Gtk::Alignment::on_add(child);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Handle the remove child widget event.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Notebook :: on_remove(Gtk::Widget* child) throw ()
|
||||
{
|
||||
Gtk::Alignment::on_remove(child);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Return what kind of widgets can be added to this container.
|
||||
*----------------------------------------------------------------------------*/
|
||||
GtkType
|
||||
Notebook :: child_type_vfunc() const throw ()
|
||||
{
|
||||
return Gtk::Alignment::child_type_vfunc();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Handle the map event.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Notebook :: on_map() throw ()
|
||||
{
|
||||
Gtk::Alignment::on_map();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Handle the unmap event.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Notebook :: on_unmap() throw ()
|
||||
{
|
||||
Gtk::Alignment::on_unmap();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Handle the realize event.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Notebook :: on_realize() throw ()
|
||||
{
|
||||
Gtk::Alignment::on_realize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Handle the unrealize event.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Notebook :: on_unrealize() throw ()
|
||||
{
|
||||
Gtk::Alignment::on_unrealize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Handle the expose event.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
Notebook :: on_expose_event(GdkEventExpose* event) throw ()
|
||||
{
|
||||
return Gtk::Alignment::on_expose_event(event);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Append a page to the notebook
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Notebook :: appendPage(Gtk::Widget & widget,
|
||||
const Glib::ustring & label) throw ()
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
Button * button = wf->createButton(label,
|
||||
WidgetFactory::tabButton);
|
||||
|
||||
Page * page = new Page(this, pageList.size(), &widget, button);
|
||||
pageList.push_back(page);
|
||||
|
||||
pagesAdded();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Prepare the visuals for the widget
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Notebook :: pagesAdded(void) throw ()
|
||||
{
|
||||
// clean already existing widgets
|
||||
tabBox->children().clear();
|
||||
|
||||
// build up the widgets based on the current pages
|
||||
PageList::iterator pagesIt = pageList.begin();
|
||||
PageList::iterator pagesEnd = pageList.end();
|
||||
|
||||
while (pagesIt != pagesEnd) {
|
||||
Page * page = *pagesIt;
|
||||
|
||||
tabBox->pack_start(*page->button);
|
||||
page->button->signal_clicked().connect(sigc::mem_fun(*page,
|
||||
&Notebook::Page::onTabClicked));
|
||||
pagesIt++;
|
||||
}
|
||||
|
||||
// reset the active page to 0, and show it
|
||||
activatePage(0);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Make a page active
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Notebook :: activatePage(unsigned int pageNo) throw ()
|
||||
{
|
||||
if (pageNo >= pageList.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
pageList[activePage]->button->unselect();
|
||||
pageList[activePage]->container->hide();
|
||||
pageHolder->remove();
|
||||
activePage = pageNo;
|
||||
pageHolder->add(*(pageList[pageNo]->container));
|
||||
pageList[pageNo]->button->select();
|
||||
show_all();
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.10 $
|
||||
Version : $Revision: 1.11 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/TestWindow.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -72,6 +72,7 @@ TestWindow :: TestWindow (void)
|
|||
|
||||
// create a combo box
|
||||
comboBoxText = Gtk::manage(widgetFactory->createComboBoxText());
|
||||
//comboBoxText = widgetFactory->createComboBoxText();
|
||||
comboBoxText->append_text("item1");
|
||||
comboBoxText->append_text("long item2");
|
||||
comboBoxText->append_text("very very very long item3");
|
||||
|
@ -81,16 +82,24 @@ TestWindow :: TestWindow (void)
|
|||
entryBin = Gtk::manage(widgetFactory->createEntryBin());
|
||||
entry = entryBin->getEntry();
|
||||
|
||||
// create a notebook
|
||||
notebook = Gtk::manage(new Notebook());
|
||||
notebook->appendPage(*button, "first page");
|
||||
notebook->appendPage(*entryBin, "third page");
|
||||
notebook->appendPage(*comboBoxText, "second page");
|
||||
|
||||
// create a blue container
|
||||
blueBin = Gtk::manage(widgetFactory->createDarkBlueBin());
|
||||
|
||||
// create and set up the layout
|
||||
layout = Gtk::manage(new Gtk::Table());
|
||||
layout->attach(*imageButton, 0, 1, 0, 1);
|
||||
layout->attach(*notebook, 0, 1, 1, 2);
|
||||
/*
|
||||
layout->attach(*button, 0, 1, 1, 2);
|
||||
layout->attach(*comboBoxText, 0, 1, 2, 3);
|
||||
layout->attach(*entryBin, 0, 1, 3, 4);
|
||||
|
||||
*/
|
||||
blueBin->add(*layout);
|
||||
add(*blueBin);
|
||||
show_all();
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.7 $
|
||||
Version : $Revision: 1.8 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/TestWindow.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -51,6 +51,7 @@
|
|||
#include "LiveSupport/Widgets/ComboBoxText.h"
|
||||
#include "LiveSupport/Widgets/BlueBin.h"
|
||||
#include "LiveSupport/Widgets/EntryBin.h"
|
||||
#include "LiveSupport/Widgets/Notebook.h"
|
||||
#include "LiveSupport/Widgets/WhiteWindow.h"
|
||||
|
||||
|
||||
|
@ -71,7 +72,7 @@ using namespace LiveSupport::Core;
|
|||
* A window, enabling interactive testing of UI components.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.7 $
|
||||
* @version $Revision: 1.8 $
|
||||
*/
|
||||
class TestWindow : public WhiteWindow
|
||||
{
|
||||
|
@ -81,6 +82,11 @@ class TestWindow : public WhiteWindow
|
|||
*/
|
||||
Gtk::Table * layout;
|
||||
|
||||
/**
|
||||
* A notebook, to tab through pages.
|
||||
*/
|
||||
Notebook * notebook;
|
||||
|
||||
/**
|
||||
* An image button.
|
||||
*/
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.7 $
|
||||
Version : $Revision: 1.8 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WidgetFactory.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -62,34 +62,14 @@ Ptr<WidgetFactory>::Ref WidgetFactory::singleton;
|
|||
static const std::string pathAttrName = "path";
|
||||
|
||||
/**
|
||||
* The name of the left passive image for the button.
|
||||
* The relative path for the standard button images.
|
||||
*/
|
||||
static const std::string buttonPassiveLeftName = "button/left.png";
|
||||
static const std::string buttonPath = "button/";
|
||||
|
||||
/**
|
||||
* The name of the center passive image for the button.
|
||||
* The relative path for the tab button images.
|
||||
*/
|
||||
static const std::string buttonPassiveCenterName = "button/center.png";
|
||||
|
||||
/**
|
||||
* The name of the right passive image for the button.
|
||||
*/
|
||||
static const std::string buttonPassiveRightName = "button/right.png";
|
||||
|
||||
/**
|
||||
* The name of the left rollover image for the button.
|
||||
*/
|
||||
static const std::string buttonRollLeftName = "button/leftRoll.png";
|
||||
|
||||
/**
|
||||
* The name of the center rollover image for the button.
|
||||
*/
|
||||
static const std::string buttonRollCenterName = "button/centerRoll.png";
|
||||
|
||||
/**
|
||||
* The name of the right rollover image for the button.
|
||||
*/
|
||||
static const std::string buttonRollRightName = "button/rightRoll.png";
|
||||
static const std::string tabButtonPath = "tabButton/";
|
||||
|
||||
/**
|
||||
* The relative path for the blue bin images.
|
||||
|
@ -178,12 +158,8 @@ WidgetFactory :: configure(const xmlpp::Element & element)
|
|||
path = attribute->get_value();
|
||||
|
||||
// load the button images, and check if all exist
|
||||
buttonPassiveImageLeft = loadImage(buttonPassiveLeftName);
|
||||
buttonPassiveImageCenter = loadImage(buttonPassiveCenterName);
|
||||
buttonPassiveImageRight = loadImage(buttonPassiveRightName);
|
||||
buttonRollImageLeft = loadImage(buttonRollLeftName);
|
||||
buttonRollImageCenter = loadImage(buttonRollCenterName);
|
||||
buttonRollImageRight = loadImage(buttonRollRightName);
|
||||
buttonImages.reset(new ButtonImages(path + buttonPath));
|
||||
tabButtonImages.reset(new ButtonImages(path + tabButtonPath));
|
||||
|
||||
// load the combo box images
|
||||
comboBoxLeftImage = loadImage(comboBoxLeftName);
|
||||
|
@ -221,15 +197,19 @@ WidgetFactory :: loadImage(const std::string imageName)
|
|||
* Create a button
|
||||
*----------------------------------------------------------------------------*/
|
||||
Button *
|
||||
WidgetFactory :: createButton(const Glib::ustring & label) throw ()
|
||||
WidgetFactory :: createButton(const Glib::ustring & label,
|
||||
ButtonType type) throw ()
|
||||
{
|
||||
return new Button(label,
|
||||
buttonPassiveImageLeft,
|
||||
buttonPassiveImageCenter,
|
||||
buttonPassiveImageRight,
|
||||
buttonRollImageLeft,
|
||||
buttonRollImageCenter,
|
||||
buttonRollImageRight);
|
||||
switch (type) {
|
||||
case pushButton:
|
||||
return new Button(label, buttonImages);
|
||||
|
||||
case tabButton:
|
||||
return new Button(label, tabButtonImages);
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -279,7 +259,7 @@ WidgetFactory :: createEntryBin(void) throw ()
|
|||
* Create a stock button
|
||||
*----------------------------------------------------------------------------*/
|
||||
ImageButton *
|
||||
WidgetFactory :: createButton(ButtonType type) throw ()
|
||||
WidgetFactory :: createButton(ImageButtonType type) throw ()
|
||||
{
|
||||
Glib::RefPtr<Gdk::Pixbuf> passiveImage;
|
||||
Glib::RefPtr<Gdk::Pixbuf> rollImage;
|
||||
|
|
Binary file not shown.
After ![]() (image error) Size: 2.8 KiB |
Binary file not shown.
After ![]() (image error) Size: 2.8 KiB |
Binary file not shown.
After ![]() (image error) Size: 2.8 KiB |
Binary file not shown.
After ![]() (image error) Size: 2.9 KiB |
Binary file not shown.
After ![]() (image error) Size: 2.9 KiB |
Binary file not shown.
After ![]() (image error) Size: 2.9 KiB |
Binary file not shown.
After ![]() (image error) Size: 2.9 KiB |
Binary file not shown.
After ![]() (image error) Size: 2.9 KiB |
Binary file not shown.
After ![]() (image error) Size: 3.0 KiB |
Loading…
Reference in New Issue