First part of fixes to make this work under MSW.

1. letters actually appear on the screen
2. Clear() works
3. Backspace/Delete in one line works too
4. breaking lines works
5. cursor is now a wxCaret
6. tons of other fixes


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2652 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 1999-06-02 21:26:11 +00:00
parent 379a3b04b9
commit 5bdc3b1d4a
6 changed files with 492 additions and 294 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Program: wxLayout * Program: wxLayout
* *
* Author: Karsten Ballüder * Author: Karsten Ballüder
* *
* Copyright: (C) 1998, Karsten Ballüder <Ballueder@usa.net> * Copyright: (C) 1998, Karsten Ballüder <Ballueder@usa.net>
@ -61,12 +61,12 @@ IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )
MyFrame::MyFrame(void) : MyFrame::MyFrame(void) :
wxFrame( (wxFrame *) NULL, -1, (char *) "wxLayout", wxPoint(20,20), wxSize(600,360) ) wxFrame( (wxFrame *) NULL, -1, (char *) "wxLayout", wxPoint(20,20), wxSize(600,360) )
{ {
CreateStatusBar( 1 ); CreateStatusBar( 2 );
SetStatusText( "wxLayout by Karsten Ballüder." ); SetStatusText( "wxLayout by Karsten Ballüder." );
wxMenuBar *menu_bar = new wxMenuBar(); wxMenuBar *menu_bar = new wxMenuBar();
wxMenu *file_menu = new wxMenu; wxMenu *file_menu = new wxMenu;
file_menu->Append(ID_PRINT, "&Print...", "Print"); file_menu->Append(ID_PRINT, "&Print...", "Print");
file_menu->Append(ID_PRINT_SETUP, "Print &Setup...","Setup printer properties"); file_menu->Append(ID_PRINT_SETUP, "Print &Setup...","Setup printer properties");
@ -102,10 +102,11 @@ MyFrame::MyFrame(void) :
#ifndef __WXMSW__ #ifndef __WXMSW__
menu_bar->Show( TRUE ); menu_bar->Show( TRUE );
#endif // MSW #endif // MSW
SetMenuBar( menu_bar ); SetMenuBar( menu_bar );
m_lwin = new wxLayoutWindow(this); m_lwin = new wxLayoutWindow(this);
m_lwin->SetStatusBar(GetStatusBar(), 0, 1);
m_lwin->SetMouseTracking(true); m_lwin->SetMouseTracking(true);
m_lwin->SetEditable(true); m_lwin->SetEditable(true);
m_lwin->SetWrapMargin(40); m_lwin->SetWrapMargin(40);
@ -122,11 +123,11 @@ MyFrame::AddSampleText(wxLayoutList *llist)
llist->SetFont(-1,-1,-1,-1,-1,"black"); llist->SetFont(-1,-1,-1,-1,-1,"black");
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->SetFont(wxROMAN,16,wxNORMAL,wxNORMAL, false); llist->SetFont(wxROMAN,16,wxNORMAL,wxNORMAL, false);
llist->Insert("--"); llist->Insert("--");
llist->LineBreak(); llist->LineBreak();
llist->SetFont(wxROMAN); llist->SetFont(wxROMAN);
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();
@ -218,7 +219,7 @@ void MyFrame::OnCommand( wxCommandEvent &event )
wxPrinter printer; wxPrinter printer;
wxLayoutPrintout printout(m_lwin->GetLayoutList(),_("M: Printout")); wxLayoutPrintout printout(m_lwin->GetLayoutList(),_("M: Printout"));
if (! printer.Print(this, &printout, TRUE)) if (! printer.Print(this, &printout, TRUE))
wxMessageBox( wxMessageBox(
_("There was a problem with printing the message:\n" _("There was a problem with printing the message:\n"
"perhaps your current printer is not set up correctly?"), "perhaps your current printer is not set up correctly?"),
_("Printing"), wxOK); _("Printing"), wxOK);
@ -314,7 +315,7 @@ void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
if (! printer.Print(this, &printout, TRUE)) if (! printer.Print(this, &printout, TRUE))
wxMessageBox( wxMessageBox(
"There was a problem printing.\nPerhaps your current printer is not set correctly?", "There was a problem printing.\nPerhaps your current printer is not set correctly?",
"Printing", wxOK); "Printing", wxOK);
} }
void MyFrame::OnPrintPS(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnPrintPS(wxCommandEvent& WXUNUSED(event))
@ -340,14 +341,14 @@ void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
// Pass two printout objects: for preview, and possible printing. // Pass two printout objects: for preview, and possible printing.
wxPrintPreview *preview = new wxPrintPreview(new wxPrintPreview *preview = new wxPrintPreview(new
wxLayoutPrintout( wxLayoutPrintout(
m_lwin->GetLayoutList()), new wxLayoutPrintout( m_lwin->GetLayoutList()), & printData); m_lwin->GetLayoutList()), new wxLayoutPrintout( m_lwin->GetLayoutList()), & printData);
if (!preview->Ok()) if (!preview->Ok())
{ {
delete preview; delete preview;
wxMessageBox("There was a problem previewing.\nPerhaps your current printer is not set correctly?", "Previewing", wxOK); wxMessageBox("There was a problem previewing.\nPerhaps your current printer is not set correctly?", "Previewing", wxOK);
return; return;
} }
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650)); wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650));
frame->Centre(wxBOTH); frame->Centre(wxBOTH);
frame->Initialize(); frame->Initialize();
@ -430,7 +431,7 @@ void MyFrame::OnPageSetupPS(wxCommandEvent& WXUNUSED(event))
// MyApp // MyApp
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
MyApp::MyApp(void) : MyApp::MyApp(void) :
wxApp( ) wxApp( )
{ {
}; };

File diff suppressed because it is too large Load Diff

View File

