source: tol/tolbase/lib/byswidget/bdialog/bdialog.tcl @ 6d7779d

1941-docker-image-to-testdevel
Last change on this file since 6d7779d was 6d7779d, checked in by Jorge Pérez <josp.jorge@…>, 18 years ago

initial import

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 3.8 KB
Line 
1#/////////////////////////////////////////////////////////////////////////////
2# FILE    : bdialog.tcl
3# PURPOSE : Bayes Dialog. Dialog con opciones
4#/////////////////////////////////////////////////////////////////////////////
5
6
7package require byscommon
8package require BWidget
9
10
11#/////////////////////////////////////////////////////////////////////////////
12::snit::widgetadaptor bdialog {
13#
14# PURPOSE: Sobrecargamos un dialog para que tenga nuevas funcionalidades
15#
16#/////////////////////////////////////////////////////////////////////////////
17# opciones especificas 
18# iniconfig -> Nombre que se asigna al dialog para identificar sus opciones
19#           en el archivo de configuración .ini por defecto "" en ese caso
20#           no se guardaran las opciones
21#/////////////////////////////////////////////////////////////////////////////
22  option -iniconfig    ""
23  option -closecmd    ""
24
25
26  #///////////////////////////////////////////////////////////////////////////
27  constructor {args} {
28  #
29  # PURPOSE: Constructor de un bdialog. Crea una instancia de un Dialog
30  #
31  # PARAMETERS:
32  #   args -> Lista de opciones especificas de un Dialog, mas las propias de
33  #           un Dialog
34  #
35  #///////////////////////////////////////////////////////////////////////////
36    # Widget que va a servir de contenedor para bdialog
37    installhull [Dialog $self]
38    # Apply all arguments given:
39    $self configurelist $args
40    # Destroy
41    wm protocol $self WM_DELETE_WINDOW [list [codename Destroy] $self]
42    # .ini
43    ReadIni $self
44  }
45 
46  #/////////////////////////////////////////////////////////////////////////// 
47  destructor {
48  #
49  # PURPOSE: Destructor o bdialog.
50  #
51  #///////////////////////////////////////////////////////////////////////////   
52    Destroy $self
53  }
54 
55  #///////////////////////////////////////////////////////////////////////////
56  proc Destroy { self } {
57  #
58  # PURPOSE: Funciones a evaluar al cerrar un toplevel. Si no tiene
59  #          procedimento propio se asume que se desea destruir el toplevel
60  #
61  #
62  #///////////////////////////////////////////////////////////////////////////
63    # Save .ini
64    WriteIni $self
65    # destroy
66    # destroy
67    set cmd [$self cget -closecmd]
68    if {[string length $cmd]} {
69       eval $cmd
70    } else  {
71      destroy $self
72    }
73  }
74   
75
76
77  #///////////////////////////////////////////////////////////////////////////
78  proc WriteIni { self } {
79  #
80  # PURPOSE: Guarda en el .ini informacion referente al dialog
81  #
82  #///////////////////////////////////////////////////////////////////////////
83    if { [$self cget -iniconfig] ne "" } {
84      # comprobamos cargado namespace y variable de .ini
85      if {[namespace exists ::iniFile]} {
86        set wini ::iniFile::Write
87        set nm [$self cget -iniconfig]
88        if {![string length $nm]} {
89          set nm $self
90        }
91        $wini $nm geometry [wm geometry $self]
92      }
93    }
94  }
95
96
97  #///////////////////////////////////////////////////////////////////////////
98  proc ReadIni { self } {
99  #
100  # PURPOSE: Recupera del .ini informacion referente al dialog
101  #
102  #///////////////////////////////////////////////////////////////////////////
103    if { [$self cget -iniconfig] ne "" } {
104      # comprobamos cargado namespace y variable de .ini
105      if {[namespace exists ::iniFile]} {
106        set rini ::iniFile::Read
107        set nm [$self cget -iniconfig]
108        if {![string length $nm]} {
109          set nm $self
110        }
111        set stt [::iniFile::ReadWMState $rini $nm]
112        set gem [$rini $nm geometry ""]       
113        if {[string length $gem]} {
114             $self configure -geometry $gem
115             wm geometry $self $gem
116        }
117      }
118    }
119  } 
120 
121  # delegacion de metodos y opciones
122  delegate method * to hull
123  delegate option * to hull
124}
125
126package provide bdialog 1.0
Note: See TracBrowser for help on using the repository browser.