GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_scroll_thumb_create.c Lines: 18 18 100.0 %
Date: 2026-03-06 19:21:09 Branches: 4 4 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
/**   Scroll Management (Scroll)                                          */
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_scrollbar.h"
31
#include "gx_utility.h"
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_scroll_thumb_create                             PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function creates a bitmap prompt, which is a special type of   */
46
/*    widget.                                                             */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    scroll_thumb                          Scroll thumb control block    */
51
/*    parent                                Pointer to parent scrollbar   */
52
/*    style                                 Style of scroll bar           */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    status                                Completion status             */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    _gx_button_create                     Create a button               */
61
/*    _gx_widget_status_remove              Clear the widget status flag  */
62
/*    _gx_widget_link                       Link the widget to its parent */
63
/*                                                                        */
64
/*  CALLED BY                                                             */
65
/*                                                                        */
66
/*    Application Code                                                    */
67
/*                                                                        */
68
/**************************************************************************/
69
2665
UINT  _gx_scroll_thumb_create(GX_SCROLL_THUMB *scroll_thumb, GX_SCROLLBAR *parent,
70
                              ULONG style)
71
{
72
GX_RECTANGLE size;
73
74
2665
    if (parent)
75
    {
76
2664
        size = parent -> gx_widget_size;
77
    }
78
    else
79
    {
80
1
        size.gx_rectangle_bottom = size.gx_rectangle_left = size.gx_rectangle_right = size.gx_rectangle_top = 0;
81
    }
82
83
    /* Clear the scroll control block.  */
84
2665
    _gx_button_create((GX_BUTTON *)scroll_thumb, GX_NULL, GX_NULL, style, GX_ID_SCROLL_THUMB, &size);
85
2665
    _gx_widget_status_remove((GX_WIDGET *)scroll_thumb, GX_STATUS_ACCEPTS_FOCUS);
86
87
2665
    scroll_thumb -> gx_widget_draw_function = (VOID (*)(struct GX_WIDGET_STRUCT *))_gx_scroll_thumb_draw;
88
2665
    scroll_thumb -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_scroll_thumb_event_process;
89
2665
    scroll_thumb -> gx_widget_normal_fill_color = GX_COLOR_ID_SCROLL_BUTTON;
90
2665
    scroll_thumb -> gx_widget_selected_fill_color = GX_COLOR_ID_SCROLL_BUTTON;
91
2665
    scroll_thumb -> gx_scroll_thumb_border_color = GX_COLOR_ID_SCROLL_BUTTON;
92
93
    /* Determine if a parent widget was provided.  */
94
2665
    if (parent)
95
    {
96
2664
        scroll_thumb -> gx_scroll_thumb_border_color = parent -> gx_scrollbar_appearance.gx_scroll_thumb_border_color;
97
2664
        scroll_thumb -> gx_widget_normal_fill_color = parent -> gx_scrollbar_appearance.gx_scroll_thumb_color;
98
2664
        scroll_thumb -> gx_widget_selected_fill_color = parent -> gx_scrollbar_appearance.gx_scroll_thumb_color;
99
2664
        scroll_thumb -> gx_scroll_thumb_pixelmap = parent -> gx_scrollbar_appearance.gx_scroll_thumb_pixelmap;
100
101
2664
        _gx_widget_link((GX_WIDGET *)parent, (GX_WIDGET *)scroll_thumb);
102
    }
103
2665
    return GX_SUCCESS;
104
}
105