Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 72fb3b1

Browse files
committed
[[ Bug 13085 ]] Add field equivalents of some paragraph properties
This patch makes `leftIndent`, `rightIndent`, `spaceAbove` and `spaceBelow` which were previously only line chunk properties properties of fields similar to `firstIndent` etc. This allows them to be set for all paragraphs in a field at once rather than setting the properties on individual paragraphs.
1 parent c0265cc commit 72fb3b1

File tree

11 files changed

+222
-25
lines changed

11 files changed

+222
-25
lines changed

docs/dictionary/property/leftIndent.lcdoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Name: leftIndent
22

33
Type: property
44

5-
Syntax: set the leftIndent of <line> of <field> to <pixels>
5+
Syntax: set the leftIndent [of <line>] of <field> to <pixels>
66

77
Summary:
88
Determines the indentation of a paragraph in a <field>.
@@ -15,6 +15,9 @@ OS: mac, windows, linux, ios, android
1515

1616
Platforms: desktop, server, mobile
1717

18+
Example:
19+
set the leftIndent of field 1 to 10
20+
1821
Example:
1922
set the leftIndent of line 1 of field 1 to 15
2023

@@ -23,7 +26,7 @@ pixels (integer):
2326
The number of pixels to indent the left of a paragraph of text.
2427

2528
Value:
26-
The <leftIndent> of a line of text in a field returns an integer.
29+
The <leftIndent> of a field or line of text in a field returns an integer.
2730

2831
Description:
2932
Use the <leftIndent> property to indent the left side of whole

docs/dictionary/property/rightIndent.lcdoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Name: rightIndent
22

33
Type: property
44

5-
Syntax: set the rightIndent of <line> of <field> to <pixels>
5+
Syntax: set the rightIndent [of <line>] of <field> to <pixels>
66

77
Summary:
88
Determines the indentation of a paragraph in a <field>.
@@ -15,6 +15,9 @@ OS: mac, windows, linux, ios, android
1515

1616
Platforms: desktop, server, mobile
1717

18+
Example:
19+
set the rightIndent of field 1 to 10
20+
1821
Example:
1922
set the rightIndent of line 1 of field 1 to 15
2023

@@ -23,7 +26,7 @@ pixels (integer):
2326
The number of pixels to indent the right of a paragraph of text.
2427

2528
Value:
26-
The <rightIndent> of a line of text in a field returns an integer.
29+
The <rightIndent> of a field or line of text in a field returns an integer.
2730

2831
Description:
2932
Use the <rightIndent> property to indent the right side of whole

docs/dictionary/property/spaceAbove.lcdoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Name: spaceAbove
22

33
Type: property
44

5-
Syntax: set the spaceAbove of <line> of <field> to <pixels>
5+
Syntax: set the spaceAbove [of <line>] of <field> to <pixels>
66

77
Summary:
88
Determines the space above a paragraph in a field.
@@ -15,6 +15,9 @@ OS: mac, windows, linux, ios, android
1515

1616
Platforms: desktop, server, mobile
1717

18+
Example:
19+
set the spaceAbove of field 1 to 10
20+
1821
Example:
1922
set the spaceAbove of line 1 of field 1 to 20
2023

@@ -23,7 +26,7 @@ pixels (integer):
2326
The number of pixels of space above the paragraph.
2427

2528
Value:
26-
The <spaceAbove> of a line of text in a field returns an integer.
29+
The <spaceAbove> of a field or line of text in a field returns an integer.
2730

2831
Description:
2932
Use the <spaceAbove> property to specify the amount of space above a

docs/dictionary/property/spaceBelow.lcdoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Name: spaceBelow
22

33
Type: property
44

5-
Syntax: set the spaceBelow of <line> of <field> to <pixels>
5+
Syntax: set the spaceBelow [of <line>] of <field> to <pixels>
66

77
Summary:
88
Determines the space below a paragraph in a field.
@@ -15,6 +15,9 @@ OS: mac, windows, linux, ios, android
1515

1616
Platforms: desktop, server, mobile
1717

18+
Example:
19+
set the spaceBelow of field 1 to 10
20+
1821
Example:
1922
set the spaceBelow of line 1 of field 1 to 20
2023

@@ -23,7 +26,7 @@ pixels (integer):
2326
The number of pixels of space below the paragraph.
2427

2528
Value:
26-
The <spaceBelow> of a line of text in a field returns an integer.
29+
The <spaceBelow> of a field or line of text in a field returns an integer.
2730

2831
Description:
2932
Use the <spaceBelow> property to specify the amount of space below a

