]> git.saurik.com Git - wxWidgets.git/blob - user/wxLayout/wxlwindow.cpp
5d36dfa9a314b588c9235c89c71e962053bca83b
[wxWidgets.git] / user / wxLayout / wxlwindow.cpp
1 /*-*- c++ -*-********************************************************
2 * wxLwindow.h : a scrolled Window for displaying/entering rich text*
3 * *
4 * (C) 1998, 1999 by Karsten Ballüder (Ballueder@usa.net) *
5 * *
6 * $Id$
7 *******************************************************************/
8
9 #ifdef __GNUG__
10 # pragma implementation "wxlwindow.h"
11 #endif
12
13 #include "wx/wxprec.h"
14 #ifdef __BORLANDC__
15 # pragma hdrstop
16 #endif
17
18
19 #include "Mpch.h"
20 #ifdef M_BASEDIR
21 # ifndef USE_PCH
22 # include "Mcommon.h"
23 # include "gui/wxMenuDefs.h"
24 # include "gui/wxMApp.h"
25 # endif // USE_PCH
26 # include "gui/wxlwindow.h"
27 # include "gui/wxlparser.h"
28 #else
29 # ifdef __WXMSW__
30 # include <windows.h>
31 # undef FindWindow
32 # undef GetCharWidth
33 # undef StartDoc
34 # endif
35
36 # include "wxlwindow.h"
37 # include "wxlparser.h"
38 #endif
39
40 #include <wx/clipbrd.h>
41 #include <wx/textctrl.h>
42 #include <wx/dataobj.h>
43
44 #include <ctype.h>
45
46 #ifdef WXLAYOUT_DEBUG
47 # define WXLO_DEBUG(x) wxLogDebug x
48 #else
49 # define WXLO_DEBUG(x)
50 #endif
51
52 /// offsets to put a nice frame around text
53 #define WXLO_XOFFSET 4
54 #define WXLO_YOFFSET 4
55
56 /// offset to the right and bottom for when to redraw scrollbars
57 #define WXLO_ROFFSET 20
58 #define WXLO_BOFFSET 20
59
60 BEGIN_EVENT_TABLE(wxLayoutWindow,wxScrolledWindow)
61 EVT_PAINT (wxLayoutWindow::OnPaint)
62 EVT_CHAR (wxLayoutWindow::OnChar)
63 EVT_KEY_UP (wxLayoutWindow::OnKeyUp)
64 EVT_LEFT_DOWN(wxLayoutWindow::OnLeftMouseClick)
65 EVT_RIGHT_DOWN(wxLayoutWindow::OnRightMouseClick)
66 EVT_LEFT_DCLICK(wxLayoutWindow::OnMouseDblClick)
67 EVT_MOTION (wxLayoutWindow::OnMouseMove)
68 EVT_MENU_RANGE(WXLOWIN_MENU_FIRST, WXLOWIN_MENU_LAST, wxLayoutWindow::OnMenu)
69 EVT_SET_FOCUS(wxLayoutWindow::OnSetFocus)
70 EVT_KILL_FOCUS(wxLayoutWindow::OnKillFocus)
71 END_EVENT_TABLE()
72
73 wxLayoutWindow::wxLayoutWindow(wxWindow *parent)
74 : wxScrolledWindow(parent, -1, wxDefaultPosition, wxDefaultSize,
75 wxHSCROLL | wxVSCROLL | wxBORDER)
76
77 {
78 m_Editable = false;
79 m_doSendEvents = false;
80 m_ViewStartX = 0; m_ViewStartY = 0;
81 m_DoPopupMenu = true;
82 m_PopupMenu = MakeFormatMenu();
83 m_memDC = new wxMemoryDC;
84 m_bitmap = new wxBitmap(4,4);
85 m_bitmapSize = wxPoint(4,4);
86 m_llist = new wxLayoutList();
87 m_BGbitmap = NULL;
88 m_ScrollToCursor = false;
89 SetWrapMargin(0);
90 wxPoint max = m_llist->GetSize();
91 SetScrollbars(10, 20 /*lineHeight*/, max.x/10+1, max.y/20+1);
92 EnableScrolling(true,true);
93 m_maxx = max.x; m_maxy = max.y;
94 m_Selecting = false;
95 SetCursor(wxCURSOR_IBEAM);
96 SetDirty();
97 }
98
99 wxLayoutWindow::~wxLayoutWindow()
100 {
101 delete m_memDC; // deletes bitmap automatically (?)
102 delete m_bitmap;
103 delete m_llist;
104 delete m_PopupMenu;
105 SetBackgroundBitmap(NULL);
106 }
107
108 void
109 wxLayoutWindow::Clear(int family,
110 int size,
111 int style,
112 int weight,
113 int underline,
114 wxColour *fg,
115 wxColour *bg)
116 {
117 GetLayoutList()->Clear(family,size,style,weight,underline,fg,bg);
118 SetBackgroundColour(*GetLayoutList()->GetDefaults()->GetBGColour());
119 ResizeScrollbars(true);
120 SetDirty();
121 SetModified(false);
122 wxRect r;
123 int w,h;
124 r.x = r.y = 0; GetSize(&w,&h);
125 r.width = w;
126 r.height = h;
127 DoPaint(&r);
128 }
129
130 #ifdef __WXMSW__
131 long
132 wxLayoutWindow::MSWGetDlgCode()
133 {
134 // if we don't return this, we won't get OnChar() events for TABs and ENTER
135 return DLGC_WANTCHARS | DLGC_WANTARROWS | DLGC_WANTMESSAGE;
136 }
137 #endif //MSW
138
139 void
140 wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
141 {
142 wxPaintDC dc( this );
143 PrepareDC( dc );
144 SetFocus();
145
146 wxPoint findPos;
147 findPos.x = dc.DeviceToLogicalX(event.GetX());
148 findPos.y = dc.DeviceToLogicalY(event.GetY());
149
150 findPos.x -= WXLO_XOFFSET;
151 findPos.y -= WXLO_YOFFSET;
152
153 if(findPos.x < 0) findPos.x = 0;
154 if(findPos.y < 0) findPos.y = 0;
155
156 m_ClickPosition = wxPoint(event.GetX(), event.GetY());
157
158 wxPoint cursorPos;
159 bool found;
160 wxLayoutObject *obj = m_llist->FindObjectScreen(dc, findPos,
161 &cursorPos, &found);
162
163 //has the mouse only been moved?
164 if(eventId == WXLOWIN_MENU_MOUSEMOVE)
165 {
166 // found is only true if we are really over an object, not just
167 // behind it
168 if(found && obj && obj->GetUserData() != NULL)
169 {
170 if(!m_HandCursor)
171 SetCursor(wxCURSOR_HAND);
172 m_HandCursor = TRUE;
173 }
174 else
175 {
176 if(m_HandCursor)
177 SetCursor(wxCURSOR_IBEAM);
178 m_HandCursor = FALSE;
179 }
180 return;
181 }
182
183 // always move cursor to mouse click:
184 if(obj && eventId == WXLOWIN_MENU_LCLICK)
185 {
186 m_llist->MoveCursorTo(cursorPos);
187 ScrollToCursor();
188 Refresh(FALSE); // DoPaint suppresses flicker under GTK
189 }
190 if(!m_doSendEvents) // nothing to do
191 return;
192
193 // only do the menu if activated, editable and not on a clickable object
194 if(eventId == WXLOWIN_MENU_RCLICK
195 && IsEditable()
196 && (! obj || (obj && obj->GetUserData() == NULL))
197 )
198 {
199 PopupMenu(m_PopupMenu, m_ClickPosition.x, m_ClickPosition.y);
200 return;
201 }
202 // find the object at this position
203 if(obj)
204 {
205 wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, eventId);
206 commandEvent.SetEventObject( this );
207 commandEvent.SetClientData((char *)obj);
208 GetEventHandler()->ProcessEvent(commandEvent);
209 }
210 }
211
212 /*
213 * Some simple keyboard handling.
214 */
215 void
216 wxLayoutWindow::OnChar(wxKeyEvent& event)
217 {
218 int keyCode = event.KeyCode();
219
220 #ifdef WXLAYOUT_DEBUG
221 if(keyCode == WXK_F1)
222 {
223 m_llist->Debug();
224 return;
225 }
226 #endif
227
228 if(! m_Selecting && event.ShiftDown())
229 {
230 switch(keyCode)
231 {
232 case WXK_UP:
233 case WXK_DOWN:
234 case WXK_RIGHT:
235 case WXK_LEFT:
236 case WXK_PRIOR:
237 case WXK_NEXT:
238 case WXK_HOME:
239 case WXK_END:
240 m_Selecting = true;
241 m_llist->StartSelection();
242 break;
243 default:
244 ;
245 }
246 }
247
248 /* These two nested switches work like this:
249 The first one processes all non-editing keycodes, to move the
250 cursor, etc. It's default will process all keycodes causing
251 modifications to the buffer, but only if editing is allowed.
252 */
253 switch(keyCode)
254 {
255 case WXK_RIGHT:
256 m_llist->MoveCursorHorizontally(1);
257 break;
258 case WXK_LEFT:
259 m_llist->MoveCursorHorizontally(-1);
260 break;
261 case WXK_UP:
262 m_llist->MoveCursorVertically(-1);
263 break;
264 case WXK_DOWN:
265 m_llist->MoveCursorVertically(1);
266 break;
267 case WXK_PRIOR:
268 m_llist->MoveCursorVertically(-20);
269 break;
270 case WXK_NEXT:
271 m_llist->MoveCursorVertically(20);
272 break;
273 case WXK_HOME:
274 m_llist->MoveCursorToBeginOfLine();
275 break;
276 case WXK_END:
277 m_llist->MoveCursorToEndOfLine();
278 break;
279 default:
280 if(keyCode == 'c' && event.ControlDown())
281 Copy();
282 if( IsEditable() )
283 {
284 /* First, handle control keys */
285 if(event.ControlDown() && ! event.AltDown())
286 {
287 switch(keyCode)
288 {
289 case WXK_DELETE :
290 case 'd':
291 m_llist->Delete(1);
292 break;
293 case 'y':
294 m_llist->DeleteLines(1);
295 break;
296 case 'h': // like backspace
297 if(m_llist->MoveCursorHorizontally(-1)) m_llist->Delete(1);
298 break;
299 case 'u':
300 m_llist->DeleteToBeginOfLine();
301 break;
302 case 'k':
303 m_llist->DeleteToEndOfLine();
304 break;
305 case 'v':
306 Paste();
307 break;
308 #ifdef WXLAYOUT_DEBUG
309 case WXK_F1:
310 m_llist->SetFont(-1,-1,-1,-1,true); // underlined
311 break;
312 #endif
313 default:
314 ;
315 }
316 }
317 // ALT only:
318 else if( event.AltDown() && ! event.ControlDown() )
319 {
320 switch(keyCode)
321 {
322 case WXK_DELETE:
323 case 'd':
324 m_llist->DeleteWord();
325 break;
326 default:
327 ;
328 }
329 }
330 // no control keys:
331 else if ( ! event.AltDown() && ! event.ControlDown())
332 {
333 switch(keyCode)
334 {
335 case WXK_INSERT:
336 if(event.ShiftDown())
337 Paste();
338 break;
339 case WXK_DELETE :
340 m_llist->Delete(1);
341 break;
342 case WXK_BACK: // backspace
343 if(m_llist->MoveCursorHorizontally(-1)) m_llist->Delete(1);
344 break;
345 case WXK_RETURN:
346 if(m_WrapMargin > 0)
347 m_llist->WrapLine(m_WrapMargin);
348 m_llist->LineBreak();
349 break;
350 default:
351 if((!(event.ControlDown() || event.AltDown() || event.MetaDown()))
352 && (keyCode < 256 && keyCode >= 32)
353 )
354 {
355 wxString tmp;
356 tmp += keyCode;
357 if(m_WrapMargin > 0 && isspace(keyCode))
358 m_llist->WrapLine(m_WrapMargin);
359 m_llist->Insert(tmp);
360 }
361 break;
362 }
363 }
364 SetDirty();
365 SetModified();
366 }// if(IsEditable())
367 }// first switch()
368 if(m_Selecting)
369 {
370 if(event.ShiftDown())
371 m_llist->ContinueSelection();
372 else
373 {
374 m_llist->EndSelection();
375 m_Selecting = false;
376 }
377 }
378
379 ScrollToCursor();
380 wxRect r = *m_llist->GetUpdateRect();
381 DoPaint(&r);
382 }
383
384 void
385 wxLayoutWindow::OnKeyUp(wxKeyEvent& event)
386 {
387 if(event.KeyCode() == WXK_SHIFT && m_llist->IsSelecting())
388 m_llist->EndSelection();
389 event.Skip();
390 }
391
392
393 void
394 wxLayoutWindow::ScrollToCursor(void)
395 {
396 wxClientDC dc( this );
397 PrepareDC( dc );
398
399 int x0,y0,x1,y1, dx, dy;
400
401 // Calculate where the top of the visible area is:
402 ViewStart(&x0,&y0);
403 GetScrollPixelsPerUnit(&dx, &dy);
404 x0 *= dx; y0 *= dy;
405
406 // Get the size of the visible window:
407 GetClientSize(&x1,&y1);
408 wxASSERT(x1 > 0);
409 wxASSERT(y1 > 0);
410 // As we have the values anyway, use them to avoid unnecessary
411 // scrollbar updates.
412 if(x1 > m_maxx) m_maxx = x1;
413 if(y1 > m_maxy) m_maxy = y1;
414 /* Make sure that the scrollbars are at a position so that the
415 cursor is visible if we are editing. */
416 /** Scroll so that cursor is visible! */
417 WXLO_DEBUG(("m_ScrollToCursor = %d", (int) m_ScrollToCursor));
418 wxPoint cc = m_llist->GetCursorScreenPos(*m_memDC);
419 if(cc.x < x0 || cc.y < y0
420 || cc.x >= x0+(9*x1)/10 || cc.y >= y0+(9*y1/10)) // (9*x)/10 == 90%
421 {
422 int nx, ny;
423 nx = cc.x - x1/2; if(nx < 0) nx = 0;
424 ny = cc.y - y1/2; if(ny < 0) ny = 0;
425 Scroll(nx/dx,ny/dy); // new view start
426 x0 = nx; y0 = ny;
427 m_ScrollToCursor = false; // avoid recursion
428 }
429 }
430
431 void
432 wxLayoutWindow::OnPaint( wxPaintEvent &WXUNUSED(event)) // or: OnDraw(wxDC& dc)
433 {
434 wxRect region = GetUpdateRegion().GetBox();
435 InternalPaint(& region);
436 }
437
438 void
439 wxLayoutWindow::DoPaint(const wxRect *updateRect)
440 {
441 #ifdef __WXGTK__
442 InternalPaint(updateRect);
443 #else
444 Refresh(FALSE, updateRect); // Causes bad flicker under wxGTK!!!
445 #endif
446 }
447
448 void
449 wxLayoutWindow::InternalPaint(const wxRect *updateRect)
450 {
451 wxPaintDC dc( this );
452 PrepareDC( dc );
453
454 int x0,y0,x1,y1, dx, dy;
455
456 // Calculate where the top of the visible area is:
457 ViewStart(&x0,&y0);
458 GetScrollPixelsPerUnit(&dx, &dy);
459 x0 *= dx; y0 *= dy;
460
461 // Get the size of the visible window:
462 GetClientSize(&x1,&y1);
463 wxASSERT(x1 > 0);
464 wxASSERT(y1 > 0);
465 // As we have the values anyway, use them to avoid unnecessary
466 // scrollbar updates.
467 if(x1 > m_maxx) m_maxx = x1;
468 if(y1 > m_maxy) m_maxy = y1;
469
470 WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
471 updateRect->x, updateRect->y,
472 updateRect->x+updateRect->width,
473 updateRect->y+updateRect->height));
474
475 if(IsDirty())
476 {
477 //FIXME m_llist->Layout(dc);
478 ResizeScrollbars();
479 }
480 /* Check whether the window has grown, if so, we need to reallocate
481 the bitmap to be larger. */
482 if(x1 > m_bitmapSize.x || y1 > m_bitmapSize.y)
483 {
484 wxASSERT(m_bitmapSize.x > 0);
485 wxASSERT(m_bitmapSize.y > 0);
486
487 m_memDC->SelectObject(wxNullBitmap);
488 delete m_bitmap;
489 m_bitmapSize = wxPoint(x1,y1);
490 m_bitmap = new wxBitmap(x1,y1);
491 m_memDC->SelectObject(*m_bitmap);
492 }
493
494 m_memDC->SetDeviceOrigin(0,0);
495 m_memDC->SetBrush(wxBrush(*m_llist->GetDefaults()->GetBGColour(),wxSOLID));
496 m_memDC->SetPen(wxPen(*m_llist->GetDefaults()->GetBGColour(),
497 0,wxTRANSPARENT));
498 m_memDC->SetLogicalFunction(wxCOPY);
499
500 /* Either fill the background with the background bitmap, or clear
501 it. */
502 if(m_BGbitmap)
503 {
504 CoordType
505 y, x,
506 w = m_BGbitmap->GetWidth(),
507 h = m_BGbitmap->GetHeight();
508 for(y = 0; y < y1; y+=h)
509 for(x = 0; x < x1; x+=w)
510 m_memDC->DrawBitmap(*m_BGbitmap, x, y);
511 m_memDC->SetBackgroundMode(wxTRANSPARENT);
512 }
513 else
514 {
515 // clear the background: (must not be done if we use the update rectangle!)
516 m_memDC->SetBackgroundMode(wxSOLID);
517 m_memDC->DrawRectangle(0,0,x1, y1);
518 }
519
520
521 /* This is the important bit: we tell the list to draw itself: */
522 #if WXLO_DEBUG_URECT
523 WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
524 updateRect->x, updateRect->y,
525 updateRect->x+updateRect->width,
526 updateRect->y+updateRect->height));
527 #endif
528
529 // Device origins on the memDC are suspect, we translate manually
530 // with the translate parameter of Draw().
531 wxPoint offset(-x0+WXLO_XOFFSET,-y0+WXLO_YOFFSET);
532 m_llist->Draw(*m_memDC,offset, y0, y0+y1);
533
534 // We start calculating a new update rect before drawing the
535 // cursor, so that the cursor coordinates get included in the next
536 // update rectangle (although they are drawn on the memDC, this is
537 // needed to erase it):
538 m_llist->InvalidateUpdateRect();
539 m_llist->DrawCursor(*m_memDC,
540 m_HaveFocus && IsEditable(), // draw a thick
541 // cursor for editable windows with focus
542 offset);
543
544 // Now copy everything to the screen:
545 #if 0
546 // This somehow doesn't work, but even the following bit with the
547 // whole rect at once is still a bit broken I think.
548 wxRegionIterator ri ( GetUpdateRegion() );
549 if(ri)
550 while(ri)
551 {
552 WXLO_DEBUG(("UpdateRegion: %ld,%ld, %ld,%ld",
553 ri.GetX(),ri.GetY(),ri.GetW(),ri.GetH()));
554 dc.Blit(x0+ri.GetX(),y0+ri.GetY(),ri.GetW(),ri.GetH(),
555 m_memDC,ri.GetX(),ri.GetY(),wxCOPY,FALSE);
556 ri++;
557 }
558 else
559 #endif
560 {
561 // FIXME: Trying to copy only the changed parts, but it does not seem
562 // to work:
563 // x0 = updateRect->x; y0 = updateRect->y;
564 // if(updateRect->height < y1)
565 // y1 = updateRect->height;
566 // y1 += WXLO_YOFFSET; //FIXME might not be needed
567 dc.Blit(x0,y0,x1,y1,m_memDC,0,0,wxCOPY,FALSE);
568 }
569
570 ResetDirty();
571 m_ScrollToCursor = false;
572 }
573
574 // change the range and position of scrollbars
575 void
576 wxLayoutWindow::ResizeScrollbars(bool exact)
577 {
578 wxPoint max = m_llist->GetSize();
579
580 if(max.x > m_maxx || max.y > m_maxy
581 || max.x > m_maxx-WXLO_ROFFSET || max.y > m_maxy-WXLO_BOFFSET
582 || exact)
583 {
584 if(! exact)
585 {
586 // add an extra bit to the sizes to avoid future updates
587 max.x = max.x+WXLO_ROFFSET;
588 max.y = max.y+WXLO_BOFFSET;
589 }
590 ViewStart(&m_ViewStartX, &m_ViewStartY);
591 SetScrollbars(10, 20, max.x/10+1,max.y/20+1,m_ViewStartX,m_ViewStartY,true);
592 m_maxx = max.x; m_maxy = max.y;
593 }
594 }
595
596 void
597 wxLayoutWindow::Paste(void)
598 {
599 wxString text;
600 // Read some text
601 if (wxTheClipboard->Open())
602 {
603 wxTextDataObject data;
604 if (wxTheClipboard->IsSupported( data.GetFormat() ))
605 {
606 wxTheClipboard->GetData(&data);
607 text += data.GetText();
608 }
609 wxTheClipboard->Close();
610 }
611 #if 0
612 /* My attempt to get the primary selection, but it does not
613 work. :-( */
614 if(text.Length() == 0)
615 {
616 wxTextCtrl tmp_tctrl(this,-1);
617 tmp_tctrl.Paste();
618 text += tmp_tctrl.GetValue();
619 }
620 #endif
621 wxLayoutImportText( m_llist, text);
622 }
623
624 bool
625 wxLayoutWindow::Copy(void)
626 {
627 // Calling GetSelection() will automatically do an EndSelection()
628 // on the list, but we need to take a note of it, too:
629 if(m_Selecting)
630 {
631 m_Selecting = false;
632 m_llist->EndSelection();
633 }
634 wxLayoutList *llist = m_llist->GetSelection();
635 if(! llist)
636 return FALSE;
637
638 wxString text;
639 wxLayoutExportObject *export;
640 wxLayoutExportStatus status(llist);
641 while((export = wxLayoutExport( &status, WXLO_EXPORT_AS_TEXT)) != NULL)
642 {
643 if(export->type == WXLO_EXPORT_TEXT)
644 text << *(export->content.text);
645 delete export;
646 }
647 delete llist;
648
649 // The exporter always appends a newline, so we chop it off if it
650 // is there:
651 {
652 size_t len = text.Length();
653 if(len > 2 && text[len-2] == '\r') // Windows
654 text = text.Mid(0,len-2);
655 else if(len > 1 && text[len-1] == '\n')
656 text = text.Mid(0,len-1);
657 }
658
659 // Read some text
660 if (wxTheClipboard->Open())
661 {
662 wxTextDataObject *data = new wxTextDataObject( text );
663 bool rc = wxTheClipboard->SetData( data );
664 wxTheClipboard->Close();
665 return rc;
666 }
667 return FALSE;
668 }
669
670 bool
671 wxLayoutWindow::Cut(void)
672 {
673 if(Copy())
674 {
675 m_llist->DeleteSelection();
676 return TRUE;
677 }
678 else
679 return FALSE;
680 }
681
682 wxMenu *
683 wxLayoutWindow::MakeFormatMenu()
684 {
685 wxMenu *m = new wxMenu(_("Layout Menu"));
686
687 m->Append(WXLOWIN_MENU_LARGER ,_("&Larger"),_("Switch to larger font."), false);
688 m->Append(WXLOWIN_MENU_SMALLER ,_("&Smaller"),_("Switch to smaller font."), false);
689 m->AppendSeparator();
690 m->Append(WXLOWIN_MENU_UNDERLINE_ON, _("&Underline on"),_("Activate underline mode."), false);
691 m->Append(WXLOWIN_MENU_UNDERLINE_OFF,_("&Underline off"),_("Deactivate underline mode."), false);
692 m->Append(WXLOWIN_MENU_BOLD_ON ,_("&Bold on"),_("Activate bold mode."), false);
693 m->Append(WXLOWIN_MENU_BOLD_OFF ,_("&Bold off"),_("Deactivate bold mode."), false);
694 m->Append(WXLOWIN_MENU_ITALICS_ON ,_("&Italics on"),_("Activate italics mode."), false);
695 m->Append(WXLOWIN_MENU_ITALICS_OFF ,_("&Italics off"),_("Deactivate italics mode."), false);
696 m->AppendSeparator();
697 m->Append(WXLOWIN_MENU_ROMAN ,_("&Roman"),_("Switch to roman font."), false);
698 m->Append(WXLOWIN_MENU_TYPEWRITER,_("&Typewriter"),_("Switch to typewriter font."), false);
699 m->Append(WXLOWIN_MENU_SANSSERIF ,_("&Sans Serif"),_("Switch to sans serif font."), false);
700 return m;
701 }
702
703 void wxLayoutWindow::OnMenu(wxCommandEvent& event)
704 {
705 switch (event.GetId())
706 {
707 case WXLOWIN_MENU_LARGER:
708 m_llist->SetFontLarger(); break;
709 case WXLOWIN_MENU_SMALLER:
710 m_llist->SetFontSmaller(); break;
711 case WXLOWIN_MENU_UNDERLINE_ON:
712 m_llist->SetFontUnderline(true); break;
713 case WXLOWIN_MENU_UNDERLINE_OFF:
714 m_llist->SetFontUnderline(false); break;
715 case WXLOWIN_MENU_BOLD_ON:
716 m_llist->SetFontWeight(wxBOLD); break;
717 case WXLOWIN_MENU_BOLD_OFF:
718 m_llist->SetFontWeight(wxNORMAL); break;
719 case WXLOWIN_MENU_ITALICS_ON:
720 m_llist->SetFontStyle(wxITALIC); break;
721 case WXLOWIN_MENU_ITALICS_OFF:
722 m_llist->SetFontStyle(wxNORMAL); break;
723 case WXLOWIN_MENU_ROMAN:
724 m_llist->SetFontFamily(wxROMAN); break;
725 case WXLOWIN_MENU_TYPEWRITER:
726 m_llist->SetFontFamily(wxFIXED); break;
727 case WXLOWIN_MENU_SANSSERIF:
728 m_llist->SetFontFamily(wxSWISS); break;
729 }
730 }
731
732 void
733 wxLayoutWindow::OnSetFocus(wxFocusEvent &ev)
734 {
735 m_HaveFocus = true;
736 //FIXME: need argument DoPaint(); // to repaint the cursor
737 }
738
739 void
740 wxLayoutWindow::OnKillFocus(wxFocusEvent &ev)
741 {
742 m_HaveFocus = false;
743 //FIXME: need argument DoPaint(); // to repaint the cursor
744 }