Skip to content

Commit

Permalink
[reports][API] gnc:make-html-table-cell/min-width
Browse files Browse the repository at this point in the history
A better version of 5aa59e0 - new API call to create a table-cell
with min-width style attribute. Can be used by balsheet-pnl as
well.
  • Loading branch information
christopherlam committed Sep 30, 2019
1 parent 72dc9bd commit 2684e51
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 44 deletions.
6 changes: 6 additions & 0 deletions gnucash/report/report-system/html-table.scm
Expand Up @@ -73,6 +73,12 @@
(gnc:make-html-table-cell-internal rowspan colspan markup
objects (gnc:make-html-style-table)))

(define (gnc:make-html-table-cell/min-width px)
(let ((cell (gnc:make-html-table-cell)))
(gnc:html-table-cell-set-style!
cell "td" 'attribute (list "style" (format #f "min-width:~apx" px)))
cell))

(define (gnc:make-html-table-header-cell . objects)
(gnc:make-html-table-cell-internal 1 1 "th" objects
(gnc:make-html-style-table)))
Expand Down
1 change: 1 addition & 0 deletions gnucash/report/report-system/report-system.scm
Expand Up @@ -563,6 +563,7 @@
(export gnc:make-html-table-header-cell)
(export gnc:make-html-table-header-cell/markup)
(export gnc:make-html-table-header-cell/size)
(export gnc:make-html-table-cell/min-width)
(export gnc:html-table-cell?)
(export gnc:html-table-cell-rowspan)
(export gnc:html-table-cell-set-rowspan!)
Expand Down
11 changes: 4 additions & 7 deletions gnucash/report/standard-reports/balance-sheet.scm
Expand Up @@ -473,13 +473,10 @@
(equity-table
(gnc:make-html-acct-table/env/accts table-env equity-accounts)))

(let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
(gnc:html-table-cell-set-style!
wide "text-cell" 'attribute '("style" "min-width:60px"))
(let ((space (make-list tree-depth wide)))
(gnc:html-table-append-row! left-table space)
(unless report-form?
(gnc:html-table-append-row! right-table space))))
(let ((space (make-list tree-depth (gnc:make-html-table-cell/min-width 60))))
(gnc:html-table-append-row! left-table space)
(unless report-form?
(gnc:html-table-append-row! right-table space)))
(gnc:report-percent-done 80)

(when label-assets?
Expand Down
6 changes: 1 addition & 5 deletions gnucash/report/standard-reports/balsheet-pnl.scm
Expand Up @@ -419,11 +419,7 @@ also show overall period profit & loss."))
(loop (cons (thunk) result) (1- n)))))

(define (make-narrow-cell)
(let ((narrow (gnc:make-html-table-cell/markup "text-cell" #f)))
(gnc:html-table-cell-set-style!
narrow "text-cell"
'attribute '("style" "width:1px"))
narrow))
(gnc:make-html-table-cell/min-width 1))

(define (add-indented-row indent label label-markup amount-indent rest)
(when (or (not depth-limit) (<= indent depth-limit))
Expand Down
17 changes: 7 additions & 10 deletions gnucash/report/standard-reports/budget-balance-sheet.scm
Expand Up @@ -653,16 +653,13 @@
(list 'rule-mode use-rules?)
)
)

(let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
(gnc:html-table-cell-set-style!
wide "text-cell" 'attribute '("style" "min-width:60px"))
(let ((space (make-list tree-depth wide)))
(gnc:html-table-append-row! left-table space)
(unless report-form?
(gnc:html-table-append-row! right-table space))))

(gnc:report-percent-done 80)

(let ((space (make-list tree-depth (gnc:make-html-table-cell/min-width 60))))
(gnc:html-table-append-row! left-table space)
(unless report-form?
(gnc:html-table-append-row! right-table space)))

(gnc:report-percent-done 80)
(if label-assets? (add-subtotal-line left-table (_ "Assets") #f #f))
(set! asset-table
(gnc:make-html-acct-table/env/accts
Expand Down
8 changes: 3 additions & 5 deletions gnucash/report/standard-reports/budget-income-statement.scm
Expand Up @@ -582,11 +582,9 @@
)
)

(let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
(gnc:html-table-cell-set-style!
wide "text-cell" 'attribute '("style" "min-width:60px"))
(gnc:html-table-append-row! inc-table (make-list tree-depth wide))
(gnc:html-table-append-row! exp-table (make-list tree-depth wide)))
(let ((space (make-list tree-depth (gnc:make-html-table-cell/min-width 60))))
(gnc:html-table-append-row! inc-table space)
(gnc:html-table-append-row! exp-table space))

(gnc:report-percent-done 80)
(if label-revenue?
Expand Down
6 changes: 2 additions & 4 deletions gnucash/report/standard-reports/equity-statement.scm
Expand Up @@ -440,10 +440,8 @@

(gnc:report-percent-done 30)

(let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
(gnc:html-table-cell-set-style!
wide "text-cell" 'attribute '("style" "min-width:60px"))
(gnc:html-table-append-row! build-table (make-list 2 wide)))
(gnc:html-table-append-row!
build-table (make-list 2 (gnc:make-html-table-cell/min-width 60)))

(gnc:report-percent-done 80)

Expand Down
10 changes: 4 additions & 6 deletions gnucash/report/standard-reports/income-statement.scm
Expand Up @@ -548,12 +548,10 @@
)
)

(let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
(gnc:html-table-cell-set-style!
wide "text-cell" 'attribute '("style" "min-width:60px"))
(gnc:html-table-append-row! inc-table (make-list tree-depth wide))
(gnc:html-table-append-row! exp-table (make-list tree-depth wide))
(gnc:html-table-append-row! tra-table (make-list tree-depth wide)))
(let ((space (make-list tree-depth (gnc:make-html-table-cell/min-width 60))))
(gnc:html-table-append-row! inc-table space)
(gnc:html-table-append-row! exp-table space)
(gnc:html-table-append-row! tra-table space))

(gnc:report-percent-done 80)
(if label-revenue?
Expand Down
11 changes: 4 additions & 7 deletions gnucash/report/standard-reports/trial-balance.scm
Expand Up @@ -557,13 +557,10 @@
(let* ((env (gnc:html-acct-table-get-row-env acct-table 0)))
(set! account-cols (get-val env 'account-cols)))

(let ((wide (gnc:make-html-table-cell/markup "text-cell" #f))
(ncols (+ account-cols (if (eq? report-variant 'work-sheet) 10 2))))
(gnc:html-table-cell-set-style!
wide "text-cell" 'attribute '("style" "min-width:60px"))
(let ((space (make-list ncols wide)))
(gnc:html-table-append-row! build-table space)
(set! header-rows (1+ header-rows))))
(let* ((ncols (+ account-cols (if (eq? report-variant 'work-sheet) 10 2)))
(space (make-list ncols (gnc:make-html-table-cell/min-width 60))))
(gnc:html-table-append-row! build-table space)
(set! header-rows (1+ header-rows)))

;; add the double-column headers if required
(if (eq? report-variant 'work-sheet)
Expand Down

0 comments on commit 2684e51

Please sign in to comment.