GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_vertical_scrollbar_create.c Lines: 30 30 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_vertical_scrollbar_create                       PORTABLE C      */
41
/*                                                           6.1          */
42
/*  AUTHOR                                                                */
43
/*                                                                        */
44
/*    Kenneth Maxwell, Microsoft Corporation                              */
45
/*                                                                        */
46
/*  DESCRIPTION                                                           */
47
/*                                                                        */
48
/*    This service creates a vertical scrollbar.                          */
49
/*                                                                        */
50
/*  INPUT                                                                 */
51
/*                                                                        */
52
/*    scrollbar                             Scrollbar control block       */
53
/*    name                                  Name of scrollbar             */
54
/*    parent                                Pointer to parent widget      */
55
/*    appearance                            Appearance of vertical        */
56
/*                                            scrollbar widget            */
57
/*                                                                        */
58
/*  OUTPUT                                                                */
59
/*                                                                        */
60
/*    status                                Completion status             */
61
/*                                                                        */
62
/*  CALLS                                                                 */
63
/*                                                                        */
64
/*    _gx_utility_rectangle_define          Define a rectangle            */
65
/*    _gx_system_scroll_appearance_get      Retrieve scroll bar settings  */
66
/*    _gx_button_create                     Create a button               */
67
/*    _gx_widget_status_add                 Set status bit                */
68
/*    _gx_widget_status_remove              Remove status bit             */
69
/*    [gx_window_scroll_info_get]           Retrieve widget scroll info   */
70
/*    _gx_scroll_thumb_create               Create scroll thumb image     */
71
/*    _gx_pixelmap_transparent_detect       Detect whether or not a       */
72
/*                                            pixelmap contains           */
73
/*                                            transparency information    */
74
/*    _gx_widget_link                       Link a widget to its parent   */
75
/*    _gx_widget_child_clipping_update      Update child clipping info    */
76
/*                                                                        */
77
/*  CALLED BY                                                             */
78
/*                                                                        */
79
/*    Application Code                                                    */
80
/*                                                                        */
81
/**************************************************************************/
82
1603
UINT  _gx_vertical_scrollbar_create(GX_SCROLLBAR *scrollbar, GX_CONST GX_CHAR *name,
83
                                    GX_WINDOW *parent, GX_SCROLLBAR_APPEARANCE *appearance, ULONG style)
84
{
85
86
GX_RECTANGLE size;
87
USHORT       id;
88
89
1603
    _gx_utility_rectangle_define(&size, 0, 0, 0, 0);
90
1603
    id = GX_ID_VERTICAL_SCROLL;
91
92
1603
    if (appearance)
93
    {
94
1104
        scrollbar -> gx_scrollbar_appearance = *appearance;
95
    }
96
    else
97
    {
98
499
        _gx_system_scroll_appearance_get(GX_SCROLLBAR_VERTICAL, &scrollbar -> gx_scrollbar_appearance);
99
    }
100
101
    /* make sure style is set correctly */
102
1603
    style &= (ULONG)(~GX_SCROLLBAR_HORIZONTAL);
103
1603
    style |= GX_SCROLLBAR_VERTICAL;
104
105
    /* Call the base widget create function.  */
106
1603
    _gx_widget_create((GX_WIDGET *)scrollbar, name, GX_NULL, style, id, &size);
107
108
1603
    scrollbar -> gx_widget_type = GX_TYPE_VERTICAL_SCROLL;
109
1603
    scrollbar -> gx_widget_normal_fill_color = GX_COLOR_ID_SCROLL_FILL;
110
1603
    scrollbar -> gx_widget_selected_fill_color = GX_COLOR_ID_SCROLL_FILL;
111
112
1603
    if (style & GX_SCROLLBAR_END_BUTTONS)
113
    {
114
        /* create the up/left button */
115
1591
        _gx_button_create(&scrollbar -> gx_scrollbar_upleft, NULL, (GX_WIDGET *)scrollbar,
116
                          GX_STYLE_ENABLED | GX_STYLE_BORDER_RAISED, GX_ID_SCROLL_UP_LEFT, &size);
117
1591
        _gx_widget_fill_color_set((GX_WIDGET *)&scrollbar -> gx_scrollbar_upleft,
118
                                  scrollbar -> gx_scrollbar_appearance.gx_scroll_button_color,
119
                                  scrollbar -> gx_scrollbar_appearance.gx_scroll_button_color,
120
                                  scrollbar -> gx_scrollbar_appearance.gx_scroll_button_color);
121
1591
        scrollbar -> gx_scrollbar_upleft.gx_widget_status &= ~GX_STATUS_ACCEPTS_FOCUS;
122
123
        /* create the down/right button */
124
1591
        _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
1591
        _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
1591
        scrollbar -> gx_scrollbar_downright.gx_widget_status &= ~GX_STATUS_ACCEPTS_FOCUS;
131
    }
132
133
    /* scroll-bars have non-client area status and do not accept focus */
134
1603
    scrollbar -> gx_widget_status |= GX_STATUS_NONCLIENT;
135
1603
    scrollbar -> gx_widget_status &= ~GX_STATUS_ACCEPTS_FOCUS;
136
137
    /* create the thumb button */
138
1603
    _gx_scroll_thumb_create(&scrollbar -> gx_scrollbar_thumb, scrollbar,
139
1603
                            (ULONG)((scrollbar -> gx_scrollbar_appearance.gx_scroll_thumb_border_style) | GX_SCROLLBAR_VERTICAL) | GX_STYLE_ENABLED);
140
141
    /* initialize the drawing function */
142
1603
    scrollbar -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_scrollbar_draw;
143
144
    /* initialize the event handler function */
145
1603
    scrollbar -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_scrollbar_event_process;
146
147
    /* Determine if a parent widget was provided.  */
148
1603
    if (parent)
149
    {
150
1602
        _gx_widget_link((GX_WIDGET *)parent, (GX_WIDGET *)scrollbar);
151
152
1602
        if (parent -> gx_widget_status & GX_STATUS_VISIBLE)
153
        {
154
2
            _gx_widget_child_clipping_update((GX_WIDGET *)parent);
155
        }
156
    }
157
158
1603
    return(GX_SUCCESS);
159
}
160