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 commandEvent
.SetClientData((char *)m_FoundObject
);
51 m_ClickPosition
= wxPoint(event
.GetX(), event
.GetY());
52 GetEventHandler()->ProcessEvent(commandEvent
);
58 * some simple keyboard handling
61 wxLayoutWindow::OnChar(wxKeyEvent
& event
)
63 long keyCode
= event
.KeyCode();
65 switch(event
.KeyCode())
68 m_llist
.MoveCursor(1);
71 m_llist
.MoveCursor(-1);
74 m_llist
.MoveCursor(0,-1);
77 m_llist
.MoveCursor(0,1);
80 m_llist
.MoveCursor(0,-20);
83 m_llist
.MoveCursor(0,20);
88 case WXK_BACK
: // backspace
89 m_llist
.MoveCursor(-1);
101 if(keyCode
< 256 && keyCode
>= 32)
114 wxLayoutWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
)w
) // or: OnDraw(wxDC& dc)
116 wxPaintDC
dc( this ); // only when used as OnPaint for OnDraw we
117 PrepareDC( dc
); // can skip the first two lines
119 if(m_EventId
) // look for keyclicks
120 m_FoundObject
= m_llist
.Draw(dc
,true,m_FindPos
);
123 if(! m_ScrollbarsSet
)
125 m_ScrollbarsSet
= true; // avoid recursion
131 wxLayoutWindow::UpdateScrollbars(void)
134 max_x
, max_y
, lineHeight
;
136 m_llist
.GetSize(&max_x
, &max_y
, &lineHeight
);
137 SetScrollbars(10, lineHeight
, max_x
/10+1, max_y
/lineHeight
+1);
138 EnableScrolling(true,true);
142 wxLayoutWindow::Print(void)
144 VAR(wxThePrintSetupData
);
146 wxPostScriptDC
dc("layout.ps",true,this);
147 if (dc
.Ok() && dc
.StartDoc((char *)_("Printing message...")))
149 //dc.SetUserScale(1.0, 1.0);