1 /*-*- c++ -*-********************************************************
2 * wxLwindow.h : a scrolled Window for displaying/entering rich text*
4 * (C) 1998 by Karsten Ballüder (Ballueder@usa.net) *
7 *******************************************************************/
10 # pragma implementation "wxlwindow.h"
13 #include "wxlwindow.h"
15 #define VAR(x) cout << #x"=" << x << endl;
17 BEGIN_EVENT_TABLE(wxLayoutWindow
,wxScrolledWindow
)
18 EVT_PAINT (wxLayoutWindow::OnPaint
)
19 EVT_CHAR (wxLayoutWindow::OnChar
)
20 EVT_LEFT_DOWN(wxLayoutWindow::OnMouse
)
23 wxLayoutWindow::wxLayoutWindow(wxWindow
*parent
)
24 : wxScrolledWindow(parent
)
26 m_ScrollbarsSet
= false;
31 wxLayoutWindow::OnMouse(wxMouseEvent
& event
)
33 if(m_EventId
== 0) // nothing to do
36 m_FindPos
.x
= event
.GetX();
37 m_FindPos
.y
= event
.GetY();
41 cerr
<< "OnMouse: " << m_FindPos
.x
<< ',' << m_FindPos
.y
<< endl
;
48 wxCommandEvent
commandEvent(wxEVENT_TYPE_MENU_COMMAND
, m_EventId
);
49 commandEvent
.SetEventObject( this );
50 GetEventHandler()->ProcessEvent(commandEvent
);
56 * some simple keyboard handling
59 wxLayoutWindow::OnChar(wxKeyEvent
& event
)
61 long keyCode
= event
.KeyCode();
63 switch(event
.KeyCode())
66 m_llist
.MoveCursor(1);
69 m_llist
.MoveCursor(-1);
72 m_llist
.MoveCursor(0,-1);
75 m_llist
.MoveCursor(0,1);
78 m_llist
.MoveCursor(0,-20);
81 m_llist
.MoveCursor(0,20);
86 case WXK_BACK
: // backspace
87 m_llist
.MoveCursor(-1);
99 if(keyCode
< 256 && keyCode
>= 32)
112 wxLayoutWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
)w
) // or: OnDraw(wxDC& dc)
114 wxPaintDC
dc( this ); // only when used as OnPaint for OnDraw we
115 PrepareDC( dc
); // can skip the first two lines
117 if(m_EventId
) // look for keyclicks
118 m_FoundObject
= m_llist
.Draw(dc
,true,m_FindPos
);
121 if(! m_ScrollbarsSet
)
123 m_ScrollbarsSet
= true; // avoid recursion
129 wxLayoutWindow::UpdateScrollbars(void)
132 max_x
, max_y
, lineHeight
;
134 m_llist
.GetSize(&max_x
, &max_y
, &lineHeight
);
135 SetScrollbars(10, lineHeight
, max_x
/10+1, max_y
/lineHeight
+1);
136 EnableScrolling(true,true);
140 wxLayoutWindow::Print(void)
142 wxPostScriptDC
dc("layout.ps",true,this);
143 if (dc
.Ok() && dc
.StartDoc((char *)_("Printing message...")))
145 //dc.SetUserScale(1.0, 1.0);