| 1 | /*
|
|---|
| 2 | * Copyright (c) 2023 Jiri Svoboda
|
|---|
| 3 | * All rights reserved.
|
|---|
| 4 | *
|
|---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 6 | * modification, are permitted provided that the following conditions
|
|---|
| 7 | * are met:
|
|---|
| 8 | *
|
|---|
| 9 | * - Redistributions of source code must retain the above copyright
|
|---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
|---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 13 | * documentation and/or other materials provided with the distribution.
|
|---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
|---|
| 15 | * derived from this software without specific prior written permission.
|
|---|
| 16 | *
|
|---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 27 | */
|
|---|
| 28 |
|
|---|
| 29 | /** @addtogroup libui
|
|---|
| 30 | * @{
|
|---|
| 31 | */
|
|---|
| 32 | /**
|
|---|
| 33 | * @file Window
|
|---|
| 34 | */
|
|---|
| 35 |
|
|---|
| 36 | #ifndef _UI_TYPES_WINDOW_H
|
|---|
| 37 | #define _UI_TYPES_WINDOW_H
|
|---|
| 38 |
|
|---|
| 39 | #include <errno.h>
|
|---|
| 40 | #include <io/kbd_event.h>
|
|---|
| 41 | #include <io/pos_event.h>
|
|---|
| 42 | #include <types/ui/wdecor.h>
|
|---|
| 43 |
|
|---|
| 44 | struct ui_window;
|
|---|
| 45 | typedef struct ui_window ui_window_t;
|
|---|
| 46 |
|
|---|
| 47 | /** Window placement hint */
|
|---|
| 48 | typedef enum {
|
|---|
| 49 | /** Use default (automatic) placement */
|
|---|
| 50 | ui_wnd_place_default = 0,
|
|---|
| 51 | /** Place window to the top-left corner of the screen */
|
|---|
| 52 | ui_wnd_place_top_left,
|
|---|
| 53 | /** Place window to the top-right corner of the screen */
|
|---|
| 54 | ui_wnd_place_top_right,
|
|---|
| 55 | /** Place window to the bottom-left corner of the screen */
|
|---|
| 56 | ui_wnd_place_bottom_left,
|
|---|
| 57 | /** Place window to the bottom-right corner of the screen */
|
|---|
| 58 | ui_wnd_place_bottom_right,
|
|---|
| 59 | /** Place window accross the entire screen */
|
|---|
| 60 | ui_wnd_place_full_screen,
|
|---|
| 61 | /** Place window as a popup window adjacent to rectangle */
|
|---|
| 62 | ui_wnd_place_popup
|
|---|
| 63 | } ui_wnd_placement_t;
|
|---|
| 64 |
|
|---|
| 65 | /** Window flags */
|
|---|
| 66 | typedef enum {
|
|---|
| 67 | /** Popup window */
|
|---|
| 68 | ui_wndf_popup = 0x1,
|
|---|
| 69 | /** Topmost window */
|
|---|
| 70 | ui_wndf_topmost = 0x2,
|
|---|
| 71 | /** Special system window */
|
|---|
| 72 | ui_wndf_system = 0x4,
|
|---|
| 73 | /** Maximized windows should avoid this window */
|
|---|
| 74 | ui_wndf_avoid = 0x8
|
|---|
| 75 | } ui_wnd_flags_t;
|
|---|
| 76 |
|
|---|
| 77 | /** Window parameters */
|
|---|
| 78 | typedef struct {
|
|---|
| 79 | /** Window rectangle */
|
|---|
| 80 | gfx_rect_t rect;
|
|---|
| 81 | /** Window caption */
|
|---|
| 82 | const char *caption;
|
|---|
| 83 | /** Window decoration style */
|
|---|
| 84 | ui_wdecor_style_t style;
|
|---|
| 85 | /** Window placement */
|
|---|
| 86 | ui_wnd_placement_t placement;
|
|---|
| 87 | /** Window flags */
|
|---|
| 88 | ui_wnd_flags_t flags;
|
|---|
| 89 | /** Parent rectangle for popup windows */
|
|---|
| 90 | gfx_rect_t prect;
|
|---|
| 91 | } ui_wnd_params_t;
|
|---|
| 92 |
|
|---|
| 93 | /** Window callbacks */
|
|---|
| 94 | typedef struct ui_window_cb {
|
|---|
| 95 | void (*minimize)(ui_window_t *, void *);
|
|---|
| 96 | void (*maximize)(ui_window_t *, void *);
|
|---|
| 97 | void (*unmaximize)(ui_window_t *, void *);
|
|---|
| 98 | void (*close)(ui_window_t *, void *);
|
|---|
| 99 | void (*focus)(ui_window_t *, void *, unsigned);
|
|---|
| 100 | void (*kbd)(ui_window_t *, void *, kbd_event_t *);
|
|---|
| 101 | errno_t (*paint)(ui_window_t *, void *);
|
|---|
| 102 | void (*pos)(ui_window_t *, void *, pos_event_t *);
|
|---|
| 103 | void (*unfocus)(ui_window_t *, void *, unsigned);
|
|---|
| 104 | } ui_window_cb_t;
|
|---|
| 105 |
|
|---|
| 106 | #endif
|
|---|
| 107 |
|
|---|
| 108 | /** @}
|
|---|
| 109 | */
|
|---|