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!!! */
105 /// allows me to compare to wxPoints
106 static bool operator != (wxPoint
const &p1
, wxPoint
const &p2
)
108 return p1
.x
!= p2
.x
|| p1
.y
!= p2
.y
;
112 #ifndef wxWANTS_CHARS
113 #define wxWANTS_CHARS 0
116 // ----------------------------------------------------------------------------
118 // ----------------------------------------------------------------------------
120 wxLayoutWindow::wxLayoutWindow(wxWindow
*parent
)
121 : wxScrolledWindow(parent
, -1,
122 wxDefaultPosition
, wxDefaultSize
,
123 wxHSCROLL
| wxVSCROLL
|
127 SetStatusBar(NULL
); // don't use statusbar
129 m_doSendEvents
= false;
130 m_ViewStartX
= 0; m_ViewStartY
= 0;
131 m_DoPopupMenu
= true;
132 m_PopupMenu
= MakeFormatMenu();
133 m_memDC
= new wxMemoryDC
;
134 m_bitmap
= new wxBitmap(4,4);
135 m_bitmapSize
= wxPoint(4,4);
136 m_llist
= new wxLayoutList();
139 m_ScrollToCursor
= false;
141 wxPoint max
= m_llist
->GetSize();
142 SetScrollbars(X_SCROLL_PAGE
, Y_SCROLL_PAGE
,
143 max
.x
/ X_SCROLL_PAGE
+ 1, max
.y
/ Y_SCROLL_PAGE
+ 1);
144 EnableScrolling(true, true);
145 m_maxx
= max
.x
+ X_SCROLL_PAGE
;
146 m_maxy
= max
.y
+ Y_SCROLL_PAGE
;
149 #ifdef WXLAYOUT_USE_CARET
150 // FIXME cursor size shouldn't be hardcoded
151 wxCaret
*caret
= new wxCaret(this, 2, 20);
153 m_llist
->SetCaret(caret
);
155 #endif // WXLAYOUT_USE_CARET
157 SetCursorVisibility(-1);
158 SetCursor(wxCURSOR_IBEAM
);
162 wxLayoutWindow::~wxLayoutWindow()
164 delete m_memDC
; // deletes bitmap automatically (?)
168 SetBackgroundBitmap(NULL
);
172 wxLayoutWindow::Clear(int family
,
180 GetLayoutList()->Clear(family
,size
,style
,weight
,underline
,fg
,bg
);
181 SetBackgroundColour(GetLayoutList()->GetDefaultStyleInfo().GetBGColour());
182 ResizeScrollbars(true);
185 wxScrolledWindow::Clear();
186 DoPaint((wxRect
*)NULL
);
190 wxLayoutWindow::OnMouse(int eventId
, wxMouseEvent
& event
)
192 wxClientDC
dc( this );
194 if ( eventId
!= WXLOWIN_MENU_MOUSEMOVE
)
196 // moving the mouse in a window shouldn't give it the focus!
201 findPos
.x
= dc
.DeviceToLogicalX(event
.GetX());
202 findPos
.y
= dc
.DeviceToLogicalY(event
.GetY());
204 findPos
.x
-= WXLO_XOFFSET
;
205 findPos
.y
-= WXLO_YOFFSET
;
207 if(findPos
.x
< 0) findPos
.x
= 0;
208 if(findPos
.y
< 0) findPos
.y
= 0;
210 m_ClickPosition
= wxPoint(event
.GetX(), event
.GetY());
214 wxLayoutObject
*obj
= m_llist
->FindObjectScreen(dc
, findPos
,
216 wxLayoutObject::UserData
*u
= obj
? obj
->GetUserData() : NULL
;
218 //has the mouse only been moved?
219 if(eventId
== WXLOWIN_MENU_MOUSEMOVE
)
221 // found is only true if we are really over an object, not just
223 if(found
&& u
&& ! m_Selecting
)
226 SetCursor(wxCURSOR_HAND
);
228 if(m_StatusBar
&& m_StatusFieldLabel
!= -1)
230 const wxString
&label
= u
->GetLabel();
232 m_StatusBar
->SetStatusText(label
,
239 SetCursor(wxCURSOR_IBEAM
);
240 m_HandCursor
= FALSE
;
241 if(m_StatusBar
&& m_StatusFieldLabel
!= -1)
242 m_StatusBar
->SetStatusText("", m_StatusFieldLabel
);
244 if(event
.LeftIsDown())
248 m_llist
->StartSelection(wxPoint(-1, -1), m_ClickPosition
);
250 DoPaint(); // TODO: we don't have to redraw everything!
254 m_llist
->ContinueSelection(cursorPos
, m_ClickPosition
);
255 DoPaint(); // TODO: we don't have to redraw everything!
258 if(m_Selecting
&& ! event
.LeftIsDown())
260 m_llist
->EndSelection(cursorPos
, m_ClickPosition
);
262 DoPaint(); // TODO: we don't have to redraw everything!
271 else if(eventId
== WXLOWIN_MENU_LCLICK
)
273 // always move cursor to mouse click:
274 m_llist
->MoveCursorTo(cursorPos
);
276 // clicking a mouse removes the selection
277 if ( m_llist
->HasSelection() )
279 m_llist
->DiscardSelection();
280 DoPaint(); // TODO: we don't have to redraw everything!
283 // Calculate where the top of the visible area is:
287 GetScrollPixelsPerUnit(&dx
, &dy
);
290 wxPoint
offset(-x0
+WXLO_XOFFSET
, -y0
+WXLO_YOFFSET
);
292 if(m_CursorVisibility
== -1)
293 m_CursorVisibility
= 1;
295 if(m_CursorVisibility
!= 0)
297 // draw a thick cursor for editable windows with focus
298 m_llist
->DrawCursor(dc
, m_HaveFocus
&& IsEditable(), offset
);
301 // VZ: this should be unnecessary because mouse can only click on a
302 // visible part of the canvas
308 DoPaint(); // DoPaint suppresses flicker under GTK
312 // notify about mouse events?
315 // only do the menu if activated, editable and not on a clickable object
316 if(eventId
== WXLOWIN_MENU_RCLICK
318 && (! obj
|| u
== NULL
))
320 PopupMenu(m_PopupMenu
, m_ClickPosition
.x
, m_ClickPosition
.y
);
325 // find the object at this position
328 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, eventId
);
329 commandEvent
.SetEventObject( this );
330 commandEvent
.SetClientData((char *)obj
);
331 GetEventHandler()->ProcessEvent(commandEvent
);
340 * Some simple keyboard handling.
343 wxLayoutWindow::OnChar(wxKeyEvent
& event
)
345 int keyCode
= event
.KeyCode();
347 #ifdef WXLAYOUT_DEBUG
348 if(keyCode
== WXK_F1
)
355 if(! m_Selecting
&& event
.ShiftDown())
368 m_llist
->StartSelection();
375 // If needed, make cursor visible:
376 if(m_CursorVisibility
== -1)
377 m_CursorVisibility
= 1;
379 /* These two nested switches work like this:
380 The first one processes all non-editing keycodes, to move the
381 cursor, etc. It's default will process all keycodes causing
382 modifications to the buffer, but only if editing is allowed.
384 bool ctrlDown
= event
.ControlDown();
389 m_llist
->MoveCursorWord(1);
391 m_llist
->MoveCursorHorizontally(1);
395 m_llist
->MoveCursorWord(-1);
397 m_llist
->MoveCursorHorizontally(-1);
400 m_llist
->MoveCursorVertically(-1);
403 m_llist
->MoveCursorVertically(1);
406 m_llist
->MoveCursorVertically(-Y_SCROLL_PAGE
);
409 m_llist
->MoveCursorVertically(Y_SCROLL_PAGE
);
413 m_llist
->MoveCursorTo(wxPoint(0, 0));
415 m_llist
->MoveCursorToBeginOfLine();
419 m_llist
->MoveCursorTo(m_llist
->GetSize());
421 m_llist
->MoveCursorToEndOfLine();
425 if(keyCode
== 'c' && ctrlDown
)
427 // this should work even in read-only mode
430 else if( IsEditable() )
432 /* First, handle control keys */
433 if(event
.ControlDown() && ! event
.AltDown())
445 m_llist
->DeleteLines(1);
447 case 'h': // like backspace
448 if(m_llist
->MoveCursorHorizontally(-1)) m_llist
->Delete(1);
451 m_llist
->DeleteToBeginOfLine();
454 m_llist
->DeleteToEndOfLine();
462 #ifdef WXLAYOUT_DEBUG
464 m_llist
->SetFont(-1,-1,-1,-1,true); // underlined
472 else if( event
.AltDown() && ! event
.ControlDown() )
478 m_llist
->DeleteWord();
485 else if ( ! event
.AltDown() && ! event
.ControlDown())
490 if(event
.ShiftDown())
494 if(event
.ShiftDown())
499 case WXK_BACK
: // backspace
500 if(m_llist
->MoveCursorHorizontally(-1)) m_llist
->Delete(1);
504 m_llist
->WrapLine(m_WrapMargin
);
505 m_llist
->LineBreak();
508 if((!(event
.ControlDown() || event
.AltDown() || event
.MetaDown()))
509 && (keyCode
< 256 && keyCode
>= 32)
512 if(m_WrapMargin
> 0 && isspace(keyCode
))
513 m_llist
->WrapLine(m_WrapMargin
);
514 m_llist
->Insert((char)keyCode
);
525 if(event
.ShiftDown())
526 m_llist
->ContinueSelection();
529 m_llist
->EndSelection();
534 // we must call ResizeScrollbars() before ScrollToCursor(), otherwise the
535 // ne cursor position might be outside the current scrolllbar range
539 // refresh the screen
540 DoPaint(m_llist
->GetUpdateRect());
544 wxLayoutWindow::OnKeyUp(wxKeyEvent
& event
)
546 if(event
.KeyCode() == WXK_SHIFT
&& m_llist
->IsSelecting())
548 m_llist
->EndSelection();
556 wxLayoutWindow::ScrollToCursor(void)
558 wxClientDC
dc( this );
561 int x0
,y0
,x1
,y1
, dx
, dy
;
563 // Calculate where the top of the visible area is:
565 GetScrollPixelsPerUnit(&dx
, &dy
);
568 WXLO_DEBUG(("ScrollToCursor: ViewStart is %d/%d", x0
, y0
));
570 // Get the size of the visible window:
571 GetClientSize(&x1
,&y1
);
573 // notice that the client size may be (0, 0)...
574 wxASSERT(x1
>= 0 && y1
>= 0);
576 // VZ: I think this is false - if you do it here, ResizeScrollbars() won't
577 // call SetScrollbars() later
579 // As we have the values anyway, use them to avoid unnecessary scrollbar
581 if(x1
> m_maxx
) m_maxx
= x1
;
582 if(y1
> m_maxy
) m_maxy
= y1
;
585 // Make sure that the scrollbars are at a position so that the cursor is
586 // visible if we are editing
587 WXLO_DEBUG(("m_ScrollToCursor = %d", (int) m_ScrollToCursor
));
588 wxPoint cc
= m_llist
->GetCursorScreenPos(dc
);
590 // the cursor should be completely visible in both directions
591 wxPoint
cs(m_llist
->GetCursorSize());
594 if ( cc
.x
< x0
|| cc
.x
>= x0
+ x1
- cs
.x
)
601 if ( cc
.y
< y0
|| cc
.y
>= y0
+ y1
- cs
.y
)
608 if ( nx
!= -1 || ny
!= -1 )
610 // set new view start
611 Scroll(nx
== -1 ? -1 : (nx
+dx
-1)/dx
, ny
== -1 ? -1 : (ny
+dy
-1)/dy
);
614 m_ScrollToCursor
= false;
619 wxLayoutWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
))
621 wxRect region
= GetUpdateRegion().GetBox();
622 InternalPaint(®ion
);
626 wxLayoutWindow::DoPaint(const wxRect
*updateRect
)
628 // Causes bad flicker under wxGTK!!!
630 InternalPaint(updateRect
);
632 Refresh(FALSE
); //, updateRect);
634 if ( !::UpdateWindow(GetHwnd()) )
635 wxLogLastError("UpdateWindow");
640 wxLayoutWindow::InternalPaint(const wxRect
*updateRect
)
642 wxPaintDC
dc( this );
645 #ifdef WXLAYOUT_USE_CARET
646 // hide the caret before drawing anything
648 #endif // WXLAYOUT_USE_CARET
650 int x0
,y0
,x1
,y1
, dx
, dy
;
652 // Calculate where the top of the visible area is:
654 GetScrollPixelsPerUnit(&dx
, &dy
);
657 // Get the size of the visible window:
658 GetClientSize(&x1
,&y1
);
664 WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
665 updateRect
->x
, updateRect
->y
,
666 updateRect
->x
+updateRect
->width
,
667 updateRect
->y
+updateRect
->height
));
674 /* Check whether the window has grown, if so, we need to reallocate
675 the bitmap to be larger. */
676 if(x1
> m_bitmapSize
.x
|| y1
> m_bitmapSize
.y
)
678 wxASSERT(m_bitmapSize
.x
> 0);
679 wxASSERT(m_bitmapSize
.y
> 0);
681 m_memDC
->SelectObject(wxNullBitmap
);
683 m_bitmapSize
= wxPoint(x1
,y1
);
684 m_bitmap
= new wxBitmap(x1
,y1
);
685 m_memDC
->SelectObject(*m_bitmap
);
688 m_memDC
->SetDeviceOrigin(0,0);
689 m_memDC
->SetBrush(wxBrush(m_llist
->GetDefaultStyleInfo().GetBGColour(),wxSOLID
));
690 m_memDC
->SetPen(wxPen(m_llist
->GetDefaultStyleInfo().GetBGColour(),
692 m_memDC
->SetLogicalFunction(wxCOPY
);
695 // fill the background with the background bitmap
700 w
= m_BGbitmap
->GetWidth(),
701 h
= m_BGbitmap
->GetHeight();
702 for(y
= 0; y
< y1
; y
+=h
)
703 for(x
= 0; x
< x1
; x
+=w
)
704 m_memDC
->DrawBitmap(*m_BGbitmap
, x
, y
);
705 m_memDC
->SetBackgroundMode(wxTRANSPARENT
);
708 // This is the important bit: we tell the list to draw itself
712 WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
713 updateRect
->x
, updateRect
->y
,
714 updateRect
->x
+updateRect
->width
,
715 updateRect
->y
+updateRect
->height
));
719 // Device origins on the memDC are suspect, we translate manually
720 // with the translate parameter of Draw().
721 wxPoint
offset(-x0
+WXLO_XOFFSET
,-y0
+WXLO_YOFFSET
);
722 m_llist
->Draw(*m_memDC
,offset
, y0
, y0
+y1
);
724 // We start calculating a new update rect before drawing the
725 // cursor, so that the cursor coordinates get included in the next
726 // update rectangle (although they are drawn on the memDC, this is
727 // needed to erase it):
728 m_llist
->InvalidateUpdateRect();
729 if(m_CursorVisibility
!= 0)
731 // draw a thick cursor for editable windows with focus
732 m_llist
->DrawCursor(*m_memDC
,
733 m_HaveFocus
&& IsEditable(),
737 // Now copy everything to the screen:
739 // This somehow doesn't work, but even the following bit with the
740 // whole rect at once is still a bit broken I think.
741 wxRegionIterator
ri ( GetUpdateRegion() );
745 WXLO_DEBUG(("UpdateRegion: %ld,%ld, %ld,%ld",
746 ri
.GetX(),ri
.GetY(),ri
.GetW(),ri
.GetH()));
747 dc
.Blit(x0
+ri
.GetX(),y0
+ri
.GetY(),ri
.GetW(),ri
.GetH(),
748 m_memDC
,ri
.GetX(),ri
.GetY(),wxCOPY
,FALSE
);
754 // FIXME: Trying to copy only the changed parts, but it does not seem
756 // x0 = updateRect->x; y0 = updateRect->y;
757 // if(updateRect->height < y1)
758 // y1 = updateRect->height;
759 // y1 += WXLO_YOFFSET; //FIXME might not be needed
760 dc
.Blit(x0
,y0
,x1
,y1
,m_memDC
,0,0,wxCOPY
,FALSE
);
763 #ifdef WXLAYOUT_USE_CARET
764 // show the caret back after everything is redrawn
766 #endif // WXLAYOUT_USE_CARET
769 m_ScrollToCursor
= false;
771 if ( m_StatusBar
&& m_StatusFieldCursor
!= -1 )
773 static wxPoint
s_oldCursorPos(-1, -1);
775 wxPoint
pos(m_llist
->GetCursorPos());
777 // avoid unnecessary status bar refreshes
778 if ( pos
!= s_oldCursorPos
)
780 s_oldCursorPos
= pos
;
783 label
.Printf(_("Ln:%d Col:%d"), pos
.y
+ 1, pos
.x
+ 1);
784 m_StatusBar
->SetStatusText(label
, m_StatusFieldCursor
);
789 // change the range and position of scrollbars
791 wxLayoutWindow::ResizeScrollbars(bool exact
)
793 wxPoint max
= m_llist
->GetSize();
795 WXLO_DEBUG(("ResizeScrollbars: max size = (%ld, %ld)",
796 (long int)max
.x
, (long int) max
.y
));
798 if( max
.x
> m_maxx
- WXLO_ROFFSET
|| max
.y
> m_maxy
- WXLO_BOFFSET
|| exact
)
802 // add an extra bit to the sizes to avoid future updates
803 max
.x
+= WXLO_ROFFSET
;
804 max
.y
+= WXLO_BOFFSET
;
807 ViewStart(&m_ViewStartX
, &m_ViewStartY
);
808 SetScrollbars(X_SCROLL_PAGE
, Y_SCROLL_PAGE
,
809 max
.x
/ X_SCROLL_PAGE
+ 1, max
.y
/ Y_SCROLL_PAGE
+ 1,
810 m_ViewStartX
, m_ViewStartY
,
813 m_maxx
= max
.x
+ X_SCROLL_PAGE
;
814 m_maxy
= max
.y
+ Y_SCROLL_PAGE
;
819 wxLayoutWindow::Paste(void)
822 if (wxTheClipboard
->Open())
824 #if wxUSE_PRIVATE_CLIPBOARD_FORMAT
825 wxLayoutDataObject wxldo
;
826 if (wxTheClipboard
->IsSupported( wxldo
.GetFormat() ))
828 wxTheClipboard
->GetData(&wxldo
);
831 //FIXME: missing functionality m_llist->Insert(wxldo.GetList());
836 wxTextDataObject data
;
837 if (wxTheClipboard
->IsSupported( data
.GetFormat() ))
839 wxTheClipboard
->GetData(&data
);
840 wxString text
= data
.GetText();
841 wxLayoutImportText( m_llist
, text
);
844 wxTheClipboard
->Close();
848 /* My attempt to get the primary selection, but it does not
850 if(text
.Length() == 0)
852 wxTextCtrl
tmp_tctrl(this,-1);
854 text
+= tmp_tctrl
.GetValue();
860 wxLayoutWindow::Copy(bool invalidate
)
862 // Calling GetSelection() will automatically do an EndSelection()
863 // on the list, but we need to take a note of it, too:
867 m_llist
->EndSelection();
870 wxLayoutDataObject wldo
;
871 wxLayoutList
*llist
= m_llist
->GetSelection(&wldo
, invalidate
);
874 // Export selection as text:
876 wxLayoutExportObject
*export
;
877 wxLayoutExportStatus
status(llist
);
878 while((export
= wxLayoutExport( &status
, WXLO_EXPORT_AS_TEXT
)) != NULL
)
880 if(export
->type
== WXLO_EXPORT_TEXT
)
881 text
<< *(export
->content
.text
);
886 // The exporter always appends a newline, so we chop it off if it
889 size_t len
= text
.Length();
890 if(len
> 2 && text
[len
-2] == '\r') // Windows
891 text
= text
.Mid(0,len
-2);
892 else if(len
> 1 && text
[len
-1] == '\n')
893 text
= text
.Mid(0,len
-1);
897 if (wxTheClipboard
->Open())
899 wxTextDataObject
*data
= new wxTextDataObject( text
);
900 bool rc
= wxTheClipboard
->SetData( data
);
901 #if wxUSE_PRIVATE_CLIPBOARD_FORMAT
902 rc
|= wxTheClipboard
->AddData( &wldo
);
904 wxTheClipboard
->Close();
912 wxLayoutWindow::Cut(void)
914 if(Copy(false)) // do not invalidate selection after copy
916 m_llist
->DeleteSelection();
923 wxLayoutWindow::Find(const wxString
&needle
,
928 if(fromWhere
== NULL
)
929 found
= m_llist
->FindText(needle
, m_llist
->GetCursorPos());
931 found
= m_llist
->FindText(needle
, *fromWhere
);
939 m_llist
->MoveCursorTo(found
);
947 wxLayoutWindow::MakeFormatMenu()
949 wxMenu
*m
= new wxMenu(_("Layout Menu"));
951 m
->Append(WXLOWIN_MENU_LARGER
,_("&Larger"),_("Switch to larger font."), false);
952 m
->Append(WXLOWIN_MENU_SMALLER
,_("&Smaller"),_("Switch to smaller font."), false);
953 m
->AppendSeparator();
954 m
->Append(WXLOWIN_MENU_UNDERLINE_ON
, _("&Underline on"),_("Activate underline mode."), false);
955 m
->Append(WXLOWIN_MENU_UNDERLINE_OFF
,_("&Underline off"),_("Deactivate underline mode."), false);
956 m
->Append(WXLOWIN_MENU_BOLD_ON
,_("&Bold on"),_("Activate bold mode."), false);
957 m
->Append(WXLOWIN_MENU_BOLD_OFF
,_("&Bold off"),_("Deactivate bold mode."), false);
958 m
->Append(WXLOWIN_MENU_ITALICS_ON
,_("&Italics on"),_("Activate italics mode."), false);
959 m
->Append(WXLOWIN_MENU_ITALICS_OFF
,_("&Italics off"),_("Deactivate italics mode."), false);
960 m
->AppendSeparator();
961 m
->Append(WXLOWIN_MENU_ROMAN
,_("&Roman"),_("Switch to roman font."), false);
962 m
->Append(WXLOWIN_MENU_TYPEWRITER
,_("&Typewriter"),_("Switch to typewriter font."), false);
963 m
->Append(WXLOWIN_MENU_SANSSERIF
,_("&Sans Serif"),_("Switch to sans serif font."), false);
967 void wxLayoutWindow::OnMenu(wxCommandEvent
& event
)
969 switch (event
.GetId())
971 case WXLOWIN_MENU_LARGER
:
972 m_llist
->SetFontLarger(); break;
973 case WXLOWIN_MENU_SMALLER
:
974 m_llist
->SetFontSmaller(); break;
975 case WXLOWIN_MENU_UNDERLINE_ON
:
976 m_llist
->SetFontUnderline(true); break;
977 case WXLOWIN_MENU_UNDERLINE_OFF
:
978 m_llist
->SetFontUnderline(false); break;
979 case WXLOWIN_MENU_BOLD_ON
:
980 m_llist
->SetFontWeight(wxBOLD
); break;
981 case WXLOWIN_MENU_BOLD_OFF
:
982 m_llist
->SetFontWeight(wxNORMAL
); break;
983 case WXLOWIN_MENU_ITALICS_ON
:
984 m_llist
->SetFontStyle(wxITALIC
); break;
985 case WXLOWIN_MENU_ITALICS_OFF
:
986 m_llist
->SetFontStyle(wxNORMAL
); break;
987 case WXLOWIN_MENU_ROMAN
:
988 m_llist
->SetFontFamily(wxROMAN
); break;
989 case WXLOWIN_MENU_TYPEWRITER
:
990 m_llist
->SetFontFamily(wxFIXED
); break;
991 case WXLOWIN_MENU_SANSSERIF
:
992 m_llist
->SetFontFamily(wxSWISS
); break;
997 wxLayoutWindow::OnSetFocus(wxFocusEvent
&ev
)
1004 wxLayoutWindow::OnKillFocus(wxFocusEvent
&ev
)
1006 m_HaveFocus
= false;