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
== -1) // 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 if(! m_llist
.IsEditable()) // do nothing
69 long keyCode
= event
.KeyCode();
72 switch(event
.KeyCode())
75 m_llist
.MoveCursor(1);
78 m_llist
.MoveCursor(-1);
81 m_llist
.MoveCursor(0,-1);
84 m_llist
.MoveCursor(0,1);
87 m_llist
.MoveCursor(0,-20);
90 m_llist
.MoveCursor(0,20);
93 p
= m_llist
.GetCursor();
98 p
= m_llist
.GetCursor();
99 p
.x
= m_llist
.GetLineLength(m_llist
.FindCurrentObject(NULL
));
100 m_llist
.SetCursor(p
);
105 case WXK_BACK
: // backspace
106 m_llist
.MoveCursor(-1);
112 #ifdef WXLAYOUT_DEBUG
118 if(keyCode
< 256 && keyCode
>= 32)
131 wxLayoutWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
)w
) // or: OnDraw(wxDC& dc)
133 wxPaintDC
dc( this ); // only when used as OnPaint for OnDraw we
134 PrepareDC( dc
); // can skip the first two lines
136 if(m_EventId
!= -1) // look for keyclicks
137 m_FoundObject
= m_llist
.Draw(dc
,true,m_FindPos
);
140 if(! m_ScrollbarsSet
)
142 m_ScrollbarsSet
= true; // avoid recursion
148 wxLayoutWindow::UpdateScrollbars(void)
151 max_x
, max_y
, lineHeight
;
153 m_llist
.GetSize(&max_x
, &max_y
, &lineHeight
);
154 SetScrollbars(10, lineHeight
, max_x
/10+1, max_y
/lineHeight
+1);
155 EnableScrolling(true,true);
159 wxLayoutWindow::Print(void)
161 VAR(wxThePrintSetupData
);
163 wxPostScriptDC
dc("layout.ps",true,this);
164 if (dc
.Ok() && dc
.StartDoc((char *)_("Printing message...")))
166 //dc.SetUserScale(1.0, 1.0);