Merge e19f78f56f
into fea45b2d5b
This commit is contained in:
commit
aeb2e53174
1
ui.h
1
ui.h
|
@ -164,6 +164,7 @@ _UI_EXTERN void uiEntrySetText(uiEntry *e, const char *text);
|
||||||
_UI_EXTERN void uiEntryOnChanged(uiEntry *e, void (*f)(uiEntry *e, void *data), void *data);
|
_UI_EXTERN void uiEntryOnChanged(uiEntry *e, void (*f)(uiEntry *e, void *data), void *data);
|
||||||
_UI_EXTERN int uiEntryReadOnly(uiEntry *e);
|
_UI_EXTERN int uiEntryReadOnly(uiEntry *e);
|
||||||
_UI_EXTERN void uiEntrySetReadOnly(uiEntry *e, int readonly);
|
_UI_EXTERN void uiEntrySetReadOnly(uiEntry *e, int readonly);
|
||||||
|
_UI_EXTERN void uiEntrySetWidthChars(uiEntry *e, int nchars);
|
||||||
_UI_EXTERN uiEntry *uiNewEntry(void);
|
_UI_EXTERN uiEntry *uiNewEntry(void);
|
||||||
_UI_EXTERN uiEntry *uiNewPasswordEntry(void);
|
_UI_EXTERN uiEntry *uiNewPasswordEntry(void);
|
||||||
_UI_EXTERN uiEntry *uiNewSearchEntry(void);
|
_UI_EXTERN uiEntry *uiNewSearchEntry(void);
|
||||||
|
|
|
@ -242,6 +242,7 @@ struct uiWindowsSizing {
|
||||||
};
|
};
|
||||||
_UI_EXTERN void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing);
|
_UI_EXTERN void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing);
|
||||||
_UI_EXTERN void uiWindowsSizingDlgUnitsToPixels(uiWindowsSizing *sizing, int *x, int *y);
|
_UI_EXTERN void uiWindowsSizingDlgUnitsToPixels(uiWindowsSizing *sizing, int *x, int *y);
|
||||||
|
_UI_EXTERN void uiWindowsSizingCharsToPixels(uiWindowsSizing *sizing, int *x, int width_chars);
|
||||||
_UI_EXTERN void uiWindowsSizingStandardPadding(uiWindowsSizing *sizing, int *x, int *y);
|
_UI_EXTERN void uiWindowsSizingStandardPadding(uiWindowsSizing *sizing, int *x, int *y);
|
||||||
|
|
||||||
// TODO document
|
// TODO document
|
||||||
|
|
|
@ -95,3 +95,8 @@ uiEntry *uiNewSearchEntry(void)
|
||||||
{
|
{
|
||||||
return finishNewEntry(gtk_search_entry_new(), "search-changed");
|
return finishNewEntry(gtk_search_entry_new(), "search-changed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiEntrySetWidthChars(uiEntry *e, int nchars)
|
||||||
|
{
|
||||||
|
gtk_entry_set_width_chars(e->entry, nchars);
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ struct uiEntry {
|
||||||
void (*onChanged)(uiEntry *, void *);
|
void (*onChanged)(uiEntry *, void *);
|
||||||
void *onChangedData;
|
void *onChangedData;
|
||||||
BOOL inhibitChanged;
|
BOOL inhibitChanged;
|
||||||
|
int width_chars;
|
||||||
};
|
};
|
||||||
|
|
||||||
static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
|
static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
|
||||||
|
@ -47,6 +48,9 @@ static void uiEntryMinimumSize(uiWindowsControl *c, int *width, int *height)
|
||||||
y = entryHeight;
|
y = entryHeight;
|
||||||
uiWindowsGetSizing(e->hwnd, &sizing);
|
uiWindowsGetSizing(e->hwnd, &sizing);
|
||||||
uiWindowsSizingDlgUnitsToPixels(&sizing, &x, &y);
|
uiWindowsSizingDlgUnitsToPixels(&sizing, &x, &y);
|
||||||
|
if (e->width_chars > 0) {
|
||||||
|
uiWindowsSizingCharsToPixels(&sizing, &x, e->width_chars);
|
||||||
|
}
|
||||||
*width = x;
|
*width = x;
|
||||||
*height = y;
|
*height = y;
|
||||||
}
|
}
|
||||||
|
@ -107,6 +111,8 @@ static uiEntry *finishNewEntry(DWORD style)
|
||||||
uiWindowsRegisterWM_COMMANDHandler(e->hwnd, onWM_COMMAND, uiControl(e));
|
uiWindowsRegisterWM_COMMANDHandler(e->hwnd, onWM_COMMAND, uiControl(e));
|
||||||
uiEntryOnChanged(e, defaultOnChanged, NULL);
|
uiEntryOnChanged(e, defaultOnChanged, NULL);
|
||||||
|
|
||||||
|
e->width_chars = 0;
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,3 +138,8 @@ uiEntry *uiNewSearchEntry(void)
|
||||||
// TODO will hr be S_OK if themes are disabled?
|
// TODO will hr be S_OK if themes are disabled?
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiEntrySetWidthChars(uiEntry *e, int nchars)
|
||||||
|
{
|
||||||
|
e->width_chars = nchars;
|
||||||
|
}
|
||||||
|
|
|
@ -48,6 +48,12 @@ void uiWindowsSizingDlgUnitsToPixels(uiWindowsSizing *sizing, int *x, int *y)
|
||||||
*y = dlgUnitsToY(*y, sizing->BaseY);
|
*y = dlgUnitsToY(*y, sizing->BaseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiWindowsSizingCharsToPixels(uiWindowsSizing *sizing, int *x, int width_chars)
|
||||||
|
{
|
||||||
|
if (x != NULL)
|
||||||
|
*x = sizing->BaseX * width_chars;
|
||||||
|
}
|
||||||
|
|
||||||
// from https://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing and https://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx
|
// from https://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing and https://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx
|
||||||
// this X value is really only for buttons but I don't see a better one :/
|
// this X value is really only for buttons but I don't see a better one :/
|
||||||
#define winXPadding 4
|
#define winXPadding 4
|
||||||
|
|
Loading…
Reference in New Issue