Class: RNDK::Fscale

Inherits:
Scale show all
Defined in:
lib/rndk/fscale.rb

Instance Attribute Summary

Attributes inherited from Widget

#BXAttr, #HZChar, #LLChar, #LRChar, #ULChar, #URChar, #VTChar, #accepts_focus, #binding_list, #border_size, #box, #exit_type, #has_focus, #is_visible, #screen, #screen_index, #supported_signals, #widget_type

Instance Method Summary collapse

Methods inherited from Scale

#activate, #decrement, #destroy, #draw, #draw_field, #erase, #focus, #getHighValue, #getLowValue, #getValue, #increment, #inject, #limitCurrentValue, #move, #moveToEditPosition, #performEdit, #position, removeChar, #set, #setEditPosition, #setLowHigh, #setValue, #set_bg_color, #unfocus, #validEditPosition

Methods inherited from Widget

#Screen_XPOS, #Screen_YPOS, #after_processing, #before_processing, #bind_key, #bind_signal, #bindable_widget, #clean_bindings, #clean_title, #destroy, #draw, #draw_title, #erase, #focus, #get_box, #getch, #inject, #is_bound?, #move, #position, #refresh_data, #run_key_binding, #run_signal_binding, #save_data, #setBXattr, #setHZchar, #setLLchar, #setLRchar, #setULchar, #setURchar, #setVTchar, #set_bg_color, #set_box, #set_exit_type, #set_title, #unbind_key, #unfocus, #valid?, #valid_type?

Constructor Details

#initialize(screen, config = {}) ⇒ Fscale

Returns a new instance of Fscale.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rndk/fscale.rb', line 5

def initialize(screen, config={})
  @widget_type = :Fscale

  x           = 0
  y           = 0
  title       = "fscale"
  label       = "label"
  field_attr  = RNDK::Color[:normal]
  field_width = 0
  start       = 0
  low         = 0
  high        = 100
  inc         = 1
  fast_inc    = 5
  digits      = 3
  box         = true
  shadow      = false

  config.each do |key, val|
    x           = val if key == :x
    y           = val if key == :y
    title       = val if key == :title
    label       = val if key == :label
    field_attr  = val if key == :field_attr
    field_width = val if key == :field_width
    start       = val if key == :start
    low         = val if key == :low
    high        = val if key == :high
    inc         = val if key == :inc
    fast_inc    = val if key == :fast_inc
    digits      = val if key == :digits
    box         = val if key == :box
    shadow      = val if key == :shadow
  end

  @digits = digits
  super(screen, x, y, title, label, field_attr, field_width, start, low, high, inc, fast_inc, box, shadow)
end

Instance Method Details

#drawFieldObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rndk/fscale.rb', line 44

def drawField
  Ncurses.werase @field_win

  # Draw the value in the field.
  digits = [@digits, 30].min
  format = '%%.%if' % [digits]
  temp = format % [@current]

  Draw.writeCharAttrib(@field_win,
                       @field_width - temp.size - 1,
                       0,
                       temp,
                       @field_attr,
                       RNDK::HORIZONTAL,
                       0,
                       temp.size)

  self.moveToEditPosition(@field_edit)
  Ncurses.wrefresh(@field_win)
end

#getDigitsObject



69
70
71
# File 'lib/rndk/fscale.rb', line 69

def getDigits
  return @digits
end

#SCAN_FMTObject



73
74
75
# File 'lib/rndk/fscale.rb', line 73

def SCAN_FMT
  '%g%c'
end

#setDigits(digits) ⇒ Object



65
66
67
# File 'lib/rndk/fscale.rb', line 65

def setDigits(digits)
  @digits = [0, digits].max
end