Skip to content

Commit 2d23259

Browse files
author
Fraser J. Gordon
committed
Implement a number of theme-related changes required by Linux/GTK theming implementation
1 parent d5c4edc commit 2d23259

File tree

6 files changed

+80
-23
lines changed

6 files changed

+80
-23
lines changed

engine/src/block.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,14 +2366,14 @@ void MCBlock::setcolorfornormaltext(MCDC* dc, MCColor* p_color)
23662366
else if (flags & F_HAS_COLOR)
23672367
dc->setforeground(*atts -> color);
23682368
else
2369-
f->setforeground(dc, DI_FORE, False, True);
2369+
f->setforeground(dc, DI_PSEUDO_TEXT_COLOR, False, True);
23702370
}
23712371

23722372
void MCBlock::setcolorforhilite(MCDC* dc)
23732373
{
23742374
MCField* f = parent->getparent();
23752375

2376-
f->setforeground(dc, DI_HILITE, False, True);
2376+
f->setforeground(dc, DI_PSEUDO_TEXT_BACKGROUND_SEL, False, True);
23772377
}
23782378

23792379
void MCBlock::setcolorforselectedtext(MCDC* dc, MCColor* p_color)
@@ -2385,7 +2385,7 @@ void MCBlock::setcolorforselectedtext(MCDC* dc, MCColor* p_color)
23852385
else if (flags & F_HAS_COLOR)
23862386
dc->setforeground(*atts -> color);
23872387
else if (!IsMacLF()) // TODO: if platform reverses selected text
2388-
f->setforeground(dc, DI_BACK, False, True, true);
2388+
f->setforeground(dc, DI_PSEUDO_TEXT_COLOR_SEL_BACK, False, True, true);
23892389
else
2390-
f->setforeground(dc, DI_FORE, False, True, true);
2390+
f->setforeground(dc, DI_PSEUDO_TEXT_COLOR_SEL_FORE, False, True, true);
23912391
}

engine/src/button.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4765,6 +4765,10 @@ MCPlatformControlType MCButton::getcontroltype()
47654765
break;
47664766
}
47674767
}
4768+
else if (menucontrol != MENUCONTROL_NONE)
4769+
{
4770+
t_type = kMCPlatformControlTypeMenuItem;
4771+
}
47684772

47694773
return t_type;
47704774
}

