Skip to content

Commit 04cb592

Browse files
committed
FEAT: enabled "window" host extension on Windows (without graphics)...
... so it's possible to `view gob` or `view image` to open a system window. Originally the windowing was dependent on `graphics` extension. Now it is independent and the graphics (using AGG ) is not yet ready.
1 parent 8a96edb commit 04cb592

13 files changed

+764
-386
lines changed

make/r3.rc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
IDI_APPICON ICON "r3.ico"
1+
101 ICON "r3.ico"
22

33
1 VERSIONINFO
44
FILEVERSION 3,0,0,0

src/boot/graphics.r

+3-26
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
REBOL [
22
System: "REBOL [R3] Language Interpreter and Run-time Environment"
33
Title: "REBOL Graphics"
4+
Author: ["Richard Smolak" "Carl Sassenrath"]
45
Rights: {
56
Copyright 2012 REBOL Technologies
67
REBOL is a trademark of REBOL Technologies
8+
9+
Additional code modifications and improvements Copyright 2012 Saphirion AG
710
}
811
License: {
912
Licensed under the Apache License, Version 2.0.
@@ -16,13 +19,6 @@ REBOL [
1619
]
1720

1821
words: [
19-
;gui-metric
20-
screen-size
21-
border-size
22-
border-fixed
23-
title-size
24-
work-origin
25-
work-size
2622
]
2723

2824
;temp hack - will be removed later
@@ -32,34 +28,20 @@ init-words: command [
3228

3329
init-words words
3430

35-
init: command [
36-
"Initialize graphics subsystem."
37-
gob [gob!] "The screen gob (root gob)"
38-
]
39-
4031
caret-to-offset: command [
4132
"Returns the xy offset (pair) for a specific string position in a graphics object."
4233
gob [gob!]
4334
element [integer! block!] "The position of the string in the richtext block"
4435
position [integer! string!] "The position within the string"
4536
]
4637

47-
cursor: command [
48-
"Changes the mouse cursor image."
49-
image [integer! image! none!]
50-
]
5138

5239
offset-to-caret: command [ ;returns pair! instead of the block..needs to be fixed
5340
"Returns the richtext block at the string position for an XY offset in the graphics object."
5441
gob [gob!]
5542
position [pair!]
5643
]
5744

58-
show: command [
59-
"Display or update a graphical object or block of them."
60-
gob [gob! none!]
61-
]
62-
6345
size-text: command [
6446
"Returns the size of text rendered by a graphics object."
6547
gob [gob!]
@@ -71,11 +53,6 @@ draw: command [
7153
commands [block!] "Draw commands"
7254
]
7355

74-
gui-metric: command [
75-
"Returns specific gui related metric setting."
76-
keyword [word!] "Available keywords: SCREEN-SIZE, BORDER-SIZE, BORDER-FIXED, TITLE-SIZE, WORK-ORIGIN and WORK-SIZE."
77-
]
78-
7956
;#not-yet-used [
8057
;
8158
;effect: command [

src/boot/window.r

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
REBOL [
2+
System: "REBOL [R3] Language Interpreter and Run-time Environment"
3+
Title: "REBOL Window"
4+
Author: ["Richard Smolak" "Carl Sassenrath" "Oldes"]
5+
Rights: {
6+
Copyright 2012 REBOL Technologies
7+
REBOL is a trademark of REBOL Technologies
8+
9+
Additional code modifications and improvements Copyright 2012 Saphirion AG
10+
}
11+
License: {
12+
Licensed under the Apache License, Version 2.0.
13+
See: http://www.apache.org/licenses/LICENSE-2.0
14+
}
15+
Name: window
16+
Type: extension
17+
Exports: [] ; added by make-host-ext.r
18+
Note: "Run make-host-ext.r to convert"
19+
]
20+
21+
words: [
22+
;gui-metric
23+
border-fixed
24+
border-size
25+
screen-size
26+
virtual-screen-size
27+
log-size
28+
phys-size
29+
screen-dpi
30+
screen-num
31+
screen-origin
32+
title-size
33+
window-min-size
34+
work-origin
35+
work-size
36+
restore
37+
minimize
38+
maximize
39+
activate
40+
]
41+
42+
;temp hack - will be removed later
43+
init-words: command [
44+
words [block!]
45+
]
46+
47+
init-words words
48+
49+
init-top-window: command [
50+
"Initialize window subsystem."
51+
gob [gob!] "The screen gob (root gob)"
52+
]
53+
54+
cursor: command [
55+
"Changes the mouse cursor image."
56+
image [integer! image! none!]
57+
]
58+
59+
show: command [
60+
"Display or update a graphical object or block of them."
61+
gob [gob! none!]
62+
]
63+
64+
gui-metric: command [
65+
"Returns specific gui related metric setting."
66+
keyword [word!] "Available keywords: BORDER-FIXED, BORDER-SIZE, SCREEN-DPI, LOG-SIZE, PHYS-SIZE, SCREEN-SIZE, VIRTUAL-SCREEN-SIZE, TITLE-SIZE, WINDOW-MIN-SIZE, WORK-ORIGIN and WORK-SIZE."
67+
/set
68+
val "Value used to set specific setting(works only on 'writable' keywords)."
69+
/display
70+
idx [integer!] "Display index, starting with 0"
71+
]
72+
73+
show-soft-keyboard: command [
74+
"Display on-screen keyboard for user input."
75+
/attach
76+
gob [gob!] "GOB which should be visible during the input operation"
77+
]
78+

src/include/reb-gob.h

+32-9
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@
3232
** are accounted for by the standard garbage collector.
3333
**
3434
***********************************************************************/
35-
3635
#ifndef REB_GOB_H
3736
#define REB_GOB_H
3837

38+
#include "host-view.h"
39+
3940
enum GOB_FLAGS { // GOB attribute and option flags
4041
GOBF_TOP = 0, // Top level (window or output image)
4142
GOBF_WINDOW, // Window (parent is OS window reference)
@@ -50,6 +51,11 @@ enum GOB_FLAGS { // GOB attribute and option flags
5051
GOBF_POPUP, // Window is a popup (with owner window)
5152
GOBF_MODAL, // Modal event filtering
5253
GOBF_ON_TOP, // The window is always on top
54+
GOBF_ACTIVE, // Window is active
55+
GOBF_MINIMIZE, // Window is minimized
56+
GOBF_MAXIMIZE, // Window is maximized
57+
GOBF_RESTORE, // Window is restored
58+
GOBF_FULLSCREEN, // Window is fullscreen
5359
};
5460

5561
enum GOB_STATE { // GOB state flags
@@ -79,7 +85,6 @@ enum GOB_DTYPES { // Userdata types
7985
GOBD_INTEGER
8086
};
8187

82-
8388
#pragma pack(4)
8489

8590
typedef struct rebol_gob REBGOB;
@@ -110,16 +115,32 @@ struct rebol_gob { // size: 64 bytes!
110115
};
111116
#pragma pack()
112117

118+
typedef struct gob_window { // Maps gob to window
119+
REBGOB *gob;
120+
void* win;
121+
void* compositor;
122+
} REBGOBWINDOWS;
123+
113124
#define GOB_X(g) ((g)->offset.x)
114125
#define GOB_Y(g) ((g)->offset.y)
115126
#define GOB_W(g) ((g)->size.x)
116127
#define GOB_H(g) ((g)->size.y)
117128

129+
#define GOB_LOG_X(g) (LOG_COORD_X((g)->offset.x))
130+
#define GOB_LOG_Y(g) (LOG_COORD_Y((g)->offset.y))
131+
#define GOB_LOG_W(g) (LOG_COORD_X((g)->size.x))
132+
#define GOB_LOG_H(g) (LOG_COORD_Y((g)->size.y))
133+
118134
#define GOB_X_INT(g) ROUND_TO_INT((g)->offset.x)
119135
#define GOB_Y_INT(g) ROUND_TO_INT((g)->offset.y)
120136
#define GOB_W_INT(g) ROUND_TO_INT((g)->size.x)
121137
#define GOB_H_INT(g) ROUND_TO_INT((g)->size.y)
122138

139+
#define GOB_LOG_X_INT(g) ROUND_TO_INT(LOG_COORD_X((g)->offset.x))
140+
#define GOB_LOG_Y_INT(g) ROUND_TO_INT(LOG_COORD_Y((g)->offset.y))
141+
#define GOB_LOG_W_INT(g) ROUND_TO_INT(LOG_COORD_X((g)->size.x))
142+
#define GOB_LOG_H_INT(g) ROUND_TO_INT(LOG_COORD_Y((g)->size.y))
143+
123144
#define GOB_XO(g) ((g)->old_offset.x)
124145
#define GOB_YO(g) ((g)->old_offset.y)
125146
#define GOB_WO(g) ((g)->old_size.x)
@@ -131,12 +152,14 @@ struct rebol_gob { // size: 64 bytes!
131152

132153
#define CLEAR_GOB_STATE(g) ((g)->state = 0)
133154

134-
#define SET_GOB_FLAG(g,f) SET_FLAG((g)->flags, f)
135-
#define GET_GOB_FLAG(g,f) GET_FLAG((g)->flags, f)
136-
#define CLR_GOB_FLAG(g,f) CLR_FLAG((g)->flags, f)
137-
#define SET_GOB_STATE(g,f) SET_FLAG((g)->state, f)
138-
#define GET_GOB_STATE(g,f) GET_FLAG((g)->state, f)
139-
#define CLR_GOB_STATE(g,f) CLR_FLAG((g)->state, f)
155+
#define SET_GOB_FLAG(g,f) SET_FLAG((g)->flags, f)
156+
#define GET_GOB_FLAG(g,f) GET_FLAG((g)->flags, f)
157+
#define CLR_GOB_FLAG(g,f) CLR_FLAG((g)->flags, f)
158+
#define CLR_GOB_FLAGS(g,f,h) CLR_FLAGS((g)->flags, f, h)
159+
#define SET_GOB_STATE(g,f) SET_FLAG((g)->state, f)
160+
#define GET_GOB_STATE(g,f) GET_FLAG((g)->state, f)
161+
#define CLR_GOB_STATE(g,f) CLR_FLAG((g)->state, f)
162+
#define CLR_GOB_STATES(g,f,h) CLR_FLAGS((g)->state, f, h)
140163

141164
#define GOB_ALPHA(g) ((g)->alpha)
142165
#define GOB_TYPE(g) ((g)->ctype)
@@ -192,4 +215,4 @@ enum {
192215

193216
extern REBGOB *Gob_Root; // Top level GOB (the screen)
194217

195-
#endif
218+
#endif

src/mezz/view-funcs.r

+12-3
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ system/standard/para: context [
3838

3939
view: func [
4040
"Displays a window view."
41-
window [gob! block! object!] "Window gob, VID face, or VID layout block"
41+
window [gob! block! object! image!] "Window gob, VID face, or VID layout block"
4242
/options opts [block!] "Window options spec block"
4343
/no-wait "Return immediately. Do not wait and process events."
4444
/as-is "Leave window as is. Do not add a parent gob."
45-
/local screen tmp xy
45+
/local screen tmp xy image
4646
][
4747
if not screen: system/view/screen-gob [return none]
4848

@@ -54,13 +54,22 @@ view: func [
5454
; options [append opts reduce/no-set opts]
5555
]
5656

57+
if image? window [
58+
image: window
59+
window: make gob! [
60+
size: image/size
61+
image: image
62+
]
63+
]
64+
5765
; GOB based view:
5866
if gob? window [
5967
; Build the window:
6068
unless opts/as-is [
6169
tmp: window
6270
tmp/offset: 0x0
6371
window: make gob! [size: tmp/size]
72+
window/offset: system/view/metrics/title-size
6473
append window tmp
6574
]
6675
; Set optional background:
@@ -214,7 +223,7 @@ init-view-system: func [
214223
/local ep
215224
][
216225
; The init function called here resides in this module
217-
init system/view/screen-gob: make gob! [text: "Top Gob"]
226+
init-top-window system/view/screen-gob: make gob! [text: "Top Gob"]
218227

219228
;update the metrics object (temp - will become mezz later)
220229
foreach w words-of system/view/metrics [

src/os/host-main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ int main(int argc, char **argv) {
284284
if (n == 2) Host_Crash("Host-lib wrong version/checksum");
285285

286286
#ifndef REB_CORE
287-
//Init_Windows();
287+
Init_Windows();
288288
//Init_Graphics();
289289
#endif
290290

src/os/win32/host-event.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ const REBCNT Key_To_Event[] = {
9393
extern HCURSOR Cursor;
9494
extern void Done_Device(int handle, int error);
9595
extern void Paint_Window(HWND window);
96-
extern void Close_Window(REBGOB *gob);
97-
extern REBOOL Resize_Window(REBGOB *gob, REBOOL redraw);
96+
9897

9998

10099
/***********************************************************************
@@ -239,12 +238,12 @@ static Check_Modifiers(REBINT flags)
239238
last_xy = xy;
240239
if (mode) {
241240
//Resize and redraw the window buffer (when resize dragging)
242-
Resize_Window(gob, TRUE);
241+
OS_Resize_Window(gob, TRUE);
243242
mode = EVT_RESIZE;
244243
break;
245244
} else {
246245
//Resize only the window buffer (when win gob size changed by REBOL code or using min/max buttons)
247-
if (!Resize_Window(gob, FALSE)){
246+
if (!OS_Resize_Window(gob, FALSE)){
248247
//size has been changed programatically - return only 'resize event
249248
Add_Event_XY(gob, EVT_RESIZE, xy, flags);
250249
break;
@@ -383,8 +382,8 @@ static Check_Modifiers(REBINT flags)
383382

384383
case WM_CLOSE:
385384
Add_Event_XY(gob, EVT_CLOSE, xy, flags);
386-
Close_Window(gob); // Needs to be removed - should be done by REBOL event handling
387-
// DestroyWindow(hwnd);// This is done in Close_Window()
385+
OS_Close_Window(gob); // Needs to be removed - should be done by REBOL event handling
386+
// DestroyWindow(hwnd);// This is done in OS_Close_Window()
388387
break;
389388

390389
case WM_DESTROY:

0 commit comments

Comments
 (0)