FDOSTUI
FreeDOS Text User Interface
Enumerations | Functions
wm.hpp File Reference

window management routines More...

Go to the source code of this file.

Enumerations

enum  wm_error {
  ERROR_NONE, ERROR_INIT_SCREEN, ERROR_INIT_MOUSE, ERROR_EMPTY_QUEUE,
  ERROR_USER_ESC
}
 error codes More...
 

Functions

enum wm_error wm_init ()
 initialize the FDOSTUI subsystem More...
 
void wm_deinit ()
 return the system to it's initial state More...
 
void wm_register_window (window *const i_window)
 add a window to the window manager More...
 
enum wm_error wm_run ()
 enter the main loop More...
 
enum event_response wm_run_modal (widget &i_widget)
 runs a widget as modal More...
 
void wm_quit (enum wm_error const i_reason)
 signal the event manager to close down More...
 
void wm_draw (window *const i_window)
 redraw window More...
 
void wm_draw_widget (widget *const i_widget)
 draw a widget More...
 
window *const wm_grab (window *const i_window)
 grab the focus More...
 
void wm_unregister_window (window *const i_window)
 remove a window from the window manager More...
 

Detailed Description

window management routines

Enumeration Type Documentation

◆ wm_error

enum wm_error

error codes

Enumerator
ERROR_NONE 

no error occurred

ERROR_INIT_SCREEN 

unable to initialize the display

ERROR_INIT_MOUSE 

unable to initialize the mouse

ERROR_EMPTY_QUEUE 

the queue is empty (there are no windows to recieve events)

ERROR_USER_ESC 

the user hit the escape key

Function Documentation

◆ wm_deinit()

void wm_deinit ( )

return the system to it's initial state

Returns
none

◆ wm_draw()

void wm_draw ( window *const  i_window)

redraw window

Parameters
[in]i_windowwindow to redraw
Returns
none

Redraws all windows, with i_window being the last to be drawn. If i_window is NULL, the currently focused window will be drawn last.

◆ wm_draw_widget()

void wm_draw_widget ( widget *const  i_widget)

draw a widget

Parameters
[in]i_widgetwidget to draw
Returns
none

◆ wm_grab()

window *const wm_grab ( window *const  i_window)

grab the focus

Parameters
[in]i_windowwindow to grab focus. NULL to unset the focus.
Returns
window that had the previous focus

◆ wm_init()

enum wm_error wm_init ( )

initialize the FDOSTUI subsystem

Returns
error code

◆ wm_quit()

void wm_quit ( enum wm_error const  i_reason)

signal the event manager to close down

Parameters
[in]i_reasonerror code
Returns
none

This routine signals the window manager to close down. It sets an internal flag, which signifies that the run loop should exit.

This has no affect in the wm_run_modal routine.

◆ wm_register_window()

void wm_register_window ( window *const  i_window)

add a window to the window manager

Parameters
[in]i_windowvalid window
Returns
none

◆ wm_run()

enum wm_error wm_run ( )

enter the main loop

Returns
error code

A typical scenario is to create a window, register it, and then call the run loop. Following, wait for an exit code and then terminate.

enum wm_error error= wm_init();
if (error)
{
printf("Unable to initialize subsystem\n");
return error;
}
add widgets to window...
wm_register_window(window);
error= wm_run();
return error;

◆ wm_run_modal()

enum event_response wm_run_modal ( widget i_widget)

runs a widget as modal

Parameters
[in]i_widgetwidget to run as modal
Returns
response

The widget will run in an infinite loop. It will exit if the user hits the escape key (RESPONSE_CLOSE) or an event produces a response other than RESPONSE_NONE or RESPONSE_HANDLED.

The code in menu::submenu illustrates the use of how to use wm_run_modal.

◆ wm_unregister_window()

void wm_unregister_window ( window *const  i_window)

remove a window from the window manager

Parameters
[in]i_windowwindow to remove
Returns
none

Once the window has been removed, it is no longer managed by the window manager. If it was dynamically allocated, it is the callers responsibility to dispose of it.