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-2016, 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
/******************************************************************************
37
*
38
* scrollbar.c: HyperDoc Scrollbar routines
39
*
40
* Copyright The Numerical Algorithms Group Limited 1991, 1992, 1993.
41
*
42
****************************************************************************/
43
44
#include "openaxiom-c-macros.h"
45
#include "debug.h"
46
#include "halloc.h"
47
#include "sockio.h"
48
#include "extent.h"
49
#include "display.h"
50
#include "group.h"
51
#include "initx.h"
52
#include "scrollbar.h"
53
#include "parse.h"
54
55
/*************************************************************************
56
Scrollbar Comments 10/08/89
57
58
The scrollbar is displayed on the side of the HyperDoc display, if needed.
59
It is composed of four windows
60
61
fScrollUpWindow -- the arrowed box at the top of the scrollbar. Scrolls the
62
window up a line at a time.
63
fScrollDownWindow -- Located at the bottom of the window, it is used to scroll
64
down a single line at a time.
65
scrollbar -- this is the window which does the variable scrolling. It
66
houses the actual scroller.
67
scroller -- This is the scroller inside the scroll bar.
68
69
The procedure below, makes all these windows, and also makes three bitmaps,
70
sup -- The up arrow for the fScrollUpWindow.
71
sdown -- the down arrow for the fScrollDownWindow.
72
scroller -- the scroller stipple.
73
It then fills the window with the proper Pixmap background.
74
75
The scrollbar and scroller works as follows. The size of the scroller is
76
calculated as
77
78
size of scroller size of visible text
79
----------------- === ------------------------------ .
80
size of scrollbar size of whole scrolling region
81
82
The top of the scroller shows the relative position in the page of
83
the top of the scrolling region. This way the user knows how far
84
down the page he or she has moved.
85
When the user clicks in the scrollbar, the center of the
86
scroller, if possible, is placed at the point of the click.
87
88
See the routines
89
showScrollBars -- to see how the scroll bars are actually realized.
90
moveScroller -- to see how the scroller is moved when the user scrolls
91
92
93
**************************************************************************/
94
95
static int ch(int height);
96
static void changeWindowBackgroundPixmap(Window window , Pixmap pixmap);
97
static void drawScroller3DEffects(HDWindow * hdWindow , int x1 , int y1 , int x2 , int y2);
98
99
static int ch(int height);
100
static void changeWindowBackgroundPixmap(Window window, Pixmap pixmap);
101
102
static Pixmap sup = 0, sdown = 0, sup_pressed = 0, sdown_pressed = 0, scroller = 0, scrollbar_pix = 0;
103
104
105
/* #undef BITMAPS2D to get old style 2d effect */
106
107
#ifdef BITMAPS2D
108
109
#define CONTROLS_3D 0
110
111
#include "sdown.bitmap"
112
#include "sup.bitmap"
113
114
#define BACKCOLOR gBackgroundColor
115
#define FORECOLOR gActiveColor
116
117
#else
118
119
#define CONTROLS_3D 1
120
121
#include "sdown3d.bitmap"
122
#include "sdown3dpr.bitmap"
123
124
#include "sup3d.bitmap"
125
#include "sup3dpr.bitmap"
126
127
#define sup_width sup3d_width
128
#define sup_height sup3d_height
129
#define sup_bits sup3d_bits
130
131
#define sdown_width sdown3d_width
132
#define sdown_height sdown3d_height
133
#define sdown_bits sdown3d_bits
134
135
#define BACKCOLOR gControlBackgroundColor
136
#define FORECOLOR gControlForegroundColor
137
138
#endif
139
140
141
#if 0
142
#define scroller_width 3
143
#define scroller_height 3
144
static char scroller_bits[] = {0x05, 0x07, 0x03};
145
146
#endif
147
148
#define scroller_width 2
149
#define scroller_height 2
150
static char scroller_bits[] = {
151
0x01, 0x02};
152
153
154
155
static int supheight = sup_height;
156
static int supwidth = sup_width;
157
158
#define scrollbar_pix_width 3
159
#define scrollbar_pix_height 3
160
static char scrollbar_pix_bits[] = {0x00, 0x03, 0x00};
161
162
163
164
int gScrollbarWidth = sup_width + 2;
165
166
167
168
void
169
makeScrollBarWindows()
170
{
171
XSetWindowAttributes at;
172
173
at.cursor = gActiveCursor;
174
at.event_mask = ButtonPress;
175
/** create the bitmaps **/
176
if (supwidth != sdown_width || supheight != sdown_height) {
177
fprintf(stderr,
178
"Scrollbar error, up and down pointers must have the same dimensions\n");
179
exit(-1);
180
}
181
182
if (sup == 0)
183
sup = XCreatePixmapFromBitmapData(
184
gXDisplay,
185
RootWindow(gXDisplay, gXScreenNumber),
186
const_cast<char*>(as_chars(sup_bits)), supwidth, supheight,
187
FORECOLOR, BACKCOLOR,
188
DefaultDepth(gXDisplay, gXScreenNumber));
189
190
if (sdown == 0)
191
sdown = XCreatePixmapFromBitmapData(
192
gXDisplay,
193
RootWindow(gXDisplay, gXScreenNumber),
194
const_cast<char*>(as_chars(sdown_bits)), sdown_width, sdown_height,
195
FORECOLOR, BACKCOLOR,
196
DefaultDepth(gXDisplay, gXScreenNumber));
197
198
if (CONTROLS_3D) {
199
sup_pressed = XCreatePixmapFromBitmapData(
200
gXDisplay,
201
RootWindow(gXDisplay, gXScreenNumber),
202
const_cast<char*>(as_chars(sup3dpr_bits)), sup3dpr_width, sup3dpr_height,
203
FORECOLOR, BACKCOLOR,
204
DefaultDepth(gXDisplay, gXScreenNumber));
205
sdown_pressed = XCreatePixmapFromBitmapData(
206
gXDisplay,
207
RootWindow(gXDisplay, gXScreenNumber),
208
const_cast<char*>(as_chars(sdown3dpr_bits)), sdown3dpr_width, sdown3dpr_height,
209
FORECOLOR, BACKCOLOR,
210
DefaultDepth(gXDisplay, gXScreenNumber));
211
}
212
213
gWindow->fScrollUpWindow = XCreateSimpleWindow(gXDisplay, gWindow->fMainWindow,
214
1, 1, supwidth, supheight,
215
gWindow->border_width,
216
gBorderColor,
217
BACKCOLOR);
218
219
gWindow->fScrollDownWindow = XCreateSimpleWindow(gXDisplay, gWindow->fMainWindow,
220
1, 1, sdown_width, sdown_height,
221
gWindow->border_width,
222
gBorderColor,
223
BACKCOLOR);
224
225
gWindow->scrollbar = XCreateSimpleWindow(gXDisplay, gWindow->fMainWindow,
226
1, 1, 1, 1,
227
gWindow->border_width,
228
gBorderColor,
229
BACKCOLOR);
230
gWindow->scroller = XCreateSimpleWindow(gXDisplay, gWindow->scrollbar,
231
1, 1, 1, 1, 0,
232
gBorderColor,
233
BACKCOLOR);
234
235
#ifdef DEBUG
236
fprintf(stderr, "Changing Window Attributes in scrollbar.c #2\n");
237
#endif
238
239
at.background_pixmap = sup;
240
XChangeWindowAttributes(gXDisplay, gWindow->fScrollUpWindow,
241
CWBackPixmap | CWEventMask | CWCursor, &at);
242
243
at.background_pixmap = sdown;
244
XChangeWindowAttributes(gXDisplay, gWindow->fScrollDownWindow,
245
CWBackPixmap | CWEventMask | CWCursor, &at);
246
247
XChangeWindowAttributes(gXDisplay, gWindow->scrollbar,
248
CWEventMask | CWCursor, &at);
249
250
251
if (scroller == 0)
252
scroller = XCreatePixmapFromBitmapData(gXDisplay,
253
RootWindow(gXDisplay, gXScreenNumber),
254
scroller_bits, scroller_width,
255
scroller_height,
256
FORECOLOR,
257
BACKCOLOR,
258
DefaultDepth(gXDisplay, gXScreenNumber));
259
if (scrollbar_pix == 0)
260
scrollbar_pix = XCreatePixmapFromBitmapData(gXDisplay,
261
RootWindow(gXDisplay, gXScreenNumber),
262
scrollbar_pix_bits,
263
scrollbar_pix_width,
264
scrollbar_pix_height,
265
FORECOLOR,
266
BACKCOLOR,
267
DefaultDepth(gXDisplay, gXScreenNumber));
268
269
at.background_pixmap = scroller;
270
XChangeWindowAttributes(gXDisplay, gWindow->scroller,
271
CWBackPixmap | CWCursor, &at);
272
at.background_pixmap = scrollbar_pix;
273
XChangeWindowAttributes(gXDisplay, gWindow->scrollbar,
274
CWBackPixmap, &at);
275
}
276
277
static void
278
drawScroller3DEffects(HDWindow * hdWindow, int x1, int y1, int x2, int y2)
279
{
280
XClearWindow(gXDisplay, hdWindow->scroller);
281
282
/* draw right "black" line */
283
284
XDrawLine(gXDisplay, hdWindow->scroller, hdWindow->fControlGC,
285
x2 - 3, y1 + 2, x2 - 3, y2 - 3);
286
287
/* draw bottom "black" line */
288
289
XDrawLine(gXDisplay, hdWindow->scroller, hdWindow->fControlGC,
290
x1 + 2, y2 - 3, x2 - 3, y2 - 3);
291
292
/* flip foreground and background colors */
293
294
XSetBackground(gXDisplay, hdWindow->fControlGC, gControlForegroundColor);
295
XSetForeground(gXDisplay, hdWindow->fControlGC, gControlBackgroundColor);
296
297
/* draw top "white" line */
298
299
XDrawLine(gXDisplay, hdWindow->scroller, hdWindow->fControlGC,
300
x1 + 2, y1 + 2, x2 - 3, y1 + 2);
301
302
/* draw left "white" line */
303
304
XDrawLine(gXDisplay, hdWindow->scroller, hdWindow->fControlGC,
305
x1 + 2, y1 + 2, x1 + 2, y2 - 3);
306
307
/* reset colors */
308
309
XSetBackground(gXDisplay, hdWindow->fControlGC, gControlBackgroundColor);
310
XSetForeground(gXDisplay, hdWindow->fControlGC, gControlForegroundColor);
311
}
312
313
void
314
showScrollBars(HDWindow * hdWindow)
315
{
316
XWindowChanges wc;
317
/*int src_x = 0, src_y = 0;*/
318
/*unsigned int width = supwidth, height = supheight;*/
319
/*int dest_x = 0, dest_y = 0;*/
320
321
/* see if we even need scroll bars */
322
323
if (hdWindow->page->scrolling->height <= hdWindow->scrollheight)
324
return;
325
326
wc.x = hdWindow->scrollx;
327
wc.y = hdWindow->scrollupy;
328
wc.height = supheight;
329
wc.width = supwidth;
330
XConfigureWindow(gXDisplay, hdWindow->fScrollUpWindow, CWX | CWY | CWHeight
331
| CWWidth, &wc);
332
wc.y = hdWindow->scrolldowny;
333
XConfigureWindow(gXDisplay, hdWindow->fScrollDownWindow,
334
CWX | CWY | CWHeight | CWWidth,
335
&wc);
336
wc.height = hdWindow->fScrollBarHeight;
337
wc.y = hdWindow->scrollbary;
338
XConfigureWindow(gXDisplay, hdWindow->scrollbar,
339
CWX | CWY | CWHeight | CWWidth,
340
&wc);
341
wc.x = 0;
342
wc.y = hdWindow->fScrollerTopPos;
343
wc.width = supwidth;
344
wc.height = hdWindow->fScrollerHeight;
345
XConfigureWindow(gXDisplay, hdWindow->scroller,
346
CWX | CWY | CWHeight | CWWidth,
347
&wc);
348
349
/*
350
* Now we map the windows, since the bitmaps are the backgrounds for the
351
* windows, we need to worry about redrawing them.
352
*/
353
354
XMapWindow(gXDisplay, hdWindow->fScrollUpWindow);
355
XMapWindow(gXDisplay, hdWindow->fScrollDownWindow);
356
XMapWindow(gXDisplay, hdWindow->scrollbar);
357
XMapWindow(gXDisplay, hdWindow->scroller);
358
359
drawScroller3DEffects(hdWindow, 0, 0, wc.width, wc.height);
360
}
361
362
363
/************************************************************************
364
365
Moves the scroller to its proper place within the scrollbar. It
366
calculates how far down the page we are, and then moves the scroller
367
accordingly
368
369
**************************************************************************/
370
371
void
372
moveScroller(HDWindow * hdWindow)
373
{
374
XWindowChanges wc;
375
376
/** moves the scroller to it's proper place **/
377
378
int t = (int) (hdWindow->fScrollBarHeight * (-hdWindow->page->scroll_off));
379
hdWindow->fScrollerTopPos = (int) (t / hdWindow->page->scrolling->height);
380
wc.x = 0;
381
wc.y = hdWindow->fScrollerTopPos;
382
wc.width = supwidth;
383
wc.height = hdWindow->fScrollerHeight;
384
XConfigureWindow(gXDisplay, hdWindow->scroller,
385
CWX | CWY | CWHeight | CWWidth,
386
&wc);
387
drawScroller3DEffects(hdWindow, 0, 0, wc.width, wc.height);
388
}
389
390
#define tophalf(y) ((y % 2 == 0)?(y/2):(y/2) + 1)
391
#define bothalf(y) (y/2)
392
393
void
394
drawScrollLines()
395
{
396
/* Checks the page_flags to see if we need a top, or a bottom line. */
397
/* These are the horizontal lines framing a scrolling region when the */
398
/* scrolling region is not the entire window. */
399
400
if (!(gWindow->page->page_flags & NOLINES)) {
401
line_top_group();
402
if (gWindow->page->header->height) {
403
XDrawLine(gXDisplay, gWindow->fMainWindow, gWindow->fStandardGC,
404
0,
405
gWindow->page->top_scroll_margin - tophalf(gWindow->border_width)
406
- 2 * scroll_top_margin,
407
gWindow->scrollwidth,
408
gWindow->page->top_scroll_margin - tophalf(gWindow->border_width)
409
- 2 * scroll_top_margin);
410
}
411
if (gWindow->page->footer->height) {
412
XDrawLine(gXDisplay, gWindow->fMainWindow, gWindow->fStandardGC,
413
0,
414
gWindow->page->bot_scroll_margin + bothalf(gWindow->border_width) - 1,
415
gWindow->scrollwidth,
416
gWindow->page->bot_scroll_margin + bothalf(gWindow->border_width) - 1);
417
}
418
pop_group_stack();
419
}
420
}
421
422
423
/*
424
* Calculates all the measures for the scrollbars
425
*/
426
427
void
428
calculateScrollBarMeasures()
429
{
430
int t;
431
432
/*
433
* The scrollhieght is the height of the scrolling region visible in the
434
* HT window. Notice how it is a multiple of line height. This was needed
435
* to make everything scroll nicely.
436
*/
437
438
gWindow->scrollheight = gWindow->page->bot_scroll_margin -
439
gWindow->page->top_scroll_margin - scroll_top_margin;
440
gWindow->scrollheight = gWindow->scrollheight - gWindow->scrollheight % line_height;
441
442
/*
443
* Now do a quick check to see if I really need a scroll bar, and if not,
444
* just return right away
445
*/
446
447
if (gWindow->scrollheight >= gWindow->page->scrolling->height) {
448
gWindow->page->scroll_off = 0;
449
return;
450
}
451
452
/*
453
* The height of the scrollbar region, extends form the top page margin
454
* all the way to the bottom, excluding the room needed for the up and
455
* down windows
456
*/
457
458
gWindow->fScrollBarHeight = gWindow->page->bot_scroll_margin -
459
gWindow->page->top_scroll_margin - 2 * supheight -
460
2 * gWindow->border_width;
461
462
gWindow->scrollupy = gWindow->page->top_scroll_margin - gWindow->border_width;
463
gWindow->scrollupy -= 2 * scroll_top_margin;
464
gWindow->scrolldowny = gWindow->page->bot_scroll_margin
465
- supheight - gWindow->border_width;
466
gWindow->scrollbary = gWindow->scrollupy + supheight + gWindow->border_width;
467
gWindow->scrollx = gWindow->width - supwidth - gWindow->border_width;
468
469
/*
470
* the scroller height is calculated from the following formula
471
*
472
* fScrollerHeight scrollheight -------------- ==
473
* --------- ------------- fScrollBarHeight
474
* page->scrolling_height
475
*
476
*/
477
478
gWindow->fScrollerHeight = 1 + 2 * scroll_top_margin + /** possible integer error correction **/
479
(int) (gWindow->fScrollBarHeight * gWindow->scrollheight / gWindow->page->scrolling->height);
480
481
/*
482
* Check the scroll offset, to see if it is too Large
483
*/
484
485
if (-(gWindow->page->scroll_off) >
486
(gWindow->page->scrolling->height - gWindow->scrollheight))
487
gWindow->page->scroll_off =
488
-(gWindow->page->scrolling->height - gWindow->scrollheight);
489
490
/*
491
* Then move the top of the scroller to it's proper position
492
*/
493
494
gWindow->fScrollBarHeight += 2 * scroll_top_margin;
495
t = (int) (gWindow->fScrollBarHeight * (-gWindow->page->scroll_off));
496
gWindow->fScrollerTopPos = (int) (t / (gWindow->page->scrolling->height));
497
}
498
499
void
500
linkScrollBars()
501
{
502
HyperLink *uplink = (HyperLink *) halloc(sizeof(HyperLink), "HyperLink");
503
HyperLink *downlink = (HyperLink *) halloc(sizeof(HyperLink), "HyperLink");
504
HyperLink *barlink = (HyperLink *) halloc(sizeof(HyperLink), "HyperLink");
505
506
uplink->win = gWindow->fScrollUpWindow;
507
downlink->win = gWindow->fScrollDownWindow;
508
barlink->win = gWindow->scrollbar;
509
uplink->type = Scrollupbutton;
510
downlink->type = Scrolldownbutton;
511
barlink->type = openaxiom_Scrollbar_token;
512
barlink->x = barlink->y = 0;
513
uplink->x = uplink->y = 0;
514
downlink->x = downlink->y = 0;
515
uplink->reference.node = NULL;
516
downlink->reference.node = NULL;
517
hash_insert(gLinkHashTable, (char *)uplink,(char *) &uplink->win);
518
hash_insert(gLinkHashTable, (char *)barlink,(char *) &barlink->win);
519
hash_insert(gLinkHashTable, (char *)downlink,(char *) &downlink->win);
520
}
521
522
void
523
scrollUp()
524
{
525
526
if (gWindow->page->scroll_off == 0); /* BeepAtTheUser(); *//* The
527
* beeping annoyed me. RSS */
528
else {
529
changeWindowBackgroundPixmap(gWindow->fScrollUpWindow, sup_pressed);
530
531
gWindow->page->scroll_off += line_height; /* Scroll a line */
532
if (gWindow->page->scroll_off > 0)
533
gWindow->page->scroll_off = 0;
534
XCopyArea(gXDisplay, gWindow->fScrollWindow, gWindow->fScrollWindow, gWindow->fStandardGC,
535
0, 0,
536
gWindow->scrollwidth, gWindow->scrollheight - line_height + 1,
537
0, line_height);
538
XClearArea(gXDisplay, gWindow->fScrollWindow, 0, 0,
539
gWindow->scrollwidth,
540
line_height, False);
541
scroll_page(gWindow->page);
542
543
changeWindowBackgroundPixmap(gWindow->fScrollUpWindow, sup);
544
}
545
546
}
547
548
void
549
scrollUpPage()
550
{
551
if (gWindow->page->scroll_off == 0); /* BeepAtTheUser(); */
552
else {
553
/* Scroll a page */
554
555
gWindow->page->scroll_off += ch(gWindow->scrollheight) - line_height;
556
if (gWindow->page->scroll_off > 0)
557
gWindow->page->scroll_off = 0;
558
559
XClearWindow(gXDisplay, gWindow->fScrollWindow);
560
scroll_page(gWindow->page);
561
}
562
}
563
564
void
565
scrollToFirstPage()
566
{
567
if (gWindow->page->scroll_off == 0); /* BeepAtTheUser(); */
568
else {
569
gWindow->page->scroll_off = 0;
570
XClearWindow(gXDisplay, gWindow->fScrollWindow);
571
scroll_page(gWindow->page);
572
}
573
}
574
575
void
576
scrollDown()
577
{
578
579
if (-(gWindow->page->scroll_off) >=
580
(gWindow->page->scrolling->height - gWindow->scrollheight)) {
581
; /* BeepAtTheUser(); */
582
}
583
else {
584
changeWindowBackgroundPixmap(gWindow->fScrollDownWindow, sdown_pressed);
585
586
gWindow->page->scroll_off -= line_height; /* Scroll a line */
587
588
XCopyArea(gXDisplay, gWindow->fScrollWindow, gWindow->fScrollWindow, gWindow->fStandardGC,
589
0, line_height,
590
gWindow->scrollwidth, gWindow->scrollheight - line_height + 1,
591
0, 0);
592
XClearArea(gXDisplay, gWindow->fScrollWindow, 0,
593
gWindow->scrollheight - line_height,
594
gWindow->scrollwidth,
595
line_height, False);
596
scroll_page(gWindow->page);
597
598
changeWindowBackgroundPixmap(gWindow->fScrollDownWindow, sdown);
599
}
600
}
601
602
603
void
604
scrollDownPage()
605
{
606
if (gWindow->page->scrolling == NULL || (-(gWindow->page->scroll_off) >=
607
(gWindow->page->scrolling->height - gWindow->scrollheight))) {
608
; /* BeepAtTheUser(); */
609
}
610
else {
611
gWindow->page->scroll_off -= ch(gWindow->scrollheight) - line_height;
612
613
if (-(gWindow->page->scroll_off) >
614
(gWindow->page->scrolling->height - gWindow->scrollheight))
615
gWindow->page->scroll_off = -
616
(gWindow->page->scrolling->height - gWindow->scrollheight);
617
618
XClearWindow(gXDisplay, gWindow->fScrollWindow);
619
620
scroll_page(gWindow->page);
621
}
622
}
623
624
void
625
scrollScroller(XButtonEvent * event)
626
{
627
628
/*
629
* This routine checks to see where in the window the button press
630
* occured. It then tries to move the scroller so that the top of the
631
* scroller is at the spot of the event
632
*/
633
634
int y = event->y;
635
int top = y;
636
637
if (top < 0) {
638
top = 0;
639
if (gWindow->fScrollerTopPos == 0)
640
return;
641
gWindow->page->scroll_off = 0;
642
}
643
else if ((top + gWindow->fScrollerHeight) > gWindow->fScrollBarHeight) {
644
top = gWindow->fScrollBarHeight - gWindow->fScrollerHeight;
645
if (top == gWindow->fScrollerTopPos)
646
return;
647
gWindow->page->scroll_off =
648
-(gWindow->page->scrolling->height - gWindow->scrollheight);
649
gWindow->page->scroll_off -= gWindow->page->scroll_off % line_height;
650
}
651
else { /** top is in an ok spot **/
652
int t;
653
654
t = -(gWindow->page->scrolling->height) * top;
655
t = t / (gWindow->fScrollBarHeight);
656
if (gWindow->page->scroll_off == (t -= t % line_height))
657
return;
658
gWindow->page->scroll_off = t;
659
gWindow->fScrollerTopPos = top;
660
}
661
XClearWindow(gXDisplay, gWindow->fScrollWindow);
662
scroll_page(gWindow->page);
663
}
664
665
666
void
667
hideScrollBars(HDWindow * hdWindow)
668
{
669
XUnmapWindow(gXDisplay, hdWindow->fScrollDownWindow);
670
XUnmapWindow(gXDisplay, hdWindow->fScrollUpWindow);
671
XUnmapWindow(gXDisplay, hdWindow->scrollbar);
672
XUnmapWindow(gXDisplay, hdWindow->scroller);
673
}
674
675
void
676
getScrollBarMinimumSize(int *width, int *height)
677
{
678
(*width) = sup_width + 4;
679
(*height) = sup_height + sdown_height + 5;
680
}
681
682
static int
683
ch(int height)
684
{
685
/*int rheight;*/
686
int rem = height % line_height;
687
688
if (rem == 0)
689
return height;
690
return height - rem + line_height;
691
}
692
693
static void
694
changeWindowBackgroundPixmap(Window window, Pixmap pixmap)
695
{
696
if (pixmap) {
697
XSetWindowAttributes at;
698
699
at.background_pixmap = pixmap;
700
XChangeWindowAttributes(gXDisplay, window, CWBackPixmap, &at);
701
XClearWindow(gXDisplay, window);
702
}
703
}
704
705