1998-06-29 08:44:36 -04:00
|
|
|
|
/*-*- c++ -*-********************************************************
|
|
|
|
|
* wxLwindow.h : a scrolled Window for displaying/entering rich text*
|
|
|
|
|
* *
|
|
|
|
|
* (C) 1998 by Karsten Ball<EFBFBD>der (Ballueder@usa.net) *
|
|
|
|
|
* *
|
|
|
|
|
* $Id$
|
|
|
|
|
*******************************************************************/
|
|
|
|
|
#ifndef WXLWINDOW_H
|
|
|
|
|
#define WXLWINDOW_H
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
# pragma interface "wxlwindow.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
1998-08-12 04:33:34 -04:00
|
|
|
|
#ifndef USE_PCH
|
|
|
|
|
# include <wx/wx.h>
|
|
|
|
|
#endif
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
|
|
|
|
#include "wxllist.h"
|
|
|
|
|
|
1998-10-30 04:50:04 -05:00
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
WXLOWIN_MENU_LARGER = 12000,
|
|
|
|
|
WXLOWIN_MENU_SMALLER,
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
class wxLayoutWindow : public wxScrolledWindow
|
|
|
|
|
{
|
|
|
|
|
public:
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/** Constructor.
|
|
|
|
|
@param parent parent window to display this panel in
|
|
|
|
|
*/
|
1998-06-29 08:44:36 -04:00
|
|
|
|
wxLayoutWindow(wxWindow *parent);
|
|
|
|
|
|
1999-02-08 10:20:38 -05:00
|
|
|
|
/// Destructor.
|
|
|
|
|
virtual ~wxLayoutWindow();
|
|
|
|
|
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/* Returns a reference to the wxLayoutList object.
|
|
|
|
|
@return the list
|
|
|
|
|
*/
|
1998-06-29 08:44:36 -04:00
|
|
|
|
wxLayoutList & GetLayoutList(void) { return m_llist; }
|
|
|
|
|
|
1998-07-29 09:57:51 -04:00
|
|
|
|
// 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());
|
1999-02-08 10:20:38 -05:00
|
|
|
|
Update();
|
1998-10-24 14:08:20 -04:00
|
|
|
|
m_bDirty = FALSE;
|
1998-07-29 09:57:51 -04:00
|
|
|
|
}
|
|
|
|
|
|
1998-08-12 04:33:34 -04:00
|
|
|
|
// callbacks
|
|
|
|
|
// NB: these functions are used as event handlers and must not be virtual
|
1998-10-24 14:08:20 -04:00
|
|
|
|
void OnPaint(wxPaintEvent &event);
|
|
|
|
|
void OnLeftMouseClick(wxMouseEvent& event)
|
1998-10-30 04:50:04 -05:00
|
|
|
|
{ OnMouse(WXLOWIN_MENU_LCLICK, event); }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
void OnRightMouseClick(wxMouseEvent& event)
|
1998-10-30 04:50:04 -05:00
|
|
|
|
{ OnMouse(WXLOWIN_MENU_RCLICK, event); }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
void OnMouseDblClick(wxMouseEvent& event)
|
1998-10-30 04:50:04 -05:00
|
|
|
|
{ OnMouse(WXLOWIN_MENU_DBLCLICK, event); }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
1998-08-12 04:33:34 -04:00
|
|
|
|
void OnChar(wxKeyEvent& event);
|
1998-10-30 04:50:04 -05:00
|
|
|
|
void OnMenu(wxCommandEvent& event);
|
1998-08-12 04:33:34 -04:00
|
|
|
|
|
1998-10-30 04:50:04 -05:00
|
|
|
|
void EnablePopup(bool enable = true) { m_DoPopupMenu = enable; }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// gets called by either Update() or OnPaint()
|
1999-02-08 10:20:38 -05:00
|
|
|
|
void DoPaint(bool cursoronly = false);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
1998-08-12 04:33:34 -04:00
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
|
virtual long MSWGetDlgCode();
|
|
|
|
|
#endif //MSW
|
|
|
|
|
|
1999-02-08 10:20:38 -05:00
|
|
|
|
/// 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);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
|
|
|
|
/// 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(); }
|
|
|
|
|
|
1999-02-08 10:20:38 -05:00
|
|
|
|
void OnSetFocus(wxFocusEvent &ev);
|
|
|
|
|
void OnKillFocus(wxFocusEvent &ev);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
protected:
|
1999-02-08 10:20:38 -05:00
|
|
|
|
/// 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);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// generic function for mouse events processing
|
|
|
|
|
void OnMouse(int eventId, wxMouseEvent& event);
|
1999-02-08 10:20:38 -05:00
|
|
|
|
/// scroll to cursor
|
|
|
|
|
void ScrollToCursor(void);
|
|
|
|
|
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// repaint if needed
|
|
|
|
|
void Update(void);
|
|
|
|
|
|
1998-07-12 11:02:44 -04:00
|
|
|
|
/// for sending events
|
|
|
|
|
wxWindow *m_Parent;
|
1998-10-24 14:08:20 -04:00
|
|
|
|
bool m_doSendEvents;
|
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
/// the layout list to be displayed
|
|
|
|
|
wxLayoutList m_llist;
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
|
|
|
|
/// Where does the current view start?
|
|
|
|
|
int m_ViewStartX; int m_ViewStartY;
|
|
|
|
|
|
|
|
|
|
/// do we have unsaved data?
|
|
|
|
|
bool m_bDirty;
|
1998-08-12 04:33:34 -04:00
|
|
|
|
|
1998-10-30 04:50:04 -05:00
|
|
|
|
/// do we handle clicks of the right mouse button?
|
|
|
|
|
bool m_DoPopupMenu;
|
|
|
|
|
/// the menu
|
|
|
|
|
wxMenu * m_PopupMenu;
|
1999-02-08 10:20:38 -05:00
|
|
|
|
/// for derived classes, set when mouse is clicked
|
|
|
|
|
wxPoint m_ClickPosition;
|
|
|
|
|
/// for scrollbar calculations:
|
|
|
|
|
int m_maxx;
|
|
|
|
|
int m_maxy;
|
|
|
|
|
int m_lineHeight;
|
1998-10-24 14:08:20 -04:00
|
|
|
|
private:
|
1999-02-08 10:20:38 -05:00
|
|
|
|
wxMemoryDC *m_memDC;
|
|
|
|
|
wxBitmap *m_bitmap;
|
|
|
|
|
wxPoint m_bitmapSize;
|
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|