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 /**   Scrollbar Management (Scrollbar)                                    */
18 /**                                                                       */
19 /**************************************************************************/
20 
21 #define GX_SOURCE_CODE
22 
23 /* Include necessary system files.  */
24 
25 #include "gx_api.h"
26 #include "gx_system.h"
27 #include "gx_scrollbar.h"
28 
29 /**************************************************************************/
30 /*                                                                        */
31 /*  FUNCTION                                               RELEASE        */
32 /*                                                                        */
33 /*    _gx_scrollbar_reset                                 PORTABLE C      */
34 /*                                                           6.1          */
35 /*  AUTHOR                                                                */
36 /*                                                                        */
37 /*    Kenneth Maxwell, Microsoft Corporation                              */
38 /*                                                                        */
39 /*  DESCRIPTION                                                           */
40 /*                                                                        */
41 /*    This service resets the scrollbar.                                  */
42 /*                                                                        */
43 /*                                                                        */
44 /*  INPUT                                                                 */
45 /*                                                                        */
46 /*    scrollbar                             Scrollbar control block       */
47 /*    info                                  Pointer to GX_SCROLL          */
48 /*                                            structure that defines the  */
49 /*                                            scrollbar limits, current   */
50 /*                                            value, and step or          */
51 /*                                            increment.                  */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    status                                Completion status             */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    [gx_window_scroll_info_get]           Get the window scroll info    */
60 /*    _gx_scrollbar_size_update             Update the scroll size        */
61 /*    _gx_scrollbar_thumb_position_calculate                              */
62 /*                                          Calculate the scrollbar thumb */
63 /*                                          position                      */
64 /*    _gx_system_dirty_mark                 Mark system block dirty       */
65 /*                                                                        */
66 /*  CALLED BY                                                             */
67 /*                                                                        */
68 /*    Application Code                                                    */
69 /*                                                                        */
70 /*  RELEASE HISTORY                                                       */
71 /*                                                                        */
72 /*    DATE              NAME                      DESCRIPTION             */
73 /*                                                                        */
74 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
75 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
76 /*                                            resulting in version 6.1    */
77 /*                                                                        */
78 /**************************************************************************/
_gx_scrollbar_reset(GX_SCROLLBAR * scrollbar,GX_SCROLL_INFO * info)79 UINT _gx_scrollbar_reset(GX_SCROLLBAR *scrollbar, GX_SCROLL_INFO *info)
80 {
81 GX_WINDOW *win;
82 
83     if (info)
84     {
85         scrollbar -> gx_scrollbar_info = *info;
86     }
87     else
88     {
89         win = (GX_WINDOW *)scrollbar -> gx_widget_parent;
90 
91         if (win)
92         {
93             win -> gx_window_scroll_info_get(win, scrollbar -> gx_widget_style, &scrollbar -> gx_scrollbar_info);
94         }
95     }
96     _gx_scrollbar_size_update(scrollbar);
97     _gx_scrollbar_thumb_position_calculate(scrollbar);
98 
99     if (scrollbar -> gx_widget_status & GX_STATUS_VISIBLE)
100     {
101         _gx_system_dirty_mark((GX_WIDGET *)scrollbar);
102     }
103 
104     return(GX_SUCCESS);
105 }
106 
107