Skip to content

Commit f9062f7

Browse files
committed
[U32] Button control rendering
1 parent 1d4e0ce commit f9062f7

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

dlls/user32/dialogs.hexa

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
// TODO turn all `as! Message` into `Message.TAG`
1717

18+
// TODO this file will be replaced with custom implementation
19+
// ^ it was one of the test-cases for C-to-Hexa translation tool
20+
// but I'd like too see a more straight-forward, idiomatic implementation
21+
1822
// TODO docs
1923
@struct
2024
class DlgControlInfo {

dlls/user32/userMain.hexa

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@
352352
')
353353
declare fun entry() Void
354354

355+
// TODO move those things
355356
enum ButtonStyles : Int {
356357
// TODO Hexa: make it possible to use constants as tags like `BS_PUSHBUTTON = push_button`
357358
BS_PUSH_BUTTON = 0x00000000
@@ -399,6 +400,12 @@ fun buttonWindowProcW(hWnd HWnd, uMsg Message, wParam WParam, lParam LParam) LRe
399400
switch uMsg {
400401
case WM_PAINT:
401402
tofitaDebugLog("buttonWindowProcW called - WM_PAINT".utf16())
403+
404+
if isWindowVisible(hWnd) != Bool32.True {
405+
// TODO return what?
406+
// return null
407+
}
408+
402409
let ps ByValue<PaintStruct> = ByValue<PaintStruct>()
403410
let hdc = beginPaint(hWnd, ps.ref)
404411
// let color_window = 5 // TODO
@@ -430,20 +437,26 @@ fun buttonWindowProcW(hWnd HWnd, uMsg Message, wParam WParam, lParam LParam) LRe
430437
// (and strong black frame for default button)
431438
let r = ByValue<Rect>()
432439
getClientRect(hWnd, r.ref)
433-
let fmt DrawTextFormat = DrawTextFormat.DT_CENTER // TODO | DrawTextFormat.DT_VCENTER
440+
let fmt DrawTextFormat = DrawTextFormat.DT_CENTER // TODO | DrawTextFormat.DT_V_CENTER
434441

435442
let color_window = 5 // TODO
436443
// fillRect(hdc, ps.ref.rcPaint.ref, (color_window + 2) as! HBrush)
437444
// fillRect(hdc, r.ref, (color_window + 2) as! HBrush)
438-
439-
if (userdata & (ButtonStates.BST_PUSHED as! UInt16) /*TODO*/) == 0 {
445+
fillRect(hdc, r.ref, getStockObject(2) as! HBrush)
446+
drawEdge(hdc, r.ref, EdgeFlags.BDR_RAISED_INNER, BorderFlags.BF_MIDDLE /* TODO | BF_RECT*/)
447+
r.ref.left += 2
448+
r.ref.top += 2
449+
r.ref.right += 2
450+
r.ref.bottom += 2
451+
drawTextW(hdc, title, -1, r.ref, fmt)
452+
453+
/*if (userdata & (ButtonStates.BST_PUSHED as! UInt16) /*TODO*/) == 0 {
440454
drawEdge(hdc, r.ref, EdgeFlags.BDR_RAISED_INNER, BorderFlags.BF_MIDDLE /* TODO | BF_RECT*/)
441455
if (style & (ButtonStyles.BS_MULTILINE as! UInt16) /*TODO*/) == 0 {
442456
// TODO fmt |= DrawTextFormat.DT_SINGLE_LINE
443457
drawTextW(hdc, title, -1, r.ref, fmt)
444458
}
445-
}
446-
459+
}*/
447460
// TODO
448461
// if focus
449462
// - drawEdge(hdc, &r, BDR_RAISEDINNER, BF_MIDDLE | BF_RECT);
@@ -471,7 +484,7 @@ fun emptyWindowProcW(hWnd HWnd, uMsg Message, wParam WParam, lParam LParam) LRes
471484
let hdc = beginPaint(hWnd, ps.ref)
472485

473486
let color_window = 5 // TODO
474-
487+
// fillRect(hdc, ps.ref.rcPaint.ref, (color_window + 1) as! HBrush)
475488

476489
endPaint(hWnd, ps.ref)
477490

0 commit comments

Comments
 (0)