docs/notes/bugfix-13085.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# The paragraph properties `leftIndent`, `rightIndent`, `spaceAbove` and `spaceBelow` can now be set for the entire field

engine/src/exec-interface-field.cpp

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,51 @@ void MCField::GetFirstIndent(MCExecContext& ctxt, integer_t& r_indent)
611611
void MCField::SetFirstIndent(MCExecContext& ctxt, integer_t p_indent)
612612
{
613613
indent = p_indent;
614-
Redraw();
614+
Redraw(true);
615+
}
616+
617+
void MCField::GetLeftIndent(MCExecContext& ctxt, integer_t& r_indent)
618+
{
619+
r_indent = leftindent;
620+
}
621+
622+
void MCField::SetLeftIndent(MCExecContext& ctxt, integer_t p_indent)
623+
{
624+
leftindent = p_indent;
625+
Redraw(true);
626+
}
627+
628+
void MCField::GetRightIndent(MCExecContext& ctxt, integer_t& r_indent)
629+
{
630+
r_indent = rightindent;
631+
}
632+
633+
void MCField::SetRightIndent(MCExecContext& ctxt, integer_t p_indent)
634+
{
635+
rightindent = p_indent;
636+
Redraw(true);
637+
}
638+
639+
void MCField::GetSpaceAbove(MCExecContext& ctxt, integer_t& r_above)
640+
{
641+
r_above = spaceabove;
642+
}
643+
644+
void MCField::SetSpaceAbove(MCExecContext& ctxt, integer_t p_above)
645+
{
646+
spaceabove = p_above;
647+
Redraw();
648+
}
649+
650+
void MCField::GetSpaceBelow(MCExecContext& ctxt, integer_t& r_below)
651+
{
652+
r_below = spacebelow;
653+
}
654+
655+
void MCField::SetSpaceBelow(MCExecContext& ctxt, integer_t p_below)
656+
{
657+
spacebelow = p_below;
658+
Redraw();
615659
}
616660

617661
void MCField::GetWideMargins(MCExecContext& ctxt, bool& r_setting)

engine/src/field.cpp

Lines changed: 109 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ MCPropertyInfo MCField::kProperties[] =
9393
DEFINE_RW_OBJ_PROPERTY(P_AUTO_HILITE, Bool, MCField, AutoHilite)
9494
DEFINE_RW_OBJ_PROPERTY(P_AUTO_ARM, Bool, MCField, AutoArm)
9595
DEFINE_RW_OBJ_PROPERTY(P_FIRST_INDENT, Int16, MCField, FirstIndent)
96-
DEFINE_RW_OBJ_PROPERTY(P_WIDE_MARGINS, Bool, MCField, WideMargins)
96+
DEFINE_RW_OBJ_PROPERTY(P_LEFT_INDENT, Int16, MCField, LeftIndent)
97+
DEFINE_RW_OBJ_PROPERTY(P_RIGHT_INDENT, Int16, MCField, RightIndent)
98+
DEFINE_RW_OBJ_PROPERTY(P_SPACE_ABOVE, Int16, MCField, SpaceAbove)
99+
DEFINE_RW_OBJ_PROPERTY(P_SPACE_BELOW, Int16, MCField, SpaceBelow)
100+
DEFINE_RW_OBJ_PROPERTY(P_WIDE_MARGINS, Bool, MCField, WideMargins)
97101
DEFINE_RW_OBJ_PROPERTY(P_HSCROLL, Int32, MCField, HScroll)
98102
DEFINE_RW_OBJ_PROPERTY(P_VSCROLL, Int32, MCField, VScroll)
99103
DEFINE_RW_OBJ_PROPERTY(P_HSCROLLBAR, Bool, MCField, HScrollbar)
@@ -245,7 +249,11 @@ MCField::MCField()
245249
fixeda = fixedd = fixedheight = 0;
246250
leftmargin = rightmargin = topmargin = bottommargin = narrowmargin;
247251
indent = 0;
248-
cury = focusedy = firsty = topmargin;
252+
leftindent = 0;
253+
rightindent = 0;
254+
spaceabove = 0;
255+
spacebelow = 0;
256+
cury = focusedy = firsty = topmargin;
249257
firstparagraph = lastparagraph = NULL;
250258
foundlength = 0;
251259
vscrollbar = hscrollbar = NULL;
@@ -274,7 +282,11 @@ MCField::MCField(const MCField &fref) : MCControl(fref)
274282
textheight = textwidth = 0;
275283
fixeda = fixedd = fixedheight = 0;
276284
indent = fref.indent;
277-
cury = focusedy = firsty = topmargin;
285+
leftindent = fref.leftindent;
286+
rightindent = fref.rightindent;
287+
spaceabove = fref.spaceabove;
288+
spacebelow = fref.spacebelow;
289+
cury = focusedy = firsty = topmargin;
278290
firstparagraph = lastparagraph = NULL;
279291
foundlength = 0;
280292
cursor_movement = fref.cursor_movement;
@@ -2570,7 +2582,11 @@ void MCField::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool p
25702582
// SN-2015-04-30: [[ Bug 15175 ]] TabAlignment flag added
25712583
#define FIELD_EXTRA_TABALIGN (1 << 1)
25722584
#define FIELD_EXTRA_KEYBOARDTYPE (1 << 2)
2573-
#define FIELD_EXTRA_RETURNKEYTYPE (1 << 3)
2585+
#define FIELD_EXTRA_RETURNKEYTYPE (1 << 3)
2586+
#define FIELD_EXTRA_LEFTINDENT (1 << 4)
2587+
#define FIELD_EXTRA_RIGHTINDENT (1 << 5)
2588+
#define FIELD_EXTRA_SPACEABOVE (1 << 6)
2589+
#define FIELD_EXTRA_SPACEBELOW (1 << 7)
25742590