engine/src/buttondraw.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,17 @@ void MCButton::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool
138138
MCcurtheme -> drawmenuheaderbackground(dc, dirty, this))
139139
{
140140
t_themed_menu = true;
141-
dc -> setforeground(getflag(F_DISABLED) ? dc -> getgray() : dc -> getblack());
141+
//dc -> setforeground(getflag(F_DISABLED) ? dc -> getgray() : dc -> getblack());
142+
setforeground(dc, DI_PSEUDO_BUTTON_TEXT, False);
142143
}
143144
else if (menucontrol != MENUCONTROL_NONE && MCcurtheme != NULL &&
144145
MCcurtheme -> drawmenuitembackground(dc, dirty, this))
145146
{
146147
t_themed_menu = true;
147148
indicator = False;
148-
dc -> setforeground(getflag(F_DISABLED) ? dc -> getgray() : dc -> getblack());
149-
}
149+
//dc -> setforeground(getflag(F_DISABLED) ? dc -> getgray() : dc -> getblack());
150+
setforeground(dc, DI_PSEUDO_BUTTON_TEXT, False);
151+
}
150152
else
151153
{
152154
if (flags & F_OPAQUE && (MCcurtheme == NULL || !noback
@@ -342,6 +344,7 @@ void MCButton::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool
342344
}
343345

344346
if (flags & F_DISABLED)
347+
{
345348
if (MClook == LF_MOTIF)
346349
{
347350
setforeground(dc, DI_FORE, False);
@@ -354,15 +357,18 @@ void MCButton::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool
354357
}
355358
else
356359
setforeground(dc, DI_TOP, False);
360+
}
357361
else
358-
if (white && state & CS_KFOCUSED && !(state & CS_SUBMENU) ||
359-
isstdbtn && noback && (MCcurtheme == NULL || MCcurtheme->getthemeid() != LF_NATIVEWIN && MCcurtheme->getthemeid() != LF_NATIVEGTK) && state & CS_HILITED && !MCaqua ||
360-
MClook != LF_MOTIF && style == F_MENU && flags & F_OPAQUE && state & CS_ARMED && !(flags & F_SHOW_BORDER))
361-
setforeground(dc, DI_BACK, False, True);
362+
{
363+
if ((white && state & CS_KFOCUSED && !(state & CS_SUBMENU)) ||
364+
(isstdbtn && noback && (MCcurtheme == NULL || (MCcurtheme->getthemeid() != LF_NATIVEWIN && MCcurtheme->getthemeid() != LF_NATIVEGTK)) && state & CS_HILITED && !MCaqua) ||
365+
(MClook != LF_MOTIF && style == F_MENU && flags & F_OPAQUE && state & CS_ARMED && !(flags & F_SHOW_BORDER)))
366+
setforeground(dc, DI_PSEUDO_BUTTON_TEXT_SEL, False, True);
362367
else
363368
setforeground(dc, DI_FORE, (state & CS_HILITED && flags & F_HILITE_FILL
364-
|| state & CS_ARMED && flags & F_ARM_FILL) && flags & F_OPAQUE && (MClook != LF_WIN95 && !MCaqua
369+
|| state & CS_ARMED && flags & F_ARM_FILL) && flags & F_OPAQUE && ((MClook != LF_WIN95 && !MCaqua)
365370
|| style != F_STANDARD), False);
371+
}
366372
}
367373

368374
// MW-2009-06-14: We will assume (perhaps unwisely) that is 'opaque' is set

engine/src/objdefs.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,16 @@ enum Draw_index {
602602
DI_TOP,
603603
DI_BOTTOM,
604604
DI_SHADOW,
605-
DI_FOCUS
605+
DI_FOCUS,
606+
607+
// Pseudo-DIs used for theming
608+
DI_PSEUDO_TEXT_COLOR, // Text colour for non-selected text
609+
DI_PSEUDO_TEXT_BACKGROUND, // Text background colour
610+
DI_PSEUDO_TEXT_COLOR_SEL_FORE, // Text colour for selected text, use DI_FORE
611+
DI_PSEUDO_TEXT_COLOR_SEL_BACK, // Text colour for selected text, use DI_BACK
612+
DI_PSEUDO_TEXT_BACKGROUND_SEL, // Text selection colour
613+
DI_PSEUDO_BUTTON_TEXT, // Text colour for button text
614+
DI_PSEUDO_BUTTON_TEXT_SEL // Text colour for selected menu items
606615
};
607616

608617

engine/src/object.cpp

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,11 +1219,35 @@ Boolean MCObject::resizeparent()
12191219
return False;
12201220
}
12211221

