Class: Cosmos::RealtimeButtonBar

Inherits:
Qt::Widget show all
Defined in:
lib/cosmos/gui/widgets/realtime_button_bar.rb

Overview

RealtimeButtonBar class

This class implements the RealtimeButtonBar

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, orientation = Qt::Horizontal) ⇒ RealtimeButtonBar

Constructor



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/cosmos/gui/widgets/realtime_button_bar.rb', line 36

def initialize (parent, orientation = Qt::Horizontal)
  super(parent)
  if orientation == Qt::Horizontal
    # Horizontal Frame for overall widget
    @overall_frame = Qt::HBoxLayout.new(self)
    @state = Qt::LineEdit.new
  else
    # Vertical Frame for overall widget
    @overall_frame = Qt::VBoxLayout.new(self)
    @state = Qt::LineEdit.new
  end
  @overall_frame.setContentsMargins(0,0,0,0)
  @state.setAlignment(Qt::AlignCenter)
  @state.setText('Connecting')
  @state.setReadOnly(true)
  @overall_frame.addWidget(@state)

  if orientation == Qt::Horizontal
    @overall_frame.addStretch
    # Buttons
    @stop_button  = Qt::PushButton.new('Stop')
    @pause_button = Qt::PushButton.new('Pause')
    @start_button = Qt::PushButton.new('Start')
    @overall_frame.addWidget(@start_button)
    @overall_frame.addWidget(@pause_button)
    @overall_frame.addWidget(@stop_button)
  else
    # Buttons
    @button_frame = Qt::HBoxLayout.new
    @start_button = Qt::PushButton.new('Start')
    @pause_button = Qt::PushButton.new('Pause')
    @stop_button  = Qt::PushButton.new('Stop')
    @button_frame.addWidget(@start_button)
    @button_frame.addWidget(@pause_button)
    @button_frame.addWidget(@stop_button)
    @overall_frame.addLayout(@button_frame)
  end

  setLayout(@overall_frame)

  # Connect handlers
  @stop_button.connect(SIGNAL('clicked()')) { @stop_callback.call if @stop_callback }
  @pause_button.connect(SIGNAL('clicked()'))  { @pause_callback.call if @pause_callback }
  @start_button.connect(SIGNAL('clicked()'))  { @start_callback.call if @start_callback }

  @start_callback = nil
  @pause_callback = nil
  @stop_callback  = nil
end

Instance Attribute Details

#pause_buttonObject (readonly)

Returns the value of attribute pause_button.



32
33
34
# File 'lib/cosmos/gui/widgets/realtime_button_bar.rb', line 32

def pause_button
  @pause_button
end

#pause_callbackObject

Returns the value of attribute pause_callback.



27
28
29
# File 'lib/cosmos/gui/widgets/realtime_button_bar.rb', line 27

def pause_callback
  @pause_callback
end

#start_buttonObject (readonly)

Readers for buttons



31
32
33
# File 'lib/cosmos/gui/widgets/realtime_button_bar.rb', line 31

def start_button
  @start_button
end

#start_callbackObject

Accessors for callbacks



26
27
28
# File 'lib/cosmos/gui/widgets/realtime_button_bar.rb', line 26

def start_callback
  @start_callback
end

#stop_buttonObject (readonly)

Returns the value of attribute stop_button.



33
34
35
# File 'lib/cosmos/gui/widgets/realtime_button_bar.rb', line 33

def stop_button
  @stop_button
end

#stop_callbackObject

Returns the value of attribute stop_callback.



28
29
30
# File 'lib/cosmos/gui/widgets/realtime_button_bar.rb', line 28

def stop_callback
  @stop_callback
end

Instance Method Details

#stateObject

Returns the text in the state field



87
88
89
# File 'lib/cosmos/gui/widgets/realtime_button_bar.rb', line 87

def state
  return @state.text
end

#state=(new_state) ⇒ Object

Sets the text in the state field



92
93
94
# File 'lib/cosmos/gui/widgets/realtime_button_bar.rb', line 92

def state= (new_state)
  @state.setText(new_state.to_s)
end