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 /** Widget Management (Widget) */ 19 /** */ 20 /**************************************************************************/ 21 22 #define GX_SOURCE_CODE 23 24 25 /* Include necessary system files. */ 26 27 #include "gx_api.h" 28 #include "gx_widget.h" 29 30 31 /**************************************************************************/ 32 /* */ 33 /* FUNCTION RELEASE */ 34 /* */ 35 /* _gx_widget_font_get PORTABLE C */ 36 /* 6.1 */ 37 /* AUTHOR */ 38 /* */ 39 /* Kenneth Maxwell, Microsoft Corporation */ 40 /* */ 41 /* DESCRIPTION */ 42 /* */ 43 /* This service gets the font associated with the specified */ 44 /* resource ID. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* widget Widget control block pointer */ 49 /* resource_id Resource ID of font */ 50 /* return_font Pointer to destination for */ 51 /* font pointer */ 52 /* */ 53 /* OUTPUT */ 54 /* */ 55 /* status Completion status */ 56 /* */ 57 /* CALLS */ 58 /* */ 59 /* _gx_widget_canvas_get Get widget canvas pointer */ 60 /* */ 61 /* CALLED BY */ 62 /* */ 63 /* Application Code */ 64 /* GUIX default drawing functions */ 65 /* */ 66 /* RELEASE HISTORY */ 67 /* */ 68 /* DATE NAME DESCRIPTION */ 69 /* */ 70 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 71 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 72 /* resulting in version 6.1 */ 73 /* */ 74 /**************************************************************************/ _gx_widget_font_get(GX_WIDGET * widget,GX_RESOURCE_ID resource_id,GX_FONT ** return_font)75UINT _gx_widget_font_get(GX_WIDGET *widget, GX_RESOURCE_ID resource_id, GX_FONT **return_font) 76 { 77 GX_FONT *font = GX_NULL; 78 UINT status = GX_INVALID_CANVAS; 79 80 GX_CANVAS *canvas; 81 GX_DISPLAY *display; 82 GX_RESOURCE_ID font_table_size; 83 84 if (widget -> gx_widget_status & GX_STATUS_VISIBLE) 85 { 86 _gx_widget_canvas_get(widget, &canvas); 87 88 if (canvas) 89 { 90 display = canvas -> gx_canvas_display; 91 92 /* Pickup the font table size. */ 93 font_table_size = display -> gx_display_font_table_size; 94 95 /* Determine if the ID is within range. */ 96 if (resource_id < font_table_size) 97 { 98 /* Yes, the ID is within range. Perform a table lookup and return the 99 font poiner. */ 100 font = display -> gx_display_font_table[resource_id]; 101 status = GX_SUCCESS; 102 } 103 else 104 { 105 status = GX_INVALID_RESOURCE_ID; 106 } 107 } 108 } 109 *return_font = font; 110 return(status); 111 } 112 113