latest sources from M

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@233 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Karsten Ballüder
1998-07-12 15:02:44 +00:00
parent 4414cc1db8
commit 23f641681f
7 changed files with 115 additions and 65 deletions

View File

@@ -31,7 +31,7 @@ IMPLEMENT_APP(MyApp)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
enum ids{ ID_EDIT = 1, ID_ADD_SAMPLE, ID_CLEAR, ID_PRINT, ID_DPRINT, enum ids{ ID_EDIT = 1, ID_ADD_SAMPLE, ID_CLEAR, ID_PRINT, ID_DPRINT,
ID_DEBUG, ID_QUIT, ID_CLICK, ID_HTML, ID_TEXT }; ID_WXLAYOUT_DEBUG, ID_QUIT, ID_CLICK, ID_HTML, ID_TEXT };
IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame ) IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )
@@ -53,7 +53,7 @@ IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )
file_menu->Append( ID_CLEAR, "Clear"); file_menu->Append( ID_CLEAR, "Clear");
file_menu->Append( ID_ADD_SAMPLE, "Example"); file_menu->Append( ID_ADD_SAMPLE, "Example");
file_menu->Append( ID_EDIT, "Edit"); file_menu->Append( ID_EDIT, "Edit");
file_menu->Append( ID_DEBUG, "Debug"); file_menu->Append( ID_WXLAYOUT_DEBUG, "Debug");
file_menu->Append( ID_PRINT, "Print"); file_menu->Append( ID_PRINT, "Print");
file_menu->Append( ID_DPRINT, "Direct Print"); file_menu->Append( ID_DPRINT, "Direct Print");
file_menu->Append( ID_TEXT, "Export Text"); file_menu->Append( ID_TEXT, "Export Text");
@@ -76,16 +76,16 @@ void
MyFrame::AddSampleText(wxLayoutList &llist) MyFrame::AddSampleText(wxLayoutList &llist)
{ {
llist.SetFont(wxROMAN,24,wxNORMAL,wxNORMAL, false); llist.Clear(wxROMAN,16,wxNORMAL,wxNORMAL, false);
llist.Insert("The quick brown fox jumps over the lazy dog."); llist.Insert("The quick brown fox jumps over the lazy dog.");
llist.LineBreak(); llist.LineBreak();
llist.Insert("Hello "); llist.Insert("Hello ");
llist.Insert(new wxLayoutObjectIcon(new wxIcon(Micon_xpm,-1,-1))); llist.Insert(new wxLayoutObjectIcon(new wxIcon(Micon_xpm,-1,-1)));
llist.Insert("World!"); llist.LineBreak();
llist.SetFontWeight(wxBOLD);
llist.Insert("World! ");
llist.SetFontWeight(wxNORMAL);
llist.Insert("The quick brown fox jumps..."); llist.Insert("The quick brown fox jumps...");
llist.LineBreak(); llist.LineBreak();
@@ -113,7 +113,7 @@ MyFrame::AddSampleText(wxLayoutList &llist)
llist.SetFont(-1,-1,-1,-1,-1,"blue"); llist.SetFont(-1,-1,-1,-1,-1,"blue");
llist.Insert("blue"); llist.Insert("blue");
llist.SetFont(-1,-1,-1,-1,-1,"black"); llist.SetFont(-1,-1,-1,-1,-1,"black");
llist.Insert("and "); llist.Insert(" and ");
llist.SetFont(-1,-1,-1,-1,-1,"red","black"); llist.SetFont(-1,-1,-1,-1,-1,"red","black");
llist.Insert("red on black"); llist.Insert("red on black");
llist.SetFont(-1,-1,-1,-1,-1,"black"); llist.SetFont(-1,-1,-1,-1,-1,"black");
@@ -194,7 +194,7 @@ void MyFrame::OnCommand( wxCommandEvent &event )
if (dc.Ok() && dc.StartDoc((char *)_("Printing message..."))) if (dc.Ok() && dc.StartDoc((char *)_("Printing message...")))
{ {
//dc.SetUserScale(1.0, 1.0); //dc.SetUserScale(1.0, 1.0);
llist.Draw(dc); llist.Draw(dc); //,false,wxPoint(0,0),true);
dc.EndDoc(); dc.EndDoc();
} }
} }
@@ -208,7 +208,7 @@ void MyFrame::OnCommand( wxCommandEvent &event )
case ID_CLEAR: case ID_CLEAR:
Clear(); Clear();
break; break;
case ID_DEBUG: case ID_WXLAYOUT_DEBUG:
m_lwin->GetLayoutList().Debug(); m_lwin->GetLayoutList().Debug();
break; break;
case ID_CLICK: case ID_CLICK:

