TKE  3.6
Advanced code editor for programmers
api::preferences Namespace Reference

Functions

 widget interp pname type win args
 
 get_value interp pname varname
 

Function Documentation

§ get_value()

api::preferences::get_value   interp pname varname  

Definition at line 1058 of file api.tcl.

1058  proc get_value {interp pname varname} {
1059 
1060  return $preferences::prefs(Plugins/$pname/$varname)
1061 
1062  }

§ widget()

api::preferences::widget   interp pname type win args  

Returns a references to a widget created for the preferences window.

Returns
Returns the pathname of the widget to pack.
Parameters
typeSpecifies the type of widget to create. (Legal values are: checkbutton, radiobutton, menubutton, emtry, text, spinbox)
winPathname of parent window to add widgets to.
prefName of preference value associated with the widget.
msgLabel text to associate with the widget (this text is searchable.
argsFor all widget types that are not "spacer", the first arg must be the name of the preference value associated with the widget, the second arg must be a label to associated with the widget (this text is searchable), the rest of the arguments provide additional information required by the widget.

Definition at line 947 of file api.tcl.

947  proc widget {interp pname type win args} {
948 
949  # Figure out a unique identifier for the widget within the parent frame
950  set index [llength [winfo children $win]]
951 
952  array set opts {
953  -grid 0
954  }
955 
956  switch $type {
957  spacer {
958  array set opts $args
959  return [pref_ui::make_spacer $win $opts(-grid)]
960  }
961  help {
962  if {([llength $args] < 1) || (([llength $args] % 2) == 0)} {
963  return -code error "api::preferences::widget $type sent an incorrect number of parameters"
964  }
965  set args [lassign $args msg]
966  array set opts $args
967  return [pref_ui::make_help $win $msg $opts(-grid)]
968  }
969  default {
970 
971  if {([llength $args] < 2) || (([llength $args] % 2) == 1)} {
972  return -code error "api::preferences::widget $type sent an incorrect number of parameters"
973  }
974 
975  set args [lassign $args pref msg]
976 
977  array set opts {
978  -value ""
979  -values ""
980  -grid 0
981  -from ""
982  -to ""
983  -increment 1
984  -ending ""
985  -color "white"
986  -height 4
987  -columns ""
988  -watermark ""
989  -help ""
990  }
991  array set opts $args
992 
993  # Calculate the full preference pathname
994  set pref_path "Plugins/$pname/$pref"
995 
996  # Make sure that the preference was loaded prior to creating the UI
997  if {![info exists [preferences::ref $pref_path]]} {
998  return -code error "Plugin preference $pref for $pname not previously loaded"
999  }
1000 
1001  switch $type {
1002  checkbutton {
1003  return [pref_ui::make_cb $win.cb$index $msg Plugins/$pname/$pref $opts(-grid)]
1004  }
1005  radiobutton {
1006  if {$opts(-value) eq ""} {
1007  return -code error "Radiobutton widget must have -value option set"
1008  }
1009  return [pref_ui::make_rb $win.rb$index $msg Plugins/$pname/$pref $opts(-value) $opts(-grid)]
1010  }
1011  menubutton {
1012  if {$opts(-values) eq ""} {
1013  return -code error "Menubutton widget must have -values option set"
1014  }
1015  return [pref_ui::make_mb $win.mb$index $msg Plugins/$pname/$pref $opts(-values) $opts(-grid)]
1016  }
1017  entry {
1018  return [pref_ui::make_entry $win.e$index $msg Plugins/$pname/$pref $opts(-grid) $opts(-help)]
1019  }
1020  token {
1021  return [pref_ui::make_token $win.te$index $msg Plugins/$pname/$pref $opts(-watermark) $opts(-grid) $opts(-help)]
1022  }
1023  text {
1024  return [pref_ui::make_text $win.t$index $msg Plugins/$pname/$pref $opts(-height) $opts(-grid) $opts(-help)]
1025  }
1026  spinbox {
1027  if {$opts(-from) eq ""} {
1028  return -code error "Spinbox widget must have -from option set"
1029  }
1030  if {$opts(-to) eq ""} {
1031  return -code error "Spinbox widget must have -to option set"
1032  }
1033  return [pref_ui::make_sb $win.sb$index $msg Plugins/$pname/$pref $opts(-from) $opts(-to) $opts(-increment) $opts(-grid) $opts(-ending)]
1034  }
1035  colorpicker {
1036  return [pref_ui::make_cp $win.cp$index $msg Plugins/$pname/$pref $opts(-color) $opts(-grid)]
1037  }
1038  table {
1039  if {$opts(-columns) eq ""} {
1040  return -code error "Table widget must have -columns option set"
1041  }
1042  return [pref_ui::make_table $win.tl$index $msg Plugins/$pname/$pref $opts(-columns) $opts(-height) $opts(-grid) $opts(-help)]
1043  }
1044  default {
1045  return -code error "Unsupported preference widget type ($type)"
1046  }
1047  }
1048 
1049  }
1050  }
1051 
1052  }