- Fix drawing of widget background. Now I'll move the code to

an abstract base class, and I'll start working out the 
adjustement / resizing problems (they're not easy to work out 
correctly).


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@822 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-08-04 19:12:17 +00:00
parent 974702af3e
commit 2174c25f74
3 changed files with 315 additions and 529 deletions

View File

@ -1,51 +1,34 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!-- Generated with glade3
Version: 2.91.3
Date: Fri Aug 4 21:13:04 2006
User: matteo
Host: tulip
-->
<glade-interface> <glade-interface>
<widget class="GtkWindow" id="MainWindow">
<widget class="GtkWindow" id="MainWindow">
<property name="title" translatable="yes"></property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">800</property> <property name="default_width">800</property>
<property name="default_height">600</property> <property name="default_height">600</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<child> <child>
<widget class="GtkVBox" id="MainBox"> <widget class="GtkVBox" id="MainBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child> <child>
<widget class="GtkMenuBar" id="MenuBar"> <widget class="GtkMenuBar" id="MenuBar">
<property name="visible">True</property> <property name="visible">True</property>
<property name="pack_direction">GTK_PACK_DIRECTION_LTR</property>
<property name="child_pack_direction">GTK_PACK_DIRECTION_LTR</property>
<child> <child>
<widget class="GtkMenuItem" id="MenuItem.File"> <widget class="GtkMenuItem" id="MenuItem.File">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label">_File</property> <property name="label">_File</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child> <child>
<widget class="GtkMenu" id="Menu.File"> <widget class="GtkMenu" id="Menu.File">
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<widget class="GtkImageMenuItem" id="MenuItem.File.Quit"> <widget class="GtkImageMenuItem" id="MenuItem.File.Quit">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label">gtk-quit</property> <property name="label">gtk-quit</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
</widget> </widget>
</child> </child>
@ -53,21 +36,19 @@
</child> </child>
</widget> </widget>
</child> </child>
<child> <child>
<widget class="GtkMenuItem" id="MenuItem.Help"> <widget class="GtkMenuItem" id="MenuItem.Help">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label">_Help</property> <property name="label">_Help</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child> <child>
<widget class="GtkMenu" id="Menu.Help"> <widget class="GtkMenu" id="Menu.Help">
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<widget class="GtkImageMenuItem" id="MenuItem.Help.About"> <widget class="GtkImageMenuItem" id="MenuItem.Help.About">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label">gtk-about</property> <property name="label">gtk-about</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
</widget> </widget>
</child> </child>
@ -77,294 +58,135 @@
</child> </child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkToolbar" id="ToolBar"> <widget class="GtkToolbar" id="ToolBar">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
<property name="toolbar_style">GTK_TOOLBAR_BOTH</property> <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
<property name="tooltips">True</property>
<property name="show_arrow">True</property>
<child> <child>
<widget class="GtkToolButton" id="ToolBar.Open"> <widget class="GtkToolButton" id="ToolBar.Open">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock_id">gtk-open</property> <property name="stock_id">gtk-open</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
</widget> </widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child> </child>
<child> <child>
<widget class="GtkToolButton" id="ToolBar.Save"> <widget class="GtkToolButton" id="ToolBar.Save">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock_id">gtk-save</property> <property name="stock_id">gtk-save</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
</widget> </widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child> </child>
<child> <child>
<widget class="GtkSeparatorToolItem" id="ToolBar.Separator0"> <widget class="GtkSeparatorToolItem" id="ToolBar.Separator0">
<property name="visible">True</property> <property name="visible">True</property>
<property name="draw">True</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
</widget> </widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child> </child>
<child> <child>
<widget class="GtkToolButton" id="ToolBar.Play"> <widget class="GtkToolButton" id="ToolBar.Play">
<property name="visible">True</property> <property name="visible">True</property>
<property name="sensitive">False</property> <property name="sensitive">False</property>
<property name="stock_id">gtk-media-play</property> <property name="stock_id">gtk-media-play</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
</widget> </widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child> </child>
<child> <child>
<widget class="GtkToolButton" id="ToolBar.Pause"> <widget class="GtkToolButton" id="ToolBar.Pause">
<property name="visible">True</property> <property name="visible">True</property>
<property name="sensitive">False</property> <property name="sensitive">False</property>
<property name="stock_id">gtk-media-pause</property> <property name="stock_id">gtk-media-pause</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
</widget> </widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child> </child>
<child> <child>
<widget class="GtkToolButton" id="ToolBar.Stop"> <widget class="GtkToolButton" id="ToolBar.Stop">
<property name="visible">True</property> <property name="visible">True</property>
<property name="sensitive">False</property> <property name="sensitive">False</property>
<property name="stock_id">gtk-media-stop</property> <property name="stock_id">gtk-media-stop</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
</widget> </widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child> </child>
<child> <child>
<widget class="GtkSeparatorToolItem" id="ToolBar.Separator1"> <widget class="GtkSeparatorToolItem" id="ToolBar.Separator1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="draw">True</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
</widget> </widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child> </child>
<child> <child>
<widget class="GtkMenuToolButton" id="ToolBar.PolicySelector"> <widget class="GtkMenuToolButton" id="ToolBar.PolicySelector">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Scheduling Policy</property> <property name="label">Scheduling Policy</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="stock_id">gtk-convert</property> <property name="stock_id">gtk-convert</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
</widget> </widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child> </child>
<child>
<widget class="GtkToolButton" id="ToolBar.PolicySelectorProperties">
<property name="visible">True</property>
<property name="stock_id">gtk-properties</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child> <child>
<widget class="GtkSeparatorToolItem" id="ToolBar.Separator2"> <widget class="GtkSeparatorToolItem" id="ToolBar.Separator2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="draw">True</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
</widget> </widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child> </child>
<child> <child>
<widget class="GtkMenuToolButton" id="ToolBar.ResourceScheduling"> <widget class="GtkMenuToolButton" id="ToolBar.ResourceScheduling">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Resource Scheduling</property> <property name="label">Resource Scheduling</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="stock_id">gtk-select-color</property> <property name="stock_id">gtk-select-color</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
</widget> </widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="ToolBar.ResourceSchedulingProperties">
<property name="visible">True</property>
<property name="stock_id">gtk-properties</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child> </child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkHPaned" id="MainHPaned"> <widget class="GtkHPaned" id="MainHPaned">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<child> <child>
<widget class="GtkScrolledWindow" id="ExpanderScrolledWindow"> <widget class="GtkScrolledWindow" id="ExpanderScrolledWindow">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property> <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child> <child>
<widget class="GtkViewport" id="ExpandersViewport"> <widget class="GtkViewport" id="ExpandersViewport">
<property name="visible">True</property> <property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child> <child>
<widget class="GtkVBox" id="ExpandersBox"> <widget class="GtkVBox" id="ExpandersBox">
<property name="border_width">3</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="homogeneous">False</property> <property name="border_width">3</property>
<property name="spacing">0</property>
<child> <child>
<widget class="GtkExpander" id="SchedulablesExpander"> <widget class="GtkExpander" id="SchedulablesExpander">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="expanded">True</property> <property name="expanded">True</property>
<property name="spacing">0</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
<child> <child>
<widget class="GtkLabel" id="SchedulablesExpander.Label"> <widget class="GtkLabel" id="SchedulablesExpander.Label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0,000000</property>
<property name="yalign">0,000000</property>
<property name="label" translatable="yes">Schedulables</property> <property name="label" translatable="yes">Schedulables</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="type">label_item</property> <property name="type">label_item</property>
</packing> </packing>
</child> </child>
</widget> </widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child> </child>
<child> <child>
<widget class="GtkExpander" id="ResourcesExpander"> <widget class="GtkExpander" id="ResourcesExpander">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="expanded">True</property> <property name="expanded">True</property>
<property name="spacing">0</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
<child> <child>
<widget class="GtkLabel" id="ResourcesExpander.Label"> <widget class="GtkLabel" id="ResourcesExpander.Label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0,000000</property>
<property name="yalign">0,000000</property>
<property name="label" translatable="yes">Resources</property> <property name="label" translatable="yes">Resources</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="type">label_item</property> <property name="type">label_item</property>
@ -372,40 +194,22 @@
</child> </child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="position">1</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkExpander" id="RequestsExpander"> <widget class="GtkExpander" id="RequestsExpander">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="expanded">False</property>
<property name="spacing">0</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
<child> <child>
<widget class="GtkLabel" id="RequestsExpander.Label"> <widget class="GtkLabel" id="RequestsExpander.Label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0,000000</property>
<property name="yalign">0,000000</property>
<property name="label" translatable="yes">Requests</property> <property name="label" translatable="yes">Requests</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="type">label_item</property> <property name="type">label_item</property>
@ -413,9 +217,8 @@
</child> </child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
</widget> </widget>
@ -424,63 +227,44 @@
</child> </child>
</widget> </widget>
<packing> <packing>
<property name="shrink">True</property>
<property name="resize">False</property> <property name="resize">False</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkScrolledWindow" id="SimulationScrolledWindow"> <widget class="GtkScrolledWindow" id="SimulationScrolledWindow">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
</widget> </widget>
<packing>
<property name="shrink">True</property>
<property name="resize">True</property>
</packing>
</child> </child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="position">2</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkStatusbar" id="MainStatusBar"> <widget class="GtkStatusbar" id="MainStatusBar">
<property name="visible">True</property> <property name="visible">True</property>
<property name="has_resize_grip">True</property>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property> <property name="pack_type">GTK_PACK_END</property>
<property name="position">3</property>
</packing> </packing>
</child> </child>
</widget> </widget>
</child> </child>
</widget> </widget>
<widget class="GtkAboutDialog" id="AboutDialog">
<widget class="GtkAboutDialog" id="AboutDialog">
<property name="destroy_with_parent">False</property>
<property name="name" translatable="yes">SGPEMv2</property>
<property name="copyright">University of Padova, dept. of Pure and Applied Mathematics</property> <property name="copyright">University of Padova, dept. of Pure and Applied Mathematics</property>
<property name="comments" translatable="yes">An educational simulator for process scheduling policies in a monoprocessor computer.</property> <property name="comments">An educational simulator for process scheduling policies in a monoprocessor computer.</property>
<property name="license">SGPEMv2 comes with ABSOLUTELY NO WARRANTY. This is free software, <property name="license">SGPEMv2 comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under the terms of the GNU General and you are welcome to redistribute it under the terms of the GNU General
Public License; for details see file COPYING contained in the source Public License; for details see file COPYING contained in the source
package.</property> package.</property>
<property name="wrap_license">False</property>
<property name="authors">Giovanni Giacobbi &lt;ggiacobb@studenti.math.unipd.it&gt; <property name="authors">Giovanni Giacobbi &lt;ggiacobb@studenti.math.unipd.it&gt;
Filippo Paparella &lt;ironpipp@gmail.com&gt; Filippo Paparella &lt;ironpipp@gmail.com&gt;
Paolo Santi &lt;psanti@studenti.math.unipd.it&gt; Paolo Santi &lt;psanti@studenti.math.unipd.it&gt;
@ -489,32 +273,25 @@ Marco Trevisan &lt;mtrevisa@studenti.math.unipd.it&gt;
Djina Verbanac &lt;betalgez@yahoo.com&gt; Djina Verbanac &lt;betalgez@yahoo.com&gt;
Luca Vezzaro &lt;lvezzaro@studenti.math.unipd.it&gt;</property> Luca Vezzaro &lt;lvezzaro@studenti.math.unipd.it&gt;</property>
<property name="documenters"></property> <property name="documenters"></property>
<property name="translator_credits" translatable="yes" comments="TRANSLATORS: Replace this string with your names, one name per line.">translator-credits</property> <property name="translator_credits">translator-credits</property>
<child internal-child="vbox"> <child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1"> <widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
<child internal-child="action_area"> <child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1"> <widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property> <property name="layout_style">GTK_BUTTONBOX_END</property>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property> <property name="pack_type">GTK_PACK_END</property>
</packing> </packing>
</child> </child>
</widget> </widget>
</child> </child>
</widget> </widget>
</glade-interface> </glade-interface>

