xutil.nim 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. import
  2. x, xlib, keysym
  3. #const
  4. # libX11* = "libX11.so"
  5. #
  6. # Automatically converted by H2Pas 0.99.15 from xutil.h
  7. # The following command line parameters were used:
  8. # -p
  9. # -T
  10. # -S
  11. # -d
  12. # -c
  13. # xutil.h
  14. #
  15. const
  16. NoValue* = 0x00000000
  17. XValue* = 0x00000001
  18. YValue* = 0x00000002
  19. WidthValue* = 0x00000004
  20. HeightValue* = 0x00000008
  21. AllValues* = 0x0000000F
  22. XNegative* = 0x00000010
  23. YNegative* = 0x00000020
  24. type
  25. TCPoint*{.final.} = object
  26. x*: cint
  27. y*: cint
  28. PXSizeHints* = ptr TXSizeHints
  29. TXSizeHints*{.final.} = object
  30. flags*: clong
  31. x*, y*: cint
  32. width*, height*: cint
  33. min_width*, min_height*: cint
  34. max_width*, max_height*: cint
  35. width_inc*, height_inc*: cint
  36. min_aspect*, max_aspect*: TCPoint
  37. base_width*, base_height*: cint
  38. win_gravity*: cint
  39. const
  40. USPosition* = 1 shl 0
  41. USSize* = 1 shl 1
  42. PPosition* = 1 shl 2
  43. PSize* = 1 shl 3
  44. PMinSize* = 1 shl 4
  45. PMaxSize* = 1 shl 5
  46. PResizeInc* = 1 shl 6
  47. PAspect* = 1 shl 7
  48. PBaseSize* = 1 shl 8
  49. PWinGravity* = 1 shl 9
  50. PAllHints* = PPosition or PSize or PMinSize or PMaxSize or PResizeInc or
  51. PAspect
  52. type
  53. PXWMHints* = ptr TXWMHints
  54. TXWMHints*{.final.} = object
  55. flags*: clong
  56. input*: TBool
  57. initial_state*: cint
  58. icon_pixmap*: TPixmap
  59. icon_window*: TWindow
  60. icon_x*, icon_y*: cint
  61. icon_mask*: TPixmap
  62. window_group*: TXID
  63. const
  64. InputHint* = 1 shl 0
  65. StateHint* = 1 shl 1
  66. IconPixmapHint* = 1 shl 2
  67. IconWindowHint* = 1 shl 3
  68. IconPositionHint* = 1 shl 4
  69. IconMaskHint* = 1 shl 5
  70. WindowGroupHint* = 1 shl 6
  71. AllHints* = InputHint or StateHint or IconPixmapHint or IconWindowHint or
  72. IconPositionHint or IconMaskHint or WindowGroupHint
  73. XUrgencyHint* = 1 shl 8
  74. WithdrawnState* = 0
  75. NormalState* = 1
  76. IconicState* = 3
  77. DontCareState* = 0
  78. ZoomState* = 2
  79. InactiveState* = 4
  80. type
  81. PXTextProperty* = ptr TXTextProperty
  82. TXTextProperty*{.final.} = object
  83. value*: Pcuchar
  84. encoding*: TAtom
  85. format*: cint
  86. nitems*: culong
  87. const
  88. XNoMemory* = - 1
  89. XLocaleNotSupported* = - 2
  90. XConverterNotFound* = - 3
  91. type
  92. PXICCEncodingStyle* = ptr TXICCEncodingStyle
  93. TXICCEncodingStyle* = enum
  94. XStringStyle, XCompoundTextStyle, XTextStyle, XStdICCTextStyle,
  95. XUTF8StringStyle
  96. PPXIconSize* = ptr PXIconSize
  97. PXIconSize* = ptr TXIconSize
  98. TXIconSize*{.final.} = object
  99. min_width*, min_height*: cint
  100. max_width*, max_height*: cint
  101. width_inc*, height_inc*: cint
  102. PXClassHint* = ptr TXClassHint
  103. TXClassHint*{.final.} = object
  104. res_name*: cstring
  105. res_class*: cstring
  106. type
  107. PXComposeStatus* = ptr TXComposeStatus
  108. TXComposeStatus*{.final.} = object
  109. compose_ptr*: TXPointer
  110. chars_matched*: cint
  111. type
  112. PXRegion* = ptr TXRegion
  113. TXRegion*{.final.} = object
  114. TRegion* = PXRegion
  115. PRegion* = ptr TRegion
  116. const
  117. RectangleOut* = 0
  118. RectangleIn* = 1
  119. RectanglePart* = 2
  120. type
  121. PXVisualInfo* = ptr TXVisualInfo
  122. TXVisualInfo*{.final.} = object
  123. visual*: PVisual
  124. visualid*: TVisualID
  125. screen*: cint
  126. depth*: cint
  127. class*: cint
  128. red_mask*: culong
  129. green_mask*: culong
  130. blue_mask*: culong
  131. colormap_size*: cint
  132. bits_per_rgb*: cint
  133. const
  134. VisualNoMask* = 0x00000000
  135. VisualIDMask* = 0x00000001
  136. VisualScreenMask* = 0x00000002
  137. VisualDepthMask* = 0x00000004
  138. VisualClassMask* = 0x00000008
  139. VisualRedMaskMask* = 0x00000010
  140. VisualGreenMaskMask* = 0x00000020
  141. VisualBlueMaskMask* = 0x00000040
  142. VisualColormapSizeMask* = 0x00000080
  143. VisualBitsPerRGBMask* = 0x00000100
  144. VisualAllMask* = 0x000001FF
  145. type
  146. PPXStandardColormap* = ptr PXStandardColormap
  147. PXStandardColormap* = ptr TXStandardColormap
  148. TXStandardColormap*{.final.} = object
  149. colormap*: TColormap
  150. red_max*: culong
  151. red_mult*: culong
  152. green_max*: culong
  153. green_mult*: culong
  154. blue_max*: culong
  155. blue_mult*: culong
  156. base_pixel*: culong
  157. visualid*: TVisualID
  158. killid*: TXID
  159. const
  160. BitmapSuccess* = 0
  161. BitmapOpenFailed* = 1
  162. BitmapFileInvalid* = 2
  163. BitmapNoMemory* = 3
  164. XCSUCCESS* = 0
  165. XCNOMEM* = 1
  166. XCNOENT* = 2
  167. ReleaseByFreeingColormap*: TXID = TXID(1)
  168. type
  169. PXContext* = ptr TXContext
  170. TXContext* = cint
  171. proc XAllocClassHint*(): PXClassHint{.cdecl, dynlib: libX11, importc.}
  172. proc XAllocIconSize*(): PXIconSize{.cdecl, dynlib: libX11, importc.}
  173. proc XAllocSizeHints*(): PXSizeHints{.cdecl, dynlib: libX11, importc.}
  174. proc XAllocStandardColormap*(): PXStandardColormap{.cdecl, dynlib: libX11,
  175. importc.}
  176. proc XAllocWMHints*(): PXWMHints{.cdecl, dynlib: libX11, importc.}
  177. proc XClipBox*(para1: TRegion, para2: PXRectangle): cint{.cdecl, dynlib: libX11,
  178. importc.}
  179. proc XCreateRegion*(): TRegion{.cdecl, dynlib: libX11, importc.}
  180. proc XDefaultString*(): cstring{.cdecl, dynlib: libX11, importc.}
  181. proc XDeleteContext*(para1: PDisplay, para2: TXID, para3: TXContext): cint{.
  182. cdecl, dynlib: libX11, importc.}
  183. proc XDestroyRegion*(para1: TRegion): cint{.cdecl, dynlib: libX11, importc.}
  184. proc XEmptyRegion*(para1: TRegion): cint{.cdecl, dynlib: libX11, importc.}
  185. proc XEqualRegion*(para1: TRegion, para2: TRegion): cint{.cdecl, dynlib: libX11,
  186. importc.}
  187. proc XFindContext*(para1: PDisplay, para2: TXID, para3: TXContext,
  188. para4: PXPointer): cint{.cdecl, dynlib: libX11, importc.}
  189. proc XGetClassHint*(para1: PDisplay, para2: TWindow, para3: PXClassHint): TStatus{.
  190. cdecl, dynlib: libX11, importc.}
  191. proc XGetIconSizes*(para1: PDisplay, para2: TWindow, para3: PPXIconSize,
  192. para4: Pcint): TStatus{.cdecl, dynlib: libX11, importc.}
  193. proc XGetNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): TStatus{.
  194. cdecl, dynlib: libX11, importc.}
  195. proc XGetRGBColormaps*(para1: PDisplay, para2: TWindow,
  196. para3: PPXStandardColormap, para4: Pcint, para5: TAtom): TStatus{.
  197. cdecl, dynlib: libX11, importc.}
  198. proc XGetSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints,
  199. para4: TAtom): TStatus{.cdecl, dynlib: libX11, importc.}
  200. proc XGetStandardColormap*(para1: PDisplay, para2: TWindow,
  201. para3: PXStandardColormap, para4: TAtom): TStatus{.
  202. cdecl, dynlib: libX11, importc.}
  203. proc XGetTextProperty*(para1: PDisplay, para2: TWindow, para3: PXTextProperty,
  204. para4: TAtom): TStatus{.cdecl, dynlib: libX11, importc.}
  205. proc XGetVisualInfo*(para1: PDisplay, para2: clong, para3: PXVisualInfo,
  206. para4: Pcint): PXVisualInfo{.cdecl, dynlib: libX11, importc.}
  207. proc XGetWMClientMachine*(para1: PDisplay, para2: TWindow, para3: PXTextProperty): TStatus{.
  208. cdecl, dynlib: libX11, importc.}
  209. proc XGetWMHints*(para1: PDisplay, para2: TWindow): PXWMHints{.cdecl,
  210. dynlib: libX11, importc.}
  211. proc XGetWMIconName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty): TStatus{.
  212. cdecl, dynlib: libX11, importc.}
  213. proc XGetWMName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty): TStatus{.
  214. cdecl, dynlib: libX11, importc.}
  215. proc XGetWMNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints,
  216. para4: ptr int): TStatus{.cdecl, dynlib: libX11, importc.}
  217. proc XGetWMSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints,
  218. para4: ptr int, para5: TAtom): TStatus{.cdecl,
  219. dynlib: libX11, importc.}
  220. proc XGetZoomHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): TStatus{.
  221. cdecl, dynlib: libX11, importc.}
  222. proc XIntersectRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.
  223. cdecl, dynlib: libX11, importc.}
  224. proc XConvertCase*(para1: TKeySym, para2: PKeySym, para3: PKeySym){.cdecl,
  225. dynlib: libX11, importc.}
  226. proc XLookupString*(para1: PXKeyEvent, para2: cstring, para3: cint,
  227. para4: PKeySym, para5: PXComposeStatus): cint{.cdecl,
  228. dynlib: libX11, importc.}
  229. proc XMatchVisualInfo*(para1: PDisplay, para2: cint, para3: cint, para4: cint,
  230. para5: PXVisualInfo): TStatus{.cdecl, dynlib: libX11,
  231. importc.}
  232. proc XOffsetRegion*(para1: TRegion, para2: cint, para3: cint): cint{.cdecl,
  233. dynlib: libX11, importc.}
  234. proc XPointInRegion*(para1: TRegion, para2: cint, para3: cint): TBool{.cdecl,
  235. dynlib: libX11, importc.}
  236. proc XPolygonRegion*(para1: PXPoint, para2: cint, para3: cint): TRegion{.cdecl,
  237. dynlib: libX11, importc.}
  238. proc XRectInRegion*(para1: TRegion, para2: cint, para3: cint, para4: cuint,
  239. para5: cuint): cint{.cdecl, dynlib: libX11, importc.}
  240. proc XSaveContext*(para1: PDisplay, para2: TXID, para3: TXContext,
  241. para4: cstring): cint{.cdecl, dynlib: libX11, importc.}
  242. proc XSetClassHint*(para1: PDisplay, para2: TWindow, para3: PXClassHint): cint{.
  243. cdecl, dynlib: libX11, importc.}
  244. proc XSetIconSizes*(para1: PDisplay, para2: TWindow, para3: PXIconSize,
  245. para4: cint): cint{.cdecl, dynlib: libX11, importc.}
  246. proc XSetNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): cint{.
  247. cdecl, dynlib: libX11, importc.}
  248. proc XSetRGBColormaps*(para1: PDisplay, para2: TWindow,
  249. para3: PXStandardColormap, para4: cint, para5: TAtom){.
  250. cdecl, dynlib: libX11, importc.}
  251. proc XSetSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints,
  252. para4: TAtom): cint{.cdecl, dynlib: libX11, importc.}
  253. proc XSetStandardProperties*(para1: PDisplay, para2: TWindow, para3: cstring,
  254. para4: cstring, para5: TPixmap, para6: PPchar,
  255. para7: cint, para8: PXSizeHints): cint{.cdecl,
  256. dynlib: libX11, importc.}
  257. proc XSetTextProperty*(para1: PDisplay, para2: TWindow, para3: PXTextProperty,
  258. para4: TAtom){.cdecl, dynlib: libX11, importc.}
  259. proc XSetWMClientMachine*(para1: PDisplay, para2: TWindow, para3: PXTextProperty){.
  260. cdecl, dynlib: libX11, importc.}
  261. proc XSetWMHints*(para1: PDisplay, para2: TWindow, para3: PXWMHints): cint{.
  262. cdecl, dynlib: libX11, importc.}
  263. proc XSetWMIconName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty){.
  264. cdecl, dynlib: libX11, importc.}
  265. proc XSetWMName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty){.cdecl,
  266. dynlib: libX11, importc.}
  267. proc XSetWMNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints){.
  268. cdecl, dynlib: libX11, importc.}
  269. proc XSetWMProperties*(para1: PDisplay, para2: TWindow, para3: PXTextProperty,
  270. para4: PXTextProperty, para5: PPchar, para6: cint,
  271. para7: PXSizeHints, para8: PXWMHints, para9: PXClassHint){.
  272. cdecl, dynlib: libX11, importc.}
  273. proc XmbSetWMProperties*(para1: PDisplay, para2: TWindow, para3: cstring,
  274. para4: cstring, para5: PPchar, para6: cint,
  275. para7: PXSizeHints, para8: PXWMHints,
  276. para9: PXClassHint){.cdecl, dynlib: libX11, importc.}
  277. proc Xutf8SetWMProperties*(para1: PDisplay, para2: TWindow, para3: cstring,
  278. para4: cstring, para5: PPchar, para6: cint,
  279. para7: PXSizeHints, para8: PXWMHints,
  280. para9: PXClassHint){.cdecl, dynlib: libX11, importc.}
  281. proc XSetWMSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints,
  282. para4: TAtom){.cdecl, dynlib: libX11, importc.}
  283. proc XSetRegion*(para1: PDisplay, para2: TGC, para3: TRegion): cint{.cdecl,
  284. dynlib: libX11, importc.}
  285. proc XSetStandardColormap*(para1: PDisplay, para2: TWindow,
  286. para3: PXStandardColormap, para4: TAtom){.cdecl,
  287. dynlib: libX11, importc.}
  288. proc XSetZoomHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): cint{.
  289. cdecl, dynlib: libX11, importc.}
  290. proc XShrinkRegion*(para1: TRegion, para2: cint, para3: cint): cint{.cdecl,
  291. dynlib: libX11, importc.}
  292. proc XStringListToTextProperty*(para1: PPchar, para2: cint,
  293. para3: PXTextProperty): TStatus{.cdecl,
  294. dynlib: libX11, importc.}
  295. proc XSubtractRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.
  296. cdecl, dynlib: libX11, importc.}
  297. proc XmbTextListToTextProperty*(para1: PDisplay, para2: PPchar, para3: cint,
  298. para4: TXICCEncodingStyle, para5: PXTextProperty): cint{.
  299. cdecl, dynlib: libX11, importc.}
  300. proc XwcTextListToTextProperty*(para1: PDisplay, para2: ptr ptr int16, para3: cint,
  301. para4: TXICCEncodingStyle, para5: PXTextProperty): cint{.
  302. cdecl, dynlib: libX11, importc.}
  303. proc Xutf8TextListToTextProperty*(para1: PDisplay, para2: PPchar, para3: cint,
  304. para4: TXICCEncodingStyle,
  305. para5: PXTextProperty): cint{.cdecl,
  306. dynlib: libX11, importc.}
  307. proc XwcFreeStringList*(para1: ptr ptr int16){.cdecl, dynlib: libX11, importc.}
  308. proc XTextPropertyToStringList*(para1: PXTextProperty, para2: PPPchar,
  309. para3: Pcint): TStatus{.cdecl, dynlib: libX11,
  310. importc.}
  311. proc XmbTextPropertyToTextList*(para1: PDisplay, para2: PXTextProperty,
  312. para3: PPPchar, para4: Pcint): cint{.cdecl,
  313. dynlib: libX11, importc.}
  314. proc XwcTextPropertyToTextList*(para1: PDisplay, para2: PXTextProperty,
  315. para3: ptr ptr ptr int16, para4: Pcint): cint{.cdecl,
  316. dynlib: libX11, importc.}
  317. proc Xutf8TextPropertyToTextList*(para1: PDisplay, para2: PXTextProperty,
  318. para3: PPPchar, para4: Pcint): cint{.cdecl,
  319. dynlib: libX11, importc.}
  320. proc XUnionRectWithRegion*(para1: PXRectangle, para2: TRegion, para3: TRegion): cint{.
  321. cdecl, dynlib: libX11, importc.}
  322. proc XUnionRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.cdecl,
  323. dynlib: libX11, importc.}
  324. proc XWMGeometry*(para1: PDisplay, para2: cint, para3: cstring, para4: cstring,
  325. para5: cuint, para6: PXSizeHints, para7: Pcint, para8: Pcint,
  326. para9: Pcint, para10: Pcint, para11: Pcint): cint{.cdecl,
  327. dynlib: libX11, importc.}
  328. proc XXorRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.cdecl,
  329. dynlib: libX11, importc.}
  330. #when defined(MACROS):
  331. proc XDestroyImage*(ximage: PXImage): cint
  332. proc XGetPixel*(ximage: PXImage, x, y: cint): culong
  333. proc XPutPixel*(ximage: PXImage, x, y: cint, pixel: culong): cint
  334. proc XSubImage*(ximage: PXImage, x, y: cint, width, height: cuint): PXImage
  335. proc XAddPixel*(ximage: PXImage, value: clong): cint
  336. proc IsKeypadKey*(keysym: TKeySym): bool
  337. proc IsPrivateKeypadKey*(keysym: TKeySym): bool
  338. proc IsCursorKey*(keysym: TKeySym): bool
  339. proc IsPFKey*(keysym: TKeySym): bool
  340. proc IsFunctionKey*(keysym: TKeySym): bool
  341. proc IsMiscFunctionKey*(keysym: TKeySym): bool
  342. proc IsModifierKey*(keysym: TKeySym): bool
  343. #function XUniqueContext : TXContext;
  344. #function XStringToContext(_string : Pchar) : TXContext;
  345. # implementation
  346. #when defined(MACROS):
  347. proc XDestroyImage(ximage: PXImage): cint =
  348. ximage.f.destroy_image(ximage)
  349. proc XGetPixel(ximage: PXImage, x, y: cint): culong =
  350. ximage.f.get_pixel(ximage, x, y)
  351. proc XPutPixel(ximage: PXImage, x, y: cint, pixel: culong): cint =
  352. ximage.f.put_pixel(ximage, x, y, pixel)
  353. proc XSubImage(ximage: PXImage, x, y: cint, width, height: cuint): PXImage =
  354. ximage.f.sub_image(ximage, x, y, width, height)
  355. proc XAddPixel(ximage: PXImage, value: clong): cint =
  356. ximage.f.add_pixel(ximage, value)
  357. proc IsKeypadKey(keysym: TKeySym): bool =
  358. (keysym >= XK_KP_Space) and (keysym <= XK_KP_Equal)
  359. proc IsPrivateKeypadKey(keysym: TKeySym): bool =
  360. (keysym >= 0x11000000.TKeySym) and (keysym <= 0x1100FFFF.TKeySym)
  361. proc IsCursorKey(keysym: TKeySym): bool =
  362. (keysym >= XK_Home) and (keysym < XK_Select)
  363. proc IsPFKey(keysym: TKeySym): bool =
  364. (keysym >= XK_KP_F1) and (keysym <= XK_KP_F4)
  365. proc IsFunctionKey(keysym: TKeySym): bool =
  366. (keysym >= XK_F1) and (keysym <= XK_F35)
  367. proc IsMiscFunctionKey(keysym: TKeySym): bool =
  368. (keysym >= XK_Select) and (keysym <= XK_Break)
  369. proc IsModifierKey(keysym: TKeySym): bool =
  370. ((keysym >= XK_Shift_L) and (keysym <= XK_Hyper_R)) or
  371. (keysym == XK_Mode_switch) or (keysym == XK_Num_Lock)