1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2;; stylesheet-plain.css : the default style sheet, very simple 3;; Copyright 2009 Phil Longstaff <plongstaff@rogers.com> 4;; Copyright 2000 Bill Gribble <grib@gnumatic.com> 5;; 6;; This program is free software; you can redistribute it and/or 7;; modify it under the terms of the GNU General Public License as 8;; published by the Free Software Foundation; either version 2 of 9;; the License, or (at your option) any later version. 10;; 11;; This program is distributed in the hope that it will be useful, 12;; but WITHOUT ANY WARRANTY; without even the implied warranty of 13;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14;; GNU General Public License for more details. 15;; 16;; You should have received a copy of the GNU General Public License 17;; along with this program; if not, contact: 18;; 19;; Free Software Foundation Voice: +1-617-542-5942 20;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 21;; Boston, MA 02110-1301, USA gnu@gnu.org 22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 23 24 25(define-module (gnucash report stylesheets plain)) 26 27(use-modules (gnucash engine)) 28(use-modules (gnucash utilities)) 29(use-modules (gnucash core-utils)) 30(use-modules (gnucash app-utils)) 31(use-modules (gnucash report)) 32(use-modules (srfi srfi-13)) 33(use-modules (srfi srfi-14)) 34(use-modules (gnucash html)) 35 36;; plain style sheet 37;; this should generally be the default style sheet for most reports. 38;; it's supposed to be lightweight and unobtrusive. 39(define (plain-options) 40 (let* ((options (gnc:new-options)) 41 (opt-register 42 (lambda (opt) 43 (gnc:register-option options opt)))) 44 (opt-register 45 (gnc:make-color-option 46 (N_ "General") 47 (N_ "Background Color") "a" (N_ "Background color for reports.") 48 (list #xff #xff #xff #xff) 49 255 #f)) 50 (opt-register 51 (gnc:make-pixmap-option 52 (N_ "General") 53 (N_ "Background Pixmap") "b" (N_ "Background tile for reports.") 54 "")) 55 (opt-register 56 (gnc:make-simple-boolean-option 57 (N_ "General") 58 (N_ "Enable Links") "c" (N_ "Enable hyperlinks in reports.") 59 #t)) 60 (opt-register 61 (gnc:make-color-option 62 (N_ "Colors") 63 (N_ "Alternate Table Cell Color") "a" (N_ "Background color for alternate lines.") 64 (list #xff #xff #xff #xff) 65 255 #f)) 66 (opt-register 67 (gnc:make-number-range-option 68 (N_ "Tables") 69 (N_ "Table cell spacing") "a" (N_ "Space between table cells.") 70 0 0 20 0 1)) 71 (opt-register 72 (gnc:make-number-range-option 73 (N_ "Tables") 74 (N_ "Table cell padding") "b" (N_ "Space between table cell edge and content.") 75 4 0 20 0 1)) 76 (opt-register 77 (gnc:make-number-range-option 78 (N_ "Tables") 79 (N_ "Table border width") "c" (N_ "Bevel depth on tables.") 80 0 0 20 0 1)) 81 (register-font-options options) 82 83 options)) 84 85(define (plain-renderer options doc) 86 (define (opt-val section name) 87 (gnc:option-value 88 (gnc:lookup-option options section name))) 89 (let* ((ssdoc (gnc:make-html-document)) 90 (bgcolor 91 (gnc:color-option->html 92 (gnc:lookup-option options "General" "Background Color"))) 93 (bgpixmap (opt-val "General" "Background Pixmap")) 94 (links? (opt-val "General" "Enable Links")) 95 (alternate-row-color 96 (gnc:color-option->html 97 (gnc:lookup-option options "Colors" "Alternate Table Cell Color"))) 98 (spacing (opt-val "Tables" "Table cell spacing")) 99 (padding (opt-val "Tables" "Table cell padding")) 100 (border (opt-val "Tables" "Table border width"))) 101 102 (gnc:html-document-set-style! 103 ssdoc "body" 104 'attribute (list "bgcolor" bgcolor)) 105 106 (if (and bgpixmap 107 (not (string-null? bgpixmap))) 108 (gnc:html-document-set-style! 109 ssdoc "body" 110 'attribute (list "background" (make-file-url bgpixmap)))) 111 112 (gnc:html-document-set-style! 113 ssdoc "table" 114 'attribute (list "border" border) 115 'attribute (list "cellspacing" spacing) 116 'attribute (list "cellpadding" padding)) 117 118 (gnc:html-document-set-style! 119 ssdoc "column-heading-left" 120 'tag "th" 121 'attribute (list "class" "column-heading-left")) 122 123 (gnc:html-document-set-style! 124 ssdoc "column-heading-center" 125 'tag "th" 126 'attribute (list "class" "column-heading-center")) 127 128 (gnc:html-document-set-style! 129 ssdoc "column-heading-right" 130 'tag "th" 131 'attribute (list "class" "column-heading-right")) 132 133 (gnc:html-document-set-style! 134 ssdoc "date-cell" 135 'tag "td" 136 'attribute (list "class" "date-cell")) 137 138 (gnc:html-document-set-style! 139 ssdoc "anchor-cell" 140 'tag "td" 141 'attribute (list "class" "anchor-cell")) 142 143 (gnc:html-document-set-style! 144 ssdoc "number-cell" 145 'tag "td" 146 'attribute (list "class" "number-cell")) 147 148 (gnc:html-document-set-style! 149 ssdoc "number-cell-neg" 150 'tag "td" 151 'attribute (list "class" "number-cell neg")) 152 153 (gnc:html-document-set-style! 154 ssdoc "number-header" 155 'tag "th" 156 'attribute (list "class" "number-header")) 157 158 (gnc:html-document-set-style! 159 ssdoc "text-cell" 160 'tag "td" 161 'attribute (list "class" "text-cell")) 162 163 (gnc:html-document-set-style! 164 ssdoc "total-number-cell" 165 'tag "td" 166 'attribute (list "class" "total-number-cell")) 167 168 (gnc:html-document-set-style! 169 ssdoc "total-number-cell-neg" 170 'tag "td" 171 'attribute (list "class" "total-number-cell neg")) 172 173 (gnc:html-document-set-style! 174 ssdoc "total-label-cell" 175 'tag "td" 176 'attribute (list "class" "total-label-cell")) 177 178 (gnc:html-document-set-style! 179 ssdoc "centered-label-cell" 180 'tag "td" 181 'attribute (list "class" "centered-label-cell")) 182 183 (gnc:html-document-set-style! 184 ssdoc "normal-row" 185 'tag "tr") 186 187 (gnc:html-document-set-style! 188 ssdoc "alternate-row" 189 'tag "tr" 190 'attribute (list "bgcolor" alternate-row-color)) 191 192 (gnc:html-document-set-style! 193 ssdoc "primary-subheading" 194 'attribute (list "bgcolor" bgcolor) 195 'tag "tr") 196 (gnc:html-document-set-style! 197 ssdoc "secondary-subheading" 198 'attribute (list "bgcolor" bgcolor) 199 'tag "tr") 200 (gnc:html-document-set-style! 201 ssdoc "grand-total" 202 'attribute (list "bgcolor" bgcolor) 203 'tag "tr") 204 205 ;; don't surround marked-up links with <a> </a> 206 (if (not links?) 207 (gnc:html-document-set-style! 208 ssdoc "a" 209 'tag "")) 210 211 (add-css-information-to-doc options ssdoc doc) 212 213 (let ((headline (or (gnc:html-document-headline doc) 214 (gnc:html-document-title doc)))) 215 (if (and headline (not (equal? headline ""))) 216 (gnc:html-document-add-object! 217 ssdoc 218 (gnc:make-html-text 219 (gnc:html-markup-h3 headline))))) 220 221 (gnc:html-document-append-objects! ssdoc (gnc:html-document-objects doc)) 222 223 ssdoc)) 224 225(gnc:define-html-style-sheet 226 'version 1 227 'name (N_ "Plain") 228 'renderer plain-renderer 229 'options-generator plain-options) 230 231;; instantiate a default style sheet 232(gnc:make-html-style-sheet "Plain" (N_ "Default")) 233