/ src / mandelbrot /
src/mandelbrot/mandelbrot.lisp
1 ;;; Copyright (C) 2009, 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
2 ;;;
3 ;;; This program is free software: you can redistribute it and/or modify
4 ;;; it under the terms of the GNU General Public License as published by
5 ;;; the Free Software Foundation, either version 3 of the License, or
6 ;;; (at your option) any later version.
7 ;;;
8 ;;; This program is distributed in the hope that it will be useful,
9 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ;;; GNU General Public License for more details.
12 ;;;
13 ;;; You should have received a copy of the GNU General Public License
14 ;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 (in-package :cl-smoke.kde.examples)
17
18 (defun make-aboutdata ()
19 (let ((app-name "kmandelbrot")
20 (catalog-name "") ;; not (null-pointer) (see smoke::conversion-pointer)
21 (program-name (kde:ki18n "KMandelbrot"))
22 (version "0.0.1")
23 (description (kde:ki18n "KDE Mandelbrot program."))
24 (copyright (kde:ki18n "Copyright (c) 2009 Tobias Rautenkranz"))
25 (text (kde:ki18n "TODO"))
26 (homepage "http://tobias.rautenkranz.ch/lisp/cl-smoke/")
27 (email "bugs@tobias.rautenkranz.ch"))
28 (let ((aboutdata
29 (make-instance 'kde:about-data
30 :args (list
31 app-name catalog-name program-name
32 version description
33 kde:about-data.+license-lgpl-v2+
34 copyright text homepage email))))
35 (cxx:add-author aboutdata
36 (kde:ki18n "Tobias Rautenkranz")
37 (make-instance 'kde:localized-string)
38 "tobias@rautenkranz.ch")
39 aboutdata)))
40
41 (defun mandelbrot ()
42 "KDE Mandelbrot example"
43 (kde:with-app (make-aboutdata)
44 (let* ((window (make-instance 'kde:xml-gui-window))
45 (mandelbrot (make-instance 'mandelbrotwidget))
46 (resource-dir
47 (namestring
48 (asdf:component-pathname
49 (asdf:find-component
50 (asdf:find-component (asdf:find-system :cl-smoke.kde.examples)
51 "src")
52 "kmandelbrot")))))
53 (cxx:add-resource-dir (kde:global.dirs)
54 "icon" resource-dir)
55 (cxx:add-resource-dir (kde:global.dirs)
56 "apps" resource-dir)
57 (cxx:quit (find-class 'kde:standard-action)
58 window (qt:qslot "close()")
59 (cxx:action-collection window))
60
61 (kde:make-standard-action kde:standard-action.+redisplay+
62 (cxx:action-collection window)
63 #'(lambda () (zoom mandelbrot 1d0)))
64
65 (kde:make-standard-action kde:standard-action.+zoom-in+
66 (cxx:action-collection window)
67 #'(lambda () (zoom mandelbrot 0.5d0)))
68
69 (kde:make-standard-action kde:standard-action.+zoom-out+
70 (cxx:action-collection window)
71 #'(lambda () (zoom mandelbrot 2d0)))
72
73 (cxx:set-central-widget window mandelbrot)
74 (cxx:set-focus mandelbrot)
75 (setup-slot mandelbrot)
76
77 (cxx:add-resource-dir (kde:global.dirs) "data" resource-dir)
78 (cxx:setup-gui window)
79
80 (cxx:show window)
81 (qt:exec))))