Class: MinimalFrame

Inherits:
Wx::Frame
  • Object
show all
Defined in:
lib/MINT-debugger/debugger2.rb

Overview

A Wx::Frame is a self-contained, top-level Window that can contain controls, menubars, and statusbars

Instance Method Summary collapse

Constructor Details

#initialize(title) ⇒ MinimalFrame

Returns a new instance of MinimalFrame.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/MINT-debugger/debugger2.rb', line 103

def initialize(title)
  # The main application frame has no parent (nil)
  super(nil, :title => title, :size => [ 800, 600 ])

  @logo_icon = Wx::Image.new(File.dirname(__FILE__)+"/MINT-Logo-short-bg.png") # load the image from the file
  @logo_image  = Wx::Bitmap.new(@logo_icon)
 
  
 @licence = File.read(File.dirname(__FILE__)+"/licence-code.txt") 
  
  splash = Wx::SplashScreen.new(@logo_image,
                                Wx::SPLASH_CENTRE_ON_SCREEN|Wx::SPLASH_TIMEOUT,
                                3000, nil, -1)
     
  @model_panels=[]
  
  menu_bar = Wx::MenuBar.new
  # The "file" menu
  menu_file = Wx::Menu.new
  # Using Wx::ID_EXIT standard id means the menu item will be given
  # the right label for the platform and language, and placed in the
  # correct platform-specific menu - eg on OS X, in the Application's menu
  menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
  menu_file.append(ID_REFRESH, "&Refresh\tAlt-R", "Refresh models")
  
  menu_bar.append(menu_file, "&File")
  
  # The Model menu
 # menu_model= Wx::Menu.new
  #menu_model.append(ID_DELETE_ENTRY, "&Delete Entry\tAlt-D", "Deletes Selected Entries")
  #menu_bar.append(menu_model, "&Model")
  
  # The "help" menu
  menu_help = Wx::Menu.new
  menu_help.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
  menu_bar.append(menu_help, "&Help")

  # Assign the menubar to this frame
  self.menu_bar = menu_bar

  # Create a status bar at the bottom of the frame
  @status_bar = create_status_bar(2)
  self.status_text = "Happy debugging!"

  # Set it up to handle menu events using the relevant methods. 
  evt_menu Wx::ID_EXIT, :on_quit
  evt_menu Wx::ID_ABOUT, :on_about
  evt_menu(ID_REFRESH) { |event| refreshAllModels(event,self)}
  evt_menu(ID_DELETE_ENTRY) { |event| deleteEntry(event)}
  
 @m_notebook = Wx::Notebook.new(self, -1,Wx::DEFAULT_POSITION,
                           Wx::DEFAULT_SIZE)
 
  # Task Model
  panel = create_list_panel(@m_notebook, MINT::Task.new, ["name","states","abstract_states","new_states","description"])
  @m_notebook.add_page(panel,"Task-Model",TRUE)    
  
  # AUI Model
  panel = create_list_panel(@m_notebook, MINT::AIO.new, ["name","class","states","abstract_states","new_states","label","description"])
  @m_notebook.add_page(panel,"AUI-Model",TRUE)    

  # PTS Model
  panel = create_list_panel(@m_notebook, MINT::PTS.new, ["name","states","abstract_states","new_states"])
  @m_notebook.add_page(panel,"PTS",TRUE)

  # Domain
  #panel = create_list_panel(@m_notebook, Domain.new, ["task","description","options"])
  #@m_notebook.add_page(panel,"Domain-Model",TRUE)    
  
  # CUI
  #     panel = create_list_panel(@m_notebook, MINT::Box.new, ["name","state","x","y","width","height","layer"])
  #    @m_notebook.add_page(panel,"CUI-Model-Box",TRUE)    
     
  #  CUI Layout-Calc
   panel = create_list_panel(@m_notebook, MINT::CIO.new, ["name","class","states","abstract_states","new_states","width","height","x","y","layer","row","col"])
                                                          #"text","minwidth","minheight","optspace","minspace",
  @m_notebook.add_page(panel,"CUI-gfx",TRUE)    
  
  # Mouse
   panel = create_list_panel(@m_notebook, MINT::Pointer3D.new, ["name","states","abstract_states","new_states","x","y","z"])
  @m_notebook.add_page(panel,"MouseHTML",TRUE)    
  
  # IR
   panel = create_list_panel(@m_notebook, MINT::OneHand.new, ["class","name","states","abstract_states","new_states","amount"])
  @m_notebook.add_page(panel,"Gesture",TRUE)    
  # IR
   panel = create_list_panel(@m_notebook, MINT::Element.new, ["class","name","states","abstract_states","new_states"])
  @m_notebook.add_page(panel,"Element",TRUE)    
end

Instance Method Details

#create_list_panel(notebook, modelname, col_labels) ⇒ Object



207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/MINT-debugger/debugger2.rb', line 207

def  create_list_panel(notebook, modelname, col_labels)
  panel = NBPanel.new(notebook)

  list = DataModel.new(col_labels,modelname,panel)
  @model_panels << list
  panel.win = list


  box = Wx::BoxSizer.new(Wx::HORIZONTAL)
  box.add(panel, 1, Wx::EXPAND)
  panel
end

#deleteEntry(event) ⇒ Object



201
202
203
204
205
# File 'lib/MINT-debugger/debugger2.rb', line 201

def deleteEntry(event)
  p "Delete Entry"
  selections = @m_notebook.get_current_page.win.get_selections
  @m_notebook.get_current_page.win.delete_data(selections)
end

#on_aboutObject

show an ‘About’ dialog - WxRuby’s about_box function will show a platform-native ‘About’ dialog, but you could also use an ordinary Wx::MessageDialog here.



228
229
230
231
232
233
234
235
236
237
# File 'lib/MINT-debugger/debugger2.rb', line 228

def on_about
  Wx::about_box(:name => self.title,
                 :version     => "1.0",
                 :description => "This is the initial version of the MINT Debugger",
                 :developers  => ['Dr.-Ing. Sebastian Feuerstack'] ,
                :copyright => "(C) Sebastian Feuerstack 2010",
                :web_site => "http://www.multi-access.de",
                :licence => @licence,
                :icon => Wx::Icon.from_bitmap(@logo_image))
end

#on_quitObject

End the application; it should finish automatically when the last window is closed.



221
222
223
# File 'lib/MINT-debugger/debugger2.rb', line 221

def on_quit
  close()
end

#refreshAllModels(event, frame) ⇒ Object



193
194
195
196
197
198
199
# File 'lib/MINT-debugger/debugger2.rb', line 193

def refreshAllModels(event,frame)
  p "Refresh all"
  @model_panels.each { |p|
    p.refresh_data
  }
  @status_bar.push_status_text "Refreshed at #{Time.now}"
end