diff options
Diffstat (limited to 'src/libui_sdl/libui')
-rw-r--r-- | src/libui_sdl/libui/common/control.c | 5 | ||||
-rw-r--r-- | src/libui_sdl/libui/ui.h | 11 | ||||
-rw-r--r-- | src/libui_sdl/libui/ui_windows.h | 7 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/areaevents.cpp | 14 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/box.cpp | 1 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/form.cpp | 1 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/grid.cpp | 1 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/group.cpp | 1 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/tab.cpp | 1 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/window.cpp | 1 |
10 files changed, 43 insertions, 0 deletions
diff --git a/src/libui_sdl/libui/common/control.c b/src/libui_sdl/libui/common/control.c index 2806646..771a29d 100644 --- a/src/libui_sdl/libui/common/control.c +++ b/src/libui_sdl/libui/common/control.c @@ -57,6 +57,11 @@ void uiControlDisable(uiControl *c) (*(c->Disable))(c); } +void uiControlSetFocus(uiControl *c) +{ + (*(c->SetFocus))(c); +} + #define uiControlSignature 0x7569436F uiControl *uiAllocControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typenamestr) diff --git a/src/libui_sdl/libui/ui.h b/src/libui_sdl/libui/ui.h index 835b0c2..3d81996 100644 --- a/src/libui_sdl/libui/ui.h +++ b/src/libui_sdl/libui/ui.h @@ -72,6 +72,7 @@ struct uiControl { int (*Enabled)(uiControl *); void (*Enable)(uiControl *); void (*Disable)(uiControl *); + void (*SetFocus)(uiControl *); }; // TOOD add argument names to all arguments #define uiControl(this) ((uiControl *) (this)) @@ -86,6 +87,7 @@ _UI_EXTERN void uiControlHide(uiControl *); _UI_EXTERN int uiControlEnabled(uiControl *); _UI_EXTERN void uiControlEnable(uiControl *); _UI_EXTERN void uiControlDisable(uiControl *); +_UI_EXTERN void uiControlSetFocus(uiControl *); _UI_EXTERN uiControl *uiAllocControl(size_t n, uint32_t OSsig, uint32_t typesig, const char *typenamestr); _UI_EXTERN void uiFreeControl(uiControl *); @@ -653,7 +655,11 @@ struct uiAreaKeyEvent { uiModifiers Modifiers; + // additional things + int Scancode; // bit0-7: scancode, bit8: ext flag + int Up; + int Repeat; }; typedef struct uiFontButton uiFontButton; @@ -701,6 +707,11 @@ _UI_EXTERN int uiGridPadded(uiGrid *g); _UI_EXTERN void uiGridSetPadded(uiGrid *g, int padded); _UI_EXTERN uiGrid *uiNewGrid(void); + +// misc. + +_UI_EXTERN char* uiKeyName(int scancode); + #ifdef __cplusplus } #endif diff --git a/src/libui_sdl/libui/ui_windows.h b/src/libui_sdl/libui/ui_windows.h index 69dda36..3917c97 100644 --- a/src/libui_sdl/libui/ui_windows.h +++ b/src/libui_sdl/libui/ui_windows.h @@ -102,6 +102,11 @@ _UI_EXTERN void uiWindowsControlChildVisibilityChanged(uiWindowsControl *); uiWindowsControl(c)->enabled = 0; \ uiWindowsControlSyncEnableState(uiWindowsControl(c), uiControlEnabledToUser(c)); \ } +#define uiWindowsControlDefaultSetFocus(type) \ + static void type ## SetFocus(uiControl *c) \ + { \ + SetFocus(type(c)->hwnd); \ + } #define uiWindowsControlDefaultSyncEnableState(type) \ static void type ## SyncEnableState(uiWindowsControl *c, int enabled) \ { \ @@ -152,6 +157,7 @@ _UI_EXTERN void uiWindowsControlChildVisibilityChanged(uiWindowsControl *); uiWindowsControlDefaultEnabled(type) \ uiWindowsControlDefaultEnable(type) \ uiWindowsControlDefaultDisable(type) \ + uiWindowsControlDefaultSetFocus(type) \ uiWindowsControlDefaultSyncEnableState(type) \ uiWindowsControlDefaultSetParentHWND(type) \ uiWindowsControlDefaultMinimumSizeChanged(type) \ @@ -177,6 +183,7 @@ _UI_EXTERN void uiWindowsControlChildVisibilityChanged(uiWindowsControl *); uiControl(var)->Enabled = type ## Enabled; \ uiControl(var)->Enable = type ## Enable; \ uiControl(var)->Disable = type ## Disable; \ + uiControl(var)->SetFocus = type ## SetFocus; \ uiWindowsControl(var)->SyncEnableState = type ## SyncEnableState; \ uiWindowsControl(var)->SetParentHWND = type ## SetParentHWND; \ uiWindowsControl(var)->MinimumSize = type ## MinimumSize; \ diff --git a/src/libui_sdl/libui/windows/areaevents.cpp b/src/libui_sdl/libui/windows/areaevents.cpp index 7d391b8..842f2d7 100644 --- a/src/libui_sdl/libui/windows/areaevents.cpp +++ b/src/libui_sdl/libui/windows/areaevents.cpp @@ -262,8 +262,14 @@ static int areaKeyEvent(uiArea *a, int up, WPARAM wParam, LPARAM lParam) ke.Modifiers = getModifiers(); + ke.Scancode = (lParam >> 16) & 0x1FF; + ke.Up = up; + ke.Repeat = (lParam & 0x40000000) ? 1:0; + // StapleButter note: I don't actually need all this key decoding + // raw scancodes are all I need for this +#if 0 // the numeric keypad keys when Num Lock is off are considered left-hand keys as the separate navigation buttons were added later // the numeric keypad Enter, however, is a right-hand key because it has the same virtual-key code as the typewriter Enter righthand = (lParam & 0x01000000) != 0; @@ -306,9 +312,17 @@ static int areaKeyEvent(uiArea *a, int up, WPARAM wParam, LPARAM lParam) return 0; keyFound: +#endif return (*(a->ah->KeyEvent))(a->ah, a, &ke); } +char* uiKeyName(int scancode) +{ + WCHAR tmp[64]; + GetKeyNameText(scancode<<16, tmp, 64); + return toUTF8(tmp); +} + // We don't handle the standard Windows keyboard messages directly, to avoid both the dialog manager and TranslateMessage(). // Instead, we set up a message filter and do things there. // That stuff is later in this file. diff --git a/src/libui_sdl/libui/windows/box.cpp b/src/libui_sdl/libui/windows/box.cpp index 9567954..c306989 100644 --- a/src/libui_sdl/libui/windows/box.cpp +++ b/src/libui_sdl/libui/windows/box.cpp @@ -143,6 +143,7 @@ uiWindowsControlDefaultHide(uiBox) uiWindowsControlDefaultEnabled(uiBox) uiWindowsControlDefaultEnable(uiBox) uiWindowsControlDefaultDisable(uiBox) +uiWindowsControlDefaultSetFocus(uiBox) static void uiBoxSyncEnableState(uiWindowsControl *c, int enabled) { diff --git a/src/libui_sdl/libui/windows/form.cpp b/src/libui_sdl/libui/windows/form.cpp index febcc69..83ed587 100644 --- a/src/libui_sdl/libui/windows/form.cpp +++ b/src/libui_sdl/libui/windows/form.cpp @@ -147,6 +147,7 @@ uiWindowsControlDefaultHide(uiForm) uiWindowsControlDefaultEnabled(uiForm) uiWindowsControlDefaultEnable(uiForm) uiWindowsControlDefaultDisable(uiForm) +uiWindowsControlDefaultSetFocus(uiForm) static void uiFormSyncEnableState(uiWindowsControl *c, int enabled) { diff --git a/src/libui_sdl/libui/windows/grid.cpp b/src/libui_sdl/libui/windows/grid.cpp index c63cd1e..78719ac 100644 --- a/src/libui_sdl/libui/windows/grid.cpp +++ b/src/libui_sdl/libui/windows/grid.cpp @@ -436,6 +436,7 @@ uiWindowsControlDefaultHide(uiGrid) uiWindowsControlDefaultEnabled(uiGrid) uiWindowsControlDefaultEnable(uiGrid) uiWindowsControlDefaultDisable(uiGrid) +uiWindowsControlDefaultSetFocus(uiGrid) static void uiGridSyncEnableState(uiWindowsControl *c, int enabled) { diff --git a/src/libui_sdl/libui/windows/group.cpp b/src/libui_sdl/libui/windows/group.cpp index 8824c5a..f78e7de 100644 --- a/src/libui_sdl/libui/windows/group.cpp +++ b/src/libui_sdl/libui/windows/group.cpp @@ -75,6 +75,7 @@ uiWindowsControlDefaultHide(uiGroup) uiWindowsControlDefaultEnabled(uiGroup) uiWindowsControlDefaultEnable(uiGroup) uiWindowsControlDefaultDisable(uiGroup) +uiWindowsControlDefaultSetFocus(uiGroup) static void uiGroupSyncEnableState(uiWindowsControl *c, int enabled) { diff --git a/src/libui_sdl/libui/windows/tab.cpp b/src/libui_sdl/libui/windows/tab.cpp index 365f5a1..ea6209b 100644 --- a/src/libui_sdl/libui/windows/tab.cpp +++ b/src/libui_sdl/libui/windows/tab.cpp @@ -112,6 +112,7 @@ uiWindowsControlDefaultHide(uiTab) uiWindowsControlDefaultEnabled(uiTab) uiWindowsControlDefaultEnable(uiTab) uiWindowsControlDefaultDisable(uiTab) +uiWindowsControlDefaultSetFocus(uiTab) static void uiTabSyncEnableState(uiWindowsControl *c, int enabled) { diff --git a/src/libui_sdl/libui/windows/window.cpp b/src/libui_sdl/libui/windows/window.cpp index 9cf13a2..c04410d 100644 --- a/src/libui_sdl/libui/windows/window.cpp +++ b/src/libui_sdl/libui/windows/window.cpp @@ -229,6 +229,7 @@ static void uiWindowHide(uiControl *c) uiWindowsControlDefaultEnabled(uiWindow) uiWindowsControlDefaultEnable(uiWindow) uiWindowsControlDefaultDisable(uiWindow) +uiWindowsControlDefaultSetFocus(uiWindow) // TODO we need to do something about undocumented fields in the OS control types uiWindowsControlDefaultSyncEnableState(uiWindow) // TODO |