arcadia 0.13.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/{README → README.md} +60 -53
  3. data/conf/LC/en-UK.LANG +10 -4
  4. data/conf/arcadia.conf +221 -83
  5. data/conf/arcadia.res.rb +165 -175
  6. data/conf/theme-dark.conf +1 -1
  7. data/conf/theme-dark.res.rb +0 -123
  8. data/ext/ae-breakpoints/ae-breakpoints.rb +4 -3
  9. data/ext/ae-dir-projects/ae-dir-projects.conf +27 -1
  10. data/ext/ae-dir-projects/ae-dir-projects.rb +120 -70
  11. data/ext/ae-editor/ae-editor.conf +2 -2
  12. data/ext/ae-editor/ae-editor.rb +610 -303
  13. data/ext/ae-file-history/ae-file-history.rb +60 -39
  14. data/ext/ae-output/ae-output.rb +52 -27
  15. data/ext/ae-ruby-debug/ae-ruby-debug.conf +3 -1
  16. data/ext/ae-ruby-debug/ae-ruby-debug.rb +18 -11
  17. data/ext/ae-search-in-files/ae-search-in-files.conf +2 -2
  18. data/ext/ae-search-in-files/ae-search-in-files.rb +124 -77
  19. data/ext/ae-shell/ae-shell.conf +1 -1
  20. data/ext/ae-shell/ae-shell.rb +18 -81
  21. data/ext/ae-subprocess-inspector/ae-subprocess-inspector.rb +78 -81
  22. data/ext/ae-term/ae-term.rb +9 -7
  23. data/lib/a-commons.rb +125 -17
  24. data/lib/a-contracts.rb +6 -2
  25. data/lib/a-core.rb +441 -405
  26. data/lib/a-tkcommons.rb +1237 -45
  27. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/ArrowButton.html +0 -0
  28. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/BWidget.html +0 -0
  29. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/Button.html +0 -0
  30. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/ButtonBox.html +0 -0
  31. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/ComboBox.html +0 -0
  32. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/Dialog.html +0 -0
  33. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/DragSite.html +0 -0
  34. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/DropSite.html +0 -0
  35. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/DynamicHelp.html +0 -0
  36. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/Entry.html +0 -0
  37. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/Label.html +0 -0
  38. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/LabelEntry.html +0 -0
  39. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/LabelFrame.html +0 -0
  40. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/ListBox.html +0 -0
  41. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/MainFrame.html +0 -0
  42. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/MessageDlg.html +0 -0
  43. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/NoteBook.html +0 -0
  44. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/PagesManager.html +0 -0
  45. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/PanedWindow.html +0 -0
  46. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/PanelFrame.html +0 -0
  47. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/PasswdDlg.html +0 -0
  48. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/ProgressBar.html +0 -0
  49. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/ProgressDlg.html +0 -0
  50. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/ScrollView.html +0 -0
  51. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/ScrollableFrame.html +0 -0
  52. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/ScrolledWindow.html +0 -0
  53. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/SelectColor.html +0 -0
  54. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/SelectFont.html +0 -0
  55. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/Separator.html +0 -0
  56. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/SpinBox.html +0 -0
  57. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/StatusBar.html +0 -0
  58. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/TitleFrame.html +0 -0
  59. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/Tree.html +0 -0
  60. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/Widget.html +0 -0
  61. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/contents.html +0 -0
  62. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/index.html +0 -0
  63. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/navtree.html +0 -0
  64. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/BWman/options.htm +0 -0
  65. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/CHANGES.txt +0 -0
  66. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/ChangeLog +65 -0
  67. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/LICENSE.txt +0 -0
  68. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/README.txt +0 -0
  69. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/arrow.tcl +0 -0
  70. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/bitmap.tcl +0 -0
  71. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/button.tcl +0 -2
  72. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/buttonbox.tcl +0 -0
  73. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/color.tcl +0 -0
  74. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/combobox.tcl +40 -16
  75. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/demo/basic.tcl +0 -0
  76. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/demo/bwidget.xbm +0 -0
  77. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/demo/demo.tcl +0 -0
  78. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/demo/dnd.tcl +0 -0
  79. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/demo/manager.tcl +0 -0
  80. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/demo/select.tcl +0 -0
  81. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/demo/tmpldlg.tcl +0 -0
  82. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/demo/tree.tcl +0 -0
  83. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/demo/x1.xbm +0 -0
  84. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/dialog.tcl +0 -0
  85. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/dragsite.tcl +0 -0
  86. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/dropsite.tcl +0 -0
  87. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/dynhelp.tcl +3 -0
  88. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/entry.tcl +0 -0
  89. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/font.tcl +0 -0
  90. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/bold.gif +0 -0
  91. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/copy.gif +0 -0
  92. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/cut.gif +0 -0
  93. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/dragfile.gif +0 -0
  94. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/dragicon.gif +0 -0
  95. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/error.gif +0 -0
  96. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/file.gif +0 -0
  97. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/folder.gif +0 -0
  98. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/hourglass.gif +0 -0
  99. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/info.gif +0 -0
  100. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/italic.gif +0 -0
  101. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/minus.xbm +0 -0
  102. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/new.gif +0 -0
  103. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/opcopy.xbm +0 -0
  104. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/open.gif +0 -0
  105. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/openfold.gif +0 -0
  106. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/oplink.xbm +0 -0
  107. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/opmove.xbm +0 -0
  108. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/overstrike.gif +0 -0
  109. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/palette.gif +0 -0
  110. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/passwd.gif +0 -0
  111. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/paste.gif +0 -0
  112. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/plus.xbm +0 -0
  113. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/print.gif +0 -0
  114. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/question.gif +0 -0
  115. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/redo.gif +0 -0
  116. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/save.gif +0 -0
  117. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/target.xbm +0 -0
  118. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/underline.gif +0 -0
  119. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/undo.gif +0 -0
  120. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/images/warning.gif +0 -0
  121. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/init.tcl +0 -0
  122. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/label.tcl +0 -2
  123. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/labelentry.tcl +0 -3
  124. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/labelframe.tcl +0 -2
  125. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/lang/da.rc +1 -0
  126. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/lang/de.rc +1 -0
  127. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/lang/en.rc +1 -0
  128. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/lang/es.rc +1 -0
  129. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/lang/fr.rc +1 -0
  130. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/lang/hu.rc +1 -0
  131. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/lang/nl.rc +1 -0
  132. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/lang/no.rc +59 -58
  133. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/lang/pl.rc +0 -0
  134. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/listbox.tcl +17 -4
  135. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/mainframe.tcl +0 -0
  136. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/messagedlg.tcl +0 -0
  137. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/notebook.tcl +0 -0
  138. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/pagesmgr.tcl +0 -0
  139. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/panedw.tcl +0 -0
  140. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/panelframe.tcl +0 -0
  141. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/passwddlg.tcl +0 -0
  142. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/pkgIndex.tcl +2 -2
  143. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/progressbar.tcl +0 -0
  144. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/progressdlg.tcl +0 -0
  145. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/scrollframe.tcl +6 -6
  146. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/scrollview.tcl +0 -0
  147. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/scrollw.tcl +1 -0
  148. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/separator.tcl +0 -0
  149. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/spinbox.tcl +0 -0
  150. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/statusbar.tcl +0 -0
  151. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/tests/entry.test +2 -2
  152. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/titleframe.tcl +0 -0
  153. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/tree.tcl +0 -0
  154. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/utils.tcl +0 -0
  155. data/tcl/bwidget-1.9.8/widget-old.tcl +1651 -0
  156. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/widget.tcl +64 -36
  157. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/wizard.tcl +0 -0
  158. data/tcl/{bwidget-1.9.7 → bwidget-1.9.8}/xpm2image.tcl +0 -0
  159. metadata +196 -195
@@ -261,6 +261,7 @@ class AGTkObjPlace
261
261
 
262
262
  end
263
263
 
264
+
264
265
  class TkFrameAdapter < TkFrame
265
266
  #include TkMovable
266
267
  attr_reader :frame
@@ -281,25 +282,50 @@ class TkFrameAdapter < TkFrame
281
282
 
282
283
  def detach_frame
283
284
  if @frame
284
- # if @movable
285
- # @frame.bind_remove("Configure")
286
- # @frame.bind_remove("Map")
287
- # @frame.bind_remove("Unmap")
288
- # end
289
285
  self.bind_remove("Map")
290
286
  self.unmap(@manager_forced_to_frame)
291
287
  @frame = nil
292
288
  end
293
289
  end
294
290
 
295
- def attach_frame(_frame)
291
+ def attach_frame(_frame, _extension = nil, _frame_index=0)
296
292
  @frame = _frame
297
293
  refresh_layout_manager
298
294
  self.map
299
- self.bind("Map", proc{@frame.raise})
295
+ if _extension
296
+ @frame.bind("Map", proc{
297
+ if _extension.frame_raised?(_frame_index)
298
+ @frame.raise
299
+ else
300
+ @frame.lower
301
+ end
302
+ })
303
+
304
+
305
+ # ffw = Arcadia.instance.layout.frame(_extension.frame_domain(_frame_index),_extension.name)
306
+ # if ffw
307
+ # ffw.bind("Map", proc{
308
+ # if _extension.frame_raised?(_frame_index)
309
+ # p "pack"
310
+ # @frame.pack
311
+ # @frame.raise
312
+ # else
313
+ # p "unpack"
314
+ # @frame.lower
315
+ # @frame.unpack
316
+ # end
317
+ # })
318
+ # end
319
+ else
320
+ self.bind("Map", proc{@frame.raise})
321
+ end
300
322
  self
301
323
  end
302
324
 
325
+ def layout_manager
326
+ @frame_manager
327
+ end
328
+
303
329
  def refresh_layout_manager
304
330
  @frame_manager = TkWinfo.manager(@frame)
