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