25752591
IO_stat MCField::extendedsave(MCObjectOutputStream& p_stream, uint4 p_part, uint32_t p_version)
25762592
{
@@ -2605,6 +2621,30 @@ IO_stat MCField::extendedsave(MCObjectOutputStream& p_stream, uint4 p_part, uint
26052621
t_flags |= FIELD_EXTRA_RETURNKEYTYPE;
26062622
t_size += sizeof(int8_t);
26072623
}
2624+
2625+
if (leftindent != 0)
2626+
{
2627+
t_flags |= FIELD_EXTRA_LEFTINDENT;
2628+
t_size += sizeof(uint16_t);
2629+
}
2630+
2631+
if (rightindent != 0)
2632+
{
2633+
t_flags |= FIELD_EXTRA_RIGHTINDENT;
2634+
t_size += sizeof(uint16_t);
2635+
}
2636+
2637+
if (spaceabove != 0)
2638+
{
2639+
t_flags |= FIELD_EXTRA_SPACEABOVE;
2640+
t_size += sizeof(uint16_t);
2641+
}
2642+
2643+
if (spacebelow != 0)
2644+
{
2645+
t_flags |= FIELD_EXTRA_SPACEBELOW;
2646+
t_size += sizeof(uint16_t);
2647+
}
26082648

26092649
IO_stat t_stat;
26102650
t_stat = p_stream . WriteTag(t_flags, t_size);
@@ -2630,6 +2670,26 @@ IO_stat MCField::extendedsave(MCObjectOutputStream& p_stream, uint4 p_part, uint
26302670
t_stat = p_stream . WriteS8((int8_t)return_key_type);
26312671
}
26322672

2673+
if (t_stat == IO_NORMAL && (t_flags & FIELD_EXTRA_LEFTINDENT))
2674+
{
2675+
t_stat = p_stream . WriteU16(leftindent);
2676+
}
2677+
2678+
if (t_stat == IO_NORMAL && (t_flags & FIELD_EXTRA_RIGHTINDENT))
2679+
{
2680+
t_stat = p_stream . WriteU16(rightindent);
2681+
}
2682+
2683+
if (t_stat == IO_NORMAL && (t_flags & FIELD_EXTRA_SPACEABOVE))
2684+
{
2685+
t_stat = p_stream . WriteU16(spaceabove);
2686+
}
2687+
2688+
if (t_stat == IO_NORMAL && (t_flags & FIELD_EXTRA_SPACEBELOW))
2689+
{
2690+
t_stat = p_stream . WriteU16(spacebelow);
2691+
}
2692+
26332693
if (t_stat == IO_NORMAL)
26342694
t_stat = MCObject::extendedsave(p_stream, p_part, p_version);
26352695

@@ -2709,6 +2769,46 @@ IO_stat MCField::extendedload(MCObjectInputStream& p_stream, uint32_t p_version,
27092769
}
27102770
}
27112771