View File

@@ -25,11 +25,13 @@
#include "wxllist.h" #include "wxllist.h"
#include "iostream" #include "iostream"
#define BASELINESTRETCH 12
#define VAR(x) cerr << #x"=" << x << endl; #define VAR(x) cerr << #x"=" << x << endl;
#define DBG_POINT(p) cerr << #p << ": " << p.x << ',' << p.y << endl #define DBG_POINT(p) cerr << #p << ": " << p.x << ',' << p.y << endl
#define TRACE(f) cerr << #f":" << endl; #define TRACE(f) cerr << #f":" << endl;
#ifdef WXDEBUG #ifdef WXLAYOUT_DEBUG
static const char *_t[] = { "invalid", "text", "cmd", "icon", static const char *_t[] = { "invalid", "text", "cmd", "icon",
"linebreak"}; "linebreak"};
@@ -44,7 +46,7 @@ wxLayoutObjectBase::Debug(void)
//-------------------------- wxLayoutObjectText //-------------------------- wxLayoutObjectText
wxLayoutObjectText::wxLayoutObjectText(const wxString &txt) wxLayoutObjectText::wxLayoutObjectText(const String &txt)
{ {
m_Text = txt; m_Text = txt;
m_Width = 0; m_Width = 0;
@@ -64,20 +66,20 @@ wxLayoutObjectText::Draw(wxDC &dc, wxPoint position, CoordType baseLine,
bool draw) bool draw)
{ {
long descent = 0l; long descent = 0l;
dc.GetTextExtent(m_Text,&m_Width, &m_Height, &descent); dc.GetTextExtent(Str(m_Text),&m_Width, &m_Height, &descent);
//FIXME: wxGTK does not set descent to a descent value yet. //FIXME: wxGTK does not set descent to a descent value yet.
if(descent == 0) if(descent == 0)
descent = (2*m_Height)/10; // crude fix descent = (2*m_Height)/10; // crude fix
m_BaseLine = m_Height - descent; m_BaseLine = m_Height - descent;
position.y += baseLine-m_BaseLine; position.y += baseLine-m_BaseLine;
if(draw) if(draw)
dc.DrawText(m_Text,position.x,position.y); dc.DrawText(Str(m_Text),position.x,position.y);
# ifdef WXDEBUG # ifdef WXLAYOUT_DEBUG
// dc.DrawRectangle(position.x, position.y, m_Width, m_Height); // dc.DrawRectangle(position.x, position.y, m_Width, m_Height);
# endif # endif
} }
#ifdef WXDEBUG #ifdef WXLAYOUT_DEBUG
void void
wxLayoutObjectText::Debug(void) wxLayoutObjectText::Debug(void)
{ {
@@ -168,11 +170,14 @@ wxLayoutObjectCmd::Draw(wxDC &dc, wxPoint position, CoordType lineHeight,
wxLayoutList::wxLayoutList() wxLayoutList::wxLayoutList()
{ {
m_DefaultSetting = NULL;
Clear(); Clear();
} }
wxLayoutList::~wxLayoutList() wxLayoutList::~wxLayoutList()
{ {
if(m_DefaultSetting)
delete m_DefaultSetting;
} }
@@ -250,7 +255,7 @@ wxLayoutList::Draw(wxDC &dc, bool findObject, wxPoint const &findCoords)
wxPoint position = wxPoint(0,0); wxPoint position = wxPoint(0,0);
wxPoint position_HeadOfLine; wxPoint position_HeadOfLine;
CoordType baseLine = m_FontPtSize; CoordType baseLine = m_FontPtSize;
CoordType baseLineSkip = (12 * baseLine)/10; CoordType baseLineSkip = (BASELINESTRETCH * baseLine)/10;
// we trace the objects' cursor positions so we can draw the cursor // we trace the objects' cursor positions so we can draw the cursor
wxPoint cursor = wxPoint(0,0); wxPoint cursor = wxPoint(0,0);
@@ -264,6 +269,9 @@ wxLayoutList::Draw(wxDC &dc, bool findObject, wxPoint const &findCoords)
CoordType objBaseLine = baseLine; CoordType objBaseLine = baseLine;
wxLayoutObjectType type; wxLayoutObjectType type;
// used temporarily
wxLayoutObjectText *tobj = NULL;
VAR(findObject); VAR(findCoords.x); VAR(findCoords.y); VAR(findObject); VAR(findCoords.x); VAR(findCoords.y);
// if the cursorobject is a cmd, we need to find the first // if the cursorobject is a cmd, we need to find the first
// printable object: // printable object:
@@ -278,6 +286,9 @@ wxLayoutList::Draw(wxDC &dc, bool findObject, wxPoint const &findCoords)
dc.SetTextForeground( *wxBLACK ); dc.SetTextForeground( *wxBLACK );
dc.SetFont( *wxNORMAL_FONT ); dc.SetFont( *wxNORMAL_FONT );
if(m_DefaultSetting)
m_DefaultSetting->Draw(dc,wxPoint(0,0),0,true);
// we calculate everything for drawing a line, then rewind to the // we calculate everything for drawing a line, then rewind to the
// begin of line and actually draw it // begin of line and actually draw it
i = begin(); i = begin();
@@ -311,12 +322,12 @@ wxLayoutList::Draw(wxDC &dc, bool findObject, wxPoint const &findCoords)
if(type == WXLO_TYPE_TEXT) // special treatment if(type == WXLO_TYPE_TEXT) // special treatment
{ {
long descent = 0l; long width, height; long descent = 0l; long width, height;
wxLayoutObjectText *tobj = (wxLayoutObjectText *)*i; tobj = (wxLayoutObjectText *)*i;
wxString str = tobj->GetText(); String str = tobj->GetText();
VAR(m_CursorPosition.x); VAR(cursor.x); VAR(m_CursorPosition.x); VAR(cursor.x);
str = str.substr(0, cursorOffset); str = str.substr(0, cursorOffset);
VAR(str); VAR(str);
dc.GetTextExtent(str, &width,&height, &descent); dc.GetTextExtent(Str(str), &width,&height, &descent);
VAR(height); VAR(height);
VAR(width); VAR(descent); VAR(width); VAR(descent);
dc.DrawLine(position.x+width, dc.DrawLine(position.x+width,
@@ -386,7 +397,8 @@ wxLayoutList::Draw(wxDC &dc, bool findObject, wxPoint const &findCoords)
position.x = 0; position.x = 0;
position.y += baseLineSkip; position.y += baseLineSkip;
baseLine = m_FontPtSize; baseLine = m_FontPtSize;
baseLineSkip = (12 * baseLine)/10; objBaseLine = baseLine; // not all objects set it
baseLineSkip = (BASELINESTRETCH * baseLine)/10;
headOfLine = i; headOfLine = i;
headOfLine++; headOfLine++;
position_HeadOfLine = position; position_HeadOfLine = position;
@@ -397,7 +409,7 @@ wxLayoutList::Draw(wxDC &dc, bool findObject, wxPoint const &findCoords)
return foundObject; return foundObject;
} }
#ifdef WXDEBUG #ifdef WXLAYOUT_DEBUG
void void
wxLayoutList::Debug(void) wxLayoutList::Debug(void)
{ {
@@ -447,7 +459,7 @@ wxLayoutList::FindObjectCursor(wxPoint const &cpos, CoordType *offset)
CoordType width; CoordType width;
wxLayoutObjectList::iterator i; wxLayoutObjectList::iterator i;
#ifdef WXDEBUG #ifdef WXLAYOUT_DEBUG
cerr << "Looking for object at " << cpos.x << ',' << cpos.y << cerr << "Looking for object at " << cpos.x << ',' << cpos.y <<
endl; endl;
#endif #endif
@@ -474,14 +486,14 @@ wxLayoutList::FindObjectCursor(wxPoint const &cpos, CoordType *offset)
if(offset) if(offset)
*offset = cpos.x-(cursor.x-width); // 0==cursor before *offset = cpos.x-(cursor.x-width); // 0==cursor before
// the object // the object
#ifdef WXDEBUG #ifdef WXLAYOUT_DEBUG
cerr << " found object at " << cursor.x-width << ',' << cerr << " found object at " << cursor.x-width << ',' <<
cursor.y << ", type:" << _t[(*i)->GetType()] <<endl; cursor.y << ", type:" << _t[(*i)->GetType()] <<endl;
#endif #endif
return i; return i;
} }
} }
#ifdef WXDEBUG #ifdef WXLAYOUT_DEBUG
cerr << " not found" << endl; cerr << " not found" << endl;
#endif #endif
return end(); // not found return end(); // not found
@@ -569,7 +581,7 @@ wxLayoutList::MoveCursor(int dx, int dy)
if(m_CursorPosition.x > lineLength) if(m_CursorPosition.x > lineLength)
m_CursorPosition.x = lineLength; m_CursorPosition.x = lineLength;
#ifdef WXDEBUG #ifdef WXLAYOUT_DEBUG
i = FindCurrentObject(&offs); i = FindCurrentObject(&offs);
cerr << "Cursor: " cerr << "Cursor: "
<< m_CursorPosition.x << ',' << m_CursorPosition.x << ','
@@ -609,7 +621,7 @@ wxLayoutList::Delete(CoordType count)
i = FindCurrentObject(&offs); i = FindCurrentObject(&offs);
if(i == end()) if(i == end())
return; return;
#ifdef WXDEBUG #ifdef WXLAYOUT_DEBUG
cerr << "trying to delete: " << _t[(*i)->GetType()] << endl; cerr << "trying to delete: " << _t[(*i)->GetType()] << endl;
#endif #endif
if((*i)->GetType() == WXLO_TYPE_LINEBREAK) if((*i)->GetType() == WXLO_TYPE_LINEBREAK)
@@ -678,11 +690,11 @@ wxLayoutList::Insert(wxLayoutObjectBase *obj)
if((*i)->GetType() == WXLO_TYPE_TEXT && offs != 0 && offs != (*i)->CountPositions()) if((*i)->GetType() == WXLO_TYPE_TEXT && offs != 0 && offs != (*i)->CountPositions())
{ {
wxLayoutObjectText *tobj = (wxLayoutObjectText *) *i; wxLayoutObjectText *tobj = (wxLayoutObjectText *) *i;
#ifdef WXDEBUG #ifdef WXLAYOUT_DEBUG
cerr << "text: '" << tobj->GetText() << "'" << endl; cerr << "text: '" << tobj->GetText() << "'" << endl;
VAR(offs); VAR(offs);
#endif #endif
wxString left = tobj->GetText().substr(0,offs); // get part before cursor String left = tobj->GetText().substr(0,offs); // get part before cursor
VAR(left); VAR(left);
tobj->GetText() = tobj->GetText().substr(offs,(*i)->CountPositions()-offs); // keeps the right half tobj->GetText() = tobj->GetText().substr(offs,(*i)->CountPositions()-offs); // keeps the right half
VAR(tobj->GetText()); VAR(tobj->GetText());
@@ -705,8 +717,9 @@ wxLayoutList::Insert(wxLayoutObjectBase *obj)
} }
void void
wxLayoutList::Insert(wxString const &text) wxLayoutList::Insert(String const &text)
{ {
wxLayoutObjectText *tobj = NULL;
TRACE(Insert(text)); TRACE(Insert(text));
if(! m_Editable) if(! m_Editable)
@@ -718,18 +731,19 @@ wxLayoutList::Insert(wxString const &text)
if(i != end() && (*i)->GetType() == WXLO_TYPE_TEXT) if(i != end() && (*i)->GetType() == WXLO_TYPE_TEXT)
{ // insert into an existing text object: { // insert into an existing text object:
TRACE(inserting into existing object); TRACE(inserting into existing object);
wxLayoutObjectText *tobj = (wxLayoutObjectText *)*i; tobj = (wxLayoutObjectText *)*i ;
wxASSERT(tobj);
tobj->GetText().insert(offs,text); tobj->GetText().insert(offs,text);
} }
else else // check whether the previous object is text:
{ {
// check whether the previous object is text:
wxLayoutObjectList::iterator j = i; wxLayoutObjectList::iterator j = i;
j--; j--;
TRACE(checking previous object); TRACE(checking previous object);
if(0 && j != end() && (*j)->GetType() == WXLO_TYPE_TEXT) if(0 && j != end() && (*j)->GetType() == WXLO_TYPE_TEXT)
{ {
wxLayoutObjectText *tobj = (wxLayoutObjectText *)*i; tobj = (wxLayoutObjectText *)*i;
wxASSERT(tobj);
tobj->GetText()+=text; tobj->GetText()+=text;
} }
else // insert a new text object else // insert a new text object
@@ -765,7 +779,8 @@ wxLayoutList::GetLineLength(wxLayoutObjectList::iterator i)
} }
void void
wxLayoutList::Clear(void) wxLayoutList::Clear(int family, int size, int style, int weight,
int underline, char const *fg, char const *bg)
{ {
wxLayoutObjectList::iterator i = begin(); wxLayoutObjectList::iterator i = begin();
@@ -773,17 +788,24 @@ wxLayoutList::Clear(void)
erase(i); erase(i);
// set defaults // set defaults
m_FontPtSize = 12; m_FontPtSize = size;
m_FontUnderline = false; m_FontUnderline = false;
m_FontFamily = wxDEFAULT; m_FontFamily = family;
m_FontStyle = wxNORMAL; m_FontStyle = style;
m_FontWeight = wxNORMAL; m_FontWeight = weight;
m_ColourFG = wxTheColourDatabase->FindColour("BLACK"); m_ColourFG = wxTheColourDatabase->FindColour(fg);
m_ColourBG = wxTheColourDatabase->FindColour("WHITE"); m_ColourBG = wxTheColourDatabase->FindColour(bg);
m_Position = wxPoint(0,0); m_Position = wxPoint(0,0);
m_CursorPosition = wxPoint(0,0); m_CursorPosition = wxPoint(0,0);
m_MaxLine = 0; m_MaxLine = 0;
m_LineHeight = (12*m_FontPtSize)/10; m_LineHeight = (BASELINESTRETCH*m_FontPtSize)/10;
m_MaxX = 0; m_MaxY = 0; m_MaxX = 0; m_MaxY = 0;
if(m_DefaultSetting)
delete m_DefaultSetting;
m_DefaultSetting = new
wxLayoutObjectCmd(m_FontPtSize,m_FontFamily,m_FontStyle,
m_FontWeight,m_FontUnderline,
m_ColourFG, m_ColourBG);
} }

View File

@@ -16,10 +16,21 @@
#include <wx/wx.h> #include <wx/wx.h>
#ifndef WXDEBUG // skip the following defines if embedded in M application
# define WXDEBUG #ifndef MCONFIG_H
// for testing only:
# define WXLAYOUT_DEBUG
# cdefine USE_STD_STRING
#endif #endif
#ifdef USE_STD_STRING
# include <string>
typedef std::string String;
# define Str(str)(str.c_str())
#else
typedef wxString String;
# define Str(str) str
#endif
enum wxLayoutObjectType { WXLO_TYPE_INVALID, WXLO_TYPE_TEXT, WXLO_TYPE_CMD, WXLO_TYPE_ICON, WXLO_TYPE_LINEBREAK }; enum wxLayoutObjectType { WXLO_TYPE_INVALID, WXLO_TYPE_TEXT, WXLO_TYPE_CMD, WXLO_TYPE_ICON, WXLO_TYPE_LINEBREAK };
@@ -51,8 +62,8 @@ public:
virtual CoordType CountPositions(void) const { return 1; } virtual CoordType CountPositions(void) const { return 1; }
wxLayoutObjectBase() { m_UserData = NULL; } wxLayoutObjectBase() { m_UserData = NULL; }
virtual ~wxLayoutObjectBase() {} virtual ~wxLayoutObjectBase() { if(m_UserData) delete m_UserData; }
#ifdef WXDEBUG #ifdef WXLAYOUT_DEBUG
virtual void Debug(void); virtual void Debug(void);
#endif #endif
@@ -75,18 +86,18 @@ public:
align text objects. align text objects.
*/ */
virtual wxPoint GetSize(CoordType *baseLine) const; virtual wxPoint GetSize(CoordType *baseLine) const;
#ifdef WXDEBUG #ifdef WXLAYOUT_DEBUG
virtual void Debug(void); virtual void Debug(void);
#endif #endif
wxLayoutObjectText(const wxString &txt); wxLayoutObjectText(const String &txt);
virtual CoordType CountPositions(void) const { return strlen(m_Text.c_str()); } virtual CoordType CountPositions(void) const { return strlen(m_Text.c_str()); }
// for editing: // for editing:
wxString & GetText(void) { return m_Text; } String & GetText(void) { return m_Text; }
void SetText(wxString const &text) { m_Text = text; } void SetText(String const &text) { m_Text = text; }
private: private:
wxString m_Text; String m_Text;
/// size of the box containing text /// size of the box containing text
long m_Width, m_Height; long m_Width, m_Height;
/// the position of the baseline counted from the top of the box /// the position of the baseline counted from the top of the box
@@ -162,7 +173,7 @@ public:
/// adds an object: /// adds an object:
void AddObject(wxLayoutObjectBase *obj); void AddObject(wxLayoutObjectBase *obj);
void AddText(wxString const &txt); void AddText(String const &txt);
void LineBreak(void); void LineBreak(void);
void SetFont(int family, int size, int style, void SetFont(int family, int size, int style,
@@ -173,6 +184,14 @@ public:
int weight=-1, int underline = -1, int weight=-1, int underline = -1,
char const *fg = NULL, char const *fg = NULL,
char const *bg = NULL); char const *bg = NULL);
inline void SetFontFamily(int family) { SetFont(family); }
inline void SetFontSize(int size) { SetFont(-1,size); }
inline void SetFontStyle(int style) { SetFont(-1,-1,style); }
inline void SetFontWeight(int weight) { SetFont(-1,-1,-1,weight); }
inline void SetFontUnderline(bool ul) { SetFont(-1,-1,-1,-1,(int)ul); }
inline void SetFontColour(char const *fg, char const *bg = NULL) { SetFont(-1,-1,-1,-1,-1,fg,bg); }
/** Draw the list on a given DC. /** Draw the list on a given DC.
@param findObject if true, return the object occupying the @param findObject if true, return the object occupying the
position specified by coords position specified by coords
@@ -182,7 +201,7 @@ public:
wxLayoutObjectBase *Draw(wxDC &dc, bool findObject = false, wxLayoutObjectBase *Draw(wxDC &dc, bool findObject = false,
wxPoint const &coords = wxPoint(0,0)); wxPoint const &coords = wxPoint(0,0));
#ifdef WXDEBUG #ifdef WXLAYOUT_DEBUG
void Debug(void); void Debug(void);
#endif #endif
@@ -200,9 +219,10 @@ public:
void SetCursor(wxPoint const &p) { m_CursorPosition = p; } void SetCursor(wxPoint const &p) { m_CursorPosition = p; }
/// delete one or more cursor positions /// delete one or more cursor positions
void Delete(CoordType count = 1); void Delete(CoordType count = 1);
void Insert(wxString const &text); void Insert(String const &text);
void Insert(wxLayoutObjectBase *obj); void Insert(wxLayoutObjectBase *obj);
void Clear(void); void Clear(int family = wxROMAN, int size=12, int style=wxNORMAL, int weight=wxNORMAL,
int underline=0, char const *fg="black", char const *bg="white");
//@} //@}
protected: protected:
@@ -213,6 +233,8 @@ protected:
/// colours: /// colours:
wxColour const * m_ColourFG; wxColour const * m_ColourFG;
wxColour const * m_ColourBG; wxColour const * m_ColourBG;
/// the default setting:
wxLayoutObjectCmd *m_DefaultSetting;
/// needs recalculation? /// needs recalculation?
bool m_dirty; bool m_dirty;

View File

@@ -15,7 +15,7 @@
#define BASE_SIZE 12 #define BASE_SIZE 12
void wxLayoutImportText(wxLayoutList &list, wxString const &str) void wxLayoutImportText(wxLayoutList &list, String const &str)
{ {
char * cptr = (char *)str.c_str(); // string gets changed only temporarily char * cptr = (char *)str.c_str(); // string gets changed only temporarily
const char * begin = cptr; const char * begin = cptr;
@@ -39,11 +39,11 @@ void wxLayoutImportText(wxLayoutList &list, wxString const &str)
} }
static static
wxString wxLayoutExportCmdAsHTML(wxLayoutObjectCmd const & cmd, String wxLayoutExportCmdAsHTML(wxLayoutObjectCmd const & cmd,
wxLayoutStyleInfo **lastStylePtr) wxLayoutStyleInfo **lastStylePtr)
{ {
static char buffer[20]; static char buffer[20];
wxString html; String html;
wxLayoutStyleInfo *si = cmd.GetStyle(); wxLayoutStyleInfo *si = cmd.GetStyle();
wxLayoutStyleInfo *last_si = NULL; wxLayoutStyleInfo *last_si = NULL;
@@ -152,7 +152,7 @@ wxString wxLayoutExportCmdAsHTML(wxLayoutObjectCmd const & cmd,
return export; return export;
} }
wxString *str = new wxString(); String *str = new String();
// text must be concatenated // text must be concatenated
while(from != list.end() && WXLO_IS_TEXT(type)) while(from != list.end() && WXLO_IS_TEXT(type))

View File

@@ -36,7 +36,7 @@ struct wxLayoutExportObject
wxLayoutExportType type; wxLayoutExportType type;
union union
{ {
wxString *text; String *text;
wxLayoutObjectBase *object; wxLayoutObjectBase *object;
}content; }content;
~wxLayoutExportObject() ~wxLayoutExportObject()
@@ -47,7 +47,7 @@ struct wxLayoutExportObject
}; };
/// import text into a wxLayoutList (including linefeeds): /// import text into a wxLayoutList (including linefeeds):
void wxLayoutImportText(wxLayoutList &list, wxString const &str); void wxLayoutImportText(wxLayoutList &list, String const &str);
wxLayoutExportObject *wxLayoutExport(wxLayoutList &list, wxLayoutExportObject *wxLayoutExport(wxLayoutList &list,

View File

@@ -37,7 +37,7 @@ wxLayoutWindow::OnMouse(wxMouseEvent& event)
m_FindPos.y = event.GetY(); m_FindPos.y = event.GetY();
m_FoundObject = NULL; m_FoundObject = NULL;
#ifdef WXDEBUG #ifdef WXLAYOUT_DEBUG
cerr << "OnMouse: " << m_FindPos.x << ',' << m_FindPos.y << endl; cerr << "OnMouse: " << m_FindPos.x << ',' << m_FindPos.y << endl;
#endif #endif
Refresh(); Refresh();
@@ -47,6 +47,8 @@ wxLayoutWindow::OnMouse(wxMouseEvent& event)
{ {
wxCommandEvent commandEvent(wxEVENT_TYPE_MENU_COMMAND, m_EventId); wxCommandEvent commandEvent(wxEVENT_TYPE_MENU_COMMAND, m_EventId);
commandEvent.SetEventObject( this ); commandEvent.SetEventObject( this );
commandEvent.SetClientData((char *)m_FoundObject);
m_ClickPosition = wxPoint(event.GetX(), event.GetY());
GetEventHandler()->ProcessEvent(commandEvent); GetEventHandler()->ProcessEvent(commandEvent);
} }
} }
@@ -90,7 +92,7 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
case WXK_RETURN: case WXK_RETURN:
m_llist.LineBreak(); m_llist.LineBreak();
break; break;
#ifdef WXDEBUG #ifdef WXLAYOUT_DEBUG
case WXK_F1: case WXK_F1:
m_llist.Debug(); m_llist.Debug();
break; break;
@@ -98,7 +100,7 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
default: default:
if(keyCode < 256 && keyCode >= 32) if(keyCode < 256 && keyCode >= 32)
{ {
wxString tmp; String tmp;
tmp += keyCode; tmp += keyCode;
m_llist.Insert(tmp); m_llist.Insert(tmp);
} }

View File

@@ -32,7 +32,11 @@ public:
void Erase(void) void Erase(void)
{ m_llist.Clear(); Clear(); } { m_llist.Clear(); Clear(); }
void SetEventId(int id) { m_EventId = id; } void SetEventId(int id) { m_EventId = id; }
wxPoint const &GetClickPosition(void) const { return
m_ClickPosition; }
private: private:
/// for sending events
wxWindow *m_Parent;
int m_EventId; int m_EventId;
/// the layout list to be displayed /// the layout list to be displayed
wxLayoutList m_llist; wxLayoutList m_llist;
@@ -41,7 +45,7 @@ private:
/// if we want to find an object: /// if we want to find an object:
wxPoint m_FindPos; wxPoint m_FindPos;
wxLayoutObjectBase *m_FoundObject; wxLayoutObjectBase *m_FoundObject;
wxPoint m_ClickPosition;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };