home *** CD-ROM | disk | FTP | other *** search
/ Freesoft 1999 February / Freesoft_1999-02_cd.bin / Recenz / Utility / DisplayDoctorLinux / scitech-display-doctor-1.0beta-3.i386.rpm / scitech-display-doctor-1.0beta.3.cpio.gz / scitech-display-doctor-1.0beta.3.cpio / usr / lib / nucleus / XF86Setup / modeselect.tcl < prev    next >
Text File  |  1998-09-19  |  6KB  |  197 lines

  1. # $XConsortium: modeselect.tcl /main/2 1996/10/25 10:21:20 kaleb $
  2. #
  3. #
  4. #
  5. #
  6. # $XFree86: xc/programs/Xserver/hw/xfree86/XF86Setup/modeselect.tcl,v 3.1.2.3 1998/02/21 06:07:00 robin Exp $
  7. #
  8. # Copyright 1996 by Joseph V. Moss <joe@XFree86.Org>
  9. #           1997 by Dirk H Hohndel <hohndel@XFree86.Org>
  10. #
  11. # See the file "LICENSE" for information regarding redistribution terms,
  12. # and for a DISCLAIMER OF ALL WARRANTIES.
  13. #
  14.  
  15. #
  16. # routines to select the modes that the user actually wants to use
  17. #
  18.  
  19. proc Modeselect_compare_modes { m1 m2 } {
  20.     scan $m1 "%d%*c%d" m1x m1y
  21.     scan $m2 "%d%*c%d" m2x m2y
  22.     return [expr $m1x*$m1y - $m2x*$m2y ]
  23. }
  24.  
  25. proc Modeselect_create_widgets { win } {
  26.     global MonitorIDs monDevNum monCanvas MonitorDescriptions
  27.     global pc98_EGC messages lbuttons
  28.     global DefaultColorDepth DefaultRefreshRate
  29.  
  30.     set w [winpathprefix $win]
  31.     set DefaultColorDepth 16
  32.     set lbuttons {}
  33.  
  34.     if !$pc98_EGC {
  35.     frame $w.modesel -width 640 -height 420 \
  36.         -relief ridge -borderwidth 5
  37.     } else {
  38.     frame $w.modesel -width 640 -height 400 \
  39.         -relief ridge -borderwidth 5
  40.     }
  41.     frame $w.modesel.top
  42.     frame $w.modesel.mid -relief sunken -borderwidth 3
  43.     frame $w.modesel.bot
  44.     entry $w.modesel.refresh -textvariable DefaultRefreshRate
  45.     pack $w.modesel.top -side top
  46. #    pack $w.modesel.refresh -side right -expand yes
  47.     pack $w.modesel.mid -side top -expand yes
  48.     pack $w.modesel.bot -side top
  49.  
  50.     label $w.modesel.top.title -text $messages(modeselect.1)
  51.     frame $w.modesel.type
  52.     pack $w.modesel.top.title $w.modesel.type -in $w.modesel.top -side top
  53.     set canv [canvas $w.modesel.buttons]
  54.  
  55.     checkbutton $win.modesel.buttons.nomode -text $messages(modeselect.19) -indicatoron no
  56.  
  57.     Modeselection_build_buttons $w $canv
  58.  
  59.     scrollbar $w.modesel.sb \
  60.     -command [list $canv yview]
  61.     pack $canv -in $w.modesel.mid \
  62.     -side left -fill both -expand yes -pady 2m
  63.     pack $w.modesel.sb -in $w.modesel.mid -side right \
  64.     -fill y -expand yes
  65.     frame $w.modesel.dcd
  66.     label $w.modesel.dcd.title -text $messages(modeselect.14)
  67.     radiobutton $w.modesel.8bpp -text $messages(modeselect.15) \
  68.     -indicatoron false -variable ColorDepth \
  69.     -value "depth8" -underline 19 \
  70.     -command [list modesel_color_select $w 8]
  71.     radiobutton $w.modesel.16bpp -text $messages(modeselect.16) \
  72.     -indicatoron false -variable ColorDepth \
  73.     -value "depth16" -underline 19 \
  74.     -command [list modesel_color_select $w 16]
  75.     $w.modesel.16bpp select
  76.     radiobutton $w.modesel.24bpp -text $messages(modeselect.17) \
  77.     -indicatoron false -variable ColorDepth \
  78.     -value "depth24" -underline 19 \
  79.     -command [list modesel_color_select $w 24]
  80.     radiobutton $w.modesel.32bpp -text $messages(modeselect.18) \
  81.     -indicatoron false -variable ColorDepth \
  82.     -value "depth32" -underline 19 \
  83.     -command [list modesel_color_select $w 32]
  84.     pack $w.modesel.8bpp $w.modesel.16bpp $w.modesel.24bpp \
  85.     $w.modesel.32bpp -side left -fill x -expand yes \
  86.     -in $w.modesel.dcd
  87.     pack $w.modesel.dcd.title $w.modesel.dcd -side left -fill y -expand yes
  88. }
  89.  
  90. proc Modeselection_build_buttons { win canv } {
  91.     global DefaultColorDepth lbuttons SelectedMonitorModes
  92.  
  93. #    if { [array exists SelectedMonitorModes] == 1 } {
  94. #    foreach i [array names SelectedMonitorModes *] {
  95. #        set SelectedMonitorModes($i) "#removed"
  96. #    }
  97. #    }
  98.  
  99. #    $canv delete modelist_buttons
  100.     set lbuttons {}
  101.  
  102.     set all_modes [vbe_getmoderes 8] 
  103. # $DefaultColorDepth]
  104.  
  105.     foreach res [lsort -command Modeselect_compare_modes $all_modes] {
  106.     if { [catch {$win.modesel.buttons.m$res deselect} ] != 0 } {
  107.         checkbutton $win.modesel.buttons.m$res \
  108.         -text $res \
  109.         -indicatoron no -variable m$res \
  110.         -command [list modesel_enable $win " $res*"]
  111.     }
  112.     lappend lbuttons $win.modesel.buttons.m$res
  113.     $win.modesel.buttons.m$res select
  114.     modesel_enable $win " $res*"
  115.     }
  116.  
  117.     if { [llength $lbuttons] == 0 } {
  118.     lappend lbuttons $win.modesel.buttons.nomode
  119.     }
  120.  
  121.     set ht 0
  122.     set wd 0
  123.     foreach wb $lbuttons {
  124.     set bwd [winfo reqwidth $wb]
  125.     if {$wd < $bwd} {set wd $bwd}
  126.     }
  127.     foreach wb $lbuttons {
  128.     $canv create window \
  129.         [expr ($wd-[winfo reqwidth $wb])/2] $ht \
  130.         -anchor nw -window $wb -tags modelist_buttons
  131.     set ht [expr $ht + [winfo reqheight $wb]]
  132.     }
  133.     $canv configure -yscrollcommand [list $win.modesel.sb set] \
  134.     -scrollregion [list 0 0 $wd $ht] \
  135.     -width $wd
  136. }
  137.  
  138. proc Modeselection_activate { win } {
  139.     set w [winpathprefix $win]
  140.     pack $w.modesel -side top -fill both -expand yes
  141. }
  142.  
  143. proc Modeselection_deactivate { win } {
  144.     set w [winpathprefix $win]
  145.     pack forget $w.modesel
  146.  
  147. }
  148.  
  149. proc modesel_color_select { win val } {
  150.     global DefaultColorDepth
  151.  
  152.     set w [winpathprefix $win]
  153.  
  154.     if { $val != $DefaultColorDepth } {
  155.     set DefaultColorDepth $val
  156. #    Modeselection_build_buttons $w $w.modesel.buttons
  157.     }
  158. }
  159.  
  160. proc modesel_enable { win val } {
  161.     global MonitorStdModes SelectedMonitorModes haveSelectedModes
  162.  
  163.     set w [winpathprefix $win]
  164.  
  165.     set haveSelectedModes 1
  166.  
  167.     # we need to handle the fact that these are toggle buttons, so every
  168.     # other time this is selected, the user actually wants to deselect
  169.     # the entries
  170.     # this would be much easier if I have a way to remove pairs from an array...
  171.     if { [array get SelectedMonitorModes $val] != "" } {
  172.     #    puts stderr "$val already existed"
  173.     # 
  174.     foreach desc [array names SelectedMonitorModes $val] {
  175.         if [string match \#removed $SelectedMonitorModes($desc)] {
  176.                 # ok, we're enabling again
  177.         set SelectedMonitorModes($desc) $MonitorStdModes($desc)
  178.             } else {
  179.         #            puts stderr "invalidating for $desc"
  180.             set SelectedMonitorModes($desc) "#removed"
  181.         }
  182.     }    
  183.     } else {
  184.     #    puts stderr "add $val to selected modes"
  185.     foreach desc [array names MonitorStdModes $val] {
  186.         set modeline $MonitorStdModes($desc)
  187.         #        puts stderr "$desc :: $modeline"
  188.         set SelectedMonitorModes($desc) $modeline
  189.     }
  190.     }
  191. #    puts Enable
  192. #    foreach desc [array names SelectedMonitorModes] {
  193. #        puts stderr "$desc -> $SelectedMonitorModes($desc)"
  194. #    }
  195. }
  196.  
  197.