Skip to content

Commit

Permalink
ttk2 classes to tk2 classes
Browse files Browse the repository at this point in the history
  • Loading branch information
phgrosjean committed Jul 31, 2018
1 parent 7b4c26c commit 30ea3b3
Show file tree
Hide file tree
Showing 7 changed files with 777 additions and 716 deletions.
15 changes: 15 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.DS_Store
.gitignore
.git
.git/*
README.md
NEWS.md
FAQ.md
CONDUCT.md
Makefile
.Rprofile
^\.Rproj\.user$
^\.*\Rproj$
^\.travis\.yml$
^appveyor\.yml$
^.*\.Rproj$
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# History files
.Rhistory
.Rapp.history

# Session Data files
.RData
.Ruserdata

# Example code in package build process
*-Ex.R

# RStudio files
.Rproj.user
.Rproj.user/

# produced vignettes
vignettes/*.html
vignettes/*.pdf

# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
.httr-oauth

# Mac files
.DS_Store
30 changes: 16 additions & 14 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= tcltk2 news

== Version 1.3-0
== Version 1.3.0

* Message translation is completed. setLanguage()/getLanguage() work now in a
more robust way. getLanguage() separately reports the language used by R and
Expand All @@ -13,6 +13,8 @@
configure a composer to enter such unicode character on the keyboard are added
(functions tk2unicode_xxx()).

* All old 'ttk2xxx' widget classes are now converted into 'tk2xxx' classes.


== Version 1.2-12

Expand All @@ -30,7 +32,7 @@
*not* change when the theme is changed of existing menu items (but it is for
future menu items). This is due to the fact that Tk menus do not follow the
ttk styling scheme.


== Version 1.2-10

Expand All @@ -45,7 +47,7 @@

* New theme handling introduced in version 1.2-8 resulted in an invisible caret
in text widget.

* Further tweaking of color themes: now fieldbackground for entry, combobox,
canvas, listbox, mclistbox, tablelist, spinbox, text and ctext widgets (build
using old Tk widgets or megawidgets) now default with the correct theme color.
Expand All @@ -55,7 +57,7 @@

* A better handling of fonts and colors for Tk widgets according to themes used
for Ttk widgets using tk2theme(). Also for menus.

* The default font was not reset properly after switching back from radiance
to another theme.

Expand All @@ -67,7 +69,7 @@
very simple example is also added in the document. The widget is very rich,
and you will have to figure out by yourself how to access all its command from
its original documentation.

* A tk2swaplist() dialog box is added.


Expand All @@ -81,7 +83,7 @@
tk2theme("plastik"). Note also that the 'radiance' theme permanently changes
fonts used by the Ttk widgets to fonts identical, or close to those used by
Ubuntu.

* tk2theme() now tries to set the same background color for old tk widgets than
the color used by ttk widgets. Suggested by Milan Bouchet-Valat.

Expand All @@ -98,7 +100,7 @@

== Version 1.2-3

* The Tk configuration sequence in .onLoad() is changed.
* The Tk configuration sequence in .onLoad() is changed.


== Version 1.2-2
Expand All @@ -119,20 +121,20 @@

* A couple of warnings for partial argument matching in tclTaskXXX() functions
under R 2.15.0 are corrected.

* Documentation and demos for the tablelist Tk widgets are not distributed any
more in the tcltk2 package, to keep its size compatible with CRAN requirements
(no more than 5mb). Those are available from http://www.nemethi.de/.


== Version 1.2-0

* Clearlooks ttk theme added and made default theme under Linux. More modern
look&feel for ttk widgets under Linux!

* Radiance ttk theme created and added. This matches ambiance and radiance
themes under Ubuntu 11.x. This is the default theme used in Ubuntu.

* The tk widget tablelist is updated to version 5.5.

* tk2listbox() is completelly reworked to provide (autohide) scrollbars,
Expand All @@ -156,7 +158,7 @@

* Little correction in Winico.c that prevented it to compile correctly on all
Windows architectures (thanks Prof. B. Ripley for the patch).


== Version 1.1-4

Expand All @@ -170,7 +172,7 @@

* New /win/src/Makevars to make it compatible with the double compilation for
Windows 32bit and 64bit. Thanks Prof. Brian Ripley.

* Correction of the example in ?tk2reg. Thanks Tony Plate.

* .onload() now works inside SciViews.
Expand All @@ -187,7 +189,7 @@
* A bug in tk2mclistbox, clailing for missing -state argument when selecting
an item in the box is corrected, thanks to a patch provided by Christiane
Raemsch (and slightly modified).


== Version 1.1-0

Expand Down
30 changes: 15 additions & 15 deletions R/tk2commands.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ tk2notetab <- function (nb, tab)
w$env <- new.env()
w$env$num.subwin <- 0
w$env$parent <- nb
class(w) <- c("ttk2notetab", "tk2container", "tkwin")
class(w) <- c("tk2notetab", "tk2container", "tkwin")
return(w)
} else return(NULL) # Tab not found!
} else stop ("'nb' must be a 'tk2notebook' object")
Expand Down Expand Up @@ -197,7 +197,7 @@ tk2theme <- function (theme = NULL)
## First, check if the theme is already loaded... or try loading it
loadedThemes <- tk2theme.list()
if (!theme %in% loadedThemes) {
## Could be plastik, keramik, keramik_alt, clearlooks, radiance
## Could be plastik, keramik, keramik_alt, clearlooks, radiance
res <- try(tclRequire(paste0("ttk::theme::", theme)), silent = TRUE)
if (inherits(res, "try-error"))
stop("Ttk theme ", theme, " is not found")
Expand Down Expand Up @@ -243,12 +243,12 @@ tk2theme <- function (theme = NULL)
"throughColor", hfg),
"fieldBackground",
tclvalue(.Tcl("ttk::style lookup TEntry -fieldbackground")))

## Set menu font the same as label font
font <- tclvalue(.Tcl("ttk::style lookup TLabel -font"))
if (!length(font) || font == "") font <- "TkDefaultFont"
tk2font.set("TkMenuFont", tk2font.get(font))

## Return the theme
res <- theme
}
Expand All @@ -257,10 +257,10 @@ tk2theme <- function (theme = NULL)
### Note: to change a style element: .Tcl('ttk::style configure TButton -font "helvetica 24"')
### Create a derived style: ttk::style configure Emergency.TButton -font "helvetica 24" -foreground red -padding 10
### Changing different states:
###ttk::style map TButton \
### -background [list disabled #d9d9d9 active #ececec] \
### -foreground [list disabled #a3a3a3] \
### -relief [list {pressed !disabled} sunken] \
###ttk::style map TButton \
### -background [list disabled #d9d9d9 active #ececec] \
### -foreground [list disabled #a3a3a3] \
### -relief [list {pressed !disabled} sunken] \
### ;

## Function to look for a ttk style
Expand Down Expand Up @@ -298,7 +298,7 @@ tk2style <- function (class, style, state = c("default", "active",
style = paste("-", as.character(style)[1], sep = "")
state = match.arg(state)
if (is.null(default)) default <- ""

## styles creates a named vector (items in even elements, labels = odd)
styles <- function (x) {
st <- as.character(x)
Expand All @@ -311,7 +311,7 @@ tk2style <- function (class, style, state = c("default", "active",
names(st) <- stnames
return(st)
}

## First look at the map for this class
res <- styles(tcl("ttk::style", "map", class, style))
res2 <- styles(tcl("ttk::style", "map", ".", style))
Expand All @@ -321,7 +321,7 @@ tk2style <- function (class, style, state = c("default", "active",
res2 <- styles(tcl("ttk::style", "configure", ".", style))
res <- c(res, res2[!names(res2) %in% names(res)])
if (length(res) == 0) res <- c(default = default)

## If state != "all", try to resolve the right state
if (state != "all") {
## If the given state is there, use it
Expand Down Expand Up @@ -384,7 +384,7 @@ tk2dataList <- function (x)
tk2text = c("values", "value", "selection", "maxundo", "undo",
"spacing1", "spacing2", "spacing3", "tabs", "tabstyle"),
tk2tree = c("values", "value", "selection"),
stop("Unknown tk2widget, provide a tk2widget object or its class")
stop("Unknown tk2widget, provide a tk2widget object or its class")
)
## Add label, tag & tip for all
res <- c(res, "label", "tag", "tip")
Expand Down Expand Up @@ -449,7 +449,7 @@ setLanguage <- function (lang)
# If the tcl.language attribute is defined, use it
tcllang <- attr(lang, "tcl.language")
if (!is.null(tcllang) && tcllang[1] != "") {
lang <- tcllang[1] # Use only first item
lang <- tcllang[1] # Use only first item
} else {
# Tcl does not accept locales like en_US.UF-8: must be en_us only
lang <- tolower(sub("^([^.]+)\\..*$", "\\1", lang))
Expand All @@ -469,11 +469,11 @@ getLanguage <- function ()
## This is a bad hack that probably does not work all the time, but at least,
## it works under Windows for getting "fr" for French language
if (lang == "") lang <- tolower(substr(Sys.getlocale("LC_COLLATE"), 1, 2))

## Try to get language information from Tcl
tcllang <- try(as.character(tcl("mcpreferences")), silent = TRUE)
attr(lang, "tcl.language") <- tcllang

lang
}

Expand Down
Loading

0 comments on commit 30ea3b3

Please sign in to comment.