-
Notifications
You must be signed in to change notification settings - Fork 1
Scrollbars
Andrej Vodopivec edited this page Mar 12, 2015
·
5 revisions
Scrollbars for windows must be manually created and connected to the windows with the scrollbar-connect
function. In the following example scrollbars are connected with a canvas window.
(defpackage :tk-user
(:use :cl :tk)
(:export :main))
(in-package :tk-user)
(defun main ()
(with-tk-root (root)
(setf (window-title root) "Scrollbars")
(setf (window-minsize root) '(300 300))
(let ((vertical (scrollbar :parent root :orient "vertical"))
(horizontal (scrollbar :parent root :orient "horizontal"))
(canvas (canvas :parent root :scrollregion '(-300 -300 300 300))))
(grid canvas :row 0 :column 0 :sticky "nwes")
(grid vertical :row 0 :column 1 :sticky "ns")
(grid horizontal :row 1 :column 0 :sticky "ew")
(grid (sizegrip :parent root) :column 1 :row 1 :sticky "news")
(grid-columnconfigure root 0 :weight 1)
(grid-rowconfigure root 0 :weight 1)
(scrollbar-connect canvas horizontal)
(scrollbar-connect canvas vertical)
(canvas-create-poylgon canvas '(-200 -200 0 200 200 -200)
:fill "blue"
:outline "red"
:width 10))))
Function implemented for scrollbars:
-
(scrollbar-connect w s)
: connectes the scrollbars
to the windoww
. -
(scrollbar-delta s dx dy)
: returns the fractional change for the given thumb change. -
(scrollbar-fraction s x y)
: retuns the fraction corresponding to the given point.