Skip to content

Commit ee1475b

Browse files
author
runrevali
committed
Merge branch 'modular' of https://github.com/runrev/livecode-widgets into modular
Conflicts: libscript/src/module-byte.cpp libscript/src/module-char.cpp toolchain/lc-compile/lc-compile.xcodeproj/project.pbxproj
2 parents 58aca07 + e7d393a commit ee1475b

File tree

162 files changed

+9872
-1310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+9872
-1310
lines changed

engine/Makefile.kernel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ SOURCES=\
7979
foundation-legacy.cpp legacy_spec.cpp \
8080
sysunxthreads.cpp, stacktile.cpp \
8181
native-layer.cpp native-layer-x11.cpp \
82-
widget.cpp widget-events.cpp
82+
widget.cpp widget-events.cpp \
83+
linux-theme.cpp
8384

8485
linuxstubs.cpp: src/linux.stubs ../util/weak_stub_maker.pl
8586
# ../prebuilt/bin/Revolution.lnx "../tools/weak_stub_maker.lc" <./src/linux.stubs >./src/linuxstubs.cpp

engine/engine.vcproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@
213213
ReferencedProjectIdentifier="{25CCFCBE-CCB2-44FC-A4FB-F46990F4383A}"
214214
RelativePathToProject=".\thirdparty\libffi\libffi.vcproj"
215215
/>
216+
<ProjectReference
217+
ReferencedProjectIdentifier="{56CD2637-6005-4DD6-9ADF-F85C7774BB88}"
218+
RelativePathToProject=".\libscript\stdscript.vcproj"
219+
/>
216220
</References>
217221
<Files>
218222
<Filter

engine/engine.xcodeproj/project.pbxproj

Lines changed: 190 additions & 19 deletions
Large diffs are not rendered by default.

engine/kernel.vcproj

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3555,6 +3555,10 @@
35553555
RelativePath="src\w32transfer.h"
35563556
>
35573557
</File>
3558+
<File
3559+
RelativePath=".\src\windows-theme.cpp"
3560+
>
3561+
</File>
35583562
</Filter>
35593563
</Filter>
35603564
<Filter
@@ -7991,6 +7995,114 @@
79917995
>
79927996
</File>
79937997
</Filter>
7998+
<Filter
7999+
Name="Core - Text"
8000+
>
8001+
<File
8002+
RelativePath=".\src\text-api.cpp"
8003+
>
8004+
</File>
8005+
<File
8006+
RelativePath=".\src\text-api.h"
8007+
>
8008+
</File>
8009+
<File
8010+
RelativePath=".\src\text-block.cpp"
8011+
>
8012+
</File>
8013+
<File
8014+
RelativePath=".\src\text-block.h"
8015+
>
8016+
</File>
8017+
<File
8018+
RelativePath=".\src\text-breakblock.cpp"
8019+
>
8020+
</File>
8021+
<File
8022+
RelativePath=".\src\text-breakblock.h"
8023+
>
8024+
</File>
8025+
<File
8026+
RelativePath=".\src\text-breakingengine.cpp"
8027+
>
8028+
</File>
8029+
<File
8030+
RelativePath=".\src\text-breakingengine.h"
8031+
>
8032+
</File>
8033+
<File
8034+
RelativePath=".\src\text-cell.cpp"
8035+
>
8036+
</File>
8037+
<File
8038+
RelativePath=".\src\text-cell.h"
8039+
>
8040+
</File>
8041+
<File
8042+
RelativePath=".\src\text-controlblock.cpp"
8043+
>
8044+
</File>
8045+
<File
8046+
RelativePath=".\src\text-controlblock.h"
8047+
>
8048+
</File>
8049+
<File
8050+
RelativePath=".\src\text-imageblock.cpp"
8051+
>
8052+
</File>
8053+
<File
8054+
RelativePath=".\src\text-imageblock.h"
8055+
>
8056+
</File>
8057+
<File
8058+
RelativePath=".\src\text-line.cpp"
8059+
>
8060+
</File>
8061+
<File
8062+
RelativePath=".\src\text-line.h"
8063+
>
8064+
</File>
8065+
<File
8066+
RelativePath=".\src\text-pane.cpp"
8067+
>
8068+
</File>
8069+
<File
8070+
RelativePath=".\src\text-pane.h"
8071+
>
8072+
</File>
8073+
<File
8074+
RelativePath=".\src\text-paragraph.cpp"
8075+
>
8076+
</File>
8077+
<File
8078+
RelativePath=".\src\text-paragraph.h"
8079+
>
8080+
</File>
8081+
<File
8082+
RelativePath=".\src\text-run.cpp"
8083+
>
8084+
</File>
8085+
<File
8086+
RelativePath=".\src\text-run.h"
8087+
>
8088+
</File>
8089+
<File
8090+
RelativePath=".\src\text-segment.cpp"
8091+
>
8092+
</File>
8093+
<File
8094+
RelativePath=".\src\text-segment.h"
8095+
>
8096+
</File>
8097+
<File
8098+
RelativePath=".\src\text-simplebreakingengine.cpp"
8099+
>
8100+
</File>
8101+
<File
8102+
RelativePath=".\src\text-simplebreakingengine.h"
8103+
>
8104+
</File>
8105+
</Filter>
79948106
<File
79958107
RelativePath=".\ChangeLog.txt"
79968108
>

