control.pp 6.6 KB

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