home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / easygui_os12 / examples / easyplugins / simplegauge_os12_demo.e < prev    next >
Encoding:
Text File  |  2000-06-06  |  3.4 KB  |  125 lines

  1. /*
  2.  
  3.    SimpleGauge Demo
  4.  
  5.    (a little bit silly demo but I think it shows how it works)
  6.  
  7.    Copyright: Ralph Wermke of Digital Innovations
  8.    EMail    : wermke@gryps1.rz.uni-greifswald.de
  9.    WWW      : http://www.user.fh-stralsund.de/~rwermke/di.html
  10.  
  11. */
  12.  
  13. OPT PREPROCESS
  14.  
  15. -> RST: Added conditional EASY_OS12 support
  16. #define EASY_OS12
  17.  
  18. #ifdef EASY_OS12
  19.   MODULE 'tools/easygui_os12', 'easyplugins/simplegauge_os12'
  20. #endif
  21. #ifndef EASY_OS12
  22.   OPT OSVERSION=37
  23.   MODULE 'tools/easygui', 'easyplugins/simplegauge'
  24. #endif
  25.  
  26. MODULE 'tools/exceptions',
  27.        'utility/tagitem'
  28.  
  29. DEF gh
  30.  
  31. PROC main() HANDLE
  32. DEF mp:PTR TO simplegauge_plugin, mp2:PTR TO simplegauge_plugin
  33.  
  34.    -> create new instances
  35.    NEW mp.simplegauge([PLA_SimpleGauge_ShowText, TRUE,
  36.                        PLA_SimpleGauge_Max, 1500,
  37.                        PLA_SimpleGauge_Current, 500,
  38.                        TAG_DONE])
  39.  
  40.    NEW mp2.simplegauge([PLA_SimpleGauge_Horizontal, FALSE,
  41.                         PLA_SimpleGauge_ShowText, TRUE,
  42.                         PLA_SimpleGauge_Max, 1500,
  43.                         TAG_DONE])
  44.  
  45.    -> initial settings
  46.    mp.set(PLA_SimpleGauge_Max, 5000)
  47.    mp.set(PLA_SimpleGauge_Current, 2500)
  48.    mp2.set(PLA_SimpleGauge_BackgroundPen, 3)
  49.    mp2.set(PLA_SimpleGauge_BarPen, 0)
  50.  
  51.    -> open gui
  52.    easyguiA('SimpleGauge Test',
  53.             [ROWS,
  54.                [COLS,
  55.                   [BUTTON, {ignore}, '   '],
  56.                   [PLUGIN, {ignore}, mp]
  57.                ],
  58.                [BEVEL,
  59.                   [COLS,
  60.                      [PLUGIN, {ignore}, mp2],
  61.                      [ROWS,
  62.                         [SPACE],
  63.                         [EQCOLS,
  64.                            [SBUTTON, {setmax}, 'Max=500', [mp,mp2,500]],
  65.                            [SBUTTON, {setmax}, 'Max=1000', [mp,mp2,1000]],
  66.                            [SBUTTON, {setmax}, 'Max=1500', [mp,mp2,1500]],
  67.                            [SLIDE, {scroll}, NIL, FALSE, 0, 1500, 0, 2, '', [mp,mp2]]
  68.                         ],
  69.                         [SBUTTON, {dis}, 'Toggle', [mp,mp2]]
  70.                      ]
  71.                   ]
  72.                ]
  73.             ],
  74.             [EG_GHVAR,{gh}, TAG_DONE])
  75. EXCEPT
  76.    END mp
  77.    report_exception()
  78. ENDPROC
  79.  
  80. PROC ignore(info, mp:PTR TO simplegauge_plugin) IS EMPTY
  81.  
  82. -> set a new maximum
  83. PROC setmax(l:PTR TO LONG, info)
  84. DEF mp:PTR TO simplegauge_plugin, mp2:PTR TO simplegauge_plugin
  85.  
  86.    mp:=l[0]; mp2:=l[1]
  87.    mp.set(PLA_SimpleGauge_Max, l[2])
  88.    mp2.set(PLA_SimpleGauge_Max, l[2])
  89.  
  90. ENDPROC
  91.  
  92. -> set and display scroller value
  93. PROC scroll(l:PTR TO LONG, info, x)
  94. DEF mp:PTR TO simplegauge_plugin, mp2:PTR TO simplegauge_plugin
  95.  
  96.    mp:=l[0]; mp2:=l[1]
  97.  
  98.    ->IF (x>(mp.get(PLA_SimpleGauge_Max)*0.9))
  99.    IF (x>Div(Mul(mp.get(PLA_SimpleGauge_Max),90),100))
  100.       mp.set(PLA_SimpleGauge_BarPen, 1)
  101.    ELSE
  102.       mp.set(PLA_SimpleGauge_BarPen, 3)
  103.    ENDIF
  104.  
  105.    mp.set(PLA_SimpleGauge_Current, x)
  106.    mp2.set(PLA_SimpleGauge_Current, x)
  107.  
  108.    WriteF('Max=\d Current=\d Percent=\d\n', mp.get(PLA_SimpleGauge_Max),
  109.                                             mp.get(PLA_SimpleGauge_Current),
  110.                                             mp.get(PLA_SimpleGauge_Percent),
  111.          )
  112.  
  113. ENDPROC
  114.  
  115. -> disables the gauges
  116. PROC dis(l:PTR TO LONG, info)
  117. DEF mp:PTR TO simplegauge_plugin, mp2:PTR TO simplegauge_plugin
  118.  
  119.    mp:=l[0]; mp2:=l[1]
  120.    mp.set(PLA_SimpleGauge_Disabled, Not(mp.get(PLA_SimpleGauge_Disabled)))
  121.    mp2.set(PLA_SimpleGauge_Disabled, Not(mp2.get(PLA_SimpleGauge_Disabled)))
  122.  
  123. ENDPROC
  124.  
  125.