1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* |
4 |
|
|
* This program and the accompanying materials are made available under the |
5 |
|
|
* terms of the MIT License which is available at |
6 |
|
|
* https://opensource.org/licenses/MIT. |
7 |
|
|
* |
8 |
|
|
* SPDX-License-Identifier: MIT |
9 |
|
|
**************************************************************************/ |
10 |
|
|
|
11 |
|
|
|
12 |
|
|
/**************************************************************************/ |
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/** */ |
15 |
|
|
/** GUIX Component */ |
16 |
|
|
/** */ |
17 |
|
|
/** Icon Management (Icon) */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
|
21 |
|
|
#define GX_SOURCE_CODE |
22 |
|
|
|
23 |
|
|
|
24 |
|
|
/* Include necessary system files. */ |
25 |
|
|
|
26 |
|
|
#include "gx_api.h" |
27 |
|
|
#include "gx_system.h" |
28 |
|
|
#include "gx_canvas.h" |
29 |
|
|
#include "gx_context.h" |
30 |
|
|
#include "gx_widget.h" |
31 |
|
|
#include "gx_icon.h" |
32 |
|
|
|
33 |
|
|
|
34 |
|
|
/**************************************************************************/ |
35 |
|
|
/* */ |
36 |
|
|
/* FUNCTION RELEASE */ |
37 |
|
|
/* */ |
38 |
|
|
/* _gx_icon_background_draw PORTABLE C */ |
39 |
|
|
/* 6.1 */ |
40 |
|
|
/* AUTHOR */ |
41 |
|
|
/* */ |
42 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
43 |
|
|
/* */ |
44 |
|
|
/* DESCRIPTION */ |
45 |
|
|
/* */ |
46 |
|
|
/* This function draws the background of specified icon. */ |
47 |
|
|
/* */ |
48 |
|
|
/* INPUT */ |
49 |
|
|
/* */ |
50 |
|
|
/* icon Icon widget control block */ |
51 |
|
|
/* */ |
52 |
|
|
/* OUTPUT */ |
53 |
|
|
/* */ |
54 |
|
|
/* None */ |
55 |
|
|
/* */ |
56 |
|
|
/* CALLS */ |
57 |
|
|
/* */ |
58 |
|
|
/* _gx_context_pixelmap_get Retrieve pixelmap image */ |
59 |
|
|
/* _gx_canvas_pixelmap_draw Draw pixelmap */ |
60 |
|
|
/* _gx_widget_context_fill_set Set fill color */ |
61 |
|
|
/* _gx_widget_background_draw Retrieve pixelmap image */ |
62 |
|
|
/* */ |
63 |
|
|
/* CALLED BY */ |
64 |
|
|
/* */ |
65 |
|
|
/* Application Code */ |
66 |
|
|
/* GUIX Internal Code */ |
67 |
|
|
/* */ |
68 |
|
|
/* RELEASE HISTORY */ |
69 |
|
|
/* */ |
70 |
|
|
/* DATE NAME DESCRIPTION */ |
71 |
|
|
/* */ |
72 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
73 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
74 |
|
|
/* resulting in version 6.1 */ |
75 |
|
|
/* */ |
76 |
|
|
/**************************************************************************/ |
77 |
|
18814 |
VOID _gx_icon_background_draw(GX_ICON *icon) |
78 |
|
|
{ |
79 |
|
18814 |
GX_WIDGET *widget = (GX_WIDGET *)icon; |
80 |
|
|
GX_PIXELMAP *map; |
81 |
|
|
GX_VALUE xpos; |
82 |
|
|
GX_VALUE ypos; |
83 |
|
|
GX_VALUE size; |
84 |
|
|
|
85 |
✓✓ |
18814 |
if (icon -> gx_icon_selected_pixelmap && |
86 |
✓✓ |
16 |
widget -> gx_widget_style & GX_STYLE_DRAW_SELECTED) |
87 |
|
|
{ |
88 |
|
1 |
_gx_context_pixelmap_get(icon -> gx_icon_selected_pixelmap, &map); |
89 |
|
|
} |
90 |
|
|
else |
91 |
|
|
{ |
92 |
|
18813 |
_gx_context_pixelmap_get(icon -> gx_icon_normal_pixelmap, &map); |
93 |
|
|
} |
94 |
|
|
|
95 |
✓✓ |
18814 |
if (map) |
96 |
|
|
{ |
97 |
|
18741 |
_gx_widget_context_fill_set(widget); |
98 |
|
|
|
99 |
✓✓✓ |
18741 |
switch(widget -> gx_widget_style & GX_PIXELMAP_HALIGN_MASK) |
100 |
|
|
{ |
101 |
|
2 |
case GX_STYLE_HALIGN_RIGHT: |
102 |
|
2 |
xpos = (GX_VALUE) (widget -> gx_widget_size.gx_rectangle_right - map->gx_pixelmap_width + 1); |
103 |
|
2 |
break; |
104 |
|
|
|
105 |
|
2 |
case GX_STYLE_HALIGN_CENTER: |
106 |
|
2 |
size = (GX_VALUE) ((icon -> gx_widget_size.gx_rectangle_right - icon -> gx_widget_size.gx_rectangle_left) + 1); |
107 |
|
2 |
size = (GX_VALUE) (size - map -> gx_pixelmap_width); |
108 |
|
2 |
xpos = (GX_VALUE) (icon -> gx_widget_size.gx_rectangle_left + (size / 2)); |
109 |
|
2 |
break; |
110 |
|
|
|
111 |
|
18737 |
default: |
112 |
|
18737 |
xpos = widget ->gx_widget_size.gx_rectangle_left; |
113 |
|
18737 |
break; |
114 |
|
|
} |
115 |
|
|
|
116 |
✓✓✓ |
18741 |
switch(widget -> gx_widget_style & GX_PIXELMAP_VALIGN_MASK) |
117 |
|
|
{ |
118 |
|
2 |
case GX_STYLE_VALIGN_BOTTOM: |
119 |
|
2 |
ypos = (GX_VALUE) (widget -> gx_widget_size.gx_rectangle_bottom - map->gx_pixelmap_height + 1); |
120 |
|
2 |
break; |
121 |
|
|
|
122 |
|
2 |
case GX_STYLE_VALIGN_CENTER: |
123 |
|
2 |
size = (GX_VALUE) ((icon -> gx_widget_size.gx_rectangle_bottom - icon -> gx_widget_size.gx_rectangle_top) + 1); |
124 |
|
2 |
size = (GX_VALUE) (size - map -> gx_pixelmap_height); |
125 |
|
2 |
ypos = (GX_VALUE) (icon -> gx_widget_size.gx_rectangle_top + (size / 2)); |
126 |
|
2 |
break; |
127 |
|
|
|
128 |
|
18737 |
default: |
129 |
|
18737 |
ypos = icon -> gx_widget_size.gx_rectangle_top; |
130 |
|
18737 |
break; |
131 |
|
|
} |
132 |
|
18741 |
_gx_canvas_pixelmap_draw(xpos, ypos, map); |
133 |
|
|
} |
134 |
|
|
else |
135 |
|
|
{ |
136 |
✓✓ |
73 |
if (!(icon -> gx_widget_style & GX_STYLE_TRANSPARENT)) |
137 |
|
|
{ |
138 |
|
71 |
_gx_widget_background_draw((GX_WIDGET *)icon); |
139 |
|
|
} |
140 |
|
|
} |
141 |
|
18814 |
} |
142 |
|
|
|