Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

open-axiom repository from github

24005 views
1
/*
2
Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd.
3
All rights reserved.
4
Copyright (C) 2007-2010, Gabriel Dos Reis.
5
All rights reserved.
6
7
Redistribution and use in source and binary forms, with or without
8
modification, are permitted provided that the following conditions are
9
met:
10
11
- Redistributions of source code must retain the above copyright
12
notice, this list of conditions and the following disclaimer.
13
14
- Redistributions in binary form must reproduce the above copyright
15
notice, this list of conditions and the following disclaimer in
16
the documentation and/or other materials provided with the
17
distribution.
18
19
- Neither the name of The Numerical Algorithms Group Ltd. nor the
20
names of its contributors may be used to endorse or promote products
21
derived from this software without specific prior written permission.
22
23
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
27
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
#include "openaxiom-c-macros.h"
37
#include "debug.h"
38
#include "sockio.h"
39
#include "extent.h"
40
#include "group.h"
41
#include "scrollbar.h"
42
43
44
static int window_height(HyperDocPage * page);
45
static void form_header_extent(HyperDocPage * page);
46
static void form_footer_extent(HyperDocPage * page);
47
static void form_scrolling_extent(HyperDocPage * page);
48
49
50
/*
51
* A few routines used to help with form extents
52
*/
53
54
void
55
compute_form_page(HyperDocPage *page)
56
{
57
58
/*
59
* To solve the problem of improperly nested \em, I will have to keep and
60
* always initialize the top of the stack
61
*/
62
while (pop_group_stack() >= 0);
63
64
/*
65
* The compute the text extents
66
*/
67
form_header_extent(page);
68
form_footer_extent(page);
69
form_scrolling_extent(page);
70
gWindow->height = window_height(gWindow->page);
71
72
}
73
74
/*
75
* A simple function that returns the width needed to store show the number
76
* of columns given
77
*/
78
int
79
window_width(int cols)
80
{
81
return (left_margin + cols * space_width + non_scroll_right_margin_space);
82
}
83
84
85
static int
86
window_height(HyperDocPage *page)
87
{
88
int temp;
89
90
temp = page->header->height + top_margin + bottom_margin;
91
92
if (page->scrolling)
93
temp += page->scrolling->height + page->footer->height;
94
95
return (temp);
96
}
97
98
99
static void
100
form_header_extent(HyperDocPage *page)
101
{
102
103
/*
104
* Hopefully I will soon be able to actually compute the needed height
105
* for the header here
106
*/
107
gExtentRegion = Header;
108
right_margin_space = non_scroll_right_margin_space;
109
init_extents();
110
text_y = top_margin + line_height;
111
compute_text_extent(page->header->next);
112
page->header->height = (gInLine) ? text_y : text_y - past_line_height;
113
if (!(page->page_flags & NOLINES))
114
page->header->height += (int) line_height / 2;
115
page->header->height += gWindow->border_width;
116
}
117
118
static void
119
form_footer_extent(HyperDocPage *page)
120
{
121
if (page->footer) {
122
gExtentRegion = Footer;
123
right_margin_space = non_scroll_right_margin_space;
124
init_extents();
125
126
compute_text_extent(page->footer->next);
127
128
/*
129
* I inserted the 2nd arg to text_height below because it
130
* was missing. Perhaps there is a better value for it.
131
*/
132
133
page->footer->height = text_height(page->footer->next,
134
page->footer->next->type);
135
if ((!page->page_flags & NOLINES))
136
page->footer->height += (int) line_height / 2;
137
}
138
}
139
140
static void
141
form_scrolling_extent(HyperDocPage *page)
142
{
143
144
/*
145
* Check to see if there is a scrolling region
146
*/
147
148
if (page->scrolling) {
149
/*
150
* If there is then compute all the proper locations
151
*/
152
153
gExtentRegion = Scrolling;
154
right_margin_space = non_scroll_right_margin_space + gScrollbarWidth;
155
init_extents();
156
text_y = line_height;
157
compute_text_extent(page->scrolling->next);
158
if (!gInLine)
159
text_y = text_y - past_line_height;
160
else if (present_line_height > line_height)
161
text_y = text_y + present_line_height - line_height;
162
page->scrolling->height = text_y;
163
}
164
}
165
166
167
168
169