View File

@ -53,6 +53,8 @@ SchedulablesWidget::~SchedulablesWidget()
void void
SchedulablesWidget::update(const History& history) SchedulablesWidget::update(const History& history)
{ {
// get_window() returns a null pointer
// if the widget has not been realized
if(!is_realized()) if(!is_realized())
return; // Nowhere to draw to. return; // Nowhere to draw to.
@ -60,10 +62,17 @@ SchedulablesWidget::update(const History& history)
unsigned int w = get_allocation().get_width(); unsigned int w = get_allocation().get_width();
_h = calc_height(history); _h = calc_height(history);
// get_window() returns a null pointer
// if the widget has not been realized
_buf = Gdk::Pixmap::create(get_window(), w, _h); _buf = Gdk::Pixmap::create(get_window(), w, _h);
// Draw the widget background as the first thing.
// I've seen this is how it's done in the very Gtk+ toolkit
// for the GtkProgressBar widget.
GtkStyle* gStyle = get_style()->gobj();
gtk_paint_box(gStyle, _buf->gobj(),
GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN,
NULL, this->gobj(), "through",
0, 0, w, _h);
cairo_t* ctx = gdk_cairo_create(_buf->gobj()); cairo_t* ctx = gdk_cairo_create(_buf->gobj());
// do the drawing... // do the drawing...
@ -118,18 +127,23 @@ SchedulablesWidget::on_realize()
attributes.wclass = GDK_INPUT_OUTPUT; attributes.wclass = GDK_INPUT_OUTPUT;
attributes.event_mask = get_events() | GDK_EXPOSURE_MASK; attributes.event_mask = get_events() | GDK_EXPOSURE_MASK;
attributes.window_type = GDK_WINDOW_CHILD; attributes.window_type = GDK_WINDOW_CHILD;
attributes.visual = get_visual()->gobj();
attributes.colormap = get_colormap()->gobj();
static const gint attributes_mask = Gdk::WA_X | Gdk::WA_Y | Gdk::WA_WMCLASS
| Gdk::WA_VISUAL | Gdk::WA_COLORMAP;
Glib::RefPtr<Gdk::Window> window = Gdk::Window::create(get_parent_window(), Glib::RefPtr<Gdk::Window> window = Gdk::Window::create(get_parent_window(),
&attributes, &attributes,
Gdk::WA_X | Gdk::WA_Y | attributes_mask);
Gdk::WA_WMCLASS);
unset_flags(Gtk::NO_WINDOW);
unset_flags(Gtk::NO_WINDOW);
set_window(window); set_window(window);
window->set_user_data(gobj()); window->set_user_data(gobj());
get_style()->set_background(window, Gtk::STATE_ACTIVE);
_refGC = Gdk::GC::create(window); // Not sure if the following line is needed:
gtk_style_attach(get_style()->gobj(), window->gobj());
get_style()->set_background(window, Gtk::STATE_ACTIVE);
} }
void void
@ -156,25 +170,21 @@ SchedulablesWidget::on_size_allocate(const Gtk::Allocation& allocation)
bool bool
SchedulablesWidget::on_expose_event(GdkEventExpose* event) SchedulablesWidget::on_expose_event(GdkEventExpose* event)
{ {
if(event == NULL || event->count > 0)
return false;
// calculated dinamically: // calculated dinamically:
int w = get_allocation().get_width(); int w = get_allocation().get_width();
set_size_request(w, _h); set_size_request(w, _h);
// Clip to redraw only the smallest possible area // Clip to redraw only the smallest possible area
std::auto_ptr<Gdk::Rectangle> clip_area;
if(event)
clip_area = std::auto_ptr<Gdk::Rectangle>(new Gdk::Rectangle(event->area.x, event->area.y,
event->area.width, event->area.height));
else
clip_area = std::auto_ptr<Gdk::Rectangle>(new Gdk::Rectangle(0, 0, w, _h));
// Use double buffering or we're CPU-dead // Use double buffering or we're CPU-dead
// Copy from the buffer to the screen // Copy from the buffer to the screen
if(_buf) if(_buf)
get_window()->draw_drawable(_refGC, _buf, get_window()->draw_drawable(get_style()->get_black_gc(), _buf,
clip_area->get_x(), clip_area->get_y(), event->area.x, event->area.y,
clip_area->get_x(), clip_area->get_y(), event->area.x, event->area.y,
clip_area->get_width(), clip_area->get_height()); event->area.width, event->area.height);
return true; return true;
} }

View File

@ -59,7 +59,6 @@ namespace sgpem
typedef std::vector<area_callback_t> areas_vect_t; typedef std::vector<area_callback_t> areas_vect_t;
Glib::RefPtr<Gdk::Pixmap> _buf; Glib::RefPtr<Gdk::Pixmap> _buf;
Glib::RefPtr<Gdk::GC> _refGC;
}; };
} //~ namespace sgpem } //~ namespace sgpem