cvs: php-gtk-doc /en/reference/gdk gdkcolor.xml /en/reference/gtk gtk-functions.xml gtkdrawingarea.xml gtklayout.xml gtkstyle.xml
| From: | Steph Fox | Date: | Sat, 09 Mar 2002 09:22:58 +0000 |
| Subject: | cvs: php-gtk-doc /en/reference/gdk gdkcolor.xml /en/reference/gtk gtk-functions.xml gtkdrawingarea.xml gtklayout.xml gtkstyle.xml | ||
| Groups: | php.gtk.doc | ||
| Request: | Send a blank email to php-gtk-doc+get-458@lists.php.net to get a copy of this message | ||
sfox Sat Mar 9 04:22:58 2002 EDT
Modified files:
/php-gtk-doc/en/reference/gdk gdkcolor.xml
/php-gtk-doc/en/reference/gtk gtk-functions.xml gtkdrawingarea.xml
gtklayout.xml gtkstyle.xml
Log:
color, darea, layout, etc.
Index: php-gtk-doc/en/reference/gdk/gdkcolor.xml diff -u php-gtk-doc/en/reference/gdk/gdkcolor.xml:1.1 php-gtk-doc/en/reference/gdk/gdkcolor.xml:1.2 --- php-gtk-doc/en/reference/gdk/gdkcolor.xml:1.1 Thu Jan 31 15:02:43 2002 +++ php-gtk-doc/en/reference/gdk/gdkcolor.xml Sat Mar 9 04:22:57 2002 @@ -4,10 +4,33 @@ <classtitle>GdkColor</classtitle> <classparent></classparent> <shortdesc> - + A structure that holds a defined color. </shortdesc> <desc> - + <simpara> + A <classname>GdkColor</classname> provides an object structure for + retaining information about a defined color. + </simpara> + <simpara> + This is an XcmsColor structure, and will take values in any XcmsColor + format accordingly. Probably the most generally useful of these formats + is the gamma-corrected XcmsRGB structure, which takes the range + <literal>0</literal> to <literal>65535</literal> per RGB value, with + <literal>0, 0, 0</literal> being the color black. RGB values that are + given in this way are scaled to match the color range of the hardware + device currently being used. + </simpara> + <simpara> + Colors can be assigned through an application's RC files, where the + <classname>GdkColor</classname> objects are constructed via the + application colormap defined through the file. Colors that are assigned + in this way can be constructed using any of the formats accepted by the + XcmsColor structure, including intensity doubles. + </simpara> + <simpara> + Note that this is not the case when assigning a color to a + <classname>GdkColor</classname> directly. + </simpara> </desc> </classmeta> @@ -15,14 +38,61 @@ <funcsynopsis> <funcprototype> <funcdef> <function>GdkColor</function></funcdef> - <paramdef></paramdef> + <paramdef>int <parameter>red</parameter></paramdef> + <paramdef>int <parameter>green</parameter></paramdef> + <paramdef>int <parameter>blue</parameter></paramdef> </funcprototype> </funcsynopsis> <shortdesc> - + Creates a new color object using one of three possible constructs. + <!-- + I've no way to express alternative constructors .. have I? - sf mar 02 + --> </shortdesc> <desc> - + <simpara> + When constructing a <classname>GdkColor</classname> directly, you will + need to use either hex RGB triples or XcmsRGB values. Attempting to use + other formats here will not result in an error message, because the + structure itself recognises them, but equally they will not display, + because the function doesn't recognise them at all. + </simpara> + <para> + The options when directly constructing colors in PHP-GTK are: + <informalexample> + <programlisting role="php"> +/* XcmsRGB values, expressed as three integers */ +$cyan = &new GdkColor(0, 65535, 65535); + </programlisting> + </informalexample> + or + <informalexample> + <programlisting role="php"> +/* hex triples expressed as a single string */ +$cyan = &new GdkColor('#00FFFF'); + </programlisting> + </informalexample> + or + <informalexample> + <programlisting role="php"> +/* a color name expressed as a single string */ +$cyan = &new GdkColor('cyan'); + </programlisting> + </informalexample> + Color names that are used on a given system are defined in a file + named <filename>rgb.txt</filename>. The equivalent file is not + available in human-readable form under win32, although utilised. + <ulink url="&url.rgbtxt;">Here</ulink> is one of the better reference + pages currently online detailing the standard color names used by + window management systems. + </para> + <simpara> + See also: <classname>GtkStyle</classname>. + </simpara> + <!-- + TODO We definitely, definitely need something in the userguide on + RC files, soonest - sf mar 02 + --> </desc> </constructor> Index: php-gtk-doc/en/reference/gtk/gtk-functions.xml diff -u php-gtk-doc/en/reference/gtk/gtk-functions.xml:1.6 php-gtk-doc/en/reference/gtk/gtk-functions.xml:1.7 --- php-gtk-doc/en/reference/gtk/gtk-functions.xml:1.6 Wed Feb 20 20:08:41 2002 +++ php-gtk-doc/en/reference/gtk/gtk-functions.xml Sat Mar 9 04:22:57 2002 @@ -431,7 +431,7 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Not implemented. </shortdesc> <desc> @@ -1338,10 +1338,27 @@ </funcprototype> </funcsynopsis> <shortdesc> - + A quick way to draw focus-like shadow around a given rectangle. </shortdesc> <desc> - + <simpara> + <function>gtk::paint_focus()</function> is a convenience function + that draws a dark shadow along the left and top sides of the given + rectangle, making it appear as GTK widgets generally do when they + have focus. + </simpara> + <simpara> + This is the only function that uses the <parameter>detail</parameter> + parameter at all now; if you pass <literal>'set-mode'</literal> as + that parameter, the shadow will appear as long dashes rather than as + a continuous line. Any other string is regarded the same as if it + were <literal>null</literal>. + </simpara> + <simpara> + The other parameters are on the whole self-explanatory. The + <parameter>widget</parameter> parameter refers to the widget that is + being drawn upon (usually a <classname>GtkDrawingArea</classname>). + </simpara> </desc> </method> Index: php-gtk-doc/en/reference/gtk/gtkdrawingarea.xml diff -u php-gtk-doc/en/reference/gtk/gtkdrawingarea.xml:1.4 php-gtk-doc/en/reference/gtk/gtkdrawingarea.xml:1.5 --- php-gtk-doc/en/reference/gtk/gtkdrawingarea.xml:1.4 Sun Jan 20 14:47:43 2002 +++ php-gtk-doc/en/reference/gtk/gtkdrawingarea.xml Sat Mar 9 04:22:58 2002 @@ -7,7 +7,35 @@ Widget for custom user interface elements. </shortdesc> <desc> - + <simpara> + A <classname>GtkDrawingArea</classname> is a widget whose + <classname>GdkWindow</classname> can be drawn to. You could use it to + create a new user interface element, or an updateable graph, or pretty + much anything, using the GDK and GTK draw and paint functions. + </simpara> + <simpara> + Because it is in itself so featureless, everything has to be added to + a <classname>GtkDrawingArea</classname>. It will not respond to key or + button press events, unless you give it the ability to do so using + <function class="GtkWidget">set_events()</function> or + <function class="GtkWidget">add_events()</function>. It cannot have + keyboard focus, unless you set the <literal>GTK_CAN_FOCUS</literal> + flag. It does not regard what is drawn upon it as a clue to sizing, so + you have to size it. If you want it to react to resizing, you will need + to connect it to an appropriate callback via the + <signalname class="GtkWidget">configure-event</signalname> signal in + order to do so. It has no defining behaviour, beyond the ability to + manufacture configure events when it is allocated a new size. It's + basically a completely empty widget. + </simpara> + <note> + <simpara> + <emphasis> + Redraws should be created through an + <signalname class="GtkWidget">expose-event</signalname> handler. + </emphasis> + </simpara> + </note> </desc> </classmeta> @@ -19,10 +47,84 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Constructs a blank, drawable widget. </shortdesc> <desc> - + <para> + <example> + <title>Drawing to a <classname>GtkDrawingArea</classname></title> + <programlisting role="php"> +dl('php_gtk.'.(strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); + +function draw_it($drawingarea, $event, $style, $gdkwindow) { + /* access the GdkWindow's colormap to associate a color with a GdkGC */ + $colormap = $gdkwindow->colormap; + $yellow = $gdkwindow->new_gc(); + $yellow->foreground = $colormap->alloc('yellow'); + $red = $gdkwindow->new_gc(); + $red->foreground = $colormap->alloc('red'); + + /* set up fonts. The first font here is set as part of the drawingarea's + style property so that it will be used in gtk::draw_string(). */ + $font = + gdk::font_load('-unknown-Arial-bold-r-normal--*-120-*-*-p-0-iso8859-1'); + $style->font = $font; + $font2 = + gdk::font_load('-unknown-Arial-bold-r-normal--*-720-*-*-p-0-iso8859-1'); + + /* call the appropriate drawing functions */ + gdk::draw_rectangle($gdkwindow, $style->white_gc, true, 0, 0, 200, 220); + gdk::draw_rectangle($gdkwindow, $yellow, true, 50, 50, 100, 100); + gdk::draw_string($gdkwindow, $font2, $style->white_gc, 75, 130, '?'); + gdk::draw_line($gdkwindow, $red, 20, 20, 180, 180); + gdk::draw_line($gdkwindow, $red, 20, 180, 180, 20); + gtk::draw_string($style, $gdkwindow, GTK_STATE_NORMAL, 12, 210, + 'SAY TO SQUARE EGGS!'); + gdk::draw_string($gdkwindow, $font, $red, 42, 210, 'NO'); +} + +function press_it($drawingarea, $event, $style, $gdkwindow) { + /* make the drawingarea look like it has been pressed down */ + $rectangle = &new GdkRectangle(0, 0, 200, 220); + gtk::paint_focus($style, $gdkwindow, $rectangle, $drawingarea, null, 0, 0, + 200, 220); +} + +function redraw_it($drawingarea, $event) { + /* trigger a new expose event */ + $drawingarea->queue_draw(); +} + +/* set up the main window that will hold the drawing area */ +$window = &new GtkWindow(); +$window->set_position(GTK_WIN_POS_CENTER); +$window->connect_object('destroy', array('gtk', 'main_quit')); + +/* set up the drawing area. Sizing is taken from the parent, unless set. + We need to add events so that the drawingarea is sensitive to the mouse, + using set_events() to do this because the widget is not realized yet. */ +$drawingarea = &new GtkDrawingArea(); +$drawingarea->size(200, 220); +$drawingarea->set_events(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); +$window->add($drawingarea); + +/* once the drawing area has been added to the window we can realize() it, + which means that we can now access its properties */ +$drawingarea->realize(); +$style = $drawingarea->style; +$gdkwindow = $drawingarea->window; + +/* drawing should always follow an expose event */ +$drawingarea->connect('expose-event', 'draw_it', $style, $gdkwindow); +$drawingarea->connect('button-press-event', 'press_it', $style, +$gdkwindow); +$drawingarea->connect('button-release-event', 'redraw_it'); + +$window->show_all(); +gtk::main(); + </programlisting> + </example> + </para> </desc> </constructor> @@ -37,10 +139,15 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Sets the size of the drawing area. </shortdesc> <desc> - + <simpara> + A <classname>GtkDrawingArea</classname> has no default size set. If + none is given, it will default to the size allocated to it by its parent + window. Note that the size set using this method is treated as the + drawingarea's size request, and may be overridden in some situations. + </simpara> </desc> </method> Index: php-gtk-doc/en/reference/gtk/gtklayout.xml diff -u php-gtk-doc/en/reference/gtk/gtklayout.xml:1.5 php-gtk-doc/en/reference/gtk/gtklayout.xml:1.6 --- php-gtk-doc/en/reference/gtk/gtklayout.xml:1.5 Thu Mar 7 16:28:19 2002 +++ php-gtk-doc/en/reference/gtk/gtklayout.xml Sat Mar 9 04:22:58 2002 @@ -7,7 +7,30 @@ Scrollable widget allowing multiple children in fixed positions. </shortdesc> <desc> - + <simpara> + A <classname>GtkLayout</classname> is a scrollable widget that provides + a scrolling-aware backdrop for a child or children having fixed + positions. It should be added directly to a + <classname>GtkScrolledWindow</classname>. + </simpara> + <simpara> + Note that the scrolling does not work on win32 unless you program it + to do so. There have been no such problems reported on other systems. + The workaround under win32 is to connect the + <classname>GtkScrolledWindow</classname> scrollbar adjustments' + <signalname class="GtkAdjustment">value-changed</signalname> signals + to a function that will force the <classname>GtkLayout</classname> to + be redrawn. This can be + <function class="GtkWidget">queue_draw()</function> in most situations, + but the more complex child widgets will not respond to this alone and + will need to have <function class="GtkWidget">hide()</function> and + then <function class="GtkWidget">show()</function> called on the + <classname>GtkLayout</classname> during the callback. + </simpara> + <simpara> + Note that GtkHtml is based on the <classname>GtkLayout</classname> + class, and that similar redraw issues are seen with that widget. + </simpara> </desc> </classmeta> @@ -26,10 +49,82 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Creates a scrollable backdrop whose children retain their positions. </shortdesc> <desc> - + <para> + The following example is based on the GTK+ test file + <filename>testgtk.c</filename>. Unix users will not need to use + the callback function in order to achieve scrolling, but it shouldn't + do any harm to run it as it stands. Win32 users will find that the + labels are redrawn and the buttons are not, giving a somewhat + psychedelic effect. To redraw both types of object under win32, + replace the callback function with: + <informalexample> + <programlisting role="php"> +function exposure($adj, $layout) { + $layout->hide(); + $layout->show(); +} + </programlisting> + </informalexample> + </para> + <para> + <example> + <title>Forcing a <classname>GtkLayout</classname> to redraw</title> + <programlisting role="php"> +dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); + +/* callback that forces a redraw of simple child widgets */ +function exposure($adj, $layout) { + $layout->queue_draw(); +} + +/* set up a window and size it to be smaller than the intended layout */ +$window = &new GtkWindow(); +$window->set_position(GTK_WIN_POS_CENTER); +$window->set_title('Layout'); +$window->set_usize(200, 200); +$window->connect_object('destroy', array('gtk', 'main_quit')); + +/* create and add the scrolled window to the main window */ +$scrolledwindow = &new GtkScrolledWindow(); +$window->add($scrolledwindow); + +/* create and add the layout widget to the scrolled window */ +$layout = &new GtkLayout(null, null); +$scrolledwindow->add($layout); + +/* set the layout to be bigger than the windows that contain it */ +$x = gdk::screen_width(); +$y = gdk::screen_height(); +$layout->set_size($x, $y); + +/* get the adjustment objects and connect them to the callback. This + part should not be necessary under *nix systems */ +$hadj = $scrolledwindow->get_hadjustment(); +$vadj = $scrolledwindow->get_vadjustment(); +$hadj->connect('value-changed', 'exposure', $layout); +$vadj->connect('value-changed', 'exposure', $layout); + +/* populate the layout with a mixture of buttons and labels */ +for ($i=0 ; $i < round($y/100); $i++) { + for ($j=0 ; $j < round($x/100); $j++) { + $buf =sprintf('Button %d, %d', $i, $j); + if (($i + $j) % 2) $button = &new GtkButton($buf); + else $button = &new GtkLabel($buf); + $layout->put($button, $j*100, $i*100); + } +} + +/* display everything and run the main loop */ +$layout->show_all(); +$window->show_all(); + +gtk::main(); + </programlisting> + </example> + </para> </desc> </constructor> @@ -48,10 +143,14 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Fixes a child widget at the given position. </shortdesc> <desc> - + <simpara> + This method adds a child widget to the layout. The top left + corner of the child widget will be positioned at the co-ordinates + passed in the <literal>x, y</literal> parameters. + </simpara> </desc> </method> @@ -68,10 +167,14 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Moves a child widget to a new position. </shortdesc> <desc> - + <simpara> + This method takes a child widget that has already been added to + the <classname>GtkLayout</classname> and moves it to a new position + reflecting the co-ordinates passed in the parameters. + </simpara> </desc> </method> @@ -84,10 +187,15 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Sets the size of the layout. </shortdesc> <desc> - + <simpara> + Sets the size of the <classname>GtkLayout</classname>. If you do + not call this method the layout will size itself according to the + size allocation given it by the parent window, rather than the size + requisition of the layout's child widgets. + </simpara> </desc> </method> @@ -102,10 +210,15 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Returns the horizontal adjustment object. </shortdesc> <desc> - + <simpara> + This method is used internally to set the horizontal scrollbar + adjustment in the <classname>GtkScrolledWindow</classname> holding + the <classname>GtkLayout</classname>. These sets of adjustment + objects are interchangeable, i.e. they share the same values. + </simpara> </desc> </method> @@ -120,48 +233,20 @@ </funcprototype> </funcsynopsis> <shortdesc> - - </shortdesc> - <desc> - - </desc> - </method> - - <method id="gtk.gtklayout.method.set_hadjustment"> - <funcsynopsis> - <funcprototype> - <funcdef>void <function>set_hadjustment</function></funcdef> - <paramdef> - <classname>GtkAdjustment</classname> - <parameter>adjustment</parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <shortdesc> - + Returns the vertical adjustment object. </shortdesc> <desc> - + <simpara> + This method is used internally to set the vertical scrollbar + adjustment in the <classname>GtkScrolledWindow</classname> holding + the <classname>GtkLayout</classname>. These sets of adjustment + objects are interchangeable, i.e. they share the same values. + </simpara> </desc> </method> - <method id="gtk.gtklayout.method.set_vadjustment"> - <funcsynopsis> - <funcprototype> - <funcdef>void <function>set_vadjustment</function></funcdef> - <paramdef> - <classname>GtkAdjustment</classname> - <parameter>adjustment</parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <shortdesc> - - </shortdesc> - <desc> - - </desc> - </method> + <!-- DELETED set_hadjustment(), set_vadjustment() - these adjustments + are set internally and cannot be altered. -sf mar 02 --> <method id="gtk.gtklayout.method.freeze"> <funcsynopsis> @@ -171,10 +256,18 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Freezes the display during an update. </shortdesc> <desc> - + <simpara> + Use <function class="GtkLayout">freeze()</function> when you are + updating a large amount of data, e.g. a large pixmap or series + of pixmaps. Calling this method prior to the update will speed up + the process and reduce flicker. + </simpara> + <simpara> + See also: <function class="GtkLayout">thaw()</function>. + </simpara> </desc> </method> @@ -186,10 +279,14 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Allows the display to be updated. </shortdesc> <desc> - + <simpara> + <function class="GtkLayout">thaw()</function> is the corollary of + <function class="GtkLayout">freeze()</function>. It allows the + display to be redrawn after the new data is fully assimilated. + </simpara> </desc> </method> Index: php-gtk-doc/en/reference/gtk/gtkstyle.xml diff -u php-gtk-doc/en/reference/gtk/gtkstyle.xml:1.2 php-gtk-doc/en/reference/gtk/gtkstyle.xml:1.3 --- php-gtk-doc/en/reference/gtk/gtkstyle.xml:1.2 Thu Mar 7 16:28:19 2002 +++ php-gtk-doc/en/reference/gtk/gtkstyle.xml Sat Mar 9 04:22:58 2002 @@ -97,9 +97,9 @@ $label = $button[5]->child; $label->set_style($newstyle); -/* gdk::color_parse() uses the colors that are already defined on your system - to fill a GdkColor structure invisibly. 'ivory' may not be a color on - your system. Try a more universal color, like 'red', if it fails. */ +/* gdk::color_parse() uses a color that is defined on your system to fill + a GdkColor structure. It can be more convenient than manually creating + a new GdkColor, particularly if you're only assigning the color once. */ $newstyle->bg[GTK_STATE_NORMAL] = gdk::color_parse('ivory'); $button[5]->set_style($newstyle);
Index: php-gtk-doc/en/reference/gdk/gdkcolor.xml diff -u php-gtk-doc/en/reference/gdk/gdkcolor.xml:1.1 php-gtk-doc/en/reference/gdk/gdkcolor.xml:1.2 --- php-gtk-doc/en/reference/gdk/gdkcolor.xml:1.1 Thu Jan 31 15:02:43 2002 +++ php-gtk-doc/en/reference/gdk/gdkcolor.xml Sat Mar 9 04:22:57 2002 @@ -4,10 +4,33 @@ <classtitle>GdkColor</classtitle> <classparent></classparent> <shortdesc> - + A structure that holds a defined color. </shortdesc> <desc> - + <simpara> + A <classname>GdkColor</classname> provides an object structure for + retaining information about a defined color. + </simpara> + <simpara> + This is an XcmsColor structure, and will take values in any XcmsColor + format accordingly. Probably the most generally useful of these formats + is the gamma-corrected XcmsRGB structure, which takes the range + <literal>0</literal> to <literal>65535</literal> per RGB value, with + <literal>0, 0, 0</literal> being the color black. RGB values that are + given in this way are scaled to match the color range of the hardware + device currently being used. + </simpara> + <simpara> + Colors can be assigned through an application's RC files, where the + <classname>GdkColor</classname> objects are constructed via the + application colormap defined through the file. Colors that are assigned + in this way can be constructed using any of the formats accepted by the + XcmsColor structure, including intensity doubles. + </simpara> + <simpara> + Note that this is not the case when assigning a color to a + <classname>GdkColor</classname> directly. + </simpara> </desc> </classmeta> @@ -15,14 +38,61 @@ <funcsynopsis> <funcprototype> <funcdef> <function>GdkColor</function></funcdef> - <paramdef></paramdef> + <paramdef>int <parameter>red</parameter></paramdef> + <paramdef>int <parameter>green</parameter></paramdef> + <paramdef>int <parameter>blue</parameter></paramdef> </funcprototype> </funcsynopsis> <shortdesc> - + Creates a new color object using one of three possible constructs. + <!-- + I've no way to express alternative constructors .. have I? - sf mar 02 + --> </shortdesc> <desc> - + <simpara> + When constructing a <classname>GdkColor</classname> directly, you will + need to use either hex RGB triples or XcmsRGB values. Attempting to use + other formats here will not result in an error message, because the + structure itself recognises them, but equally they will not display, + because the function doesn't recognise them at all. + </simpara> + <para> + The options when directly constructing colors in PHP-GTK are: + <informalexample> + <programlisting role="php"> +/* XcmsRGB values, expressed as three integers */ +$cyan = &new GdkColor(0, 65535, 65535); + </programlisting> + </informalexample> + or + <informalexample> + <programlisting role="php"> +/* hex triples expressed as a single string */ +$cyan = &new GdkColor('#00FFFF'); + </programlisting> + </informalexample> + or + <informalexample> + <programlisting role="php"> +/* a color name expressed as a single string */ +$cyan = &new GdkColor('cyan'); + </programlisting> + </informalexample> + Color names that are used on a given system are defined in a file + named <filename>rgb.txt</filename>. The equivalent file is not + available in human-readable form under win32, although utilised. + <ulink url="&url.rgbtxt;">Here</ulink> is one of the better reference + pages currently online detailing the standard color names used by + window management systems. + </para> + <simpara> + See also: <classname>GtkStyle</classname>. + </simpara> + <!-- + TODO We definitely, definitely need something in the userguide on + RC files, soonest - sf mar 02 + --> </desc> </constructor> Index: php-gtk-doc/en/reference/gtk/gtk-functions.xml diff -u php-gtk-doc/en/reference/gtk/gtk-functions.xml:1.6 php-gtk-doc/en/reference/gtk/gtk-functions.xml:1.7 --- php-gtk-doc/en/reference/gtk/gtk-functions.xml:1.6 Wed Feb 20 20:08:41 2002 +++ php-gtk-doc/en/reference/gtk/gtk-functions.xml Sat Mar 9 04:22:57 2002 @@ -431,7 +431,7 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Not implemented. </shortdesc> <desc> @@ -1338,10 +1338,27 @@ </funcprototype> </funcsynopsis> <shortdesc> - + A quick way to draw focus-like shadow around a given rectangle. </shortdesc> <desc> - + <simpara> + <function>gtk::paint_focus()</function> is a convenience function + that draws a dark shadow along the left and top sides of the given + rectangle, making it appear as GTK widgets generally do when they + have focus. + </simpara> + <simpara> + This is the only function that uses the <parameter>detail</parameter> + parameter at all now; if you pass <literal>'set-mode'</literal> as + that parameter, the shadow will appear as long dashes rather than as + a continuous line. Any other string is regarded the same as if it + were <literal>null</literal>. + </simpara> + <simpara> + The other parameters are on the whole self-explanatory. The + <parameter>widget</parameter> parameter refers to the widget that is + being drawn upon (usually a <classname>GtkDrawingArea</classname>). + </simpara> </desc> </method> Index: php-gtk-doc/en/reference/gtk/gtkdrawingarea.xml diff -u php-gtk-doc/en/reference/gtk/gtkdrawingarea.xml:1.4 php-gtk-doc/en/reference/gtk/gtkdrawingarea.xml:1.5 --- php-gtk-doc/en/reference/gtk/gtkdrawingarea.xml:1.4 Sun Jan 20 14:47:43 2002 +++ php-gtk-doc/en/reference/gtk/gtkdrawingarea.xml Sat Mar 9 04:22:58 2002 @@ -7,7 +7,35 @@ Widget for custom user interface elements. </shortdesc> <desc> - + <simpara> + A <classname>GtkDrawingArea</classname> is a widget whose + <classname>GdkWindow</classname> can be drawn to. You could use it to + create a new user interface element, or an updateable graph, or pretty + much anything, using the GDK and GTK draw and paint functions. + </simpara> + <simpara> + Because it is in itself so featureless, everything has to be added to + a <classname>GtkDrawingArea</classname>. It will not respond to key or + button press events, unless you give it the ability to do so using + <function class="GtkWidget">set_events()</function> or + <function class="GtkWidget">add_events()</function>. It cannot have + keyboard focus, unless you set the <literal>GTK_CAN_FOCUS</literal> + flag. It does not regard what is drawn upon it as a clue to sizing, so + you have to size it. If you want it to react to resizing, you will need + to connect it to an appropriate callback via the + <signalname class="GtkWidget">configure-event</signalname> signal in + order to do so. It has no defining behaviour, beyond the ability to + manufacture configure events when it is allocated a new size. It's + basically a completely empty widget. + </simpara> + <note> + <simpara> + <emphasis> + Redraws should be created through an + <signalname class="GtkWidget">expose-event</signalname> handler. + </emphasis> + </simpara> + </note> </desc> </classmeta> @@ -19,10 +47,84 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Constructs a blank, drawable widget. </shortdesc> <desc> - + <para> + <example> + <title>Drawing to a <classname>GtkDrawingArea</classname></title> + <programlisting role="php"> +dl('php_gtk.'.(strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); + +function draw_it($drawingarea, $event, $style, $gdkwindow) { + /* access the GdkWindow's colormap to associate a color with a GdkGC */ + $colormap = $gdkwindow->colormap; + $yellow = $gdkwindow->new_gc(); + $yellow->foreground = $colormap->alloc('yellow'); + $red = $gdkwindow->new_gc(); + $red->foreground = $colormap->alloc('red'); + + /* set up fonts. The first font here is set as part of the drawingarea's + style property so that it will be used in gtk::draw_string(). */ + $font = + gdk::font_load('-unknown-Arial-bold-r-normal--*-120-*-*-p-0-iso8859-1'); + $style->font = $font; + $font2 = + gdk::font_load('-unknown-Arial-bold-r-normal--*-720-*-*-p-0-iso8859-1'); + + /* call the appropriate drawing functions */ + gdk::draw_rectangle($gdkwindow, $style->white_gc, true, 0, 0, 200, 220); + gdk::draw_rectangle($gdkwindow, $yellow, true, 50, 50, 100, 100); + gdk::draw_string($gdkwindow, $font2, $style->white_gc, 75, 130, '?'); + gdk::draw_line($gdkwindow, $red, 20, 20, 180, 180); + gdk::draw_line($gdkwindow, $red, 20, 180, 180, 20); + gtk::draw_string($style, $gdkwindow, GTK_STATE_NORMAL, 12, 210, + 'SAY TO SQUARE EGGS!'); + gdk::draw_string($gdkwindow, $font, $red, 42, 210, 'NO'); +} + +function press_it($drawingarea, $event, $style, $gdkwindow) { + /* make the drawingarea look like it has been pressed down */ + $rectangle = &new GdkRectangle(0, 0, 200, 220); + gtk::paint_focus($style, $gdkwindow, $rectangle, $drawingarea, null, 0, 0, + 200, 220); +} + +function redraw_it($drawingarea, $event) { + /* trigger a new expose event */ + $drawingarea->queue_draw(); +} + +/* set up the main window that will hold the drawing area */ +$window = &new GtkWindow(); +$window->set_position(GTK_WIN_POS_CENTER); +$window->connect_object('destroy', array('gtk', 'main_quit')); + +/* set up the drawing area. Sizing is taken from the parent, unless set. + We need to add events so that the drawingarea is sensitive to the mouse, + using set_events() to do this because the widget is not realized yet. */ +$drawingarea = &new GtkDrawingArea(); +$drawingarea->size(200, 220); +$drawingarea->set_events(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); +$window->add($drawingarea); + +/* once the drawing area has been added to the window we can realize() it, + which means that we can now access its properties */ +$drawingarea->realize(); +$style = $drawingarea->style; +$gdkwindow = $drawingarea->window; + +/* drawing should always follow an expose event */ +$drawingarea->connect('expose-event', 'draw_it', $style, $gdkwindow); +$drawingarea->connect('button-press-event', 'press_it', $style, +$gdkwindow); +$drawingarea->connect('button-release-event', 'redraw_it'); + +$window->show_all(); +gtk::main(); + </programlisting> + </example> + </para> </desc> </constructor> @@ -37,10 +139,15 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Sets the size of the drawing area. </shortdesc> <desc> - + <simpara> + A <classname>GtkDrawingArea</classname> has no default size set. If + none is given, it will default to the size allocated to it by its parent + window. Note that the size set using this method is treated as the + drawingarea's size request, and may be overridden in some situations. + </simpara> </desc> </method> Index: php-gtk-doc/en/reference/gtk/gtklayout.xml diff -u php-gtk-doc/en/reference/gtk/gtklayout.xml:1.5 php-gtk-doc/en/reference/gtk/gtklayout.xml:1.6 --- php-gtk-doc/en/reference/gtk/gtklayout.xml:1.5 Thu Mar 7 16:28:19 2002 +++ php-gtk-doc/en/reference/gtk/gtklayout.xml Sat Mar 9 04:22:58 2002 @@ -7,7 +7,30 @@ Scrollable widget allowing multiple children in fixed positions. </shortdesc> <desc> - + <simpara> + A <classname>GtkLayout</classname> is a scrollable widget that provides + a scrolling-aware backdrop for a child or children having fixed + positions. It should be added directly to a + <classname>GtkScrolledWindow</classname>. + </simpara> + <simpara> + Note that the scrolling does not work on win32 unless you program it + to do so. There have been no such problems reported on other systems. + The workaround under win32 is to connect the + <classname>GtkScrolledWindow</classname> scrollbar adjustments' + <signalname class="GtkAdjustment">value-changed</signalname> signals + to a function that will force the <classname>GtkLayout</classname> to + be redrawn. This can be + <function class="GtkWidget">queue_draw()</function> in most situations, + but the more complex child widgets will not respond to this alone and + will need to have <function class="GtkWidget">hide()</function> and + then <function class="GtkWidget">show()</function> called on the + <classname>GtkLayout</classname> during the callback. + </simpara> + <simpara> + Note that GtkHtml is based on the <classname>GtkLayout</classname> + class, and that similar redraw issues are seen with that widget. + </simpara> </desc> </classmeta> @@ -26,10 +49,82 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Creates a scrollable backdrop whose children retain their positions. </shortdesc> <desc> - + <para> + The following example is based on the GTK+ test file + <filename>testgtk.c</filename>. Unix users will not need to use + the callback function in order to achieve scrolling, but it shouldn't + do any harm to run it as it stands. Win32 users will find that the + labels are redrawn and the buttons are not, giving a somewhat + psychedelic effect. To redraw both types of object under win32, + replace the callback function with: + <informalexample> + <programlisting role="php"> +function exposure($adj, $layout) { + $layout->hide(); + $layout->show(); +} + </programlisting> + </informalexample> + </para> + <para> + <example> + <title>Forcing a <classname>GtkLayout</classname> to redraw</title> + <programlisting role="php"> +dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); + +/* callback that forces a redraw of simple child widgets */ +function exposure($adj, $layout) { + $layout->queue_draw(); +} + +/* set up a window and size it to be smaller than the intended layout */ +$window = &new GtkWindow(); +$window->set_position(GTK_WIN_POS_CENTER); +$window->set_title('Layout'); +$window->set_usize(200, 200); +$window->connect_object('destroy', array('gtk', 'main_quit')); + +/* create and add the scrolled window to the main window */ +$scrolledwindow = &new GtkScrolledWindow(); +$window->add($scrolledwindow); + +/* create and add the layout widget to the scrolled window */ +$layout = &new GtkLayout(null, null); +$scrolledwindow->add($layout); + +/* set the layout to be bigger than the windows that contain it */ +$x = gdk::screen_width(); +$y = gdk::screen_height(); +$layout->set_size($x, $y); + +/* get the adjustment objects and connect them to the callback. This + part should not be necessary under *nix systems */ +$hadj = $scrolledwindow->get_hadjustment(); +$vadj = $scrolledwindow->get_vadjustment(); +$hadj->connect('value-changed', 'exposure', $layout); +$vadj->connect('value-changed', 'exposure', $layout); + +/* populate the layout with a mixture of buttons and labels */ +for ($i=0 ; $i < round($y/100); $i++) { + for ($j=0 ; $j < round($x/100); $j++) { + $buf =sprintf('Button %d, %d', $i, $j); + if (($i + $j) % 2) $button = &new GtkButton($buf); + else $button = &new GtkLabel($buf); + $layout->put($button, $j*100, $i*100); + } +} + +/* display everything and run the main loop */ +$layout->show_all(); +$window->show_all(); + +gtk::main(); + </programlisting> + </example> + </para> </desc> </constructor> @@ -48,10 +143,14 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Fixes a child widget at the given position. </shortdesc> <desc> - + <simpara> + This method adds a child widget to the layout. The top left + corner of the child widget will be positioned at the co-ordinates + passed in the <literal>x, y</literal> parameters. + </simpara> </desc> </method> @@ -68,10 +167,14 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Moves a child widget to a new position. </shortdesc> <desc> - + <simpara> + This method takes a child widget that has already been added to + the <classname>GtkLayout</classname> and moves it to a new position + reflecting the co-ordinates passed in the parameters. + </simpara> </desc> </method> @@ -84,10 +187,15 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Sets the size of the layout. </shortdesc> <desc> - + <simpara> + Sets the size of the <classname>GtkLayout</classname>. If you do + not call this method the layout will size itself according to the + size allocation given it by the parent window, rather than the size + requisition of the layout's child widgets. + </simpara> </desc> </method> @@ -102,10 +210,15 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Returns the horizontal adjustment object. </shortdesc> <desc> - + <simpara> + This method is used internally to set the horizontal scrollbar + adjustment in the <classname>GtkScrolledWindow</classname> holding + the <classname>GtkLayout</classname>. These sets of adjustment + objects are interchangeable, i.e. they share the same values. + </simpara> </desc> </method> @@ -120,48 +233,20 @@ </funcprototype> </funcsynopsis> <shortdesc> - - </shortdesc> - <desc> - - </desc> - </method> - - <method id="gtk.gtklayout.method.set_hadjustment"> - <funcsynopsis> - <funcprototype> - <funcdef>void <function>set_hadjustment</function></funcdef> - <paramdef> - <classname>GtkAdjustment</classname> - <parameter>adjustment</parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <shortdesc> - + Returns the vertical adjustment object. </shortdesc> <desc> - + <simpara> + This method is used internally to set the vertical scrollbar + adjustment in the <classname>GtkScrolledWindow</classname> holding + the <classname>GtkLayout</classname>. These sets of adjustment + objects are interchangeable, i.e. they share the same values. + </simpara> </desc> </method> - <method id="gtk.gtklayout.method.set_vadjustment"> - <funcsynopsis> - <funcprototype> - <funcdef>void <function>set_vadjustment</function></funcdef> - <paramdef> - <classname>GtkAdjustment</classname> - <parameter>adjustment</parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <shortdesc> - - </shortdesc> - <desc> - - </desc> - </method> + <!-- DELETED set_hadjustment(), set_vadjustment() - these adjustments + are set internally and cannot be altered. -sf mar 02 --> <method id="gtk.gtklayout.method.freeze"> <funcsynopsis> @@ -171,10 +256,18 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Freezes the display during an update. </shortdesc> <desc> - + <simpara> + Use <function class="GtkLayout">freeze()</function> when you are + updating a large amount of data, e.g. a large pixmap or series + of pixmaps. Calling this method prior to the update will speed up + the process and reduce flicker. + </simpara> + <simpara> + See also: <function class="GtkLayout">thaw()</function>. + </simpara> </desc> </method> @@ -186,10 +279,14 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Allows the display to be updated. </shortdesc> <desc> - + <simpara> + <function class="GtkLayout">thaw()</function> is the corollary of + <function class="GtkLayout">freeze()</function>. It allows the + display to be redrawn after the new data is fully assimilated. + </simpara> </desc> </method> Index: php-gtk-doc/en/reference/gtk/gtkstyle.xml diff -u php-gtk-doc/en/reference/gtk/gtkstyle.xml:1.2 php-gtk-doc/en/reference/gtk/gtkstyle.xml:1.3 --- php-gtk-doc/en/reference/gtk/gtkstyle.xml:1.2 Thu Mar 7 16:28:19 2002 +++ php-gtk-doc/en/reference/gtk/gtkstyle.xml Sat Mar 9 04:22:58 2002 @@ -97,9 +97,9 @@ $label = $button[5]->child; $label->set_style($newstyle); -/* gdk::color_parse() uses the colors that are already defined on your system - to fill a GdkColor structure invisibly. 'ivory' may not be a color on - your system. Try a more universal color, like 'red', if it fails. */ +/* gdk::color_parse() uses a color that is defined on your system to fill + a GdkColor structure. It can be more convenient than manually creating + a new GdkColor, particularly if you're only assigning the color once. */ $newstyle->bg[GTK_STATE_NORMAL] = gdk::color_parse('ivory'); $button[5]->set_style($newstyle);