Clarisse 4.0 SP10 SDK  4.0.0.0.10
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
GuiWidget Class Reference

Base class for all Gui widgets. More...

Inheritance diagram for GuiWidget:
EventObject CoreCustomData CoreBaseObject CoreBaseType GuiAttributeEditor GuiBasicViewportWidget GuiBrowser GuiBrowserPickerWidget GuiCheckbox GuiCheckButton GuiClassCreationWidget GuiColorField GuiContextField GuiContextFieldArrow GuiContextFieldButton GuiContextFieldSelection GuiCurve GuiCustomUIWidget GuiFileBrowserPathField GuiFileBrowserPathFieldButton GuiFileBrowserWidget GuiFilenameField GuiFrame GuiGlWidget GuiGradient GuiGraphEditor GuiGrid GuiHorizontalColorField GuiItemGalleryThumbnailItem GuiLabel GuiLineEdit GuiListButton GuiListPanel GuiListTabWidget GuiListView GuiMenu GuiNumberField GuiObjectField GuiObjectList GuiPanel GuiProgressBar GuiPushButton GuiRenameBackground GuiScriptField GuiScrollbar GuiSearchField GuiSearchWidget GuiShelfItem GuiSlider GuiSpreadsheet GuiTabWidget GuiTagField GuiTextEdit GuiTimeline GuiToolbar GuiTree GuiTreeItem GuiViewport GuiWindow

Public Types

enum  Roundness {
  ROUNDNESS_NONE = 0,
  ROUNDNESS_TOP_LEFT = 1,
  ROUNDNESS_TOP_RIGHT = 2,
  ROUNDNESS_BOTTOM_LEFT = 4,
  ROUNDNESS_BOTTOM_RIGHT = 8,
  ROUNDNESS_LEFT = ROUNDNESS_TOP_LEFT | ROUNDNESS_BOTTOM_LEFT,
  ROUNDNESS_RIGHT = ROUNDNESS_TOP_RIGHT | ROUNDNESS_BOTTOM_RIGHT,
  ROUNDNESS_TOP = ROUNDNESS_TOP_LEFT | ROUNDNESS_TOP_RIGHT,
  ROUNDNESS_BOTTOM = ROUNDNESS_BOTTOM_LEFT | ROUNDNESS_BOTTOM_RIGHT,
  ROUNDNESS_ALL = ROUNDNESS_TOP | ROUNDNESS_BOTTOM
}
 
enum  Constraint {
  CONSTRAINT_LEFT,
  CONSTRAINT_RIGHT,
  CONSTRAINT_TOP,
  CONSTRAINT_BOTTOM,
  CONSTRAINT_COUNT
}
 
enum  Justify {
  JUSTIFY_LEFT,
  JUSTIFY_RIGHT,
  JUSTIFY_CENTER,
  JUSTIFY_COUNT
}
 
enum  IconPosition {
  ICON_POSITION_LEFT,
  ICON_POSITION_RIGHT,
  ICON_POSITION_COUNT
}
 
- Public Types inherited from EventObject
typedef void(* EventInfoFunction )(EventObject &, const EventInfo &, void *)
 
typedef void(EventObject::* EventInfoMethod )(EventObject &, const EventInfo &, void *)
 
typedef void(* EventFunction )(EventObject &, const CoreString &, void *)
 
typedef void(EventObject::* EventMethod )(EventObject &, const CoreString &, void *)
 

Public Member Functions

 GuiWidget (GuiWidget &parent, const int &x, const int &y, const int &w, const int &h)
 
 GuiWidget (GuiApp &app, const int &x, const int &y, const int &w, const int &h)
 
virtual void load_settings (const ParserGroup &settings)
 
virtual void save_settings (ParserGroup &settings)
 
void destroy ()
 
virtual bool is_shown () const
 
bool is_hidden () const
 
bool is_recursive_destroyed () const
 
const bool & is_destroyed () const
 
virtual void show ()
 
virtual void hide ()
 
virtual GuiWidgetget_parent () const
 
const GuiWindowget_root_window () const
 
virtual void set_parent (GuiWidget *parent)
 
GuiWindowget_window () const
 
const int & get_width () const
 
const int & get_height () const
 
const int & get_x () const
 
const int & get_y () const
 
void set_width (int width)
 
void set_height (int height)
 
virtual const GMathVec2i & get_size () const
 
void set_size (int x, int y, int w, int h)
 
