1 /*-*- c++ -*-********************************************************
2 * wxLwindow.h : a scrolled Window for displaying/entering rich text*
4 * (C) 1998, 1999 by Karsten Ballüder (Ballueder@usa.net) *
7 *******************************************************************/
9 // ===========================================================================
11 // ===========================================================================
13 // ----------------------------------------------------------------------------
15 // ----------------------------------------------------------------------------
18 # pragma implementation "wxlwindow.h"
21 #include "wx/wxprec.h"
32 # include "gui/wxMenuDefs.h"
33 # include "gui/wxMApp.h"
35 # include "gui/wxlwindow.h"
36 # include "gui/wxlparser.h"
39 # include <wx/msw/private.h>
42 # include "wxlwindow.h"
43 # include "wxlparser.h"
46 #include <wx/clipbrd.h>
47 #include <wx/textctrl.h>
48 #include <wx/dataobj.h>
50 #ifdef WXLAYOUT_USE_CARET
51 # include <wx/caret.h>
52 #endif // WXLAYOUT_USE_CARET
56 // ----------------------------------------------------------------------------
58 // ----------------------------------------------------------------------------
61 # define WXLO_DEBUG(x) wxLogDebug x
63 # define WXLO_DEBUG(x)
66 // ----------------------------------------------------------------------------
68 // ----------------------------------------------------------------------------
70 /// offsets to put a nice frame around text
71 #define WXLO_XOFFSET 4
72 #define WXLO_YOFFSET 4
74 /// offset to the right and bottom for when to redraw scrollbars
75 #define WXLO_ROFFSET 20
76 #define WXLO_BOFFSET 20
78 /// the size of one scrollbar page in pixels
79 static const int X_SCROLL_PAGE
= 10;
80 static const int Y_SCROLL_PAGE
= 20;
82 // ----------------------------------------------------------------------------
84 // ----------------------------------------------------------------------------
86 BEGIN_EVENT_TABLE(wxLayoutWindow
,wxScrolledWindow
)
87 EVT_PAINT (wxLayoutWindow::OnPaint
)
88 EVT_CHAR (wxLayoutWindow::OnChar
)
89 EVT_KEY_UP (wxLayoutWindow::OnKeyUp
)
90 EVT_LEFT_DOWN(wxLayoutWindow::OnLeftMouseClick
)
91 EVT_RIGHT_DOWN(wxLayoutWindow::OnRightMouseClick
)
92 EVT_LEFT_DCLICK(wxLayoutWindow::OnMouseDblClick
)
93 EVT_MOTION (wxLayoutWindow::OnMouseMove
)
94 EVT_MENU_RANGE(WXLOWIN_MENU_FIRST
, WXLOWIN_MENU_LAST
, wxLayoutWindow::OnMenu
)
95 EVT_SET_FOCUS(wxLayoutWindow::OnSetFocus
)
96 EVT_KILL_FOCUS(wxLayoutWindow::OnKillFocus
)
99 // ===========================================================================
101 // ===========================================================================
103 /* LEAVE IT HERE UNTIL WXGTK WORKS AGAIN!!! */
104 /// allows me to compare to wxPoints
105 static bool operator != (wxPoint
const &p1
, wxPoint
const &p2
)
107 return p1
.x
!= p2
.x
|| p1
.y
!= p2
.y
;
110 // ----------------------------------------------------------------------------
112 // ----------------------------------------------------------------------------
114 wxLayoutWindow::wxLayoutWindow(wxWindow
*parent
)
115 : wxScrolledWindow(parent
, -1,
116 wxDefaultPosition
, wxDefaultSize
,
117 wxHSCROLL
| wxVSCROLL
|
119 //FIXME |wxWANTS_CHARS
122 SetStatusBar(NULL
); // don't use statusbar
124 m_doSendEvents
= false;
125 m_ViewStartX
= 0; m_ViewStartY
= 0;
126 m_DoPopupMenu
= true;
127 m_PopupMenu
= MakeFormatMenu();
128 m_memDC
= new wxMemoryDC
;
129 m_bitmap
= new wxBitmap(4,4);
130 m_bitmapSize
= wxPoint(4,4);
131 m_llist
= new wxLayoutList();
134 m_ScrollToCursor
= false;
136 wxPoint max
= m_llist
->GetSize();
137 SetScrollbars(X_SCROLL_PAGE
, Y_SCROLL_PAGE
,
138 max
.x
/ X_SCROLL_PAGE
+ 1, max
.y
/ Y_SCROLL_PAGE
+ 1);
139 EnableScrolling(true, true);
140 m_maxx
= max
.x
+ X_SCROLL_PAGE
;
141 m_maxy
= max
.y
+ Y_SCROLL_PAGE
;
144 #ifdef WXLAYOUT_USE_CARET
145 // FIXME cursor size shouldn't be hardcoded
146 wxCaret
*caret
= new wxCaret(this, 2, 20);
148 m_llist
->SetCaret(caret
);
150 #endif // WXLAYOUT_USE_CARET
152 SetCursorVisibility(-1);
153 SetCursor(wxCURSOR_IBEAM
);
157 wxLayoutWindow::~wxLayoutWindow()
159 delete m_memDC
; // deletes bitmap automatically (?)
163 SetBackgroundBitmap(NULL
);
167 wxLayoutWindow::Clear(int family
,
175 GetLayoutList()->Clear(family
,size
,style
,weight
,underline
,fg
,bg
);
176 SetBackgroundColour(GetLayoutList()->GetDefaultStyleInfo().GetBGColour());
177 ResizeScrollbars(true);
180 wxScrolledWindow::Clear();
181 DoPaint((wxRect
*)NULL
);
185 wxLayoutWindow::OnMouse(int eventId
, wxMouseEvent
& event
)
187 wxClientDC
dc( this );
189 if ( eventId
!= WXLOWIN_MENU_MOUSEMOVE
)
191 // moving the mouse in a window shouldn't give it the focus!
196 findPos
.x
= dc
.DeviceToLogicalX(event
.GetX());
197 findPos
.y
= dc
.DeviceToLogicalY(event
.GetY());
199 findPos
.x
-= WXLO_XOFFSET
;
200 findPos
.y
-= WXLO_YOFFSET
;
202 if(findPos
.x
< 0) findPos
.x
= 0;
203 if(findPos
.y
< 0) findPos
.y
= 0;
205 m_ClickPosition
= wxPoint(event
.GetX(), event
.GetY());
209 wxLayoutObject
*obj
= m_llist
->FindObjectScreen(dc
, findPos
,
211 wxLayoutObject::UserData
*u
= obj
? obj
->GetUserData() : NULL
;
213 //has the mouse only been moved?
214 if(eventId
== WXLOWIN_MENU_MOUSEMOVE
)
216 // found is only true if we are really over an object, not just
218 if(found
&& u
&& ! m_Selecting
)
221 SetCursor(wxCURSOR_HAND
);
223 if(m_StatusBar
&& m_StatusFieldLabel
!= -1)
225 const wxString
&label
= u
->GetLabel();
227 m_StatusBar
->SetStatusText(label
,
234 SetCursor(wxCURSOR_IBEAM
);
235 m_HandCursor
= FALSE
;
236 if(m_StatusBar
&& m_StatusFieldLabel
!= -1)
237 m_StatusBar
->SetStatusText("", m_StatusFieldLabel
);
239 if(event
.LeftIsDown())
243 m_llist
->StartSelection();
249 m_llist
->ContinueSelection(cursorPos
);
253 if(m_Selecting
&& ! event
.LeftIsDown())
255 m_llist
->EndSelection(cursorPos
);
263 // always move cursor to mouse click:
264 if(eventId
== WXLOWIN_MENU_LCLICK
)
266 m_llist
->MoveCursorTo(cursorPos
);
268 // Calculate where the top of the visible area is:
272 GetScrollPixelsPerUnit(&dx
, &dy
);
275 wxPoint
offset(-x0
+WXLO_XOFFSET
, -y0
+WXLO_YOFFSET
);
276 m_llist
->UpdateCursorScreenPos(dc
, true, offset
);
278 if(m_CursorVisibility
== -1)
279 m_CursorVisibility
= 1;
281 // VZ: this should be unnecessary because mouse can only click on a
282 // visible part of the canvas
288 DoPaint(FALSE
); // DoPaint suppresses flicker under GTK
292 if(!m_doSendEvents
) // nothing to do
298 // only do the menu if activated, editable and not on a clickable object
299 if(eventId
== WXLOWIN_MENU_RCLICK
301 && (! obj
|| u
== NULL
))
303 PopupMenu(m_PopupMenu
, m_ClickPosition
.x
, m_ClickPosition
.y
);
309 // find the object at this position
312 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, eventId
);
313 commandEvent
.SetEventObject( this );
314 commandEvent
.SetClientData((char *)obj
);
315 GetEventHandler()->ProcessEvent(commandEvent
);
320 * Some simple keyboard handling.
323 wxLayoutWindow::OnChar(wxKeyEvent
& event
)
325 int keyCode
= event
.KeyCode();
327 #ifdef WXLAYOUT_DEBUG
328 if(keyCode
== WXK_F1
)
335 if(! m_Selecting
&& event
.ShiftDown())
348 m_llist
->StartSelection();
355 // If needed, make cursor visible:
356 if(m_CursorVisibility
== -1)
357 m_CursorVisibility
= 1;
359 /* These two nested switches work like this:
360 The first one processes all non-editing keycodes, to move the
361 cursor, etc. It's default will process all keycodes causing
362 modifications to the buffer, but only if editing is allowed.
364 bool ctrlDown
= event
.ControlDown();
369 m_llist
->MoveCursorWord(1);
371 m_llist
->MoveCursorHorizontally(1);
375 m_llist
->MoveCursorWord(-1);
377 m_llist
->MoveCursorHorizontally(-1);
380 m_llist
->MoveCursorVertically(-1);
383 m_llist
->MoveCursorVertically(1);
386 m_llist
->MoveCursorVertically(-Y_SCROLL_PAGE
);
389 m_llist
->MoveCursorVertically(Y_SCROLL_PAGE
);
393 m_llist
->MoveCursorTo(wxPoint(0, 0));
395 m_llist
->MoveCursorToBeginOfLine();
399 m_llist
->MoveCursorTo(m_llist
->GetSize());
401 m_llist
->MoveCursorToEndOfLine();
405 if(keyCode
== 'c' && ctrlDown
)
407 // this should work even in read-only mode
410 else if( IsEditable() )
412 /* First, handle control keys */
413 if(event
.ControlDown() && ! event
.AltDown())
425 m_llist
->DeleteLines(1);
427 case 'h': // like backspace
428 if(m_llist
->MoveCursorHorizontally(-1)) m_llist
->Delete(1);
431 m_llist
->DeleteToBeginOfLine();
434 m_llist
->DeleteToEndOfLine();
442 #ifdef WXLAYOUT_DEBUG
444 m_llist
->SetFont(-1,-1,-1,-1,true); // underlined
452 else if( event
.AltDown() && ! event
.ControlDown() )
458 m_llist
->DeleteWord();
465 else if ( ! event
.AltDown() && ! event
.ControlDown())
470 if(event
.ShiftDown())
474 if(event
.ShiftDown())
479 case WXK_BACK
: // backspace
480 if(m_llist
->MoveCursorHorizontally(-1)) m_llist
->Delete(1);
484 m_llist
->WrapLine(m_WrapMargin
);
485 m_llist
->LineBreak();
488 if((!(event
.ControlDown() || event
.AltDown() || event
.MetaDown()))
489 && (keyCode
< 256 && keyCode
>= 32)
492 if(m_WrapMargin
> 0 && isspace(keyCode
))
493 m_llist
->WrapLine(m_WrapMargin
);
494 m_llist
->Insert((char)keyCode
);
505 if(event
.ShiftDown())
506 m_llist
->ContinueSelection();
509 m_llist
->EndSelection();
514 // we must call ResizeScrollbars() before ScrollToCursor(), otherwise the
515 // ne cursor position might be outside the current scrolllbar range
519 // refresh the screen
520 DoPaint(m_llist
->GetUpdateRect());
524 wxLayoutWindow::OnKeyUp(wxKeyEvent
& event
)
526 if(event
.KeyCode() == WXK_SHIFT
&& m_llist
->IsSelecting())
528 m_llist
->EndSelection();
536 wxLayoutWindow::ScrollToCursor(void)
538 wxClientDC
dc( this );
541 int x0
,y0
,x1
,y1
, dx
, dy
;
543 // Calculate where the top of the visible area is:
545 GetScrollPixelsPerUnit(&dx
, &dy
);
548 WXLO_DEBUG(("ScrollToCursor: ViewStart is %d/%d", x0
, y0
));
550 // Get the size of the visible window:
551 GetClientSize(&x1
,&y1
);
553 // notice that the client size may be (0, 0)...
554 wxASSERT(x1
>= 0 && y1
>= 0);
556 // VZ: I think this is false - if you do it here, ResizeScrollbars() won't
557 // call SetScrollbars() later
559 // As we have the values anyway, use them to avoid unnecessary scrollbar
561 if(x1
> m_maxx
) m_maxx
= x1
;
562 if(y1
> m_maxy
) m_maxy
= y1
;
565 // Make sure that the scrollbars are at a position so that the cursor is
566 // visible if we are editing
567 WXLO_DEBUG(("m_ScrollToCursor = %d", (int) m_ScrollToCursor
));
568 wxPoint cc
= m_llist
->GetCursorScreenPos(dc
);
570 // the cursor should be completely visible in both directions
571 wxPoint
cs(m_llist
->GetCursorSize());
574 if ( cc
.x
< x0
|| cc
.x
>= x0
+ x1
- cs
.x
)
581 if ( cc
.y
< y0
|| cc
.y
>= y0
+ y1
- cs
.y
)
588 if ( nx
!= -1 || ny
!= -1 )
590 // set new view start
591 Scroll(nx
== -1 ? -1 : (nx
+dx
-1)/dx
, ny
== -1 ? -1 : (ny
+dy
-1)/dy
);
594 m_ScrollToCursor
= false;
599 wxLayoutWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
))
601 wxRect region
= GetUpdateRegion().GetBox();
602 InternalPaint(®ion
);
606 wxLayoutWindow::DoPaint(const wxRect
*updateRect
)
609 InternalPaint(updateRect
);
611 Refresh(FALSE
, updateRect
); // Causes bad flicker under wxGTK!!!
613 if ( !::UpdateWindow(GetHwnd()) )
614 wxLogLastError("UpdateWindow");
619 wxLayoutWindow::InternalPaint(const wxRect
*updateRect
)
621 wxPaintDC
dc( this );
624 #ifdef WXLAYOUT_USE_CARET
625 // hide the caret before drawing anything
627 #endif // WXLAYOUT_USE_CARET
629 int x0
,y0
,x1
,y1
, dx
, dy
;
631 // Calculate where the top of the visible area is:
633 GetScrollPixelsPerUnit(&dx
, &dy
);
636 // Get the size of the visible window:
637 GetClientSize(&x1
,&y1
);
643 WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
644 updateRect
->x
, updateRect
->y
,
645 updateRect
->x
+updateRect
->width
,
646 updateRect
->y
+updateRect
->height
));
653 /* Check whether the window has grown, if so, we need to reallocate
654 the bitmap to be larger. */
655 if(x1
> m_bitmapSize
.x
|| y1
> m_bitmapSize
.y
)
657 wxASSERT(m_bitmapSize
.x
> 0);
658 wxASSERT(m_bitmapSize
.y
> 0);
660 m_memDC
->SelectObject(wxNullBitmap
);
662 m_bitmapSize
= wxPoint(x1
,y1
);
663 m_bitmap
= new wxBitmap(x1
,y1
);
664 m_memDC
->SelectObject(*m_bitmap
);
667 m_memDC
->SetDeviceOrigin(0,0);
668 m_memDC
->SetBrush(wxBrush(m_llist
->GetDefaultStyleInfo().GetBGColour(),wxSOLID
));
669 m_memDC
->SetPen(wxPen(m_llist
->GetDefaultStyleInfo().GetBGColour(),
671 m_memDC
->SetLogicalFunction(wxCOPY
);
673 /* Either fill the background with the background bitmap, or clear
679 w
= m_BGbitmap
->GetWidth(),
680 h
= m_BGbitmap
->GetHeight();
681 for(y
= 0; y
< y1
; y
+=h
)
682 for(x
= 0; x
< x1
; x
+=w
)
683 m_memDC
->DrawBitmap(*m_BGbitmap
, x
, y
);
684 m_memDC
->SetBackgroundMode(wxTRANSPARENT
);
688 // clear the background: (must not be done if we use the update rectangle!)
689 m_memDC
->SetBackgroundMode(wxSOLID
);
690 m_memDC
->DrawRectangle(0,0,x1
, y1
);
694 /* This is the important bit: we tell the list to draw itself: */
698 WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
699 updateRect
->x
, updateRect
->y
,
700 updateRect
->x
+updateRect
->width
,
701 updateRect
->y
+updateRect
->height
));
705 // Device origins on the memDC are suspect, we translate manually
706 // with the translate parameter of Draw().
707 wxPoint
offset(-x0
+WXLO_XOFFSET
,-y0
+WXLO_YOFFSET
);
708 m_llist
->Draw(*m_memDC
,offset
, y0
, y0
+y1
);
710 // We start calculating a new update rect before drawing the
711 // cursor, so that the cursor coordinates get included in the next
712 // update rectangle (although they are drawn on the memDC, this is
713 // needed to erase it):
714 m_llist
->InvalidateUpdateRect();
715 if(m_CursorVisibility
!= 0)
717 m_llist
->UpdateCursorScreenPos(dc
, true, offset
);
718 m_llist
->DrawCursor(*m_memDC
,
719 m_HaveFocus
&& IsEditable(), // draw a thick
720 // cursor for editable windows with focus
724 // Now copy everything to the screen:
726 // This somehow doesn't work, but even the following bit with the
727 // whole rect at once is still a bit broken I think.
728 wxRegionIterator
ri ( GetUpdateRegion() );
732 WXLO_DEBUG(("UpdateRegion: %ld,%ld, %ld,%ld",
733 ri
.GetX(),ri
.GetY(),ri
.GetW(),ri
.GetH()));
734 dc
.Blit(x0
+ri
.GetX(),y0
+ri
.GetY(),ri
.GetW(),ri
.GetH(),
735 m_memDC
,ri
.GetX(),ri
.GetY(),wxCOPY
,FALSE
);
741 // FIXME: Trying to copy only the changed parts, but it does not seem
743 // x0 = updateRect->x; y0 = updateRect->y;
744 // if(updateRect->height < y1)
745 // y1 = updateRect->height;
746 // y1 += WXLO_YOFFSET; //FIXME might not be needed
747 dc
.Blit(x0
,y0
,x1
,y1
,m_memDC
,0,0,wxCOPY
,FALSE
);
750 #ifdef WXLAYOUT_USE_CARET
751 // show the caret back after everything is redrawn
753 #endif // WXLAYOUT_USE_CARET
756 m_ScrollToCursor
= false;
758 if ( m_StatusBar
&& m_StatusFieldCursor
!= -1 )
760 static wxPoint
s_oldCursorPos(-1, -1);
762 wxPoint
pos(m_llist
->GetCursorPos());
764 // avoid unnecessary status bar refreshes
765 if ( pos
!= s_oldCursorPos
)
767 s_oldCursorPos
= pos
;
770 label
.Printf(_("Ln:%d Col:%d"), pos
.y
+ 1, pos
.x
+ 1);
771 m_StatusBar
->SetStatusText(label
, m_StatusFieldCursor
);
776 // change the range and position of scrollbars
778 wxLayoutWindow::ResizeScrollbars(bool exact
)
780 wxPoint max
= m_llist
->GetSize();
782 WXLO_DEBUG(("ResizeScrollbars: max size = (%ld, %ld)",
783 (long int)max
.x
, (long int) max
.y
));
785 if( max
.x
> m_maxx
- WXLO_ROFFSET
|| max
.y
> m_maxy
- WXLO_BOFFSET
|| exact
)
789 // add an extra bit to the sizes to avoid future updates
790 max
.x
+= WXLO_ROFFSET
;
791 max
.y
+= WXLO_BOFFSET
;
794 ViewStart(&m_ViewStartX
, &m_ViewStartY
);
795 SetScrollbars(X_SCROLL_PAGE
, Y_SCROLL_PAGE
,
796 max
.x
/ X_SCROLL_PAGE
+ 1, max
.y
/ Y_SCROLL_PAGE
+ 1,
797 m_ViewStartX
, m_ViewStartY
,
800 m_maxx
= max
.x
+ X_SCROLL_PAGE
;
801 m_maxy
= max
.y
+ Y_SCROLL_PAGE
;
806 wxLayoutWindow::Paste(void)
809 if (wxTheClipboard
->Open())
811 #if wxUSE_PRIVATE_CLIPBOARD_FORMAT
812 wxLayoutDataObject wxldo
;
813 if (wxTheClipboard
->IsSupported( wxldo
.GetFormat() ))
815 wxTheClipboard
->GetData(&wxldo
);
818 //FIXME: missing functionality m_llist->Insert(wxldo.GetList());
823 wxTextDataObject data
;
824 if (wxTheClipboard
->IsSupported( data
.GetFormat() ))
826 wxTheClipboard
->GetData(&data
);
827 wxString text
= data
.GetText();
828 wxLayoutImportText( m_llist
, text
);
831 wxTheClipboard
->Close();
835 /* My attempt to get the primary selection, but it does not
837 if(text
.Length() == 0)
839 wxTextCtrl
tmp_tctrl(this,-1);
841 text
+= tmp_tctrl
.GetValue();
847 wxLayoutWindow::Copy(bool invalidate
)
849 // Calling GetSelection() will automatically do an EndSelection()
850 // on the list, but we need to take a note of it, too:
854 m_llist
->EndSelection();
857 wxLayoutDataObject wldo
;
858 wxLayoutList
*llist
= m_llist
->GetSelection(&wldo
, invalidate
);
861 // Export selection as text:
863 wxLayoutExportObject
*export
;
864 wxLayoutExportStatus
status(llist
);
865 while((export
= wxLayoutExport( &status
, WXLO_EXPORT_AS_TEXT
)) != NULL
)
867 if(export
->type
== WXLO_EXPORT_TEXT
)
868 text
<< *(export
->content
.text
);
873 // The exporter always appends a newline, so we chop it off if it
876 size_t len
= text
.Length();
877 if(len
> 2 && text
[len
-2] == '\r') // Windows
878 text
= text
.Mid(0,len
-2);
879 else if(len
> 1 && text
[len
-1] == '\n')
880 text
= text
.Mid(0,len
-1);
884 if (wxTheClipboard
->Open())
886 wxTextDataObject
*data
= new wxTextDataObject( text
);
887 bool rc
= wxTheClipboard
->SetData( data
);
888 #if wxUSE_PRIVATE_CLIPBOARD_FORMAT
889 rc
|= wxTheClipboard
->AddData( &wldo
);
891 wxTheClipboard
->Close();
899 wxLayoutWindow::Cut(void)
901 if(Copy(false)) // do not invalidate selection after copy
903 m_llist
->DeleteSelection();
910 wxLayoutWindow::Find(const wxString
&needle
,
915 if(fromWhere
== NULL
)
916 found
= m_llist
->FindText(needle
, m_llist
->GetCursorPos());
918 found
= m_llist
->FindText(needle
, *fromWhere
);
926 m_llist
->MoveCursorTo(found
);
934 wxLayoutWindow::MakeFormatMenu()
936 wxMenu
*m
= new wxMenu(_("Layout Menu"));
938 m
->Append(WXLOWIN_MENU_LARGER
,_("&Larger"),_("Switch to larger font."), false);
939 m
->Append(WXLOWIN_MENU_SMALLER
,_("&Smaller"),_("Switch to smaller font."), false);
940 m
->AppendSeparator();
941 m
->Append(WXLOWIN_MENU_UNDERLINE_ON
, _("&Underline on"),_("Activate underline mode."), false);
942 m
->Append(WXLOWIN_MENU_UNDERLINE_OFF
,_("&Underline off"),_("Deactivate underline mode."), false);
943 m
->Append(WXLOWIN_MENU_BOLD_ON
,_("&Bold on"),_("Activate bold mode."), false);
944 m
->Append(WXLOWIN_MENU_BOLD_OFF
,_("&Bold off"),_("Deactivate bold mode."), false);
945 m
->Append(WXLOWIN_MENU_ITALICS_ON
,_("&Italics on"),_("Activate italics mode."), false);
946 m
->Append(WXLOWIN_MENU_ITALICS_OFF
,_("&Italics off"),_("Deactivate italics mode."), false);
947 m
->AppendSeparator();
948 m
->Append(WXLOWIN_MENU_ROMAN
,_("&Roman"),_("Switch to roman font."), false);
949 m
->Append(WXLOWIN_MENU_TYPEWRITER
,_("&Typewriter"),_("Switch to typewriter font."), false);
950 m
->Append(WXLOWIN_MENU_SANSSERIF
,_("&Sans Serif"),_("Switch to sans serif font."), false);
954 void wxLayoutWindow::OnMenu(wxCommandEvent
& event
)
956 switch (event
.GetId())
958 case WXLOWIN_MENU_LARGER
:
959 m_llist
->SetFontLarger(); break;
960 case WXLOWIN_MENU_SMALLER
:
961 m_llist
->SetFontSmaller(); break;
962 case WXLOWIN_MENU_UNDERLINE_ON
:
963 m_llist
->SetFontUnderline(true); break;
964 case WXLOWIN_MENU_UNDERLINE_OFF
:
965 m_llist
->SetFontUnderline(false); break;
966 case WXLOWIN_MENU_BOLD_ON
:
967 m_llist
->SetFontWeight(wxBOLD
); break;
968 case WXLOWIN_MENU_BOLD_OFF
:
969 m_llist
->SetFontWeight(wxNORMAL
); break;
970 case WXLOWIN_MENU_ITALICS_ON
:
971 m_llist
->SetFontStyle(wxITALIC
); break;
972 case WXLOWIN_MENU_ITALICS_OFF
:
973 m_llist
->SetFontStyle(wxNORMAL
); break;
974 case WXLOWIN_MENU_ROMAN
:
975 m_llist
->SetFontFamily(wxROMAN
); break;
976 case WXLOWIN_MENU_TYPEWRITER
:
977 m_llist
->SetFontFamily(wxFIXED
); break;
978 case WXLOWIN_MENU_SANSSERIF
:
979 m_llist
->SetFontFamily(wxSWISS
); break;
984 wxLayoutWindow::OnSetFocus(wxFocusEvent
&ev
)
991 wxLayoutWindow::OnKillFocus(wxFocusEvent
&ev
)