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 /** Horizontal List (List) */ 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 #include "gx_window.h" 30 #include "gx_system.h" 31 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _gx_horizontal_list_children_position PORTABLE C */ 38 /* 6.1 */ 39 /* AUTHOR */ 40 /* */ 41 /* Kenneth Maxwell, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function positions the children for the horizontal list. */ 46 /* */ 47 /* INPUT */ 48 /* */ 49 /* horizontal_list Horizontal list widget */ 50 /* control block */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* status Completion status */ 55 /* */ 56 /* CALLS */ 57 /* */ 58 /* _gx_widget_width_get Retrieves the width of the */ 59 /* widget */ 60 /* _gx_widget_resize Resizes the widget */ 61 /* _gx_window_client_width_get Retrieves the width of the */ 62 /* client */ 63 /* */ 64 /* CALLED BY */ 65 /* */ 66 /* _gx_horizontal_list_event_process */ 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 /**************************************************************************/ _gx_horizontal_list_children_position(GX_HORIZONTAL_LIST * horizontal_list)77UINT _gx_horizontal_list_children_position(GX_HORIZONTAL_LIST *horizontal_list) 78 { 79 GX_RECTANGLE childsize = horizontal_list -> gx_window_client; 80 GX_WIDGET *child = horizontal_list -> gx_widget_first_child; 81 INT index = horizontal_list -> gx_horizontal_list_top_index; 82 83 GX_VALUE width; 84 GX_VALUE client_width; 85 86 horizontal_list -> gx_horizontal_list_child_width = 0; 87 horizontal_list -> gx_horizontal_list_child_count = 0; 88 89 while (child) 90 { 91 if (!(child -> gx_widget_status & GX_STATUS_NONCLIENT)) 92 { 93 /* increment child count */ 94 horizontal_list -> gx_horizontal_list_child_count++; 95 96 /* assign this child's id */ 97 98 if (!(child -> gx_widget_id)) 99 { 100 child -> gx_widget_id = (USHORT)(LIST_CHILD_ID_START + horizontal_list -> gx_horizontal_list_child_count); 101 } 102 103 if (index == horizontal_list -> gx_horizontal_list_selected) 104 { 105 child -> gx_widget_style |= GX_STYLE_DRAW_SELECTED; 106 } 107 else 108 { 109 child -> gx_widget_style &= ~GX_STYLE_DRAW_SELECTED; 110 } 111 index++; 112 113 child -> gx_widget_status &= ~GX_STATUS_ACCEPTS_FOCUS; 114 115 /* pick up child item width, needed for scrolling */ 116 _gx_widget_width_get(child, &width); 117 if (width > horizontal_list -> gx_horizontal_list_child_width) 118 { 119 horizontal_list -> gx_horizontal_list_child_width = width; 120 } 121 122 /* move this child into position */ 123 childsize.gx_rectangle_right = (GX_VALUE)(childsize.gx_rectangle_left + width - 1); 124 _gx_widget_resize(child, &childsize); 125 childsize.gx_rectangle_left = (GX_VALUE)(childsize.gx_rectangle_right + 1); 126 } 127 child = child -> gx_widget_next; 128 } 129 130 /* calculate number of visible columns, needed for scrolling info */ 131 132 if (horizontal_list -> gx_horizontal_list_child_width > 0) 133 { 134 _gx_window_client_width_get((GX_WINDOW *)horizontal_list, &client_width); 135 horizontal_list -> gx_horizontal_list_visible_columns = (GX_VALUE)((client_width + horizontal_list -> gx_horizontal_list_child_width - 1) / 136 horizontal_list -> gx_horizontal_list_child_width); 137 } 138 else 139 { 140 horizontal_list -> gx_horizontal_list_visible_columns = 1; 141 } 142 return(GX_SUCCESS); 143 } 144 145