void set_position (const int &x, const int &y, bool origin=true)
 sets position , leave size unchanged.
 
virtual const GMathVec2i & get_position () const
 
void set_mouse_cursor (const Gui::MouseCursorId &cursor)
 
const Gui::MouseCursorId & get_mouse_cursor () const
 
void set_font (const GuiFont &font)
 
GuiFontget_font () const
 
const CoreStringget_tooltip () const
 
virtual void set_tooltip (const CoreString &tooltip)
 
void force_tooltip ()
 
virtual bool is_enabled () const
 
void set_enable (const bool &enable)
 
virtual void enable ()
 
virtual void disable ()
 
virtual GuiColorSchemeget_color_scheme () const
 
void set_color (const GuiColorScheme::Group &group, const GuiColorScheme::Role &role, const unsigned char &r, const unsigned char &g, const unsigned char &b)
 
void set_color (const GuiColorScheme::Group &group, const GuiColorScheme::Role &role, const GMathVec3uc &color)
 
void get_color (const GuiColorScheme::Group &group, const GuiColorScheme::Role &role, unsigned char &r, unsigned char &g, unsigned char &b) const
 
const GMathVec3uc & get_color (const GuiColorScheme::Group &group, const GuiColorScheme::Role &role) const
 
bool is_entered () const
 
virtual void set_focus ()
 
bool children_has_focus (GuiWidget *widget) const
 
bool has_focus () const
 
void lose_focus ()
 
bool is_focus_receiver () const
 
void set_focus_receiver (const bool &receiver)
 
bool is_key_receiver () const
 
void set_key_receiver (const bool &receiver)
 
virtual void redraw ()
 This will ask the widget to be drawn again.
 
virtual void draw (GuiDc &dc)
 This is the main drawing method of the widget.
 
virtual CtxDrawget_draw_ctx () const
 Return the drawing context needed by ModuleTool to draw in the widget.
 
virtual void widget_update ()
 This method is called just before draw() if set_is_dirty() has been called before.
 
void set_is_dirty (const bool &value=true)
 
bool get_is_dirty ()
 returns if widget is dirty or not.
 
virtual int process_event (const CoreString &event_id)
 This method is called whenever an event happens on this widget. Override this to catch and process them.
 
void compute_children_bbox (GMathVec2i &lo, GMathVec2i &hi) const
 
const CoreVector< GuiWidget * > & get_children () const
 
GuiAppget_application () const
 
GuiActionregister_action (const CoreString &name, GuiAction::Function function, const CoreString &shortcut, const CoreString &tooltip="", void *data=0, const GuiImage *icon=0)
 
const CoreVector< GuiAction * > & get_actions () const
 
GuiActionget_action (const CoreString &name) const
 
void remove_action (GuiAction *action, bool delete_it)
 
void remove_all_actions ()
 
const int & get_top_offset () const
 
const int & get_bottom_offset () const
 
const int & get_left_offset () const
 
const int & get_right_offset () const
 
const Constraint & get_top_constraint () const
 
const Constraint & get_bottom_constraint () const
 
const Constraint & get_left_constraint () const
 
const Constraint & get_right_constraint () const
 
virtual void set_constraints (const Constraint &left, const Constraint &top, const Constraint &right, const Constraint &bottom)
 
void set_active_constraints (const bool &active)
 
virtual const bool & is_active_constraints () const
 
void set_recursive_constraints (const bool &recursive)
 
virtual const bool & is_recursive_constraints () const
 
virtual void resize (const int &x, const int &y, const int &w, const int &h)
 
void disable_clipping ()
 
void enable_clipping ()
 
void get_clip_region (int &x, int &y, int &w, int &h) const
 
virtual void set_clip_region (const int &x, const int &y, const int &w, const int &h)
 
const bool & is_clipping_enabled () const
 
void bring_to_front ()
 
void enable_tab_navigation (const bool &enable)
 
const bool & is_tab_navigation_enabled () const
 
virtual bool is_visible () const
 
virtual void update_color_scheme (const GuiColorScheme &scheme)
 
virtual void paste (const CoreString &clipboard)
 
bool initiate_dnd_event (const CoreVector< CoreBaseObject * > &data)
 Initiate Drag'n drop event.
 
bool initiate_dnd_event (CoreBaseObject *data)
 See initiate_dnd_event.
 
virtual GuiWidgetget_next_focus_widget () const
 
virtual GuiWidgetget_previous_focus_widget () const
 
void give_focus_to_next_widget ()
 
