size_t i = 0;
size_t len = text.length();
wxString line;
- wxRichTextParagraph* para = new wxRichTextParagraph(wxT(""), this, & style);
+ wxRichTextParagraph* para = new wxRichTextParagraph(wxEmptyString, this, & style);
if (paraStyle)
para->SetAttributes(*paraStyle);
wxRichTextPlainText* plainText = (wxRichTextPlainText*) para->GetChildren().GetFirst()->GetData();
plainText->SetText(line);
- para = new wxRichTextParagraph(wxT(""), this, & style);
+ para = new wxRichTextParagraph(wxEmptyString, this, & style);
if (paraStyle)
para->SetAttributes(*paraStyle);
}
else
newPara = para;
-
+
if (paragraphStyle && !charactersOnly)
{
if (applyMinimal)
}
}
+ if (style.HasBulletName() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_BULLET_NAME))
+ {
+ if (currentStyle.HasBulletName())
+ {
+ if (currentStyle.HasBulletName() != style.HasBulletName())
+ {
+ // Clash of style - mark as such
+ multipleStyleAttributes |= wxTEXT_ATTR_BULLET_NAME;
+ currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_BULLET_NAME);
+ }
+ }
+ else
+ {
+ currentStyle.SetBulletName(style.GetBulletName());
+ }
+ }
+
return true;
}
// Problem: when changing from one list style to another, there's a danger that the level info will get lost.
// So when changing a list style interactively, could retrieve level based on current style, then
// set appropriate indent and apply new style.
-
+
if (!para->GetAttributes().GetParagraphStyleName().IsEmpty() && !para->GetAttributes().GetListStyleName().IsEmpty())
{
int currentIndent = para->GetAttributes().GetLeftIndent();
wxRichTextListStyleDefinition* listDef = styleSheet->FindListStyle(para->GetAttributes().GetListStyleName());
- // Overall list definition style
+ // Overall list definition style
para->GetAttributes() = listDef->GetStyle();
-
+
// Style for this level
wxRichTextApplyStyle(para->GetAttributes(), * listDef->GetLevelAttributes(listDef->FindLevelForIndent(currentIndent)));
// bool applyMinimal = ((flags & wxRICHTEXT_SETSTYLE_OPTIMIZE) != 0);
bool specifyLevel = ((flags & wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL) != 0);
bool renumber = ((flags & wxRICHTEXT_SETSTYLE_RENUMBER) != 0);
-
+
// Current number, if numbering
int n = startFrom;
-
+
wxASSERT (!specifyLevel || (specifyLevel && (specifiedLevel >= 0)));
// If we are associated with a control, make undoable; otherwise, apply immediately
}
else
newPara = para;
-
+
if (def)
{
int thisIndent = newPara->GetAttributes().GetLeftIndent();
int thisLevel = specifyLevel ? specifiedLevel : def->FindLevelForIndent(thisIndent);
-
+
// How is numbering going to work?
// If we are renumbering, or numbering for the first time, we need to keep
// track of the number for each level. But we might be simply applying a different
// Apply the overall list style, and item style for this level
wxTextAttrEx listStyle(def->GetCombinedStyleForLevel(thisLevel));
wxRichTextApplyStyle(newPara->GetAttributes(), listStyle);
-
+
// Now we need to check numbering
if (renumber)
{
newPara->GetAttributes().SetBulletNumber(n);
}
-
+
n ++;
}
else if (!newPara->GetAttributes().GetListStyleName().IsEmpty())
newPara->GetAttributes().SetListStyleName(wxEmptyString);
newPara->GetAttributes().SetLeftIndent(0, 0);
-
+
// Eliminate the main list-related attributes
newPara->GetAttributes().SetFlags(newPara->GetAttributes().GetFlags() & ~wxTEXT_ATTR_LEFT_INDENT & ~wxTEXT_ATTR_BULLET_STYLE & ~wxTEXT_ATTR_BULLET_NUMBER & ~wxTEXT_ATTR_BULLET_SYMBOL & wxTEXT_ATTR_LIST_STYLE_NAME);
-
+
wxRichTextStyleSheet* styleSheet = GetStyleSheet();
if (styleSheet && !newPara->GetAttributes().GetParagraphStyleName().IsEmpty())
{
bool specifyLevel = ((flags & wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL) != 0);
bool renumber = ((flags & wxRICHTEXT_SETSTYLE_RENUMBER) != 0);
-
+
// Max number of levels
const int maxLevels = 10;
-
+
// The level we're looking at now
int currentLevel = -1;
-
+
// The item number for each level
int levels[maxLevels];
int i;
-
+
// Reset all numbering
for (i = 0; i < maxLevels; i++)
{
else
levels[i] = -1; // start from the number we found, if any
}
-
+
wxASSERT(!specifyLevel || (specifyLevel && (specifiedLevel >= 0)));
// If we are associated with a control, make undoable; otherwise, apply immediately
}
else
newPara = para;
-
+
wxRichTextListStyleDefinition* defToUse = def;
if (!defToUse)
{
wxRichTextStyleSheet* sheet = GetStyleSheet();
-
+
if (sheet && !newPara->GetAttributes().GetListStyleName().IsEmpty())
defToUse = sheet->FindListStyle(newPara->GetAttributes().GetListStyleName());
}
-
+
if (defToUse)
{
int thisIndent = newPara->GetAttributes().GetLeftIndent();
// change the level.
if (thisIndent == 0 || specifiedLevel != -1)
thisLevel = specifiedLevel;
-
+
// Do promotion if specified
if ((promoteBy != 0) && !para->GetRange().IsOutside(promotionRange))
{
if (thisLevel > 9)
thisLevel = 9;
}
-
+
// Apply the overall list style, and item style for this level
wxTextAttrEx listStyle(defToUse->GetCombinedStyleForLevel(thisLevel));
wxRichTextApplyStyle(newPara->GetAttributes(), listStyle);
-
+
// OK, we've (re)applied the style, now let's get the numbering right.
-
+
if (currentLevel == -1)
currentLevel = thisLevel;
-
+
// Same level as before, do nothing except increment level's number afterwards
if (currentLevel == thisLevel)
{
else if (thisLevel < currentLevel)
{
currentLevel = thisLevel;
- }
+ }
// Use the current numbering if -1 and we have a bullet number already
if (levels[currentLevel] == -1)
else
levels[currentLevel] = 1;
}
-
+
newPara->GetAttributes().SetBulletNumber(levels[currentLevel]);
- levels[currentLevel] ++;
+ levels[currentLevel] ++;
}
}
}
// list position will start from 1.
// Similarly, we look after the last para in the promote range for an indentation that is less (or no list style).
// We can end the renumbering at this point.
-
+
// For now, only renumber within the promotion range.
-
+
return DoNumberList(range, range, promoteBy, def, flags, 1, specifiedLevel);
}
{
// TODO
}
+ else if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_STANDARD)
+ {
+ wxTextAttrEx bulletAttr(GetCombinedAttributes());
+ if (bulletAttr.GetTextColour().Ok())
+ {
+ dc.SetPen(wxPen(bulletAttr.GetTextColour()));
+ dc.SetBrush(wxBrush(bulletAttr.GetTextColour()));
+ }
+ else
+ {
+ dc.SetPen(*wxBLACK_PEN);
+ dc.SetBrush(*wxBLACK_BRUSH);
+ }
+
+ wxFont font;
+ if (bulletAttr.GetFont().Ok())
+ font = bulletAttr.GetFont();
+ else
+ font = (*wxNORMAL_FONT);
+
+ dc.SetFont(font);
+
+ // Get line height from first line, if any
+ wxRichTextLine* line = m_cachedLines.GetFirst() ? (wxRichTextLine* ) m_cachedLines.GetFirst()->GetData() : (wxRichTextLine*) NULL;
+
+ wxPoint linePos;
+ int lineHeight wxDUMMY_INITIALIZE(0);
+ if (line)
+ {
+ lineHeight = line->GetSize().y;
+ linePos = line->GetPosition() + GetPosition();
+ }
+ else
+ {
+ lineHeight = dc.GetCharHeight();
+ linePos = GetPosition();
+ linePos.y += spaceBeforePara;
+ }
+
+ int charHeight = dc.GetCharHeight();
+
+ int bulletWidth = wxMax(2, (charHeight/3 + 1));
+ int bulletHeight = bulletWidth;
+
+ int x = GetPosition().x + leftIndent;
+ int y = linePos.y + (lineHeight - charHeight/2) - bulletHeight/2;
+
+ if (bulletAttr.GetBulletName() == wxT("standard/square"))
+ {
+ dc.DrawRectangle(x, y, bulletWidth, bulletHeight);
+ }
+ else // "standard/round", and catch-all
+ {
+ dc.DrawEllipse(x, y, bulletWidth, bulletHeight);
+ }
+ }
else
{
wxString bulletText = GetBulletText();
// Compensate for kerning difference
wxString stringFragment2(m_text.Mid(r1 - offset, fragmentLen+1));
wxString stringFragment3(m_text.Mid(r1 - offset + fragmentLen, 1));
-
+
wxCoord w1, h1, w2, h2, w3, h3;
dc.GetTextExtent(stringFragment, & w1, & h1);
dc.GetTextExtent(stringFragment2, & w2, & h2);
dc.GetTextExtent(stringFragment3, & w3, & h3);
-
+
int kerningDiff = (w1 + w3) - w2;
x = x - kerningDiff;
}
// Compensate for kerning difference
wxString stringFragment2(m_text.Mid(s1 - offset, fragmentLen+1));
wxString stringFragment3(m_text.Mid(s1 - offset + fragmentLen, 1));
-
+
wxCoord w1, h1, w2, h2, w3, h3;
dc.GetTextExtent(stringFragment, & w1, & h1);
dc.GetTextExtent(stringFragment2, & w2, & h2);
dc.GetTextExtent(stringFragment3, & w3, & h3);
-
+
int kerningDiff = (w1 + w3) - w2;
x = x - kerningDiff;
}
tabArray = textAttr.GetTabs();
int tabCount = tabArray.GetCount();
-
+
for (int i = 0; i < tabCount; ++i)
{
int pos = tabArray[i];
pos = ((wxRichTextPlainText*) this)->ConvertTenthsMMToPixels(dc, pos);
tabArray[i] = pos;
}
-
+
int nextTabPos = -1;
while (stringChunk.Find(wxT('\t')) >= 0)
styleSheet->InsertSheet(m_styleSheet);
SetStyleSheet(styleSheet);
-
+
return true;
}
wxRichTextStyleSheet* oldSheet = m_styleSheet;
m_styleSheet = oldSheet->GetNextSheet();
oldSheet->Unlink();
-
+
return oldSheet;
}
else
bool wxRichTextBuffer::BeginNumberedBullet(int bulletNumber, int leftIndent, int leftSubIndent, int bulletStyle)
{
wxTextAttrEx attr;
- attr.SetFlags(wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_LEFT_INDENT);
+ attr.SetFlags(wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_LEFT_INDENT);
attr.SetBulletStyle(bulletStyle);
attr.SetBulletNumber(bulletNumber);
attr.SetLeftIndent(leftIndent, leftSubIndent);
bool wxRichTextBuffer::BeginSymbolBullet(wxChar symbol, int leftIndent, int leftSubIndent, int bulletStyle)
{
wxTextAttrEx attr;
- attr.SetFlags(wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_SYMBOL|wxTEXT_ATTR_LEFT_INDENT);
+ attr.SetFlags(wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_LEFT_INDENT);
attr.SetBulletStyle(bulletStyle);
attr.SetLeftIndent(leftIndent, leftSubIndent);
attr.SetBulletSymbol(symbol);
return BeginStyle(attr);
}
+/// Begin standard bullet
+bool wxRichTextBuffer::BeginStandardBullet(const wxString& bulletName, int leftIndent, int leftSubIndent, int bulletStyle)
+{
+ wxTextAttrEx attr;
+ attr.SetFlags(wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_LEFT_INDENT);
+ attr.SetBulletStyle(bulletStyle);
+ attr.SetLeftIndent(leftIndent, leftSubIndent);
+ attr.SetBulletName(bulletName);
+
+ return BeginStyle(attr);
+}
+
/// Begin named character style
bool wxRichTextBuffer::BeginCharacterStyle(const wxString& characterStyle)
{
return false;
}
+/// Begin named list style
+bool wxRichTextBuffer::BeginListStyle(const wxString& listStyle, int level, int number)
+{
+ if (GetStyleSheet())
+ {
+ wxRichTextListStyleDefinition* def = GetStyleSheet()->FindListStyle(listStyle);
+ if (def)
+ {
+ wxTextAttrEx attr(def->GetCombinedStyleForLevel(level));
+
+ attr.SetBulletNumber(number);
+
+ return BeginStyle(attr);
+ }
+ }
+ return false;
+}
+
/// Adds a handler to the end
void wxRichTextBuffer::AddHandler(wxRichTextFileHandler *handler)
{
/// Load a file
bool wxRichTextBuffer::LoadFile(const wxString& filename, int type)
+
+
{
wxRichTextFileHandler* handler = FindHandlerFilenameOrType(filename, type);
if (handler)
wxRichTextBuffer::CleanUpHandlers();
wxRichTextDecimalToRoman(-1);
wxRichTextParagraph::ClearDefaultTabs();
+ wxRichTextCtrl::ClearAvailableFontNames();
};
};
attr1.GetBulletStyle() == attr2.GetBulletStyle() &&
attr1.GetBulletNumber() == attr2.GetBulletNumber() &&
attr1.GetBulletSymbol() == attr2.GetBulletSymbol() &&
+ attr1.GetBulletName() == attr2.GetBulletName() &&
attr1.GetBulletFont() == attr2.GetBulletFont() &&
attr1.GetCharacterStyleName() == attr2.GetCharacterStyleName() &&
attr1.GetParagraphStyleName() == attr2.GetParagraphStyleName() &&
return false;
if ((flags & wxTEXT_ATTR_BULLET_SYMBOL) &&
- (attr1.GetBulletSymbol() != attr2.GetBulletSymbol()))
+ (attr1.GetBulletSymbol() != attr2.GetBulletSymbol()) &&
+ (attr1.GetBulletFont() != attr2.GetBulletFont()))
return false;
- if ((flags & wxTEXT_ATTR_BULLET_SYMBOL) &&
- (attr1.GetBulletFont() != attr2.GetBulletFont()))
+ if ((flags & wxTEXT_ATTR_BULLET_NAME) &&
+ (attr1.GetBulletName() != attr2.GetBulletName()))
return false;
if ((flags & wxTEXT_ATTR_TABS) &&
return false;
if ((flags & wxTEXT_ATTR_BULLET_SYMBOL) &&
- (attr1.GetBulletSymbol() != attr2.GetBulletSymbol()))
+ (attr1.GetBulletSymbol() != attr2.GetBulletSymbol()) &&
+ (attr1.GetBulletFont() != attr2.GetBulletFont()))
return false;
- if ((flags & wxTEXT_ATTR_BULLET_SYMBOL) &&
- (attr1.GetBulletFont() != attr2.GetBulletFont()))
+ if ((flags & wxTEXT_ATTR_BULLET_NAME) &&
+ (attr1.GetBulletName() != attr2.GetBulletName()))
return false;
if ((flags & wxTEXT_ATTR_TABS) &&
destStyle.SetListStyleName(style.GetListStyleName());
if (style.HasBulletStyle())
- {
destStyle.SetBulletStyle(style.GetBulletStyle());
+
+ if (style.HasBulletSymbol())
+ {
destStyle.SetBulletSymbol(style.GetBulletSymbol());
destStyle.SetBulletFont(style.GetBulletFont());
}
+ if (style.HasBulletName())
+ destStyle.SetBulletName(style.GetBulletName());
+
if (style.HasBulletNumber())
destStyle.SetBulletNumber(style.GetBulletNumber());
destStyle.SetBulletNumber(style.GetBulletNumber());
}
+ if (style.HasBulletName())
+ {
+ if (!(compareWith && compareWith->HasBulletName() && compareWith->GetBulletName() == style.GetBulletName()))
+ destStyle.SetBulletName(style.GetBulletName());
+ }
+
return true;
}
m_bulletNumber = attr.m_bulletNumber;
m_bulletSymbol = attr.m_bulletSymbol;
m_bulletFont = attr.m_bulletFont;
+ m_bulletName = attr.m_bulletName;
}
// operators
m_bulletStyle = attr.GetBulletStyle();
m_bulletNumber = attr.GetBulletNumber();
m_bulletSymbol = attr.GetBulletSymbol();
+ m_bulletName = attr.GetBulletName();
m_bulletFont = attr.GetBulletFont();
if (attr.GetFont().Ok())
GetBulletSymbol() == attr.GetBulletSymbol() &&
GetBulletNumber() == attr.GetBulletNumber() &&
GetBulletFont() == attr.GetBulletFont() &&
+ GetBulletName() == attr.GetBulletName() &&
m_fontSize == attr.m_fontSize &&
m_fontStyle == attr.m_fontStyle &&
attr.SetBulletStyle(m_bulletStyle);
attr.SetBulletNumber(m_bulletNumber);
attr.SetBulletSymbol(m_bulletSymbol);
+ attr.SetBulletName(m_bulletName);
attr.SetBulletFont(m_bulletFont);
attr.SetCharacterStyleName(m_characterStyleName);
attr.SetParagraphStyleName(m_paragraphStyleName);
if (attr.HasBulletNumber())
newAttr.SetBulletNumber(attr.GetBulletNumber());
+ if (attr.HasBulletName())
+ newAttr.SetBulletName(attr.GetBulletName());
+
if (attr.HasBulletSymbol())
{
newAttr.SetBulletSymbol(attr.GetBulletSymbol());
m_bulletStyle = attr.m_bulletStyle;
m_bulletNumber = attr.m_bulletNumber;
m_bulletSymbol = attr.m_bulletSymbol;
+ m_bulletName = attr.m_bulletName;
m_bulletFont = attr.m_bulletFont;
}
m_lineSpacing = 0;
m_bulletStyle = wxTEXT_ATTR_BULLET_STYLE_NONE;
m_bulletNumber = 0;
- m_bulletSymbol = 0;
m_bulletSymbol = wxT('*');
}
m_bulletNumber = attr.m_bulletNumber;
m_bulletSymbol = attr.m_bulletSymbol;
m_bulletFont = attr.m_bulletFont;
+ m_bulletName = attr.m_bulletName;
}
// Assignment from a wxTextAttr object.
GetBulletStyle() == attr.GetBulletStyle() &&
GetBulletNumber() == attr.GetBulletNumber() &&
GetBulletSymbol() == attr.GetBulletSymbol() &&
+ GetBulletName() == attr.GetBulletName() &&
GetBulletFont() == attr.GetBulletFont() &&
GetCharacterStyleName() == attr.GetCharacterStyleName() &&
GetParagraphStyleName() == attr.GetParagraphStyleName() &&
if (attr.HasBulletNumber())
newAttr.SetBulletNumber(attr.GetBulletNumber());
+ if (attr.HasBulletName())
+ newAttr.SetBulletName(attr.GetBulletName());
+
if (attr.HasBulletSymbol())
{
newAttr.SetBulletSymbol(attr.GetBulletSymbol());
#endif
// wxUSE_RICHTEXT
-