chiark / gitweb /
Add filter styles
[ypp-sc-tools.main.git] / yarrg / where-vessels
index 47cd6ed1119fb63aedea28561d8a8a00abdae5c3..f9f6879e37f42760aef411a9b5efc283b0fb6e5c 100755 (executable)
@@ -537,11 +537,27 @@ proc make-filters {} {
     make-entry-filter xabbre "Flags\n regexp" {}
 }
 
+proc filterstyle-changed {n1 n2 op} {
+    global filterstyle
+    debug "filterstyle-changed $filterstyle"
+    redraw-needed
+}
+
 proc filters-say-yes {code} {
-    global filters
+    global filters filterstyle
     debug "filters-say-yes $code"
+    set codel [split $code _]
+    set lockown [lindex $codel 3]
+    switch -exact $filterstyle {
+       0 { return 1 }
+       1 { return [filter-default/lockown $lockown] }
+       2 { return [regexp {^.0} $lockown] }
+       3 { }
+       default { error $filterstyle }
+    }
+    
     foreach fil $filters {
-       if {![filter-says-yes/$fil [split $code _]]} { return 0 }
+       if {![filter-says-yes/$fil $codel]} { return 0 }
     }
     return 1
 }
@@ -934,9 +950,9 @@ proc islandnames-handler {offset maxchars} {
 #---------- main user interface ----------
 
 proc widgets-setup {} {
-    global canvas debug pirate ocean
+    global canvas debug pirate ocean filterstyle
 
-    wm geometry . 1024x480
+    wm geometry . 1024x600
     wm title . "where-vessels - $pirate on the $ocean ocean"
 
     #----- map -----
@@ -954,7 +970,19 @@ proc widgets-setup {} {
     frame .islands -pady 2
     pack .cp .filter .islands -side top
 
-    label .filter.title -text Filter
+    set filterstyle 1
+    trace add variable filterstyle write filterstyle-changed
+
+    frame .filter.title
+    label .filter.title.title -text Show
+    pack .filter.title.title -side left
+    for {set fing 0} {$fing < 4} {incr fing} {
+       radiobutton .filter.title.f$fing \
+           -variable filterstyle -value $fing \
+           -text [lindex {All Useable Mine These:} $fing]
+       pack .filter.title.f$fing -side left
+    }
+
     grid configure .filter.title -row 0 -column 0 -columnspan 2
 
     #----- control panel -----