home *** CD-ROM | disk | FTP | other *** search
/ Solo Programadores 22 / SOLO_22.iso / packages / win32ada / data.z / wxform_util.adb < prev    next >
Encoding:
Text File  |  1995-12-06  |  39.1 KB  |  1,060 lines

  1. -- $Source: /home/harp/1/proto/monoBANK/winnt/wxform_util.adb,v $ 
  2. -- $Revision: 1.1 $ $Date: 95/02/09 13:24:21 $ $Author: mg $ 
  3.  
  4. --  package Wxform_Util body
  5. --
  6. --  The functions here were translated from wxform.c.  Ada procedure 
  7. --  wxform_ada does the initial window creation and the message loop.  All
  8. --  other utility functions are defined here.
  9. --
  10. --  One major change from the C version is the implementation of parts of
  11. --  doTrackObject.  This function was initially written using the standard
  12. --  calling parameters of a callback routine that handles messages.  The
  13. --  C version used the lParam (a LONG type) to pass addresses of different
  14. --  data structures.  Often, the address of an item which is part of a record
  15. --  would be passed to dotrackobject where it would then be converted back
  16. --  to the type of the record via C typecasts.  Ada strong typing is not 
  17. --  conducive to this kind of parameter passing.  Since the data object in
  18. --  question is global to this whole routine, its data elements will be 
  19. --  referenced directly rather than type converting and passing addresses.
  20. --  There have been other changes which mainly have to do with parameter 
  21. --  passing between routines, otherwise the overall design has remained the
  22. --  same.
  23. -- ------------------------------------------------------------------
  24.  
  25.  
  26. with Win32;           use Win32;
  27. with Win32.WinDef;    use Win32.WinDef;
  28. with Win32.WinUser; use Win32.WinUser;
  29. with Win32.WinGdi;  use Win32.WinGdi;
  30.  
  31. with Ada.Numerics.Generic_Elementary_Functions;
  32. with Ada.Unchecked_Conversion;
  33.  
  34. with Text_IO;
  35. with Interfaces.C.Strings;
  36.  
  37. with Interfaces.C;
  38. use type Interfaces.C.INT;  -- for operations on types
  39. use type Interfaces.C.LONG;  -- for operations on types
  40. use type Interfaces.C.C_FLOAT;  -- for operations on types
  41. use type Interfaces.C.UNSIGNED;  -- for operations on types
  42. use type Interfaces.C.UNSIGNED_SHORT;  -- for operations on types
  43.  
  44.  
  45. package body Wxform_Util is
  46.  
  47.   -- aliases made global
  48.  
  49.     -- aliases for case WM_PAINT
  50.     old_pt: aliased POINT;
  51.     ps    : aliased PAINTSTRUCT;
  52.     pt    : aliased POINT;
  53.     rct   : aliased RECT;
  54.  
  55.     -- aliases for case WM_PUTUPFLOATS
  56.     pScreen : aliased POINT;
  57.     pWorld  : aliased array (0..5) of aliased POINT;
  58.   
  59.     -- aliases for procedure CenterOrigin
  60.     rect_rec : aliased RECT;
  61.     old_pt2  : aliased POINT;
  62.     
  63.     -- aliases for TROB_HITTEST
  64.     mouWorld : array (0..5) of aliased POINT;
  65.  
  66.     -- aliased for WM_LBUTTONDOWN | WM_RBUTTONDOWN
  67.     newmouScreen : array (0..5) of aliased POINT;
  68.     mouWorld2    : array (0..5) of aliased POINT;
  69.  
  70.     -- aliased for WM_MOUSEMOVE
  71.     rect : aliased WinDef.RECT;
  72.     
  73.     -- aliased for procedure MouseMove
  74.     mouWorld3 : array (0..5) of aliased POINT;
  75.     mouDevice : aliased POINT;
  76.     orgDevice : aliased POINT;
  77.     
  78.  
  79.   package Float_Functions is new
  80.     Ada.Numerics.Generic_Elementary_Functions (FLOAT);
  81.  
  82.   -- define dummy variables to hold results of function calls
  83.   iResult  : Win32.INT;
  84.   bResult  : Win32.BOOL;
  85.   lResult  : Win32.LONG;
  86.   uResult  : Win32.UINT;
  87.   lrResult : Win32.LRESULT;
  88.  
  89.  
  90. function CP(S : Win32.CHAR_Array) return Win32.LPCSTR is
  91.     function UC is new Ada.Unchecked_Conversion(System.Address,Win32.LPCSTR);
  92. begin
  93.     return UC(S(S'First)'Address);
  94. end CP;
  95.  
  96. function To_CA(S: String) return Win32.CHAR_Array is
  97. begin
  98.    return Win32.To_Win(Interfaces.C.To_C(S));
  99. end To_CA;
  100.  
  101. function New_LPCSTR (S: String) return Win32.LPCSTR is
  102. begin
  103.    return CP(To_CA(S));
  104. end New_LPCSTR;
  105.  
  106.  
  107. function HWND_to_WPARAM is new Ada.Unchecked_Conversion (HWND, WPARAM); 
  108. function To_DWORD is new Ada.Unchecked_Conversion (Win32.LPARAM, Win32.DWORD);
  109. function To_DWORD is new Ada.Unchecked_Conversion (Win32.WPARAM, Win32.DWORD);
  110.  
  111.  
  112. --debug
  113.   procedure dobox (msg : LPCSTR) is
  114.   begin
  115.     iResult := MessageBox(System.Null_Address, msg, New_LPCSTR("Wxform_Util"), 0);
  116.   end dobox;
  117. --debug, end
  118.  
  119.   -- global boolean set by case TROB_HITTEST
  120.   In_Bounds : Boolean := False;
  121.   
  122. --  function:  MainWndProc()
  123. --
  124. --  input parameters:  normal window procedure parameters.
  125. --
  126. --  global variables:
  127. --   hwndTransform,
  128. --   hwndMouse - information dialog box window handles.
  129. --   showTransform,
  130. --   showMouse - Booleans recording the retore/minimize state of the dialogs.
  131. --   ptoRect   - The object in the middle of the screen
  132. --   In_Bounds - Boolean indicating whether mouse is in the bounds of the
  133. --   track object
  134. function MainWndProc (hwnd    : HWND;
  135.                       message : UINT;
  136.                       wParam  : WPARAM;
  137.                       lParam  : LPARAM) return Win32.LRESULT is
  138. begin
  139.   case message is 
  140.  
  141.     -- *  WM_CREATE
  142.     -- *
  143.     -- * create a pen for later use.
  144.     when WM_CREATE =>
  145.       hPenGrid := CreatePen (PS_SOLID, 1, GRIDCOLOR);
  146.  
  147.  
  148.     -- *  WM_DESTROY
  149.     -- *
  150.     -- * Complement of WM_CREATE.  send the track object the delete messages,
  151.     -- *  then call PostQuitMessage.
  152.     when WM_DESTROY =>
  153.       bResult := DeleteObject(HGDIOBJ(hPenGrid));
  154.       doTrackObject(TROB_DELETE, hwnd, lParam);
  155.       PostQuitMessage(0);
  156.  
  157.  
  158.     -- *  WM_SIZE
  159.     -- *
  160.     -- * Invalidate the whole window because we reset the origin on paint
  161.     -- *  messages according to the size.  Also, send the track object a
  162.     -- *  message so that it will also change its HDC's viewport origin.
  163.     -- Note: in C, one can easily pass in a null pointer to a function.  If
  164.     -- InvalidateRect gets a null second record, then the entire client area
  165.     -- is added to the area to be invalidated.  For the Ada implementation,
  166.     -- try declaring a pointer to a rect, but don't initialize it.
  167.     when WM_SIZE =>
  168.       declare
  169.         null_rect : ac_RECT_t;
  170.       begin
  171.         bResult := InvalidateRect (hwnd, null_rect, Win32.False);
  172.         doTrackObject (TROB_CENTER, hwnd, lParam);
  173.       end;
  174.  
  175.  
  176.     -- *  WM_PAINT
  177.     -- *
  178.     -- * First invalidate the whole window (forces the object to be painted
  179.     -- *  fresh, and thus it won't XOR its old self out).  Then draw the
  180.     -- *  grid and finally draw the object.
  181.     when WM_PAINT =>
  182.       declare
  183.         the_Hdc   : HDC;
  184.         i         : Win32.INT;
  185.         hgdi      : HGDIOBJ;
  186.         x, y      : Win32.INT;
  187.         null_rect : ac_RECT_t;
  188.       begin
  189.         bResult := InvalidateRect (hwnd, null_rect, Win32.True);
  190.  
  191.         the_hdc := BeginPaint(hwnd, ps'Access);
  192.  
  193.         CenterOrigin (hwnd, the_hdc);
  194.         bResult := GetClientRect (hwnd, rct'Access);
  195.         bResult := GetViewportOrgEx(the_hdc, pt'Access);
  196.         x := Win32.INT(pt.x * (-1));
  197.         y := Win32.INT(pt.y * (-1));
  198.         bResult := OffsetRect(rct'Access, x, y);
  199.  
  200.         -- /* Draw vertical lines.  Draw three at the origin. */
  201.         hgdi := SelectObject(the_hdc, HGDIOBJ(hPenGrid));
  202.         i := 0;
  203.         while i <= Win32.INT (rct.right) loop
  204.           bResult := MoveToEx 
  205.                      (the_hdc, i, Win32.INT(rct.top),old_pt'access );
  206.           bResult := LineTo (the_hdc, i, Win32.INT (rct.bottom));
  207.           bResult := MoveToEx (the_hdc, -i, 
  208.                             Win32.INT(rct.top),old_pt'access);
  209.           bResult := LineTo (the_hdc, -i, Win32.INT (rct.bottom));
  210.           i := i + TICKSPACE;
  211.         end loop;
  212.  
  213.         bResult := MoveToEx (the_hdc, -1, 
  214.                    Win32.INT (rct.top), old_pt'access);
  215.         bResult := LineTo (the_hdc, -1, Win32.INT (rct.bottom));
  216.         bResult := MoveToEx (the_hdc, 1, Win32.INT (rct.top), 
  217.                                     old_pt'access);
  218.         bResult := LineTo (the_hdc, 1, Win32.INT (rct.bottom));
  219.  
  220.         -- /* Draw horizontal lines.  Draw three at the origin. */
  221.         i := 0;
  222.         while i <= Win32.INT (rct.bottom) loop
  223.           bResult := MoveToEx (the_hdc, Win32.INT (rct.left), 
  224.                                       i, old_pt'access);
  225.           bResult := LineTo (the_hdc, Win32.INT (rct.right), i);
  226.           bResult := MoveToEx (the_hdc, Win32.INT (rct.left), 
  227.                                       -i, old_pt'access);
  228.           bResult := LineTo (the_hdc, Win32.INT (rct.right), -i);
  229.           i := i + TICKSPACE;
  230.         end loop;
  231.         bResult := MoveToEx (the_hdc, Win32.INT (rct.left), 
  232.                                     -1, old_pt'access);
  233.         bResult := LineTo (the_hdc, Win32.INT (rct.right), -1);
  234.         bResult := MoveToEx (the_hdc, Win32.INT (rct.left), 
  235.                                     1, old_pt'access);
  236.         bResult := LineTo (the_hdc, Win32.INT (rct.right), 1);
  237.  
  238.         doTrackObject(TROB_PAINT, hwnd, lParam);
  239.  
  240.         bResult := EndPaint (hwnd, ps'Access);
  241.  
  242.       end;
  243.  
  244.  
  245.     -- *  WM_LBUTTONDOWN & WM_RBUTTONDOWN
  246.     -- * On button down messages, hittest on the track object, and if
  247.     -- * In_Bounds is True, then send these messages to the track object.
  248.     when WM_RBUTTONDOWN | WM_LBUTTONDOWN =>
  249.       In_Bounds := False;  -- preset to Win32.False
  250.       doTrackObject (TROB_HITTEST, hwnd, lParam);
  251.       if In_Bounds then
  252.         doTrackObject (message, hwnd, lParam);
  253.       end if;
  254.  
  255.  
  256.     -- *  WM_LBUTTONUP & WM_RBUTTONDOWN & MW_MOUSEMOVE
  257.     -- *  If the track object is in a "tracking mode" then send it
  258.     -- *  these messages.
  259.     -- *  If the transform dialog is not minimized, fill it with numbers.
  260.     -- *  If the mouse dialog is not minimized, fill it with numbers.
  261.     when WM_RBUTTONUP | WM_LBUTTONUP | WM_MOUSEMOVE =>
  262.       if ptoRect.Mode /= TMNONE then
  263.         doTrackObject(message, hwnd, lParam);
  264.         if showTransform = Win32.True then
  265.           lrResult := SendMessage (hwndTransform, WM_PUTUPFLOATS, 0, 0);
  266.           -- Note, the C version follows.  I have opted not to use lParam
  267.           -- of SendMessage to pass the information; it will be used 
  268.           -- directly in the dialog box procedure that handles this message.
  269.           -- This avoids having to convert an address of a record to a long
  270.           -- integer and then back to the record when it is handled by the
  271.           -- callback routine.
  272.           -- SendMessage (hwndTransform, WM_PUTUPFLOATS, 0,
  273.           --              (LONG) &ptoRect->xfmChange);
  274.         end if;
  275.       end if;
  276.       if showMouse = Win32.True then
  277.         lrResult := SendMessage
  278.                      (hwndMouse, WM_PUTUPFLOATS,
  279.                       HWND_to_WPARAM(hwnd), lParam);
  280.       end if;
  281.  
  282.     when others =>
  283.       return DefWindowProc (hwnd, message, wParam, lParam);
  284.  
  285.   end case; 
  286.   return DefWindowProc(hwnd, message, wParam, lParam);
  287.  
  288. end MainWndProc;
  289.  
  290.  
  291. -- *  function:  TransformDlgProc()
  292. -- *
  293. -- *  input parameters:  normal window procedure parameters.
  294. -- *
  295. -- *  global variables:
  296. -- *   showTransform  - Win32.True if window is restored, Win32.False if minimized.
  297. -- *       maintain the value in this routine for other windows' use.
  298. -- *   ptoRect - the track object.
  299. -- *   showMouse, hwndMain.
  300. -- *
  301. -- *  nonstandard messages:
  302. -- *   WM_PUTUPFLOATS - fill the entry fields with the contents of an XFORM.
  303. function TransformDlgProc(hwnd    : Windef.HWND;
  304.                           message : Win32.UINT;
  305.                           wParam  : WPARAM;
  306.                           lParam  : LPARAM) return BOOL is
  307.  
  308.   zero_str: constant Win32.CHAR_Array := To_CA("0");
  309.   one_str:  constant Win32.CHAR_Array := To_CA("1");
  310.  
  311.   Package Win32_Flt_IO is new Text_IO.Float_IO(Win32.Float);
  312.   use Win32_Flt_IO;
  313.  
  314. begin
  315.   case message is
  316.  
  317.     -- *  WM_INITDIALOG
  318.     -- *
  319.     -- * Fill the entry fields with sensible original values.
  320.     when WM_INITDIALOG =>
  321.       bResult := SetDlgItemText(hwnd, IDD_13, CP(zero_str));
  322.       bResult := SetDlgItemText(hwnd, IDD_23, CP(zero_str));
  323.       bResult := SetDlgItemText(hwnd, IDD_33, CP(one_str));
  324.       return Win32.True;
  325.  
  326.  
  327.     -- *  WM_PUTUPFLOATS
  328.     -- *
  329.     -- *  lParam - pointer to an XFORM structure (for the C version!).
  330.     -- *   for the Ada implementation, read these values from the track object.
  331.     -- *  fill the entry fields with the XFORM values.  
  332.     when WM_PUTUPFLOATS =>
  333.     declare
  334.       float_val : Win32.FLOAT;
  335.       float_str : String(1..10); 
  336.     begin
  337.       float_val := ptoRect.xfmChange.eM11;
  338.       Put(float_str, float_val, Aft=>2);
  339.       bResult := SetDlgItemText(hwnd, IDD_EM11, New_LPCSTR(float_str));
  340.       float_val := ptoRect.xfmChange.eM12;
  341.       Put(float_str, float_val, Aft=>2);
  342.       bResult := SetDlgItemText(hwnd, IDD_EM12, New_LPCSTR(float_str));
  343.       float_val := ptoRect.xfmChange.eDx;
  344.       Put(float_str, float_val, Aft=>2);
  345.       bResult := SetDlgItemText(hwnd, IDD_EDX, New_LPCSTR(float_str));
  346.  
  347.       float_val := ptoRect.xfmChange.eM21;
  348.       Put(float_str, float_val, Aft=>2);
  349.       bResult := SetDlgItemText(hwnd, IDD_EM21, New_LPCSTR(float_str));
  350.       float_val := ptoRect.xfmChange.eM22;
  351.       Put(float_str, float_val, Aft=>2);
  352.       bResult := SetDlgItemText(hwnd, IDD_EM22, New_LPCSTR(float_str));
  353.       float_val := ptoRect.xfmChange.eDy;
  354.       Put(float_str, float_val, Aft=>2);
  355.       bResult := SetDlgItemText(hwnd, IDD_EDY, New_LPCSTR(float_str));
  356.     end;
  357.     return Win32.False;
  358.  
  359.  
  360.     -- *  WM_SIZE
  361.     -- *
  362.     -- *  toggle the global variable keeping track of the iconized state
  363.     -- *   of this window.
  364.     when WM_SIZE =>
  365.       if wParam = SIZEICONIC then
  366.         showTransform := Win32.False;
  367.       else 
  368.         showTransform := Win32.True;
  369.         lrResult := SendMessage (hwnd, WM_PUTUPFLOATS, 0, 0);
  370.       end if;
  371.       return Win32.False;
  372.  
  373.  
  374.     when WM_COMMAND =>
  375.     declare
  376.       buf       : Win32.CHAR_Array(0 .. MAXCHARS-1) := (others => '0');
  377.       buf_ptr   : LPSTR := Win32.LPSTR(CP(buf));
  378.       float_val : Win32.FLOAT;
  379.       junk: POSITIVE;
  380.     begin
  381.       -- *  WM_COMMAND,  IDD_SETXFORM
  382.       -- *
  383.       -- *  take the values from the entry field, fill them into an XFORM
  384.       -- *   structure and then send the track object the message to use
  385.       -- *   these values.  Finally, reformat and repaint the entry fields.
  386.       if LOWORD (To_DWORD(wParam)) = IDD_SETXFORM then
  387.         uResult := GetDlgItemText(hwnd, IDD_EM11, buf_ptr, MAXCHARS);
  388.         Get(Interfaces.C.To_Ada(Win32.To_C(buf)),ptoRect.xfmChange.eM11,junk);
  389.  
  390.         uResult := GetDlgItemText(hwnd, IDD_EM12, buf_ptr, MAXCHARS);
  391.         Get(Interfaces.C.To_Ada(Win32.To_C(buf)),ptoRect.xfmChange.eM12,junk);
  392.  
  393.         uResult := GetDlgItemText(hwnd, IDD_EDX, buf_ptr, MAXCHARS);
  394.         Get(Interfaces.C.To_Ada(Win32.To_C(buf)),ptoRect.xfmChange.eDx,junk);
  395.  
  396.         uResult := GetDlgItemText(hwnd, IDD_EM21, buf_ptr, MAXCHARS);
  397.         Get(Interfaces.C.To_Ada(Win32.To_C(buf)),ptoRect.xfmChange.eM21,junk);
  398.  
  399.         uResult := GetDlgItemText(hwnd, IDD_EM22, buf_ptr, MAXCHARS);
  400.         Get(Interfaces.C.To_Ada(Win32.To_C(buf)),ptoRect.xfmChange.eM22,junk);
  401.  
  402.         uResult := GetDlgItemText(hwnd, IDD_EDY, buf_ptr, MAXCHARS);
  403.          Get(Interfaces.C.To_Ada(Win32.To_C(buf)),ptoRect.xfmChange.eDy,junk);
  404.  
  405.         -- // HACK.  The WM_SIZE here is used to flush the GDI buffer in order
  406.         -- //  to eliminate a very strange bug whereby DPtoLP() doesn't work.
  407.         if showMouse = Win32.True then
  408.           lrResult := SendMessage (hwndMain, WM_SIZE, 0,0);
  409.         end if;
  410.  
  411.         doTrackObject (TROB_SETXFORM, hwnd, 0);
  412.         lrResult := SendMessage (hwnd, WM_PUTUPFLOATS, 0, 0);
  413.  
  414.       -- *  WM_COMMAND,  IDD_IDENTITY
  415.       -- *
  416.       -- *  fill a local XFORM structure with the identity matrix.  Now
  417.       -- *   send the track object the message to use these values.
  418.       -- *   Finally, reformat and repaint the entry fields.
  419.       elsif LOWORD (To_DWORD(wParam)) = IDD_IDENTITY then
  420.         ptoRect.xfmChange.eM11 := 1.0;
  421.         ptoRect.xfmChange.eM22 := 1.0;
  422.         ptoRect.xfmChange.eDx  := 0.0;
  423.         ptoRect.xfmChange.eDy  := 0.0;
  424.         ptoRect.xfmChange.eM12 := 0.0;
  425.         ptoRect.xfmChange.eM21 := 0.0;
  426.  
  427.         -- // HACK.  The WM_SIZE here is used to flush the GDI buffer in order
  428.         -- //  to eliminate a very strange bug whereby DPtoLP() doesn't work.
  429.         if showMouse = Win32.True then
  430.           lrResult := SendMessage (hwndMain, WM_SIZE, 0,0);
  431.         end if;
  432.  
  433.         doTrackObject (TROB_SETXFORM, hwnd, 0);
  434.         lrResult := SendMessage (hwnd, WM_PUTUPFLOATS, 0, 0);
  435.       end if;
  436.       return Win32.False;
  437.     end;
  438.  
  439.     when others =>
  440.       return Win32.False;
  441.   end case;
  442.   return Win32.False;
  443. end TransformDlgProc;
  444.  
  445.  
  446. -- *  function:  MouseDlgProc()
  447. -- *
  448. -- *  input parameters:  normal window procedure parameters.
  449. -- *
  450. -- *  global variables:
  451. -- *   showMouse  -- Win32.True if window is restored, Win32.False if minimized.
  452. -- *       maintain the value in this routine for other windows' use.
  453. -- *   ptoRect - pointer to the track object.  Needed for DPtoLP()
  454. -- *
  455. -- *  nonstandard messages:
  456. -- *   WM_PUTUPFLOATS - fill the entry fields with the mouse position.
  457. function MouseDlgProc(hwnd    : WinDef.HWND;
  458.                       message : Win32.UINT;
  459.                       wParam  : Win32.WPARAM;
  460.                       lParam  : Win32.LPARAM) return BOOL is
  461.  
  462. function To_HWND
  463. is new Ada.Unchecked_Conversion (Win32.WPARAM, WinDef.HWND);
  464.  
  465. begin
  466.  
  467.   case message is
  468.  
  469.     -- *  WM_PUTUPFLOATS
  470.     -- *
  471.     -- *  wParam - contains the hwnd for the main window.
  472.     -- *  lParam - contains the mouse position in device coordinates.
  473.     -- *           (c.f. WM_MOUSEMOVE)
  474.     when WM_PUTUPFLOATS =>
  475.       declare
  476.         hwndMain: WinDef.HWND;
  477.         buf     : Win32.CHAR_Array(0 .. MAXCHARS-1) := (others => '0');
  478.           buf_ptr : LPSTR := Win32.LPSTR(CP(buf));
  479.         num_char: Win32.INT;
  480.       begin
  481.         hwndMain    := To_HWND(wParam);
  482.         pScreen.x   := Win32.LONG (LOWORD (To_DWORD(lParam)));
  483.         pWorld(0).x := Win32.LONG (LOWORD (To_DWORD(lParam)));
  484.         pScreen.y   := Win32.LONG (HIWORD (To_DWORD(lParam))); 
  485.         pWorld(0).y := Win32.LONG (HIWORD (To_DWORD(lParam)));
  486.  
  487.         bResult := SetDlgItemText(hwnd, IDD_DEVICEX, 
  488.                                   New_LPCSTR(Win32.LONG'Image(pScreen.x)));
  489.         bResult := SetDlgItemText(hwnd, IDD_DEVICEY,
  490.                                   New_LPCSTR(Win32.LONG'Image(pScreen.y)));
  491.  
  492.         bResult := ClientToScreen (hwndMain, pScreen'Access);
  493.         bResult := SetDlgItemText(hwnd, IDD_SCREENX, 
  494.                                   New_LPCSTR(Win32.LONG'Image(pScreen.x)));
  495.         bResult := SetDlgItemText(hwnd, IDD_SCREENY,
  496.                                   New_LPCSTR(Win32.LONG'Image(pScreen.y)));
  497.  
  498.         bResult := DPtoLP (ptoRect.hdc_value, pWorld(0)'Access, 1);
  499.         bResult := SetDlgItemText(hwnd, IDD_WORLDX, 
  500.                                   New_LPCSTR(Win32.LONG'Image(pWorld(0).x)));
  501.         bResult := SetDlgItemText(hwnd, IDD_WORLDY,
  502.                                   New_LPCSTR(Win32.LONG'Image(pWorld(0).y)));
  503.  
  504.         return Win32.False;
  505.       end;
  506.  
  507.  
  508.     -- *  WM_SIZE
  509.     -- *
  510.     -- *  toggle the global variable keeping track of the iconized state
  511.     -- *   of this window.
  512.     when WM_SIZE =>
  513.       if wParam = SIZEICONIC then
  514.         showMouse := Win32.False;
  515.       else
  516.         showMouse := Win32.True;
  517.       end if;
  518.       return Win32.False;
  519.  
  520.     when others =>
  521.       return Win32.False;
  522.  
  523.   end case;
  524.   return Win32.False;
  525.  
  526. end MouseDlgProc;
  527.  
  528.  
  529. --  function:  CenterOrigin()
  530. --
  531. --  input parameters:
  532. --   hwnd - window with client we want the center of.
  533. --   hdc - device context which we set the Viewport origin of.
  534. procedure CenterOrigin (hwnd : HWND;
  535.                         the_hdc  : HDC) is
  536.   x, y     : Win32.INT;
  537. begin
  538.   bResult := GetClientRect (hwnd, rect_rec'Access);
  539.   x := Win32.INT (rect_rec.right) / 2;
  540.   y := Win32.INT (rect_rec.bottom) / 2;
  541.  
  542.   bResult := SetViewportOrgEx (the_hdc, x, y, old_pt2'access);
  543. end CenterOrigin;
  544.  
  545.  
  546.  
  547. --  function:  doTrackObject()
  548. --
  549. --  input parameters:
  550. --   msg -  message selecting what action to take.  Values may include WM_*'s
  551. --           (see case statements below for more information.)
  552. --   hwnd - Window handle for the window the track object exists within.
  553. --   lParam - Usually fourth param to window proc. varies based on msg.
  554. --
  555. --  global variables:  ptoRect (the object on which this procedure operates).
  556. --
  557. --  coordinate spaces:  There are three coordinate spaces of interest here,
  558. --   and this routine is frequently switching between them...
  559. --
  560. --           WORLD                   DEVICE                  SCREEN
  561. --
  562. --      object coordinates       input mouse pos       used w/ SetCursorPos()
  563. --         (pto->rect)          (lParam for WM_*)
  564. --
  565. --             ----->  LPtoDP() ---->    ----> ClientToScreen() -->
  566. --             <-----  DPtoLP() <----    <---- ScreenToClient() <--
  567. --
  568. --   in addition, the HDC has an offset origin.  Device coordinates for the
  569. --   mouse (lParam) never take this into account, but it is necessary to
  570. --   translate them in order to get direct manipulation right.
  571. --
  572. procedure doTrackObject (msg    : Win32.UINT;
  573.                          hwnd   : HWND;
  574.                          lParam : Win32.LONG) is
  575. begin
  576.   case msg is
  577.  
  578.     --   TROB_NEW
  579.     --  
  580.     --   Fill in default values for new PTrackObject structure.  (In the
  581.     --   C version, space for this object is allocated; the object has 
  582.     --   already been created in the spec for the Ada version).
  583.     --   for the fields of the structure.  Set up the HDC correctly.
  584.     when TROB_NEW => 
  585.       declare
  586.         gdiobj : HGDIOBJ;
  587.       begin
  588.         -- /* initialize the HDC and other fields. */
  589.         ptoRect.hdc_value := GetDC(hwnd);
  590.         iResult := SetGraphicsMode (ptoRect.hdc_value, GM_ADVANCED);
  591.         iResult := SetROP2(ptoRect.hdc_value, R2_NOT);
  592.         gdiobj  := SelectObject (ptoRect.hdc_value, 
  593.                    GetStockObject (NULL_BRUSH));
  594.         gdiobj  := SelectObject(ptoRect.hdc_value, HGDIOBJ (
  595.                    CreatePen (PS_SOLID, 2, 
  596.                                      COLORREF (16#01000009#))));
  597.         ptoRect.Mode := TMNONE;
  598.         doTrackObject (TROB_CENTER, hwnd, lParam);
  599.         bResult := GetWorldTransform (ptoRect.hdc_value,
  600.                                       ptoRect.xfmChange'Access); 
  601.         -- /* initialize the size. */
  602.         ptoRect.rect.top := 0;  ptoRect.rect.left := 0;
  603.         ptoRect.rect.bottom := TICKSPACE * 5;
  604.         ptoRect.rect.right  := TICKSPACE * 5;
  605.  
  606.       end;
  607.  
  608.  
  609.     -- *  TROB_DELETE
  610.     -- *
  611.     -- * Delete the pen that we created, release the DC.
  612.     -- *  free up the memory allocated for the object.
  613.     when TROB_DELETE =>
  614.       bResult := DeleteObject (
  615.                                SelectObject (ptoRect.hdc_value, 
  616.                                   GetStockObject (BLACK_PEN)));
  617.       doTrackObject (TROB_PAINT, hwnd, lParam);
  618.       iResult := ReleaseDC (hwnd, ptoRect.hdc_value);
  619.  
  620.  
  621.     -- *  TROB_CENTER
  622.     -- *
  623.     -- * Called in order to reset the view port origin in the track objects
  624.     -- *  hdc whenever the client window changes size.  This hdc is thus kept
  625.     -- *  synchronized with the hdc that the axes are painted into.
  626.     when TROB_CENTER =>
  627.       CenterOrigin (hwnd, ptoRect.hdc_value);
  628.     
  629.  
  630.     -- *  TROB_PAINT
  631.     -- *
  632.     -- * Paint the object into its hdc.  Called half the time to erase
  633.     -- *  the object, and half the time to redraw it.
  634.     when TROB_PAINT =>
  635.       bResult := Rectangle (ptoRect.hdc_value, 
  636.                             Win32.INT (ptoRect.rect.left)+1, 
  637.                             Win32.INT (ptoRect.rect.top) +1,
  638.                             Win32.INT (ptoRect.rect.left)+INC, 
  639.                             Win32.INT (ptoRect.rect.top) +INC);
  640.  
  641.       bResult := Rectangle (ptoRect.hdc_value, 
  642.                             Win32.INT (ptoRect.rect.left), 
  643.                             Win32.INT (ptoRect.rect.top),
  644.                             Win32.INT (ptoRect.rect.right), 
  645.                             Win32.INT (ptoRect.rect.bottom));
  646.  
  647.  
  648.     -- *  TROB_SETXFORM
  649.     -- *
  650.     -- * lParam - pointer to the new transform.
  651.     -- *  set the new transform into the HDC, then update xfmChange.
  652.     -- This message is called when the transform has been changed via the
  653.     -- dialog box.
  654.     when TROB_SETXFORM =>
  655.       doTrackObject (TROB_PAINT, hwnd, lParam);
  656.       bResult := SetWorldTransform(ptoRect.hdc_value, ptoRect.xfmChange'Access);
  657.       bResult := GetWorldTransform(ptoRect.hdc_value, ptoRect.xfmChange'Access);
  658.       doTrackObject (TROB_PAINT, hwnd, lParam);
  659.  
  660.  
  661.     -- *  TROB_HITTEST
  662.     -- *
  663.     -- * Check the point sent in in the lParam to see if it lays within
  664.     -- *  the bounds of the object's defining rectangle.
  665.     -- * iff the point is in rectangle, set In_Bounds = True, False otherwise.
  666.     when TROB_HITTEST =>
  667.       declare
  668.       begin
  669.         mouWorld(0).x := Win32.LONG (WinDef.LOWORD (DWORD(lParam)));
  670.         mouWorld(0).y := Win32.LONG (WinDef.HIWORD (DWORD(lParam)));
  671.  
  672.         bResult := DPtoLP (ptoRect.hdc_value, mouWorld(0)'Access, 1);
  673.  
  674.         bResult := PtInRect (ptoRect.rect'Access, mouWorld(0));
  675.         if bResult = Win32.True then
  676.           In_Bounds := True;
  677.         else
  678.           In_Bounds := False; 
  679.         end if;
  680.       end;
  681.  
  682.  
  683.     -- *  WM_LBUTTONDOWN &  WM_RBUTTONDOWN
  684.     -- *
  685.     -- * Capture the mouse, set the tracking mode depending on the mouse
  686.     -- *  location in world coordinates, reset the mouse position.
  687.     when WM_LBUTTONDOWN | WM_RBUTTONDOWN =>
  688.       declare
  689.         hwnd_dummy   : WinDef.HWND;
  690.         half_right   : Win32.LONG;
  691.         half_bottom  : Win32.LONG;
  692.       begin
  693.         mouWorld2(0).x := Win32.LONG (WinDef.LOWORD (DWORD(lParam)));
  694.         mouWorld2(0).y := Win32.LONG (WinDef.HIWORD (DWORD(lParam)));
  695.         bResult := DPtoLP (ptoRect.hdc_value, mouWorld2(0)'Access, 1);
  696.         half_right  := ptoRect.rect.right / 2;
  697.         half_bottom := ptoRect.rect.bottom / 2;
  698.  
  699.         -- /* upper left hand corner. right button is no-op. */
  700.         if ((mouWorld2(0).x <= half_right) and 
  701.             (mouWorld2(0).y <= half_bottom) ) then
  702.           if msg = WM_LBUTTONDOWN then
  703.             ptoRect.Mode := TMMOVE;
  704.             newmouScreen(0).x := ptoRect.rect.left;
  705.             newmouScreen(0).y := ptoRect.rect.top;
  706.           else  -- WM_RBUTTONDOWN, do nothing
  707.             null;
  708.           end if;
  709.  
  710.         -- /* lower left hand corner */
  711.         elsif ((mouWorld2(0).x <= half_right) and 
  712.                (mouWorld2(0).y >  half_bottom)) then
  713.           if msg = WM_RBUTTONDOWN then
  714.             ptoRect.Mode := TMSHEARY;
  715.           else 
  716.             ptoRect.Mode := TMSIZEY;
  717.           end if;
  718.           newmouScreen(0).x := ptoRect.rect.left;
  719.           newmouScreen(0).y := ptoRect.rect.bottom;
  720.  
  721.         -- /* upper right hand corner */
  722.         elsif ((mouWorld2(0).x >  half_right) and 
  723.                (mouWorld2(0).y <= half_bottom)) then
  724.           if msg = WM_RBUTTONDOWN then
  725.             ptoRect.Mode := TMSHEARX;
  726.           else 
  727.             ptoRect.Mode := TMSIZEX;
  728.           end if;
  729.           newmouScreen(0).x := ptoRect.rect.right;
  730.           newmouScreen(0).y := ptoRect.rect.top;
  731.  
  732.         -- /* lower right hand corner */
  733.         -- elsif ((mouWorld2(0).x > half_right) and 
  734.         --        (mouWorld2(0).y > half_bottom)) then
  735.         else  -- take care of last case
  736.           if msg = WM_RBUTTONDOWN then
  737.             ptoRect.Mode := TMROTATE;
  738.           else
  739.             ptoRect.Mode := TMSIZEXY;
  740.           end if;
  741.           newmouScreen(0).x := ptoRect.rect.right;
  742.           newmouScreen(0).y := ptoRect.rect.bottom;
  743.  
  744.         end if;
  745.  
  746.         hwnd_dummy := SetCapture(hwnd);
  747.         bResult := LPtoDP (ptoRect.hdc_value, newmouScreen(0)'Access, 1);
  748.         bResult := ClientToScreen (hwnd, newmouScreen(0)'Access);
  749.         bResult := SetCursorPos (Win32.INT (newmouScreen(0).x),
  750.                                  Win32.INT (newmouScreen(0).y));
  751.         bResult := GetWorldTransform(ptoRect.hdc_value,ptoRect.xfmDown'Access);
  752.       end; 
  753.  
  754.  
  755.     -- *  WM_MOUSEMOVE
  756.     -- *
  757.     -- * this is where almost all of the interesting calculation is done.
  758.     -- *  First clip the mouse location to be in client rectangle, then
  759.     -- *  call MouseMove() to handle the different tracking modes.
  760.     when WM_MOUSEMOVE =>
  761.       declare 
  762.         mouse_pos_out : POINT;
  763.         mouse_pos_in  : POINT; 
  764.       begin
  765.         mouse_pos_in.x := Win32.LONG (WinDef.LOWORD (DWORD(lParam)));
  766.         mouse_pos_in.y := Win32.LONG (WinDef.HIWORD (DWORD(lParam)));
  767.         bResult := GetClientRect (hwnd, rect'Access);
  768.         -- set default values for the mouse out position.
  769.         mouse_pos_out.x := mouse_pos_in.x;
  770.         mouse_pos_out.y := mouse_pos_in.y;
  771.  
  772.         -- make corrections to the mouse out position.  If it is outside of
  773.         -- any bounds of the client area, then use the client area.
  774.  
  775.         if mouse_pos_in.x < rect.left then
  776.           mouse_pos_out.x := rect.left;
  777.         end if;
  778.  
  779.         if mouse_pos_in.x > rect.right then
  780.           mouse_pos_out.x := rect.right;
  781.         end if;
  782.  
  783.         if mouse_pos_in.y < rect.top then
  784.           mouse_pos_out.y := rect.top;
  785.         end if;
  786.  
  787.         if mouse_pos_in.y > rect.bottom then
  788.           mouse_pos_out.y := rect.bottom;
  789.         end if;
  790.  
  791.         MouseMove (msg, hwnd, mouse_pos_out);
  792.  
  793.       end;
  794.  
  795.  
  796.     -- *  WM_RBUTTONUP & WM_LBUTTONUP
  797.     -- *
  798.     -- * simply release the mouse capture, and set the mode to TMNONE.
  799.     when WM_RBUTTONUP | WM_LBUTTONUP =>
  800.       if (ptoRect.Mode /= TMNONE) then
  801.         bResult := ReleaseCapture;
  802.         ptoRect.Mode := TMNONE;
  803.       end if;
  804.  
  805.     when others =>
  806.       null;
  807.  
  808.   end case;
  809.  
  810. end doTrackObject;
  811.  
  812.  
  813. -- *  function:  MouseMove()
  814. -- *
  815. -- *  input parameters:
  816. -- *   msg -  not used.
  817. -- *   hwnd - Window handle for the window the track object exists within.
  818. -- *   location - location of the mouse
  819. -- *
  820. -- *  The tracking behavior which the user observers when moving the mouse
  821. -- *   is based on the current tracking mode of the object.  This is usually
  822. -- *   determined on the mouse down event (c.f. TM*).  First erase the old
  823. -- *   object, then figure out the change to the transform matrix, finally
  824. -- *   change the world transform matrix and redraw the object.
  825. -- *
  826. -- *  Tranform:
  827. -- *    (    eM11        eM12        0   )
  828. -- *    (    eM21        eM22        0   )
  829. -- *    (    eDx         eDy         1   )
  830. -- *
  831. -- *   xDevice = (xWorld * eM11) + (yWorld * eM21) + eDx
  832. -- *   yDevice = (xWorld * eM12) + (yWorld * eM22) + eDy
  833. -- *
  834. -- *   In this routine the Device (mouse location) and World (rectangle corner)
  835. -- *   points are known.  Therefore, the two equations above are solved for
  836. -- *   the desired matrix entry value (e.g. eM11, 1M12, ... eDy).  The tracking
  837. -- *   mode determines which one of these entries may be changed.  E.g. scaling
  838. -- *   in X modifies eM11 while shearing in X modifies eM12.  So rather than
  839. -- *   using the world transform to map from world to device points, we are
  840. -- *   back-computing the proper contents of the world transform.
  841. -- *
  842. -- Note;  The C version of this did not do any checking for possible divide
  843. -- by zero errors.  This version will leave the procedure without doing
  844. -- anything in the case in which the parameters are such that a divide by zero
  845. -- or other floating point error occurs.  The C version also passed the x
  846. -- and y values via a LONG type parameter.  Rather than doing this, I will
  847. -- pass a point record in.  This will save on some converting back and forth. 
  848. procedure MouseMove (msg      : UINT;    
  849.                      hwnd     : HWND;
  850.                      location : POINT) is
  851.   temp      : FLOAT;
  852.   invalid_computation : boolean := False;
  853.  
  854. begin
  855.   doTrackObject(TROB_PAINT, hwnd, 0);
  856.   mouDevice.x     := location.x;
  857.   mouWorld3(0).x  := location.x;
  858.   mouDevice.y     := location.y;
  859.   mouWorld3(0).y  := location.y;
  860.  
  861.   bResult := SetWorldTransform (ptoRect.hdc_value, ptoRect.xfmDown'Access);
  862.   bResult := DPtoLP (ptoRect.hdc_value, mouWorld3(0)'Access, 1);
  863.  
  864.   -- /* offset the mouse device point for the viewport's origin. */
  865.   bResult := GetViewportOrgEx (ptoRect.hdc_value, orgDevice'Access);
  866.   mouDevice.x := mouDevice.x - orgDevice.x;
  867.   mouDevice.y := mouDevice.y - orgDevice.y;
  868.  
  869.   bResult := GetWorldTransform(ptoRect.hdc_value, ptoRect.xfmChange'Access);
  870.  
  871.   case ptoRect.Mode is
  872.     -- *    (     1         xShear       0   )
  873.     -- *    (     0           1          0   )
  874.     -- *    (     0           0          1   )
  875.     -- *
  876.     -- * xWorld = rect.left == 0;
  877.     when TMSHEARX =>
  878.       if ptoRect.rect.right /= 0 then
  879.         ptoRect.xfmChange.eM12 := (Win32.FLOAT (mouDevice.y) - 
  880.                                    ptoRect.xfmChange.eDy) /
  881.                                    Win32.FLOAT (ptoRect.rect.right);
  882.         bResult := SetWorldTransform (ptoRect.hdc_value, ptoRect.xfmChange'Access);
  883.       else 
  884.         invalid_computation := True;
  885.       end if;
  886.  
  887.  
  888.     -- *    (     1           0          0   )
  889.     -- *    (   yShear        1          0   )
  890.     -- *    (     0           0          1   )
  891.     -- *
  892.     -- * yWorld = rect.top == 0;
  893.     when TMSHEARY =>
  894.       if ptoRect.rect.bottom /= 0 then
  895.         ptoRect.xfmChange.eM21 := (Win32.FLOAT (mouDevice.x) - 
  896.                                    ptoRect.xfmChange.eDx) /
  897.                                    Win32.FLOAT (ptoRect.rect.bottom);
  898.         bResult := SetWorldTransform (ptoRect.hdc_value, ptoRect.xfmChange'Access);
  899.       else
  900.         invalid_computation := True;
  901.       end if;
  902.  
  903.  
  904.     -- *    (   cos(a)      -sin(a)      0   )
  905.     -- *    (   sin(a)       cos(a)      0   )
  906.     -- *    (     0           0          1   )
  907.     -- *
  908.     -- * a == rotation angle.  Since mouse in in lower right,
  909.     -- *  we need to shift this back 45 degrees (assuming that
  910.     -- *  straight down is 0 degrees).  Thus we actually compute
  911.     -- *  cos(a) = cos(b - 45) = cos(b)sin(45) + cos(45)sin(45)
  912.     -- *  where b is angle from the origin to the mouse (x,y)
  913.     -- *  cos(45) = sin(45) ~= 0.707107
  914.     -- *  cos(b) = y/r    sin(b) = x/r
  915.     -- *
  916.     when TMROTATE =>
  917.     declare 
  918.       r : FLOAT;
  919.     begin
  920.       -- /* translate back to the origin. */
  921.       ptoRect.xfmChange.eDx := 0.0;
  922.       ptoRect.xfmChange.eDy := 0.0;
  923.       bResult := SetWorldTransform (ptoRect.hdc_value, ptoRect.xfmChange'Access);
  924.  
  925.       -- /* rotate about the origin. */
  926.       r := Float_Functions.sqrt (FLOAT ( 
  927.              (mouWorld3(0).x * mouWorld3(0).x) +
  928.              (mouWorld3(0).y * mouWorld3(0).y)) );
  929.          
  930.       ptoRect.xfmChange.eM11 := 
  931.         Win32.FLOAT((FLOAT(mouWorld3(0).y + mouWorld3(0).x) * 0.707107) / r);
  932.       ptoRect.xfmChange.eM22 := ptoRect.xfmChange.eM11;
  933.       ptoRect.xfmChange.eM12 := 
  934.         Win32.FLOAT((FLOAT (mouWorld3(0).y - mouWorld3(0).x) * 0.707107) / r);
  935.       ptoRect.xfmChange.eM21 := -1.0 * ptoRect.xfmChange.eM12;
  936.       ptoRect.xfmChange.eDx := 0.0;
  937.       ptoRect.xfmChange.eDy := 0.0;
  938.  
  939.       bResult := ModifyWorldTransform (ptoRect.hdc_value, 
  940.                                        ptoRect.xfmChange'Access, 
  941.                                        MWT_RIGHTMULTIPLY);
  942.  
  943.       -- /* translate back to the original offset. */
  944.       ptoRect.xfmChange.eM11 := 1.0;
  945.       ptoRect.xfmChange.eM22 := 1.0;
  946.       ptoRect.xfmChange.eM12 := 0.0;
  947.       ptoRect.xfmChange.eM21 := 0.0;
  948.  
  949.       ptoRect.xfmChange.eDx := ptoRect.xfmDown.eDx;
  950.       ptoRect.xfmChange.eDy := ptoRect.xfmDown.eDy;
  951.       bResult := ModifyWorldTransform (ptoRect.hdc_value, 
  952.                                        ptoRect.xfmChange'Access, 
  953.                                        MWT_RIGHTMULTIPLY);
  954.       bResult := GetWorldTransform (ptoRect.hdc_value, ptoRect.xfmChange'Access);
  955.     end; 
  956.  
  957.  
  958.     -- *    (  Size X         0          0   )
  959.     -- *    (     0        Size Y        0   )
  960.     -- *    (     0           0          1   )
  961.     -- *
  962.     when TMSIZEXY =>
  963.     if ptoRect.rect.right /= 0 and ptoRect.rect.bottom /= 0 then
  964.       ptoRect.xfmChange.eM11 := 
  965.          (Win32.FLOAT (mouDevice.x) - ptoRect.xfmChange.eDx - 
  966.           (Win32.FLOAT (ptoRect.rect.bottom) * ptoRect.xfmChange.eM21)) /
  967.            Win32.FLOAT (ptoRect.rect.right);
  968.  
  969.       ptoRect.xfmChange.eM22 := 
  970.           (Win32.FLOAT (mouDevice.y) - ptoRect.xfmChange.eDy - 
  971.            (Win32.FLOAT (ptoRect.rect.right) * ptoRect.xfmChange.eM12)) /
  972.             Win32.FLOAT (ptoRect.rect.bottom);
  973.  
  974.       bResult := SetWorldTransform (ptoRect.hdc_value, ptoRect.xfmChange'Access);
  975.     else
  976.       invalid_computation := True;
  977.     end if; 
  978.  
  979.  
  980.     -- *    (  Size X         0          0   )
  981.     -- *    (     0           1          0   )
  982.     -- *    (     0           0          1   )
  983.     -- *
  984.     -- * yWorld = rect.top == 0;
  985.     when TMSIZEX =>
  986.     if ptoRect.rect.right /= 0 then
  987.       ptoRect.xfmChange.eM11 := (Win32.FLOAT (mouDevice.x) - 
  988.                                  ptoRect.xfmChange.eDx) /
  989.                                  Win32.FLOAT (ptoRect.rect.right);
  990.       bResult := SetWorldTransform (ptoRect.hdc_value, ptoRect.xfmChange'Access);
  991.     else
  992.       invalid_computation := True;
  993.     end if;
  994.  
  995.  
  996.     -- *    (     1           0          0   )
  997.     -- *    (     0        Size Y        0   )
  998.     -- *    (     0           0          1   )
  999.     -- *
  1000.     -- * xWorld = rect.left == 0;
  1001.     when TMSIZEY =>
  1002.     if ptoRect.rect.bottom /= 0 then
  1003.       ptoRect.xfmChange.eM22 := (Win32.FLOAT (mouDevice.y) - 
  1004.                                  ptoRect.xfmChange.eDy) /
  1005.                                  Win32.FLOAT (ptoRect.rect.bottom);
  1006.       bResult := SetWorldTransform (ptoRect.hdc_value, ptoRect.xfmChange'Access);
  1007.     else
  1008.       invalid_computation := True;
  1009.     end if; 
  1010.  
  1011.  
  1012.     -- *    (     1           0          0   )
  1013.     -- *    (     0           1          0   )
  1014.     -- *    (   Move x      Move y       1   )
  1015.     -- *
  1016.     -- * xWorld = rect.left == 0;
  1017.     -- * yWorld = rect.top == 0;
  1018.     when TMMOVE =>
  1019.       ptoRect.xfmChange.eDx := Win32.FLOAT (mouDevice.x);
  1020.       ptoRect.xfmChange.eDy := Win32.FLOAT (mouDevice.y);
  1021.       bResult := SetWorldTransform (ptoRect.hdc_value, ptoRect.xfmChange'Access);
  1022.  
  1023.     when others =>
  1024.       invalid_computation := True; 
  1025.   end case;
  1026.  
  1027.   doTrackObject(TROB_PAINT, hwnd, 0);
  1028.  
  1029. end MouseMove;
  1030.  
  1031. --  The following null dialog box procedure did not appear in the C version
  1032. --  of this sample.  It has been provided here for use in wxform_ada.
  1033. function Null_Dlgproc (hwnd    : HWND;
  1034.                        message : UINT;
  1035.                        wParam  : WPARAM;
  1036.                        lParam  : LPARAM) return BOOL is
  1037. begin
  1038.   return Win32.False;
  1039. end Null_Dlgproc;
  1040.  
  1041. -------------------------------------------------------------------------------
  1042. --
  1043. -- THIS FILE AND ANY ASSOCIATED DOCUMENTATION IS PROVIDED "AS IS" WITHOUT 
  1044. -- WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT 
  1045. -- LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR 
  1046. -- A PARTICULAR PURPOSE.  The user assumes the entire risk as to the accuracy 
  1047. -- and the use of this file.  This file may be used only by licensees of 
  1048. -- Microsoft Corporation's WIN32 Software Development Kit in accordance with 
  1049. -- the terms of the licensee's End-User License Agreement for Microsoft 
  1050. -- Software for the WIN32 Development Kit.
  1051. --
  1052. -- Copyright (c) Intermetrics, Inc. 1995
  1053. -- Portions (c) 1985-1994 Microsoft Corporation with permission.
  1054. -- Microsoft is a registered trademark and Windows and Windows NT are 
  1055. -- trademarks of Microsoft Corporation.
  1056. --
  1057. -------------------------------------------------------------------------------
  1058.  
  1059. end Wxform_Util;
  1060.