This widget implements a top level window. It is used as the base class for dialogs, ...
A window has both a default widget (to which events are sent if no other widget has been selected and has the focus), and a focus widget (which gets the events and overrides the default widget).
You can set many hints on the window (its minimum and maximum size, its decoration, etc.) but these are only hints to the window manager, which might not respect them.
A useful hint, respected by most window managers, can be used to force some secondary windows to stay on top of the main window on the screen (for instance, so that a smaller window can not be hidden by a bigger one). See the function Set_Transient_For below.
A window can also be modal, i.e. grab all the mouse and keyboard events in the application while it is displayed.
Widget Hierarchy |
---|
Gtk_Object (see section Package Gtk.Object) \___ Gtk_Widget (see section Package Gtk.Widget) \___ Gtk_Container (see section Package Gtk.Container) \___ Gtk_Bin (see section Package Gtk.Bin) \___ Gtk_Window (see section Package Gtk.Window) |
Signals |
---|
Subprograms |
---|
procedure Gtk_New (Window : out Gtk_Window; The_Type : in Gtk.Enums.Gtk_Window_Type := Gtk.Enums.Window_Toplevel); | ||
Create a new window. | ||
function Get_Type return Gtk.Gtk_Type; | ||
Return the internal value associated with a Gtk_Window.
| ||
procedure Set_Title (Window : access Gtk_Window_Record; Title : in String); | ||
Change the title of the window, as it appears in the title bar. | ||
function Get_Title (Window : access Gtk_Window_Record) return String; | ||
Return the title of the window, or "" if there is none
| ||
procedure Set_Wmclass (Window : access Gtk_Window_Record; Wmclass_Name : in String; Wmclass_Class : in String); | ||
Specify the string to look for in the user's configuration files | ||
procedure Set_Policy (Window : access Gtk_Window_Record; Allow_Shrink : in Boolean; Allow_Grow : in Boolean; Auto_Shrink : in Boolean); | ||
Specify the behavior of the window with regards to size modifications. Allow_Shrink => False, Allow_Grow => True, Auto_Shrink => False.
If Allow_Shrink is False, then the minimum size of the window is
calculated once depending on its children, and the window can never be
smaller.
If Allow_Grow is False, then the maximum size of the window is
calculated once depending on its children, and the window can never be
bigger.
If Auto_Shrink if False, then the window is not shrinked when its
content changes.
| ||
procedure Add_Accel_Group (Window : access Gtk_Window_Record; Accel_Group : in Gtk.Accel_Group.Gtk_Accel_Group); | ||
Specify an accelerator group for the window.
| ||
procedure Remove_Accel_Group (Window : access Gtk_Window_Record; Accel_Group : in Gtk.Accel_Group.Gtk_Accel_Group); | ||
Remove the specified accelerator group for the window.
| ||
procedure Set_Position (Window : access Gtk_Window_Record; Position : in Gtk.Enums.Gtk_Window_Position); | ||
Specify how the position of the window should be computed. | ||
function Activate_Focus (Window : access Gtk_Window_Record) return Boolean; | ||
Call Gtk.Widget.Activate on the widget that currently has the focus in | ||
function Activate_Default (Window : access Gtk_Window_Record) return Boolean; | ||
Activate the default widget in the window. Gtk.Widget.Set_Flags (Widget, Can_Default);
Gtk.Widget.Grab_Default (Widget);
| ||
function Get_Transient_Parent (Window : access Gtk_Window_Record) return Gtk_Window; | ||
Return the window for which this one is a temporary window. | ||
procedure Set_Transient_For (Window : access Gtk_Window_Record; Parent : access Gtk_Window_Record'Class); | ||
Specify that Window is a transient window.
The main usage of this function is to force Window to be on top of
Parent on the screen at all times. Most window managers respect this
hint, even if this is not mandatory.
| ||
procedure Set_Geometry_Hints (Window : access Gtk_Window_Record; Geometry_Widget : Gtk.Widget.Gtk_Widget; Geometry : Gdk.Types.Gdk_Geometry; Geom_Mask : Gdk.Types.Gdk_Window_Hints); | ||
Specify some geometry hints for the window. Geometry.Base_* indicates the size that is used by the window manager to report the size: for instance, if Base_Width = 600 and actual width is 200, the window manager will indicate a width of -400. If your window manager respects the hints (and its doesn't have to), then the user will never be able to resize the window to a size not in Geometry.Min_* .. Geometry.Max_*. Geometry.*_Inc specifies by which amount the size will be multiplied. For instance, if Width_Inc = 50 and the size reported by the Window Manager is 2x3, then the actual width of the window is 100. Your window's size will always be a multiple of the *_Inc values.
Geometry.*_Aspect specifies the aspect ratio for the window. The window
will always be resized so that the ratio between its width and its
height remains in the range Min_Aspect .. Max_Aspect.
| ||
procedure Set_Default_Size (Window : access Gtk_Window_Record; Width : in Gint; Height : in Gint); | ||
Specify a minimal size for the window. | ||
procedure Set_Modal (Window : access Gtk_Window_Record; Modal : in Boolean := True); | ||
Define the window as being Modal. |
Example |
---|
-- This example shows how you can display a banner while your application is -- loading with Gtk.Window, Gtk.Enums, Gtk.Main, Gtk.Label; use Gtk.Window, Gtk.Enums, Gtk.Main, Gtk.Label; procedure Banner is Win : Gtk_Window; Label : Gtk_Label; begin Gtk.Main.Init; Gtk_New (Win, Window_Popup); Set_Policy (Win, Allow_Shrink => False, Allow_Grow => False, Auto_Shrink => False); Set_Position (Win, Win_Pos_Center); Set_Usize (Win, 300, 300); Gtk_New (Label, "You should show a pixmap instead..."); Add (Win, Label); Show_All (Win); Gtk.Main.Main; end Banner;