]> git.saurik.com Git - apple/boot.git/blob - i386/boot2/old/scrollbar.c
31d659eeee93ce5dad3dd842396e1ab6e7655ca3
[apple/boot.git] / i386 / boot2 / old / scrollbar.c
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
12 * this file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
20 * under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24 /*
25 * Copyright 1993 NeXT, Inc.
26 * All rights reserved.
27 */
28
29 #import "libsa.h"
30 #import "console.h"
31 #import "fontio.h"
32 #import "graphics.h"
33 #import "scrollbar.h"
34
35
36 scroll_t *initScrollbar(
37 scroll_t *sp,
38 int x,
39 int y,
40 int w,
41 int h,
42 int position, /* 0 - 100 */
43 int percent /* 0 - 100 */
44 )
45 {
46 sp->loc.x = x;
47 sp->loc.y = y;
48 sp->loc.w = w;
49 sp->loc.h = h;
50 sp->position = position;
51 sp->percent = percent;
52 return sp;
53 }
54
55 #if 0
56 void destroyScrollbar(
57 scroll_t *sp
58 )
59 {
60 (void)zfree((char *)sp);
61 }
62 #endif
63
64 void drawScrollbar(
65 scroll_t *sp
66 )
67 {
68 clearRect(sp->loc.x, sp->loc.y, sp->loc.w, sp->loc.h, SB_BG);
69 // clearRect(sp->loc.x, sp->loc.y, sp->loc.w, 1, COLOR_BLACK);
70 // clearRect(sp->loc.x, sp->loc.y + sp->loc.h - 1, sp->loc.w, 1, COLOR_BLACK);
71 // clearRect(sp->loc.x, sp->loc.y, 1, sp->loc.h, COLOR_BLACK);
72 clearRect(sp->loc.x + sp->loc.w - 1, sp->loc.y, 1, sp->loc.h, COLOR_BLACK);
73 if (sp->percent < 100)
74 popupBox(sp->loc.x + SB_MARGIN,
75 sp->loc.y + (sp->position * (sp->loc.h - 2 * SB_MARGIN)) / 100,
76 sp->loc.w - 3 * SB_MARGIN,
77 (sp->loc.h - 2 * SB_MARGIN) * sp->percent / 100,
78 TEXT_BG, POPUP_OUT);
79 }
80
81 #if 0
82 void clearScrollbar(
83 scroll_t *sp,
84 int color
85 )
86 {
87 clearRect(sp->loc.x, sp->loc.y, sp->loc.w, sp->loc.h, color);
88 }
89 #endif