X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6c11b5265004937450f8e08d55b8a1476e1452dd..015e69f36dfbc469eef59456f973d0567e865d70:/samples/richedit/wxlwindow.h?ds=sidebyside diff --git a/samples/richedit/wxlwindow.h b/samples/richedit/wxlwindow.h index 7e4d0ce70f..8958e62fab 100644 --- a/samples/richedit/wxlwindow.h +++ b/samples/richedit/wxlwindow.h @@ -1,7 +1,7 @@ /*-*- c++ -*-******************************************************** * wxLwindow.h : a scrolled Window for displaying/entering rich text* * * - * (C) 1998,1999 by Karsten Ballüder (Ballueder@usa.net) * + * (C) 1998-2000 by Karsten Ballüder (ballueder@gmx.net) * * * * $Id$ *******************************************************************/ @@ -23,24 +23,22 @@ #endif -#define wxUSE_PRIVATE_CLIPBOARD_FORMAT 1 - 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_UNDERLINE, + WXLOWIN_MENU_BOLD, + WXLOWIN_MENU_ITALICS, WXLOWIN_MENU_ROMAN, WXLOWIN_MENU_TYPEWRITER, WXLOWIN_MENU_SANSSERIF, WXLOWIN_MENU_RCLICK, - WXLOWIN_MENU_LCLICK, WXLOWIN_MENU_DBLCLICK, + WXLOWIN_MENU_MDOWN, + WXLOWIN_MENU_LDOWN, + WXLOWIN_MENU_LCLICK = WXLOWIN_MENU_LDOWN, + WXLOWIN_MENU_LUP, WXLOWIN_MENU_MOUSEMOVE, WXLOWIN_MENU_LAST = WXLOWIN_MENU_MOUSEMOVE }; @@ -69,6 +67,11 @@ public: int underline=0, wxColour *fg=NULL, wxColour *bg=NULL); + + /// override base class virtual to also refresh the scrollbar position + virtual void Refresh(bool eraseBackground = TRUE, + const wxRect *rect = (const wxRect *)NULL); + /** Sets a background image, only used on screen, not on printouts. @param bitmap a pointer to a wxBitmap or NULL to remove it */ @@ -78,7 +81,8 @@ public: m_BGbitmap = bitmap; } /// Enable or disable editing, i.e. processing of keystrokes. - void SetEditable(bool toggle) { m_Editable = toggle; } + void SetEditable(bool toggle) + { m_Editable = toggle; SetCursorVisibility(toggle); } /// Query whether list can be edited by user. bool IsEditable(void) const { return m_Editable; } /** Sets cursor visibility, visible=1, invisible=0, @@ -91,17 +95,21 @@ public: m_CursorVisibility = visibility; return v;} /// Pastes text from clipboard. - void Paste(void); + void Paste(bool privateFormat = FALSE, bool usePrimarySelection = FALSE); /** Copies selection to clipboard. @param invalidate used internally, see wxllist.h for details */ - bool Copy(bool invalidate = true); + bool Copy(bool invalidate = true, bool privateFormat = FALSE, bool primary = FALSE); /// Copies selection to clipboard and deletes it. - bool Cut(void); + bool Cut(bool privateFormat = FALSE, bool usePrimary = FALSE); //@} + /// find string in buffer bool Find(const wxString &needle, - wxPoint * fromWhere = NULL); + wxPoint * fromWhere = NULL, + const wxString &configPath = "MsgViewFindString"); + /// find the same string again + bool FindAgain(void); void EnablePopup(bool enable = true) { m_DoPopupMenu = enable; } @@ -110,11 +118,16 @@ public: */ void SetWrapMargin(CoordType margin) { m_WrapMargin = margin; } + /** Toggle wordwrap as we type. + @param on true to activate word wrap + */ + void SetWordWrap(bool on = true) { m_DoWordWrap = on; } + /** Redraws the window. Internally, this stores the parameter and calls a refresh on wxMSW, draws directly on wxGTK. */ - void DoPaint(const wxRect *updateRect = NULL); + void RequestUpdate(const wxRect *updateRect = NULL); /// if exact == false, assume 50% extra size for the future void ResizeScrollbars(bool exact = false); // don't change this to true! @@ -129,12 +142,18 @@ public: /**@name Callbacks */ //@{ + void OnSize(wxSizeEvent &event); void OnPaint(wxPaintEvent &event); void OnChar(wxKeyEvent& event); void OnKeyUp(wxKeyEvent& event); + void OnUpdateMenuUnderline(wxUpdateUIEvent& event); + void OnUpdateMenuBold(wxUpdateUIEvent& event); + void OnUpdateMenuItalic(wxUpdateUIEvent& event); void OnMenu(wxCommandEvent& event); - void OnLeftMouseClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_LCLICK, event); } + void OnLeftMouseDown(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_LDOWN, event); } + void OnLeftMouseUp(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_LUP, event); } void OnRightMouseClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_RCLICK, event); } + void OnMiddleMouseDown(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_MDOWN, event); } void OnMouseDblClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_DBLCLICK, event); } void OnMouseMove(wxMouseEvent &event) { OnMouse(WXLOWIN_MENU_MOUSEMOVE, event) ; } void OnSetFocus(wxFocusEvent &ev); @@ -143,22 +162,9 @@ public: /// Creates a wxMenu for use as a format popup. static wxMenu * MakeFormatMenu(void); - /**@name Dirty flag handling for optimisations. */ - //@{ - /// Set dirty flag. - void SetDirty(void) { m_Dirty = true; } - /// Query whether window needs redrawing. - bool IsDirty(void) const { return m_Dirty; } - /// Reset dirty flag. - void ResetDirty(void) { m_Dirty = false; } - //@} - /// Redraws the window, used by DoPaint() or OnPaint(). + /// Redraws the window, used by RequestUpdate() or OnPaint(). void InternalPaint(const wxRect *updateRect); - /// Has list been modified/edited? - bool IsModified(void) const { return m_Modified; } - /// Mark list as modified or unchanged. - void SetModified(bool modified = true) { m_Modified = modified; } /** Tell window to update a wxStatusBar with UserData labels and cursor positions. @param bar wxStatusBar pointer @@ -172,7 +178,36 @@ public: m_StatusBar = bar; m_StatusFieldLabel = labelfield; m_StatusFieldCursor = cursorfield; } +#ifndef __WXMSW__ + /// Enable or disable focus follow mode under non-MSW + void SetFocusFollowMode(bool enable = TRUE) + { m_FocusFollowMode = enable; } +#endif + + /**@name Modified flag handling, will not get reset by list unless + in Clear() */ + //@{ + /// Set dirty flag. + void SetModified(bool modified = TRUE) { m_Modified = modified; } + /// Query whether window needs redrawing. + bool IsModified(void) const { return m_Modified; } + //@} + + /**@name Dirty flag handling for optimisations. + Normally one should only need to call SetDirty(), e.g. when + manipulating the wxLayoutList directly, so the window will update + itself. ResetDirty() and IsDirty() should only be used + internally. */ + //@{ + /// Set dirty flag. + void SetDirty(void) { m_Dirty = true; m_Modified = true; } + /// 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); @@ -200,10 +235,26 @@ protected: int m_maxx; int m_maxy; int m_lineHeight; + /// do we want automatic word wrap? + bool m_DoWordWrap; + /// wrap margin + CoordType m_WrapMargin; + + /// do we have the corresponding scrollbar? + bool m_hasHScrollbar, + m_hasVScrollbar; + /** Visibility parameter for cursor. 0/1 as expected, -1: visible on demand. */ int m_CursorVisibility; + + bool SetAutoDeleteSelection(bool enable = TRUE) + { + bool old = m_AutoDeleteSelection; + m_AutoDeleteSelection = enable; + return old; + } private: /// The layout list to be displayed. wxLayoutList *m_llist; @@ -211,12 +262,10 @@ private: bool m_Editable; /// Are we currently building a selection with the keyboard? bool m_Selecting; - /// wrap margin - CoordType m_WrapMargin; - /// Is list dirty (for redraws, internal use)? - bool m_Dirty; - /// Has list been edited? - bool m_Modified; + /// Has list changed since last redraw, e.g. in size? + bool m_Dirty; + /// Has the list ever been modified? + bool m_Modified; wxMemoryDC *m_memDC; wxBitmap *m_bitmap; wxPoint m_bitmapSize; @@ -228,6 +277,17 @@ private: int m_StatusFieldCursor; /// a pointer to a bitmap for the background wxBitmap *m_BGbitmap; + /**@name Some configuration options */ + //@{ + /// Do we want to auto-replace the selection with new text? + bool m_AutoDeleteSelection; +#ifndef __WXMSW__ + /// Do we want the focus to follow the mouse? + bool m_FocusFollowMode; +#endif + /// For finding text and finding it again: + wxString m_FindString; +//@} DECLARE_EVENT_TABLE() };