tk2ico                package:tcltk2                R Documentation

_M_a_n_i_p_u_l_a_t_e _i_c_o_n_s _u_n_d_e_r _W_i_n_d_o_w_s

_D_e_s_c_r_i_p_t_i_o_n:

     Create, load and work with Windows icons. Change icons fo Windows,
     use icons in the taskbar under Windows 9X/2000/XP, ... These
     function are only useful for Windows.

_U_s_a_g_e:

       tk2ico.create(icofile)
       tk2ico.destroy(icon)
       tk2ico.hicon(icon)
       tk2ico.info(icon, convert = TRUE)
       tk2ico.load(file = "shell32.dll", res = "application")
       tk2ico.pos(icon, pos)
       tk2ico.set(win, icon, pos = NULL, type = c("all", "small", "big"))
       tk2ico.text(icon, text = NULL)
       tk2ico.taskbar.add(icon, pos = 0, text = tk2ico.text(icon), callback = NULL)
       tk2ico.taskbar.delete(icon)
       tk2ico.taskbar.modify(icon, pos = NULL, text = NULL)

_A_r_g_u_m_e_n_t_s:

 icofile: A file with a .ico extension, containing one or more Windows
          icons 

    icon: An icon object 

 convert: Do we convert the result into a data.frame? 

    file: A file having icon resources (.exe, or .dll) 

     res: The name of the resource from where the icon should be
          extracted 

     pos: A position (starting from 0) pointing to an icon in a
          multi-icon object 

     win: A tk window whose icon is changed 

    type: Do we change only the small, the large, or both icons? 

    text: Change a text for an icon 

callback: Give a callback function called when the user clicks in the
          taskbar icon 

_V_a_l_u_e:

     An icon object, which is a reference to an image resource in tcl.
     Do not forget to destroy it using 'tk2ico.destroy()' when you do
     not need it any more!

_N_o_t_e:

     This is Windows-specific. It uses the winico 0.5 Tcl library.
     Under other platforms these functions just return 'NULL' without
     error or warning. So, code that must run on different platforms
     could use these functions all the time, as soon as they correctly
     deal with possible 'NULL' return.

_A_u_t_h_o_r(_s):

     Philippe Grosjean

_S_e_e _A_l_s_o:

     'tk2dde', 'tk2reg'

_E_x_a_m_p_l_e_s:

       ## Not run: 
         ## These cannot be run by examples() but should be OK when pasted
         ## into an interactive R session with the tcltk package loaded

             ## Examples of tk2ico - icon manipulation under Windows
         tt2 <- tktoplevel()
         # Load a system icon (there are: "application", "asterisk", "error",
         # "exclamation", "hand", "question", "information", "warning", and "winlogo".
         Warn <- tk2ico.load(res = "warning")
         tk2ico.info(Warn)
         # Change the text
         tk2ico.text(Warn)
         tk2ico.text(Warn, "Warning icon")
         tk2ico.text(Warn)
         # Get hicon
         tk2ico.hicon(Warn)
         # Change the icon of my window tt2
         tk2ico.set(tt2, Warn)
         # Do not forget to destroy icon to free resource when not needed any more
         tk2ico.destroy(Warn)
         rm(Warn)
         # Load an icon from the resource section of an exe, or dll
         Rico <- tk2ico.load(file.path(Sys.getenv("R_HOME"), "bin", "R.exe"), res = "R")
         tk2ico.info(Rico)
         tk2ico.set(tt2, Rico)
         tk2ico.destroy(Rico)
         rm(Rico)

         # Load one or several icons from an .ico file
         libdir <- file.path(.path.package(package="tcltk2")[1], "etc")
         SVico <- tk2ico.create(file.path(libdir, "SciViews.ico"))
         # The various resolution icons created from this file
         tk2ico.info(SVico)
         # Change the default position to 1
         tk2ico.pos(SVico, 1)
         # Change only the small icon (use Alt-Tab to see the large one)
         tk2ico.set(tt2, SVico, pos = 0, type = "small")

         ### This does not work!
         ## Set a taskbar icon (rem: should use callback usually)
         #tk2ico.taskbar.add(SVico, pos = 0, text = "{my tcltk taskbar icon}")
         ## Change its text...
         #tk2ico.tackbar.modify(SVico, text = "{text changed!}")
         ##... and delete it
         #tk2ico.taskbar.delete(SVico)

         # Destroy the icons
         tk2ico.destroy(SVico)
         rm(SVico)

         # When done, dispose of the window
         tkdestroy(tt2)
       ## End(Not run)

