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 /**   Window Management (Window)                                          */
18 /**                                                                       */
19 /**************************************************************************/
20 
21 #define GX_SOURCE_CODE
22 
23 
24 /* Include necessary system files.  */
25 
26 #include "gx_api.h"
27 #include "gx_widget.h"
28 #include "gx_window.h"
29 
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _gx_window_create                                   PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Kenneth Maxwell, Microsoft Corporation                              */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function creates a window, which is a special type of          */
44 /*    widget.                                                             */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    window                                Pointer to window control     */
49 /*                                           block                        */
50 /*    name                                  Logical name of window        */
51 /*    parent                                Pointer to parent window      */
52 /*    style                                 Window Style                  */
53 /*    window_id                             Application-defined ID of the */
54 /*                                            window                      */
55 /*    size                                  Size of the window            */
56 /*                                                                        */
57 /*  OUTPUT                                                                */
58 /*                                                                        */
59 /*    status                                Completion status             */
60 /*                                                                        */
61 /*  CALLS                                                                 */
62 /*                                                                        */
63 /*    _gx_widget_create                     Create the underlying widget  */
64 /*    _gx_widget_border_width_get           Get the widget border width   */
65 /*    _gx_widget_client_get                 Get the widget client         */
66 /*    _gx_widget_link                       Link the widget to the parent */
67 /*                                                                        */
68 /*  CALLED BY                                                             */
69 /*                                                                        */
70 /*    Application Code                                                    */
71 /*                                                                        */
72 /*  RELEASE HISTORY                                                       */
73 /*                                                                        */
74 /*    DATE              NAME                      DESCRIPTION             */
75 /*                                                                        */
76 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
77 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
78 /*                                            fixed compiler warnings,    */
79 /*                                            resulting in version 6.1    */
80 /*                                                                        */
81 /**************************************************************************/
_gx_window_create(GX_WINDOW * window,GX_CONST GX_CHAR * name,GX_WIDGET * parent,ULONG style,USHORT window_id,GX_CONST GX_RECTANGLE * size)82 UINT  _gx_window_create(GX_WINDOW *window, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
83                         ULONG style, USHORT window_id, GX_CONST GX_RECTANGLE *size)
84 {
85 
86 GX_VALUE border_width;
87 
88     /* Call the widget create function.  */
89     _gx_widget_create((GX_WIDGET *)window, name, GX_NULL, style, window_id, size);
90 
91     /* Populate the rest of window control block - overriding as necessary.  */
92     window -> gx_widget_type = GX_TYPE_WINDOW;
93     window -> gx_widget_status |= GX_STATUS_ACCEPTS_FOCUS;
94     _gx_widget_border_width_get((GX_WIDGET *)window, &border_width);
95     _gx_widget_client_get((GX_WIDGET *)window,
96                           border_width,
97                           &window -> gx_window_client);
98 
99     window -> gx_window_views =                   GX_NULL;
100     window -> gx_widget_normal_fill_color =       GX_COLOR_ID_WINDOW_FILL;
101     window -> gx_widget_selected_fill_color =     GX_COLOR_ID_WINDOW_FILL;
102     window -> gx_window_wallpaper   =             0;
103     window -> gx_widget_type =                    GX_TYPE_WINDOW;
104     window -> gx_window_move_mode =               0;
105     window -> gx_window_move_start.gx_point_x =   0;
106     window -> gx_window_move_start.gx_point_y =   0;
107     window -> gx_widget_draw_function =           (VOID (*)(GX_WIDGET *))_gx_window_draw;
108     window -> gx_widget_event_process_function =  (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_window_event_process;
109     window -> gx_window_scroll_info_get =         (VOID (*)(GX_WINDOW *, ULONG, GX_SCROLL_INFO *))(void (*)(void))_gx_window_scroll_info_get;
110 
111     /* Determine if a parent widget was provided.  */
112     if (parent)
113     {
114         _gx_widget_link(parent, (GX_WIDGET *)window);
115     }
116 
117     /* Return completion status code. */
118     return(GX_SUCCESS);
119 }
120 
121