/lib/CProgressControl.ahk

http://github.com/Skiouros/Macro · AutoHotKey · 79 lines · 59 code · 1 blank · 19 comment · 20 complexity · 319078378a6c756667dc0c33d14ef878 MD5 · raw file

  1. /*
  2. Class: CProgressControl
  3. A Progress control.
  4. This control extends <CControl>. All basic properties and functions are implemented and documented in this class.
  5. */
  6. Class CProgressControl Extends CControl
  7. {
  8. __New(Name, Options, Text, GUINum)
  9. {
  10. Base.__New(Name, Options, Text, GUINum)
  11. this.Type := "Progress"
  12. this._.Insert("ControlStyles", {Vertical : 0x4, Smooth : 0x1, Marquee : 0x8})
  13. ;TODO: Range in options is not parsed but could potentially be set by the user
  14. this._.Insert("Min", 0)
  15. this._.Insert("Max", 100)
  16. }
  17. /*
  18. Variable: Value
  19. The Value of the progress indicator. Relative offsets are possible by adding a sign when assigning it, i.e. Progress.Value := "+10". Progress.Value += 10 is also possible but less efficient.
  20. Variable: Min
  21. The minimum value of the progress indicator.
  22. Variable: Max
  23. The maximum value of the progress indicator.
  24. */
  25. __Get(Name, Params*)
  26. {
  27. ;~ global CGUI
  28. if(Name != "GUINum" && !CGUI.GUIList[this.GUINum].IsDestroyed)
  29. {
  30. DetectHidden := A_DetectHiddenWindows
  31. DetectHiddenWindows, On
  32. if(Name = "Value")
  33. GuiControlGet, Value, % this.GUINum ":", % this.ClassNN
  34. else if(Name = "Min")
  35. Value := this._.Min
  36. else if(Name = "Max")
  37. Value := this._.Max
  38. Loop % Params.MaxIndex()
  39. if(IsObject(Value)) ;Fix unlucky multi parameter __GET
  40. Value := Value[Params[A_Index]]
  41. if(!DetectHidden)
  42. DetectHiddenWindows, Off
  43. if(Value != "")
  44. return Value
  45. }
  46. }
  47. __Set(Name, Value, Params*)
  48. {
  49. ;~ global CGUI
  50. if(!CGUI.GUIList[this.GUINum].IsDestroyed)
  51. {
  52. DetectHidden := A_DetectHiddenWindows
  53. DetectHiddenWindows, On
  54. Handled := true
  55. if(Name = "Value")
  56. GuiControl, % this.GUINum ":", % this.ClassNN, %Value%
  57. else if(Name = "Min")
  58. {
  59. GuiControl, % this.GUINum ":+Range" Value "-" this._.Max, % this.ClassNN
  60. this._.Min := Value
  61. }
  62. else if(Name = "Max")
  63. {
  64. GuiControl, % this.GUINum ":+Range" this._.Min "-" Value, % this.ClassNN
  65. this._.Max := Value
  66. }
  67. else
  68. Handled := false
  69. if(!DetectHidden)
  70. DetectHiddenWindows, Off
  71. if(Handled)
  72. return Value
  73. }
  74. }
  75. }