Check-in [fb70bdbca2]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Automatically resize the tabs header when changing the gui font. (CVS 1260)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:fb70bdbca26371be25f36a1e93f95c7f426732ba
User & Date: danielk1977 2008-02-03 17:53:26
Context
2008-02-04
04:42
Add new downloads to the top of the list, not the bottom. (CVS 1261) check-in: ba840d6874 user: danielk1977 tags: trunk
2008-02-03
17:53
Automatically resize the tabs header when changing the gui font. (CVS 1260) check-in: fb70bdbca2 user: danielk1977 tags: trunk
11:19
Fix some javascript problems. (CVS 1259) check-in: 0f9ea1c484 user: danielk1977 tags: trunk
Changes

Changes to hv/hv3_notebook.tcl.

1
2
3
4
5
6
7
8
..
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
..
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
...
174
175
176
177
178
179
180


181
182
183
184
185
186
187
188
...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
...
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
namespace eval hv3 { set {version($Id: hv3_notebook.tcl,v 1.9 2008/02/02 17:15:02 danielk1977 Exp $)} 1 }

# This file contains the implementation of three snit widgets:
#
#     ::hv3::notebook_header
#     ::hv3::notebook
#     ::hv3::tabset
#
................................................................................

  # List of identifiers in display order from left to right.
  variable myIdList ""
  
  # Map from current identifiers to display titles.
  variable myIdMap -array [list]

  variable myTabHeight 0

  proc init_bitmaps {} {

    # Set up the two images used for the "close tab" buttons positioned
    # on the tabs themselves. The image data was created by me using an 
    # archaic tool called "bitmap" that was installed with fedora.
    #
    set BitmapData {
................................................................................
    canvas ${win}.tabs
    ${win}.tabs configure -borderwidth 0
    ${win}.tabs configure -highlightthickness 0
    ${win}.tabs configure -selectborderwidth 0

    init_bitmaps

    set myTabHeight [expr [font metrics Hv3DefaultFont -linespace] * 1.5]

    $self configurelist $args

    bind ${win}.tabs <Configure> [list $self Redraw]
    place ${win}.tabs -relwidth 1.0 -relheight 1.0
    $hull configure -height 0
  }

................................................................................
  method RedrawCallback {} {
    # Optimization: When there is only one tab in the list, do not bother
    # to draw anything. It won't be visible anyway.
    if {[array size myIdMap]<=1} {
      $hull configure -height 1
      return
    }


    $hull configure -height $myTabHeight

    set font Hv3DefaultFont

    set iPadding  2
    set iDiagonal 2
    set iButton   14
    set iCanvasWidth [expr [winfo width ${win}.tabs] - 2]
................................................................................
    # If the myIdList is empty, there are no tabs to draw.
    set myRedrawScheduled 0
    if {[llength $myIdList] == 0} return

    set iRemainingTabs [llength $myIdList]
    set iRemainingPixels $iCanvasWidth

    set yt [expr 0.5 * ($myTabHeight + [font metrics $font -linespace])]
    set x 1
    foreach ident $myIdList {

      set zTitle $myIdMap($ident)

      set  iTabWidth [expr $iRemainingPixels / $iRemainingTabs]
      incr iRemainingTabs -1
................................................................................
        set zTitle "[string range $zTitle 0 [expr $n - 1]]..."
      }

      set x2 [expr $x + $iDiagonal]
      set x3 [expr $x + $iTabWidth - $iDiagonal - 1]
      set x4 [expr $x + $iTabWidth - 1]

      set y1 [expr $myTabHeight - 0]
      set y2 [expr $iDiagonal + 1]
      set y3 1

      set ximg [expr $x + $iTabWidth - $iDiagonal - $iButton - 1]
      set yimg [expr 1 + ($myTabHeight - $iButton) / 2]

      ${win}.tabs create polygon \
          $x $y1 $x $y2 $x2 $y3 $x3 $y3 $x4 $y2 $x4 $y1 -tags $ident

      ${win}.tabs create text [expr $x2 + $iPadding] $yt \
          -anchor sw -text $zTitle -font $font -tags $ident

|







 







<
<







 







<
<







 







>
>
|







 







|







 







|




|







1
2
3
4
5
6
7
8
..
41
42
43
44
45
46
47


48
49
50
51
52
53
54
..
68
69
70
71
72
73
74


75
76
77
78
79
80
81
...
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
...
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
...
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
namespace eval hv3 { set {version($Id: hv3_notebook.tcl,v 1.10 2008/02/03 17:53:26 danielk1977 Exp $)} 1 }

# This file contains the implementation of three snit widgets:
#
#     ::hv3::notebook_header
#     ::hv3::notebook
#     ::hv3::tabset
#
................................................................................

  # List of identifiers in display order from left to right.
  variable myIdList ""
  
  # Map from current identifiers to display titles.
  variable myIdMap -array [list]



  proc init_bitmaps {} {

    # Set up the two images used for the "close tab" buttons positioned
    # on the tabs themselves. The image data was created by me using an 
    # archaic tool called "bitmap" that was installed with fedora.
    #
    set BitmapData {
................................................................................
    canvas ${win}.tabs
    ${win}.tabs configure -borderwidth 0
    ${win}.tabs configure -highlightthickness 0
    ${win}.tabs configure -selectborderwidth 0

    init_bitmaps



    $self configurelist $args

    bind ${win}.tabs <Configure> [list $self Redraw]
    place ${win}.tabs -relwidth 1.0 -relheight 1.0
    $hull configure -height 0
  }

................................................................................
  method RedrawCallback {} {
    # Optimization: When there is only one tab in the list, do not bother
    # to draw anything. It won't be visible anyway.
    if {[array size myIdMap]<=1} {
      $hull configure -height 1
      return
    }

    set tab_height [expr [font metrics Hv3DefaultFont -linespace] * 1.5]
    $hull configure -height $tab_height

    set font Hv3DefaultFont

    set iPadding  2
    set iDiagonal 2
    set iButton   14
    set iCanvasWidth [expr [winfo width ${win}.tabs] - 2]
................................................................................
    # If the myIdList is empty, there are no tabs to draw.
    set myRedrawScheduled 0
    if {[llength $myIdList] == 0} return

    set iRemainingTabs [llength $myIdList]
    set iRemainingPixels $iCanvasWidth

    set yt [expr 0.5 * ($tab_height + [font metrics $font -linespace])]
    set x 1
    foreach ident $myIdList {

      set zTitle $myIdMap($ident)

      set  iTabWidth [expr $iRemainingPixels / $iRemainingTabs]
      incr iRemainingTabs -1
................................................................................
        set zTitle "[string range $zTitle 0 [expr $n - 1]]..."
      }

      set x2 [expr $x + $iDiagonal]
      set x3 [expr $x + $iTabWidth - $iDiagonal - 1]
      set x4 [expr $x + $iTabWidth - 1]

      set y1 [expr $tab_height - 0]
      set y2 [expr $iDiagonal + 1]
      set y3 1

      set ximg [expr $x + $iTabWidth - $iDiagonal - $iButton - 1]
      set yimg [expr 1 + ($tab_height - $iButton) / 2]

      ${win}.tabs create polygon \
          $x $y1 $x $y2 $x2 $y3 $x3 $y3 $x4 $y2 $x4 $y1 -tags $ident

      ${win}.tabs create text [expr $x2 + $iPadding] $yt \
          -anchor sw -text $zTitle -font $font -tags $ident

Changes to hv/hv3_widgets.tcl.

1
2
3
4
5
6
7
8
..
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
namespace eval hv3 { set {version($Id: hv3_widgets.tcl,v 1.58 2008/02/02 17:15:02 danielk1977 Exp $)} 1 }

package require snit
package require Tk

set ::hv3::toolkit Tk
catch {
#  package require tile
................................................................................
    catch {font delete Hv3DefaultFont}
    catch {font delete Hv3DefaultBold}
    eval [linsert $font 0 font create Hv3DefaultFont]
    eval [linsert $font 0 font create Hv3DefaultBold -weight bold]

  
    # WARNING: Horrible, horrible action at a distance...
    catch {.notebook.notebook Redraw}
  }

  SetFont {-size 10}

  proc button {args} {
    if {$::hv3::toolkit eq "Tile"} {
      set w [eval [linsert $args 0 ::ttk::button]]
|







 







|







1
2
3
4
5
6
7
8
..
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
namespace eval hv3 { set {version($Id: hv3_widgets.tcl,v 1.59 2008/02/03 17:53:26 danielk1977 Exp $)} 1 }

package require snit
package require Tk

set ::hv3::toolkit Tk
catch {
#  package require tile
................................................................................
    catch {font delete Hv3DefaultFont}
    catch {font delete Hv3DefaultBold}
    eval [linsert $font 0 font create Hv3DefaultFont]
    eval [linsert $font 0 font create Hv3DefaultBold -weight bold]

  
    # WARNING: Horrible, horrible action at a distance...
    catch {.notebook.header Redraw}
  }

  SetFont {-size 10}

  proc button {args} {
    if {$::hv3::toolkit eq "Tile"} {
      set w [eval [linsert $args 0 ::ttk::button]]