Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -0,0 +1,83 @@
|
|||
#include once "windows.bi"
|
||||
#include once "/win/commctrl.bi"
|
||||
|
||||
Dim Shared As zString * 255 textMessage = ""
|
||||
Dim Shared As zString * 255 valueMessage = ""
|
||||
Dim Shared As HWND MainWindow
|
||||
Dim Shared As HWND EditBox, ValueBox, Button, Cancel, LabelBox
|
||||
|
||||
Function CreateToolTip(X As hwnd, msg As String = "") As hwnd
|
||||
Dim As hwnd TT = CreateWindowEx(0, "ToolTips_Class32", "", 64, 0, 0, 0, 0, X, 0, GetModuleHandle(0), 0)
|
||||
SendMessage(TT, TTM_SETMAXTIPWIDTH, 0, 180)
|
||||
SendMessage(TT, TTM_SETDELAYTIME, TTDT_INITIAL, 10)
|
||||
SendMessage(TT, TTM_SETDELAYTIME, TTDT_RESHOW, 60)
|
||||
Dim bubble As TOOLINFO
|
||||
bubble.cbSize = Len(TOOLINFO)
|
||||
bubble.uFlags = TTF_IDISHWND Or TTF_SUBCLASS
|
||||
bubble.uId = Cast(Uinteger, X)
|
||||
bubble.lpszText = Strptr(msg)
|
||||
SendMessage(TT, TTM_ADDTOOL, 0, Cast(LPARAM, @bubble))
|
||||
Return TT
|
||||
End Function
|
||||
|
||||
Sub CreateMainWindow
|
||||
MainWindow = CreateWindowEx(NULL, "WindowClass", "User input/Graphical", WS_OVERLAPPEDWINDOW Or WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 300, 180, NULL, NULL, NULL, NULL)
|
||||
EditBox = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", textMessage, WS_VISIBLE Or WS_CHILD, 10, 10, 250, 24, MainWindow, NULL, NULL, NULL)
|
||||
ValueBox = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", valueMessage, WS_VISIBLE Or WS_CHILD Or ES_NUMBER, 10, 40, 250, 24, MainWindow, NULL, NULL, NULL)
|
||||
Button = CreateWindowEx(NULL, "Button", "Aceptar", WS_VISIBLE Or WS_CHILD, 10, 70, 250, 24, MainWindow, NULL, NULL, NULL)
|
||||
LabelBox = CreateWindowEx(NULL, "static", "", WS_VISIBLE Or WS_CHILD, 10, 100, 250, 24, MainWindow, NULL, NULL, NULL)
|
||||
CreateToolTip(EditBox, "Type something in the box")
|
||||
CreateToolTip(ValueBox, "Type a number in the box")
|
||||
End Sub
|
||||
|
||||
Function WndProc(hWnd As HWND, msg As UINT, wParam As WPARAM, lParam As LPARAM) As LRESULT
|
||||
Select Case hWnd
|
||||
Case MainWindow
|
||||
Select Case msg
|
||||
Case WM_PAINT
|
||||
Dim As PAINTSTRUCT ps
|
||||
BeginPaint(hWnd, @ps)
|
||||
FillRect(ps.hdc, @ps.rcPaint, CreateSolidBrush(BGR(238, 238, 238)))
|
||||
EndPaint(hWnd, @ps)
|
||||
|
||||
Case WM_CLOSE
|
||||
DestroyWindow(hWnd)
|
||||
|
||||
Case WM_COMMAND
|
||||
Select Case lParam
|
||||
Case Button
|
||||
GetWindowText(EditBox, @textMessage, 255)
|
||||
GetWindowText(ValueBox, @valueMessage, 255)
|
||||
SetWindowText(LabelBox, textMessage & " - " & valueMessage)
|
||||
End Select
|
||||
End Select
|
||||
End Select
|
||||
|
||||
Return DefWindowProc(hWnd, msg, wParam, lParam)
|
||||
End Function
|
||||
|
||||
Dim As WNDCLASS wcls
|
||||
|
||||
With wcls
|
||||
.style = CS_HREDRAW Or CS_VREDRAW
|
||||
.lpfnWndProc = Cast(WNDPROC, @WndProc)
|
||||
.hInstance = GetModuleHandle(NULL)
|
||||
.hIcon = LoadIcon(NULL, IDI_APPLICATION)
|
||||
.hCursor = LoadCursor(NULL, IDC_ARROW)
|
||||
.hbrBackground = GetStockObject(WHITE_BRUSH)
|
||||
.lpszMenuName = NULL
|
||||
.lpszClassName = Strptr("WindowClass")
|
||||
End With
|
||||
|
||||
If RegisterClass(@wcls) = False Then
|
||||
MessageBox(NULL, "RegisterClass('WindowClass') FALLO!", "Error!", MB_OK Or MB_ICONERROR)
|
||||
End
|
||||
End If
|
||||
|
||||
CreateMainWindow
|
||||
|
||||
Dim As MSG uMsg
|
||||
While GetMessage(@uMsg, NULL, NULL, NULL) <> False
|
||||
TranslateMessage(@uMsg)
|
||||
DispatchMessage(@uMsg)
|
||||
Wend
|
||||
59
Task/User-input-Graphical/V-(Vlang)/user-input-graphical.v
Normal file
59
Task/User-input-Graphical/V-(Vlang)/user-input-graphical.v
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import ui
|
||||
|
||||
@[heap]
|
||||
struct App {
|
||||
mut:
|
||||
win &ui.Window = unsafe {nil}
|
||||
txt_1 &ui.TextBox = unsafe {nil}
|
||||
txt_2 &ui.TextBox = unsafe {nil}
|
||||
lbl_1 &ui.Label = unsafe {nil}
|
||||
lbl_2 &ui.Label = unsafe {nil}
|
||||
btn_1 &ui.Button = unsafe {nil}
|
||||
instr string = "Enter some text, the number 75000, and press 'Validate'"
|
||||
txt string
|
||||
num string
|
||||
}
|
||||
|
||||
fn main() {
|
||||
mut app := &App{}
|
||||
// widgets defined and placed here for clarity
|
||||
app.lbl_1 = ui.label(text: &app.instr, id: "lbl_1", justify: [0.5, 0.0]) // [x, y] for text placement
|
||||
app.lbl_2 = ui.label(text: "", id: "lbl_2", text_align: .center, justify: [0.5, 0.0])
|
||||
app.txt_1 = ui.textbox(placeholder: "String", text: &app.txt, id: "txt_1")
|
||||
app.txt_2 = ui.textbox(placeholder: "Number", text: &app.num, id: "txt_2")
|
||||
app.btn_1 = ui.button(width: 5, text: "Validate", on_click: app.btn_click)
|
||||
|
||||
app.win = ui.window(
|
||||
height: 150
|
||||
width: 450
|
||||
title: "Input Info"
|
||||
mode: .resizable
|
||||
children: [
|
||||
ui.column(
|
||||
alignment: .center // button's center, relative to UI
|
||||
spacing: 5 // button's distance from other widgets
|
||||
widths: [ui.stretch, 150] // button's width relative to UI
|
||||
margin: ui.Margin{0, 5, 0, 5} // widgets relative to UI's edges, {y, right, x, left}
|
||||
children: [
|
||||
ui.column(
|
||||
alignment: .center
|
||||
spacing: 5 // distance between widgets in same column
|
||||
children: [
|
||||
app.lbl_1
|
||||
app.lbl_2
|
||||
app.txt_1
|
||||
app.txt_2
|
||||
]
|
||||
),
|
||||
// button in and controlled from separate column
|
||||
app.btn_1
|
||||
]
|
||||
),
|
||||
]
|
||||
)
|
||||
ui.run(app.win)
|
||||
}
|
||||
|
||||
fn (mut app App) btn_click(btn &ui.Button) {
|
||||
app.lbl_2.set_text("${app.txt} ${app.num}")
|
||||
}
|
||||
95
Task/User-input-Graphical/XPL0/user-input-graphical.xpl0
Normal file
95
Task/User-input-Graphical/XPL0/user-input-graphical.xpl0
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
\12345678901234567890123456789012345
|
||||
\User input/Graphical.......... X .
|
||||
\ Please enter a string and 75000: .
|
||||
\ String: Hello, World!___ .
|
||||
\ Number: 75000___________ .
|
||||
|
||||
def X0=20, Y0=10; \upper-left corner of window's position (chars)
|
||||
def StrMax = 16; \maximum number of characters in strings
|
||||
char String(2, StrMax); \string arrays (includes Number string)
|
||||
int StrInx(2); \index to character to be added to String
|
||||
int Mouse, Button, C, I, SN;
|
||||
|
||||
func GetButton; \Return soft button number at mouse pointer
|
||||
int X, Y;
|
||||
[Mouse:= GetMouse;
|
||||
X:= Mouse(0)/8 - X0; \convert pixels to char cells
|
||||
Y:= Mouse(1)/16 - Y0;
|
||||
if X>=32 & X<=34 & Y=0 then return 0; \exit [X]
|
||||
if X>=10 & X<=10+StrMax & Y=4 then return 1; \line 1
|
||||
if X>=10 & X<=10+StrMax & Y=6 then return 2; \line 2
|
||||
return -1; \mouse not on any soft button
|
||||
];
|
||||
|
||||
proc ShowCursor(Flag); \Turn cursor at insertion point on or off
|
||||
int Flag;
|
||||
[Cursor(10+StrInx(SN)+X0, 4+SN*2+Y0);
|
||||
ChOut(6, if Flag then ^_ else ^ );
|
||||
];
|
||||
|
||||
[SetVid($12); \640x480 graphics
|
||||
TrapC(true); \disable Ctrl+C
|
||||
Attrib($70); \black on gray
|
||||
SetWind(0+X0, 0+Y0, 35+X0, 8+Y0, 0, \fill\true);
|
||||
Cursor(33+X0, 0+Y0); Text(6, "X");
|
||||
Cursor(2+X0, 2+Y0); Text(6, "Please enter a string and 75000:");
|
||||
Cursor(2+X0, 4+Y0); Text(6, "String:");
|
||||
Cursor(2+X0, 6+Y0); Text(6, "Number:");
|
||||
|
||||
Attrib($1F); \bright white on blue, for title
|
||||
Cursor(0+X0, 0+Y0); Text(6, " User input/Graphical ");
|
||||
|
||||
Attrib($F0); \black on bright white
|
||||
for SN:= 0 to 1 do \initialize Strings
|
||||
[StrInx(SN):= 0;
|
||||
Cursor(10+X0, 4+SN*2+Y0);
|
||||
for I:= 0 to StrMax-1 do
|
||||
[String(SN, I):= $20; ChOut(6, ^ )];
|
||||
];
|
||||
SN:= 0; \select first, topmost String
|
||||
ShowCursor(true);
|
||||
|
||||
ShowMouse(true);
|
||||
loop [MoveMouse; \make pointer track mouse movements
|
||||
Mouse:= GetMouse;
|
||||
if Mouse(2) then \a left or right mouse button is down
|
||||
[Button:= GetButton; \get soft button at mouse pointer
|
||||
while Mouse(2) do \wait for mouse button's release
|
||||
[MoveMouse;
|
||||
Mouse:= GetMouse;
|
||||
];
|
||||
if Button = GetButton then \if down Button = release button
|
||||
[if Button = 0 then quit;
|
||||
if Button # -1 then \move cursor to active String
|
||||
[ShowCursor(false);
|
||||
SN:= Button-1;
|
||||
ShowCursor(true);
|
||||
];
|
||||
];
|
||||
];
|
||||
if KeyHit then
|
||||
[ShowMouse(false); \don't overwrite mouse pointer
|
||||
C:= ChIn(1); \get character from non-echoed keyboard
|
||||
if SN = 0 and C >= $20 and C <= $7E or \all printable ASCIIs
|
||||
SN = 1 and C >= $30 and C <= $39 then \only numeric digits
|
||||
[String(SN, StrInx(SN)):= C;
|
||||
if StrInx(SN) < StrMax-1 then StrInx(SN):= StrInx(SN)+1;
|
||||
]
|
||||
else if C = \BS\$08 then \delete back a character
|
||||
[ShowCursor(false);
|
||||
if StrInx(SN) > 0 then StrInx(SN):= StrInx(SN)-1;
|
||||
]
|
||||
else if C = \tab\$09 then \select next string
|
||||
[ShowCursor(false);
|
||||
SN:= rem((SN+1)/2);
|
||||
]
|
||||
else if C = \Esc\$1B then quit;
|
||||
|
||||
Cursor(10+X0, 4+SN*2+Y0); \show active String
|
||||
for I:= 0 to StrInx(SN)-1 do ChOut(6, String(SN, I));
|
||||
ChOut(6, ^_);
|
||||
ShowMouse(true);
|
||||
];
|
||||
];
|
||||
SetVid(3); \restore normal text mode immediately
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue