add cssrendering_coordinate_t.
@@ -0,0 +1,52 @@ | ||
1 | +/* | |
2 | + * cssrendering_coodinate.h | |
3 | + * | |
4 | + * Copyright (c) 2013 project bchan | |
5 | + * | |
6 | + * This software is provided 'as-is', without any express or implied | |
7 | + * warranty. In no event will the authors be held liable for any damages | |
8 | + * arising from the use of this software. | |
9 | + * | |
10 | + * Permission is granted to anyone to use this software for any purpose, | |
11 | + * including commercial applications, and to alter it and redistribute it | |
12 | + * freely, subject to the following restrictions: | |
13 | + * | |
14 | + * 1. The origin of this software must not be misrepresented; you must not | |
15 | + * claim that you wrote the original software. If you use this software | |
16 | + * in a product, an acknowledgment in the product documentation would be | |
17 | + * appreciated but is not required. | |
18 | + * | |
19 | + * 2. Altered source versions must be plainly marked as such, and must not be | |
20 | + * misrepresented as being the original software. | |
21 | + * | |
22 | + * 3. This notice may not be removed or altered from any source | |
23 | + * distribution. | |
24 | + * | |
25 | + */ | |
26 | + | |
27 | +#include <basic.h> | |
28 | + | |
29 | +#include "cssmetric.h" | |
30 | + | |
31 | +#ifndef __CSSRENDERING_COORDINATE_H__ | |
32 | +#define __CSSRENDERING_COORDINATE_H__ | |
33 | + | |
34 | +/* Functionality name: cssrendering */ | |
35 | +/* Detail name: coordinate */ | |
36 | +struct cssrendering_coordinate_t_ { | |
37 | + cssmetric_rectangle_t draw; | |
38 | + cssmetric_rectangle_t view; | |
39 | +}; | |
40 | +typedef struct cssrendering_coordinate_t_ cssrendering_coordinate_t; | |
41 | + | |
42 | +IMPORT VOID cssrendering_coordinate_initialize(cssrendering_coordinate_t *scroll); | |
43 | +IMPORT VOID cssrendering_coordinate_finalize(cssrendering_coordinate_t *scroll); | |
44 | +IMPORT VOID cssrendering_coordinate_getabsoluterect(cssrendering_coordinate_t *scroll, RECT src, cssmetric_rectangle_t *dest); | |
45 | +IMPORT VOID cssrendering_coordinate_getrelativepoint(cssrendering_coordinate_t *scroll, W src_x, W src_y, W *dest_x, W *dest_y); | |
46 | +IMPORT VOID cssrendering_coordinate_setdrawrect(cssrendering_coordinate_t *scroll, cssmetric_rectangle_t draw); | |
47 | +IMPORT VOID cssrendering_coordinate_getdrawrect(cssrendering_coordinate_t *scroll, W *l, W *t, W *r, W *b); | |
48 | +IMPORT VOID cssrendering_coordinate_setviewrect(cssrendering_coordinate_t *scroll, W l, W t, W r, W b); | |
49 | +IMPORT VOID cssrendering_coordinate_getviewrect(cssrendering_coordinate_t *scroll, W *l, W *t, W *r, W *b); | |
50 | +IMPORT VOID cssrendering_coordinate_scrollviewrect(cssrendering_coordinate_t *scroll, W dh, W dv); | |
51 | + | |
52 | +#endif |
@@ -0,0 +1,98 @@ | ||
1 | +/* | |
2 | + * cssrendering_coordinate.c | |
3 | + * | |
4 | + * Copyright (c) 2013 project bchan | |
5 | + * | |
6 | + * This software is provided 'as-is', without any express or implied | |
7 | + * warranty. In no event will the authors be held liable for any damages | |
8 | + * arising from the use of this software. | |
9 | + * | |
10 | + * Permission is granted to anyone to use this software for any purpose, | |
11 | + * including commercial applications, and to alter it and redistribute it | |
12 | + * freely, subject to the following restrictions: | |
13 | + * | |
14 | + * 1. The origin of this software must not be misrepresented; you must not | |
15 | + * claim that you wrote the original software. If you use this software | |
16 | + * in a product, an acknowledgment in the product documentation would be | |
17 | + * appreciated but is not required. | |
18 | + * | |
19 | + * 2. Altered source versions must be plainly marked as such, and must not be | |
20 | + * misrepresented as being the original software. | |
21 | + * | |
22 | + * 3. This notice may not be removed or altered from any source | |
23 | + * distribution. | |
24 | + * | |
25 | + */ | |
26 | + | |
27 | +#include "cssrendering_coordinate.h" | |
28 | + | |
29 | +#include <bstdio.h> | |
30 | + | |
31 | +#include "cssmetric.h" | |
32 | + | |
33 | +#ifdef BCHAN_CONFIG_DEBUG | |
34 | +# define DP(arg) printf arg | |
35 | +# define DP_ER(msg, err) printf("%s (%d/%x)\n", msg, err>>16, err) | |
36 | +#else | |
37 | +# define DP(arg) /**/ | |
38 | +# define DP_ER(msg, err) /**/ | |
39 | +#endif | |
40 | + | |
41 | +EXPORT VOID cssrendering_coordinate_getabsoluterect(cssrendering_coordinate_t *scroll, RECT src, cssmetric_rectangle_t *dest) | |
42 | +{ | |
43 | + dest->c.left = src.c.left + scroll->view.c.left; | |
44 | + dest->c.top = src.c.top + scroll->view.c.top; | |
45 | + dest->c.right = src.c.right + scroll->view.c.left; | |
46 | + dest->c.bottom = src.c.bottom + scroll->view.c.top; | |
47 | +} | |
48 | + | |
49 | +EXPORT VOID cssrendering_coordinate_getrelativepoint(cssrendering_coordinate_t *scroll, W src_x, W src_y, W *dest_x, W *dest_y) | |
50 | +{ | |
51 | + *dest_x = src_x - scroll->view.c.left; | |
52 | + *dest_y = src_y - scroll->view.c.top; | |
53 | +} | |
54 | + | |
55 | +EXPORT VOID cssrendering_coordinate_setdrawrect(cssrendering_coordinate_t *scroll, cssmetric_rectangle_t draw) | |
56 | +{ | |
57 | + scroll->draw = draw; | |
58 | +} | |
59 | + | |
60 | +EXPORT VOID cssrendering_coordinate_getdrawrect(cssrendering_coordinate_t *scroll, W *l, W *t, W *r, W *b) | |
61 | +{ | |
62 | + *l = scroll->draw.c.left; | |
63 | + *t = scroll->draw.c.top; | |
64 | + *r = scroll->draw.c.right; | |
65 | + *b = scroll->draw.c.bottom; | |
66 | +} | |
67 | + | |
68 | +EXPORT VOID cssrendering_coordinate_setviewrect(cssrendering_coordinate_t *scroll, W l, W t, W r, W b) | |
69 | +{ | |
70 | + scroll->view.c.left = l; | |
71 | + scroll->view.c.top = t; | |
72 | + scroll->view.c.right = r; | |
73 | + scroll->view.c.bottom = b; | |
74 | +} | |
75 | + | |
76 | +EXPORT VOID cssrendering_coordinate_getviewrect(cssrendering_coordinate_t *scroll, W *l, W *t, W *r, W *b) | |
77 | +{ | |
78 | + *l = scroll->view.c.left; | |
79 | + *t = scroll->view.c.top; | |
80 | + *r = scroll->view.c.right; | |
81 | + *b = scroll->view.c.bottom; | |
82 | +} | |
83 | + | |
84 | +EXPORT VOID cssrendering_coordinate_scrollviewrect(cssrendering_coordinate_t *scroll, W dh, W dv) | |
85 | +{ | |
86 | + scroll->view.c.left += dh; | |
87 | + scroll->view.c.top += dv; | |
88 | + scroll->view.c.right += dh; | |
89 | + scroll->view.c.bottom += dv; | |
90 | +} | |
91 | + | |
92 | +EXPORT VOID cssrendering_coordinate_initialize(cssrendering_coordinate_t *scroll) | |
93 | +{ | |
94 | +} | |
95 | + | |
96 | +EXPORT VOID cssrendering_coordinate_finalize(cssrendering_coordinate_t *scroll) | |
97 | +{ | |
98 | +} |