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

Commit 43781cf

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 43781cf

File tree

10 files changed

+124
-19
lines changed

10 files changed

+124
-19
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: 15 additions & 3 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;

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);

engine/src/fieldf.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,26 @@ int32_t MCField::getfirstindent(void) const
518518
return indent;
519519
}
520520

521+
int32_t MCField::getleftindent(void) const
522+
{
523+
return leftindent;
524+
}
525+
526+
int32_t MCField::getrightindent(void) const
527+
{
528+
return rightindent;
529+
}
530+
531+
int32_t MCField::getspaceabove(void) const
532+
{
533+
return spaceabove;
534+
}
535+
536+
int32_t MCField::getspacebelow(void) const
537+
{
538+
return spacebelow;
539+
}
540+
521541
int32_t MCField::gettexty(void) const
522542
{
523543
return texty;

engine/src/paragrafattr.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -886,14 +886,14 @@ int32_t MCParagraph::getspaceabove(void) const
886886
{
887887
if (attrs != nil && (attrs -> flags & PA_HAS_SPACE_ABOVE) != 0)
888888
return attrs -> space_above;
889-
return 0;
889+
return parent -> getspaceabove();
890890
}
891891

892892
int32_t MCParagraph::getspacebelow(void) const
893893
{
894894
if (attrs != nil && (attrs -> flags & PA_HAS_SPACE_BELOW) != 0)
895895
return attrs -> space_below;
896-
return 0;
896+
return parent -> getspacebelow();
897897
}
898898

899899
int32_t MCParagraph::getborderwidth(void) const
@@ -943,14 +943,14 @@ int32_t MCParagraph::getleftindent(void) const
943943
{
944944
if (attrs != nil && (attrs -> flags & PA_HAS_LEFT_INDENT) != 0)
945945
return attrs -> left_indent;
946-
return 0;
946+
return parent -> getleftindent();
947947
}
948948

949949
int32_t MCParagraph::getrightindent(void) const
950950
{
951951
if (attrs != nil && (attrs -> flags & PA_HAS_RIGHT_INDENT) != 0)
952952
return attrs -> right_indent;
953-
return 0;
953+
return parent -> getrightindent();
954954
}
955955

956956
int32_t MCParagraph::getlistindent(void) const

0 commit comments

Comments
 (0)