void give_focus_to_previous_widget ()
 
void get_parent_effective_clip_region (int &x, int &y, int &w, int &h) const
 
const bool & is_widget_visible (GuiWidget &child) const
 
const bool & is_show_children () const
 
void set_show_children (const bool &show_children)
 
template<class WidgetType >
WidgetType * get_parent_widget () const
 Return the first occurence of WidgetType* in the widget parent hierarchy, or 0 if not found.
 
size_t get_memory_size () const
 
- Public Member Functions inherited from EventObject
 EventObject ()
 Constructor.
 
 EventObject (const EventObject &src)
 Copy Constructor.
 
virtual ~EventObject ()
 Destructor.
 
void connect (EventObject &sender, const CoreString &event_id, EventMethod event_cb, void *data=0)
 Connects this to an object to listen to a specific event.
 
void connect (EventObject &sender, EventMethod event_cb, void *data=0)
 Connects this to an object to listen any of its events.
 
void raise_event (const CoreString &event_id) const
 sends an event
 
void connect (EventObject &sender, const CoreString &event_id, EventInfoMethod event_cb, void *data=0)
 Connects this to an object to listen to a specific event.
 
void connect (EventObject &sender, EventInfoMethod event_cb, void *data=0)
 Connects this to an object to listen any of its events.
 
void raise_event (const EventInfo &event_info) const
 sends an event
 
bool disconnect_all (EventObject &sender)
 Disconnects from all objects sender was listening on.
 
void disconnect_all ()
 Disconnects from all objects we were listening on.
 
void remove_all_connection ()
 Disconnects object from other objects it is listening to, and also disconnects all objects listening to it.
 
bool is_connected (EventObject &sender, const CoreString &event_id, void *data)
 
void set_mute (const bool &mute)
 Asks for object muting. This will increase or decrease the muting counter. Unmuting may not be immediat since it will happen only when counter reaches 0.
 
bool is_mute () const
 Returns if object is muted.
 
bool disconnect (EventObject &sender, const CoreString &event_id, EventMethod event_cb, void *data=0)
 Disconnects this from an object for a specific event.
 
bool disconnect (EventObject &sender, const CoreString &event_id, EventInfoMethod event_cb, void *data=0)
 
unsigned int get_sender_count () const
 
unsigned int get_receiver_count () const
 
- Public Member Functions inherited from CoreCustomData
 CoreCustomData (const CoreCustomData &src)
 
void add_custom_data (void *key, const bool &data)
 
void add_custom_data (void *key, const int &data)
 
void add_custom_data (void *key, const unsigned int &data)
 
void add_custom_data (void *key, const char *data)
 
void add_custom_data (void *key, const CoreString &data)
 
void add_custom_data (void *key, const double &data)
 
void add_custom_data (void *key, void *data)
 
void remove_custom_data (void *key)
 
void remove_all_custom_data ()
 
void set_custom_data (void *key, const bool &data)
 
void set_custom_data (void *key, const int &data)
 
void set_custom_data (void *key, const unsigned int &data)
 
void set_custom_data (void *key, const double &data)
 
void set_custom_data (void *key, const char *data)
 
void set_custom_data (void *key, const CoreString &data)
 
void set_custom_data (void *key, void *data)
 
void get_custom_data (void *key, bool &data) const
 
void get_custom_data (void *key, int &data) const
 
void get_custom_data (void *key, unsigned int &data) const
 
void get_custom_data (void *key, double &data) const
 
void get_custom_data (void *key, CoreString &data) const
 
void get_custom_data (void *key, void *&data) const
 
- Public Member Functions inherited from CoreBaseObject
bool is_kindof (const CoreBaseObject &object) const
 
CoreString get_class_info_name () const
 
CoreString get_class_interface () const
 
const unsigned long & get_class_info_id () const
 
bool is_kindof (const CoreClassInfo &cinfo) const
 
virtual const CoreClassInfoget_class_info () const
 
bool operator== (const CoreBaseObject &obj) const
 
template<class T >
T * cast ()
 
template<class T >
const T * cast () const
 
- Public Member Functions inherited from CoreBaseType
bool is_kindof (const CoreClassInfo &cinfo) const
 
bool operator== (const CoreBaseType &obj) const
 

Static Public Member Functions

static CoreString open_file (GuiApp &app, const CoreString &directory="", const CoreString &title="Open file", const CoreString &filter="")
 
