cvs: php-gtk-doc /examples/reference/gtk/gtkwindow activate_default.phpw add_mnemonic.phpw constructor.phpw get_focus.phpw /manual/en/reference/gtk
gtkwindow.xml

From: Date: Fri, 13 Jan 2006 11:19:41 +0000
Subject: cvs: php-gtk-doc /examples/reference/gtk/gtkwindow activate_default.phpw add_mnemonic.phpw constructor.phpw get_focus.phpw /manual/en/reference/gtk
gtkwindow.xml
Groups: php.gtk.doc 
Request: Send a blank email to php-gtk-doc+get-1754@lists.php.net to get a copy of this message
cweiske Fri Jan 13 11:19:41 2006 UTC Added files: /php-gtk-doc/examples/reference/gtk/gtkwindow activate_default.phpw add_mnemonic.phpw constructor.phpw get_focus.phpw Modified files: /php-gtk-doc/manual/en/reference/gtk gtkwindow.xml Log: Some method docs and examples for GtkWindow

http://cvs.php.net/viewcvs.cgi/php-gtk-doc/manual/en/reference/gtk/gtkwindow.xml?r1=1.8&r2=1.9&diff_format=u Index: php-gtk-doc/manual/en/reference/gtk/gtkwindow.xml diff -u php-gtk-doc/manual/en/reference/gtk/gtkwindow.xml:1.8 php-gtk-doc/manual/en/reference/gtk/gtkwindow.xml:1.9 --- php-gtk-doc/manual/en/reference/gtk/gtkwindow.xml:1.8 Sun Aug 28 20:45:23 2005 +++ php-gtk-doc/manual/en/reference/gtk/gtkwindow.xml Fri Jan 13 11:19:41 2006 @@ -24,24 +24,10 @@ <example> <title>Adding too many children.</title> <programlisting role="php"> -<![CDATA[ -<?php -// Create a new window. -$window = new GtkWindow(); - -// Add two buttons. -$window->add(new GtkButton('1')); -$window->add(new GtkButton('2')); - -/* -Spits out: -Gtk-WARNING **: Attempting to add a widget with type GtkButton to -a GtkWindow, but as a GtkBin subclass a GtkWindow can only -contain one widget at a time; it already contains a widget -of type GtkButton -*/ -?> -]]> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/reference/gtk/gtkwindow/constructor.phpw" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> </programlisting> </example> </para> @@ -59,24 +45,24 @@ <funcsynopsis> <funcprototype> <funcdef> <function>GtkWindow</function></funcdef> - <paramdef>GtkWindowType <parameter><optional>type = GTK::WINDOW_TOPLEVEL</optional></parameter></paramdef> + <paramdef><enumname>GtkWindowType</enumname> <parameter><optional>type = GTK::WINDOW_TOPLEVEL</optional></parameter></paramdef> </funcprototype> </funcsynopsis> <shortdesc> Creates a new GtkWindow instance. </shortdesc> <desc> - <simpara> + <para> Creates a new instance of GtkWindow of type <parameter>type</parameter>. If no <parameter>type</parameter> is passed, the window will be created as - a <enumname>GTK::WINDOW_TOPLEVEL</enumname>. This means that the window + a <enumname>Gtk::WINDOW_TOPLEVEL</enumname>. This means that the window will have borders and a title bar by default. Windows of type - <enumname>GTK::WINDOW_POPUP</enumname> will not have borders or a title + <enumname>Gtk::WINDOW_POPUP</enumname> will not have borders or a title bar. Popup windows are used for things such as tooltips and menus. They should not be used to create regular windows without borders. For that you should use a toplevel window and - <function class="GtkWindow">set_decorated</function>. - </simpara> + <function class="GtkWindow">set_decorated</function>. + </para> </desc> </constructor> @@ -92,14 +78,43 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Send the activate signal to the default widget. </shortdesc> <desc> <para> - See also: + Activates the window's default widget (e.g. sends the + <signalname class="GtkButton">activate</signalname> signal to the widget). + Returns <literal>true</literal> if the widget could be activated, + <literal>false</literal> if not. + </para> + <note> + <para> + Before you can activate the default widget, you need to define it + with <function class="GtkWindow">set_default</function>. + </para> + </note> + <para> + That is very useful if you don't know which widget the default one is + (or don't care about that), but need to cause it to be clicked/activated. + The example shows how this method is used to cause the default button to + be activated when the user presses the <literal>Return</literal> key on + the text entry widget. + </para> + <para> + <example> + <title>Activating the button with return key on entry</title> + <programlisting role="php"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/reference/gtk/gtkwindow/activate_default.phpw" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + </para> + <para> + See also: <function class="GtkWindow">set_default</function> </para> - </desc> </method> @@ -111,15 +126,18 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Activates the widget with the focus. </shortdesc> <desc> <para> - See also: - <function class="GtkWindow">get_focus</function>, + Activates the current focused widget within the window. + Returns <literal>true</literal> if the widget got activated. + </para> + <para> + See also: + <function class="GtkWindow">get_focus</function>, <function class="GtkWindow">set_focus</function> </para> - </desc> </method> @@ -131,10 +149,20 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Activate a keyboard shortcut in the window by hand. </shortdesc> <desc> - + <para> + Activates mnemonics and accelerators for this GtkWindow. + This is normally called by the default key_press_event + handler for toplevel windows, however in some cases it + may be useful to call this directly when overriding + the standard key handling for a toplevel window. + </para> + <para> + Returns <literal>true</literal> if a mnemonic or accelerator + was found and activated. + </para> </desc> </method> @@ -142,7 +170,7 @@ <funcsynopsis> <funcprototype> <funcdef>void <function>add_accel_group</function></funcdef> - <paramdef>GtkAccelGroup <parameter>accel_group</parameter></paramdef> + <paramdef><classname>GtkAccelGroup</classname> <parameter>accel_group</parameter></paramdef> </funcprototype> </funcsynopsis> <shortdesc> @@ -150,13 +178,17 @@ </shortdesc> <desc> <para> + Associate <parameter>accel_group</parameter> with the window, such + that pressing shortcuts and mnemonics on the window will activate + accelerators in <parameter>accel_group</parameter>. + </para> + <para> See also: <function class="GtkWindow">remove_accel_group</function> </para> - </desc> </method> - +<!-- Doesn't exist any more <method id="gtk.gtkwindow.method.add_embedded_xid"> <funcsynopsis> <funcprototype> @@ -175,24 +207,53 @@ </desc> </method> +--> <method id="gtk.gtkwindow.method.add_mnemonic"> <funcsynopsis> <funcprototype> <funcdef>void <function>add_mnemonic</function></funcdef> <paramdef>int <parameter>keyval</parameter></paramdef> - <paramdef>GtkWidget <parameter>target</parameter></paramdef> + <paramdef><classname>GtkWidget</classname> <parameter>target</parameter></paramdef> </funcprototype> </funcsynopsis> <shortdesc> - + Adds a mnemonic to the window. </shortdesc> <desc> <para> - See also: + Adds a mnemonic to the window. Whenever the mnemonic key is pressed, + the <parameter>target</parameter> widget will be activated. + </para> + <para> + The <parameter>keyval</parameter> parameter is the ASCII number of the + letter which shall cause the mnemonic to be activated. E.g. if you want + <literal>Alt+K</literal> to activate a <literal>$button</literal>, the + keyval would be + <programlisting role="php"><![CDATA[ord('K')]]></programlisting> that is + value <literal>75</literal> in ASCII. + </para> + <note> + <para> + Before the window gets destroyed, you have to remove the mnemonic by + hand if you don't want a warning to be thrown. + </para> + </note> + <para> + <example> + <title>Adding a mnemonic by hand</title> + <programlisting role="php"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/reference/gtk/gtkwindow/add_mnemonic.phpw" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + </para> + <para> + See also: <function class="GtkWindow">remove_mnemonic</function> </para> - </desc> </method> @@ -284,14 +345,17 @@ </funcprototype> </funcsynopsis> <shortdesc> - + If the window wants to be focusable or not. </shortdesc> <desc> <para> - See also: + Returns the value set with + <function class="GtkWindow">set_accept_focus</function>. + </para> + <para> + See also: <function class="GtkWindow">set_accept_focus</function> </para> - </desc> </method> @@ -320,19 +384,29 @@ <method id="gtk.gtkwindow.method.get_default_size"> <funcsynopsis> <funcprototype> - <funcdef>void <function>get_default_size</function></funcdef> + <funcdef>array <function>get_default_size</function></funcdef> <paramdef>void</paramdef> </funcprototype> </funcsynopsis> <shortdesc> - + Returns the window's default size. </shortdesc> <desc> <para> - See also: + Gets the default size of the window. A value of <literal>-1</literal> + for the width or height indicates that a default size has not been + explicitly set (with + <function class="GtkWindow">set_default_size</function>) for that + dimension, so the "natural" size of the window will be used. + </para> + <para> + The first value of the returned array is the width, the second + is the height. + </para> + <para> + See also: <function class="GtkWindow">set_default_size</function> </para> - </desc> </method> @@ -344,35 +418,59 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Whether the window will be destroyed with its transient parent. </shortdesc> <desc> <para> - See also: + Returns whether the window will be destroyed with its transient parent. + </para> + <para> + See also: <function class="GtkWindow">set_destroy_with_parent</function>, <propname class="GtkWindow">destroy_with_parent</propname> </para> - </desc> </method> <method id="gtk.gtkwindow.method.get_focus"> <funcsynopsis> <funcprototype> - <funcdef>GtkWidget <function>get_focus</function></funcdef> + <funcdef><classname>GtkWidget</classname> <function>get_focus</function></funcdef> <paramdef>void</paramdef> </funcprototype> </funcsynopsis> <shortdesc> - + Returns the widget that has the focus. </shortdesc> <desc> <para> - See also: + Retrieves the current focused widget within the window. Returns + <literal>NULL</literal> if no widget has the focus. + </para> + <note> + <para> + Note that this is the widget that would have the focus if the toplevel + window focused; if the toplevel window is not focused then + <programlisting role="php"><![CDATA[$widget->flags() & Gtk::HAS_FOCUS]]></programlisting> + will not be <literal>&gt; 0</literal> for the widget. + </para> + </note> + <para> + <example> + <title>Using GtkWindow::get_focus()</title> + <programlisting role="php"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/reference/gtk/gtkwindow/get_focus.phpw" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + </para> + <para> + See also: <function class="GtkWindow">activate_focus</function>, <function class="GtkWindow">set_focus</function> </para> - </desc> </method> @@ -384,14 +482,17 @@ </funcprototype> </funcsynopsis> <shortdesc> - + If window should receive the input focus when mapped. </shortdesc> <desc> <para> - See also: + Gets the value set by + <function class="GtkWindow">set_focus_on_map</function>. + </para> + <para> + See also: <function class="GtkWindow">set_focus_on_map</function> </para> - </desc> </method> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/reference/gtk/gtkwindow/activate_default.phpw?view=markup&rev=1.1 Index: php-gtk-doc/examples/reference/gtk/gtkwindow/activate_default.phpw +++ php-gtk-doc/examples/reference/gtk/gtkwindow/activate_default.phpw <?php //Create the widgets $wnd = new GtkWindow(); $vbox = new GtkVBox(); $entry = new GtkEntry(); $btn = new GtkButton('Button'); //add them to the box $vbox->pack_start($entry); $vbox->pack_start($btn); //add the box to the window $wnd->add($vbox); //little echo method function echoit($value) { echo $value . "\r\n"; } //connect the clicked signal to out echo method $btn->connect_simple('clicked', 'echoit', $btn->get_label()); $wnd->connect_simple('destroy', array('gtk', 'main_quit')); //here we let the activate signal of the gtkentry call the //activate_default method of the window $entry->connect_simple('activate', array($wnd, 'activate_default')); //allow our button to be the default widget $btn->set_flags(Gtk::CAN_DEFAULT); //set the button the default one in the window $wnd->set_default($btn); $wnd->show_all(); Gtk::main(); ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/reference/gtk/gtkwindow/add_mnemonic.phpw?view=markup&rev=1.1 Index: php-gtk-doc/examples/reference/gtk/gtkwindow/add_mnemonic.phpw +++ php-gtk-doc/examples/reference/gtk/gtkwindow/add_mnemonic.phpw <?php //Create the window and the box for the buttons $wnd = new GtkWindow(); $vbox = new GtkVBox(); //Button1 uses the easy method: An underscore before the //desired mnemonic adds the mnemonic automatically //Use Alt+1 to activate it $button1 = new GtkButton('Button _1'); //Button2's mnemonic will be added by and, so we don't //use an underscore here $button2 = new GtkButton('Button 2'); //pack the widgets $vbox->pack_start($button1); $vbox->pack_start($button2); $wnd->add($vbox); //little echo method function echoit($value) { echo $value . "\r\n"; } //if one of the button is clicked, it's label will be printed //on the console $button1->connect_simple('clicked', 'echoit', $button1->get_label()); $button2->connect_simple('clicked', 'echoit', $button2->get_label()); //Here we add the mnemonic for button2 by hand. So //pressing Alt+2 will cause button2 to be activated. $wnd->add_mnemonic(ord('2'), $button2); //We have to remove the mnemonic from the window before it gets destroyed //If we don't do this, a warning will be spit out $wnd->connect_simple('destroy', array($wnd, 'remove_mnemonic'), ord('2'), $button2); $wnd->connect_simple('destroy', array('gtk', 'main_quit')); $wnd->show_all(); Gtk::main(); ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/reference/gtk/gtkwindow/constructor.phpw?view=markup&rev=1.1 Index: php-gtk-doc/examples/reference/gtk/gtkwindow/constructor.phpw +++ php-gtk-doc/examples/reference/gtk/gtkwindow/constructor.phpw <?php // Create a new window. $window = new GtkWindow(); // Add two buttons. $window->add(new GtkButton('1')); $window->add(new GtkButton('2')); /* Spits out: Gtk-WARNING **: Attempting to add a widget with type GtkButton to a GtkWindow, but as a GtkBin subclass a GtkWindow can only contain one widget at a time; it already contains a widget of type GtkButton */ ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/reference/gtk/gtkwindow/get_focus.phpw?view=markup&rev=1.1 Index: php-gtk-doc/examples/reference/gtk/gtkwindow/get_focus.phpw +++ php-gtk-doc/examples/reference/gtk/gtkwindow/get_focus.phpw <?php /** * Start the script and use <Tab> key to cycle the focus * through the buttons. You will see the label of the focused * button be echoed to the console every second. * Also try to activate another window while the script is * running. */ $wnd = new GtkWindow(); $vbox = new GtkVBox(); //Create ten buttons we can focus with <Tab> for ($nA = 1; $nA <= 10; $nA++) { $button = new GtkButton('Button ' . $nA); $vbox->add($button); } /** * This method will write the label of the current * focused widget to the console * It returns true, so that the interval doesn't stop */ function echoFocusedLabel($wnd) { //get_focus() returns the widget if ($wnd->get_focus()->flags() & Gtk::HAS_FOCUS) { $focus = 'focus is set'; } else { $focus = 'focus is NOT set (window not focused?)'; } echo $wnd->get_focus()->get_label() . ' - ' . $focus . "\r\n"; return true; } //add a timeout of one second, so that the echoFocusedLabel //method will echo the label of the focused widget every second Gtk::timeout_add(1000, 'echoFocusedLabel', $wnd); $wnd->add($vbox); $wnd->connect_simple('destroy', array('gtk', 'main_quit')); $wnd->show_all(); Gtk::main(); ?>
« previous php.gtk.doc (#1754) next »