I was stupid enough to reorganise the way font changes get stored and applied,

so after only four hours work I'm back where I was yesterday. Selections still
buggy.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2454 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Karsten Ballüder
1999-05-13 21:13:26 +00:00
parent c3317e87ec
commit 60a040b3bb
6 changed files with 165 additions and 167 deletions

View File

@@ -43,35 +43,23 @@ their sizes change:
!!! GOOD: this can also be used to recalculate the wxLayoutObjectCmds' !!! GOOD: this can also be used to recalculate the wxLayoutObjectCmds'
fonts! :-) fonts! :-)
- searching for text
- moving cursor in non-edit mode
- cursor screen positioning ignores font sizes once again :-( - cursor screen positioning ignores font sizes once again :-(
--> UpdateCursorScreenPos() cannot work as it ignores previous font formatting commands. --> UpdateCursorScreenPos() cannot work as it ignores previous font formatting commands.
Either draw cursor when drawing text, or wait for new wxLayoutObjectCmd to be fully Either draw cursor when drawing text, or wait for new wxLayoutObjectCmd to be fully
implemented. implemented.
RECENTLY FIXED (?) RECENTLY FIXED (?)
- fix(simplify) cursor size calculation
- delete in empty line doesn't work - delete in empty line doesn't work
- fix horiz scrollbar size OK here, a Mahogany problem?
- with a large number of lines, wraps to top of scrolled window
--> check where the problem lies, add a debug function showing all coordinates
- update rectangle (needs support in wxllist and wxWindows) - update rectangle (needs support in wxllist and wxWindows)
--> needs a bit of fixing still --> needs a bit of fixing still
some code bits are commented out in wxlwindow.cpp some code bits are commented out in wxlwindow.cpp
offset handling seems a bit dodgy, white shadow to top/left of cursor offset handling seems a bit dodgy, white shadow to top/left of cursor
- replacement of llist in window - replacement of llist in window
- undo - undo
- font optimisations(!)
- occasionally wraps lines wongly (twice) ??
- UNDO - UNDO
later: - DragNDrop
- DragNDrop ... broken in wxGTK at present
- cut&paste ... broken in wxGTK at present, Paste already implemented
- Selections
- More optimisations: - More optimisations:
- let each line have a pointer to the last layoutcommand and let that - let each line have a pointer to the last layoutcommand and let that

View File

@@ -116,6 +116,15 @@ MyFrame::MyFrame(void) :
void void
MyFrame::AddSampleText(wxLayoutList *llist) MyFrame::AddSampleText(wxLayoutList *llist)
{ {
#if 0
llist->Clear(wxSWISS,16,wxNORMAL,wxNORMAL, false);
llist->SetFont(-1,-1,-1,-1,-1,"blue");
llist->Insert("blue");
llist->SetFont(-1,-1,-1,-1,-1,"black");
llist->Insert("The quick brown fox jumps over the lazy dog.");
llist->LineBreak();
#endif
llist->SetFont(wxROMAN,16,wxNORMAL,wxNORMAL, false); llist->SetFont(wxROMAN,16,wxNORMAL,wxNORMAL, false);
llist->Insert("--"); llist->Insert("--");
llist->LineBreak(); llist->LineBreak();
@@ -130,7 +139,6 @@ MyFrame::AddSampleText(wxLayoutList *llist)
llist->SetFontWeight(wxNORMAL); llist->SetFontWeight(wxNORMAL);
llist->Insert("The quick brown fox jumps..."); llist->Insert("The quick brown fox jumps...");
llist->LineBreak(); llist->LineBreak();
llist->Insert("over the lazy dog."); llist->Insert("over the lazy dog.");
llist->SetFont(-1,-1,-1,-1,true); llist->SetFont(-1,-1,-1,-1,true);
llist->Insert("underlined"); llist->Insert("underlined");
@@ -144,6 +152,7 @@ MyFrame::AddSampleText(wxLayoutList *llist)
llist->SetFont(-1,-1,wxNORMAL); llist->SetFont(-1,-1,wxNORMAL);
llist->LineBreak(); llist->LineBreak();
#if 0
llist->Insert("and "); llist->Insert("and ");
llist->SetFont(-1,-1,wxSLANT); llist->SetFont(-1,-1,wxSLANT);
llist->Insert("slanted"); llist->Insert("slanted");
@@ -188,6 +197,7 @@ MyFrame::AddSampleText(wxLayoutList *llist)
llist->LineBreak(); llist->LineBreak();
} }
} }
#endif
llist->MoveCursorTo(wxPoint(0,0)); llist->MoveCursorTo(wxPoint(0,0));
m_lwin->SetDirty(); m_lwin->SetDirty();
m_lwin->Refresh(); m_lwin->Refresh();

