X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4f08af68b955ae29cab937874ad714752b4bcb51..77c630ca853a557a42408d6ca2ee2ff658ff4708:/user/wxLayout/wxlwindow.h diff --git a/user/wxLayout/wxlwindow.h b/user/wxLayout/wxlwindow.h index cf656ce45c..89d709a728 100644 --- a/user/wxLayout/wxlwindow.h +++ b/user/wxLayout/wxlwindow.h @@ -1,7 +1,7 @@ /*-*- c++ -*-******************************************************** * wxLwindow.h : a scrolled Window for displaying/entering rich text* * * - * (C) 1998 by Karsten Ballüder (Ballueder@usa.net) * + * (C) 1998,1999 by Karsten Ballüder (Ballueder@usa.net) * * * * $Id$ *******************************************************************/ @@ -12,59 +12,162 @@ # pragma interface "wxlwindow.h" #endif -#include +#ifndef USE_PCH +# include +#endif #include "wxllist.h" -#ifdef BROKEN_COMPILER -# define virtual +#ifndef WXLOWIN_MENU_FIRST +# define WXLOWIN_MENU_FIRST 12000 #endif +enum +{ + WXLOWIN_MENU_LARGER = WXLOWIN_MENU_FIRST, + WXLOWIN_MENU_SMALLER, + 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_LAST = WXLOWIN_MENU_DBLCLICK +}; + +/** + This class is a rich text editing widget. +*/ class wxLayoutWindow : public wxScrolledWindow { public: + /** Constructor. + @param parent parent window to display this panel in + */ wxLayoutWindow(wxWindow *parent); - wxLayoutList & GetLayoutList(void) { return m_llist; } + /// Destructor. + virtual ~wxLayoutWindow(); - // 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()); + GetLayoutList()->Clear(family,size,style,weight,underline,fg,bg); + SetBackgroundColour(*GetLayoutList()->GetDefaults()->GetBGColour()); + SetDirty(); + DoPaint(); } - //virtual void OnDraw(wxDC &dc); - void OnPaint(wxPaintEvent &WXUNUSED(event)); - virtual void OnMouse(wxMouseEvent& event); - virtual void OnChar(wxKeyEvent& event); - void UpdateScrollbars(void); - void Print(void); - void Erase(void) - { m_llist.Clear(); Clear(); } - void SetEventId(int id) { m_EventId = id; } - wxPoint const &GetClickPosition(void) const { return - m_ClickPosition; } - virtual ~wxLayoutWindow() {} ; -private: + /// 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; } + + /** Sets the wrap margin. + @param margin set this to 0 to disable it + */ + void SetWrapMargin(CoordType margin) { m_WrapMargin = margin; } + + /** 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 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; } + + /* 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: + /**@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); + /// for sending events wxWindow *m_Parent; - int m_EventId; - /// the layout list to be displayed - wxLayoutList m_llist; - /// have we already set the scrollbars? - bool m_ScrollbarsSet; - /// if we want to find an object: - wxPoint m_FindPos; - wxLayoutObjectBase *m_FoundObject; + /// Shall we send events? + bool m_doSendEvents; + /// Where does the current view start? + int m_ViewStartX; int m_ViewStartY; + /// Do we currently have the focus? + bool m_HaveFocus; + /// do we handle clicks of the right mouse button? + bool m_DoPopupMenu; + /// the menu + wxMenu * m_PopupMenu; + /// for derived classes, set when mouse is clicked wxPoint m_ClickPosition; + /// for scrollbar calculations: + int m_maxx; + int m_maxy; + int m_lineHeight; +private: + /// The layout list to be displayed. + wxLayoutList *m_llist; + + /// Can user edit the window? + bool m_Editable; + /// wrap margin + CoordType m_WrapMargin; + /// Is list dirty? + bool m_Dirty; + wxMemoryDC *m_memDC; + wxBitmap *m_bitmap; + wxPoint m_bitmapSize; + DECLARE_EVENT_TABLE() }; -#ifdef BROKEN_COMPILER -#undef virtual -#endif - #endif