GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_generic_scroll_wheel_draw.c Lines: 21 21 100.0 %
Date: 2024-12-05 08:52:37 Branches: 12 12 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** GUIX Component                                                        */
16
/**                                                                       */
17
/**   Scroll Wheel Management (Generic Scroll Wheel)                      */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_window.h"
28
#include "gx_widget.h"
29
#include "gx_scroll_wheel.h"
30
#include "gx_canvas.h"
31
#include "gx_context.h"
32
#include "gx_utility.h"
33
34
/**************************************************************************/
35
/*                                                                        */
36
/*  FUNCTION                                               RELEASE        */
37
/*                                                                        */
38
/*    _gx_generic_scroll_wheel_draw                       PORTABLE C      */
39
/*                                                           6.1.7        */
40
/*  AUTHOR                                                                */
41
/*                                                                        */
42
/*    Ting Zhu, Microsoft Corporation                                     */
43
/*                                                                        */
44
/*  DESCRIPTION                                                           */
45
/*                                                                        */
46
/*    This function draws the generic scroll wheel widget.                */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    wheel                                 Generic scroll wheel control  */
51
/*                                            block                       */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _gx_window_background_draw            Draw window background        */
60
/*    _gx_context_pixelmap_get              Get pixelmap by resource ID   */
61
/*    _gx_window_client_height_get          Get window client height      */
62
/*    _gx_window_client_width_get           Get window client width       */
63
/*    _gx_canvas_pixelmap_tile              Tile a pixelmap               */
64
/*    _gx_widget_children_draw              Draw children of the widget   */
65
/*    _gx_widget_first_visible_client_child_get                           */
66
/*                                          Get the first visible client  */
67
/*    _gx_widget_next_visible_client_child_get                            */
68
/*                                          Get the next visible client   */
69
/*                                                                        */
70
/*  CALLED BY                                                             */
71
/*                                                                        */
72
/*    Application Code                                                    */
73
/*    GUIX Internal Code                                                  */
74
/*                                                                        */
75
/*  RELEASE HISTORY                                                       */
76
/*                                                                        */
77
/*    DATE              NAME                      DESCRIPTION             */
78
/*                                                                        */
79
/*  06-02-2021     Ting Zhu                 Initial Version 6.1.7         */
80
/*                                                                        */
81
/**************************************************************************/
82
380
VOID _gx_generic_scroll_wheel_draw(GX_GENERIC_SCROLL_WHEEL *wheel)
83
{
84
GX_PIXELMAP *map;
85
GX_RECTANGLE selected_area;
86
GX_WIDGET   *child;
87
88
    /* Draw window background.  */
89
380
    _gx_window_background_draw((GX_WINDOW *)wheel);
90
91
    /* Pickup selected background.  */
92
380
    _gx_context_pixelmap_get(wheel -> gx_scroll_wheel_selected_background, &map);
93
94
    /* Define selected area.  */
95
380
    selected_area = wheel -> gx_window_client;
96
380
    selected_area.gx_rectangle_top = (GX_VALUE)((selected_area.gx_rectangle_top + selected_area.gx_rectangle_bottom) >> 1);
97
380
    selected_area.gx_rectangle_top = (GX_VALUE)(selected_area.gx_rectangle_top - (wheel -> gx_scroll_wheel_row_height >> 1));
98
380
    selected_area.gx_rectangle_bottom = (GX_VALUE)(selected_area.gx_rectangle_top + wheel -> gx_scroll_wheel_row_height - 1);
99
100
380
    if (map)
101
    {
102
        /* Draw selected background.  */
103
349
        _gx_canvas_pixelmap_tile(&selected_area, map);
104
    }
105
106
107
380
    if (!(wheel -> gx_widget_status & GX_STATUS_TRACKING_PEN) &&
108
357
        (wheel -> gx_scroll_wheel_animation_steps == 0))
109
    {
110
173
        child = _gx_widget_first_visible_client_child_get((GX_WIDGET *)wheel);
111
112
        /* The scroll wheel is stop scrolling, set GX_STYLE_DRAW_SELECTED style to the selected widget. */
113
637
        while (child)
114
        {
115
609
            if (selected_area.gx_rectangle_top == child -> gx_widget_size.gx_rectangle_top)
116
            {
117
145
                child -> gx_widget_style |= GX_STYLE_DRAW_SELECTED;
118
145
                break;
119
            }
120
121
464
            child = _gx_widget_next_visible_client_child_get(child);
122
        }
123
    }
124
125
    /* Draw all children of the generic scroll wheel.  */
126
380
    _gx_widget_children_draw((GX_WIDGET *)wheel);
127
128
    /* Draw the overlay pixelmap, if there is one.  */
129
380
    if (wheel -> gx_scroll_wheel_gradient.gx_gradient_pixelmap.gx_pixelmap_data)
130
    {
131
349
        _gx_canvas_pixelmap_tile(&wheel -> gx_widget_size, &wheel -> gx_scroll_wheel_gradient.gx_gradient_pixelmap);
132
    }
133
380
}
134