00001 # Copyright (C) 1997-2004 The CDG Team <cdg@nats.informatik.uni-hamburg.de> 00002 # 00003 # This file is free software; as a special exception the author gives 00004 # unlimited permission to copy and/or distribute it, with or without 00005 # modifications, as long as this notice is preserved. 00006 # 00007 # This program is distributed in the hope that it will be useful, but 00008 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the 00009 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00010 00011 ## ---------------------------------------------------------------------------- 00012 ## CdgPrefs - a preference dialog 00013 ## 00014 ## \author Michael Daum (see also AUTHORS and THANKS for more) 00015 ## $Id: prefs.tcl,v 1.12 2004/02/25 14:40:42 micha Exp $ 00016 ## ---------------------------------------------------------------------------- 00017 class CdgPrefs { 00018 inherit iwidgets::Dialog 00019 00020 # public methods 00021 public method activate {} 00022 00023 constructor {args} {}; ## \type TclList 00024 00025 # private methods 00026 private method _ok_action {} 00027 private method _getData {} 00028 private method _setData {} 00029 00030 # private variables 00031 00032 ## prefenrence-data mirrored from CdgMain 00033 private variable _preferences ;## \type TclArray 00034 }; 00035 00036 ## ---------------------------------------------------------------------------- 00037 ## constructor 00038 ## ---------------------------------------------------------------------------- 00039 body CdgPrefs::constructor {args} { 00040 00041 hide Apply 00042 hide Help 00043 buttonconfigure OK -command [code $this _ok_action] 00044 00045 set child [childsite] 00046 00047 itk_component add grammarpath { 00048 iwidgets::entryfield $child.grammarpath \ 00049 -labeltext "Grammar-Path: "\ 00050 -labelpos w \ 00051 -textvariable [scope _preferences(grammarpath)] 00052 } {} 00053 00054 itk_component add editor { 00055 iwidgets::entryfield $child.editor \ 00056 -labeltext "Editor: "\ 00057 -labelpos w \ 00058 -textvariable [scope _preferences(editor)] 00059 } {} 00060 00061 iwidgets::Labeledwidget::alignlabels \ 00062 $itk_component(grammarpath) \ 00063 $itk_component(editor) 00064 00065 pack $itk_component(grammarpath) \ 00066 $itk_component(editor) \ 00067 -side top -expand 1 -fill both -padx 5 -pady 5 00068 00069 00070 eval itk_initialize $args 00071 } 00072 00073 ## ---------------------------------------------------------------------------- 00074 ## involved by buttonpress on ok-button 00075 ## ---------------------------------------------------------------------------- 00076 body CdgPrefs::_ok_action {} { 00077 _setData 00078 deactivate 00079 } 00080 00081 00082 ## ---------------------------------------------------------------------------- 00083 ## init data, start dialog 00084 ## ---------------------------------------------------------------------------- 00085 body CdgPrefs::activate {} { 00086 center . 00087 _getData 00088 Shell::activate 00089 } 00090 00091 ## ---------------------------------------------------------------------------- 00092 ## refresh _preferences from main 00093 ## ---------------------------------------------------------------------------- 00094 body CdgPrefs::_getData {} { 00095 set _preferences(grammarpath) [.cdgmain cget -grammarpath] 00096 set _preferences(editor) [.cdgmain cget -editor] 00097 } 00098 00099 ## ---------------------------------------------------------------------------- 00100 ## set configurations 00101 ## ---------------------------------------------------------------------------- 00102 body CdgPrefs::_setData {} { 00103 .cdgmain configure -grammarpath $_preferences(grammarpath) 00104 .cdgmain configure -editor $_preferences(editor) 00105 }