with Claw.Dialog, Claw.Brushes, Claw.Fonts;
package Claw.Dialog.Modeless is
    --
    -- CLAW - Class Library for Ada and Windows.
    --
    -- This package contains the modeless dialog class.
    --
    -- Copyright 1996, 1997  R.R. Software, Inc.
    -- P.O. Box 1512, Madison WI  53701
    -- All rights reserved.
    --

    pragma Elaborate_Body; -- Insure that the body is elaborated before anyone
	                   -- can call CLAW.

    -- Dialog Window class

    type Modeless_Dialog_Type is new CLAW.Dialog.Root_Dialog_Type with private;

    -- Operations:
    procedure Create (Dialog          : in out Modeless_Dialog_Type;
		      Dialog_Template : in String;
                      Owner           : in out CLAW.Root_Window_Type'Class;
		      Autoposition    : in Boolean := FALSE);
        -- Create a modeless dialog box and return to the caller.
	-- The template is Dialog_Template and the owner is Owner.
	-- If Autoposition is True, Claw will center the dialog box in
	-- its owner window.  Otherwise, the position set in the template will
	-- be used.
        -- Raises:
        --      Already_Valid_Error if the dialog box is already open.
	--	Not_Valid_Error if the owner window is not already open.
        --      Windows_Error if Windows returns an error.
	-- Note: Dialog Boxes are not child windows; they use screen
	-- coordinates for movement operations.  However, Get_Parent will
	-- return the owner window.

    procedure Create (Dialog		: in out Modeless_Dialog_Type;
		      Dialog_Name	: in String;
                      Owner		: in out CLAW.Root_Window_Type'Class;
		      Style		: in Claw.Dialog.Styles.Dialog_Style_Type := Claw.Dialog.Styles.Standard_Modeless;
		      Position		: in Rectangle_Type;
		      Position_in_Dialog_Units : in Boolean := FALSE;
		      Autoposition	: in Boolean := FALSE;
		      Within_Owner	: in Boolean := TRUE);
        -- Create a modeless dialog box and return to the caller.
	-- The dialog box will have the title Dialog_Name, the specified
	-- styles and position and the owner is Owner.  The dialog box will be
	-- empty; create controls in it in When_Initialize.  Position is in
	-- Dialog_Units if Position_in_Dialog_Units is true, and in pixels
	-- otherwise.
	-- If Autoposition is True, Claw will center the dialog box in
	-- its owner window.  Otherwise, the position specified by Position
	-- will be used.  If Within_Owner is True, the Position is intrepreted
	-- as client coordinates within Owner; otherwise, the Position is an
	-- absolute screen position.
        -- Raises:
        --      Already_Valid_Error if the dialog box is already open.
	--	Not_Valid_Error if the owner window is not already open.
        --      Windows_Error if Windows returns an error.
	-- Note: Dialog Boxes are not child windows; they use screen
	-- coordinates for movement operations.  However, Get_Parent will
	-- return the owner window.

    procedure Create (Dialog		: in out Modeless_Dialog_Type;
		      Dialog_Name	: in String;
                      Owner		: in out CLAW.Root_Window_Type'Class;
		      Style		: in Claw.Dialog.Styles.Dialog_Style_Type := Claw.Dialog.Styles.Standard_Modeless;
		      Position		: in Rectangle_Type;
		      Position_in_Dialog_Units : in Boolean := FALSE;
		      Font		: in Claw.Fonts.Font_Type'Class;
		      Autoposition	: in Boolean := FALSE;
		      Within_Owner	: in Boolean := TRUE);
        -- Create a modeless dialog box and return to the caller.
	-- The dialog box will have the title Dialog_Name, the specified
	-- styles and position and the owner is Owner.  The dialog box will be
	-- empty; create controls in it in When_Initialize.  Position is in
	-- Dialog_Units if Position_in_Dialog_Units is true, and in pixels
	-- otherwise. Font will be used to calculate dialog units, and
	-- controls whose owner is Dialog will use this font by default.
	-- If Autoposition is True, Claw will center the dialog box in
	-- its owner window.  Otherwise, the position specified by Position
	-- will be used.  If Within_Owner is True, the Position is intrepreted
	-- as client coordinates within Owner; otherwise, the Position is an
	-- absolute screen position.
        -- Raises:
        --      Already_Valid_Error if the dialog box is already open.
	--	Not_Valid_Error if the owner window is not already open.
        --      Windows_Error if Windows returns an error.
	-- Note: Dialog Boxes are not child windows; they use screen
	-- coordinates for movement operations.  However, Get_Parent will
	-- return the owner window.

    procedure Create (Dialog          : in out Modeless_Dialog_Type;
		      Dialog_Template : in String;
		      Autoposition    : in Boolean := FALSE);
        -- Create a modeless dialog box and return to the caller.
	-- The template is Dialog_Template.  If Autoposition is True, Claw
	-- will center the dialog box in the workspace.  Otherwise, the
	-- position set in the template will be used.
        -- Raises:
        --      Already_Valid_Error if the dialog box is already open.
        --      Windows_Error if Windows returns an error.

    procedure Create (Dialog		: in out Modeless_Dialog_Type;
		      Dialog_Name	: in String;
		      Style		: in Claw.Dialog.Styles.Dialog_Style_Type := Claw.Dialog.Styles.Standard_Modeless;
		      Position		: in Rectangle_Type;
		      Position_in_Dialog_Units : in Boolean := FALSE;
		      Autoposition	: in Boolean := FALSE);
        -- Create a modeless dialog box and return to the caller.
	-- The dialog box will have the title Dialog_Name, the specified
	-- styles and position.  The dialog box will be empty;
	-- create controls in it in When_Initialize.  Position is in
	-- Dialog_Units if Position_in_Dialog_Units is true, and in pixels
	-- otherwise.
	-- If Autoposition is True, Claw will center the dialog box in
	-- the workspace.  Otherwise, the position specified by Position
	-- will be used.
        -- Raises:
        --      Already_Valid_Error if the dialog box is already open.
	--	Not_Valid_Error if the owner window is not already open.
        --      Windows_Error if Windows returns an error.

    procedure Create (Dialog		: in out Modeless_Dialog_Type;
		      Dialog_Name	: in String;
		      Style		: in Claw.Dialog.Styles.Dialog_Style_Type := Claw.Dialog.Styles.Standard_Modeless;
		      Position		: in Rectangle_Type;
		      Position_in_Dialog_Units : in Boolean := FALSE;
		      Font		: in Claw.Fonts.Font_Type'Class;
		      Autoposition	: in Boolean := FALSE);
        -- Create a modeless dialog box and return to the caller.
	-- The dialog box will have the title Dialog_Name, the specified
	-- styles and position.  The dialog box will be empty;
	-- create controls in it in When_Initialize.  Position is in
	-- Dialog_Units if Position_in_Dialog_Units is true, and in pixels
	-- otherwise. Font will be used to calculate dialog units, and
	-- controls whose owner is Dialog will use this font by default.
	-- If Autoposition is True, Claw will center the dialog box in
	-- the workspace.  Otherwise, the position specified by Position
	-- will be used.
        -- Raises:
        --      Already_Valid_Error if the dialog box is already open.
	--	Not_Valid_Error if the owner window is not already open.
        --      Windows_Error if Windows returns an error.

    procedure Destroy (Dialog : in out Modeless_Dialog_Type);
	-- Destroy Dialog and all child windows.
	-- Raises:
	--	Not_Valid_Error if Window does not have a valid (Windows) window.
	--	Windows_Error if Windows returns an error.

    procedure Finalize (Dialog : in out Modeless_Dialog_Type);
	-- Finalize Dialog and all child windows.
	-- This will destroy the window and all child windows.
	-- (This routine is for the implicit calls made by Controlled types;
	-- for explicit calls, use Destroy instead.)

    -- Will inherit Get_Parent, Show, Update.

    procedure Set_Background_Brush (Dialog : in out Modeless_Dialog_Type;
				    Brush  : in out Claw.Brushes.Brush_Type);
	-- Set the Background brush for Dialog.
	-- Raises:
	--	Not_Valid_Error if Dialog does not have an open (Windows) window,
	--	    or if Brush is not valid.

    procedure Set_Default_Background (Dialog : in out Modeless_Dialog_Type);
	-- Set the background to the default color.
	-- Raises:
	--	Not_Valid_Error if Dialog does not have an open (Windows) window.

    function Get_Background_Brush (Dialog : in Modeless_Dialog_Type) return
	Claw.Brushes.Brush_Type;
	-- Get the Background brush for Dialog.
	-- Raises:
	--	Not_Valid_Error if Dialog does not have an open (Windows) window,
	--	    or if the window is using the default background.

    -- Action routines:

    -- Inherits When_Resize, When_Character, When_Key_Down,
    -- When_System_Character, When_System_Key_Down, When_Left_Button_Double_Click,
    -- When_Right_Button_Double_Click, When_Middle_Button_Double_Click,
    -- When_Left_Button_Down, When_Right_Button_Down, When_Middle_Button_Down,
    -- When_Left_Button_Up, When_Right_Button_Up, When_Middle_Button_Up,
    -- When_Horizontal_Scroll, and When_Vertical_Scroll.
    -- When_Create is inherited, but will never be called; use When_Initialize
    -- instead.


    procedure When_Child_Notify (Window  : in out Modeless_Dialog_Type;
				 Code    : in Notification_Code_Type;
				 Data	 : in Notification_Data_Type'Class;
				 Control : in out Root_Control_Type'Class;
				 Unknown_Command : in out Boolean);
	-- This procedure is called whenever a child control sends a notification
	-- to Window.  The specification notification is specified by Code,
	-- and Control is the control's Claw object.
	-- Notification_Codes are defined in the packages for the
	-- various controls.
	-- If this routine does not recognize (or handle) the command, it
	-- should return Unknown_Command = True.  This will cause CLAW to
	-- exceute the default action for the command, usually nothing
	-- (but some system commands do have default actions).
	-- This routine is often overridden to provide actions for the
	-- notifications.  If it is not overridden, all commands return
	-- Unknown_Command = True.
	-- Implementation notes: This routine handles some cases of the
	--	WM_COMMAND message and the WM_NOTIFY message.  If the
	--	WM_COMMAND or WM_NOTIFY message is from a
	--	control, but Claw cannot identify a control object for the
	--	message, it will execute the default action.  This can happen
	--	only if some action is taken outside of Claw: a control is
	--	created in a Claw window by some non-Claw means, or if a
	--	control command is sent from a non-control.
	--	We don't pass the Id parameter; this can be retrived by
	--	calling Get_Identifier(Control) or by retriving it from Data.

    procedure When_OK (Dialog : in out Modeless_Dialog_Type);
	-- This procedure is called whenever the OK button (if any) is pushed.
	-- The OK button has Id number CLAW.Dialog.ID_OK.
	-- By default, this routine calls Destroy.

    procedure When_Cancel (Dialog : in out Modeless_Dialog_Type);
	-- This procedure is called whenever the Cancel button (if any) is pushed.
	-- The Cancel button has Id number CLAW.Dialog.ID_Cancel.
	-- By default, this routine calls Destroy.

    procedure When_Help (Dialog : in out Modeless_Dialog_Type);
	-- This procedure is called whenever the Help button (if any) is pushed.
	-- The Help button has Id number CLAW.Dialog.ID_Help.
	-- By default, this routine does nothing.

    procedure When_Initialize (Dialog : in out Modeless_Dialog_Type;
			       Windows_Set_Focus : in out Boolean);
	-- This procedure is called when the dialog box is initialized.
	-- If this routine sets the input focus to a specific control, it
	-- should set Windows_Set_Focus to False; otherwise, it should set
	-- Windows_Set_Focus to True (Windows will then set the focus to
	-- an appropriate control).
	-- By default, this routine just shows the dialog box and lets Windows
	-- set the focus.

    procedure When_Close (Dialog : in out Modeless_Dialog_Type);
	-- This procedure is called whenever a dialog box is closed.
	-- By default, this routine calls Destroy.

    procedure When_Other_Message (Dialog      : in out Modeless_Dialog_Type;
				  The_Message : in     Claw.Win32.Short_Message_Record;
				  Do_Default  : in out Boolean;
				  Result      :    out Claw.Win32.LResult);
        -- This procedure is called when any unhandled message is passed to
        -- a dialog box.  Unless overridden, it just allows the default action
        -- for a message.  For a dialog box, Result is ignored.

    -- Low-level access:

    -- Inherits Get_Handle.

private
    type Modeless_Dialog_Type is new CLAW.Dialog.Root_Dialog_Type with null record;
end Claw.Dialog.Modeless;