-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.bh
155 lines (125 loc) · 4.89 KB
/
global.bh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
$NoPrefix
$Resize:On
Option Explicit
Print "Initializing..."
Type winType 'Window type definition. QB64 is not object-oriented, so we have to use user types instead.
IH As Long ' Image handle. A value of 0 indicates that this is an open window handle.
FH As Long ' Font handle. Not really necessarry, as you can use _FONT() but it's useful when resizing
PM As Unsigned Byte ' _PRINTMODE
T As String ' Title. Empty string means that the window is a overlay
X As Integer ' X position. Should be Single but for some reason QB64 doesn't like virginity :(
Y As Integer ' Y position
Z As Unsigned Byte ' Z position
W As Unsigned Integer ' Width
H As Unsigned Integer ' Height
NeedsRefresh As Byte ' Set to -1 if the window, well, needs refreshed. Preferrably would be BIT, but unfortunately, QB64 can't have BITs in UDTs
MX As Integer ' Mouse X position relative to the window
MY As Integer ' Mouse Y position relative to the window
MS As Single ' Mouse scroll (relative to last refresh)
MAS As Single ' Mouse scroll (absolute)
End Type
'Constants
Const True = -1
Const False = 0
Const __PM_KeepBackground = 1
Const __PM_OnlyBackground = 2
Const __PM_FillBackground = 3
$Let TRUE = -1
$Let FALSE = 0
$Let HW = FALSE
$Let LIGHT = FALSE
'Initialize variables
Rem $Dynamic
Dim w(1 To 1) As winType
Rem $Static
Dim winZOrder(0 To 255) As Byte
Dim Shared __template_Win As winType
Dim Shared __template_Overlay As winType
Dim Shared __template_WinOptions As winType
Dim Shared __font_Header As Long
Dim Shared __font_Body As Long
Dim Shared __font_Mono As Long
Dim Shared __font_Sans As Long
Dim Shared __font_Serif As Long
Dim __image_Background As Long
Dim __image_Screen As Long
Dim __image_ScreenBuffer As Long
Dim __image_Cursor As Long
Dim __param_ScreenFont As Long
Dim __param_TBHeight As Unsigned Byte
Dim Shared __inKey As String
Dim Shared __focusedWindow As Integer
Print "...Images:"
'Initialize the IMAGEs...
__image_Background = LoadImage("images/back.png", 32): Print , "Background: "; __image_Background
__image_Screen = NewImage(640, 480, 32): Print , "Screen: "; __image_Screen
__image_Cursor = LoadImage("images/cursor.png", 33): Print , "Cursor: "; __image_Cursor
$If HW = TRUE Then
__image_ScreenBuffer = COPYIMAGE(__image_Screen, 33): PRINT , "ScreenBuffer: "; __image_ScreenBuffer
$End If
Print "...Fonts:"
'...and the FONTs
$If LINUX Then
__font_Header = LoadFont("/usr/share/fonts/truetype/ubuntu/Ubuntu-B.ttf", 14, "DONTBLEND"): Print , "Header: "; __font_Header
__font_Body = LoadFont("/usr/share/fonts/truetype/ubuntu/Ubuntu-L.ttf", 12, "DONTBLEND"): Print , "Body: "; __font_Body
__font_Mono = LoadFont("/usr/share/fonts/truetype/ubuntu/UbuntuMono-R.ttf", 12, "DONTBLEND"): Print , "Mono: "; __font_Mono
__font_Serif = LoadFont("/usr/share/fonts/truetype/liberation/LiberationSerif-Regular.ttf", 12, "DONTBLEND"): Print , "Serif: "; __font_Serif
__font_Sans = LoadFont("/usr/share/fonts/truetype/ubuntu/Ubuntu-R.ttf", 12, "DONTBLEND"): Print , "Sans: "; __font_Sans
$Else
'TODO: integrate Windows & MacOS fonts
__font_Header = 16
__font_Body = 14
__font_Mono = 14
__font_Serif = 14
__font_Sans = 14
$End If
__param_ScreenFont = __font_Header
Print "...Templates:"
'Initialize the window templates
__template_Win.T = "Untitled window"
__template_Win.W = 320
__template_Win.H = 240
__template_Win.Z = 0
__template_Win.IH = 0
__template_Win.FH = __font_Body
__template_Win.PM = __PM_KeepBackground
__template_Win.NeedsRefresh = True
Print , "Win"
__template_Overlay.T = ""
__template_Overlay.W = 120
__template_Overlay.H = 60
__template_Overlay.Z = 0
__template_Overlay.IH = 0
__template_Overlay.FH = __font_Body
__template_Overlay.PM = __PM_KeepBackground
__template_Overlay.NeedsRefresh = True
Print , "Overlay"
__template_WinOptions.T = ""
__template_WinOptions.W = 120
__template_WinOptions.H = 60
__template_WinOptions.Z = 0
__template_WinOptions.IH = NewImage(120, 60, 32)
__template_WinOptions.FH = __font_Body
__template_WinOptions.PM = __PM_KeepBackground
__template_WinOptions.NeedsRefresh = True
Print , "WinOptions"
'Initialize the WinOptions template's contents
Print "WinOptions"
Dest __template_WinOptions.IH
Font __template_WinOptions.FH
PrintString (0, 0), "Close"
__param_TBHeight = FontHeight(__param_ScreenFont) + 2
Sleep
'And finally, initialize the SCREEN.
Screen __image_Screen
MouseHide
$If HW = TRUE Then
'DisplayOrder Hardware , Software
DEST __image_ScreenBuffer
FONT __param_ScreenFont, __image_ScreenBuffer
printmode keepbackground,__image_screenbuffer
$Else
Dest Display
Font __param_ScreenFont, __image_Screen
PrintMode KeepBackground , __image_Screen
$End If