- 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,520 +1,297 @@
<?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="default_width">800</property>
<property name="title" translatable="yes"></property> <property name="default_height">600</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property> <child>
<property name="window_position">GTK_WIN_POS_NONE</property> <widget class="GtkVBox" id="MainBox">
<property name="modal">False</property> <property name="visible">True</property>
<property name="default_width">800</property> <child>
<property name="default_height">600</property> <widget class="GtkMenuBar" id="MenuBar">
<property name="resizable">True</property> <property name="visible">True</property>
<property name="destroy_with_parent">False</property> <child>
<property name="decorated">True</property> <widget class="GtkMenuItem" id="MenuItem.File">
<property name="skip_taskbar_hint">False</property> <property name="visible">True</property>
<property name="skip_pager_hint">False</property> <property name="label">_File</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> <property name="use_underline">True</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <child>
<property name="focus_on_map">True</property> <widget class="GtkMenu" id="Menu.File">
<property name="urgency_hint">False</property> <property name="visible">True</property>
<child>
<child> <widget class="GtkImageMenuItem" id="MenuItem.File.Quit">
<widget class="GtkVBox" id="MainBox"> <property name="visible">True</property>
<property name="visible">True</property> <property name="label">gtk-quit</property>
<property name="homogeneous">False</property> <property name="use_underline">True</property>
<property name="spacing">0</property> <property name="use_stock">True</property>
</widget>
<child> </child>
<widget class="GtkMenuBar" id="MenuBar"> </widget>
<property name="visible">True</property> </child>
<property name="pack_direction">GTK_PACK_DIRECTION_LTR</property> </widget>
<property name="child_pack_direction">GTK_PACK_DIRECTION_LTR</property> </child>
<child>
<child> <widget class="GtkMenuItem" id="MenuItem.Help">
<widget class="GtkMenuItem" id="MenuItem.File"> <property name="visible">True</property>
<property name="visible">True</property> <property name="label">_Help</property>
<property name="label">_File</property> <property name="use_underline">True</property>
<property name="use_underline">True</property> <child>
<widget class="GtkMenu" id="Menu.Help">
<child> <property name="visible">True</property>
<widget class="GtkMenu" id="Menu.File"> <child>
<property name="visible">True</property> <widget class="GtkImageMenuItem" id="MenuItem.Help.About">
<property name="visible">True</property>
<child> <property name="label">gtk-about</property>
<widget class="GtkImageMenuItem" id="MenuItem.File.Quit"> <property name="use_underline">True</property>
<property name="visible">True</property> <property name="use_stock">True</property>
<property name="label">gtk-quit</property> </widget>
<property name="use_stock">True</property> </child>
</widget> </widget>
</child> </child>
</widget> </widget>
</child> </child>
</widget> </widget>
</child> <packing>
<property name="expand">False</property>
<child> </packing>
<widget class="GtkMenuItem" id="MenuItem.Help"> </child>
<property name="visible">True</property> <child>
<property name="label">_Help</property> <widget class="GtkToolbar" id="ToolBar">
<property name="use_underline">True</property> <property name="visible">True</property>
<property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
<child> <child>
<widget class="GtkMenu" id="Menu.Help"> <widget class="GtkToolButton" id="ToolBar.Open">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock_id">gtk-open</property>
<child> </widget>
<widget class="GtkImageMenuItem" id="MenuItem.Help.About"> </child>
<property name="visible">True</property> <child>
<property name="label">gtk-about</property> <widget class="GtkToolButton" id="ToolBar.Save">
<property name="use_stock">True</property> <property name="visible">True</property>
</widget> <property name="stock_id">gtk-save</property>
</child> </widget>
</widget> </child>
</child> <child>
</widget> <widget class="GtkSeparatorToolItem" id="ToolBar.Separator0">
</child> <property name="visible">True</property>
</widget> </widget>
<packing> </child>
<property name="padding">0</property> <child>
<property name="expand">False</property> <widget class="GtkToolButton" id="ToolBar.Play">
<property name="fill">True</property> <property name="visible">True</property>
</packing> <property name="sensitive">False</property>
</child> <property name="stock_id">gtk-media-play</property>
</widget>
<child> </child>
<widget class="GtkToolbar" id="ToolBar"> <child>
<property name="visible">True</property> <widget class="GtkToolButton" id="ToolBar.Pause">
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property> <property name="visible">True</property>
<property name="toolbar_style">GTK_TOOLBAR_BOTH</property> <property name="sensitive">False</property>
<property name="tooltips">True</property> <property name="stock_id">gtk-media-pause</property>
<property name="show_arrow">True</property> </widget>
</child>
<child> <child>
<widget class="GtkToolButton" id="ToolBar.Open"> <widget class="GtkToolButton" id="ToolBar.Stop">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock_id">gtk-open</property> <property name="sensitive">False</property>
<property name="visible_horizontal">True</property> <property name="stock_id">gtk-media-stop</property>
<property name="visible_vertical">True</property> </widget>
<property name="is_important">False</property> </child>
</widget> <child>
<packing> <widget class="GtkSeparatorToolItem" id="ToolBar.Separator1">
<property name="expand">False</property> <property name="visible">True</property>
<property name="homogeneous">True</property> </widget>
</packing> </child>
</child> <child>
<widget class="GtkMenuToolButton" id="ToolBar.PolicySelector">
<child> <property name="visible">True</property>
<widget class="GtkToolButton" id="ToolBar.Save"> <property name="label">Scheduling Policy</property>
<property name="visible">True</property> <property name="use_underline">True</property>
<property name="stock_id">gtk-save</property> <property name="stock_id">gtk-convert</property>
<property name="visible_horizontal">True</property> </widget>
<property name="visible_vertical">True</property> </child>
<property name="is_important">False</property> <child>
</widget> <widget class="GtkSeparatorToolItem" id="ToolBar.Separator2">
<packing> <property name="visible">True</property>
<property name="expand">False</property> </widget>
<property name="homogeneous">True</property> </child>
</packing> <child>
</child> <widget class="GtkMenuToolButton" id="ToolBar.ResourceScheduling">
<property name="visible">True</property>
<child> <property name="label">Resource Scheduling</property>
<widget class="GtkSeparatorToolItem" id="ToolBar.Separator0"> <property name="use_underline">True</property>
<property name="visible">True</property> <property name="stock_id">gtk-select-color</property>
<property name="draw">True</property> </widget>
<property name="visible_horizontal">True</property> </child>
<property name="visible_vertical">True</property> </widget>
</widget> <packing>
<packing> <property name="expand">False</property>
<property name="expand">False</property> <property name="position">1</property>
<property name="homogeneous">False</property> </packing>
</packing> </child>
</child> <child>
<widget class="GtkHPaned" id="MainHPaned">
<child> <property name="visible">True</property>
<widget class="GtkToolButton" id="ToolBar.Play"> <property name="can_focus">True</property>
<property name="visible">True</property> <child>
<property name="sensitive">False</property> <widget class="GtkScrolledWindow" id="ExpanderScrolledWindow">
<property name="stock_id">gtk-media-play</property> <property name="visible">True</property>
<property name="visible_horizontal">True</property> <property name="can_focus">True</property>
<property name="visible_vertical">True</property> <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="is_important">False</property> <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
</widget> <child>
<packing> <widget class="GtkViewport" id="ExpandersViewport">
<property name="expand">False</property> <property name="visible">True</property>
<property name="homogeneous">True</property> <child>
</packing> <widget class="GtkVBox" id="ExpandersBox">
</child> <property name="visible">True</property>
<property name="border_width">3</property>
<child> <child>
<widget class="GtkToolButton" id="ToolBar.Pause"> <widget class="GtkExpander" id="SchedulablesExpander">
<property name="visible">True</property> <property name="visible">True</property>
<property name="sensitive">False</property> <property name="can_focus">True</property>
<property name="stock_id">gtk-media-pause</property> <property name="expanded">True</property>
<property name="visible_horizontal">True</property> <child>
<property name="visible_vertical">True</property> <placeholder/>
<property name="is_important">False</property> </child>
</widget> <child>
<packing> <widget class="GtkLabel" id="SchedulablesExpander.Label">
<property name="expand">False</property> <property name="visible">True</property>
<property name="homogeneous">True</property> <property name="xalign">0,000000</property>
</packing> <property name="yalign">0,000000</property>
</child> <property name="label" translatable="yes">Schedulables</property>
</widget>
<child> <packing>
<widget class="GtkToolButton" id="ToolBar.Stop"> <property name="type">label_item</property>
<property name="visible">True</property> </packing>
<property name="sensitive">False</property> </child>
<property name="stock_id">gtk-media-stop</property> </widget>
<property name="visible_horizontal">True</property> </child>
<property name="visible_vertical">True</property> <child>
<property name="is_important">False</property> <widget class="GtkExpander" id="ResourcesExpander">
</widget> <property name="visible">True</property>
<packing> <property name="can_focus">True</property>
<property name="expand">False</property> <property name="expanded">True</property>
<property name="homogeneous">True</property> <child>
</packing> <placeholder/>
</child> </child>
<child>
<child> <widget class="GtkLabel" id="ResourcesExpander.Label">
<widget class="GtkSeparatorToolItem" id="ToolBar.Separator1"> <property name="visible">True</property>
<property name="visible">True</property> <property name="xalign">0,000000</property>
<property name="draw">True</property> <property name="yalign">0,000000</property>
<property name="visible_horizontal">True</property> <property name="label" translatable="yes">Resources</property>
<property name="visible_vertical">True</property> </widget>
</widget> <packing>
<packing> <property name="type">label_item</property>
<property name="expand">False</property> </packing>
<property name="homogeneous">False</property> </child>
</packing> </widget>
</child> <packing>
<property name="position">1</property>
<child> </packing>
<widget class="GtkMenuToolButton" id="ToolBar.PolicySelector"> </child>
<property name="visible">True</property> <child>
<property name="label" translatable="yes">Scheduling Policy</property> <widget class="GtkExpander" id="RequestsExpander">
<property name="use_underline">True</property> <property name="visible">True</property>
<property name="stock_id">gtk-convert</property> <property name="can_focus">True</property>
<property name="visible_horizontal">True</property> <child>
<property name="visible_vertical">True</property> <placeholder/>
<property name="is_important">False</property> </child>
</widget> <child>
<packing> <widget class="GtkLabel" id="RequestsExpander.Label">
<property name="expand">False</property> <property name="visible">True</property>
<property name="homogeneous">False</property> <property name="xalign">0,000000</property>
</packing> <property name="yalign">0,000000</property>
</child> <property name="label" translatable="yes">Requests</property>
</widget>
<child> <packing>
<widget class="GtkToolButton" id="ToolBar.PolicySelectorProperties"> <property name="type">label_item</property>
<property name="visible">True</property> </packing>
<property name="stock_id">gtk-properties</property> </child>
<property name="visible_horizontal">True</property> </widget>
<property name="visible_vertical">True</property> <packing>
<property name="is_important">False</property> <property name="expand">False</property>
</widget> <property name="position">2</property>
<packing> </packing>
<property name="expand">False</property> </child>
<property name="homogeneous">True</property> </widget>
</packing> </child>
</child> </widget>
</child>
<child> </widget>
<widget class="GtkSeparatorToolItem" id="ToolBar.Separator2"> <packing>
<property name="visible">True</property> <property name="resize">False</property>
<property name="draw">True</property> </packing>
<property name="visible_horizontal">True</property> </child>
<property name="visible_vertical">True</property> <child>
</widget> <widget class="GtkScrolledWindow" id="SimulationScrolledWindow">
<packing> <property name="visible">True</property>
<property name="expand">False</property> <property name="can_focus">True</property>
<property name="homogeneous">False</property> <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
</packing> <child>
</child> <placeholder/>
</child>
<child> </widget>
<widget class="GtkMenuToolButton" id="ToolBar.ResourceScheduling"> </child>
<property name="visible">True</property> </widget>
<property name="label" translatable="yes">Resource Scheduling</property> <packing>
<property name="use_underline">True</property> <property name="position">2</property>
<property name="stock_id">gtk-select-color</property> </packing>
<property name="visible_horizontal">True</property> </child>
<property name="visible_vertical">True</property> <child>
<property name="is_important">False</property> <widget class="GtkStatusbar" id="MainStatusBar">
</widget> <property name="visible">True</property>
<packing> </widget>
<property name="expand">False</property> <packing>
<property name="homogeneous">False</property> <property name="expand">False</property>
</packing> <property name="pack_type">GTK_PACK_END</property>
</child> <property name="position">3</property>
</packing>
<child> </child>
<widget class="GtkToolButton" id="ToolBar.ResourceSchedulingProperties"> </widget>
<property name="visible">True</property> </child>
<property name="stock_id">gtk-properties</property> </widget>
<property name="visible_horizontal">True</property> <widget class="GtkAboutDialog" id="AboutDialog">
<property name="visible_vertical">True</property> <property name="copyright">University of Padova, dept. of Pure and Applied Mathematics</property>
<property name="is_important">False</property> <property name="comments">An educational simulator for process scheduling policies in a monoprocessor computer.</property>
</widget> <property name="license">SGPEMv2 comes with ABSOLUTELY NO WARRANTY. This is free software,
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHPaned" id="MainHPaned">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<widget class="GtkScrolledWindow" id="ExpanderScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</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>
<widget class="GtkViewport" id="ExpandersViewport">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkVBox" id="ExpandersBox">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkExpander" id="SchedulablesExpander">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="expanded">True</property>
<property name="spacing">0</property>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkLabel" id="SchedulablesExpander.Label">
<property name="visible">True</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>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkExpander" id="ResourcesExpander">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="expanded">True</property>
<property name="spacing">0</property>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkLabel" id="ResourcesExpander.Label">
<property name="visible">True</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>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkExpander" id="RequestsExpander">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="expanded">False</property>
<property name="spacing">0</property>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkLabel" id="RequestsExpander.Label">
<property name="visible">True</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>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="SimulationScrolledWindow">
<property name="visible">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="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkStatusbar" id="MainStatusBar">
<property name="visible">True</property>
<property name="has_resize_grip">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
<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="comments" translatable="yes">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,
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;
Matteo Settenvini &lt;matteo@member.fsf.org&gt; Matteo Settenvini &lt;matteo@member.fsf.org&gt;
Marco Trevisan &lt;mtrevisa@studenti.math.unipd.it&gt; 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="spacing">12</property>
<property name="homogeneous">False</property> <child>
<property name="spacing">12</property> <placeholder/>
</child>
<child> <child internal-child="action_area">
<placeholder/> <widget class="GtkHButtonBox" id="dialog-action_area1">
</child> <property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child internal-child="action_area"> </widget>
<widget class="GtkHButtonBox" id="dialog-action_area1"> <packing>
<property name="visible">True</property> <property name="expand">False</property>
<property name="layout_style">GTK_BUTTONBOX_END</property> <property name="pack_type">GTK_PACK_END</property>
</widget> </packing>
<packing> </child>
<property name="padding">0</property> </widget>
<property name="expand">False</property> </child>
<property name="fill">True</property> </widget>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</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