GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_horizontal_scrollbar_create.c Lines: 29 29 100.0 %
Date: 2026-03-06 19:21:09 Branches: 8 8 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   Scrollbar Management (Scrollbar)                                    */
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_button.h"
30
#include "gx_utility.h"
31
#include "gx_scrollbar.h"
32
#include "gx_system.h"
33
#include "gx_window.h"
34
35
36
/**************************************************************************/
37
/*                                                                        */
38
/*  FUNCTION                                               RELEASE        */
39
/*                                                                        */
40
/*    _gx_horizontal_scrollbar_create                     PORTABLE C      */
41
/*                                                           6.1          */
42
/*  AUTHOR                                                                */
43
/*                                                                        */
44
/*    Kenneth Maxwell, Microsoft Corporation                              */
45
/*                                                                        */
46
/*  DESCRIPTION                                                           */
47
/*                                                                        */
48
/*    This function creates a horizontal scrollbar.                       */
49
/*                                                                        */
50
/*  INPUT                                                                 */
51
/*                                                                        */
52
/*    scrollbar                             scroll control block          */
53
/*    name                                  name of scroll                */
54
/*    parent                                parent window                 */
55
/*    appearance                            appearance of scroll bar      */
56
/*    style                                 style of scroll bar           */
57
/*                                                                        */
58
/*  OUTPUT                                                                */
59
/*                                                                        */
60
/*    status                                Completion status             */
61
/*                                                                        */
62
/*  CALLS                                                                 */
63
/*                                                                        */
64
/*    _gx_utility_rectangle_define          Define a rectangle            */
65
/*    _gx_widget_create                     Create the underlying prompt  */
66
/*    _gx_system_scroll_appearance_get      Get the scrollbar appearance  */
67
/*    _gx_button_create                     Button create call            */
68
/*    [gx_window_scroll_info_get]           Retrieve window scroll info   */
69
/*    _gx_scroll_thumb_create               Create the thrum button       */
70
/*    _gx_widget_link                       Link the widget to its parent */
71
/*    _gx_widget_child_clipping_update      Update the clipping area      */
72
/*                                                                        */
73
/*  CALLED BY                                                             */
74
/*                                                                        */
75
/*    Application Code                                                    */
76
/*                                                                        */
77
/**************************************************************************/
78
1060
UINT  _gx_horizontal_scrollbar_create(GX_SCROLLBAR *scrollbar, GX_CONST GX_CHAR *name, GX_WINDOW *parent,
79
                                      GX_SCROLLBAR_APPEARANCE *appearance, ULONG style)
80
{
81
82
GX_RECTANGLE size;
83
UINT         id;
84
85
1060
    _gx_utility_rectangle_define(&size, 0, 0, 0, 0);
86
87
1060
    id = GX_ID_HORIZONTAL_SCROLL;
88
89
1060
    if (appearance)
90
    {
91
1057
        scrollbar -> gx_scrollbar_appearance = *appearance;
92
    }
93
    else
94
    {
95
3
        _gx_system_scroll_appearance_get(GX_SCROLLBAR_HORIZONTAL, &scrollbar -> gx_scrollbar_appearance);
96
    }
97
98
    /* make sure style is set correctly */
99
1060
    style &= (ULONG)(~GX_SCROLLBAR_VERTICAL);
100
1060
    style |= GX_SCROLLBAR_HORIZONTAL;
101
102
    /* Call the base widget create function.  */
103
1060
    _gx_widget_create((GX_WIDGET *)scrollbar, name, GX_NULL, style, (USHORT)id, &size);
104
105
    /* Check for completion status on the widget's create.  */
106
1060
    scrollbar -> gx_widget_type = GX_TYPE_HORIZONTAL_SCROLL;
107
1060
    scrollbar -> gx_widget_normal_fill_color = GX_COLOR_ID_SCROLL_FILL;
108
1060
    scrollbar -> gx_widget_selected_fill_color = GX_COLOR_ID_SCROLL_FILL;
109
110
1060
    if (style & GX_SCROLLBAR_END_BUTTONS)
111
    {
112
        /* create the up/left button */
113
800
        _gx_button_create(&scrollbar -> gx_scrollbar_upleft, NULL, (GX_WIDGET *)scrollbar,
114
                          GX_STYLE_ENABLED | GX_STYLE_BORDER_RAISED, GX_ID_SCROLL_UP_LEFT, &size);
115
116
800
        _gx_widget_fill_color_set((GX_WIDGET *)&scrollbar -> gx_scrollbar_upleft,
117
                                  scrollbar -> gx_scrollbar_appearance.gx_scroll_button_color,
118
                                  scrollbar -> gx_scrollbar_appearance.gx_scroll_button_color,
119
                                  scrollbar -> gx_scrollbar_appearance.gx_scroll_button_color);
120
121
800
        scrollbar -> gx_scrollbar_upleft.gx_widget_status &= ~GX_STATUS_ACCEPTS_FOCUS;
122
123
        /* create the down/right button */
124
800
        _gx_button_create(&scrollbar -> gx_scrollbar_downright, NULL, (GX_WIDGET *)scrollbar,
125
                          GX_STYLE_ENABLED | GX_STYLE_BORDER_RAISED, GX_ID_SCROLL_DOWN_RIGHT, &size);
126
800
        _gx_widget_fill_color_set((GX_WIDGET *)&scrollbar -> gx_scrollbar_downright,
127
                                  scrollbar -> gx_scrollbar_appearance.gx_scroll_button_color,
128
                                  scrollbar -> gx_scrollbar_appearance.gx_scroll_button_color,
129
                                  scrollbar -> gx_scrollbar_appearance.gx_scroll_button_color);
130
131
800
        scrollbar -> gx_scrollbar_downright.gx_widget_status &= ~GX_STATUS_ACCEPTS_FOCUS;
132
    }
133
134
    /* create the thumb button */
135
1060
    _gx_scroll_thumb_create(&scrollbar -> gx_scrollbar_thumb, scrollbar, (ULONG)((scrollbar -> gx_scrollbar_appearance.gx_scroll_thumb_border_style) | GX_SCROLLBAR_HORIZONTAL) | GX_STYLE_ENABLED);
136
137
    /* initialize the drawing function */
138
1060
    scrollbar -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_scrollbar_draw;
139
140
    /* initialize the event handler function */
141
1060
    scrollbar -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_scrollbar_event_process;
142
143
    /* scroll-bars have non-client area status and do not accept focus */
144
145
1060
    scrollbar -> gx_widget_status |= GX_STATUS_NONCLIENT;
146
1060
    scrollbar -> gx_widget_status &= ~GX_STATUS_ACCEPTS_FOCUS;
147
148
    /* Determine if a parent widget was provided.  */
149
1060
    if (parent)
150
    {
151
1058
        _gx_widget_link((GX_WIDGET *)parent, (GX_WIDGET *)scrollbar);
152
153
1058
        if (parent -> gx_widget_status & GX_STATUS_VISIBLE)
154
        {
155
1
            _gx_widget_child_clipping_update((GX_WIDGET *)parent);
156
        }
157
    }
158
159
1060
    return(GX_SUCCESS);
160
}
161