1222-
Boolean MCObject::getforecolor(uint2 di, Boolean rev, Boolean hilite,
1222+
Boolean MCObject::getforecolor(uint2 p_di, Boolean rev, Boolean hilite,
12231223
MCColor &c, MCPatternRef &r_pattern,
12241224
int2 &x, int2 &y, MCDC *dc, MCObject *o, bool selected)
12251225
{
1226-
uint2 i;
1226+
uint2 di;
1227+
switch (p_di)
1228+
{
1229+
case DI_PSEUDO_TEXT_COLOR:
1230+
case DI_PSEUDO_TEXT_COLOR_SEL_FORE:
1231+
case DI_PSEUDO_BUTTON_TEXT:
1232+
di = DI_FORE;
1233+
break;
1234+
1235+
case DI_PSEUDO_TEXT_BACKGROUND:
1236+
case DI_PSEUDO_TEXT_COLOR_SEL_BACK:
1237+
case DI_PSEUDO_BUTTON_TEXT_SEL:
1238+
di = DI_BACK;
1239+
break;
1240+
1241+
case DI_PSEUDO_TEXT_BACKGROUND_SEL:
1242+
di = DI_HILITE;
1243+
break;
1244+
1245+
default:
1246+
di = p_di;
1247+
break;
1248+
}
1249+
1250+
uint2 i;
12271251
if (dc->getdepth() > 1)
12281252
{
12291253
Boolean hasindex = getcindex(di, i);
@@ -1257,14 +1281,14 @@ Boolean MCObject::getforecolor(uint2 di, Boolean rev, Boolean hilite,
12571281
if (MClook != LF_MOTIF && hilite && flags & F_OPAQUE
12581282
&& !(flags & F_DISABLED))
12591283
{
1260-
if (di == DI_BACK)
1261-
c = dc->getwhite();
1262-
else
1263-
parent->getforecolor(di, rev, hilite, c, r_pattern, x, y, dc, o, selected);
1284+
//if (di == DI_BACK)
1285+
// c = dc->getwhite();
1286+
//else
1287+
parent->getforecolor(p_di, rev, hilite, c, r_pattern, x, y, dc, o, selected);
12641288
return True;
12651289
}
12661290
if (parent && parent != MCdispatcher)
1267-
return parent->getforecolor(di, rev, hilite, c, r_pattern, x, y, dc, o, selected);
1291+
return parent->getforecolor(p_di, rev, hilite, c, r_pattern, x, y, dc, o, selected);
12681292
}
12691293
}
12701294

@@ -1275,7 +1299,7 @@ Boolean MCObject::getforecolor(uint2 di, Boolean rev, Boolean hilite,
12751299
MCPlatformThemeProperty t_theme_prop;
12761300
MCPlatformThemePropertyType t_theme_prop_type;
12771301
Properties which;
1278-
switch (di)
1302+
switch (p_di)
12791303
{
12801304
case DI_TOP:
12811305
which = P_TOP_COLOR;
@@ -1285,15 +1309,25 @@ Boolean MCObject::getforecolor(uint2 di, Boolean rev, Boolean hilite,
12851309
which = P_BOTTOM_COLOR;
12861310
break;
12871311

1312+
case DI_PSEUDO_TEXT_COLOR_SEL_FORE:
1313+
case DI_PSEUDO_TEXT_COLOR_SEL_BACK:
1314+
case DI_PSEUDO_BUTTON_TEXT_SEL:
1315+
selected = true;
1316+
/* FALLTHROUGH */
1317+
12881318
case DI_FORE:
1319+
case DI_PSEUDO_TEXT_COLOR:
1320+
case DI_PSEUDO_BUTTON_TEXT:
12891321
which = P_FORE_COLOR;
12901322
break;
12911323

12921324
case DI_BACK:
1325+
case DI_PSEUDO_TEXT_BACKGROUND:
12931326
which = P_BACK_COLOR;
12941327
break;
12951328

12961329
case DI_HILITE:
1330+
case DI_PSEUDO_TEXT_BACKGROUND_SEL:
12971331
which = P_HILITE_COLOR;
12981332
break;
12991333

@@ -1378,6 +1412,7 @@ void MCObject::setforeground(MCDC *dc, uint2 di, Boolean rev, Boolean hilite, bo
13781412
idi = DI_TOP;
13791413
break;
13801414
case DI_BACK:
1415+
case DI_PSEUDO_BUTTON_TEXT_SEL:
13811416
idi = DI_HILITE;
13821417
break;
13831418
default:
@@ -4323,7 +4358,7 @@ bool MCObject::mapfont(bool recursive)
43234358
// Images don't use the fontref, so don't do anything if we are an image.
43244359

43254360
if (gettype() == CT_IMAGE)
4326-
return;
4361+
return false;
43274362

43284363
// This is only set if an explicitly-set font was found at some point
43294364
bool t_explicit_font;
@@ -4399,6 +4434,8 @@ bool MCObject::mapfont(bool recursive)
43994434
// first place.
44004435
if (t_mapped_parent)
44014436
parent -> unmapfont();
4437+
4438+
return t_explicit_font;
44024439
}
44034440

44044441
// MW-2012-02-14: [[ FontRefs ]] New method which unmaps the object's concrete font

engine/src/platform.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ void MCPlatformSwitchFocusToView(MCPlatformWindowRef window, uint32_t id);
12121212

12131213
enum MCPlatformControlType
12141214
{
1215-
kMCPlatformControlTypeGlobal, // Global theming (i.e the theme inherited by all controls)
1215+
kMCPlatformControlTypeGlobal = 0, // Global theming (i.e the theme inherited by all controls)
12161216
kMCPlatformControlTypeButton, // Buttons not covered more specifically
12171217
kMCPlatformControlTypeCheckbox, // On-off tick box
12181218
kMCPlatformControlTypeRadioButton, // One-of-many selection button
@@ -1222,6 +1222,7 @@ enum MCPlatformControlType
12221222
kMCPlatformControlTypeInputField, // Standard text entry box
12231223
kMCPlatformControlTypeList, // Itemised text box
12241224
kMCPlatformControlTypeMenu, // Menus not covered more specifically
1225+
kMCPlatformControlTypeMenuItem, // Item within a menu
12251226
kMCPlatformControlTypeOptionMenu, // Select a single item
12261227
kMCPlatformControlTypePulldownMenu, // Menu as found in menubars
12271228
kMCPlatformControlTypeComboBox, // Input field/option menu combination

0 commit comments

Comments
 (0)