static CoreArray< CoreStringopen_files (GuiApp &app, const CoreString &directory="", const CoreString &title="Open files", const CoreString &filter="")
 
static CoreString open_folder (GuiApp &app, const CoreString &directory="", const CoreString &title="Choose folder")
 
static CoreString save_file (GuiApp &app, const CoreString &directory="", const CoreString &title="Save file", const CoreString &filter="", int *filter_selected=0)
 
static CoreVector< OfItem * > pick_objects (GuiApp &app, const CoreVector< OfItem * > &current_selection, const CoreVector< OfClass * > &filter_classes, OfContext *context=0, const CoreVector< OfItem * > &unselectable_items=CoreVector< OfItem * >(), const bool &enable_multi_selection=false)
 
static CoreVector< OfItem * > pick_objects (GuiApp &app, const CoreVector< OfClass * > &filter_classes, OfContext *context=0, const bool &enable_multi_selection=false)
 
static const char * get_roundness_name (const Roundness &roundness)
 
static const char * get_constraint_name (const Constraint &constraint)
 
static const char * get_justify_name (const Justify &justification)
 
static const char * get_icon_position_name (const IconPosition &position)
 
static GuiWidgetget_focused_widget ()
 
static GuiWidgetget_last_focused_widget ()
 
static GuiWidgetget_last_event_widget ()
 
static void intersect_box (const int &x1, const int &y1, const int &w1, const int &h1, const int &x2, const int &y2, const int &w2, const int &h2, int &x, int &y, int &w, int &h)
 
static bool intersect_box (const int &x1, const int &y1, const int &w1, const int &h1, const int &x2, const int &y2, const int &w2, const int &h2)
 
static void on_dnd_timeout (void *data)
 
static const CoreVector
< CoreBaseObject * > & 
get_dnd_event_data ()
 Return the data associated with the current Drag'n drop. The data is only valid if a widget is currently calling initiate_dnd_event, otherwise it is empty.
 
static GuiWidgetget_dnd_widget ()
 Return the GuiWidget that initiated the Drag'n drop. Null otherwise.
 
static GuiWidgetget_dnd_accepting_widget ()
 Return the GuiWidget that accepts the Drag'n drop. Null otherwise.
 
- Static Public Member Functions inherited from EventObject
static void connect (EventObject &sender, const CoreString &event_id, EventObject &receiver, EventMethod event_cb, void *data=0)
 Static version of the above function.
 
static void connect (EventObject &sender, EventObject &receiver, EventMethod event_cb, void *data=0)
 Static version of the above function.
 
static void connect (EventObject &sender, const CoreString &event_id, EventObject &receiver, EventInfoMethod event_cb, void *data=0)
 Static version of the above function.
 
static void connect (EventObject &sender, EventObject &receiver, EventInfoMethod event_cb, void *data=0)
 Static version of the above function.
 
static void raise_event (EventObject &sender, const CoreString &event_id)
 Sends an event.
 
static void raise_event (EventObject &sender, const EventInfo &event_info)
 Sends an event.
 
static void connect (EventObject &sender, const CoreString &event_id, EventFunction event_cb, void *data=0)
 Connects to an object to listen to a specific event.
 
static void connect (EventObject &sender, EventFunction event_cb, void *data=0)
 Connects to an object to listen any of its events.
 
static void connect (EventObject &sender, const CoreString &event_id, EventInfoFunction event_cb, void *data=0)
 Connects to an object to listen to a specific event.
 
static void connect (EventObject &sender, EventInfoFunction event_cb, void *data=0)
 Connects to an object to listen any of its events.
 
static bool disconnect (EventObject &sender, const CoreString &event_id, EventFunction event_cb, void *data=0)
 Disconnects this from an object for a specific event.
 
static bool disconnect (EventObject &sender, const CoreString &event_id, EventInfoFunction event_cb, void *data=0)
 
- Static Public Member Functions inherited from CoreCustomData
static void * get_custom_data_key (const CoreString &key)
 
- Static Public Member Functions inherited from CoreBaseObject
static const CoreClassInfoclass_info ()
 
static bool ___class_destructor__ (void *instance, const bool &is_array)
 
template<class T >
static T * cast (CoreBaseObject *object)
 
template<class T >
static const T * cast (const CoreBaseObject *object)
 
- Static Public Member Functions inherited from CoreBaseType
static bool ___class_destructor__ (void *instance, const bool &is_array)
 
static const CoreClassInfoclass_info ()
 

Protected Types

