Class: PFM::Choice_Helper

Inherits:
Object show all
Defined in:
docs/4_Systems_000_General_1_PFM.rb

Overview

Class that help to make choice inside Interfaces

Instance Method Summary collapse

Constructor Details

#initialize(klass, can_cancel = true, cancel_index = nil) ⇒ Choice_Helper

Create a new Choice_Helper

Parameters:

  • klass (Class) —

    class used to display the choice

  • can_cancel (Boolean) (defaults to: true) —

    if the user can cancel the choice

  • cancel_index (Integer, nil) (defaults to: nil) —

    Index returned if the user cancel



203
204
# File 'docs/4_Systems_000_General_1_PFM.rb', line 203

def initialize(klass, can_cancel = true, cancel_index = nil)
end

Instance Method Details

#cancel

Cancel the choice from outside



210
211
# File 'docs/4_Systems_000_General_1_PFM.rb', line 210

def cancel
end

#display_choice(viewport, x, y, width, *args, on_update: nil, align_right: false) ⇒ Integer

Display the choice

Parameters:

  • viewport (Viewport) —

    viewport in wich the choice is shown

  • x (Integer) —

    x coordinate of the choice window

  • y (Integer) —

    y coordinate of the choice window

  • width (Integer) —

    width of the choice window

  • on_update (#call, nil) (defaults to: nil) —

    handle to call during choice update

  • align_right (Boolean) (defaults to: false) —

    tell if the x/y coordinate are the top right coordinate of the choice

  • args (Array) —

    argument to send to the on_update handle

Returns:

  • (Integer) —

    the choice made by the user



230
231
# File 'docs/4_Systems_000_General_1_PFM.rb', line 230

def display_choice(viewport, x, y, width, *args, on_update: nil, align_right: false)
end

#register_choice(text, *args, disable_detect: nil, on_validate: nil, color: nil) ⇒ self

Register a choice

Parameters:

  • text (String)
  • disable_detect (#call, nil) (defaults to: nil) —

    handle to call to detect if the choice is disabled or not

  • on_validate (#call, nil) (defaults to: nil) —

    handle to call when the choice validated on this choice

  • color (Integer, nil) (defaults to: nil) —

    non default color to use on this choice

  • args (Array) —

    arguments to send to the disable_detect and on_validate handler

Returns:

  • (self)


219
220
# File 'docs/4_Systems_000_General_1_PFM.rb', line 219

def register_choice(text, *args, disable_detect: nil, on_validate: nil, color: nil)
end

#size ⇒ Integer

Return the number of choices (for calculation)

Returns:

  • (Integer)


207
208
# File 'docs/4_Systems_000_General_1_PFM.rb', line 207

def size
end