Class: HinnerDialog

Inherits:
TkFrame
  • Object
show all
Defined in:
lib/a-tkcommons.rb

Instance Method Summary collapse

Constructor Details

#initialize(side = 'top', args = nil) ⇒ HinnerDialog

Returns a new instance of HinnerDialog.



3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
# File 'lib/a-tkcommons.rb', line 3177

def initialize(side='top',args=nil)
  newargs =  Arcadia.style('panel').update({
    "highlightbackground" => Arcadia.conf('hightlight.link.foreground'),
    "highlightthickness" => 1
  })
  if !args.nil?
    newargs.update(args) 
  end
  super(Arcadia.layout.parent_frame, newargs)

  case side
    when 'top'
#        self.pack('side' =>side,'before'=>Arcadia.layout.root, 'anchor'=>'nw','fill'=>'both', 'padx'=>0, 'pady'=>0, 'expand'=>'yes')
      self.pack('side' =>side,'before'=>Arcadia.layout.root, 'anchor'=>'nw','fill'=>'x', 'padx'=>0, 'pady'=>0)
    when 'bottom'
      self.pack('side' =>side,'after'=>Arcadia.layout.root, 'anchor'=>'nw','fill'=>'x', 'padx'=>0, 'pady'=>0)
  end
  @modal = false
end

Instance Method Details

#is_modal?Boolean

Returns:

  • (Boolean)


3299
3300
3301
# File 'lib/a-tkcommons.rb', line 3299

def is_modal?
  @modal
end

#make_scrollable_frame(_frame) ⇒ Object



3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
# File 'lib/a-tkcommons.rb', line 3197

def make_scrollable_frame(_frame)


  TkGrid.rowconfigure(_frame, 0, 'weight'=>1, 'minsize'=>0)
  TkGrid.columnconfigure(_frame, 0, 'weight'=>1, 'minsize'=>0)
  canvas = TkCanvas.new(_frame)
  canvas.grid('row'=>0, 'column'=>0, 'sticky'=>'news')


  v_scroll = Arcadia.wf.scrollbar(_frame,{'orient'=>'vertical'})
  h_scroll = Arcadia.wf.scrollbar(_frame,{'orient'=>'horizontal'})




  p_vscroll = proc{|mode|
    st = TkGrid.info(v_scroll)
    if mode && st.size == 0 then
      v_scroll.grid('row'=>0, 'column'=>1, 'sticky'=>'ns')
    elsif mode == false
      v_scroll.ungrid 
    end
  }

  p_hscroll = proc{|mode|
    st = TkGrid.info(h_scroll)
    if mode && st.size == 0 then
      h_scroll.grid('row'=>1, 'column'=>0, 'sticky'=>'ew')
    elsif mode == false
      h_scroll.ungrid 
    end
  }

  p_do_yscrollcommand = proc{|first,last|
    if first != nil && last != nil
      delta = last.to_f - first.to_f
      if delta != @last_y_delta
        if delta < 1 && delta > 0 && last != @last_y_last
          p_vscroll.call(true)
          begin
            v_scroll.set(first,last)
          rescue Exception => e
            Arcadia.runtime_error(e)
          end
        elsif delta == 1 || delta == 0
          p_vscroll.call(false)
        end
      end
      @last_y_last = last if last.to_f < 1
      @last_y_delta = delta
    end    
  }

  p_do_xscrollcommand = proc{|first,last|
    if first != nil && last != nil
      delta = last.to_f - first.to_f
      if delta != @last_x_delta
        if delta < 1 && delta > 0 && last != @last_x_last
          p_hscroll.call(true)
          begin
            h_scroll.set(first,last)
          rescue Exception => e
            Arcadia.runtime_error(e)
          end
        elsif delta == 1 || delta == 0
          p_hscroll.call(false)
        end
      end
      @last_x_last = last if last.to_f < 1
      @last_x_delta = delta
    end    
  }

  canvas.yscrollbar(v_scroll)
  canvas.xscrollbar(h_scroll)


  canvas.yscrollcommand(proc{|first,last|
    p_do_yscrollcommand.call(first,last)
  })

  canvas.xscrollcommand(proc{|first,last|
    p_do_xscrollcommand.call(first,last)
  })



  frame = TkFrame.new(canvas) 



  frame.bind("Configure", proc{canvas.configure(:scrollregion=>canvas.bbox("all"))})


  cwin = TkcWindow.new(canvas, 0, 0, :window=>frame)

  canvas.scrollregion(cwin.bbox)

  return frame

end

#releaseObject



3303
3304
3305
# File 'lib/a-tkcommons.rb', line 3303

def release
  @modal=false
end

#show_modal(_destroy = true) ⇒ Object



3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
# File 'lib/a-tkcommons.rb', line 3307

def show_modal(_destroy=true)
  @modal=true
  Tk.update
  self.grab("set")
  begin
    while is_modal? do 
      Tk.update
      sleep(0.1) 
    end
  ensure
    self.grab("release")
  end
  Tk.update
  self.destroy if _destroy
end