New, rewritten, wxLayout. Almost complete.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1873 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*-*- c++ -*-********************************************************
|
||||
* wxLwindow.h : a scrolled Window for displaying/entering rich text*
|
||||
* *
|
||||
* (C) 1998 by Karsten Ball<6C>der (Ballueder@usa.net) *
|
||||
* (C) 1998,1999 by Karsten Ball<6C>der (Ballueder@usa.net) *
|
||||
* *
|
||||
* $Id$
|
||||
*******************************************************************/
|
||||
@@ -18,22 +18,32 @@
|
||||
|
||||
#include "wxllist.h"
|
||||
|
||||
#ifndef WXLOWIN_MENU_FIRST
|
||||
# define WXLOWIN_MENU_FIRST 12000
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
WXLOWIN_MENU_LARGER = 12000,
|
||||
WXLOWIN_MENU_LARGER = WXLOWIN_MENU_FIRST,
|
||||
WXLOWIN_MENU_SMALLER,
|
||||
WXLOWIN_MENU_UNDERLINE,
|
||||
WXLOWIN_MENU_BOLD,
|
||||
WXLOWIN_MENU_ITALICS,
|
||||
WXLOWIN_MENU_UNDERLINE_ON,
|
||||
WXLOWIN_MENU_UNDERLINE_OFF,
|
||||
WXLOWIN_MENU_BOLD_ON,
|
||||
WXLOWIN_MENU_BOLD_OFF,
|
||||
WXLOWIN_MENU_ITALICS_ON,
|
||||
WXLOWIN_MENU_ITALICS_OFF,
|
||||
WXLOWIN_MENU_ROMAN,
|
||||
WXLOWIN_MENU_TYPEWRITER,
|
||||
WXLOWIN_MENU_SANSSERIF,
|
||||
WXLOWIN_MENU_RCLICK,
|
||||
WXLOWIN_MENU_LCLICK,
|
||||
WXLOWIN_MENU_DBLCLICK
|
||||
|
||||
WXLOWIN_MENU_DBLCLICK,
|
||||
WXLOWIN_MENU_LAST = WXLOWIN_MENU_DBLCLICK
|
||||
};
|
||||
|
||||
/**
|
||||
This class is a rich text editing widget.
|
||||
*/
|
||||
class wxLayoutWindow : public wxScrolledWindow
|
||||
{
|
||||
public:
|
||||
@@ -44,90 +54,90 @@ public:
|
||||
|
||||
/// Destructor.
|
||||
virtual ~wxLayoutWindow();
|
||||
|
||||
/* Returns a reference to the wxLayoutList object.
|
||||
@return the list
|
||||
*/
|
||||
wxLayoutList & GetLayoutList(void) { return m_llist; }
|
||||
|
||||
// clears the window and sets default parameters:
|
||||
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")
|
||||
/**@name Editing functionality */
|
||||
//@{
|
||||
/// Clears the window and sets default parameters.
|
||||
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")
|
||||
{
|
||||
GetLayoutList().Clear(family,size,style,weight,underline,fg,bg);
|
||||
SetBackgroundColour( *GetLayoutList().GetDefaults()->GetBGColour());
|
||||
Update();
|
||||
m_bDirty = FALSE;
|
||||
GetLayoutList()->Clear(family,size,style,weight,underline,fg,bg);
|
||||
SetBackgroundColour(*GetLayoutList()->GetDefaults()->GetBGColour());
|
||||
SetDirty();
|
||||
DoPaint();
|
||||
}
|
||||
|
||||
// callbacks
|
||||
// NB: these functions are used as event handlers and must not be virtual
|
||||
void OnPaint(wxPaintEvent &event);
|
||||
void OnLeftMouseClick(wxMouseEvent& event)
|
||||
{ OnMouse(WXLOWIN_MENU_LCLICK, event); }
|
||||
void OnRightMouseClick(wxMouseEvent& event)
|
||||
{ OnMouse(WXLOWIN_MENU_RCLICK, event); }
|
||||
void OnMouseDblClick(wxMouseEvent& event)
|
||||
{ OnMouse(WXLOWIN_MENU_DBLCLICK, event); }
|
||||
|
||||
void OnChar(wxKeyEvent& event);
|
||||
void OnMenu(wxCommandEvent& event);
|
||||
/// Enable or disable editing, i.e. processing of keystrokes.
|
||||
void SetEditable(bool toggle) { m_Editable = toggle; }
|
||||
/// Query whether list can be edited by user.
|
||||
bool IsEditable(void) const { return m_Editable; }
|
||||
|
||||
//@}
|
||||
|
||||
void EnablePopup(bool enable = true) { m_DoPopupMenu = enable; }
|
||||
/// gets called by either Update() or OnPaint()
|
||||
void DoPaint(bool cursoronly = false);
|
||||
|
||||
/** Redraws the window.
|
||||
@param scrollToCursor if true, scroll the window so that the
|
||||
cursor becomes visible
|
||||
*/
|
||||
void DoPaint(bool scrollToCursor = false);
|
||||
|
||||
#ifdef __WXMSW__
|
||||
virtual long MSWGetDlgCode();
|
||||
#endif //MSW
|
||||
|
||||
/// if exact == false, assume 50% extra size for the future
|
||||
void UpdateScrollbars(bool exact = false); // don't change this to true!
|
||||
void Print(wxDC &dc);
|
||||
wxMenu * MakeFormatMenu(void);
|
||||
void ResizeScrollbars(bool exact = false); // don't change this to true!
|
||||
|
||||
/// if the flag is true, we send events when user clicks on embedded objects
|
||||
inline void SetMouseTracking(bool doIt = true) { m_doSendEvents = doIt; }
|
||||
|
||||
// dirty flag access
|
||||
bool IsDirty() const { return m_llist.IsDirty(); }
|
||||
void ResetDirty() { m_llist.ResetDirty(); }
|
||||
/* Returns a pointer to the wxLayoutList object.
|
||||
@return the list
|
||||
*/
|
||||
wxLayoutList * GetLayoutList(void) { return m_llist; }
|
||||
|
||||
/**@name Callbacks */
|
||||
//@{
|
||||
void OnPaint(wxPaintEvent &event);
|
||||
void OnChar(wxKeyEvent& event);
|
||||
void OnMenu(wxCommandEvent& event);
|
||||
void OnLeftMouseClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_LCLICK, event); }
|
||||
void OnRightMouseClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_RCLICK, event); }
|
||||
void OnMouseDblClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_DBLCLICK, event); }
|
||||
void OnSetFocus(wxFocusEvent &ev);
|
||||
void OnKillFocus(wxFocusEvent &ev);
|
||||
//@}
|
||||
|
||||
/// Creates a wxMenu for use as a format popup.
|
||||
static wxMenu * MakeFormatMenu(void);
|
||||
/// Set dirty flag.
|
||||
void SetDirty(void) { m_Dirty = true; }
|
||||
protected:
|
||||
/// Deletes from cursor to end of line.
|
||||
void DeleteToEndOfLine(void);
|
||||
/// Deletes everything left of cursor.
|
||||
void DeleteToBeginOfLine(void);
|
||||
/// Goto end of line.
|
||||
void GotoEndOfLine(void);
|
||||
/// Goto begin of line.
|
||||
void GotoBeginOfLine(void);
|
||||
/// Delete Line
|
||||
void DeleteLine(void);
|
||||
/**@name Dirty flag handling for optimisations. */
|
||||
//@{
|
||||
/// Query whether window needs redrawing.
|
||||
bool IsDirty(void) const { return m_Dirty; }
|
||||
/// Reset dirty flag.
|
||||
void ResetDirty(void) { m_Dirty = false; }
|
||||
//@}
|
||||
protected:
|
||||
/// generic function for mouse events processing
|
||||
void OnMouse(int eventId, wxMouseEvent& event);
|
||||
/// scroll to cursor
|
||||
void ScrollToCursor(void);
|
||||
|
||||
/// repaint if needed
|
||||
void Update(void);
|
||||
|
||||
/// for sending events
|
||||
wxWindow *m_Parent;
|
||||
/// Shall we send events?
|
||||
bool m_doSendEvents;
|
||||
|
||||
/// the layout list to be displayed
|
||||
wxLayoutList m_llist;
|
||||
|
||||
/// Where does the current view start?
|
||||
int m_ViewStartX; int m_ViewStartY;
|
||||
|
||||
/// do we have unsaved data?
|
||||
bool m_bDirty;
|
||||
|
||||
/// Do we currently have the focus?
|
||||
bool m_HaveFocus;
|
||||
/// do we handle clicks of the right mouse button?
|
||||
bool m_DoPopupMenu;
|
||||
/// the menu
|
||||
@@ -139,6 +149,13 @@ protected:
|
||||
int m_maxy;
|
||||
int m_lineHeight;
|
||||
private:
|
||||
/// The layout list to be displayed.
|
||||
wxLayoutList *m_llist;
|
||||
|
||||
/// Can user edit the window?
|
||||
bool m_Editable;
|
||||
/// Is list dirty?
|
||||
bool m_Dirty;
|
||||
wxMemoryDC *m_memDC;
|
||||
wxBitmap *m_bitmap;
|
||||
wxPoint m_bitmapSize;
|
||||
|
Reference in New Issue
Block a user