with Interfaces.C, Ada.Unchecked_Conversion;
private package Claw.Low_Level is
--
-- CLAW - Class Library for Ada and Windows.
--
-- This is the place where various commonly used low-level routines
-- are collected.
--
-- Copyright 1996, 1997 R.R. Software, Inc.
-- P.O. Box 1512, Madison WI 53701
-- All rights reserved.
--
use Claw.Win32;
-- Class styles.
Cs_Vredraw : constant := 16#01#;
Cs_Hredraw : constant := 16#02#;
Cs_Keycvtwindow : constant := 16#04#;
Cs_Dblclks : constant := 16#08#;
Cs_Owndc : constant := 16#020#;
Cs_Classdc : constant := 16#040#;
Cs_Parentdc : constant := 16#080#;
Cs_Nokeycvt : constant := 16#0100#;
Cs_Noclose : constant := 16#0200#;
Cs_Savebits : constant := 16#0800#;
Cs_Bytealignclient : constant := 16#01000#;
Cs_Bytealignwindow : constant := 16#02000#;
Cs_Globalclass : constant := 16#04000#;
-- Standard Cursor Ids
Idc_Arrow : constant DWord := 32512;
Idc_Ibeam : constant DWord := 32513;
Idc_Wait : constant DWord := 32514;
Idc_Cross : constant DWord := 32515;
Idc_Uparrow : constant DWord := 32516;
Idc_Size : constant DWord := 32640;
Idc_Icon : constant DWord := 32641;
Idc_Sizenwse: constant DWord := 32642;
Idc_Sizenesw: constant DWord := 32643;
Idc_Sizewe : constant DWord := 32644;
Idc_Sizens : constant DWord := 32645;
Idc_SizeAll : constant DWord := 32646;
Idc_No : constant DWord := 32648;
Idc_Appstarting: constant DWord := 32650;
-- Standard Icon IDs
Idi_Application: constant DWord := 32512;
Idi_Hand : constant DWord := 32513;
Idi_Question : constant DWord := 32514;
Idi_Exclamation: constant DWord := 32515;
Idi_Asterisk : constant DWord := 32516;
-- Stock objects
White_Brush : constant := 0;
Ltgray_Brush : constant := 1;
Gray_Brush : constant := 2;
Dkgray_Brush : constant := 3;
Black_Brush : constant := 4;
Null_Brush : constant := 5;
Hollow_Brush : constant := Null_Brush;
White_Pen : constant := 6;
Black_Pen : constant := 7;
Null_Pen : constant := 8;
Oem_Fixed_Font: constant := 10;
Ansi_Fixed_Font: constant := 11;
Ansi_Var_Font : constant := 12;
System_Font : constant := 13;
Device_Default_Font: constant := 14;
Default_Palette: constant := 15;
System_Fixed_Font: constant := 16;
function To_Long is new Ada.Unchecked_Conversion (Source => Claw.Wnd_Func_Type,
Target => Long);
function To_Ptr is new Ada.Unchecked_Conversion (Source => Long,
Target => Claw.Wnd_Func_Type);
type Wnd_Class_Type is record
Style : UInt;
Wnd_Proc: Claw.Wnd_Func_Type;
Cls_Extra: Int;
Wnd_Extra: Int;
Instance: HInstance;
Icon : Hicon;
Cursor : Hcursor;
Background: Hbrush;
Menu_Name: Lpcstr;
Class_Name: Lpcstr;
end record;
-- MS Windows Parameters to WinMain
function Instance return HInstance;
-- The instance handle of the application.
function Previnstance return HInstance;
-- The Handle of another instance of the application, if one is running.
-- Windows sets this to null it no other instance.
function Cmdline return Lpcstr;
-- A long pointer to a null terminated command line string
-- Note: The Ada.Command_Line package should be used to access the
-- command line.
function Cmdshow return Claw.Codes.Show_Window_Type;
-- An integer value that specifies whether to display the application's
-- window as a window or as a icon. The application passes this value
-- to the Show_Window function when calling that function to display
-- the application's main window.
--Get_Window_Long items
Gwl_Wndproc : constant Int := - 4;
Gwl_Hinstance : constant Int := - 6;
Gwl_Hwndparent: constant Int := - 8;
Gwl_Id : constant Int := - 12;
Gwl_Style : constant Int := - 16;
Gwl_Exstyle : constant Int := - 20;
Gwl_UserData : constant Int := - 21;
function Get_Last_Error return DWord;
pragma Import (StdCall, Get_Last_Error, "GetLastError");
-- Note: The language name "StdCall" may vary on other compilers.
function Get_Window_Long(Wnd : Hwnd;
Index : Int) return Long;
pragma Import (StdCall, Get_Window_Long, "GetWindowLongA");
function Set_Window_Long(Wnd : Hwnd;
Index : Int;
New_Long: Long) return Long;
pragma Import (StdCall, Set_Window_Long, "SetWindowLongA");
--Get_Class_Long items
Gcl_Menuname : constant Int := - 8;
Gcl_Hbrbackground : constant Int := -10;
Gcl_Hcursor : constant Int := - 12;
Gcl_HIcon : constant Int := - 14;
Gcl_HModule : constant Int := - 16;
Gcl_CbWndExtra: constant Int := - 18;
Gcl_CbClsExtra: constant Int := - 20;
Gcl_WndProc : constant Int := - 24;
Gcl_Style : constant Int := - 26;
Gcl_Atom : constant Int := - 32;
Gcl_HIconSm : constant Int := - 34; -- Windows 4.0 or later only.
function Get_Class_Long(Wnd : Hwnd;
Index : Int) return Long;
pragma Import (StdCall, Get_Class_Long, "GetClassLongA");
function Set_Class_Long(Wnd : Hwnd;
Index : Int;
New_Long: Long) return Long;
pragma Import (StdCall, Set_Class_Long, "SetClassLongA");
function Def_Window_Proc(Wnd : Hwnd;
Msg : UInt;
Param : WParam;
Lparm : LParam) return LResult;
pragma Import (StdCall, Def_Window_Proc, "DefWindowProcA");
function Call_Window_Proc (Prev_Wnd_Func: Claw.Wnd_Func_Type;
Wnd : Hwnd;
Msg : UInt;
Param : WParam;
Lparm : LParam) return LResult;
pragma Import (StdCall, Call_Window_Proc, "CallWindowProcA");
procedure Post_Quit_Message(Exit_Code: in Exit_Code_Type);
pragma Import (StdCall, Post_Quit_Message, "PostQuitMessage");
function Begin_Paint(Wnd : in Hwnd;
Paint : access Paint_Record) return Hdc;
pragma Import (StdCall, Begin_Paint, "BeginPaint");
function End_Paint(Wnd : in Hwnd;
Paint : access Paint_Record) return Bool;
pragma Import (StdCall, End_Paint, "EndPaint");
function Get_Sys_Color_Brush (Index : in Int) return Claw.Win32.HBrush;
pragma Import (StdCall, Get_Sys_Color_Brush, "GetSysColorBrush");
-- Keyboard and mouse message crackers:
type W_and_L_Parameters is record
W_Param : WParam;
L_Param : LParam;
end record;
for W_and_L_Parameters use record
W_Param at 0 range 0 .. 31;
L_Param at 4 range 0 .. 31;
end record;
for W_and_L_Parameters'size use 2*32;
function Keypress_Info_of is new Ada.Unchecked_Conversion
(Source => LParam,
Target => CLAW.Keys.Keypress_Info_Type);
function Mouse_params_of is new Ada.Unchecked_Conversion
(Source => W_and_L_Parameters,
Target => CLAW.Mouse.Mouse_Params_Type);
function Resize_params_of is new Ada.Unchecked_Conversion
(Source => W_and_L_Parameters,
Target => CLAW.Codes.Resize_Params_Type);
end Claw.Low_Level;