with Claw.Dialog;
package Claw.Dialog.Color is
--
-- CLAW - Class Library for Ada and Windows.
--
-- This package contains the Color Dialog class.
--
-- Copyright 1996, 1997 R.R. Software, Inc.
-- P.O. Box 1512, Madison WI 53701
-- All rights reserved.
--
pragma Elaborate_Body;
type Color_Dialog_Type is new CLAW.Dialog.Root_Dialog_Type with private;
-- Flags. Flags not listed here are reserved for Claw usage only.
-- Implementation note: Resources and hook routines are handled by Claw
-- as needed. Users are not allowed to set those.
type Color_Dialog_Flag_Type is private;
No_Flags : constant Color_Dialog_Flag_Type;
Full_Open : constant Color_Dialog_Flag_Type; -- Start with the custom colors box displayed.
Prevent_Full_Open : constant Color_Dialog_Flag_Type; -- Never show the custom colors box.
RGB_Init : constant Color_Dialog_Flag_Type; -- The initial value is the initial value
-- of RGB_Result; otherwise it is black.
Show_Help : constant Color_Dialog_Flag_Type; -- Include a Help button in the dialog box.
Solid_Color_Only : constant Color_Dialog_Flag_Type; -- not supported on Window 3.x. Force the selection of a solid color.
function "+" (Left, Right : in Color_Dialog_Flag_Type) return Color_Dialog_Flag_Type;
-- Combines two styles into a single style set value.
function "-" (Left, Right : in Color_Dialog_Flag_Type) return Color_Dialog_Flag_Type;
-- Removes an action from another action set.
function ">=" (Left, Right : in Color_Dialog_Flag_Type) return Boolean;
-- Read A >= B as A includes B
-- I.e. each set style in B is also in A.
function DWord_of (S : in Color_Dialog_Flag_Type) return CLAW.DWord;
-- Low-level access to styles.
function Color_Dialog_Flag_Type_Of (D : in Claw.DWord)
return Color_Dialog_Flag_Type;
-- Create a style from a DWord for low-level use.
type Custom_Color_Array_Type is array(0..15) of Claw.Colors.Color_Type;
-- Operations:
type Result_Type is (OK, Canceled);
procedure Choose_Color (Dialog : in out Color_Dialog_Type; -- Object
Owner : in out Claw.Root_Window_Type'Class;
RGB_Result : in out Claw.Colors.Color_Type;
Custom_Colors : in out Custom_Color_Array_Type;
Result_Action : out Result_Type;
Resource : in String := "";
Flags : in Color_Dialog_Flag_Type := NO_FLAGS;
Autoposition : in Boolean := False);
-- Open a Choose Color dialog box for the user to select a single RGB Value or modifiy the
-- color in the color dialog boxes.
-- RGB_Result The selected color.
-- Custom_Colors A 16 color Array that contains the color value
-- of the 16 custom color dialog boxes. If the user
-- modified the value(s), this array is modified and
-- returned.
-- Resource A customized resource template for the dialog box.
-- This parameter is generally used only with derived
-- classes.
-- Flags A combination of one or more flags that allow you to
-- customize the dialog box.
-- Autoposition If Autoposition is True, Claw will center the dialog
-- box in its owner window. Otherwise, it will let
-- Windows position it.
-- If the user closed or canceled the dialog box, Result_Action
-- equals Canceled, and the other parameters are undefined.
-- If the user finished the dialog box normally, Result_Action equals
-- OK, and the selected color is stored in RGB_Result.
-- Raises:
-- Not_Valid_Error if Owner is not open.
-- Already_Valid_Error if this dialog is already open.
-- Windows_Error if Windows reports an error.
procedure Set_Color (Dialog : in out Color_Dialog_Type;
Color : in Claw.Colors.Color_Type);
-- Set the "selected" Color for Dialog. The color supplied is set
-- as the selection if it matches one of the primary or custom colors;
-- otherwise, it is set into the custom colors dialog only.
-- Since Dialog has to be open, this routine can only usefully be
-- used inside of an action routine.
-- Raises:
-- Not_Valid_Error if Dialog is not open.
procedure Abort_Dialog (Dialog : in out Color_Dialog_Type);
-- Abort the dialog at the next opportunity. If the dialog is
-- already closed, this does nothing. This is intended to be used
-- from action routines. Note: This routine does return; the
-- abort occurs after the action routine that it is called from
-- returns.
-- Action routines:
procedure When_Child_Notify (Window : in out Color_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 Color_Dialog_Type);
-- This procedure is called whenever the OK button (if any) is pushed.
-- The OK button has Id number ID_OK.
-- For a color dialog, any default processing is done afterwards.
procedure When_Cancel (Dialog : in out Color_Dialog_Type);
-- This procedure is called whenever the Cancel button (if any) is pushed.
-- The Cancel button has Id number ID_Cancel.
-- For a color dialog, any default processing is done afterwards.
procedure When_Help (Dialog : in out Color_Dialog_Type);
-- This procedure is called whenever the Help button (if any) is pushed.
-- The Help button has Id number ID_Help.
-- For a color dialog, any default processing is done afterwards.
procedure When_Initialize (Dialog : in out Color_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).
-- The routine can be used to set up edit and listbox controls in
-- the dialog box.
-- This routine is called AFTER the predefined part of the dialog
-- box is set up.
procedure When_Close (Dialog : in out Color_Dialog_Type);
-- This procedure is called whenever a dialog box is closed.
-- By default, this routine does nothing.
-- For a color dialog, default processing occurs after this routine.
procedure When_Color_OK (Dialog : in out Color_Dialog_Type;
Color : in Claw.Colors.Color_Type;
Reject : in out Boolean);
-- This routine is called after a color is selected and OKed by the
-- user. Color is the selected color. If Reject is true after
-- this routine is called, then the color is rejected; otherwise
-- the color is accepted and the dialog box closed.
-- By default, this routine accepts all colors.
procedure When_Other_Message (Dialog : in out Color_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.
-- Inherits Get_Handle and others
private
type Color_Dialog_Flag_Type is new Dword;
No_Flags : constant Color_Dialog_Flag_Type := 16#00000000#;
ENABLE_HOOK : constant Color_Dialog_Flag_Type := 16#00000010#;
ENABLE_TEMPLATE : constant Color_Dialog_Flag_Type := 16#00000020#;
ENABLE_TEMPLATE_HANDLE : constant Color_Dialog_Flag_Type := 16#00000040#;
FULL_OPEN : constant Color_Dialog_Flag_Type := 16#00000002#;
PREVENT_FULL_OPEN : constant Color_Dialog_Flag_Type := 16#00000004#;
RGB_INIT : constant Color_Dialog_Flag_Type := 16#00000001#;
SHOW_HELP : constant Color_Dialog_Flag_Type := 16#00000008#;
Solid_Color_Only : constant Color_Dialog_Flag_Type := 16#00000080#;
Any_Color : constant Color_Dialog_Flag_Type := 16#00000100#; -- not implemented anywhere.
type Dialog_Hook_Func_Type is access function (
Wnd : Claw.Win32.Hwnd;
Message : UInt;
W_Param : Claw.Win32.WParam;
L_Param : Claw.Win32.LParam) return Claw.Win32.LResult;
pragma Convention (StdCall, Dialog_Hook_Func_Type);
type Custom_Color_Array_Type_Access is access all Custom_Color_Array_Type;
type Choose_Color_Rec is
record
lStructSize : DWORD := 36;
hwndOwner : Claw.Win32.HWnd := Claw.Win32.Null_HWnd;
hInst : Claw.Win32.HINSTANCE := 0;
RGB_Result : Claw.Colors.Color_Type := Claw.Colors.BLACK;
Cust_Colors_Ptr : Custom_Color_Array_Type_Access := null;
Flags : Color_Dialog_Flag_Type := NO_FLAGS;
lCustData : Claw.Win32.LPARAM := 0;
lpfnHook : Dialog_Hook_Func_Type := null;
lpTemplateName : Claw.Win32.LPCSTR := null;
end record;
type Choose_Color_Rec_Ptr is access all Choose_Color_Rec;
type Color_Dialog_Type is new CLAW.Dialog.Root_Dialog_Type with record
CCR : aliased Choose_Color_Rec;
Has_Hook : Boolean := FALSE;
end record;
end Claw.Dialog.Color;