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 |
---|
GObject (see section Package Glib.Object) 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 : Gtk.Enums.Gtk_Window_Type := Gtk.Enums.Window_Toplevel); | ||
Create a new window. | ||
function Get_Type return Glib.GType; | ||
Return the internal value associated with a Gtk_Window.
| ||
procedure Set_Title (Window : access Gtk_Window_Record; Title : UTF8_String); | ||
Change the title of the window, as it appears in the title bar. | ||
function Get_Title (Window : access Gtk_Window_Record) return UTF8_String; | ||
Return the title of the window, or "" if there is none
| ||
procedure Set_Wmclass (Window : access Gtk_Window_Record; Wmclass_Name : String; Wmclass_Class : String); | ||
Don't use this function. It sets the X Window System "class" and | ||
procedure Set_Role (Window : access Gtk_Window_Record; Role : String); | ||
In combination with the window title, the window role allows a | ||
procedure Add_Accel_Group (Window : access Gtk_Window_Record; Accel_Group : Gtk.Accel_Group.Gtk_Accel_Group); | ||
Specify an accelerator group for the window.
| ||
procedure Remove_Accel_Group (Window : access Gtk_Window_Record; Accel_Group : Gtk.Accel_Group.Gtk_Accel_Group); | ||
Remove the specified accelerator group for the window.
| ||
procedure Set_Position (Window : access Gtk_Window_Record; Position : 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);
| ||
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_Type_Hint (Window : access Gtk_Window_Record; Hint : Gdk.Window.Gdk_Window_Type_Hint); | ||
allow the window manager to decorate and handle the window in a way | ||
procedure Set_Destroy_With_Parent (Window : access Gtk_Window_Record; Setting : Boolean := True); | ||
Set whether destroying the transient parent of Window will also destroy | ||
procedure Set_Resizable (Window : access Gtk_Window_Record; Resizable : Boolean := True); | ||
Set whether the user can resize a window. | ||
function Get_Resizable (Window : access Gtk_Window_Record) return Boolean; | ||
Whether the user can resize a window.
| ||
function Get_Resizeable (Window : access Gtk_Window_Record) return Boolean; | ||
This function is deprecated.
| ||
procedure Set_Gravity (Window : access Gtk_Window_Record; Gravity : Gdk.Window.Gdk_Gravity); | ||
Window gravity defines the "reference point" to be used when See Gdk_Gravity for full details. To briefly summarize, Gravity_North_West means that the reference point is the northwest (top left) corner of the window frame. Gravity_South_East would be the bottom right corner of the frame, and so on. If you want to position the window contents, rather than the window manager's frame, Gravity_Static moves the reference point to the northwest corner of the Gtk_Window itself.
The default window gravity is Gravity_North_West.
| ||
function Get_Gravity (Window : access Gtk_Window_Record) return Gdk.Window.Gdk_Gravity; | ||
Return the value set by Set_Gravity.
| ||
procedure Set_Geometry_Hints (Window : access Gtk_Window_Record; Geometry_Widget : Gtk.Widget.Gtk_Widget; Geometry : Gdk.Window.Gdk_Geometry; Geom_Mask : Gdk.Window.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_Has_Frame (Window : access Gtk_Window_Record); | ||
If this function is called on a window before it is realized
This function is used by the linux-fb port to implement managed
windows, but it could concievably be used by X-programs that
want to do their own window decorations.
| ||
procedure Set_Frame_Dimensions (Window : access Gtk_Window_Record; Left : Gint; Top : Gint; Right : Gint; Bottom : Gint); | ||
Change the size of the frame border. | ||
procedure Set_Decorated (Window : access Gtk_Window_Record; Setting : Boolean := True); | ||
By default, windows are decorated with a title bar, resize | ||
procedure Set_Modal (Window : access Gtk_Window_Record; Modal : Boolean := True); | ||
Define the window as being Modal. | ||
function List_Toplevels return Gtk.Widget.Widget_List.Glist; | ||
Return a list of all existing toplevel windows. | ||
procedure Present (Window : access Gtk_Window_Record); | ||
Present a window to the user. If Window is hidden, this function calls Gtk.Widget.Show as well.
This function should be used when the user tries to open a window
that's already open. Say for example the preferences dialog is
currently open, and the user chooses Preferences from the menu
a second time; use Present to move the already-open dialog
where the user can see it.
| ||
procedure Iconify (Window : access Gtk_Window_Record); | ||
Ask to iconify Window. It's permitted to call this function before showing a window, in which case the window will be iconified before it ever appears onscreen.
You can track iconification via the "window_state_event" signal
on Gtk_Widget.
| ||
procedure Deiconify (Window : access Gtk_Window_Record); | ||
Ask to deiconify Window.
You can track iconification via the "window_state_event" signal
on Gtk_Widget.
| ||
procedure Stick (Window : access Gtk_Window_Record); | ||
Ask to stick Window, which means that it will appear on all user It's permitted to call this function before showing a window.
You can track stickiness via the "window_state_event" signal
on Gtk_Widget.
| ||
procedure Unstick (Window : access Gtk_Window_Record); | ||
Ask to unstick Window, which means that it will appear on only
You can track stickiness via the "window_state_event" signal
on Gtk_Widget.
| ||
procedure Maximize (Window : access Gtk_Window_Record); | ||
Ask to maximize Window, so that it becomes full-screen. It's permitted to call this function before showing a window, in which case the window will be maximized when it appears onscreen initially.
You can track maximization via the "window_state_event" signal
on Gtk_Widget.
| ||
procedure Unmaximize (Window : access Gtk_Window_Record); | ||
Ask to unmaximize Window.
You can track maximization via the "window_state_event" signal
on Gtk_Widget.
| ||
function Get_Transient_For (Window : access Gtk_Window_Record) return Gtk_Window; | ||
Return the window for which this one is a temporary window. | ||
procedure Set_Default_Size (Window : access Gtk_Window_Record; Width : Gint; Height : Gint); | ||
Sets the default size of a window. If the window's "natural" size (its Unlike Gtk.Widget.Set_Size_Request, which sets a size request for a widget and thus would keep users from shrinking the window, this function only sets the initial size, just as if the user had resized the window themselves. Users can still shrink the window again as they normally would. Setting a default size of -1 means to use the "natural" default size (the size request of the window). For more control over a window's initial size and how resizing works, investigate Set_Geometry_Hints. For some uses, Resize is a more appropriate function. Resize changes the current size of the window, rather than the size to be used on initial display. Resize always affects the window itself, not the geometry widget. The default size of a window only affects the first time a window is shown; if a window is hidden and re-shown, it will remember the size it had prior to hiding, rather than using the default size. Windows can't actually be 0x0 in size, they must be at least 1x1, but passing 0 for Width and Height is OK, resulting in a 1x1 default size.
This has no effect on Popup windows (set in call to Gtk_New).
| ||
procedure Resize (Window : access Gtk_Window_Record; Width, Height : Gint); | ||
Resize the window as if the user had done so, obeying geometry If Resize is called before showing a window for the -- first time, it overrides any default size set with -- Set_Default_Size.
Windows may not be resized smaller than 1 by 1 pixels. However, as a
special case, if both Width and Height are set to -1, the best requested
size is recomputed for the window, and used.
| ||
procedure Add_Mnemonic (Window : access Gtk_Window_Record; Keyval : Gdk.Types.Gdk_Key_Type; Target : access Gtk.Widget.Gtk_Widget_Record'Class); | ||
Add a mnemonic to this window. | ||
Focus | ||
function Get_Focus (Window : access Gtk_Window_Record) return Gtk.Widget.Gtk_Widget; | ||
Return the widget that would have the keyboard focus if | ||
procedure Set_Focus (Window : access Gtk_Window_Record; Focus : Gtk.Widget.Gtk_Widget); | ||
Set the focus child for Window. |
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_Size_Request (Win, 300, 300); Gtk_New (Label, "You should show a pixmap instead..."); Add (Win, Label); Show_All (Win); Gtk.Main.Main; end Banner;