MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / PiuFieldProc

Function PiuFieldProc

modules/piu/PC/win/piuField.cpp:60–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59
60LRESULT CALLBACK PiuFieldProc(HWND control, UINT message, WPARAM wParam, LPARAM lParam, UINT_PTR id, DWORD_PTR data)
61{
62 if ((message == WM_NCCALCSIZE) && wParam) {
63 NCCALCSIZE_PARAMS* params = (NCCALCSIZE_PARAMS*)lParam;
64 RECT* rect = params->rgrc;
65 PiuField* self = (PiuField*)data;
66 PiuStyle* style = (*self)->computedStyle;
67 int delta;
68 rect->left += (*style)->margins.left;
69 rect->right -= (*style)->margins.right;
70 rect->top += (*style)->margins.top;
71 rect->bottom -= (*style)->margins.bottom;
72 switch ((*style)->vertical) {
73 case piuTop:
74 break;
75 case piuBottom:
76 delta = rect->bottom - rect->top - PiuFontGetHeight((*style)->font);
77 rect->top += delta;
78 break;
79 default:
80 delta = (rect->bottom - rect->top - PiuFontGetHeight((*style)->font)) / 2;
81 rect->top += delta;
82 rect->bottom -= delta;
83 break;
84 }
85 }
86 else if (message == WM_SETFOCUS) {
87 PiuField* self = (PiuField*)data;
88 if ((*self)->application)
89 PiuApplicationSetFocus((*self)->application, self);
90 }
91 else if (message == WM_CHAR) {
92 if (wParam == VK_RETURN)
93 return 0;
94 }
95 else if (message == WM_KEYDOWN) {
96 if (wParam == VK_RETURN) {
97 PiuField* self = (PiuField*)data;
98 if ((*self)->behavior) {
99 xsBeginHost((*self)->the);
100 xsVars(2);
101 xsVar(0) = xsReference((*self)->behavior);
102 if (xsFindResult(xsVar(0), xsID_onEnter)) {
103 xsVar(1) = xsReference((*self)->reference);
104 (void)xsCallFunction1(xsResult, xsVar(0), xsVar(1));
105 }
106 xsEndHost((*self)->the);
107 }
108 return 0;
109 }
110 }
111 return DefSubclassProc(control, message, wParam, lParam);
112}
113
114void PiuFieldBind(void* it, PiuApplication* application, PiuView* view)
115{

Callers

nothing calls this directly

Calls 2

PiuApplicationSetFocusFunction · 0.85
PiuFontGetHeightFunction · 0.70

Tested by

no test coverage detected