Class: WrapperContainer

Inherits:
TkFrame
  • Object
show all
Defined in:
ext/ae-rad/ae-rad-palette.rb

Instance Method Summary collapse

Constructor Details

#initialize(_owner) ⇒ WrapperContainer

Returns a new instance of WrapperContainer.



91
92
93
94
95
96
97
98
99
100
101
102
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
# File 'ext/ae-rad/ae-rad-palette.rb', line 91

def initialize(_owner)
  
  super(_owner.rad.float_frame(0, 'x'=>10, 'y'=>10, 'width'=>200,'heigh'=>220).hinner_frame, Arcadia.style('panel'))
  @owner = _owner
  _self = self
  frame = TkFrame.new(self, Arcadia.style('panel')).pack('side' =>'left', 'anchor'=>'n', :padx=>2, :pady=>2)

  @button_u = Tk::BWidget::Button.new(frame, Arcadia.style('toolbarbutton') ){
    image  Arcadia.image_res(CURSOR_GIF)
    helptext 'Select'
    text 'C'
    #foreground 'blue'
    command proc{_self.unfill}
    #relief 'groove'
    pack('side' =>'top', 'anchor'=>'n',:padx=>2, :pady=>2)
  }
  @button_m = Tk::BWidget::Button.new(frame, Arcadia.style('toolbarbutton')){
    _command = proc{
      require 'tk/clipboard'
      _code = AG.active.renderer.class_code.to_s if AG.active
      TkClipboard::set(_code)
      eval(_code)
      _self.fill(
      self,
      _owner.selected_wrapper.class,
      nil,
      _owner.selected_wrapper.getInstanceClass
      )
      _self.new_wrapper if _owner.selected_wrapper.class.is_top

    }
    image  Arcadia.image_res(WIDGET_COPY_GIF)
    helptext 'Copy current selected'
    text 'C'
    #foreground 'blue'
    command _command
    #relief 'groove'
    pack('side' =>'left','anchor'=>'n', :padx=>2, :pady=>2)
  }
  @familyts = Tk::BWidget::NoteBook.new(self, Arcadia.style('tabpanel')){
    tabbevelsize 0
    internalborderwidth 1
    #activeforeground 'orange'
    #font $arcadia['conf']['main.font']
    pack('side' =>'left','expand'=>'yes','fill'=>'both', :padx=>2, :pady=>2)
  }
  @objCollections = Array.new
end

Instance Method Details

#add_palette(_lib_obj) ⇒ Object



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'ext/ae-rad/ae-rad-palette.rb', line 200

def add_palette(_lib_obj)
  _name = _lib_obj.arcadia_lib_params.name
  _file = _lib_obj.arcadia_lib_params.require
  _img = nil
  @objCollections << {
    'name'=>_name,
    'collection'=>_lib_obj,
    'file'=>_file,
    'img'=>_img
  }

  @classes_panel = @familyts.insert('end',_name,
  'text'=>_name#,
  )
  
  _background = @classes_panel.cget('background')

@tpanel = TkText.new(@classes_panel){
  relief 'flat'
  background _background
}.pack('side' =>'left', 'anchor'=>'nw', :padx=>2, :pady=>2)


  _lib_obj.classes.each{|value|
    _self = self
    _image = self.class_image(value)
    ewin = TkTextWindow.new(@tpanel, 'end',
    'window'=> Tk::BWidget::Button.new(@tpanel, Arcadia.style('toolbarbutton')){
      _command = proc{
        _self.fill(self, value, _file)
        _self.new_wrapper if value.is_top
      }
      text value.class_wrapped.to_s
      helptext  value.class_wrapped.to_s
      image Arcadia.image_res(_image)
      #foreground 'blue'
      command _command
      #font $arcadia['conf']['main.component.font']
      relief 'groove'
      height 25
      width 25
      #pack('side' =>'left', 'anchor'=>'nw', :padx=>2, :pady=>2)
    }
    )
  }

  if @objCollections.length == 1
    @familyts.raise(_name)
  end
end

#class_image(_class = nil) ⇒ Object



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'ext/ae-rad/ae-rad-palette.rb', line 251

def class_image(_class=nil)
  _current_class = _class
  _found = false
  if _class
    _dir = File.dirname(_class.library.arcadia_lib_params.source)
  end
  while _current_class != nil && !_found
    if defined?(_current_class.library)
    		_dir = File.dirname(_current_class.library.arcadia_lib_params.source)
    end
    _img = (_current_class.to_s+"_gif").upcase
    _data = eval(_img + ' if defined?('+_img+')' )
    #_file = _dir+"/res/"+_current_class.to_s+".gif"
    if _data
    #if FileTest.exist?(_file)
      _found = true
    else
      _current_class = _current_class.superclass
    end
  end
  return (_found)?_data:A_WIDGET_GIF
end

#fill(_b, _class, _require, _class_obj = nil) ⇒ Object



175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'ext/ae-rad/ae-rad-palette.rb', line 175

def fill(_b, _class, _require, _class_obj = nil)
  _b.configure('relief'=>'sunken')
  if  @selected_button != nil
    @selected_button.configure('relief'=>'groove')
  end
  @selected_button = _b
  @selected_class = _class
  @selected_require = _require
  @selected_class_obj = _class_obj
  @owner.rad.float_frame.title(_class.class_wrapped)
  #Arcadia.instance.layout.domain(Arcadia.instance['conf']['palette.frame'])['root'].top_text(_class.class_wrapped)

end

#new_wrapper(_parent = nil, _obj = nil) ⇒ Object



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'ext/ae-rad/ae-rad-palette.rb', line 153

def new_wrapper(_parent = nil, _obj = nil)
  if @selected_button == nil
    return
  end
  # copy obj
  if @selected_class_obj != nil && _obj == nil
    _obj = eval(@selected_class_obj).new(_parent == nil ?nil:_parent.obj)
  end
  
  w = @selected_class.new(_parent, _obj)
  #$arcadia['objic'].active.select_last(true) if @selected_class_obj != nil
  #$arcadia.objects('objic').active.addRequire(@selected_require) if @selected_require != nil
  
  
  w.select.activate if @selected_class_obj != nil
  w.add_require([@selected_require]) if @selected_require != nil
  
  @selected_button.configure('relief'=>'groove')
  @selected_button = @selected_class = @selected_require = nil
end

#new_wrapper_codeObject



140
141
142
143
144
145
146
147
148
149
150
# File 'ext/ae-rad/ae-rad-palette.rb', line 140

def new_wrapper_code
  _code = ''
  if @selected_button != nil && @selected_class_obj != nil
    #objiinfo = @owner.ae_inspector_talker.info
    #_code = objiinfo.active_wrapper.renderer.class_code.to_s
    _code = AG.active.renderer.class_code.to_s
    @selected_button.configure('relief'=>'groove')
    @selected_button = @selected_class = @selected_require = nil
  end
  return _code
end

#unfillObject



189
190
191
192
193
194
195
196
197
198
# File 'ext/ae-rad/ae-rad-palette.rb', line 189

def unfill
  if  @selected_button != nil
    @selected_button.configure('relief'=>'groove')
  end
  @selected_button = nil
  @selected_class = nil
  @selected_require = nil
  @selected_class_obj = nil
  Arcadia.instance.layout.domain(Arcadia.instance['conf']['palette.frame'])['root'].top_text_clear
end