mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-03 20:34:14 +01:00
Use fixed font size in original WMCreate*Panel functions
Instead of just assuming that the size of the system font has not
been changed by the user, the WMCreateAlertPanel,
WMCreateInputPanel and WMCreateGenericPanel functions now use a
fixed default font size of 12, so that changing the system font's
size in WPrefs.app does not break the fixed layouts of these panels.
("12" is specified as DEFAULT_FONT_SIZE in WINGS/configuration.c)
This commit is contained in:
committed by
Carlos R. Mafra
parent
c803218ed1
commit
ba3df2599d
@@ -89,10 +89,12 @@ WMAlertPanel *WMCreateAlertPanel(WMScreen * scrPtr, WMWindow * owner,
|
|||||||
const char *alternateButton, const char *otherButton)
|
const char *alternateButton, const char *otherButton)
|
||||||
{
|
{
|
||||||
WMAlertPanel *panel;
|
WMAlertPanel *panel;
|
||||||
|
WMFont *defaultFont;
|
||||||
int dw = 0, aw = 0, ow = 0, w;
|
int dw = 0, aw = 0, ow = 0, w;
|
||||||
WMBox *hbox;
|
WMBox *hbox;
|
||||||
WMPixmap *icon;
|
WMPixmap *icon;
|
||||||
|
|
||||||
|
defaultFont = WMSystemFontOfSize(scrPtr, 12);
|
||||||
panel = wmalloc(sizeof(WMAlertPanel));
|
panel = wmalloc(sizeof(WMAlertPanel));
|
||||||
|
|
||||||
if (owner) {
|
if (owner) {
|
||||||
@@ -160,6 +162,7 @@ WMAlertPanel *WMCreateAlertPanel(WMScreen * scrPtr, WMWindow * owner,
|
|||||||
WMFontHeight(scrPtr->normalFont) * 4, 0, 5);
|
WMFontHeight(scrPtr->normalFont) * 4, 0, 5);
|
||||||
WMSetLabelText(panel->mLbl, msg);
|
WMSetLabelText(panel->mLbl, msg);
|
||||||
WMSetLabelTextAlignment(panel->mLbl, WACenter);
|
WMSetLabelTextAlignment(panel->mLbl, WACenter);
|
||||||
|
WMSetLabelFont(panel->mLbl, defaultFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
panel->hbox = WMCreateBox(panel->vbox);
|
panel->hbox = WMCreateBox(panel->vbox);
|
||||||
@@ -170,13 +173,13 @@ WMAlertPanel *WMCreateAlertPanel(WMScreen * scrPtr, WMWindow * owner,
|
|||||||
|
|
||||||
/* create buttons */
|
/* create buttons */
|
||||||
if (otherButton)
|
if (otherButton)
|
||||||
ow = WMWidthOfString(scrPtr->normalFont, otherButton, strlen(otherButton));
|
ow = WMWidthOfString(defaultFont, otherButton, strlen(otherButton));
|
||||||
|
|
||||||
if (alternateButton)
|
if (alternateButton)
|
||||||
aw = WMWidthOfString(scrPtr->normalFont, alternateButton, strlen(alternateButton));
|
aw = WMWidthOfString(defaultFont, alternateButton, strlen(alternateButton));
|
||||||
|
|
||||||
if (defaultButton)
|
if (defaultButton)
|
||||||
dw = WMWidthOfString(scrPtr->normalFont, defaultButton, strlen(defaultButton));
|
dw = WMWidthOfString(defaultFont, defaultButton, strlen(defaultButton));
|
||||||
|
|
||||||
dw = dw + (scrPtr->buttonArrow ? scrPtr->buttonArrow->width : 0);
|
dw = dw + (scrPtr->buttonArrow ? scrPtr->buttonArrow->width : 0);
|
||||||
|
|
||||||
@@ -206,18 +209,21 @@ WMAlertPanel *WMCreateAlertPanel(WMScreen * scrPtr, WMWindow * owner,
|
|||||||
WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow);
|
WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow);
|
||||||
WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow);
|
WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow);
|
||||||
WMSetButtonImagePosition(panel->defBtn, WIPRight);
|
WMSetButtonImagePosition(panel->defBtn, WIPRight);
|
||||||
|
WMSetButtonFont(panel->defBtn, defaultFont);
|
||||||
}
|
}
|
||||||
if (alternateButton) {
|
if (alternateButton) {
|
||||||
panel->altBtn = WMCreateCommandButton(panel->hbox);
|
panel->altBtn = WMCreateCommandButton(panel->hbox);
|
||||||
WMAddBoxSubviewAtEnd(panel->hbox, WMWidgetView(panel->altBtn), False, True, aw, 0, 5);
|
WMAddBoxSubviewAtEnd(panel->hbox, WMWidgetView(panel->altBtn), False, True, aw, 0, 5);
|
||||||
WMSetButtonAction(panel->altBtn, alertPanelOnClick, panel);
|
WMSetButtonAction(panel->altBtn, alertPanelOnClick, panel);
|
||||||
WMSetButtonText(panel->altBtn, alternateButton);
|
WMSetButtonText(panel->altBtn, alternateButton);
|
||||||
|
WMSetButtonFont(panel->altBtn, defaultFont);
|
||||||
}
|
}
|
||||||
if (otherButton) {
|
if (otherButton) {
|
||||||
panel->othBtn = WMCreateCommandButton(panel->hbox);
|
panel->othBtn = WMCreateCommandButton(panel->hbox);
|
||||||
WMSetButtonAction(panel->othBtn, alertPanelOnClick, panel);
|
WMSetButtonAction(panel->othBtn, alertPanelOnClick, panel);
|
||||||
WMAddBoxSubviewAtEnd(panel->hbox, WMWidgetView(panel->othBtn), False, True, ow, 0, 5);
|
WMAddBoxSubviewAtEnd(panel->hbox, WMWidgetView(panel->othBtn), False, True, ow, 0, 5);
|
||||||
WMSetButtonText(panel->othBtn, otherButton);
|
WMSetButtonText(panel->othBtn, otherButton);
|
||||||
|
WMSetButtonFont(panel->othBtn, defaultFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
WMMapSubwidgets(panel->hbox);
|
WMMapSubwidgets(panel->hbox);
|
||||||
@@ -227,6 +233,8 @@ WMAlertPanel *WMCreateAlertPanel(WMScreen * scrPtr, WMWindow * owner,
|
|||||||
WMRealizeWidget(panel->win);
|
WMRealizeWidget(panel->win);
|
||||||
WMMapSubwidgets(panel->win);
|
WMMapSubwidgets(panel->win);
|
||||||
|
|
||||||
|
WMReleaseFont(defaultFont);
|
||||||
|
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,8 +510,10 @@ WMInputPanel *WMCreateInputPanel(WMScreen * scrPtr, WMWindow * owner, const char
|
|||||||
const char *defaultText, const char *okButton, const char *cancelButton)
|
const char *defaultText, const char *okButton, const char *cancelButton)
|
||||||
{
|
{
|
||||||
WMInputPanel *panel;
|
WMInputPanel *panel;
|
||||||
|
WMFont *defaultFont;
|
||||||
int x, dw = 0, aw = 0, w;
|
int x, dw = 0, aw = 0, w;
|
||||||
|
|
||||||
|
defaultFont = WMSystemFontOfSize(scrPtr, 12);
|
||||||
panel = wmalloc(sizeof(WMInputPanel));
|
panel = wmalloc(sizeof(WMInputPanel));
|
||||||
|
|
||||||
if (owner)
|
if (owner)
|
||||||
@@ -535,21 +545,23 @@ WMInputPanel *WMCreateInputPanel(WMScreen * scrPtr, WMWindow * owner, const char
|
|||||||
WMResizeWidget(panel->mLbl, 320 - 40, WMFontHeight(scrPtr->normalFont) * 2);
|
WMResizeWidget(panel->mLbl, 320 - 40, WMFontHeight(scrPtr->normalFont) * 2);
|
||||||
WMSetLabelText(panel->mLbl, msg);
|
WMSetLabelText(panel->mLbl, msg);
|
||||||
WMSetLabelTextAlignment(panel->mLbl, WALeft);
|
WMSetLabelTextAlignment(panel->mLbl, WALeft);
|
||||||
|
WMSetLabelFont(panel->mLbl, defaultFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
panel->text = WMCreateTextField(panel->win);
|
panel->text = WMCreateTextField(panel->win);
|
||||||
WMMoveWidget(panel->text, 20, 85);
|
WMMoveWidget(panel->text, 20, 85);
|
||||||
WMResizeWidget(panel->text, 320 - 40, WMWidgetHeight(panel->text));
|
WMResizeWidget(panel->text, 320 - 40, WMWidgetHeight(panel->text));
|
||||||
WMSetTextFieldText(panel->text, defaultText);
|
WMSetTextFieldText(panel->text, defaultText);
|
||||||
|
WMSetTextFieldFont(panel->text, defaultFont);
|
||||||
|
|
||||||
WMAddNotificationObserver(endedEditingObserver, panel, WMTextDidEndEditingNotification, panel->text);
|
WMAddNotificationObserver(endedEditingObserver, panel, WMTextDidEndEditingNotification, panel->text);
|
||||||
|
|
||||||
/* create buttons */
|
/* create buttons */
|
||||||
if (cancelButton)
|
if (cancelButton)
|
||||||
aw = WMWidthOfString(scrPtr->normalFont, cancelButton, strlen(cancelButton));
|
aw = WMWidthOfString(defaultFont, cancelButton, strlen(cancelButton));
|
||||||
|
|
||||||
if (okButton)
|
if (okButton)
|
||||||
dw = WMWidthOfString(scrPtr->normalFont, okButton, strlen(okButton));
|
dw = WMWidthOfString(defaultFont, okButton, strlen(okButton));
|
||||||
|
|
||||||
w = dw + (scrPtr->buttonArrow ? scrPtr->buttonArrow->width : 0);
|
w = dw + (scrPtr->buttonArrow ? scrPtr->buttonArrow->width : 0);
|
||||||
if (aw > w)
|
if (aw > w)
|
||||||
@@ -570,6 +582,7 @@ WMInputPanel *WMCreateInputPanel(WMScreen * scrPtr, WMWindow * owner, const char
|
|||||||
WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow);
|
WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow);
|
||||||
WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow);
|
WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow);
|
||||||
WMSetButtonImagePosition(panel->defBtn, WIPRight);
|
WMSetButtonImagePosition(panel->defBtn, WIPRight);
|
||||||
|
WMSetButtonFont(panel->defBtn, defaultFont);
|
||||||
}
|
}
|
||||||
if (cancelButton) {
|
if (cancelButton) {
|
||||||
x -= w + 10;
|
x -= w + 10;
|
||||||
@@ -579,6 +592,7 @@ WMInputPanel *WMCreateInputPanel(WMScreen * scrPtr, WMWindow * owner, const char
|
|||||||
WMMoveWidget(panel->altBtn, x, 124);
|
WMMoveWidget(panel->altBtn, x, 124);
|
||||||
WMResizeWidget(panel->altBtn, w, 24);
|
WMResizeWidget(panel->altBtn, w, 24);
|
||||||
WMSetButtonText(panel->altBtn, cancelButton);
|
WMSetButtonText(panel->altBtn, cancelButton);
|
||||||
|
WMSetButtonFont(panel->altBtn, defaultFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
WMCreateEventHandler(W_VIEW(panel->win), KeyPressMask, handleKeyPress2, panel);
|
WMCreateEventHandler(W_VIEW(panel->win), KeyPressMask, handleKeyPress2, panel);
|
||||||
@@ -588,6 +602,8 @@ WMInputPanel *WMCreateInputPanel(WMScreen * scrPtr, WMWindow * owner, const char
|
|||||||
|
|
||||||
WMSetFocusToWidget(panel->text);
|
WMSetFocusToWidget(panel->text);
|
||||||
|
|
||||||
|
WMReleaseFont(defaultFont);
|
||||||
|
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -716,10 +732,12 @@ WMGenericPanel *WMCreateGenericPanel(WMScreen * scrPtr, WMWindow * owner,
|
|||||||
const char *title, const char *defaultButton, const char *alternateButton)
|
const char *title, const char *defaultButton, const char *alternateButton)
|
||||||
{
|
{
|
||||||
WMGenericPanel *panel;
|
WMGenericPanel *panel;
|
||||||
|
WMFont *defaultFont;
|
||||||
int dw = 0, aw = 0, w;
|
int dw = 0, aw = 0, w;
|
||||||
WMBox *hbox;
|
WMBox *hbox;
|
||||||
WMPixmap *icon;
|
WMPixmap *icon;
|
||||||
|
|
||||||
|
defaultFont = WMSystemFontOfSize(scrPtr, 12);
|
||||||
panel = wmalloc(sizeof(WMGenericPanel));
|
panel = wmalloc(sizeof(WMGenericPanel));
|
||||||
|
|
||||||
if (owner) {
|
if (owner) {
|
||||||
@@ -792,10 +810,10 @@ WMGenericPanel *WMCreateGenericPanel(WMScreen * scrPtr, WMWindow * owner,
|
|||||||
|
|
||||||
/* create buttons */
|
/* create buttons */
|
||||||
if (defaultButton)
|
if (defaultButton)
|
||||||
dw = WMWidthOfString(scrPtr->normalFont, defaultButton, strlen(defaultButton));
|
dw = WMWidthOfString(defaultFont, defaultButton, strlen(defaultButton));
|
||||||
|
|
||||||
if (alternateButton)
|
if (alternateButton)
|
||||||
aw = WMWidthOfString(scrPtr->normalFont, alternateButton, strlen(alternateButton));
|
aw = WMWidthOfString(defaultFont, alternateButton, strlen(alternateButton));
|
||||||
|
|
||||||
dw = dw + (scrPtr->buttonArrow ? scrPtr->buttonArrow->width : 0);
|
dw = dw + (scrPtr->buttonArrow ? scrPtr->buttonArrow->width : 0);
|
||||||
|
|
||||||
@@ -820,6 +838,7 @@ WMGenericPanel *WMCreateGenericPanel(WMScreen * scrPtr, WMWindow * owner,
|
|||||||
WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow);
|
WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow);
|
||||||
WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow);
|
WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow);
|
||||||
WMSetButtonImagePosition(panel->defBtn, WIPRight);
|
WMSetButtonImagePosition(panel->defBtn, WIPRight);
|
||||||
|
WMSetButtonFont(panel->defBtn, defaultFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
WMMapSubwidgets(hbox);
|
WMMapSubwidgets(hbox);
|
||||||
@@ -829,5 +848,7 @@ WMGenericPanel *WMCreateGenericPanel(WMScreen * scrPtr, WMWindow * owner,
|
|||||||
WMRealizeWidget(panel->win);
|
WMRealizeWidget(panel->win);
|
||||||
WMMapSubwidgets(panel->win);
|
WMMapSubwidgets(panel->win);
|
||||||
|
|
||||||
|
WMReleaseFont(defaultFont);
|
||||||
|
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user