home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / easygui_os12 / source / easyplugins / bar_os12.e next >
Encoding:
Text File  |  2000-06-11  |  2.6 KB  |  144 lines

  1.  
  2. /*
  3.  
  4.     $VER: bar_plugin 1.0 (25.5.98)
  5.  
  6.     Author:         Ali Graham
  7.                     <agraham@hal9000.net.au>
  8.  
  9.     Desc.:          Replacement for BAR with percentile width.
  10.  
  11. */
  12.  
  13. OPT MODULE
  14. OPT PREPROCESS
  15.  
  16. -> RST: Added conditional EASY_OS12 support
  17. #define EASY_OS12
  18.  
  19. #ifdef EASY_OS12
  20.   MODULE 'tools/easygui_os12','hybrid/tagdata'
  21.   #define GetTagData getTagData
  22. #endif
  23. #ifndef EASY_OS12
  24.   OPT OSVERSION=37
  25.   MODULE 'tools/easygui','utility'
  26. #endif
  27.  
  28. MODULE 'intuition/intuition', 'utility/tagitem'
  29.  
  30. EXPORT OBJECT bar_plugin OF plugin PRIVATE
  31.  
  32.     percent
  33.     vertical
  34.  
  35. ENDOBJECT
  36.  
  37. -> PROGRAMMER_ID | MODULE_ID
  38. ->      $01      |   $08
  39.  
  40.  
  41. EXPORT ENUM PLA_Bar_Percent=$81080001,     ->[IS.]
  42.             PLA_Bar_Vertical               ->[I..]
  43.  
  44. PROC bar(tags=NIL:PTR TO tagitem) OF bar_plugin
  45.  
  46. #ifndef EASY_OS12
  47.     IF utilitybase
  48. #endif
  49.  
  50.         self.percent  := GetTagData(PLA_Bar_Percent, 100, tags)
  51.         IF self.percent<0 THEN self.percent:=0; IF self.percent>100 THEN self.percent:=100
  52.  
  53.         self.vertical:= GetTagData(PLA_Bar_Vertical, FALSE, tags)
  54.  
  55. #ifndef EASY_OS12
  56.     ELSE
  57.  
  58.         Raise("util")
  59.  
  60.     ENDIF
  61. #endif
  62.  
  63. ENDPROC
  64.  
  65. PROC set(attr, value) OF bar_plugin
  66.  
  67.     SELECT attr
  68.  
  69.         CASE PLA_Bar_Percent
  70.  
  71.             IF self.percent<>value
  72.  
  73.                 self.percent:=value
  74.  
  75.                 self.draw()
  76.  
  77.             ENDIF
  78.  
  79.     ENDSELECT
  80.  
  81. ENDPROC
  82.  
  83. PROC draw(win=NIL:PTR TO window) OF bar_plugin
  84.  
  85.     DEF width, height, gap
  86.  
  87.     IF (win=NIL) THEN win:=self.gh.wnd
  88.  
  89.     SetStdRast(win.rport)
  90.  
  91.     Box(self.x, self.y, self.x + self.xs -1, self.y + self.ys -1, 0)
  92.  
  93.     IF self.percent>0
  94.  
  95.         IF self.vertical
  96.  
  97.             height:=((self.ys * self.percent) / 100)
  98.             gap:=(self.ys - height)/2
  99.  
  100.             Line((self.x + 1), (self.y + gap), (self.x + 1), ((self.y + self.ys - 1) - gap), 1)
  101.             Line((self.x + 2), (self.y + gap), (self.x + 2), ((self.y + self.ys - 1) - gap), 2)
  102.  
  103.         ELSE
  104.  
  105.             width:=((self.xs * self.percent) / 100)
  106.             gap:=(self.xs - width)/2
  107.  
  108.             Line((self.x + gap), (self.y + 1), ((self.x + self.xs - 1) - gap), (self.y + 1), 1)
  109.             Line((self.x + gap), (self.y + 2), ((self.x + self.xs - 1) - gap), (self.y + 2), 2)
  110.  
  111.         ENDIF
  112.  
  113.     ENDIF
  114.  
  115. ENDPROC
  116.  
  117. PROC min_size(ta,fh) OF bar_plugin
  118.  
  119.     DEF ret_x, ret_y
  120.  
  121.     IF self.vertical
  122.  
  123.         ret_x:=4
  124.         ret_y:=8
  125.  
  126.     ELSE
  127.  
  128.         ret_x:=8
  129.         ret_y:=4
  130.  
  131.     ENDIF
  132.  
  133. ENDPROC ret_x, ret_y
  134.  
  135. PROC will_resize() OF bar_plugin IS (IF self.vertical THEN RESIZEY ELSE RESIZEX)
  136.  
  137. PROC render(ta, x, y, xs, ys, win:PTR TO window) OF bar_plugin
  138.  
  139.     self.draw(win)
  140.  
  141. ENDPROC
  142.  
  143.  
  144.