control.pp 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. (******************************************************************************
  2. *
  3. * Copyright (c) 1994-2000 Palm, Inc. or its subsidiaries.
  4. * All rights reserved.
  5. *
  6. * File: Control.h
  7. *
  8. * Release: Palm OS SDK 4.0 (63220)
  9. *
  10. * Description:
  11. * This file defines check box structures and routines.
  12. *
  13. * History:
  14. * August 29, 1994 Created by Art Lamb
  15. * Name Date Description
  16. * ---- ---- -----------
  17. * bob 2/9/99 Fix up const stuff
  18. * bob 4/16/99 add GraphicControlType
  19. *
  20. *****************************************************************************)
  21. {$MACRO ON}
  22. {$IFNDEF FPC_DOTTEDUNITS}
  23. unit control;
  24. {$ENDIF FPC_DOTTEDUNITS}
  25. interface
  26. {$IFDEF FPC_DOTTEDUNITS}
  27. uses PalmApi.Palmos, PalmApi.Coretraps, PalmApi.Rect, PalmApi.Datamgr, PalmApi.Font;
  28. {$ELSE FPC_DOTTEDUNITS}
  29. uses palmos, coretraps, rect, datamgr, font;
  30. {$ENDIF FPC_DOTTEDUNITS}
  31. type
  32. ControlAttrType = record
  33. {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_CONTROLS} // These fields will not be available in the next OS release!
  34. Bits: UInt16;
  35. {
  36. UInt8 usable :1; // set if part of ui
  37. UInt8 enabled :1; // set if interactable (not grayed out)
  38. UInt8 visible :1; // set if drawn (set internally)
  39. UInt8 on :1; // set if on (checked)
  40. UInt8 leftAnchor :1; // set if bounds expand to the right
  41. // clear if bounds expand to the left
  42. UInt8 frame :3;
  43. UInt8 drawnAsSelected :1; // support for old-style graphic controls
  44. // where control overlaps a bitmap
  45. UInt8 graphical :1; // set if images are used instead of text
  46. UInt8 vertical :1; // true for vertical sliders
  47. UInt8 reserved :5;
  48. }
  49. {$endif}
  50. end;
  51. ControlAttrTag = ControlAttrType;
  52. type
  53. controlStyles = Enum;
  54. const
  55. buttonCtl = 0;
  56. pushButtonCtl = Succ(buttonCtl);
  57. checkboxCtl = Succ(pushButtonCtl);
  58. popupTriggerCtl = Succ(checkboxCtl);
  59. selectorTriggerCtl = Succ(popupTriggerCtl);
  60. repeatingButtonCtl = Succ(selectorTriggerCtl);
  61. sliderCtl = Succ(repeatingButtonCtl);
  62. feedbackSliderCtl = Succ(sliderCtl);
  63. type
  64. ControlStyleType = controlStyles;
  65. type
  66. buttonFrames = Enum;
  67. const
  68. noButtonFrame = 0;
  69. standardButtonFrame = Succ(noButtonFrame);
  70. boldButtonFrame = Succ(standardButtonFrame);
  71. rectangleButtonFrame = Succ(boldButtonFrame);
  72. type
  73. ButtonFrameType = buttonFrames;
  74. type
  75. ControlType = record
  76. {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_CONTROLS} // These fields will not be available in the next OS release!
  77. id: UInt16;
  78. bounds: RectangleType;
  79. text: PAnsiChar;
  80. attr: ControlAttrType;
  81. style: ControlStyleType;
  82. font: FontID;
  83. group: UInt8;
  84. reserved: UInt8;
  85. {$endif}
  86. end;
  87. ControlPtr = ^ControlType; // deprecated, use ControlType *
  88. // GraphicControlType *'s can be cast to ControlType *'s and passed to all
  89. // Control API functions (as long as the 'graphical' bit in the attrs is set)
  90. GraphicControlType = record
  91. {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_CONTROLS} // These fields will not be available in the next OS release!
  92. id: UInt16;
  93. bounds: RectangleType;
  94. bitmapID: DmResID; // overlays text in ControlType
  95. selectedBitmapID: DmResID; // overlays text in ControlType
  96. attr: ControlAttrType;
  97. style: ControlStyleType;
  98. unused: FontID;
  99. group: UInt8;
  100. reserved: UInt8;
  101. {$endif}
  102. end;
  103. GraphicControlPtr = ^GraphicControlType;
  104. // SliderControlType *'s can be cast to ControlType *'s and passed to all
  105. // Control API functions (as long as the control style is a slider)
  106. SliderControlType = record
  107. {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_CONTROLS} // These fields will not be available in the next OS release!
  108. id: UInt16;
  109. bounds: RectangleType;
  110. thumbID: DmResID; // overlays text in ControlType
  111. backgroundID: DmResID; // overlays text in ControlType
  112. attr: ControlAttrType; // graphical *is* set
  113. style: ControlStyleType; // must be sliderCtl or repeatingSliderCtl
  114. reserved: UInt8;
  115. minValue: Int16;
  116. maxValue: Int16;
  117. pageSize: Int16;
  118. value: Int16;
  119. activeSliderP: MemPtr;
  120. {$endif}
  121. end;
  122. SliderControlPtr = ^SliderControlType;
  123. //----------------------------------------------------------
  124. // Control Functions
  125. //----------------------------------------------------------
  126. procedure CtlDrawControl(controlP: ControlPtr); syscall sysTrapCtlDrawControl;
  127. procedure CtlEraseControl(controlP: ControlPtr); syscall sysTrapCtlEraseControl;
  128. procedure CtlHideControl(controlP: ControlPtr); syscall sysTrapCtlHideControl;
  129. procedure CtlShowControl(controlP: ControlPtr); syscall sysTrapCtlShowControl;
  130. function CtlEnabled(const controlP: ControlPtr): Boolean; syscall sysTrapCtlEnabled;
  131. procedure CtlSetEnabled(controlP: ControlPtr; usable: Boolean); syscall sysTrapCtlSetEnabled;
  132. procedure CtlSetUsable(controlP: ControlPtr; usable: Boolean); syscall sysTrapCtlSetUsable;
  133. function CtlGetValue(const controlP: ControlPtr): Int16; syscall sysTrapCtlGetValue;
  134. procedure CtlSetValue(controlP: ControlPtr; newValue: Int16); syscall sysTrapCtlSetValue;
  135. function CtlGetLabel(const controlP: ControlPtr): PAnsiChar; syscall sysTrapCtlGetLabel;
  136. procedure CtlSetLabel(controlP: ControlPtr; const newLabel: PAnsiChar); syscall sysTrapCtlSetLabel;
  137. procedure CtlSetGraphics(ctlP: ControlPtr; newBitmapID, newSelectedBitmapID: DmResID); syscall sysTrapCtlSetGraphics;
  138. procedure CtlSetSliderValues(ctlP: ControlPtr; {const} var minValueP, maxValueP, pageSizeP, valueP: UInt16); syscall sysTrapCtlSetSliderValues;
  139. procedure CtlGetSliderValues(const ctlP: ControlPtr; var minValueP, maxValueP, pageSizeP, valueP: UInt16); syscall sysTrapCtlGetSliderValues;
  140. procedure CtlHitControl(const controlP: ControlPtr); syscall sysTrapCtlHitControl;
  141. type
  142. EventPtr = Pointer;
  143. function CtlHandleEvent(controlP: ControlPtr; pEvent: EventPtr): Boolean; syscall sysTrapCtlHandleEvent;
  144. function CtlValidatePointer(const controlP: ControlPtr): Boolean; syscall sysTrapCtlValidatePointer;
  145. function CtlNewControl(formPP: PointerPtr; ID: UInt16; style: ControlStyleType; const textP: PAnsiChar;
  146. x, y, width, height: Coord; font: FontID; group: UInt8; leftAnchor: Boolean): ControlPtr; syscall sysTrapCtlNewControl;
  147. function CtlNewGraphicControl(formPP: PointerPtr; ID: UInt16; style: ControlStyleType; bitmapID, selectedBitmapID: DmResID;
  148. x, y, width, height: Coord; group: UInt8; leftAnchor: Boolean): GraphicControlPtr; syscall sysTrapCtlNewGraphicControl;
  149. function CtlNewSliderControl(formPP: PointerPtr; ID: UInt16; style: ControlStyleType; thumbID, backgroundID: DmResID;
  150. x, y, width, height: Coord; minValue, maxValue, pageSize, value: UInt16): SliderControlPtr; syscall sysTrapCtlNewSliderControl;
  151. implementation
  152. end.