sysmsg.pas 3.1 KB

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