@ -30,6 +30,12 @@
# define WXMENU_LAYOUT_DBLCLICK 1113 # define WXMENU_LAYOUT_DBLCLICK 1113
#endif #endif
// use the wxWindows caret class instead of home grown cursor whenever possible
#ifdef __WXMSW__
#undef WXLAYOUT_USE_CARET
#define WXLAYOUT_USE_CARET 1
#endif // __WXMSW__
// do not enable debug mode within Mahogany // do not enable debug mode within Mahogany
#if defined(__WXDEBUG__) && ! defined(M_BASEDIR) #if defined(__WXDEBUG__) && ! defined(M_BASEDIR)
# define WXLAYOUT_DEBUG # define WXLAYOUT_DEBUG
@ -38,7 +44,7 @@
#ifdef WXLAYOUT_DEBUG #ifdef WXLAYOUT_DEBUG
# define WXLO_TRACE(x) wxLogDebug(x) # define WXLO_TRACE(x) wxLogDebug(x)
#else #else
# define WXLO_TRACE(x) # define WXLO_TRACE(x)
#endif #endif
#define WXLO_DEBUG_URECT 0 #define WXLO_DEBUG_URECT 0
@ -72,20 +78,22 @@ typedef long CoordType;
// Forward declarations. // Forward declarations.
class wxLayoutList; class wxLayoutList;
class wxLayoutLine;
class wxLayoutObject; class wxLayoutObject;
class wxDC;
class wxColour;
class wxFont;
class WXDLLEXPORT wxCaret;
class WXDLLEXPORT wxColour;
class WXDLLEXPORT wxDC;
class WXDLLEXPORT wxFont;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
The wxLayout objects which make up the lines. The wxLayout objects which make up the lines.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/** The base class defining the interface to each object which can be /** The base class defining the interface to each object which can be
part of the layout. Each object needs to draw itself and calculate part of the layout. Each object needs to draw itself and calculate
its size. its size.
*/ */
class wxLayoutObject class wxLayoutObject
@ -118,7 +126,7 @@ public:
@param dc the wxDC to draw on @param dc the wxDC to draw on
@param llist the wxLayoutList @param llist the wxLayoutList
*/ */
virtual void Layout(wxDC &dc, class wxLayoutList *llist) = 0; virtual void Layout(wxDC &dc, wxLayoutList *llist) = 0;
/** Draws an object. /** Draws an object.
@param dc the wxDC to draw on @param dc the wxDC to draw on
@ -129,11 +137,11 @@ public:
*/ */
virtual void Draw(wxDC & /* dc */, virtual void Draw(wxDC & /* dc */,
wxPoint const & /* coords */, wxPoint const & /* coords */,
class wxLayoutList *wxllist, wxLayoutList *wxllist,
CoordType begin = -1, CoordType begin = -1,
CoordType end = -1) { } CoordType end = -1) { }
/** Calculates and returns the size of the object. /** Calculates and returns the size of the object.
@param top where to store height above baseline @param top where to store height above baseline
@param bottom where to store height below baseline @param bottom where to store height below baseline
@return the size of the object's box in pixels @return the size of the object's box in pixels
@ -154,7 +162,7 @@ public:
virtual CoordType GetOffsetScreen(wxDC &dc, CoordType xpos) const { return 0; } virtual CoordType GetOffsetScreen(wxDC &dc, CoordType xpos) const { return 0; }
/// constructor /// constructor
wxLayoutObject() { m_UserData = NULL; } wxLayoutObject() { m_UserData = NULL; m_Line = NULL; }
/// delete the user data /// delete the user data
virtual ~wxLayoutObject() { if(m_UserData) m_UserData->DecRef(); } virtual ~wxLayoutObject() { if(m_UserData) m_UserData->DecRef(); }
@ -174,7 +182,21 @@ public:
if(m_UserData) if(m_UserData)
m_UserData->IncRef(); m_UserData->IncRef();
} }
/// returns the line we belong to (or NULL)
wxLayoutLine *GetLine() const { return m_Line; }
/// attaches this object to the given line, it's an error to reattach us
void AttachToLine(wxLayoutLine *line)
{
wxASSERT_MSG( !m_Line, "this layout object already belongs to a line" );
m_Line = line;
}
/// unattaches the object (should reattach it immediately afterwards!)
void UnattachFromLine() { if ( m_Line ) m_Line = (wxLayoutLine *)NULL; }
/** Return the user data. /** Return the user data.
Increments the object's reference count. When no longer needed, Increments the object's reference count. When no longer needed,
caller must call DecRef() on the pointer returned. caller must call DecRef() on the pointer returned.
@ -199,6 +221,9 @@ public:
protected: protected:
/// optional data for application's use /// optional data for application's use
UserData *m_UserData; UserData *m_UserData;
/// the line of the text we belong to or NULL if we're not shown on screen
wxLayoutLine *m_Line;
}; };
/// Define a list type of wxLayoutObject pointers. /// Define a list type of wxLayoutObject pointers.
@ -209,7 +234,7 @@ KBLIST_DEFINE(wxLayoutObjectList, wxLayoutObject);
/// The iterator type. /// The iterator type.
#define wxLOiterator wxLayoutObjectList::iterator #define wxLOiterator wxLayoutObjectList::iterator
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
wxLayoutObjectText wxLayoutObjectText
@ -220,14 +245,14 @@ class wxLayoutObjectText : public wxLayoutObject
{ {
public: public:
wxLayoutObjectText(const wxString &txt = ""); wxLayoutObjectText(const wxString &txt = "");
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_TEXT; } virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_TEXT; }
virtual void Layout(wxDC &dc, class wxLayoutList *llist); virtual void Layout(wxDC &dc, wxLayoutList *llist);
virtual void Draw(wxDC &dc, wxPoint const &coords, virtual void Draw(wxDC &dc, wxPoint const &coords,
class wxLayoutList *wxllist, wxLayoutList *wxllist,
CoordType begin = -1, CoordType begin = -1,
CoordType end = -1); CoordType end = -1);
/** Calculates and returns the size of the object. /** Calculates and returns the size of the object.
@param top where to store height above baseline @param top where to store height above baseline
@param bottom where to store height below baseline @param bottom where to store height below baseline
@return the size of the object's box in pixels @return the size of the object's box in pixels
@ -268,7 +293,7 @@ private:
long m_Bottom; long m_Bottom;
}; };
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
wxLayoutObjectIcon wxLayoutObjectIcon
@ -284,13 +309,13 @@ public:
~wxLayoutObjectIcon() { if(m_Icon) delete m_Icon; } ~wxLayoutObjectIcon() { if(m_Icon) delete m_Icon; }
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_ICON; } virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_ICON; }
virtual void Layout(wxDC &dc, class wxLayoutList *llist); virtual void Layout(wxDC &dc, wxLayoutList *llist);
virtual void Draw(wxDC &dc, wxPoint const &coords, virtual void Draw(wxDC &dc, wxPoint const &coords,
class wxLayoutList *wxllist, wxLayoutList *wxllist,
CoordType begin = -1, CoordType begin = -1,
CoordType end = -1); CoordType end = -1);
/** Calculates and returns the size of the object. /** Calculates and returns the size of the object.
@param top where to store height above baseline @param top where to store height above baseline
@param bottom where to store height below baseline @param bottom where to store height below baseline
@return the size of the object's box in pixels @return the size of the object's box in pixels
@ -309,7 +334,7 @@ private:
wxBitmap *m_Icon; wxBitmap *m_Icon;
}; };
/** This structure holds all formatting information. Members which are /** This structure holds all formatting information. Members which are
undefined (for a CmdObject this means: no change), are set to -1. undefined (for a CmdObject this means: no change), are set to -1.
*/ */
struct wxLayoutStyleInfo struct wxLayoutStyleInfo
@ -337,7 +362,7 @@ struct wxLayoutStyleInfo
class wxFontCacheEntry class wxFontCacheEntry
{ {
public: public:
wxFontCacheEntry(int family, int size, int style, int weight, wxFontCacheEntry(int family, int size, int style, int weight,
bool underline) bool underline)
{ {
m_Family = family; m_Size = size; m_Style = style; m_Family = family; m_Size = size; m_Style = style;
@ -345,7 +370,7 @@ public:
m_Font = new wxFont(m_Size, m_Family, m_Font = new wxFont(m_Size, m_Family,
m_Style, m_Weight, m_Underline); m_Style, m_Weight, m_Underline);
} }
bool Matches(int family, int size, int style, int weight, bool Matches(int family, int size, int style, int weight,
bool underline) const bool underline) const
{ {
return size == m_Size && family == m_Family return size == m_Size && family == m_Family
@ -368,17 +393,18 @@ KBLIST_DEFINE(wxFCEList, wxFontCacheEntry);
class wxFontCache class wxFontCache
{ {
public: public:
wxFont & GetFont(int family, int size, int style, int weight, wxFont & GetFont(int family, int size, int style, int weight,
bool underline); bool underline);
wxFont & GetFont(wxLayoutStyleInfo const &si) wxFont & GetFont(wxLayoutStyleInfo const &si)
{ {
return GetFont(si.family, si.size, si.style, si.weight, si.underline); return GetFont(si.family, si.size, si.style, si.weight,
si.underline != 0);
} }
private: private:
wxFCEList m_FontList; wxFCEList m_FontList;
}; };
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
wxLayoutObjectCmd wxLayoutObjectCmd
@ -389,9 +415,9 @@ class wxLayoutObjectCmd : public wxLayoutObject
{ {
public: public:
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_CMD; } virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_CMD; }
virtual void Layout(wxDC &dc, class wxLayoutList *llist); virtual void Layout(wxDC &dc, wxLayoutList *llist);
virtual void Draw(wxDC &dc, wxPoint const &coords, virtual void Draw(wxDC &dc, wxPoint const &coords,
class wxLayoutList *wxllist, wxLayoutList *wxllist,
CoordType begin = -1, CoordType begin = -1,
CoordType end = -1); CoordType end = -1);
wxLayoutObjectCmd(int family = -1, wxLayoutObjectCmd(int family = -1,
@ -413,19 +439,16 @@ private:
wxLayoutStyleInfo *m_StyleInfo; wxLayoutStyleInfo *m_StyleInfo;
}; };
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
The wxLayoutLine object The wxLayoutLine object
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/// forward declaration
class wxLayoutList;
/** This class represents a single line of objects to be displayed. /** This class represents a single line of objects to be displayed.
It knows its height and total size and whether it needs to be It knows its height and total size and whether it needs to be
redrawn or not. redrawn or not.
It has pointers to its first and next line so it can automatically It has pointers to its first and next line so it can automatically
update them as needed. update them as needed.
*/ */
class wxLayoutLine class wxLayoutLine
@ -443,7 +466,7 @@ public:
@return true if that xpos existed and the object was inserted @return true if that xpos existed and the object was inserted
*/ */
bool Insert(CoordType xpos, wxLayoutObject *obj); bool Insert(CoordType xpos, wxLayoutObject *obj);
/** This function inserts text at cursor position xpos. /** This function inserts text at cursor position xpos.
@param xpos where to insert @param xpos where to insert
@param text the text to insert @param text the text to insert
@ -457,6 +480,8 @@ public:
void Append(wxLayoutObject * obj) void Append(wxLayoutObject * obj)
{ {
wxASSERT(obj); wxASSERT(obj);
obj->AttachToLine(this);
m_ObjectList.push_back(obj); m_ObjectList.push_back(obj);
m_Length += obj->GetLength(); m_Length += obj->GetLength();
} }
@ -483,20 +508,20 @@ public:
whitespace. whitespace.
This function does not delete over font changes, i.e. a word This function does not delete over font changes, i.e. a word
with formatting instructions in the middle of it is treated as with formatting instructions in the middle of it is treated as
two (three actually!) words. In fact, if the cursor is on a non-text object, that two (three actually!) words. In fact, if the cursor is on a non-text object, that
one is treated as a word. one is treated as a word.
@param xpos from where to delete @param xpos from where to delete
@return true if a word was deleted @return true if a word was deleted
*/ */
bool DeleteWord(CoordType npos); bool DeleteWord(CoordType npos);
/** Finds a suitable position left to the given column to break the /** Finds a suitable position left to the given column to break the
line. line.
@param column we want to break the line to the left of this @param column we want to break the line to the left of this
@return column for breaking line or -1 if no suitable location found @return column for breaking line or -1 if no suitable location found
*/ */
CoordType GetWrapPosition(CoordType column); CoordType GetWrapPosition(CoordType column);
/** Finds the object which covers the cursor position xpos in this /** Finds the object which covers the cursor position xpos in this
line. line.
@param xpos the column number @param xpos the column number
@ -526,8 +551,8 @@ public:
@return the cursoor coord where it was found or -1 @return the cursoor coord where it was found or -1
*/ */
CoordType FindText(const wxString &needle, CoordType xpos = 0) const; CoordType FindText(const wxString &needle, CoordType xpos = 0) const;
/** Get the first object in the list. This is used by the wxlparser /** Get the first object in the list. This is used by the wxlparser
functions to export the list. functions to export the list.
@return iterator to the first object @return iterator to the first object
*/ */
@ -535,7 +560,7 @@ public:
{ {
return m_ObjectList.begin(); return m_ObjectList.begin();
} }
/** Deletes this line, returns pointer to next line. /** Deletes this line, returns pointer to next line.
@param update If true, update all following lines. @param update If true, update all following lines.
*/ */
@ -557,17 +582,17 @@ public:
//@{ //@{
/** Draws the line on a wxDC. /** Draws the line on a wxDC.
@param dc the wxDC to draw on @param dc the wxDC to draw on
@param llist the wxLayoutList @param llist the wxLayoutList
@param offset an optional offset to shift printout @param offset an optional offset to shift printout
*/ */
void Draw(wxDC &dc, void Draw(wxDC &dc,
wxLayoutList *llist, wxLayoutList *llist,
const wxPoint &offset = wxPoint(0,0)) const; const wxPoint &offset = wxPoint(0,0)) const;
/** Recalculates the positions of objects and the height of the /** Recalculates the positions of objects and the height of the
line. line.
@param dc the wxDC to draw on @param dc the wxDC to draw on
@param llist th e wxLayoutList @param llist th e wxLayoutList
@param cursorPos if not NULL, set cursor screen position in there @param cursorPos if not NULL, set cursor screen position in there
@param cursorSize if not cursorPos != NULL, set cursor size in there @param cursorSize if not cursorPos != NULL, set cursor size in there
@param cx if cursorPos != NULL, the cursor x position @param cx if cursorPos != NULL, the cursor x position
@ -631,7 +656,7 @@ public:
void Copy(wxLayoutList *llist, void Copy(wxLayoutList *llist,
CoordType from = 0, CoordType from = 0,
CoordType to = -1); CoordType to = -1);
#ifdef WXLAYOUT_DEBUG #ifdef WXLAYOUT_DEBUG
void Debug(void); void Debug(void);
#endif #endif
@ -695,13 +720,13 @@ private:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
The wxLayoutList object The wxLayoutList object
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/** The wxLayoutList is a list of wxLayoutLine objects. It provides a /** The wxLayoutList is a list of wxLayoutLine objects. It provides a
higher level of abstraction for the text and can generally be considered higher level of abstraction for the text and can generally be considered
as representing "the text". as representing "the text".
*/ */
class wxLayoutList class wxLayoutList
{ {
@ -711,6 +736,11 @@ public:
/// Destructor. /// Destructor.
~wxLayoutList(); ~wxLayoutList();
#ifdef WXLAYOUT_USE_CARET
/// give us the pointer to the caret to use
void SetCaret(wxCaret *caret) { m_caret = caret; }
#endif // WXLAYOUT_USE_CARET
/// Clear the list. /// Clear the list.
void Clear(int family = wxROMAN, void Clear(int family = wxROMAN,
int size=WXLO_DEFAULTFONTSIZE, int size=WXLO_DEFAULTFONTSIZE,
@ -721,7 +751,7 @@ public:
wxColour *bg=NULL); wxColour *bg=NULL);
/// Empty: clear the list but leave font settings. /// Empty: clear the list but leave font settings.
void Empty(void); void Empty(void);
/**@name Cursor Management */ /**@name Cursor Management */
//@{ //@{
/** Set new cursor position. /** Set new cursor position.
@ -744,9 +774,9 @@ public:
void MoveCursorToEndOfLine(void) void MoveCursorToEndOfLine(void)
{ {
wxASSERT(m_CursorLine); wxASSERT(m_CursorLine);
MoveCursorHorizontally(m_CursorLine->GetLength()-m_CursorPos.x); MoveCursorHorizontally(m_CursorLine->GetLength()-m_CursorPos.x);
} }
/// Move cursor to begin of line. /// Move cursor to begin of line.
void MoveCursorToBeginOfLine(void) void MoveCursorToBeginOfLine(void)
{ MoveCursorHorizontally(-m_CursorPos.x); } { MoveCursorHorizontally(-m_CursorPos.x); }
@ -754,7 +784,7 @@ public:
/// Returns current cursor position. /// Returns current cursor position.
const wxPoint &GetCursorPos(wxDC &dc) const { return m_CursorPos; } const wxPoint &GetCursorPos(wxDC &dc) const { return m_CursorPos; }
const wxPoint &GetCursorPos() const { return m_CursorPos; } const wxPoint &GetCursorPos() const { return m_CursorPos; }
//@} //@}
/**@name Editing functions. /**@name Editing functions.
@ -767,7 +797,7 @@ public:
bool Insert(wxLayoutObject *obj); bool Insert(wxLayoutObject *obj);
/// Inserts objects at current cursor positions /// Inserts objects at current cursor positions
bool Insert(wxLayoutList *llist); bool Insert(wxLayoutList *llist);
/// Inserts a linebreak at current cursor position. /// Inserts a linebreak at current cursor position.
bool LineBreak(void); bool LineBreak(void);
/** Wraps the current line. Searches to the left of the cursor to /** Wraps the current line. Searches to the left of the cursor to
@ -788,7 +818,7 @@ public:
@return how many it could not delete @return how many it could not delete
*/ */
int DeleteLines(int n); int DeleteLines(int n);
/// Delete to end of line. /// Delete to end of line.
void DeleteToEndOfLine(void) void DeleteToEndOfLine(void)
{ {
@ -843,7 +873,7 @@ public:
/// 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_CurrentSetting.size)/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); }
/// set font size /// set font size
@ -898,7 +928,7 @@ public:
@param bottom optional y coordinate where to stop calculating @param bottom optional y coordinate where to stop calculating
*/ */
void Recalculate(wxDC &dc, CoordType bottom = -1); void Recalculate(wxDC &dc, CoordType bottom = -1);
/** Returns the size of the list in screen coordinates. /** Returns the size of the list in screen coordinates.
The return value only makes sense after the list has been The return value only makes sense after the list has been
drawn. drawn.
@ -911,7 +941,7 @@ public:
@return cursor position in pixels @return cursor position in pixels
*/ */
wxPoint GetCursorScreenPos(wxDC &dc); wxPoint GetCursorScreenPos(wxDC &dc);
/** Draws the cursor. /** Draws the cursor.
@param active If true, draw a bold cursor to mark window as @param active If true, draw a bold cursor to mark window as
active. active.
@ -944,6 +974,15 @@ public:
*/ */
inline void SetUpdateRect(const wxPoint &p) inline void SetUpdateRect(const wxPoint &p)
{ SetUpdateRect(p.x,p.y); } { SetUpdateRect(p.x,p.y); }
/// adds the cursor position to the update rectangle
void AddCursorPosToUpdateRect()
{
#ifndef WXLAYOUT_USE_CARET
SetUpdateRect(m_CursorScreenPos);
SetUpdateRect(m_CursorScreenPos+m_CursorSize);
//#else - the caret will take care of refreshing itself
#endif // !WXLAYOUT_USE_CARET
}
/// Invalidates the update rectangle. /// Invalidates the update rectangle.
void InvalidateUpdateRect(void) { m_UpdateRectValid = false; } void InvalidateUpdateRect(void) { m_UpdateRectValid = false; }
/// Returns the update rectangle. /// Returns the update rectangle.
@ -977,7 +1016,7 @@ public:
wxLayoutList *GetSelection(class wxLayoutDataObject *wxldo = NULL, bool invalidate = TRUE); wxLayoutList *GetSelection(class wxLayoutDataObject *wxldo = NULL, bool invalidate = TRUE);
/// Delete selected bit /// Delete selected bit
void DeleteSelection(void); void DeleteSelection(void);
wxLayoutList *Copy(const wxPoint &from = wxPoint(0,0), wxLayoutList *Copy(const wxPoint &from = wxPoint(0,0),
const wxPoint &to = wxPoint(-1,-1)); const wxPoint &to = wxPoint(-1,-1));
@ -985,7 +1024,7 @@ public:
void StartHighlighting(wxDC &dc); void StartHighlighting(wxDC &dc);
/// ends highlighting of text for selections /// ends highlighting of text for selections
void EndHighlighting(wxDC &dc); void EndHighlighting(wxDC &dc);
/** Tests whether this layout line is selected and needs /** Tests whether this layout line is selected and needs
highlighting. highlighting.
@param line to test for @param line to test for
@ -993,7 +1032,7 @@ public:
@param to set to last cursorpos to be highlighted (for returncode == -1) @param to set to last cursorpos to be highlighted (for returncode == -1)
@return 0 = not selected, 1 = fully selected, -1 = partially @return 0 = not selected, 1 = fully selected, -1 = partially
selected selected
*/ */
int IsSelected(const wxLayoutLine *line, CoordType *from, CoordType *to); int IsSelected(const wxLayoutLine *line, CoordType *from, CoordType *to);
@ -1007,7 +1046,7 @@ private:
/** Calculates the cursor position on the screen. /** Calculates the cursor position on the screen.
*/ */
void UpdateCursorScreenPos(wxDC &dc); void UpdateCursorScreenPos(wxDC &dc);
/// The list of lines. /// The list of lines.
wxLayoutLine *m_FirstLine; wxLayoutLine *m_FirstLine;
/// The update rectangle which needs to be refreshed: /// The update rectangle which needs to be refreshed:
@ -1018,13 +1057,17 @@ private:
//@{ //@{
/// Where the text cursor (column,line) is. /// Where the text cursor (column,line) is.
wxPoint m_CursorPos; wxPoint m_CursorPos;
/// The size of the cursor.
wxPoint m_CursorSize;
/// Where the cursor should be drawn. /// Where the cursor should be drawn.
wxPoint m_CursorScreenPos; wxPoint m_CursorScreenPos;
/// The line where the cursor is. /// The line where the cursor is.
wxLayoutLine *m_CursorLine; wxLayoutLine *m_CursorLine;
//@} /// The size of the cursor.
wxPoint m_CursorSize;
#ifdef WXLAYOUT_USE_CARET
/// the caret
wxCaret *m_caret;
#endif // WXLAYOUT_USE_CARET
//@}
/// A structure for the selection. /// A structure for the selection.
struct Selection struct Selection
@ -1045,12 +1088,11 @@ private:
//@} //@}
}; };
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
The wxLayoutDataObject for exporting data to the clipboard in our The wxLayoutDataObject for exporting data to the clipboard in our
own format. own format.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
class wxLayoutDataObject : public wxPrivateDataObject class wxLayoutDataObject : public wxPrivateDataObject
{ {
@ -1063,10 +1105,10 @@ public:
}; };
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
The wxLayoutPrintout object for printing within the wxWindows print The wxLayoutPrintout object for printing within the wxWindows print
framework. framework.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/** This class implements a wxPrintout for printing a wxLayoutList within /** This class implements a wxPrintout for printing a wxLayoutList within
the wxWindows printing framework. the wxWindows printing framework.
@ -1083,7 +1125,7 @@ public:
"wxLayout Printout"); "wxLayout Printout");
/// Destructor. /// Destructor.
~wxLayoutPrintout(); ~wxLayoutPrintout();
/** Function which prints the n-th page. /** Function which prints the n-th page.
@param page the page number to print @param page the page number to print
@return bool true if we are not at end of document yet @return bool true if we are not at end of document yet
@ -1114,7 +1156,7 @@ protected:
/* no longer used /* no longer used
virtual void DrawHeader(wxDC &dc, wxPoint topleft, wxPoint bottomright, int pageno); virtual void DrawHeader(wxDC &dc, wxPoint topleft, wxPoint bottomright, int pageno);
*/ */
private: private:
/// The list to print. /// The list to print.
wxLayoutList *m_llist; wxLayoutList *m_llist;

View File

@ -10,7 +10,14 @@
# pragma implementation "wxlparser.h" # pragma implementation "wxlparser.h"
#endif #endif
#include <wx/wxprec.h>
#ifdef __BORLANDC__
# pragma hdrstop
#endif
#include "Mpch.h" #include "Mpch.h"
#ifdef M_PREFIX #ifdef M_PREFIX
# include "gui/wxllist.h" # include "gui/wxllist.h"
# include "gui/wxlparser.h" # include "gui/wxlparser.h"

View File

@ -1,7 +1,7 @@
/*-*- c++ -*-******************************************************** /*-*- c++ -*-********************************************************
* wxLwindow.h : a scrolled Window for displaying/entering rich text* * wxLwindow.h : a scrolled Window for displaying/entering rich text*
* * * *
* (C) 1998, 1999 by Karsten Ballüder (Ballueder@usa.net) * * (C) 1998, 1999 by Karsten Ballüder (Ballueder@usa.net) *
* * * *
* $Id$ * $Id$
*******************************************************************/ *******************************************************************/
@ -11,12 +11,13 @@
#endif #endif
#include "wx/wxprec.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__ #ifdef __BORLANDC__
# pragma hdrstop # pragma hdrstop
#endif #endif
#include "Mpch.h" #include "Mpch.h"
#ifdef M_BASEDIR #ifdef M_BASEDIR
# ifndef USE_PCH # ifndef USE_PCH
# include "Mcommon.h" # include "Mcommon.h"
@ -41,6 +42,10 @@
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/dataobj.h> #include <wx/dataobj.h>
#ifdef WXLAYOUT_USE_CARET
# include <wx/caret.h>
#endif // WXLAYOUT_USE_CARET
#include <ctype.h> #include <ctype.h>
#ifdef WXLAYOUT_DEBUG #ifdef WXLAYOUT_DEBUG
@ -71,8 +76,9 @@ BEGIN_EVENT_TABLE(wxLayoutWindow,wxScrolledWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
wxLayoutWindow::wxLayoutWindow(wxWindow *parent) wxLayoutWindow::wxLayoutWindow(wxWindow *parent)
: wxScrolledWindow(parent, -1, wxDefaultPosition, wxDefaultSize, : wxScrolledWindow(parent, -1,
wxHSCROLL | wxVSCROLL | wxBORDER) wxDefaultPosition, wxDefaultSize,
wxHSCROLL | wxVSCROLL | wxBORDER)
{ {
SetStatusBar(NULL); // don't use statusbar SetStatusBar(NULL); // don't use statusbar
@ -85,6 +91,7 @@ wxLayoutWindow::wxLayoutWindow(wxWindow *parent)
m_bitmap = new wxBitmap(4,4); m_bitmap = new wxBitmap(4,4);
m_bitmapSize = wxPoint(4,4); m_bitmapSize = wxPoint(4,4);
m_llist = new wxLayoutList(); m_llist = new wxLayoutList();
m_BGbitmap = NULL; m_BGbitmap = NULL;
m_ScrollToCursor = false; m_ScrollToCursor = false;
SetWrapMargin(0); SetWrapMargin(0);
@ -93,7 +100,16 @@ wxLayoutWindow::wxLayoutWindow(wxWindow *parent)
EnableScrolling(true,true); EnableScrolling(true,true);
m_maxx = max.x; m_maxy = max.y; m_maxx = max.x; m_maxy = max.y;
m_Selecting = false; m_Selecting = false;
SetCursorVisibility(-1);
#ifdef WXLAYOUT_USE_CARET
// FIXME cursor size shouldn't be hardcoded
wxCaret *caret = new wxCaret(this, 2, 20);
SetCaret(caret);
m_llist->SetCaret(caret);
caret->Show();
#endif // WXLAYOUT_USE_CARET
SetCursorVisibility(-1);
SetCursor(wxCURSOR_IBEAM); SetCursor(wxCURSOR_IBEAM);
SetDirty(); SetDirty();
} }
@ -121,12 +137,8 @@ wxLayoutWindow::Clear(int family,
ResizeScrollbars(true); ResizeScrollbars(true);
SetDirty(); SetDirty();
SetModified(false); SetModified(false);
wxRect r;
int w,h; DoPaint((wxRect *)NULL);
r.x = r.y = 0; GetSize(&w,&h);
r.width = w;
r.height = h;
DoPaint(&r);
} }
#ifdef __WXMSW__ #ifdef __WXMSW__
@ -142,7 +154,7 @@ void
wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event) wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
{ {
wxPaintDC dc( this ); wxPaintDC dc( this );
PrepareDC( dc ); PrepareDC( dc );
SetFocus(); SetFocus();
wxPoint findPos; wxPoint findPos;
@ -173,7 +185,7 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
if(!m_HandCursor) if(!m_HandCursor)
SetCursor(wxCURSOR_HAND); SetCursor(wxCURSOR_HAND);
m_HandCursor = TRUE; m_HandCursor = TRUE;
if(m_StatusBar && m_StatusFieldLabel != -1) if(m_StatusBar && m_StatusFieldLabel != -1)
{ {
const wxString &label = u->GetLabel(); const wxString &label = u->GetLabel();
if(label.Length()) if(label.Length())
@ -186,7 +198,7 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
if(m_HandCursor) if(m_HandCursor)
SetCursor(wxCURSOR_IBEAM); SetCursor(wxCURSOR_IBEAM);
m_HandCursor = FALSE; m_HandCursor = FALSE;
if(m_StatusBar && m_StatusFieldLabel != -1) if(m_StatusBar && m_StatusFieldLabel != -1)
m_StatusBar->SetStatusText("", m_StatusFieldLabel); m_StatusBar->SetStatusText("", m_StatusFieldLabel);
} }
if(event.LeftIsDown()) if(event.LeftIsDown())
@ -195,19 +207,19 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
{ {
m_llist->StartSelection(); m_llist->StartSelection();
m_Selecting = true; m_Selecting = true;
DoPaint(FALSE); DoPaint(FALSE);
} }
else else
{ {
m_llist->ContinueSelection(cursorPos); m_llist->ContinueSelection(cursorPos);
DoPaint(FALSE); DoPaint(FALSE);
} }
} }
if(m_Selecting && ! event.LeftIsDown()) if(m_Selecting && ! event.LeftIsDown())
{ {
m_llist->EndSelection(cursorPos); m_llist->EndSelection(cursorPos);
m_Selecting = false; m_Selecting = false;
DoPaint(FALSE); DoPaint(FALSE);
} }
if(u) u->DecRef(); if(u) u->DecRef();
return; return;
@ -257,7 +269,7 @@ void
wxLayoutWindow::OnChar(wxKeyEvent& event) wxLayoutWindow::OnChar(wxKeyEvent& event)
{ {
int keyCode = event.KeyCode(); int keyCode = event.KeyCode();
#ifdef WXLAYOUT_DEBUG #ifdef WXLAYOUT_DEBUG
if(keyCode == WXK_F1) if(keyCode == WXK_F1)
{ {
@ -289,7 +301,7 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
// If needed, make cursor visible: // If needed, make cursor visible:
if(m_CursorVisibility == -1) if(m_CursorVisibility == -1)
m_CursorVisibility = 1; m_CursorVisibility = 1;
/* These two nested switches work like this: /* These two nested switches work like this:
The first one processes all non-editing keycodes, to move the The first one processes all non-editing keycodes, to move the
cursor, etc. It's default will process all keycodes causing cursor, etc. It's default will process all keycodes causing
@ -323,7 +335,10 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
break; break;
default: default:
if(keyCode == 'c' && event.ControlDown()) if(keyCode == 'c' && event.ControlDown())
{
// this should work even in read-only mode
Copy(); Copy();
}
if( IsEditable() ) if( IsEditable() )
{ {
/* First, handle control keys */ /* First, handle control keys */
@ -353,9 +368,6 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
case 'v': case 'v':
Paste(); Paste();
break; break;
case 'c':
Copy();
break;
case 'x': case 'x':
Cut(); Cut();
break; break;
@ -420,7 +432,7 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
} }
SetDirty(); SetDirty();
SetModified(); SetModified();
}// if(IsEditable()) }// if(IsEditable())
}// first switch() }// first switch()
if(m_Selecting) if(m_Selecting)
{ {
@ -464,14 +476,14 @@ wxLayoutWindow::ScrollToCursor(void)
x0 *= dx; y0 *= dy; x0 *= dx; y0 *= dy;
WXLO_DEBUG(("ScrollToCursor: ViewStart is %d/%d", x0, y0)); WXLO_DEBUG(("ScrollToCursor: ViewStart is %d/%d", x0, y0));
// Get the size of the visible window: // Get the size of the visible window:
GetClientSize(&x1,&y1); GetClientSize(&x1,&y1);
wxASSERT(x1 > 0); wxASSERT(x1 > 0);
wxASSERT(y1 > 0); wxASSERT(y1 > 0);
// As we have the values anyway, use them to avoid unnecessary // As we have the values anyway, use them to avoid unnecessary
// scrollbar updates. // scrollbar updates.
if(x1 > m_maxx) m_maxx = x1; if(x1 > m_maxx) m_maxx = x1;
if(y1 > m_maxy) m_maxy = y1; if(y1 > m_maxy) m_maxy = y1;
/* Make sure that the scrollbars are at a position so that the /* Make sure that the scrollbars are at a position so that the
cursor is visible if we are editing. */ cursor is visible if we are editing. */
@ -513,6 +525,11 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
wxPaintDC dc( this ); wxPaintDC dc( this );
PrepareDC( dc ); PrepareDC( dc );
#ifdef WXLAYOUT_USE_CARET
// hide the caret before drawing anything
GetCaret()->Hide();
#endif // WXLAYOUT_USE_CARET
int x0,y0,x1,y1, dx, dy; int x0,y0,x1,y1, dx, dy;
// Calculate where the top of the visible area is: // Calculate where the top of the visible area is:
@ -526,7 +543,7 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
wxASSERT(y1 > 0); wxASSERT(y1 > 0);
// As we have the values anyway, use them to avoid unnecessary // As we have the values anyway, use them to avoid unnecessary
// scrollbar updates. // scrollbar updates.
if(x1 > m_maxx) m_maxx = x1; if(x1 > m_maxx) m_maxx = x1;
if(y1 > m_maxy) m_maxy = y1; if(y1 > m_maxy) m_maxy = y1;
@ -542,13 +559,13 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
m_llist->Layout(dc); m_llist->Layout(dc);
ResizeScrollbars(); ResizeScrollbars();
} }
/* Check whether the window has grown, if so, we need to reallocate /* Check whether the window has grown, if so, we need to reallocate
the bitmap to be larger. */ the bitmap to be larger. */
if(x1 > m_bitmapSize.x || y1 > m_bitmapSize.y) if(x1 > m_bitmapSize.x || y1 > m_bitmapSize.y)
{ {
wxASSERT(m_bitmapSize.x > 0); wxASSERT(m_bitmapSize.x > 0);
wxASSERT(m_bitmapSize.y > 0); wxASSERT(m_bitmapSize.y > 0);
m_memDC->SelectObject(wxNullBitmap); m_memDC->SelectObject(wxNullBitmap);
delete m_bitmap; delete m_bitmap;
m_bitmapSize = wxPoint(x1,y1); m_bitmapSize = wxPoint(x1,y1);
@ -559,7 +576,7 @@ 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);
/* Either fill the background with the background bitmap, or clear /* Either fill the background with the background bitmap, or clear
@ -582,7 +599,7 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
m_memDC->DrawRectangle(0,0,x1, y1); m_memDC->DrawRectangle(0,0,x1, y1);
} }
/* This is the important bit: we tell the list to draw itself: */ /* This is the important bit: we tell the list to draw itself: */
#if WXLO_DEBUG_URECT #if WXLO_DEBUG_URECT
if(updateRect) if(updateRect)
@ -590,10 +607,10 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld", WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
updateRect->x, updateRect->y, updateRect->x, updateRect->y,
updateRect->x+updateRect->width, updateRect->x+updateRect->width,
updateRect->y+updateRect->height)); updateRect->y+updateRect->height));
} }
#endif #endif
// Device origins on the memDC are suspect, we translate manually // Device origins on the memDC are suspect, we translate manually
// with the translate parameter of Draw(). // with the translate parameter of Draw().
wxPoint offset(-x0+WXLO_XOFFSET,-y0+WXLO_YOFFSET); wxPoint offset(-x0+WXLO_XOFFSET,-y0+WXLO_YOFFSET);
@ -603,8 +620,8 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
// cursor, so that the cursor coordinates get included in the next // cursor, so that the cursor coordinates get included in the next
// update rectangle (although they are drawn on the memDC, this is // update rectangle (although they are drawn on the memDC, this is
// needed to erase it): // needed to erase it):
m_llist->InvalidateUpdateRect(); m_llist->InvalidateUpdateRect();
if(m_CursorVisibility == 1) if(m_CursorVisibility != 0)
m_llist->DrawCursor(*m_memDC, m_llist->DrawCursor(*m_memDC,
m_HaveFocus && IsEditable(), // draw a thick m_HaveFocus && IsEditable(), // draw a thick
// cursor for editable windows with focus // cursor for editable windows with focus
@ -636,12 +653,19 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
dc.Blit(x0,y0,x1,y1,m_memDC,0,0,wxCOPY,FALSE); dc.Blit(x0,y0,x1,y1,m_memDC,0,0,wxCOPY,FALSE);
} }
#ifdef WXLAYOUT_USE_CARET
// show the caret back after everything is redrawn
m_caret->Show();
#endif // WXLAYOUT_USE_CARET
ResetDirty(); ResetDirty();
m_ScrollToCursor = false; m_ScrollToCursor = false;
if(m_StatusBar && m_StatusFieldCursor != -1) if(m_StatusBar && m_StatusFieldCursor != -1)
{ {
wxString label; wxString label;
label.Printf(_("L:%d C:%d"), m_llist->GetCursorPos().x+1, m_llist->GetCursorPos().y+1); label.Printf(_("Ln:%d Col:%d"),
m_llist->GetCursorPos().y+1,
m_llist->GetCursorPos().x+1);
m_StatusBar->SetStatusText(label, m_StatusFieldCursor); m_StatusBar->SetStatusText(label, m_StatusFieldCursor);
} }
} }
@ -652,16 +676,16 @@ wxLayoutWindow::ResizeScrollbars(bool exact)
{ {
wxPoint max = m_llist->GetSize(); wxPoint max = m_llist->GetSize();
WXLO_DEBUG(("ResizeScrollbars: GetSize: %ld, %ld", (long int)max.x, WXLO_DEBUG(("ResizeScrollbars: GetSize: %ld, %ld", (long int)max.x,
(long int) max.y)); (long int) max.y));
if(max.x > m_maxx || max.y > m_maxy if(max.x > m_maxx || max.y > m_maxy
|| max.x > m_maxx-WXLO_ROFFSET || max.y > m_maxy-WXLO_BOFFSET || max.x > m_maxx-WXLO_ROFFSET || max.y > m_maxy-WXLO_BOFFSET
|| exact) || exact)
{ {
if(! exact) if(! exact)
{ {
// add an extra bit to the sizes to avoid future updates // add an extra bit to the sizes to avoid future updates
max.x = max.x+WXLO_ROFFSET; max.x = max.x+WXLO_ROFFSET;
max.y = max.y+WXLO_BOFFSET; max.y = max.y+WXLO_BOFFSET;
} }
ViewStart(&m_ViewStartX, &m_ViewStartY); ViewStart(&m_ViewStartX, &m_ViewStartY);
@ -684,7 +708,7 @@ wxLayoutWindow::Paste(void)
{ {
} }
//FIXME: missing functionality m_llist->Insert(wxldo.GetList()); //FIXME: missing functionality m_llist->Insert(wxldo.GetList());
} }
else else
#endif #endif
{ {
@ -698,6 +722,7 @@ wxLayoutWindow::Paste(void)
} }
wxTheClipboard->Close(); wxTheClipboard->Close();
} }
#if 0 #if 0
/* My attempt to get the primary selection, but it does not /* My attempt to get the primary selection, but it does not
work. :-( */ work. :-( */
@ -746,7 +771,7 @@ wxLayoutWindow::Copy(bool invalidate)
else if(len > 1 && text[len-1] == '\n') else if(len > 1 && text[len-1] == '\n')
text = text.Mid(0,len-1); text = text.Mid(0,len-1);
} }
if (wxTheClipboard->Open()) if (wxTheClipboard->Open())
{ {
@ -758,6 +783,7 @@ wxLayoutWindow::Copy(bool invalidate)
wxTheClipboard->Close(); wxTheClipboard->Close();
return rc; return rc;
} }
return FALSE; return FALSE;
} }
@ -777,7 +803,7 @@ wxLayoutWindow::Find(const wxString &needle,
wxPoint * fromWhere) wxPoint * fromWhere)
{ {
wxPoint found; wxPoint found;
if(fromWhere == NULL) if(fromWhere == NULL)
found = m_llist->FindText(needle, m_llist->GetCursorPos()); found = m_llist->FindText(needle, m_llist->GetCursorPos());
else else

View File

@ -23,7 +23,7 @@
#endif #endif
#define wxUSE_PRIVATE_CLIPBOARD_FORMAT 0 #define wxUSE_PRIVATE_CLIPBOARD_FORMAT 1
enum enum
{ {