View File

@@ -297,76 +297,57 @@ wxLayoutStyleInfo::wxLayoutStyleInfo(int ifamily,
underline = iul; underline = iul;
if(fg) if(fg)
{ {
fg_valid = true; m_fg = *fg;
fg_red = fg->Red(); m_fg_valid = TRUE;
fg_blue = fg->Blue();
fg_green = fg->Green();
} }
else else
fg_valid = false; m_fg = *wxBLACK;
if(bg) if(bg)
{ {
bg_valid = true; m_bg = *bg;
bg_red = bg->Red(); m_bg_valid = TRUE;
bg_blue = bg->Blue();
bg_green = bg->Green();
} }
else else
bg_valid = false; m_bg = *wxWHITE;
} }
#define SET_SI(what) tmp.what = (what != -1) ? what : ( si ? si->what : wxNORMAL); #define COPY_SI_(what) if(right.what != -1) what = right.what;
wxLayoutStyleInfo &
wxFont * wxLayoutStyleInfo::operator=(const wxLayoutStyleInfo &right)
wxLayoutStyleInfo::GetFont(wxLayoutStyleInfo *si)
{ {
wxLayoutStyleInfo tmp; COPY_SI_(family);
COPY_SI_(style);
SET_SI(family); COPY_SI_(size);
SET_SI(size); COPY_SI_(weight);
SET_SI(style); COPY_SI_(underline);
SET_SI(weight); if(right.m_fg_valid) m_fg = right.m_fg;
SET_SI(underline); if(right.m_bg_valid) m_bg = right.m_bg;
return *this;
return new wxFont(tmp.size,tmp.family,tmp.style,tmp.weight,tmp.underline);
} }
wxLayoutObjectCmd::wxLayoutObjectCmd(int size, int family, int style, int wxLayoutObjectCmd::wxLayoutObjectCmd(int family, int size, int style, int
weight, int underline, weight, int underline,
wxColour *fg, wxColour *bg) wxColour *fg, wxColour *bg)
{ {
m_StyleInfo = new m_StyleInfo = new wxLayoutStyleInfo(family, size,style,weight,underline,fg,bg);
wxLayoutStyleInfo(size,family,style,weight,underline,fg,bg);
m_font = NULL;
} }
wxLayoutObject * wxLayoutObject *
wxLayoutObjectCmd::Copy(void) wxLayoutObjectCmd::Copy(void)
{ {
wxColour
* fg = NULL,
* bg = NULL;
if(m_StyleInfo->fg_valid)
fg = new
wxColour(m_StyleInfo->fg_red,m_StyleInfo->fg_green,m_StyleInfo->fg_blue);
if(m_StyleInfo->bg_valid)
bg = new
wxColour(m_StyleInfo->bg_red,m_StyleInfo->bg_green,m_StyleInfo->bg_blue);
wxLayoutObjectCmd *obj = new wxLayoutObjectCmd( wxLayoutObjectCmd *obj = new wxLayoutObjectCmd(
m_StyleInfo->size, m_StyleInfo->size,
m_StyleInfo->family, m_StyleInfo->family,
m_StyleInfo->style, m_StyleInfo->style,
m_StyleInfo->weight, m_StyleInfo->weight,
m_StyleInfo->underline, m_StyleInfo->underline,
fg, bg); m_StyleInfo->m_fg_valid ?
&m_StyleInfo->m_fg : NULL,
m_StyleInfo->m_bg_valid ?
&m_StyleInfo->m_bg : NULL);
obj->SetUserData(m_UserData); obj->SetUserData(m_UserData);
if(fg) delete fg;
if(bg) delete bg;
return obj; return obj;
} }
@@ -374,7 +355,6 @@ wxLayoutObjectCmd::Copy(void)
wxLayoutObjectCmd::~wxLayoutObjectCmd() wxLayoutObjectCmd::~wxLayoutObjectCmd()
{ {
delete m_StyleInfo; delete m_StyleInfo;
if(m_font) delete m_font;
} }
wxLayoutStyleInfo * wxLayoutStyleInfo *
@@ -389,17 +369,12 @@ wxLayoutObjectCmd::Draw(wxDC &dc, wxPoint const & /* coords */,
CoordType begin, CoordType /* len */) CoordType begin, CoordType /* len */)
{ {
wxASSERT(m_StyleInfo); wxASSERT(m_StyleInfo);
dc.SetFont(*m_font);
wxllist->ApplyStyle(m_StyleInfo, dc); wxllist->ApplyStyle(m_StyleInfo, dc);
} }
void void
wxLayoutObjectCmd::Layout(wxDC &dc, class wxLayoutList * llist) wxLayoutObjectCmd::Layout(wxDC &dc, class wxLayoutList * llist)
{ {
if(m_font) delete m_font;
m_font = m_StyleInfo->GetFont(llist->GetStyleInfo());
// this get called, so that recalculation uses right font sizes // this get called, so that recalculation uses right font sizes
Draw(dc, wxPoint(0,0), llist); Draw(dc, wxPoint(0,0), llist);
} }
@@ -540,7 +515,7 @@ wxLayoutLine::FindObjectScreen(wxDC &dc,
@return the cursoor coord where it was found or -1 @return the cursoor coord where it was found or -1
*/ */
CoordType CoordType
wxLayoutLine::FindText(const wxString &needle, CoordType xpos = 0) const wxLayoutLine::FindText(const wxString &needle, CoordType xpos) const
{ {
int int
cpos = 0, cpos = 0,
@@ -769,6 +744,7 @@ wxLayoutLine::Draw(wxDC &dc,
CoordType xpos = 0; // cursorpos, lenght of line CoordType xpos = 0; // cursorpos, lenght of line
CoordType from, to, tempto; CoordType from, to, tempto;
llist->ApplyStyle(&((wxLayoutLine *)this)->m_StyleInfo, dc);
int highlight = llist->IsSelected(this, &from, &to); int highlight = llist->IsSelected(this, &from, &to);
// WXLO_DEBUG(("highlight=%d", highlight )); // WXLO_DEBUG(("highlight=%d", highlight ));
if(highlight == 1) // we need to draw the whole line inverted! if(highlight == 1) // we need to draw the whole line inverted!
@@ -834,6 +810,7 @@ wxLayoutLine::Layout(wxDC &dc,
if(cursorSize) *cursorSize = wxPoint(0,0); if(cursorSize) *cursorSize = wxPoint(0,0);
} }
llist->ApplyStyle(&m_StyleInfo, dc);
for(i = m_ObjectList.begin(); i != NULLIT; i++) for(i = m_ObjectList.begin(); i != NULLIT; i++)
{ {
(**i).Layout(dc, llist); (**i).Layout(dc, llist);
@@ -926,6 +903,7 @@ wxLayoutLine::Layout(wxDC &dc,
if(m_BaseLine >= cursorSize->y) // the normal case anyway if(m_BaseLine >= cursorSize->y) // the normal case anyway
cursorPos->y += m_BaseLine-cursorSize->y; cursorPos->y += m_BaseLine-cursorSize->y;
} }
RecalculatePositions(1, llist);
} }
@@ -1150,10 +1128,7 @@ wxLayoutLine::Copy(wxLayoutList *llist,
wxLayoutList::wxLayoutList() wxLayoutList::wxLayoutList()
{ {
m_DefaultSetting = NULL;
m_FirstLine = NULL; m_FirstLine = NULL;
m_ColourFG = *wxBLACK;
m_ColourBG = *wxWHITE;
InvalidateUpdateRect(); InvalidateUpdateRect();
Clear(); Clear();
} }
@@ -1183,19 +1158,20 @@ void
wxLayoutList::InternalClear(void) wxLayoutList::InternalClear(void)
{ {
Empty(); Empty();
if(m_DefaultSetting)
{
delete m_DefaultSetting;
m_DefaultSetting = NULL;
}
m_Selection.m_selecting = false; m_Selection.m_selecting = false;
m_Selection.m_valid = false; m_Selection.m_valid = false;
m_CurrentSetting.family = wxSWISS; m_DefaultSetting.family = wxSWISS;
m_CurrentSetting.size = WXLO_DEFAULTFONTSIZE; m_DefaultSetting.size = WXLO_DEFAULTFONTSIZE;
m_CurrentSetting.style = wxNORMAL; m_DefaultSetting.style = wxNORMAL;
m_CurrentSetting.weight = wxNORMAL; m_DefaultSetting.weight = wxNORMAL;
m_CurrentSetting.underline = 0; m_DefaultSetting.underline = 0;
m_DefaultSetting.m_fg_valid = TRUE;
m_DefaultSetting.m_fg = *wxBLACK;
m_DefaultSetting.m_bg_valid = TRUE;
m_DefaultSetting.m_bg = *wxWHITE;
m_CurrentSetting = m_DefaultSetting;
} }
void void
@@ -1208,27 +1184,16 @@ wxLayoutList::SetFont(int family, int size, int style, int weight,
if(style != -1) m_CurrentSetting.style = style; if(style != -1) m_CurrentSetting.style = style;
if(weight != -1) m_CurrentSetting.weight = weight; if(weight != -1) m_CurrentSetting.weight = weight;
if(underline != -1) m_CurrentSetting.underline = underline != 0; if(underline != -1) m_CurrentSetting.underline = underline != 0;
if(fg) if(fg) m_CurrentSetting.m_fg = *fg;
{ if(bg) m_CurrentSetting.m_bg = *bg;
m_CurrentSetting.fg_valid = true;
m_CurrentSetting.fg_red = fg->Red();
m_CurrentSetting.fg_blue = fg->Blue();
m_CurrentSetting.fg_green = fg->Green();
}
if(bg)
{
m_CurrentSetting.bg_valid = true;
m_CurrentSetting.bg_red = bg->Red();
m_CurrentSetting.bg_blue = bg->Blue();
m_CurrentSetting.bg_green = bg->Green();
}
Insert( Insert(
new wxLayoutObjectCmd( new wxLayoutObjectCmd(
m_CurrentSetting.size,
m_CurrentSetting.family, m_CurrentSetting.family,
m_CurrentSetting.size,
m_CurrentSetting.style, m_CurrentSetting.style,
m_CurrentSetting.weight, m_CurrentSetting.weight,
m_CurrentSetting.underline, fg, bg)); m_CurrentSetting.underline,
fg, bg));
} }
void void
@@ -1245,7 +1210,7 @@ wxLayoutList::SetFont(int family, int size, int style, int weight,
if( bg ) if( bg )
cbg = wxTheColourDatabase->FindColour(bg); cbg = wxTheColourDatabase->FindColour(bg);
SetFont(size,family,style,weight,underline,cfg,cbg); SetFont(family,size,style,weight,underline,cfg,cbg);
} }
void void
@@ -1253,12 +1218,9 @@ wxLayoutList::Clear(int family, int size, int style, int weight,
int underline, wxColour *fg, wxColour *bg) int underline, wxColour *fg, wxColour *bg)
{ {
InternalClear(); InternalClear();
m_DefaultSetting = wxLayoutStyleInfo(family, size, style, weight,
if(m_DefaultSetting) underline, fg, bg);
delete m_DefaultSetting; m_CurrentSetting = m_DefaultSetting;
m_DefaultSetting = new
wxLayoutStyleInfo(family,size,style,weight,underline,fg,bg);
} }
wxPoint wxPoint
@@ -1544,7 +1506,7 @@ wxLayoutList::Recalculate(wxDC &dc, CoordType bottom)
// first, make sure everything is calculated - this might not be // first, make sure everything is calculated - this might not be
// needed, optimise it later // needed, optimise it later
ApplyStyle(m_DefaultSetting, dc); ApplyStyle(&m_DefaultSetting, dc);
while(line) while(line)
{ {
line->RecalculatePosition(this); // so we don't need to do it all the time line->RecalculatePosition(this); // so we don't need to do it all the time
@@ -1575,9 +1537,10 @@ wxLayoutList::Layout(wxDC &dc, CoordType bottom)
// first, make sure everything is calculated - this might not be // first, make sure everything is calculated - this might not be
// needed, optimise it later // needed, optimise it later
ApplyStyle(m_DefaultSetting, dc); ApplyStyle(&m_DefaultSetting, dc);
while(line) while(line)
{ {
line->GetStyleInfo() = m_CurrentSetting;
if(line == m_CursorLine) if(line == m_CursorLine)
line->Layout(dc, this, (wxPoint *)&m_CursorScreenPos, (wxPoint *)&m_CursorSize, m_CursorPos.x); line->Layout(dc, this, (wxPoint *)&m_CursorScreenPos, (wxPoint *)&m_CursorSize, m_CursorPos.x);
else else
@@ -1606,9 +1569,8 @@ wxLayoutList::Draw(wxDC &dc,
{ {
wxLayoutLine *line = m_FirstLine; wxLayoutLine *line = m_FirstLine;
Layout(dc, bottom); ApplyStyle(&m_DefaultSetting, dc);
ApplyStyle(m_DefaultSetting, dc); wxBrush brush(m_DefaultSetting.m_bg, wxSOLID);
wxBrush brush(m_ColourBG, wxSOLID);
dc.SetBrush(brush); dc.SetBrush(brush);
while(line) while(line)
@@ -1638,7 +1600,7 @@ wxLayoutList::FindObjectScreen(wxDC &dc, wxPoint const pos,
wxPoint p; wxPoint p;
// we need to run a layout here to get font sizes right :-( // we need to run a layout here to get font sizes right :-(
ApplyStyle(m_DefaultSetting, dc); ApplyStyle(&m_DefaultSetting, dc);
while(line) while(line)
{ {
p = line->GetPosition(); p = line->GetPosition();
@@ -1892,8 +1854,8 @@ void
wxLayoutList::StartHighlighting(wxDC &dc) wxLayoutList::StartHighlighting(wxDC &dc)
{ {
#if SHOW_SELECTIONS #if SHOW_SELECTIONS
dc.SetTextForeground(m_ColourBG); dc.SetTextForeground(m_CurrentSetting.m_bg);
dc.SetTextBackground(m_ColourFG); dc.SetTextBackground(m_CurrentSetting.m_fg);
#endif #endif
} }
@@ -1902,8 +1864,8 @@ void
wxLayoutList::EndHighlighting(wxDC &dc) wxLayoutList::EndHighlighting(wxDC &dc)
{ {
#if SHOW_SELECTIONS #if SHOW_SELECTIONS
dc.SetTextForeground(m_ColourFG); dc.SetTextForeground(m_CurrentSetting.m_fg);
dc.SetTextBackground(m_ColourBG); dc.SetTextBackground(m_CurrentSetting.m_bg);
#endif #endif
} }
@@ -1979,41 +1941,30 @@ wxLayoutList::GetSelection(void)
#define COPY_SI(what) if(si->what != -1) m_CurrentSetting.what = si->what; #define COPY_SI(what) if(si->what != -1) { m_CurrentSetting.what = si->what; fontChanged = TRUE; }
void void
wxLayoutList::ApplyStyle(wxLayoutStyleInfo *si, wxDC &dc) wxLayoutList::ApplyStyle(wxLayoutStyleInfo *si, wxDC &dc)
{ {
bool fontChanged = FALSE;
COPY_SI(family); COPY_SI(family);
COPY_SI(size); COPY_SI(size);
COPY_SI(style); COPY_SI(style);
COPY_SI(weight); COPY_SI(weight);
COPY_SI(underline); COPY_SI(underline);
if(fontChanged)
dc.SetFont( m_FontCache.GetFont(m_CurrentSetting) );
if(si->m_fg_valid)
if(si->fg_valid)
{ {
m_CurrentSetting.fg_valid = true; m_CurrentSetting.m_fg = si->m_fg;
m_CurrentSetting.fg_red = si->fg_red; dc.SetTextForeground(m_CurrentSetting.m_fg);
m_CurrentSetting.fg_green = si->fg_green;
m_CurrentSetting.fg_blue = si->fg_blue;
} }
if(si->bg_valid) if(si->m_bg_valid)
{ {
m_CurrentSetting.bg_valid = true; m_CurrentSetting.m_bg = si->m_bg;
m_CurrentSetting.bg_red = si->bg_red; dc.SetTextBackground(m_CurrentSetting.m_bg);
m_CurrentSetting.bg_green = si->bg_green;
m_CurrentSetting.bg_blue = si->bg_blue;
} }
m_ColourFG = wxColour(m_CurrentSetting.fg_red,
m_CurrentSetting.fg_green,
m_CurrentSetting.fg_blue);
m_ColourBG = wxColour(m_CurrentSetting.bg_red,
m_CurrentSetting.bg_green,
m_CurrentSetting.bg_blue);
dc.SetTextForeground(m_ColourFG);
dc.SetTextBackground(m_ColourBG);
} }
@@ -2203,3 +2154,18 @@ wxLayoutPrintout::DrawHeader(wxDC &dc,
#endif #endif
wxFont &
wxFontCache::GetFont(int family, int size, int style, int weight,
bool underline)
{
for(wxFCEList::iterator i = m_FontList.begin();
i != m_FontList.end(); i++)
if( (**i).Matches(family, size, style, weight, underline) )
return (**i).GetFont();
// not found:
wxFontCacheEntry *fce = new wxFontCacheEntry(family, size, style,
weight, underline);
m_FontList.push_back(fce);
return fce->GetFont();
}

View File

@@ -290,23 +290,61 @@ struct wxLayoutStyleInfo
int iul = -1, int iul = -1,
wxColour *fg = NULL, wxColour *fg = NULL,
wxColour *bg = NULL); wxColour *bg = NULL);
wxColour * GetBGColour() const wxColour & GetBGColour()
{ {
return fg_valid ? new return m_bg;
wxColour(bg_red,bg_green,bg_blue)
: wxWHITE;
} }
wxFont *GetFont(wxLayoutStyleInfo *); wxLayoutStyleInfo & operator=(const wxLayoutStyleInfo &right);
/// Font change parameters. /// Font change parameters.
int size, family, style, weight, underline; int size, family, style, weight, underline;
/// Is foreground colour valid to bet set? /// Colours
bool fg_valid; wxColour m_bg, m_fg;
/// Is background colour valid to bet set? bool m_fg_valid, m_bg_valid;
bool bg_valid; };
/// Foreground colour RGB values.
unsigned fg_red, fg_green, fg_blue;
/// Background colour RGB values. class wxFontCacheEntry
unsigned bg_red, bg_green, bg_blue; {
public:
wxFontCacheEntry(int family, int size, int style, int weight,
bool underline)
{
m_Family = family; m_Size = size; m_Style = style;
m_Weight = weight; m_Underline = underline;
m_Font = new wxFont(m_Size, m_Family,
m_Style, m_Weight, m_Underline);
}
bool Matches(int family, int size, int style, int weight,
bool underline) const
{
return size == m_Size && family == m_Family
&& style == m_Style && weight == m_Weight
&& underline == m_Underline;
}
wxFont & GetFont(void) { return *m_Font; }
~wxFontCacheEntry()
{
delete m_Font;
}
private:
wxFont *m_Font;
int m_Family, m_Size, m_Style, m_Weight;
bool m_Underline;
};
KBLIST_DEFINE(wxFCEList, wxFontCacheEntry);
class wxFontCache
{
public:
wxFont & GetFont(int family, int size, int style, int weight,
bool underline);
wxFont & GetFont(wxLayoutStyleInfo const &si)
{
return GetFont(si.family, si.size, si.style, si.weight, si.underline);
}
private:
wxFCEList m_FontList;
}; };
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
@@ -325,8 +363,8 @@ public:
class wxLayoutList *wxllist, class wxLayoutList *wxllist,
CoordType begin = -1, CoordType begin = -1,
CoordType end = -1); CoordType end = -1);
wxLayoutObjectCmd(int size = -1, wxLayoutObjectCmd(int family = -1,
int family = -1, int size = -1,
int style = -1, int style = -1,
int weight = -1, int weight = -1,
int underline = -1, int underline = -1,
@@ -339,8 +377,6 @@ public:
*/ */
virtual wxLayoutObject *Copy(void); virtual wxLayoutObject *Copy(void);
private: private:
/// the font to use
wxFont *m_font;
wxLayoutStyleInfo *m_StyleInfo; wxLayoutStyleInfo *m_StyleInfo;
}; };
@@ -566,6 +602,7 @@ public:
#ifdef WXLAYOUT_DEBUG #ifdef WXLAYOUT_DEBUG
void Debug(void); void Debug(void);
#endif #endif
wxLayoutStyleInfo &GetStyleInfo() { return m_StyleInfo; }
private: private:
/// Destructor is private. Use DeleteLine() to remove it. /// Destructor is private. Use DeleteLine() to remove it.
@@ -611,6 +648,8 @@ private:
wxLayoutLine *m_Previous; wxLayoutLine *m_Previous;
/// Pointer to next line if it exists. /// Pointer to next line if it exists.
wxLayoutLine *m_Next; wxLayoutLine *m_Next;
/// A StyleInfo structure, holding the current settings.
wxLayoutStyleInfo m_StyleInfo;
/// Just to suppress gcc compiler warnings. /// Just to suppress gcc compiler warnings.
friend class dummy; friend class dummy;
private: private:
@@ -760,10 +799,10 @@ public:
char const *bg = NULL); char const *bg = NULL);
/// changes to the next larger font size /// changes to the next larger font size
inline void SetFontLarger(void) inline void SetFontLarger(void)
{ SetFont(-1,(12*m_FontPtSize)/10); } { SetFont(-1,(12*m_CurrentSetting.size)/10); }
/// changes to the next smaller font size /// changes to the next smaller font size
inline void SetFontSmaller(void) inline void SetFontSmaller(void)
{ SetFont(-1,(10*m_FontPtSize)/12); } { SetFont(-1,(10*m_CurrentSetting.size)/12); }
/// set font family /// set font family
inline void SetFontFamily(int family) { SetFont(family); } inline void SetFontFamily(int family) { SetFont(family); }
@@ -789,7 +828,7 @@ public:
anywhere. anywhere.
@return the default settings of the list @return the default settings of the list
*/ */
wxLayoutStyleInfo *GetDefaults(void) { return m_DefaultSetting ; } wxLayoutStyleInfo *GetDefaults(void) { return &m_DefaultSetting ; }
wxLayoutStyleInfo *GetStyleInfo(void) { return &m_CurrentSetting ; } wxLayoutStyleInfo *GetStyleInfo(void) { return &m_CurrentSetting ; }
//@} //@}
@@ -914,7 +953,6 @@ public:
*/ */
int IsSelected(const wxLayoutLine *line, CoordType *from, CoordType *to); int IsSelected(const wxLayoutLine *line, CoordType *from, CoordType *to);
void ApplyStyle(wxLayoutStyleInfo *si, wxDC &dc); void ApplyStyle(wxLayoutStyleInfo *si, wxDC &dc);
#ifdef WXLAYOUT_DEBUG #ifdef WXLAYOUT_DEBUG
void Debug(void); void Debug(void);
@@ -954,14 +992,10 @@ private:
} m_Selection; } m_Selection;
/** @name Font parameters. */ /** @name Font parameters. */
//@{ //@{
int m_FontFamily, m_FontStyle, m_FontWeight; /// this object manages the fonts for us
int m_FontPtSize; wxFontCache m_FontCache;
bool m_FontUnderline;
/// colours:
wxColour m_ColourFG;
wxColour m_ColourBG;
/// the default setting: /// the default setting:
wxLayoutStyleInfo *m_DefaultSetting; wxLayoutStyleInfo m_DefaultSetting;
/// the current setting: /// the current setting:
wxLayoutStyleInfo m_CurrentSetting; wxLayoutStyleInfo m_CurrentSetting;
//@} //@}

View File

@@ -77,17 +77,17 @@ wxString wxLayoutExportCmdAsHTML(wxLayoutObjectCmd const & cmd,
html += "<font "; html += "<font ";
if(si->fg_valid) if(si->m_fg_valid)
{ {
html +="color="; html +="color=";
sprintf(buffer,"\"#%02X%02X%02X\"", si->fg_red,si->fg_green,si->fg_blue); sprintf(buffer,"\"#%02X%02X%02X\"", si->m_fg.Red(),si->m_fg.Green(),si->m_fg.Blue());
html += buffer; html += buffer;
} }
if(si->bg_valid) if(si->m_bg_valid)
{ {
html += " bgcolor="; html += " bgcolor=";
sprintf(buffer,"\"#%02X%02X%02X\"", si->bg_red,si->bg_green,si->bg_blue); sprintf(buffer,"\"#%02X%02X%02X\"", si->m_bg.Red(),si->m_bg.Green(),si->m_bg.Blue());
html += buffer; html += buffer;
} }

View File

@@ -115,7 +115,7 @@ wxLayoutWindow::Clear(int family,
wxColour *bg) wxColour *bg)
{ {
GetLayoutList()->Clear(family,size,style,weight,underline,fg,bg); GetLayoutList()->Clear(family,size,style,weight,underline,fg,bg);
SetBackgroundColour(*GetLayoutList()->GetDefaults()->GetBGColour()); SetBackgroundColour(GetLayoutList()->GetDefaults()->GetBGColour());
ResizeScrollbars(true); ResizeScrollbars(true);
SetDirty(); SetDirty();
SetModified(false); SetModified(false);
@@ -494,8 +494,8 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
} }
m_memDC->SetDeviceOrigin(0,0); m_memDC->SetDeviceOrigin(0,0);
m_memDC->SetBrush(wxBrush(*m_llist->GetDefaults()->GetBGColour(),wxSOLID)); m_memDC->SetBrush(wxBrush(m_llist->GetDefaults()->GetBGColour(),wxSOLID));
m_memDC->SetPen(wxPen(*m_llist->GetDefaults()->GetBGColour(), m_memDC->SetPen(wxPen(m_llist->GetDefaults()->GetBGColour(),
0,wxTRANSPARENT)); 0,wxTRANSPARENT));
m_memDC->SetLogicalFunction(wxCOPY); m_memDC->SetLogicalFunction(wxCOPY);