engine/src/MCBlock.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ class MCBlock : public MCDLlist
171171
void reset();
172172
uint2 getascent(void);
173173
uint2 getdescent(void);
174+
coord_t GetAscent() const;
175+
coord_t GetDescent() const;
176+
coord_t GetLeading() const;
174177
void freeatts();
175178
void freerefs();
176179
void openimage();
@@ -412,5 +415,11 @@ class MCBlock : public MCDLlist
412415
void SetTextStyleElement(MCExecContext& ctxt, MCNameRef p_index, bool p_value);
413416

414417
//////////
418+
419+
// FG-2014-11-11: [[ Better theming ]]
420+
// Sets up the colours on the DC for the given type of drawing
421+
void setcolorfornormaltext(MCDC*, MCColor*);
422+
void setcolorforhilite(MCDC*);
423+
void setcolorforselectedtext(MCDC*, MCColor*);
415424
};
416425
#endif

engine/src/aclip.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,9 @@ void MCAudioClip::timer(MCNameRef mptr, MCParameter *params)
202202
delete this;
203203
}
204204
}
205-
#ifdef LEGACY_EXEC
206-
Exec_stat MCAudioClip::getprop_legacy(uint4 parid, Properties which, MCExecPoint &ep, Boolean effective)
205+
206+
#ifdef LEGACY_EXEC
207+
Exec_stat MCAudioClip::getprop_legacy(uint4 parid, Properties which, MCExecPoint &ep, Boolean effective, bool recursive)
207208
{
208209
switch (which)
209210
{
@@ -223,7 +224,7 @@ Exec_stat MCAudioClip::getprop_legacy(uint4 parid, Properties which, MCExecPoint
223224
break;
224225
#endif /* MCAudioClip::getprop */
225226
default:
226-
return MCObject::getprop_legacy(parid, which, ep, effective);
227+
return MCObject::getprop_legacy(parid, which, ep, effective, recursive);
227228
}
228229
return ES_NORMAL;
229230
}

engine/src/aclip.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,10 @@ class MCAudioClip : public MCObject
8080
virtual void timer(MCNameRef mptr, MCParameter *params);
8181

8282
#ifdef LEGACY_EXEC
83-
virtual Exec_stat getprop_legacy(uint4 parid, Properties which, MCExecPoint &, Boolean effective);
83+
virtual Exec_stat getprop_legacy(uint4 parid, Properties which, MCExecPoint &, Boolean effective, bool recursive = false);
8484
virtual Exec_stat setprop_legacy(uint4 parid, Properties which, MCExecPoint &, Boolean effective);
8585
#endif
8686

87-
8887
virtual Boolean del();
8988
virtual void paste(void);
9089

engine/src/block.cpp

Lines changed: 95 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -950,9 +950,15 @@ void MCBlock::split(findex_t p_index)
950950
void MCBlock::drawstring(MCDC *dc, coord_t x, coord_t p_cell_left, coord_t p_cell_right, int2 y, findex_t start, findex_t length, Boolean image, uint32_t style)
951951
{
952952
// MW-2012-02-16: [[ FontRefs ]] Fetch the font metrics we need to draw.
953-
int32_t t_ascent, t_descent;
953+
coord_t t_ascent, t_descent, t_leading, t_xheight;
954954
t_ascent = MCFontGetAscent(m_font);
955955
t_descent = MCFontGetDescent(m_font);
956+
t_leading = MCFontGetLeading(m_font);
957+
t_xheight = MCFontGetXHeight(m_font);
958+
959+
// Width for strike-through/underline lines. Factor is arbitrary...
960+
coord_t t_strikewidth;
961+
t_strikewidth = ceilf(MCFontGetAscent(m_font)/16);
956962

957963
// MW-2012-01-25: [[ ParaStyles ]] Fetch the vGrid setting from the owning paragraph.
958964
if (parent -> getvgrid())
@@ -1011,9 +1017,17 @@ void MCBlock::drawstring(MCDC *dc, coord_t x, coord_t p_cell_left, coord_t p_cel
10111017
if (t_next_index - t_index > 0)
10121018
{
10131019
if ((style & FA_UNDERLINE) != 0)
1014-
dc -> drawline(x, y + 1, x + t_width, y + 1);
1020+
{
1021+
MCRectangle t_underlinerect;
1022+
t_underlinerect = MCU_make_rect(x, y + t_strikewidth, t_width, t_strikewidth);
1023+
dc -> fillrect(t_underlinerect);
1024+
}
10151025
if ((style & FA_STRIKEOUT) != 0)
1016-
dc -> drawline(x, y - (t_ascent >> 1), x + t_width, y - (t_ascent >> 1));
1026+
{
1027+
MCRectangle t_strikerect;
1028+
t_strikerect = MCU_make_rect(x, y - (t_xheight / 2) - (t_strikewidth / 2), t_width, t_strikewidth);
1029+
dc -> fillrect(t_strikerect);
1030+
}
10171031
if ((style & FA_BOX) != 0)
10181032
{
10191033
// MW-2012-09-04: [[ Bug 9759 ]] Adjust any pattern origin to scroll with text.
@@ -1111,9 +1125,17 @@ void MCBlock::drawstring(MCDC *dc, coord_t x, coord_t p_cell_left, coord_t p_cel
11111125

11121126
// Apply strike/underline.
11131127
if ((style & FA_UNDERLINE) != 0)
1114-
dc -> drawline(t_line_x, y + 1, t_line_x + t_line_width, y + 1);
1128+
{
1129+
MCRectangle t_underlinerect;
1130+
t_underlinerect = MCU_make_rect(t_line_x, y + t_strikewidth, t_line_width, t_strikewidth);
1131+
dc -> fillrect(t_underlinerect);
1132+
}
11151133
if ((style & FA_STRIKEOUT) != 0)
1116-
dc -> drawline(t_line_x, y - (t_ascent >> 1), t_line_x + t_line_width, y - (t_ascent >> 1));
1134+
{
1135+
MCRectangle t_strikerect;
1136+
t_strikerect = MCU_make_rect(t_line_x, y - (t_xheight / 2) - (t_strikewidth / 2), t_line_width, t_strikewidth);
1137+
dc -> fillrect(t_strikerect);
1138+
}
11171139
}
11181140
}
11191141

@@ -1177,8 +1199,7 @@ void MCBlock::draw(MCDC *dc, coord_t x, coord_t lx, coord_t cx, int2 y, findex_t
11771199
if (flags & F_HAS_BACK_COLOR)
11781200
dc->setbackground(*atts->backcolor);
11791201

1180-
if (t_foreground_color != NULL)
1181-
dc -> setforeground(*t_foreground_color);
1202+
setcolorfornormaltext(dc, t_foreground_color);
11821203

11831204
uint32_t t_style;
11841205
t_style = 0;
@@ -1292,11 +1313,13 @@ void MCBlock::draw(MCDC *dc, coord_t x, coord_t lx, coord_t cx, int2 y, findex_t
12921313
f->getforecolor(DI_HILITE, False, True, hc, t_pattern, x, y, dc, f);
12931314
if (hc.pixel == fc.pixel)
12941315
f->setforeground(dc, DI_BACK, False, True);
1316+
else
1317+
setcolorforselectedtext(dc, nil);
12951318
}
12961319
else
1297-
f->setforeground(dc, DI_BACK, False, True);
1320+
setcolorforselectedtext(dc, t_foreground_color);
12981321
}
1299-
1322+
13001323
// Draw the selected text.
13011324
// SN-2014-08-13: [[ Bug 13016 ]] Added a parameter for the left of the cell
13021325
drawstring(dc, x, lx, cx, y, m_index, m_size, (flags & F_HAS_BACK_COLOR) != 0, t_style);
@@ -1888,7 +1911,7 @@ uint2 MCBlock::getascent(void)
18881911
if (flags & F_HAS_IMAGE && atts->image != NULL)
18891912
return MCU_max(0, atts->image->getrect().height - shift + 2);
18901913
else
1891-
return MCU_max(0, heightfromsize(MCFontGetAscent(m_font)) - MCFontGetDescent(m_font) - shift);
1914+
return MCU_max(0, heightfromsize(ceilf(MCFontGetAscent(m_font))) - uint2(ceilf(MCFontGetDescent(m_font))) - shift);
18921915
}
18931916

18941917
uint2 MCBlock::getdescent(void)
@@ -1897,7 +1920,35 @@ uint2 MCBlock::getdescent(void)
18971920
if (flags & F_HAS_IMAGE && atts->image != NULL)
18981921
return MCU_max(0, shift);
18991922
else
1900-
return MCU_max(0, MCFontGetDescent(m_font) + shift);
1923+
return MCU_max(0, uint2(ceilf(MCFontGetDescent(m_font))) + shift);
1924+
}
1925+
1926+
coord_t MCBlock::GetAscent() const
1927+
{
1928+
int2 shift = flags & F_HAS_SHIFT ? atts->shift : 0;
1929+
// MW-2007-07-05: [[ Bug 1943 ]] - Images do not have correct ascent height *MIGHT NEED REVERSION*
1930+
if (flags & F_HAS_IMAGE && atts->image != NULL)
1931+
return MCU_max(0, atts->image->getrect().height - shift + 2);
1932+
else
1933+
return MCU_max(0.0f, MCFontGetAscent(m_font) - shift);
1934+
}
1935+
1936+
coord_t MCBlock::GetDescent() const
1937+
{
1938+
int2 shift = flags & F_HAS_SHIFT ? atts->shift : 0;
1939+
if (flags & F_HAS_IMAGE && atts->image != NULL)
1940+
return MCU_max(0, shift);
1941+
else
1942+
return MCU_max(0.0f, MCFontGetDescent(m_font) + shift);
1943+
}
1944+
1945+
coord_t MCBlock::GetLeading() const
1946+
{
1947+
int2 shift = flags & F_HAS_SHIFT ? atts->shift : 0;
1948+
if (flags & F_HAS_IMAGE && atts->image != NULL)
1949+
return GetAscent()+GetDescent();
1950+
else
1951+
return MCFontGetLeading(m_font);
19011952
}
19021953

19031954
void MCBlock::freeatts()
@@ -2400,3 +2451,36 @@ MCBlock *MCBlock::GetPrevBlockVisualOrder()
24002451

24012452
return nil;
24022453
}
2454+
2455+
void MCBlock::setcolorfornormaltext(MCDC* dc, MCColor* p_color)
2456+
{
2457+
MCField* f = parent->getparent();
2458+
2459+
if (p_color != nil)
2460+
dc->setforeground(*p_color);
2461+
else if (flags & F_HAS_COLOR)
2462+
dc->setforeground(*atts -> color);
2463+
else
2464+
f->setforeground(dc, DI_PSEUDO_TEXT_COLOR, False, True);
2465+
}
2466+
2467+
void MCBlock::setcolorforhilite(MCDC* dc)
2468+
{
2469+
MCField* f = parent->getparent();
2470+
2471+
f->setforeground(dc, DI_PSEUDO_TEXT_BACKGROUND_SEL, False, True);
2472+
}
2473+
2474+
void MCBlock::setcolorforselectedtext(MCDC* dc, MCColor* p_color)
2475+
{
2476+
MCField* f = parent->getparent();
2477+
2478+
if (p_color != nil)
2479+
dc->setforeground(*p_color);
2480+
else if (flags & F_HAS_COLOR)
2481+
dc->setforeground(*atts -> color);
2482+
else if (!IsMacLF()) // TODO: if platform reverses selected text
2483+
f->setforeground(dc, DI_PSEUDO_TEXT_COLOR_SEL_BACK, False, True, true);
2484+
else
2485+
f->setforeground(dc, DI_PSEUDO_TEXT_COLOR_SEL_FORE, False, True, true);
2486+
}

0 commit comments

Comments
 (0)