305
331
  end
@@ -423,9 +449,12 @@ class AGTkVSplittedFrames < AGTkSplittedFrames
423
449
  "ButtonRelease-1",
424
450
  proc{do_resize}
425
451
  )
426
- _xbutton = TkButton.new(@splitter_frame, Arcadia.style('toolbarbutton')){
427
- background '#4966d7'
452
+ _xbutton = Arcadia.wf.toolbutton(@splitter_frame){
453
+ image Arcadia.image_res(VERTICAL_SPLITTER_HIDE_LEFT_GIF)
428
454
  }
455
+ # _xbutton = TkButton.new(@splitter_frame, Arcadia.style('toolbarbutton')){
456
+ # background '#4966d7'
457
+ # }
429
458
  _xbutton.place(
430
459
  'x' => 0,
431
460
  'y' => 0,
@@ -437,9 +466,12 @@ class AGTkVSplittedFrames < AGTkSplittedFrames
437
466
  "ButtonPress-1",
438
467
  proc{hide_left}
439
468
  )
440
- _ybutton = TkButton.new(@splitter_frame, Arcadia.style('toolbarbutton')){
441
- background '#118124'
469
+ _ybutton = Arcadia.wf.toolbutton(@splitter_frame){
470
+ image Arcadia.image_res(VERTICAL_SPLITTER_HIDE_RIGHT_GIF)
442
471
  }
472
+ # _ybutton = TkButton.new(@splitter_frame, Arcadia.style('toolbarbutton')){
473
+ # background '#118124'
474
+ # }
443
475
  _ybutton.place(
444
476
  'x' => 0,
445
477
  'y' => 21,
@@ -666,9 +698,12 @@ class AGTkOSplittedFrames < AGTkSplittedFrames
666
698
  "ButtonRelease-1",
667
699
  proc{do_resize}
668
700
  )
669
- _xbutton = TkButton.new(@splitter_frame, Arcadia.style('toolbarbutton')){
670
- background '#4966d7'
701
+ _xbutton = Arcadia.wf.toolbutton(@splitter_frame){
702
+ image Arcadia.image_res(HORIZONTAL_SPLITTER_HIDE_TOP_GIF)
671
703
  }
704
+ # _xbutton = TkButton.new(@splitter_frame, Arcadia.style('toolbarbutton')){
705
+ # background '#4966d7'
706
+ # }
672
707
  _xbutton.place(
673
708
  'x' => 0,
674
709
  'y' => 0,
@@ -680,9 +715,13 @@ class AGTkOSplittedFrames < AGTkSplittedFrames
680
715
  "ButtonPress-1",
681
716
  proc{hide_top}
682
717
  )
683
- _ybutton = TkButton.new(@splitter_frame, Arcadia.style('toolbarbutton')){
684
- background '#118124'
718
+
719
+ _ybutton = Arcadia.wf.toolbutton(@splitter_frame){
720
+ image Arcadia.image_res(HORIZONTAL_SPLITTER_HIDE_BOTTOM_GIF)
685
721
  }
722
+ # _ybutton = TkButton.new(@splitter_frame, Arcadia.style('toolbarbutton')){
723
+ # background '#118124'
724
+ # }
686
725
  _ybutton.place(
687
726
  'x' => 21,
688
727
  'y' => 0,
@@ -836,15 +875,20 @@ class TkBaseTitledFrame < TkFrame
836
875
  __add_sep(_width, @button_frame)
837
876
  end
838
877
 
878
+ def add_fixed_progress(_max=100, _canc_proc=nil, _hint=nil)
879
+ __add_progress(_max, _canc_proc, @button_frame, _hint)
880
+ end
881
+
839
882
  def __add_button(_label,_proc=nil,_image=nil, _side= 'right', _frame=nil)
840
883
  return if _frame.nil?
841
884
  begin
842
885
  last = @last_for_frame[_frame]
843
- @last_for_frame[_frame] = TkButton.new(_frame, Arcadia.style('titletoolbarbutton')){
886
+ # @last_for_frame[_frame] = TkButton.new(_frame, Arcadia.style('titletoolbarbutton')){
887
+ @last_for_frame[_frame] = Arcadia.wf.titletoolbutton(_frame){
844
888
  text _label if _label
845
889
  image Arcadia.image_res(_image) if _image
846
- padx 0
847
- pady 0
890
+ # padx 0
891
+ # pady 0
848
892
  if last
849
893
  pack('side'=> _side,'anchor'=> 'e', 'after'=>last)
850
894
  else
@@ -865,25 +909,79 @@ class TkBaseTitledFrame < TkFrame
865
909
  args = Arcadia.style('titlelabel')
866
910
  args.update(_args) if _args
867
911
  last = @last_for_frame[_frame]
868
- @last_for_frame[_frame] = @menu_buttons[_name] = TkMenuButton.new(_frame, args){|mb|
869
- menu TkMenu.new(mb, Arcadia.style('titlemenu'))
912
+ @last_for_frame[_frame] = @menu_buttons[_name] = Arcadia.wf.titlecontextmenubutton(_frame, _args){|mb|
913
+ menu Arcadia.wf.titlemenu(mb)
914
+ # menu TkMenu.new(mb, Arcadia.style('titlemenu'))
870
915
  if _image
871
- indicatoron false
916
+ # indicatoron false
872
917
  image Arcadia.image_res(_image)
873
918
  else
874
- indicatoron true
919
+ # indicatoron true
875
920
  end
876
- padx 0
921
+ # padx 0
877
922
  if last
878
923
  pack('side'=> _side,'anchor'=> 'e', 'after'=>last)
879
924
  else
880
925
  pack('side'=> _side,'anchor'=> 'e')
881
926
  end
882
927
  }
928
+
929
+ # @last_for_frame[_frame] = @menu_buttons[_name] = TkMenuButton.new(_frame, args){|mb|
930
+ # menu TkMenu.new(mb, Arcadia.style('titlemenu'))
931
+ # if _image
932
+ # indicatoron false
933
+ # image Arcadia.image_res(_image)
934
+ # else
935
+ # indicatoron true
936
+ # end
937
+ # padx 0
938
+ # if last
939
+ # pack('side'=> _side,'anchor'=> 'e', 'after'=>last)
940
+ # else
941
+ # pack('side'=> _side,'anchor'=> 'e')
942
+ # end
943
+ # }
883
944
  @menu_buttons[_name]
884
945
  end
885
946
  private :__add_menu_button
886
947
 
948
+ def __add_check_button(_label,_proc=nil,_image=nil, _side= 'right', _frame=nil)
949
+ return if _frame.nil?
950
+ begin
951
+ last = @last_for_frame[_frame]
952
+ # @last_for_frame[_frame] = TkCheckButton.new(_frame, Arcadia.style('checkbox').update('background'=>_frame.background)){
953
+ # text _label if _label
954
+ # image Arcadia.image_res(_image) if _image
955
+ # padx 0
956
+ # pady 0
957
+ # if last
958
+ # pack('side'=> _side,'anchor'=> 'e', 'after'=>last)
959
+ # else
960
+ # pack('side'=> _side,'anchor'=> 'e')
961
+ # end
962
+ # command(_proc) if _proc
963
+ # }
964
+ # Tk::BWidget::DynamicHelp::add(@last_for_frame[_frame], 'text'=>_label) if _label
965
+
966
+ @last_for_frame[_frame] = Arcadia.wf.titlecontextcheckbutton(@panel){
967
+ text _label if _label
968
+ variable TkVariable.new
969
+ image Arcadia.image_res(_image) if _image
970
+ if last
971
+ pack('side'=> _side,'anchor'=> 'e', 'after'=>last)
972
+ else
973
+ pack('side'=> _side,'anchor'=> 'e')
974
+ end
975
+ command(_proc) if _proc
976
+ }
977
+ @last_for_frame[_frame].hint=_label if _label
978
+ @last_for_frame[_frame]
979
+ rescue RuntimeError => e
980
+ Arcadia.runtime_error(e)
981
+ end
982
+ end
983
+ private :__add_check_button
984
+
887
985
  def __add_panel(_name='default', _side= 'right', _args=nil, _frame=nil)
888
986
  return if _frame.nil?
889
987
  args = Arcadia.style('panel').update('background'=>_frame.background, 'highlightbackground'=>_frame.background)
@@ -926,12 +1024,13 @@ class TkBaseTitledFrame < TkFrame
926
1024
  return if _frame.nil?
927
1025
  begin
928
1026
  last = @last_for_state_frame[_frame]
929
- @last_for_state_frame[_frame] = TkButton.new(_frame, Arcadia.style('titletoolbarbutton')){
1027
+ #@last_for_state_frame[_frame] = TkButton.new(_frame, Arcadia.style('titletoolbarbutton')){
1028
+ @last_for_state_frame[_frame] = Arcadia.wf.titletoolbutton(_frame){
930
1029
  text _label if _label
931
1030
  image Arcadia.image_res(_image) if _image
932
- font 'helvetica 8 bold'
933
- padx 0
934
- pady 0
1031
+ # font 'helvetica 8 bold'
1032
+ # padx 0
1033
+ # pady 0
935
1034
  if last
936
1035
  pack('side'=> _side,'anchor'=> 'w', 'after'=>last)
937
1036
  else
@@ -939,7 +1038,8 @@ class TkBaseTitledFrame < TkFrame
939
1038
  end
940
1039
  bind('1',_proc) if _proc
941
1040
  }
942
- Tk::BWidget::DynamicHelp::add(@last_for_state_frame[_frame], 'text'=>_label) if _label
1041
+ @last_for_state_frame[_frame].hint=_label
1042
+ #Tk::BWidget::DynamicHelp::add(@last_for_state_frame[_frame], 'text'=>_label) if _label
943
1043
  @last_for_state_frame[_frame]
944
1044
  rescue RuntimeError => e
945
1045
  Arcadia.runtime_error(e)
@@ -947,6 +1047,34 @@ class TkBaseTitledFrame < TkFrame
947
1047
  end
948
1048
  private :__add_state_button
949
1049
 
1050
+ def __add_progress(_max, _canc_proc=nil, _frame=nil, _hint=nil, _side= 'left')
1051
+
1052
+ return if _frame.nil?
1053
+ begin
1054
+ last = @last_for_frame[_frame]
1055
+ @last_for_frame[_frame] = TkFrameProgress.new(_frame, _max)
1056
+ if last
1057
+ @last_for_frame[_frame].pack('side'=> _side,'anchor'=> 'e', 'after'=>last)
1058
+ else
1059
+ @last_for_frame[_frame].pack('side'=> _side,'anchor'=> 'e')
1060
+ end
1061
+
1062
+ @last_for_frame[_frame].on_cancel=_canc_proc if _canc_proc
1063
+
1064
+ Tk::BWidget::DynamicHelp::add(@last_for_frame[_frame], 'text'=>_hint) if _hint
1065
+ @last_for_frame[_frame]
1066
+ rescue RuntimeError => e
1067
+ Arcadia.runtime_error(e)
1068
+ end
1069
+ end
1070
+ private :__add_progress
1071
+
1072
+ def __destroy_progress(_progress, _frame)
1073
+ @last_for_frame[_frame] = nil if @last_for_frame[_frame] == _progress
1074
+ _progress.destroy
1075
+ end
1076
+ private :__destroy_progress
1077
+
950
1078
  def menu_button(_name='default')
951
1079
  @menu_buttons[_name]
952
1080
  end
@@ -1183,11 +1311,13 @@ class TkLabelTitledFrame < TkTitledFrame
1183
1311
  end
1184
1312
 
1185
1313
  def shift_on
1186
- @left_label.foreground(Arcadia.conf('titlelabel.foreground'))
1314
+ @left_label.state='normal'
1315
+ #@left_label.foreground(Arcadia.conf('titlelabel.foreground'))
1187
1316
  end
1188
1317
 
1189
1318
  def shift_off
1190
- @left_label.foreground(Arcadia.conf('titlelabel.disabledforeground'))
1319
+ @left_label.state='disable'
1320
+ #@left_label.foreground(Arcadia.conf('titlelabel.disabledforeground'))
1191
1321
  end
1192
1322
 
1193
1323
  def title(_text=nil)
@@ -1204,6 +1334,17 @@ class TkLabelTitledFrame < TkTitledFrame
1204
1334
  end
1205
1335
  end
1206
1336
 
1337
+ class TkLabelTitledFrameClosable < TkLabelTitledFrame
1338
+ def head_buttons
1339
+ @bclose = add_fixed_button('[ ]',proc{}, CLOSE_FRAME_GIF)
1340
+ end
1341
+
1342
+ def add_close_action(_proc)
1343
+ @bclose.bind_append("1", _proc)
1344
+ end
1345
+ end
1346
+
1347
+
1207
1348
  class TkMenuTitledFrame < TkTitledFrame
1208
1349
  def create_left_title
1209
1350
  @left_menu_button = __create_left_menu_button(@top)
@@ -1216,15 +1357,17 @@ class TkMenuTitledFrame < TkTitledFrame
1216
1357
 
1217
1358
  def __create_left_menu_button(_frame)
1218
1359
  img=@img
1219
- @left_menu_button = TkMenuButton.new(_frame, Arcadia.style('titlebutton')){|mb|
1220
- menu TkMenu.new(mb, Arcadia.style('titlemenu'))
1360
+ #@left_menu_button = TkMenuButton.new(_frame, Arcadia.style('titlebutton')){|mb|
1361
+ @left_menu_button = Arcadia.wf.titlemenubutton(_frame){|mb|
1362
+ menu Arcadia.wf.titlemenu(mb)
1363
+ #menu TkMenu.new(mb, Arcadia.style('titlemenu'))
1221
1364
  if img
1222
- indicatoron false
1365
+ #indicatoron false
1223
1366
  image Arcadia.image_res(img)
1224
1367
  else
1225
- indicatoron true
1368
+ #indicatoron true
1226
1369
  end
1227
- padx 0
1370
+ #padx 0
1228
1371
  textvariable TkVariable.new('')
1229
1372
  pack('side'=> 'left','anchor'=> 'e')
1230
1373
  }
@@ -1232,11 +1375,13 @@ class TkMenuTitledFrame < TkTitledFrame
1232
1375
  end
1233
1376
 
1234
1377
  def shift_on
1235
- @left_menu_button.foreground(Arcadia.conf('titlelabel.foreground'))
1378
+ @left_menu_button.state='normal'
1379
+ #@left_menu_button.foreground(Arcadia.conf('titlelabel.foreground'))
1236
1380
  end
1237
1381
 
1238
1382
  def shift_off
1239
- @left_menu_button.foreground(Arcadia.conf('titlelabel.disabledforeground'))
1383
+ @left_menu_button.state='disable'
1384
+ #@left_menu_button.foreground(Arcadia.conf('titlelabel.disabledforeground'))
1240
1385
  end
1241
1386
 
1242
1387
  def title(_text=nil)
@@ -1469,6 +1614,11 @@ class TkTitledFrameAdapter < TkMenuTitledFrame
1469
1614
  __add_menu_button(_name, _image, _side, _args, @transient_frame_adapter[_sender_name][:action])
1470
1615
  end
1471
1616
 
1617
+ def add_check_button(_sender_name, _label,_proc=nil,_image=nil, _side= 'right')
1618
+ forge_transient_adapter(_sender_name)
1619
+ __add_check_button(_label,_proc,_image, _side, @transient_frame_adapter[_sender_name][:action])
1620
+ end
1621
+
1472
1622
  def add_panel(_sender_name, _name='default',_side= 'right', _args=nil)
1473
1623
  forge_transient_adapter(_sender_name)
1474
1624
  __add_panel(_name, _side, _args, @transient_frame_adapter[_sender_name][:action])
@@ -1484,6 +1634,15 @@ class TkTitledFrameAdapter < TkMenuTitledFrame
1484
1634
  __add_state_button(_label,_proc,_image, _side, @transient_frame_adapter[_sender_name][:state])
1485
1635
  end
1486
1636
 
1637
+ def add_progress(_sender_name, _max=100, _canc_proc=nil, _hint=nil)
1638
+ forge_transient_adapter(_sender_name)
1639
+ __add_progress(_max, _canc_proc, @transient_frame_adapter[_sender_name][:action], _hint)
1640
+ end
1641
+
1642
+ def destroy_progress(_sender_name, _progress)
1643
+ __destroy_progress(_progress, @transient_frame_adapter[_sender_name][:action])
1644
+ end
1645
+
1487
1646
  end
1488
1647
 
1489
1648
 
@@ -1623,7 +1782,8 @@ class TkProgressframe < TkFloatTitledFrame
1623
1782
 
1624
1783
  @buttons_frame = TkFrame.new(self, Arcadia.style('panel')).pack('fill'=>'x', 'side'=>'bottom')
1625
1784
 
1626
- @b_cancel = TkButton.new(@buttons_frame, Arcadia.style('button')){|_b_go|
1785
+ #@b_cancel = TkButton.new(@buttons_frame, Arcadia.style('button')){|_b_go|
1786
+ @b_cancel = Arcadia.wf.titletoolbutton(@buttons_frame){|_b_go|
1627
1787
  default 'disabled'
1628
1788
  text 'Cancel'
1629
1789
  overrelief 'raised'
@@ -1647,6 +1807,58 @@ class TkProgressframe < TkFloatTitledFrame
1647
1807
  end
1648
1808
  end
1649
1809
 
1810
+ class TkFrameProgress < TkFrame
1811
+ attr_accessor :max
1812
+ def initialize(parent=nil, _max=100, *args)
1813
+ super(parent, Arcadia.style('panel').update({:background => Arcadia.conf('titlelabel.background')}), *args)
1814
+ _max=1 if _max<=0
1815
+ @max = _max
1816
+ @progress = TkVariable.new
1817
+ @progress.value = -1
1818
+ Tk::BWidget::ProgressBar.new(self, :width=>50, :height=>16,
1819
+ :background=>Arcadia.conf('titlelabel.background'),
1820
+ :troughcolor=>Arcadia.conf('titlelabel.background'),
1821
+ :foreground=>Arcadia.conf('progress.foreground'),
1822
+ :variable=>@progress,
1823
+ :borderwidth=>0,
1824
+ :relief=>'flat',
1825
+ :maximum=>_max).pack('side'=>'left','padx'=>0, 'pady'=>0)
1826
+ #@b_cancel = TkButton.new(self, Arcadia.style('toolbarbutton')){|b|
1827
+ @b_cancel = Arcadia.wf.titletoolbutton(self){|b|
1828
+ # background Arcadia.conf('titlelabel.background')
1829
+ # foreground Arcadia.conf('titlelabel.background')
1830
+ # highlightbackground Arcadia.conf('titlelabel.background')
1831
+ # highlightcolor Arcadia.conf('titlelabel.background')
1832
+ image Arcadia.image_res(CLOSE_FRAME_GIF)
1833
+ # borderwidth 0
1834
+ # relief 'flat'
1835
+ # padx 0
1836
+ # pady 0
1837
+ # anchor 'n'
1838
+ pack('side'=>'left','padx'=>0, 'pady'=>0)
1839
+ }
1840
+ end
1841
+
1842
+ def destroy
1843
+ @on_destroy.call if defined?(@on_destroy)
1844
+ super
1845
+ end
1846
+
1847
+ def progress(_incr=1)
1848
+ @progress.numeric += _incr
1849
+ end
1850
+
1851
+ def on_cancel=(_proc)
1852
+ @b_cancel.bind_append('1', _proc)
1853
+ end
1854
+
1855
+ def on_destroy=(_proc)
1856
+ @on_destroy=_proc
1857
+ end
1858
+
1859
+ end
1860
+
1861
+
1650
1862
  class TkBuffersChoiseView < TkToplevel
1651
1863
 
1652
1864
  def initialize
@@ -1683,7 +1895,27 @@ class TclTkInfo
1683
1895
  attr_reader :level
1684
1896
  def initialize
1685
1897
  @level = Tk.tk_call( "eval", "info patchlevel")
1686
- # @level = TclTkIp.new._eval "info patchlevel"
1898
+
1899
+ # info args procname
1900
+ # info body procname
1901
+ # info cmdcount
1902
+ # info commands ?pattern?
1903
+ # info complete command
1904
+ # info default procname arg varname
1905
+ # info exists varName
1906
+ # info globals ?pattern?
1907
+ # info hostname
1908
+ # info level ?number?
1909
+ # info library
1910
+ # info loaded ?interp?
1911
+ # info locals ?pattern?
1912
+ # info nameofexecutable
1913
+ # info patchlevel
1914
+ # info procs ?pattern?
1915
+ # info script
1916
+ # info sharedlibextension
1917
+ # info tclversion
1918
+ # info vars ?pattern?
1687
1919
  end
1688
1920
  end
1689
1921
 
@@ -1691,7 +1923,15 @@ end
1691
1923
  #Tk.tk_call "eval","ttk::setTheme clam"
1692
1924
  #Tk::Tile::Style.theme_use('clam')
1693
1925
 
1926
+
1694
1927
  class TkWidgetFactory
1928
+
1929
+ module WidgetEnhancer
1930
+ def hint=(_hint=nil)
1931
+ Tk::BWidget::DynamicHelp::add(self, 'text'=>_hint) if _hint
1932
+ end
1933
+ end
1934
+
1695
1935
  def initialize
1696
1936
  if Arcadia.conf('tile.theme')
1697
1937
  @use_tile = true
@@ -1708,6 +1948,16 @@ class TkWidgetFactory
1708
1948
  end
1709
1949
 
1710
1950
  def initialize_tile_widgets
1951
+
1952
+ #Widget state flags include:
1953
+ #active,disabled,focus,pressed,selected,background,readonly,alternate,invalid,hover
1954
+
1955
+ # Workaround for #1100117:
1956
+ # Actually, on Aqua we probably shouldn't stipple images in
1957
+ # disabled buttons even if it did work...
1958
+ # don't work with Cocoa
1959
+ Tk.tk_call("eval","ttk::style configure . -stipple {}") if OS.mac?
1960
+
1711
1961
  #TScrollbar
1712
1962
  Tk::Tile::Style.configure("Arcadia.TScrollbar", Arcadia.style('scrollbar'))
1713
1963
  Tk::Tile::Style.map("Arcadia.TScrollbar",
@@ -1746,26 +1996,410 @@ class TkWidgetFactory
1746
1996
  #Treeview
1747
1997
  #Tk::Tile::Style.configure(Tk::Tile::Treeview, Arcadia.style('treepanel'))
1748
1998
 
1749
-
1750
1999
  #TMenubutton
1751
- #Tk::Tile::Style.configure(Tk::Tile::TMenubutton, Arcadia.style('menu'))
2000
+ Tk::Tile::Style.element_create('Arcadia.Menubutton.indicator',
2001
+ :image, Arcadia.image_res(DROP_DOWN_ARROW_GIF),
2002
+ :sticky=>:w)
2003
+
2004
+ Tk::Tile::Style.configure("Arcadia.TMenubutton", Arcadia.style('menubutton').update(
2005
+ 'padding'=>"0 0 0 0",
2006
+ 'width'=>0
2007
+ )
2008
+ )
2009
+
2010
+ Tk::Tile::Style.map("Arcadia.TMenubutton",
2011
+ :background=>[:pressed, Arcadia.style('menubutton')['activebackground'], :disabled, Arcadia.style('menubutton')['background'], :active, Arcadia.style('menubutton')['activebackground']],
2012
+ :arrowcolor=>[:pressed, Arcadia.style('menubutton')['background'], :disabled, Arcadia.style('menubutton')['highlightbackground'], :active, Arcadia.style('menubutton')['background']],
2013
+ :relief=>[:pressed, :flat])
2014
+ Tk::Tile::Style.layout('Arcadia.TMenubutton', [
2015
+ 'Menubutton.border', {:children=>[
2016
+ 'Menubutton.padding', {:children=>[
2017
+ 'Arcadia.Menubutton.indicator', {:side=>:right},
2018
+ 'Menubutton.focus', {:side=>:left, :children=>['Menubutton.label']}
2019
+ ]}
2020
+ ]}
2021
+ ])
2022
+
2023
+ #Title.TMenubutton
2024
+ #
2025
+ Tk::Tile::Style.configure("Arcadia.Title.TMenubutton", Arcadia.style('titlelabel').update(
2026
+ 'padding'=>"0 0 0 0",
2027
+ 'font'=>Arcadia.conf('titlelabel.font'),
2028
+ 'width'=>0,
2029
+ 'foreground' => Arcadia.conf('titlelabel.foreground'),
2030
+ )
2031
+ )
2032
+ Tk::Tile::Style.map("Arcadia.Title.TMenubutton",
2033
+ :background=>[:pressed, Arcadia.style('titlelabel')['activebackground'], :disabled, Arcadia.style('titlelabel')['background'], :active, Arcadia.style('titlelabel')['activebackground']],
2034
+ :arrowcolor=>[:pressed, Arcadia.style('titlelabel')['background'], :disabled, Arcadia.style('titlelabel')['highlightbackground'], :active, Arcadia.style('titlelabel')['background']],
2035
+ :relief=>[:pressed, :flat])
2036
+ Tk::Tile::Style.layout('Arcadia.Title.TMenubutton', [
2037
+ 'Menubutton.border', {:children=>[
2038
+ 'Menubutton.padding', {:children=>[
2039
+ 'Arcadia.Menubutton.indicator', {:side=>:right},
2040
+ 'Menubutton.focus', {:side=>:left, :children=>['Menubutton.label']}
2041
+ ]}
2042
+ ]}
2043
+ ])
2044
+
2045
+ #Title.Context.TMenubutton
2046
+ #
2047
+ Tk::Tile::Style.configure("Arcadia.Title.Context.TMenubutton", Arcadia.style('titlelabel').update(
2048
+ 'padding'=>"0 0 0 0",
2049
+ 'font'=>"#{Arcadia.conf('titlelabel.font')} italic",
2050
+ 'width'=>0,
2051
+ 'foreground' => Arcadia.conf('titlecontext.foreground'),
2052
+ )
2053
+ )
2054
+ Tk::Tile::Style.map("Arcadia.Title.Context.TMenubutton",
2055
+ :background=>[:pressed, Arcadia.style('titlelabel')['activebackground'], :disabled, Arcadia.style('titlelabel')['background'], :active, Arcadia.style('titlelabel')['activebackground']],
2056
+ :arrowcolor=>[:pressed, Arcadia.style('titlelabel')['background'], :disabled, Arcadia.style('titlelabel')['highlightbackground'], :active, Arcadia.style('titlelabel')['background']],
2057
+ :relief=>[:pressed, :flat])
2058
+ Tk::Tile::Style.layout('Arcadia.Title.Context.TMenubutton', [
2059
+ 'Menubutton.border', {:children=>[
2060
+ 'Menubutton.padding', {:children=>[
2061
+ 'Arcadia.Menubutton.indicator', {:side=>:right},
2062
+ 'Menubutton.focus', {:side=>:left, :children=>['Menubutton.label']}
2063
+ ]}
2064
+ ]}
2065
+ ])
2066
+
2067
+
2068
+ #TCheckbutton,
2069
+
2070
+ Tk::Tile::Style.element_create('Arcadia.Checkbutton.indicator',
2071
+ :image, Arcadia.image_res(CHECKBOX_0_DARK_GIF),
2072
+ :map=>[
2073
+ [:pressed, :selected],Arcadia.image_res(CHECKBOX_1_DARK_GIF),
2074
+ :pressed, Arcadia.image_res(CHECKBOX_0_DARK_GIF),
2075
+ [:active, :selected], Arcadia.image_res(CHECKBOX_2_DARK_GIF),
2076
+ :active, Arcadia.image_res(CHECKBOX_0_DARK_GIF),
2077
+ :selected, Arcadia.image_res(CHECKBOX_1_DARK_GIF),
2078
+ ], :sticky=>:w)
2079
+
2080
+ Tk::Tile::Style.configure("Arcadia.TCheckbutton", Arcadia.style('checkbox').update(
2081
+ 'padding'=>"0 0 0 0",
2082
+ 'width'=>0
2083
+ )
2084
+ )
2085
+
2086
+ Tk::Tile::Style.layout('Arcadia.TCheckbutton', [
2087
+ 'Checkbutton.background', # this is not needed in tile 0.5 or later
2088
+ 'Checkbutton.border', {:children=>[
2089
+ 'Checkbutton.padding', {:children=>[
2090
+ 'Arcadia.Checkbutton.indicator', {:side=>:left},
2091
+ 'Checkbutton.focus', {:side=>:left, :children=>[
2092
+ 'Checkbutton.label'
2093
+ ]}
2094
+ ]}
2095
+ ]}
2096
+ ])
2097
+
2098
+
2099
+ Tk::Tile::Style.configure("Arcadia.Title.TCheckbutton", Arcadia.style('titlelabel').update(
2100
+ 'padding'=>"0 0 0 0",
2101
+ 'width'=>0
2102
+ )
2103
+ )
2104
+
2105
+ Tk::Tile::Style.layout('Arcadia.Title.TCheckbutton', [
2106
+ 'Checkbutton.background', # this is not needed in tile 0.5 or later
2107
+ 'Checkbutton.border', {:children=>[
2108
+ 'Checkbutton.padding', {:children=>[
2109
+ 'Arcadia.Checkbutton.indicator', {:side=>:left},
2110
+ 'Checkbutton.focus', {:side=>:left, :children=>[
2111
+ 'Checkbutton.label'
2112
+ ]}
2113
+ ]}
2114
+ ]}
2115
+ ])
2116
+
2117
+ #Combobox
2118
+
2119
+
2120
+ Tk::Tile::Style.element_create('Arcadia.Combobox.indicator',
2121
+ :image, Arcadia.image_res(DROP_DOWN_ARROW_GIF),
2122
+ :sticky=>:w)
2123
+
2124
+ Tk::Tile::Style.configure("Arcadia.TCombobox", Arcadia.style('combobox').update(
2125
+ 'padding'=>"0 0 0 0",
2126
+ 'width'=>0
2127
+ # 'borderwidth'=>1,
2128
+ # 'relief'=>'groove'
2129
+ )
2130
+ )
2131
+
2132
+ # Tk::Tile::Style.map("Arcadia.TCombobox",
2133
+ # :relief=>[:pressed, :flat])
2134
+
2135
+ Tk::Tile::Style.layout('Arcadia.TCombobox', [
2136
+ 'Combobox.border', {:children=>[
2137
+ 'Combobox.padding', {:children=>[
2138
+ 'Arcadia.Combobox.indicator', {:side=>:right},
2139
+ 'Combobox.focus', {:side=>:left, :children=>['Combobox.label']}
2140
+ ]}
2141
+ ]}
2142
+ ])
2143
+
2144
+
2145
+ #Tk::Tile::Style.configure(Tk::Tile::TLabel, Arcadia.style('label'))
2146
+ #TLabel
2147
+ Tk::Tile::Style.configure("Arcadia.TLabel", Arcadia.style('label'))
2148
+
1752
2149
 
1753
2150
  #TButton
1754
- #Tk::Tile::Style.configure(Tk::Tile::TButton, Arcadia.style('button'))
2151
+ Tk::Tile::Style.configure("Arcadia.TButton", Arcadia.style('button').update(
2152
+ 'padding'=>"0 0 0 0"
2153
+ # ,
2154
+ # 'borderwidth'=>1,
2155
+ # 'relief'=>'groove'
2156
+ )
2157
+ )
2158
+ Tk::Tile::Style.map("Arcadia.TButton",
2159
+ :background=>[:pressed, Arcadia.style('button')['activebackground'], :disabled, Arcadia.style('button')['background'], :active, Arcadia.style('button')['activebackground']],
2160
+ :foreground=>[:pressed, Arcadia.style('button')['activeforeground'], :disabled, Arcadia.style('button')['foreground'], :active, Arcadia.style('button')['activeforeground']],
2161
+ :relief=>[:pressed, :sunken])
2162
+
2163
+ #Tool.TButton
2164
+ Tk::Tile::Style.configure("Arcadia.Tool.TButton", Arcadia.style('toolbarbutton').update(
2165
+ 'padding'=>"0 0 0 0",
2166
+ 'anchor'=>'w'
2167
+ )
2168
+ )
2169
+ Tk::Tile::Style.map("Arcadia.Tool.TButton",
2170
+ :background=>[:pressed, Arcadia.style('button')['activebackground'], :disabled, Arcadia.style('toolbarbutton')['background'], :active, Arcadia.style('toolbarbutton')['activebackground']],
2171
+ :arrowcolor=>[:pressed, Arcadia.style('button')['background'], :disabled, Arcadia.style('toolbarbutton')['highlightbackground'], :active, Arcadia.style('toolbarbutton')['background']],
2172
+ :relief=>[:pressed, :sunken])
2173
+
2174
+ #Title.Tool.TButton
2175
+ Tk::Tile::Style.configure("Arcadia.Title.Tool.TButton", Arcadia.style('titletoolbarbutton').update(
2176
+ 'padding'=>"0 0 0 0"
2177
+ )
2178
+ )
2179
+ Tk::Tile::Style.map("Arcadia.Title.Tool.TButton",
2180
+ :background=>[:pressed, Arcadia.style('button')['activebackground'], :disabled, Arcadia.style('titletoolbarbutton')['background'], :active, Arcadia.style('toolbarbutton')['activebackground']],
2181
+ :arrowcolor=>[:pressed, Arcadia.style('button')['background'], :disabled, Arcadia.style('titletoolbarbutton')['highlightbackground'], :active, Arcadia.style('toolbarbutton')['background']],
2182
+ :relief=>[:pressed, :sunken])
2183
+
2184
+ end
2185
+
2186
+
2187
+
2188
+ def scrollbar(_parent,_args={}, &b)
2189
+ begin
2190
+ if @use_tile
2191
+ obj = Tk::Tile::Scrollbar.new(_parent,{:style=>"Arcadia.TScrollbar"}.update(_args), &b)
2192
+ else
2193
+ obj = TkScrollbar.new(_parent,Arcadia.style('scrollbar').update(_args), &b)
2194
+ end
2195
+ class << obj
2196
+ include WidgetEnhancer
2197
+ end
2198
+ return obj
2199
+ rescue RuntimeError => e
2200
+ Arcadia.runtime_error(e)
2201
+ end
2202
+ end
2203
+
2204
+ def label(_parent,_args={}, &b)
2205
+ begin
2206
+ if @use_tile
2207
+ obj = Tk::Tile::TLabel.new(_parent,{:style=>"Arcadia.TLabel"}.update(_args), &b)
2208
+ else
2209
+ obj = TkLabel.new(_parent,Arcadia.style('label').update(_args), &b)
2210
+ end
2211
+ class << obj
2212
+ include WidgetEnhancer
2213
+ end
2214
+ return obj
2215
+ rescue RuntimeError => e
2216
+ Arcadia.runtime_error(e)
2217
+ return nil
2218
+ end
2219
+ end
2220
+
2221
+ def button(_parent,_args={}, &b)
2222
+ begin
2223
+ if @use_tile
2224
+ obj = Tk::Tile::Button.new(_parent,{:style=>"Arcadia.TButton"}.update(_args), &b)
2225
+ else
2226
+ obj = TkButton.new(_parent,Arcadia.style('button').update(_args), &b)
2227
+ end
2228
+ class << obj
2229
+ include WidgetEnhancer
2230
+ end
2231
+ return obj
2232
+ rescue RuntimeError => e
2233
+ Arcadia.runtime_error(e)
2234
+ return nil
2235
+ end
2236
+ end
2237
+
2238
+ def toolbutton(_parent,_args={}, &b)
2239
+ begin
2240
+ if @use_tile
2241
+ obj = Tk::Tile::Button.new(_parent,{:style=>"Arcadia.Tool.TButton"}.update(_args), &b)
2242
+ else
2243
+ obj = TkButton.new(_parent,Arcadia.style('toolbarbutton').update(_args), &b)
2244
+ end
2245
+ class << obj
2246
+ include WidgetEnhancer
2247
+ end
2248
+ return obj
2249
+ rescue RuntimeError => e
2250
+ Arcadia.runtime_error(e)
2251
+ return nil
2252
+ end
2253
+ end
2254
+
2255
+ def titletoolbutton(_parent,_args={}, &b)
2256
+ begin
2257
+ if @use_tile
2258
+ obj = Tk::Tile::Button.new(_parent,{:style=>"Arcadia.Title.Tool.TButton"}.update(_args), &b)
2259
+ else
2260
+ obj = TkButton.new(_parent,Arcadia.style('toolbarbutton').update(_args), &b)
2261
+ end
2262
+ class << obj
2263
+ include WidgetEnhancer
2264
+ end
2265
+ return obj
2266
+ rescue RuntimeError => e
2267
+ Arcadia.runtime_error(e)
2268
+ return nil
2269
+ end
2270
+ end
2271
+
2272
+ def menubutton(_parent,_args={}, &b)
2273
+ begin
2274
+ if @use_tile
2275
+ obj = Tk::Tile::Menubutton.new(_parent,{:style=>"Arcadia.TMenubutton"}.update(_args), &b)
2276
+ else
2277
+ obj = TkMenuButton.new(_parent,Arcadia.style('menubutton').update(_args), &b)
2278
+ end
2279
+ class << obj
2280
+ include WidgetEnhancer
2281
+ end
2282
+ return obj
2283
+ rescue RuntimeError => e
2284
+ Arcadia.runtime_error(e)
2285
+ return nil
2286
+ end
2287
+ end
2288
+
2289
+ def combobox(_parent,_args={}, &b)
2290
+ begin
2291
+ if @use_tile
2292
+ obj = Tk::Tile::Combobox.new(_parent,{:style=>"Arcadia.TCombobox"}.update(_args), &b)
2293
+ else
2294
+ obj = Tk::BWidget::ComboBox.new(_parent, Arcadia.style('combobox').update(_args), &b)
2295
+ end
2296
+ class << obj
2297
+ include WidgetEnhancer
2298
+ end
2299
+ return obj
2300
+ rescue RuntimeError => e
2301
+ Arcadia.runtime_error(e)
2302
+ return nil
2303
+ end
2304
+ end
2305
+
2306
+ def titlemenubutton(_parent, _args={}, &b)
2307
+ begin
2308
+ if @use_tile
2309
+ obj = Tk::Tile::Menubutton.new(_parent,{:style=>"Arcadia.Title.TMenubutton"}.update(_args), &b)
2310
+ else
2311
+ obj = TkMenuButton.new(_parent,Arcadia.style('menubutton').update(_args), &b)
2312
+ end
2313
+ class << obj
2314
+ include WidgetEnhancer
2315
+ end
2316
+ return obj
2317
+ rescue RuntimeError => e
2318
+ Arcadia.runtime_error(e)
2319
+ return nil
2320
+ end
1755
2321
  end
1756
2322
 
1757
- def scrollbar(_parent,_args=nil, &b)
2323
+ def titlecontextmenubutton(_parent, _args={}, &b)
1758
2324
  begin
1759
2325
  if @use_tile
1760
- return Tk::Tile::Scrollbar.new(_parent,{:style=>"Arcadia.TScrollbar"}.update(_args), &b)
2326
+ obj = Tk::Tile::Menubutton.new(_parent,{:style=>"Arcadia.Title.Context.TMenubutton"}.update(_args), &b)
1761
2327
  else
1762
- return TkScrollbar.new(_parent,Arcadia.style('scrollbar').update(_args), &b)
2328
+ obj = TkMenuButton.new(_parent,Arcadia.style('menubutton').update(_args), &b)
2329
+ end
2330
+ class << obj
2331
+ include WidgetEnhancer
1763
2332
  end
2333
+ return obj
1764
2334
  rescue RuntimeError => e
1765
2335
  Arcadia.runtime_error(e)
2336
+ return nil
1766
2337
  end
1767
2338
  end
1768
2339
 
2340
+ def checkbutton(_parent, _args={}, &b)
2341
+ begin
2342
+ if @use_tile
2343
+ obj = Tk::Tile::Checkbutton.new(_parent,{:style=>"Arcadia.TCheckbutton"}.update(_args), &b)
2344
+ else
2345
+ obj = TkCheckbutton.new(_parent,Arcadia.style('checkbox').update(_args), &b)
2346
+ end
2347
+ class << obj
2348
+ include WidgetEnhancer
2349
+ end
2350
+ return obj
2351
+ rescue RuntimeError => e
2352
+ Arcadia.runtime_error(e)
2353
+ return nil
2354
+ end
2355
+ end
2356
+
2357
+ def titlecontextcheckbutton(_parent, _args={}, &b)
2358
+ begin
2359
+ if @use_tile
2360
+ obj = Tk::Tile::Checkbutton.new(_parent,{:style=>"Arcadia.Title.TCheckbutton"}.update(_args), &b)
2361
+ else
2362
+ obj = TkCheckbutton.new(_parent,Arcadia.style('checkbox').update(_args), &b)
2363
+ end
2364
+ class << obj
2365
+ include WidgetEnhancer
2366
+ end
2367
+ return obj
2368
+ rescue RuntimeError => e
2369
+ Arcadia.runtime_error(e)
2370
+ return nil
2371
+ end
2372
+ end
2373
+
2374
+ def menu(_parent,_args={}, &b)
2375
+ begin
2376
+ obj = TkMenu.new(_parent, &b)
2377
+ if !OS.mac?
2378
+ obj.configure(Arcadia.style('menu').update(_args))
2379
+ obj.extend(TkAutoPostMenu)
2380
+ end
2381
+ return obj
2382
+ rescue RuntimeError => e
2383
+ Arcadia.runtime_error(e)
2384
+ return nil
2385
+ end
2386
+ end
2387
+
2388
+ def titlemenu(_parent,_args={}, &b)
2389
+ begin
2390
+ obj = TkMenu.new(_parent, &b)
2391
+ if !OS.mac?
2392
+ obj.configure(Arcadia.style('titlemenu').update(_args))
2393
+ obj.extend(TkAutoPostMenu)
2394
+ end
2395
+ return obj
2396
+ rescue RuntimeError => e
2397
+ Arcadia.runtime_error(e)
2398
+ return nil
2399
+ end
2400
+ end
2401
+
2402
+
1769
2403
  end
1770
2404
 
1771
2405
 
@@ -2174,4 +2808,562 @@ class KeyTest < TkFloatTitledFrame
2174
2808
  @ttest.extend(TkScrollableWidget).show
2175
2809
  place('x'=>100,'y'=>100,'height'=> 220,'width'=> 500)
2176
2810
  end
2811
+ end
2812
+
2813
+ class HinnerDialog < TkFrame
2814
+ def initialize(side='top',args=nil)
2815
+ newargs = Arcadia.style('panel').update({
2816
+ "highlightbackground" => Arcadia.conf('hightlight.link.foreground'),
2817
+ "highlightthickness" => 1
2818
+ })
2819
+ if !args.nil?
2820
+ newargs.update(args)
2821
+ end
2822
+ super(Arcadia.layout.parent_frame, newargs)
2823
+ case side
2824
+ when 'top'
2825
+ # self.pack('side' =>side,'before'=>Arcadia.layout.root, 'anchor'=>'nw','fill'=>'both', 'padx'=>0, 'pady'=>0, 'expand'=>'yes')
2826
+ self.pack('side' =>side,'before'=>Arcadia.layout.root, 'anchor'=>'nw','fill'=>'x', 'padx'=>0, 'pady'=>0)
2827
+ when 'bottom'
2828
+ self.pack('side' =>side,'after'=>Arcadia.layout.root, 'anchor'=>'nw','fill'=>'x', 'padx'=>0, 'pady'=>0)
2829
+ end
2830
+ @modal = false
2831
+ end
2832
+
2833
+ def is_modal?
2834
+ @modal
2835
+ end
2836
+
2837
+ def release
2838
+ @modal=false
2839
+ end
2840
+
2841
+ def show_modal(_destroy=true)
2842
+ @modal=true
2843
+ Tk.update
2844
+ self.grab("set")
2845
+ begin
2846
+ while is_modal? do
2847
+ Tk.update
2848
+ sleep(0.1)
2849
+ end
2850
+ ensure
2851
+ self.grab("release")
2852
+ end
2853
+ Tk.update
2854
+ self.destroy if _destroy
2855
+ end
2856
+ end
2857
+
2858
+
2859
+ class HinnerSplittedDialog < HinnerDialog
2860
+ attr_reader :frame, :splitter_frame
2861
+ def initialize(side='top', height=100, args=nil)
2862
+ super(side, args)
2863
+ y0 = height
2864
+ fr = TkFrame.new(self){
2865
+ height y0
2866
+ pack('side' =>side,'padx'=>0, 'pady'=>0, 'fill'=>'x', 'expand'=>'1')
2867
+ }
2868
+ splitter_frame = TkFrame.new(self, Arcadia.style('splitter')){
2869
+ height 5
2870
+ pack('side' =>side,'padx'=>0, 'pady'=>0, 'fill'=>'x', 'expand'=>'1')
2871
+ }
2872
+ oldcursor = splitter_frame.cget('cursor')
2873
+ tmpcursor = 'sb_v_double_arrow'
2874
+ yx=0
2875
+
2876
+ splitter_frame.bind_append("Enter", proc{|x, y|
2877
+ splitter_frame.configure('cursor'=> tmpcursor)
2878
+ } , "%x %y")
2879
+
2880
+ splitter_frame.bind_append("B1-Motion", proc{|x, y|
2881
+ yx=y
2882
+ splitter_frame.raise
2883
+ } ,"%x %y")
2884
+
2885
+ splitter_frame.bind_append("ButtonRelease-1", proc{|e|
2886
+ splitter_frame.configure('cursor'=> oldcursor)
2887
+ if side == 'top'
2888
+ h = (y0+yx).abs
2889
+ elsif side == 'bottom'
2890
+ h = (y0-yx).abs
2891
+ end
2892
+ y0 = h
2893
+ fr.configure('height'=>h)
2894
+ })
2895
+ @frame = fr
2896
+ @splitter_frame = splitter_frame
2897
+ end
2898
+ end
2899
+
2900
+ class HinnerSplittedDialogTitled < HinnerSplittedDialog
2901
+ attr_accessor :hinner_frame
2902
+ def initialize(title=nil, side='top', height=100, args=nil)
2903
+ super(side, height, args)
2904
+ btf = TkLabelTitledFrameClosable.new(self.frame, title).place('x'=>0, 'y'=>0,'relheight'=>1, 'relwidth'=>1)
2905
+ close = proc{
2906
+ self.destroy
2907
+ Tk.callback_break
2908
+ }
2909
+ btf.add_close_action(close)
2910
+ @hinner_frame = btf.frame
2911
+ end
2912
+ end
2913
+
2914
+ class HinnerFileDialog < HinnerDialog
2915
+ SELECT_FILE_MODE=0
2916
+ SAVE_FILE_MODE=1
2917
+ SELECT_DIR_MODE=2
2918
+ def initialize(mode=SELECT_FILE_MODE , must_exist = nil, side='top',args=nil)
2919
+ super(side, args)
2920
+ @mode = mode
2921
+ if must_exist.nil?
2922
+ must_exist = mode != SAVE_FILE_MODE
2923
+ end
2924
+ @must_exist = must_exist
2925
+ build_gui
2926
+ @closed = false
2927
+ end
2928
+
2929
+ def build_gui
2930
+ @font = Arcadia.conf('edit.font')
2931
+ @font_bold = "#{Arcadia.conf('edit.font')} bold"
2932
+ @font_metrics = TkFont.new(@font).metrics
2933
+ @font_metrics_bold = TkFont.new(@font_bold).metrics
2934
+ @dir_text = TkText.new(self, Arcadia.style('text').update({"height"=>'1',"highlightcolor"=>Arcadia.conf('panel.background'), "bg"=>Arcadia.conf('panel.background')})).pack('side' =>'left','padx'=>5, 'pady'=>5, 'fill'=>'x', 'expand'=>'1')
2935
+ #{"bg"=>'white', "height"=>'1', "borderwidth"=>0, 'font'=>@font}
2936
+ @dir_text.bind_append("Enter", proc{ @dir_text.set_insert("end")})
2937
+ #@dir_text.tag_configure("entry",'foreground'=> "red",'borderwidth'=>0, 'relief'=>'flat', 'underline'=>true)
2938
+
2939
+ @tag_file_exist = "file_exist"
2940
+ @dir_text.tag_configure(@tag_file_exist,'background'=> Arcadia.conf("hightlight.selected.background"), 'borderwidth'=>0, 'relief'=>'flat', 'underline'=>true)
2941
+
2942
+ @tag_selected = "link_selected"
2943
+ @dir_text.tag_configure(@tag_selected,'borderwidth'=>0, 'relief'=>'flat', 'underline'=>true)
2944
+ @dir_text.tag_bind(@tag_selected,"ButtonRelease-1", proc{
2945
+ self.release
2946
+ } )
2947
+ @dir_text.tag_bind(@tag_selected,"Enter", proc{@dir_text.configure('cursor'=> 'hand2')})
2948
+ @dir_text.tag_bind(@tag_selected,"Leave", proc{@dir_text.configure('cursor'=> @cursor)})
2949
+ _self=self
2950
+ @dir_text.bind_append('KeyPress'){|e|
2951
+ case e.keysym
2952
+ when 'Escape','Tab'
2953
+ i1 = @dir_text.index("insert")
2954
+ raise_candidates(i1, @dir_text.get("#{i1} linestart", i1))
2955
+ when "Return"
2956
+ if (@mode == SELECT_FILE_MODE || @mode == SAVE_FILE_MODE) && @must_exist
2957
+ str_file = @dir_text.get('1.0','end')
2958
+ if str_file && str_file.length > 0 && File.exists?(str_file.strip) && File.ftype(str_file.strip) == 'file'
2959
+ _self.release
2960
+ end
2961
+ Tk.callback_break
2962
+ elsif @mode == SELECT_DIR_MODE && @must_exist
2963
+ str_file = @dir_text.get('1.0','end')
2964
+ if str_file && str_file.length > 0 && File.exists?(str_file.strip) && File.ftype(str_file.strip) == 'directory'
2965
+ _self.release
2966
+ end
2967
+ Tk.callback_break
2968
+ else
2969
+ _self.release
2970
+ end
2971
+ end
2972
+ }
2973
+ @dir_text.bind_append('KeyRelease'){|e|
2974
+ case e.keysym
2975
+ when 'Escape','Tab', "Return"
2976
+ else
2977
+ @dir_text.tag_remove(@tag_selected,'1.0','end')
2978
+ i1 = @dir_text.index("insert - 1 chars wordstart")
2979
+ while @dir_text.get("#{i1} -1 chars",i1) != File::SEPARATOR && @dir_text.get("#{i1} - 1 chars",i1) != ""
2980
+ i1 = @dir_text.index("#{i1} - 1 chars")
2981
+ end
2982
+ i2 = @dir_text.index("insert")
2983
+
2984
+ @dir_text.tag_add(@tag_selected ,i1,i2) if @mode == SAVE_FILE_MODE
2985
+
2986
+ if File.exists?(@dir_text.get('1.0',i2))
2987
+ @dir_text.tag_add(@tag_file_exist ,i1,i2)
2988
+ @dir_text.tag_add(@tag_selected ,i1,i2) if @mode == SELECT_FILE_MODE && File.ftype(@dir_text.get('1.0',i2)) == 'file'
2989
+ @dir_text.tag_add(@tag_selected ,i1,i2) if @mode == SELECT_DIR_MODE && File.ftype(@dir_text.get('1.0',i2)) == 'directory'
2990
+ else
2991
+ @dir_text.tag_remove(@tag_file_exist,'1.0','end')
2992
+ end
2993
+ end
2994
+ }
2995
+
2996
+ @dir_text.bind_append("Control-KeyPress"){|e|
2997
+ case e.keysym
2998
+ when 'd'
2999
+ _self.close
3000
+ Tk.callback_break
3001
+ end
3002
+ }
3003
+
3004
+ #@select_button = Tk::BWidget::Button.new(self, Arcadia.style('toolbarbutton')){
3005
+ @select_button = Arcadia.wf.toolbutton(self){
3006
+ command proc{_self.close}
3007
+ image Arcadia.image_res(CLOSE_FRAME_GIF)
3008
+ }.pack('side' =>'right','padx'=>5, 'pady'=>0)
3009
+ end
3010
+
3011
+ def file(_dir)
3012
+ set_dir(_dir)
3013
+ show_modal(false)
3014
+ if @closed == false
3015
+ file_selected = @dir_text.get("0.1","end").strip
3016
+ destroy
3017
+ file_selected
3018
+ end
3019
+ end
3020
+
3021
+ def dir(_dir)
3022
+ file(_dir)
3023
+ end
3024
+
3025
+ def close
3026
+ @closed=true
3027
+ self.release
3028
+ destroy
3029
+ end
3030
+
3031
+ def set_dir(_dir)
3032
+ _dir=Dir.pwd if !File.exists?(_dir)
3033
+ #load_from_dir(_dir)
3034
+ @dir_text.state("normal")
3035
+ @dir_text.delete("0.1","end")
3036
+ @cursor = @dir_text.cget('cursor')
3037
+ dir_seg = _dir.split(File::SEPARATOR)
3038
+ incr_dir = ""
3039
+ get_dir = proc{|i|
3040
+ res = ""
3041
+ 0.upto(i){|j|
3042
+ if res == File::SEPARATOR
3043
+ res=res+dir_seg[j]
3044
+ elsif res.length == 0 && dir_seg[j].length == 0
3045
+ res=File::SEPARATOR+dir_seg[j]
3046
+ elsif res.length == 0 && dir_seg[j].length > 0
3047
+ res=dir_seg[j]
3048
+ else
3049
+ res=res+File::SEPARATOR+dir_seg[j]
3050
+ end
3051
+ }
3052
+ is_dir = File.ftype(res) == "directory"
3053
+ res=res+File::SEPARATOR if is_dir && res[-1..-1]!=File::SEPARATOR
3054
+ res
3055
+ }
3056
+
3057
+ dir_seg.each_with_index{|seg,i|
3058
+ tag_name = "link#{i}"
3059
+ @dir_text.tag_configure(tag_name,'foreground'=> Arcadia.conf('hightlight.link.foreground'),'borderwidth'=>0, 'relief'=>'flat', 'underline'=>true)
3060
+
3061
+ dir = get_dir.call(i)
3062
+ if File.ftype(dir) == "directory"
3063
+ @dir_text.insert("end", seg, tag_name)
3064
+ @dir_text.insert("end", "#{File::SEPARATOR}")
3065
+ @dir_text.tag_bind(tag_name,"ButtonRelease-1", proc{
3066
+ inx = @dir_text.index("insert wordend +1 chars")
3067
+ @dir_text.set_insert("end")
3068
+ raise_candidates(inx, dir)
3069
+ } )
3070
+ @dir_text.tag_bind(tag_name,"Enter", proc{@dir_text.configure('cursor'=> 'hand2')})
3071
+ @dir_text.tag_bind(tag_name,"Leave", proc{@dir_text.configure('cursor'=> @cursor)})
3072
+ else
3073
+ @dir_text.insert("end", seg, @tag_selected)
3074
+ end
3075
+ }
3076
+
3077
+ @dir_text.focus
3078
+ @dir_text.set_insert("end")
3079
+ @dir_text.see("end")
3080
+ end
3081
+
3082
+ def raise_candidates(_inx, _dir)
3083
+ if _dir[-1..-1] != File::SEPARATOR && _dir !=nil && _dir.length > 0
3084
+ len = _dir.split(File::SEPARATOR)[-1].length+1
3085
+ _dir = _dir[0..-len]
3086
+ _inx = "#{_inx} - #{len-1} chars"
3087
+ end
3088
+ _dir=Dir.pwd if !File.exists?(_dir)
3089
+ @dir_text.set_insert("end")
3090
+ dirs_and_files=load_from_dir(_dir)
3091
+ if dirs_and_files[0].length + dirs_and_files[1].length == 1
3092
+ if dirs_and_files[0].length == 1
3093
+ one = "#{_dir}#{dirs_and_files[0][0]}"
3094
+ else
3095
+ one = "#{_dir}#{dirs_and_files[1][0]}"
3096
+ end
3097
+ set_dir(one)
3098
+ elsif dirs_and_files[0].length + dirs_and_files[1].length == 0
3099
+ # do not raise
3100
+ else
3101
+ if @mode == SELECT_DIR_MODE
3102
+ raise_dir(_inx, _dir, dirs_and_files[0], [])
3103
+ else
3104
+ raise_dir(_inx, _dir, dirs_and_files[0], dirs_and_files[1])
3105
+ end
3106
+ end
3107
+ Tk.callback_break
3108
+ end
3109
+
3110
+ def last_candidate_is_file?(_name)
3111
+ @last_candidates_file && @last_candidates_file.include?(_name)
3112
+ end
3113
+
3114
+ def last_candidate_is_dir?(_name)
3115
+ @last_candidates_dir && @last_candidates_dir.include?(_name)
3116
+ end
3117
+
3118
+ def raise_dir(_index, _dir, _candidates_dir, _candidates_file=nil)
3119
+ @raised_listbox_frame.destroy if @raised_listbox_frame != nil
3120
+ @last_candidates_dir = _candidates_dir
3121
+ @last_candidates_file = _candidates_file
3122
+ _index_now = @dir_text.index('insert')
3123
+ _index_for_raise = @dir_text.index("#{_index} wordstart")
3124
+ _candidates = []
3125
+ _candidates.concat(_candidates_dir) if _candidates_dir
3126
+ _candidates.concat(_candidates_file) if _candidates_file
3127
+
3128
+ if _candidates.length >= 1
3129
+ _rx, _ry, _width, heigth = @dir_text.bbox(_index_for_raise);
3130
+ _x = _rx + TkWinfo.rootx(@dir_text)
3131
+ _y = _ry + TkWinfo.rooty(@dir_text) + @font_metrics[2][1]
3132
+ _xroot = _x
3133
+ _yroot = _y
3134
+
3135
+ max_width = TkWinfo.screenwidth(Arcadia.layout.root) - _x
3136
+
3137
+ @raised_listbox_frame = TkFrame.new(Arcadia.layout.root, {
3138
+ :padx=>"1",
3139
+ :pady=>"1",
3140
+ :background=> "yellow"
3141
+ })
3142
+
3143
+ @raised_listbox = TkTextListBox.new(@raised_listbox_frame, {
3144
+ :takefocus=>true}.update(Arcadia.style('listbox')))
3145
+ @raised_listbox.tag_configure('file','foreground'=> Arcadia.conf('hightlight.link.foreground'),'borderwidth'=>0, 'relief'=>'flat')
3146
+
3147
+
3148
+ _char_height = @font_metrics[2][1]
3149
+ _width = 0
3150
+ _docs_entries = Hash.new
3151
+ _item_num = 0
3152
+
3153
+ _select_value = proc{
3154
+ if @raised_listbox.selected_line && @raised_listbox.selected_line.strip.length>0
3155
+ #_value = @raised_listbox.selected_line.split('-')[0].strip
3156
+ seldir = File.join(_dir,@raised_listbox.selected_line)
3157
+
3158
+ set_dir(seldir)
3159
+ @raised_listbox_frame.grab("release")
3160
+ @raised_listbox_frame.destroy
3161
+ end
3162
+ }
3163
+
3164
+ _update_list = proc{|_in|
3165
+ _in.strip!
3166
+ @raised_listbox.clear
3167
+ _length = 0
3168
+ _candidates.each{|value|
3169
+ _doc = value.strip
3170
+ _class, _key, _arity = _doc.split('#')
3171
+ if _key && _arity
3172
+ args = arity_to_str(_arity.to_i)
3173
+ if args.length > 0
3174
+ _key = "#{_key}(#{args})"
3175
+ end
3176
+ end
3177
+
3178
+ if _key && _class && _key.strip.length > 0 && _class.strip.length > 0
3179
+ _item = "#{_key.strip} #{TkTextListBox::SEP} #{_class.strip}"
3180
+ elsif _key && _key.strip.length > 0
3181
+ _item = "#{_key.strip}"
3182
+ else
3183
+ _key = "#{_doc.strip}"
3184
+ _item = "#{_doc.strip}"
3185
+ end
3186
+ array_include = proc{|_a, _str, _asterisk_first_char|
3187
+ ret = true
3188
+ str = _str
3189
+ _a.each_with_index{|x, j|
3190
+ next if x.length == 0
3191
+ if j == 0 && !_asterisk_first_char
3192
+ ret = ret && str[0..x.length-1] == x
3193
+ else
3194
+ ret = ret && str.include?(x)
3195
+ end
3196
+ if ret
3197
+ i = str.index(x)
3198
+ str = str[i+x.length..-1]
3199
+ else
3200
+ break
3201
+ end
3202
+ }
3203
+ ret
3204
+ }
3205
+ if _in.nil? || _in.strip.length == 0 || _item[0.._in.length-1] == _in ||
3206
+ (_in.include?('*') && array_include.call(_in.split("*"), _item, _in[0..1]=='*'))
3207
+ # (_in[0..0] == '*' && _item.include?(_in[1..-1]))
3208
+
3209
+ _docs_entries[_item]= _doc
3210
+ # @raised_listbox.insert('end', _item)
3211
+ if last_candidate_is_dir?(_item)
3212
+ @raised_listbox.add(_item, 'file')
3213
+ else
3214
+ @raised_listbox.add(_item)
3215
+ end
3216
+ _temp_length = _item.length
3217
+ _length = _temp_length if _temp_length > _length
3218
+ _item_num = _item_num+1
3219
+ _last_valid_key = _key
3220
+ end
3221
+ }
3222
+ _width = _length*8
3223
+ if @raised_listbox.length == 0
3224
+ @raised_listbox.grab("release")
3225
+ @raised_listbox_frame.destroy
3226
+ @dir_text.focus
3227
+ Tk.callback_break
3228
+ #Tk.event_generate(@raised_listbox, "KeyPress" , :keysym=>"Escape") if TkWinfo.mapped?(@raised_listbox)
3229
+ else
3230
+ @raised_listbox.select(1)
3231
+ Tk.event_generate(@raised_listbox, "1") if TkWinfo.mapped?(@raised_listbox)
3232
+ end
3233
+ }
3234
+
3235
+ get_filter = proc{
3236
+ filter = ""
3237
+ if @dir_text.get("insert -1 chars", "insert") != File::SEPARATOR
3238
+ file_str = @dir_text.get("insert linestart", "insert")
3239
+ parts = file_str.split(File::SEPARATOR)
3240
+ if _dir == File::SEPARATOR
3241
+ original_parts = [""]
3242
+ else
3243
+ original_parts = _dir.split(File::SEPARATOR)
3244
+ end
3245
+ if parts && parts.length == original_parts.length + 1
3246
+ filter = parts[-1]
3247
+ end
3248
+ end
3249
+ filter = "" if filter.nil?
3250
+ filter
3251
+ }
3252
+ #filter = @dir_text.get("insert -1 chars wordstart", "insert")
3253
+
3254
+
3255
+ @raised_listbox.bind_append('KeyPress'){|e|
3256
+ is_list_for_update = false
3257
+ case e.keysym
3258
+ when 'a'..'z','A'..'Z','0'..'9'
3259
+ @dir_text.insert('end', e.keysym)
3260
+ @dir_text.see("end")
3261
+ is_list_for_update = true
3262
+ when 'minus'
3263
+ @dir_text.insert('end', e.char)
3264
+ @dir_text.see("end")
3265
+ is_list_for_update = true
3266
+ when 'period'
3267
+ @dir_text.insert('end', '.')
3268
+ @dir_text.see("end")
3269
+ is_list_for_update = true
3270
+ when 'BackSpace'
3271
+ if @dir_text.get("insert -1 chars", "insert") != File::SEPARATOR
3272
+ @dir_text.delete('end -2 chars','end')
3273
+ end
3274
+ is_list_for_update = true
3275
+ when 'Escape'
3276
+ @raised_listbox.grab("release")
3277
+ @raised_listbox_frame.destroy
3278
+ @dir_text.focus
3279
+ Tk.callback_break
3280
+ when "Next","Prior"
3281
+ when "Down","Up"
3282
+ Tk.callback_break
3283
+ else
3284
+ Tk.callback_break
3285
+ end
3286
+ _update_list.call(get_filter.call) if is_list_for_update
3287
+ @raised_listbox.focus
3288
+ Tk.callback_break if !["Next","Prior"].include?(e.keysym)
3289
+ }
3290
+
3291
+ @raised_listbox.bind_append('Shift-KeyPress'){|e|
3292
+ is_list_for_update = false
3293
+ case e.keysym
3294
+ when 'asterisk','underscore'
3295
+ @dir_text.insert('end', e.char)
3296
+ @dir_text.see("end")
3297
+ is_list_for_update = true
3298
+ when 'a'..'z','A'..'Z'
3299
+ @dir_text.insert('end', e.keysym)
3300
+ @dir_text.see("end")
3301
+ is_list_for_update = true
3302
+
3303
+ end
3304
+ _update_list.call(get_filter.call) if is_list_for_update
3305
+ @raised_listbox.focus
3306
+ Tk.callback_break
3307
+ }
3308
+
3309
+ @raised_listbox.bind_append('KeyRelease'){|e|
3310
+ case e.keysym
3311
+ when 'Return'
3312
+ _select_value.call
3313
+ end
3314
+ }
3315
+
3316
+ _update_list.call(get_filter.call)
3317
+
3318
+ if @raised_listbox.length == 1
3319
+ _select_value.call
3320
+ else
3321
+ _width = _width + 30
3322
+ _width = max_width if _width > max_width
3323
+ _height = 15*_char_height
3324
+
3325
+ @raised_listbox_frame.place('x'=>_x,'y'=>_ry, 'width'=>_width, 'height'=>_height)
3326
+ @raised_listbox.extend(TkScrollableWidget).show(0,0)
3327
+ @raised_listbox.place('x'=>0,'y'=>0, 'relwidth'=>1, 'relheight'=>1)
3328
+ @raised_listbox.focus
3329
+ @raised_listbox.select(1)
3330
+
3331
+ Tk.update
3332
+ @raised_listbox_frame.grab("set")
3333
+
3334
+
3335
+
3336
+ @raised_listbox.bind_append("Double-ButtonPress-1",
3337
+ proc{|x,y|
3338
+ _select_value.call
3339
+ Tk.callback_break
3340
+ }, "%x %y")
3341
+
3342
+ end
3343
+ elsif _candidates.length == 1 && _candidates[0].length>0
3344
+ @dir_text.set_dir(_candidates[0])
3345
+ end
3346
+ end
3347
+
3348
+
3349
+ def load_from_dir(_dir)
3350
+ childrens = Dir.entries(_dir)
3351
+ childrens_dir = Array.new
3352
+ childrens_file = Array.new
3353
+ childrens.sort.each{|c|
3354
+ if c != '.' && c != '..'
3355
+ child = File.join(_dir,c)
3356
+ fty = File.ftype(child)
3357
+ if fty == "file"
3358
+ childrens_file << c
3359
+ #childrens_file << child
3360
+ elsif fty == "directory"
3361
+ #childrens_dir << child
3362
+ childrens_dir << c
3363
+ end
3364
+ end
3365
+ }
3366
+ return childrens_dir,childrens_file
3367
+ end
3368
+
2177
3369
  end