Cross-platform C SDK logo

Cross-platform C SDK

Window

❮ Back
Next ❯
This page has been automatically translated using the Google Translate API services. We are working on improving texts. Thank you for your understanding and patience.

Functions

Window*window_create (...)
voidwindow_destroy (...)
voidwindow_OnClose (...)
voidwindow_OnMoved (...)
voidwindow_OnResize (...)
voidwindow_title (...)
voidwindow_show (...)
voidwindow_hide (...)
uint32_twindow_modal (...)
voidwindow_stop_modal (...)
voidwindow_update (...)
voidwindow_origin (...)
voidwindow_size (...)
V2Dfwindow_get_origin (...)
S2Dfwindow_get_size (...)
S2Dfwindow_get_client_size (...)
voidwindow_defbutton (...)
voidwindow_cursor (...)

Window objects are the highest level containers within the user interface (Figure 1). They are composed of the title bar, where the close, maximize and minimize buttons are located, the interior area and the frame. If the window supports resizing, this frame can be dragged with the mouse to change its size. The interior area or client area of the window is configured by a Panel passed as a constructor parameter.

  • Use window_create to create a window.
  • Windows 3 operating system capture.
    Figure 1: The window concept appears already in the first graphic systems.

1. Window size

In principle, the window size is automatically calculated based on the Natural sizing of its main panel, but it can be changed at any time.

  • Use window_size to change the size of the main panel.
  • Use ekWNRES flag to create a user resizable window.

The change in the dimensions of the client area implies a re-location and resizing of the internal controls. This is automatically managed by Layout objects depending on how its Cell expansion, which will be recursively propagated by all sublayouts. In Die you have an example of resizing a window (Figure 2).

It shows how the oversize is distributed among the controls when resizing the window.
Figure 2: Resizing the window in the Die demo.

window_create ()

Create a new window.

Window*
window_create(const uint32_t flags,
              Panel **main_panel);
flags

Combination of window_flag_t values.

main_panel

Main panel, which integrates the content of the window.

Return

The window.

Remarks

The window size will be calculated based on the Natural sizing of the main panel.


window_destroy ()

Destroy the window and all its contents.

void
window_destroy(Window **window);
window

The window. Will be set to NULL after destruction.

Remarks

Panels, layouts and components will be recursively destroyed.


window_OnClose ()

Set an event handler for the window closing.

void
window_OnClose(Window *window,
               Listener *listener);
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
static void i_OnClose(App *app, Event *e)
{
    const EvWinClose *params = event_params(e, EvWinClose);
    if (can_close(app, params->origin) == FALSE)
    {
        bool_t *result = event_result(e, bool_t);
        *result = FALSE;
    }
}
...
window_OnClose(window, listener(app, i_OnClose, App));
window

The window.

listener

Callback function to be called before closing a window.

Remarks

If for any reason the window should not close, it must be returned FALSE as a result of the event. See GUI Events.


window_OnMoved ()

Set an event handler for moving the window on the desktop.

void
window_OnMoved(Window *window,
               Listener *listener);
window

The window.

listener

Callback function to be called as the title bar is dragged and the window moves across the desktop.

Remarks

See GUI Events.


window_OnResize ()

Set an event handler for window resizing.

void
window_OnResize(Window *window,
                Listener *listener);
window

The window.

listener

Callback function to be called as the outer edges of the window are dragged to resize.

Remarks

The resizing and relocation of elements is done automatically based on the main Layout, so it is not usually necessary for the application to respond to this event. See GUI Events.


window_title ()

Set the text that will display the window in the title bar.

void
window_title(Window *window,
             const char_t *text);
window

The window.

text

UTF8 C-string terminated in null character '\0'.


window_show ()

Show the window. By default windows are created hidden. You have to show them explicitly.

void
window_show(Window *window);
window

The window.


window_hide ()

Hide the window.

void
window_hide(Window *window);
window

The window.


window_modal ()

Launch a window in modal mode.

uint32_t
window_modal(Window *window,
             Window *parent);
window

The window.

parent

The parent window.

Return

Value returned by window_stop_modal.

Remarks

parent stop receiving events until you call window_stop_modal.


window_stop_modal ()

Ends the modal cycle of a window.

void
window_stop_modal(Window *window,
                  const uint32_t return_value);
window

The window previously launched with window_modal.

return_value

Value to be returned window_modal.


window_update ()

Recalculate the position and size of the controls after modifying any Layout.

void
window_update(Window *window);
window

The window.


window_origin ()

Move the window to specific desktop coordinates.

void
window_origin(Window *window,
              const V2Df origin);
window

The window.

origin

Position (x,y) of the upper-left corner of the window.


window_size ()

Set the size of the client area of the window.

void
window_size(Window *window,
            const S2Df size);
window

The window.

size

Main panel size.

Remarks

The final size will depend on the window frame and desktop theme settings. This measure only refers to the interior area.


window_get_origin ()

Get the window position.

V2Df
window_get_origin(const Window *window);
window

The window.

Return

Position (x,y) from the upper-left corner of the window.


window_get_size ()

Get the total dimensions of the window.

S2Df
window_get_size(const Window *window);
window

The window.

Return

Window size.

Remarks

The frame and title bar are taken into account.


window_get_client_size ()

Get the dimensions of the client area of the window.

S2Df
window_get_client_size(const Window *window);
window

The window.

Return

Main panel size.


window_defbutton ()

Set the default window button. It will be activated when pressed [Intro].

void
window_defbutton(Window *window,
                 Button *button);
window

The window.

button

The button.


window_cursor ()

Change the mouse cursor.

void
window_cursor(Window *window,
              const cursor_t cursor,
              const Image *image,
              const real32_t hot_x,
              const real32_t hot_y);
window

The window.

cursor

Identifier of the new cursor.

image

Custom image. Only valid in ekCUSER.

hot_x

The x coordinate of the click point. Only valid in ekCUSER.

hot_y

The y coordinate of the click point. Only valid in ekCUSER.

Remarks

hot_x, hot_y indicate the "sensitive" point within the image, which will indicate the exact position of the mouse.

❮ Back
Next ❯