[Sciviews-commits] r126 - pkg/svWidgets/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Apr 6 12:59:00 CEST 2009
Author: romain
Date: 2009-04-06 12:59:00 +0200 (Mon, 06 Apr 2009)
New Revision: 126
Modified:
pkg/svWidgets/R/Tool.R
pkg/svWidgets/R/tkTool.R
Log:
allowing multiple seperators. (makes zooimage happy)
Modified: pkg/svWidgets/R/Tool.R
===================================================================
--- pkg/svWidgets/R/Tool.R 2009-04-06 09:37:02 UTC (rev 125)
+++ pkg/svWidgets/R/Tool.R 2009-04-06 10:59:00 UTC (rev 126)
@@ -10,7 +10,8 @@
function (toolbar, side = "top")
{
res <- switch(ToolType(toolbar),
- tkTool = tkToolAdd(toolbar = toolbar, side = side))
+ tkTool = tkToolAdd(toolbar = toolbar, side = side)
+ )
return(invisible(res))
}
@@ -158,15 +159,16 @@
# add it to the data.frame
L[i, ] <- Litem
}
-# # The [toolbar] entries are not needed
-# L <- L[L$action != "[toolbar]", ]
+
+ # The [toolbar] entries are not needed
+ L <- subset( L, action != "[toolbar]" )
- # Execute this line-by-line to create the various tools
+ # Execute this line-by-line to create the various tools
N <- nrow(L)
for (i in 1:N) {
action <- L$action[i]
- if (action == "[toolbar]") { # Create a toolbar
- ToolAdd(toolbar = L$menu[i])
+ if (action == "[tool]") { # Create a toolbar
+ ToolAdd(toolbar = L$tool[i])
# } else if (action == "[tool]") { # Create a tool button
# ### TODO: determine which type of tool button it is!
# ToolAddItem(toolbar = L$menu[i])
Modified: pkg/svWidgets/R/tkTool.R
===================================================================
--- pkg/svWidgets/R/tkTool.R 2009-04-06 09:37:02 UTC (rev 125)
+++ pkg/svWidgets/R/tkTool.R 2009-04-06 10:59:00 UTC (rev 126)
@@ -70,22 +70,28 @@
Tl <- .guiTools[[toolbar]]
if (is.null(Tl))
stop("toolbar does not exist!")
- # Look if the toolbar already has tools
+
+ # is this item a separator
+ isSeparator <- regexpr("^-+$", item) > 0
+
Items <- Tl$Items
+ # Look if the toolbar already has this tool
if (is.null(Items)) n <- 0 else {
- if (item %in% Items$name)
+ if (!isSeparator && item %in% Items$name)
stop("the tool ", item, " already exists!")
n <- max(Items$pos) + 1
}
+
# Add the entry at the end of the Tk toolbar (### TODO: allow other positions)
# First look if it is a tool button or a separator
- if (regexpr("^-+$", item) > 0) { #This must be a separator
+ if ( isSeparator ) { #This must be a separator
### TODO: choose correct orientation
but <- ttkseparator(Tl, orient = "vertical")
tkgrid(but, row = 0, column = n, sticky = "nsew")
action <- "[separator]"
options <- 'orient = "vertical"'
} else { # This is a tool button
+
# Rework options
### TODO: I need to deal with options!
#if (options == "") opts <- "" else opts <- paste(",", options)
More information about the Sciviews-commits
mailing list