source: tol/tolbaseBLT/lib/byswidget/bfunctions/bfmessages.tcl @ 56ade3b

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

fixes #1932, se ha creado la rama trunk/tolbaseBLT copia de trunk/tolbase

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

  • Property mode set to 100644
File size: 4.5 KB
Line 
1#/////////////////////////////////////////////////////////////////////////////
2# FILE    : bfMessages
3# PURPOSE : Functions of messages of TolBase to users or external applications
4#
5#/////////////////////////////////////////////////////////////////////////////
6
7#/////////////////////////////////////////////////////////////////////////////
8proc ShowMessage { type msg parent {useMessageBox 1} } {
9#
10# PURPOSE: Shows a message with an pop-up window and in the HciWriter
11#          depending on its type
12#
13# PARAMETERS:
14#   type -> Type of the message ("E": Error, "W": Warning, o "M": Message)
15#   msg -> Text to show
16#   parent -> Widget that generates the message
17#   useMessageBox -> If has a value 0, don't show the messageBox. 1 by default
18#
19#/////////////////////////////////////////////////////////////////////////////
20  switch $type {
21    E {
22      if {$useMessageBox} {
23        tk_messageBox -type ok -icon error\
24          -message [mc $msg]\
25          -parent $parent -title [mc Error]
26      }
27      set msg [concat "<E>[mc ERROR]:" [mc $msg] "</E>"]
28      ::TolConsole::HciWriter $msg
29    }
30    W {
31      if {$useMessageBox} {     
32        tk_messageBox -type ok -icon warning\
33           -message [mc $msg]\
34           -parent $parent -title [mc Warning]
35      }
36      set msg [concat "<W>[mc WARNING]:" [mc $msg] "</W>"]
37      ::TolConsole::HciWriter $msg
38    }
39    M {
40      if {$useMessageBox} {
41        tk_messageBox -type ok -icon info\
42          -message [mc $msg]\
43          -parent $parent -title [mc Message]
44      }
45      set msg [concat "[mc MESSAGE]:" [mc $msg] ]
46      ::TolConsole::HciWriter $msg
47    }
48  } ;# switch
49}
50
51#/////////////////////////////////////////////////////////////////////////////
52proc ShowBrowserPage { page {section ""} } {
53#
54# PURPOSE: Shows a web page on the internet browser. If this option isn't
55#          established it uses the default browser under windows and allows to
56#          select it in linux.
57#
58# PARAMETERS:
59#   page -> Page to open
60#   section -> Section of the page (optional)
61#
62#/////////////////////////////////////////////////////////////////////////////
63  set rini ::iniFile::Read
64  set pathBrowser  [$rini TolConsole pathBrowser {}]
65  if {[llength $pathBrowser] eq 0 } { ;#pathBrowser isn't established
66    if { $::tcl_platform(platform) == "windows" } {
67      ShowMessage "W" \
68        [mc "The path of the internet browser isn't established, using the default Windows browser"] \
69        "." 0
70      eval exec [auto_execok start] [list $page] &
71    } else { ;# linux
72      ShowMessage "E" \
73        [mc "The path of the internet browser isn't established"] \
74        "." 0
75      ::TolConsole::OptionsCreate "Paths"
76    }
77  } else {
78    if {$section eq ""} { ;# this page hasn't section
79      exec $pathBrowser $page &
80    } else {
81      exec $pathBrowser $page $section &
82    }
83  }
84}
85
86#/////////////////////////////////////////////////////////////////////////////
87proc ShowPDFDocument { path } {
88#
89# PURPOSE: Shows a PDF document on the internet browser. If this option isn't
90#          established allows to select it in linux.
91#
92# PARAMETERS:
93#   path -> path to PDF document
94#
95#/////////////////////////////////////////////////////////////////////////////
96  set rini ::iniFile::Read
97  set pathPDFViewer  [$rini TolConsole pathPDFViewer {}]
98  if {[llength $pathPDFViewer] eq 0 } { ;#pathPDFViewer isn't established
99    ShowMessage "E" [mc "The path of the PDF wiewer isn't established"] "." 0
100    ::TolConsole::OptionsCreate "Paths"
101  } else {
102    exec $pathPDFViewer $path &
103  }
104}
105
106#/////////////////////////////////////////////////////////////////////////////
107proc ShowHelp { {section "Tb4Mai"} } {
108#
109# PURPOSE: Constructs the absolute path of the help and launch the browser.
110#
111# PARAMETERS:
112#  section -> section of the help. By default "Tb4Mai" (Tolbase4 Main)
113#
114#/////////////////////////////////////////////////////////////////////////////
115  global toltk_options
116
117  set rini ::iniFile::Read
118  set pathHelp  [$rini TolConsole pathHelp {}]
119  if { ([file isdirectory $pathHelp]) && \
120       ([file isfile [file join $pathHelp "pathhelp.bst"]]) } {
121    set page [GetUniqueName Text _helpPage]
122    set cmd "Text $page = GetDirHelpSection(\"$pathHelp\",\"$section\");"
123    ::tol::console eval $cmd
124    array set info [TclInfoVar Text $page]
125    eval "set path $info(CONTENT)"
126    ::tol::console stack release $page
127    ShowBrowserPage $path
128  } else {
129    ShowMessage "E" \
130        [mc "The path of the help isn't correctly established"] \
131        "." 0
132      ::TolConsole::OptionsCreate "Paths"
133  }
134}
Note: See TracBrowser for help on using the repository browser.