typedef void(* CreateWidget )(void *inst)
 

Protected Member Functions

virtual GuiDcget_dc ()
 
 GuiWidget (CreateWidget create_widget, GuiWidget &parent, const int &x, const int &y, const int &w, const int &h)
 
 GuiWidget (CreateWidget create_widget, GuiApp &app, const int &x, const int &y, const int &w, const int &h)
 
virtual void widget_redraw ()
 
virtual Fl_Widget * get_widget () const
 
virtual Fl_Group * get_group () const
 
void clear_all_children ()
 
void damage (const unsigned char &mask)
 
const bool is_damaged (const unsigned char &mask) const
 
const unsigned char get_damage () const
 
void create_delayed_parenting (Fl_Group *group) const
 
void recompute_constraints ()
 
virtual void push_clip (const int &x, const int &y, const int &w, const int &h)
 
virtual void pop_clip ()
 
void get_text_size (const CoreString &text, int &w, int &h) const
 
void get_text_size (const char *text, int &w, int &h) const
 
virtual void on_add_child (GuiWidget *child)
 
virtual void on_remove_child (GuiWidget *child)
 
virtual void apply_constraints (const int &px, const int &py, const int &pw, const int &ph)
 
void apply_children_constraints (const int &px, const int &py, const int &pw, const int &ph) const
 
void apply_constraints (GuiWidget &child, const int &px, const int &py, const int &pw, const int &ph) const
 
virtual void apply_clipping ()
 
void apply_children_clipping ()
 
void capture_events (const bool &value)
 
virtual bool process_actions ()
 

Protected Attributes

Fl_Widget * m_widget
 
Fl_Window * m_window
 
Fl_Group * m_group
 
GuiAppm_application
 
int m_child_index
 
Constraint m_top_constraint
 
Constraint m_bottom_constraint
 
Constraint m_left_constraint
 
Constraint m_right_constraint
 
int m_top_offset
 
int m_bottom_offset
 
int m_left_offset
 
int m_right_offset
 
int m_clip_x
 
int m_clip_y
 
int m_clip_w
 
int m_clip_h
 
int m_eff_clip_x
 
int m_eff_clip_y
 
int m_eff_clip_w
 
int m_eff_clip_h
 
GMathVec2i m_size
 
GMathVec2i m_position
 
GuiColorSchemem_color_scheme
 
GuiDcm_dc
 

Friends

class GuiDc
 
class GuiWidgetDc
 
class GuiMenuRouter
 
class GuiGlRouter
 
class GuiBoxRouter
 
class GuiRouter
 
class GuiWindowRouter
 
class GuiApp
 

Detailed Description

Base class for all Gui widgets.

When creating custom gui widgets, the 2 main methods that you might want to use are GuiWidget::draw and GuiWidget::process_event. GuiWidget::redraw can also be used to trigger a redraw (for instance when reacting to some user events in the event processing method)

Member Function Documentation

void GuiWidget::draw ( GuiDc dc)
virtual
CtxDraw * GuiWidget::get_draw_ctx ( ) const
virtual

Return the drawing context needed by ModuleTool to draw in the widget.

Note
Not all the widgets may provide a drawing context and they return a NULL pointer in this case.
bool GuiWidget::initiate_dnd_event ( const CoreVector< CoreBaseObject * > &  data)

Initiate Drag'n drop event.

Parameters
dataThe data to be passed on to receiving widgets. The data is copied and method checks and skips null pointers. Data stays valid only for the duration of the method call. If you want to pass the data to a timer (GuiApplication::add_timer) to display menu popup for example, you must copy the data and pass it to the application timer callback.
Returns
true if a drop was accepted
int GuiWidget::process_event ( const CoreString event_id)
virtual
void GuiWidget::redraw ( )
virtual

This will ask the widget to be drawn again.

Note
This call returns immediately and GuiWidget::draw is called on the next render of the UI.

Reimplemented in GuiToolbar, GuiFilenameField, GuiObjectField, GuiTagField, GuiScriptField, GuiSearchField, and GuiNumberField.

void GuiWidget::set_is_dirty ( const bool &  value = true)

Set the widget dirty, the method widget_update will be called before next redraw. No need to call it again with 'false' its automatic after widget_update call.

void GuiWidget::set_position ( const int &  x,
const int &  y,
bool  origin = true 
)

sets position , leave size unchanged.

Parameters
[in]originIf set to false, centers the widget on required location, otherwise sets its origin.