2772+
if (t_stat == IO_NORMAL && (t_flags & FIELD_EXTRA_LEFTINDENT) != 0)
2773+
{
2774+
uint16_t t_value;
2775+
t_stat = checkloadstat(p_stream . ReadU16(t_value));
2776+
if (t_stat == IO_NORMAL)
2777+
{
2778+
leftindent = t_value;
2779+
}
2780+
}
2781+
2782+
if (t_stat == IO_NORMAL && (t_flags & FIELD_EXTRA_RIGHTINDENT) != 0)
2783+
{
2784+
uint16_t t_value;
2785+
t_stat = checkloadstat(p_stream . ReadU16(t_value));
2786+
if (t_stat == IO_NORMAL)
2787+
{
2788+
rightindent = t_value;
2789+
}
2790+
}
2791+
2792+
if (t_stat == IO_NORMAL && (t_flags & FIELD_EXTRA_SPACEABOVE) != 0)
2793+
{
2794+
uint16_t t_value;
2795+
t_stat = checkloadstat(p_stream . ReadU16(t_value));
2796+
if (t_stat == IO_NORMAL)
2797+
{
2798+
spaceabove = t_value;
2799+
}
2800+
}
2801+
2802+
if (t_stat == IO_NORMAL && (t_flags & FIELD_EXTRA_SPACEBELOW) != 0)
2803+
{
2804+
uint16_t t_value;
2805+
t_stat = checkloadstat(p_stream . ReadU16(t_value));
2806+
if (t_stat == IO_NORMAL)
2807+
{
2808+
spacebelow = t_value;
2809+
}
2810+
}
2811+
27122812
if (t_stat == IO_NORMAL)
27132813
t_stat = checkloadstat(p_stream . Skip(t_length));
27142814

@@ -2737,7 +2837,11 @@ IO_stat MCField::save(IO_handle stream, uint4 p_part, bool p_force_ext, uint32_t
27372837
t_has_extension = text_direction != kMCTextDirectionAuto ||
27382838
nalignments != 0 ||
27392839
keyboard_type != kMCInterfaceKeyboardTypeNone ||
2740-
return_key_type != kMCInterfaceReturnKeyTypeNone;
2840+
return_key_type != kMCInterfaceReturnKeyTypeNone ||
2841+
leftindent != 0 ||
2842+
rightindent != 0 ||
2843+
spaceabove != 0 ||
2844+
spacebelow != 0;
27412845

27422846
if ((stat = MCObject::save(stream, p_part, t_has_extension || p_force_ext, p_version)) != IO_NORMAL)
27432847
return stat;

engine/src/field.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,11 @@ class MCField : public MCControl, public MCMixinObjectHandle<MCField>
218218
uint4 textheight;
219219
uint2 textwidth;
220220
int2 indent;
221-
uint2 fixeda;
221+
uint16_t leftindent;
222+
uint16_t rightindent;
223+
uint16_t spaceabove;
224+
uint16_t spacebelow;
225+
uint2 fixeda;
222226
uint2 fixedd;
223227
uint2 fixedheight;
224228
findex_t foundlength;
@@ -372,7 +376,11 @@ class MCField : public MCControl, public MCMixinObjectHandle<MCField>
372376
int32_t getcontenty(void) const;
373377
int32_t gettexty(void) const;
374378
int32_t getfirstindent(void) const;
375-
int32_t getfixedheight(void) const { return fixedheight; }
379+
int32_t getleftindent(void) const;
380+
int32_t getrightindent(void) const;
381+
int32_t getspaceabove(void) const;
382+
int32_t getspacebelow(void) const;
383+
int32_t getfixedheight(void) const { return fixedheight; }
376384

377385
MCTextDirection gettextdirection() const { return text_direction; }
378386

@@ -658,7 +666,15 @@ class MCField : public MCControl, public MCMixinObjectHandle<MCField>
658666
void SetAutoArm(MCExecContext& ctxt, bool setting);
659667
void GetFirstIndent(MCExecContext& ctxt, integer_t& r_indent);
660668
void SetFirstIndent(MCExecContext& ctxt, integer_t indent);
661-
void GetWideMargins(MCExecContext& ctxt, bool& r_setting);
669+
void GetLeftIndent(MCExecContext& ctxt, integer_t& r_indent);
670+
void SetLeftIndent(MCExecContext& ctxt, integer_t indent);
671+
void GetRightIndent(MCExecContext& ctxt, integer_t& r_indent);
672+
void SetRightIndent(MCExecContext& ctxt, integer_t indent);
673+
void GetSpaceAbove(MCExecContext& ctxt, integer_t& r_above);
674+
void SetSpaceAbove(MCExecContext& ctxt, integer_t above);
675+
void GetSpaceBelow(MCExecContext& ctxt, integer_t& r_below);
676+
void SetSpaceBelow(MCExecContext& ctxt, integer_t below);
677+
void GetWideMargins(MCExecContext& ctxt, bool& r_setting);
662678
void SetWideMargins(MCExecContext& ctxt, bool setting);
663679
void GetHScroll(MCExecContext& ctxt, integer_t& r_scroll);
664680
void SetHScroll(MCExecContext& ctxt, integer_t scroll);

0 commit comments

Comments
 (0)