Window manipulation |
MX-Windows Help
|
Example :
|-----------------------------------------------------------------------------------------------|
|screen
|
|
|
| |---|-----------------------------------------------|---|
|
| CLOSE->| X |window caption
| O |<-MAXIMIZE
|
| |
|
| |
|
| |---|-----------------------------------------------|---|
|
| |
|window client area
| |
|
| |
|
| |
|
| |
| |----------------------------------|
| |
|
| |
| |form
| | |
|
| |
| |
| | |
|
| |
| |
| | |
|
| |
| |
| | |
|
| |
| |
| | |
|
| |
| |
| | |
|
| |
| |
| | |
|
| |
| |
| | |
|
| |
| | |----------| |---------------| |
| |
|
| |
| | |OK BUTTON | |CANCEL BUTTON | |
| |
|
| |
| | |----------| |---------------| |
| |
|
| |
| |----------------------------------|
| |
|
| |
|
| |
|
| |
|
| |
|
| |---|-----------------------------------------------|---|
|
|
|
|
|
|
|
|
|
|TASK BAR
|
|-----------------------------------------------------------------------------------------------|
|START BUTTON | ICON AREA
| SYSTEM TRAY |
|-----------------------------------------------------------------------------------------------|
In the above example we may observe a typical example of a nowadays
most often seen gui screen. The window tree is the following one :
SCREEN
|---APPLICATION WINDOW
| |---CLOSE BUTTON
| |---MAXIMIZE BUTTON
| |---WINDOW CAPTION
| |---WINDOW CLIENT AREA
|
|---FORM
|
|---OK BUTTON
|
|---CANCEL BUTTON
|---TASKBAR
|---START BUTTON
|---ICON AREA
|---SYSTEM TRAY
Window CreateWindow(
Window parent,
void *extension,
void (*event_handler)(WindowInfo
*, Event *),
int x,
int y,
int width,
int height,
int border_width,
int processed_events,
int propagated_events);
Once a window is created, it can be destroyed with the following function :
void DestroyWindow(Window *window);
The parameter is the window handle; you must pass a pointer to it so
as that the variable that the window handle is stored in is NULLed. When
a window is destroyed, it is also removed from the parent's list; if the
parent was drawn, then the window removal causes some areas of the screen
to be exposed; lower windows and its parent receive a series of expose
events.
Bool InsertWindow(Window window, Window parent, int pos);
The pos parameter is the depth (or z-order) of the window: A
positive value from 1 to n (n is maximum positive 32-bit integer) means
the biggest the value the deepest into the screen the window will be inserted;
a value of 1 means 'insert on top'; a value of 2 means 'insert just under
the top window' and so on;
POSITION
VIEWER ----> 1 --> 2
--> 3 --> 4 --> 5 --> 6 ...
If pos is a negative number greater than zero then the order
is inverted :
POSITION
VIEWER ----> ... -6 --> -5 --> -4 --> -3 --> -2 --> -1
Therefore if you would like to insert a window at the lowest posible position then use the value -1.
A window can be removed from the screen (but not destroyed) with the function :
Bool RemoveWindow(Window window);
Root windows (windows with no parent) can not be removed so in
that case the function returns FALSE.
If you do not like a window's depth then you could use the following
function to change it :
Bool SetWindowZOrder(Window window, int pos);
The rools about pos mentioned above also apply here. If
the new depth brings the window closer to the screen plane then some areas
of the window are exposed; If the new depth pushes the window away from
the screen plane then some windows or top of it are exposed.
void SetWindowX(Window window, int val);
void SetWindowY(Window window, int val);
void SetWindowWidth(Window window, int val);
void SetWindowHeight(Window window, int val);
void SetWindowBorderWidth(Window window, int
val);
If you wish to see the changes on the screen then the following function does all the needed changes on the screen (if neccessary) by re-calculating the physical position of each window in the given window tree and exposing or hiding any modified areas:
void UpdateWindowGeometry(Window window);
Bool RefreshWindow(Window window);
But if you would like to refresh just a window and not its children then you may use the function :
Bool PaintWindow(Window window);
These functions return TRUE if any change on the screen has been made;
if the window is not visible then they return FALSE.
These functions redraw whatever you have program the window to draw
in response to an expose event. If you would like to draw something temporary
in a window then you may use the function :
Bool DoWindowDrawing(Window window, Bool overwrite_children, void (*paint_function)(WindowInfo *, ExposeEvent *));
This function returns FALSE if the window was not visible; The passed
function uses the passed parameters to draw by using Allegro functions
just like when the window receives an expose event. Unfortunately you must
use external variables to control the drawing since the drawing is totally
user - defined. The drawing may appear on top of the window's children
or below them.