sysmsg.pas 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. {
  2. $Id$
  3. Unit to handle system events
  4. Copyright 2000 by Pierre Muller <[email protected]>
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public
  14. License along with this library; if not, write to the Free
  15. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************}
  17. Unit sysmsg;
  18. interface
  19. type
  20. TSystemMessage = (
  21. SysNothing,
  22. SysSetFocus,
  23. SysReleaseFocus,
  24. SysClose,
  25. SysResize );
  26. TSystemEvent = Record
  27. case typ : TSystemMessage of
  28. SysClose : ( CloseTyp : Longint);
  29. SysResize : (X,Y : Longint);
  30. end;
  31. PSystemEvent = ^TSystemEvent;
  32. const
  33. SystemEventBufSize = 16;
  34. var
  35. PendingSystemEvent : array[0..SystemEventBufSize-1] of TSystemEvent;
  36. PendingSystemHead,
  37. PendingSystemTail : PSystemEvent;
  38. PendingSystemEvents : byte;
  39. LastSystemEvent : TSystemEvent;
  40. procedure InitSystemMsg;
  41. procedure DoneSystemMsg;
  42. procedure GetSystemEvent(var SystemEvent:TSystemEvent);
  43. { Returns the last SystemEvent, and waits for one if not available }
  44. procedure PutSystemEvent(const SystemEvent: TSystemEvent);
  45. { Adds the given SystemEvent to the input queue. }
  46. function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
  47. { Checks if a SystemEvent is available, and returns it if one is found. If no
  48. event is pending, it returns 0 }
  49. implementation
  50. {$undef HAS_SYSMSG}
  51. {$ifdef go32v2}
  52. {$i go32smsg.inc}
  53. {$define HAS_SYSMSG}
  54. {$endif go32v2}
  55. {$ifdef win32}
  56. {$i w32smsg.inc}
  57. {$define HAS_SYSMSG}
  58. {$endif win32}
  59. {$ifdef unix}
  60. {$i unixsmsg.inc}
  61. {$define HAS_SYSMSG}
  62. {$endif unix}
  63. {$ifndef HAS_SYSMSG}
  64. procedure InitSystemMsg;
  65. begin
  66. end;
  67. procedure DoneSystemMsg;
  68. begin
  69. end;
  70. procedure GetSystemEvent(var SystemEvent:TSystemEvent);
  71. begin
  72. FillChar(SystemEvent,SizeOf(SystemEvent),#0);
  73. end;
  74. function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
  75. begin
  76. FillChar(SystemEvent,SizeOf(SystemEvent),#0);
  77. PollSystemEvent:=false;
  78. end;
  79. {$endif not HAS_SYSMSG}
  80. procedure PutSystemEvent(const SystemEvent: TSystemEvent);
  81. begin
  82. if PendingSystemEvents<SystemEventBufSize then
  83. begin
  84. PendingSystemTail^:=SystemEvent;
  85. inc(PendingSystemTail);
  86. if longint(PendingSystemTail)=longint(@PendingSystemEvent)+sizeof(PendingSystemEvent) then
  87. PendingSystemTail:=@PendingSystemEvent;
  88. inc(PendingSystemEvents);
  89. end;
  90. end;
  91. end.
  92. {
  93. $Log$
  94. Revision 1.1 2002-05-21 11:59:57 pierre
  95. + system messages unit added
  96. }