home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Programming / Python2 / Python20_source / Amiga_Misc / unused / intuitionlib.py < prev    next >
Encoding:
Python Source  |  1996-06-13  |  3.6 KB  |  159 lines

  1. #
  2. # AMIGA LIBRARY INTERFACE FOR intuition.library
  3. #
  4. # Generated from FD file FD:intuition_lib.fd by ConvertFD.py
  5. #
  6.  
  7. # LVO definitions:
  8.  
  9. LVO = {
  10. 'ActivateWindow':(-450, 256),
  11. 'ChangeWindowBox':(-486, 271),
  12. 'CloseScreen':(-66, 256),
  13. 'CloseWindow':(-72, 256),
  14. 'CurrentTime':(-84, 768),
  15. 'DisplayBeep':(-96, 256),
  16. 'DrawBorder':(-108, 771),
  17. 'EasyRequestArgs':(-588, 3840),
  18. 'OpenScreen':(-198, 256),
  19. 'OpenScreenTagList':(-612, 768),
  20. 'OpenWindow':(-204, 256),
  21. 'OpenWindowTagList':(-606, 768),
  22. 'PrintIText':(-216, 771),
  23. 'SetWindowTitles':(-276, 1792),
  24. }
  25.  
  26.  
  27. import amigalibs
  28. libname="intuition.library"
  29.  
  30. lib = amigalibs.openlib(libname,37)
  31.  
  32. # General libcall interface:
  33.  
  34. def call(func,args):
  35.         try:
  36.                 return lib.call(LVO[func],args)
  37.         except KeyError:
  38.                 raise NameError,func+" not found in "+libname
  39.  
  40.  
  41. # exception:
  42.  
  43. IntuitionError = "IntuitionError"
  44.  
  45.  
  46. ################ USER CODE FOLLOWS
  47.  
  48. import struct
  49.  
  50. strptr = amigalibs.strptr
  51. intptr = amigalibs.intptr
  52. obj2reg = amigalibs.obj2reg
  53.  
  54.  
  55. #
  56. # implemented functions:
  57. #
  58. # EasyRequest
  59. # CurrentTime
  60. #
  61. # implemented classes:
  62. #
  63. # Window
  64. #
  65.  
  66.  
  67. def EasyRequest(body,buttons="Ok|Cancel",title="Requester"):
  68.     req = struct.pack("lllll",20,0,strptr(title),strptr(body),strptr(buttons))
  69.     return call('EasyRequestArgs',{8:0,9:strptr(req),10:0,11:0})
  70.  
  71. def CurrentTime():
  72.     secs=0
  73.     micros=1
  74.     call('CurrentTime',{8:intptr(secs),9:intptr(micros)})
  75.     return (secs,micros)
  76.  
  77. TAG_DONE = TAG_END = 0
  78. TAG_IGNORE = 1
  79. TAG_USER = 0x80000000
  80.  
  81. WA_Dummy        = TAG_USER+99
  82. WA_Left            = WA_Dummy + 0x01
  83. WA_Top            = WA_Dummy + 0x02
  84. WA_Width        = WA_Dummy + 0x03
  85. WA_Height        = WA_Dummy + 0x04
  86. WA_IDCMP        = WA_Dummy + 0x07
  87. WA_Flags        = WA_Dummy + 0x08
  88. WA_Gadgets        = WA_Dummy + 0x09
  89. WA_Title        = WA_Dummy + 0x0B
  90. WA_ScreenTitle    = WA_Dummy + 0x0C
  91. WA_CustomScreen    = WA_Dummy + 0x0D
  92. WA_MinWidth        = WA_Dummy + 0x0F
  93. WA_MinHeight    = WA_Dummy + 0x10
  94. WA_MaxWidth        = WA_Dummy + 0x11
  95. WA_MaxHeight    = WA_Dummy + 0x12
  96. WA_InnerWidth    = WA_Dummy + 0x13
  97. WA_InnerHeight    = WA_Dummy + 0x14
  98.     
  99. WFLG_SIZEGADGET        = 0x00000001
  100. WFLG_DRAGBAR        = 0x00000002
  101. WFLG_DEPTHGADGET    = 0x00000004
  102. WFLG_CLOSEGADGET    = 0x00000008
  103. WFLG_SIZEBRIGHT        = 0x00000010
  104. WFLG_SIZEBBOTTOM    = 0x00000020
  105. WFLG_SMART_REFRESH    = 0x00000000
  106. WFLG_SIMPLE_REFRESH    = 0x00000040
  107. WFLG_REPORTMOUSE    = 0x00000200
  108. WFLG_GIMMEZEROZERO    = 0x00000400
  109. WFLG_ACTIVATE        = 0x00001000
  110. WFLG_RMBTRAP        = 0x00010000
  111. WFLG_NEWLOOKMENUS    = 0x00200000
  112.  
  113. WFLG_DEFAULT = WFLG_SIZEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_CLOSEGADGET | WFLG_ACTIVATE | WFLG_NEWLOOKMENUS
  114.  
  115. IDCMP_SIZEVERIFY    = 0x00000001
  116. IDCMP_NEWSIZE        = 0x00000002
  117. IDCMP_REFRESHWINDOW    = 0x00000004
  118. IDCMP_MOUSEBUTTONS    = 0x00000008
  119. IDCMP_MOUSEMOVE        = 0x00000010
  120. IDCMP_GADGETDOWN    = 0x00000020
  121. IDCMP_GADGETUP        = 0x00000040
  122. IDCMP_MENUPICK        = 0x00000100
  123. IDCMP_CLOSEWINDOW    = 0x00000200
  124. IDCMP_RAWKEY        = 0x00000400
  125. IDCMP_MENUVERIFY    = 0x00002000
  126. IDCMP_DISKINSERTED    = 0x00008000
  127. IDCMP_DISKREMOVED    = 0x00010000
  128. IDCMP_ACTIVEWINDOW    = 0x00040000
  129. IDCMP_INACTIVEWINDOW= 0x00080000
  130. IDCMP_DELTAMOVE        = 0x00100000
  131. IDCMP_VANILLAKEY    = 0x00200000
  132. IDCMP_INTUITICKS    = 0x00400000
  133. IDCMP_CHANGEWINDOW    = 0x02000000
  134.  
  135. IDCMP_DEFAULT = 0
  136.  
  137. class Window:
  138.     # member data:
  139.     # win
  140.  
  141.     def __init__(self,x,y,w,h,title,flags=WFLG_DEFAULT,idcmp=IDCMP_DEFAULT):
  142.         wintags = struct.pack("2l2l2l2l2l2l2l2l2l2l2ll",
  143.             WA_Left,x,WA_Top,y,WA_Width,w,WA_Height,h,WA_Title,strptr(title),
  144.             WA_Flags,flags,WA_IDCMP,idcmp,WA_MinWidth,20,WA_MinHeight,20,
  145.             WA_MaxWidth,-1,WA_MaxHeight,-1,
  146.             TAG_DONE)
  147.         self.win=call('OpenWindowTagList',{8:0,9:strptr(wintags)})
  148.         if not self.win:
  149.             raise IntuitionError,"can't open window "+title
  150.     
  151.     def close(self):
  152.         if self.win:
  153.             call('CloseWindow',{8:self.win})
  154.             self.win=0
  155.             
  156.     def __del__(self):
  157.         self.close()
  158.  
  159.