Function 0 — define and draw window

From KolibriOS wiki
Jump to: navigation, search

Parameters

bits type value description
eax
0–31 uint32 0 Function number.
ebx
0–15 uint16 window width Window placement by X axis.
16–31 int16 window offset by X
ecx
0–15 uint16 window height Window placement by Y axis.
16–31 int16 window offset by Y
edx
0–23 rgb888 client area color
24–27 uint4 window type
  • 0 — window type I — fixed size window;
  • 1 — just define window area, don't draw anything;
  • 2 — window type II — user-resizable window;
  • 3 — window type III — skinned window;
  • 4 — window type IV — fixed size skinned window.

Other possible values (from 5 to 15) are reserved, function call will be ignored.

28 bit flag: caption text Window type I–II: ignored.

Window type III–IV:

  • 0 — no caption;
  • 1 — caption text address is in edi.
29 bit flag: paint origin Paint origin corresponds to:
  • 0 — top left window corner: 0 by X, 0 by Y;
  • 1 — top left client area corner: <border width> by X, <title bar height> by Y.
30 bit flag: window background On window redraw, client area is:
  • 0 — filled;
  • 1 — not filled.
31 bit flag: gradient background On window redraw, client area is filled with:
  • 0 — solid color;
  • 1 — gradient from specified color (top) to black (bottom).
esi
0–23 rgb888 title bar color Only for window type I–II.
24 bit flag: fixed position window
  • 0 — window could be moved by user;
  • 1 — window couldn't be moved by user.
25–27 0 Reserved.
28–31 uint4 title bar style Window type I–II:
  • 0 — no gradient;
  • 4 — reverse gradient;
  • 8 — normal gradient.

Other values are reserved.

Window type III–IV: ignored.

edi
0–31 rgb888 window border color Only for window type I–II.
char* caption text address Only for window type III–IV with edx28 = 1.

Return value

Function doesn't return value.

Examples

        ;; without macros
 
        ; function number: 0
        xor     eax, eax
        ; window position: <offset> * 65536 + <size>
        ; alternatives: 100 shl 16 + 300, 0x0064012C
        mov     ebx, 100 * 65536 + 300
        mov     eсx, 200 * 65536 + 150
        ; background color: 0x0080ff (red 0, green 128, blue 255)
        ; window type: III (skinned, user-resizable)
        ; flags: has caption text, paint origin at (0, 0), solid background with no gradient
        mov     edx, 0x130080ff
        ; caption text address
        mov     edi, window_title
        ; function call
        int     0x40
 
        ;; same with use of mcall
 
        mcall   0, <100, 300>, <200, 150>, 0x130080ff, , window_title
 
; ...
window_title db 'Foobar', 0
; ...

Notes

Window position and size are set on first function call and ignored on further calls; to change position and/or size of already defined window use function 67.

For windows of type III–IV with caption (edx28 = 1), caption text address is set on first function call and ignored on further calls (precisely, it's ignored after call to function 12.2 — end of drawing); to change caption text address of already defined window use function 71.1.

By using specific window styles, window position and/or size could be changed by user. Current position and size could be obtained by calling function 9.

Window should fit into screen. If specified position and size don't fit this requirement, corresponding offset (or even both or them) is set to 0, and if this doesn't help either then corresponding extent (or even both of them) is set to match screen size.

Note: Later we'll use xpos, ypos, xsize, ysize — values passed in ebx and ecx. Provided coordinates are relative to top left window corner which is (0, 0), bottom right corner coordinates are (xsize, ysize).

Window size is treated as coordinates of bottom right corner.

Note: Same applies to all other functions. This means that real window extents are 1 pixel greater.

Window type I look

  • drawing outer frame 1 pixel wide of edi color;
  • drawing title bar — rectangle with top left corner at (1, 1) and bottom right corner at (xsize − 1, min(25, ysize)) — using color in esi (taking gradient settings into account)
  • if ysize ≥ 26 then filling client area — rectangle with left top corner at (1, 21) and bottom right corner at (xsize − 1, ysize − 1) (or size (xsize − 1) × (ysize − 21)) — using color in edx (taking gradient settings into account)
  • if edx28 = 1 and caption text address is set by calling function 71.1, it's drawn on title bar in corresponding place.

Window type II look

  • drawing outer frame 1 pixel wide of "shaded" edi color (all color components divided by 2);
  • drawing middle frame 3 pixels wide of edi color;
  • drawing inner frame 1 pixel wide of "shaded" edi color;
  • drawing title bar — rectangle with top left corner at (4, 4) and bottom right corner at (xsize − 4, min(20, ysize)) — using color in esi (taking gradient settings into account);
  • if ysize ≥ 26 then filling client area — rectangle with top left corner at (5, 20) and bottom right corner at (xsize − 5, ysize − 5) — using color in edx (taking gradient settings into account);
  • if edx28 = 1 and caption text address is set by calling function 71.1, it's drawn on title bar in corresponding place.

Skinned window look (types III and IV)

  • drawing outer frame 1 pixel wide of 'outer' skin color;
  • drawing middle frame 3 pixels wide of 'frame' skin color;
  • drawing inner frame 1 pixel wide or 'inner' skin color;
  • drawing title bar (using skin images) in rectangle (0, 0) – (xsize, _skinh − 1);
  • if ysize ≥ 26 then filling client area — rectangle with top left corner at (5, _skinh) and bottom right corner at (xsize − 5, ysize − 5) — using color in edx (taking gradient settings into account);
  • defining two standard buttons: window close and minimize (see function 8);
  • if edx28 = 1 and edi contains (non-null) caption text address, it's drawn on title bar using rectangle defined by skin.

Value of _skinh variable corresponds to result of calling function 48.4.