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
);
291 m_llist
->UpdateCursorScreenPos(dc
, true, offset
);
293 if(m_CursorVisibility
== -1)
294 m_CursorVisibility
= 1;
296 // VZ: this should be unnecessary because mouse can only click on a
297 // visible part of the canvas
303 DoPaint(); // DoPaint suppresses flicker under GTK
307 // notify about mouse events?
310 // only do the menu if activated, editable and not on a clickable object
311 if(eventId
== WXLOWIN_MENU_RCLICK
313 && (! obj
|| u
== NULL
))
315 PopupMenu(m_PopupMenu
, m_ClickPosition
.x
, m_ClickPosition
.y
);
320 // find the object at this position
323 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, eventId
);
324 commandEvent
.SetEventObject( this );
325 commandEvent
.SetClientData((char *)obj
);
326 GetEventHandler()->ProcessEvent(commandEvent
);
335 * Some simple keyboard handling.
338 wxLayoutWindow::OnChar(wxKeyEvent
& event
)
340 int keyCode
= event
.KeyCode();
342 #ifdef WXLAYOUT_DEBUG
343 if(keyCode
== WXK_F1
)
350 if(! m_Selecting
&& event
.ShiftDown())
363 m_llist
->StartSelection();
370 // If needed, make cursor visible:
371 if(m_CursorVisibility
== -1)
372 m_CursorVisibility
= 1;
374 /* These two nested switches work like this:
375 The first one processes all non-editing keycodes, to move the
376 cursor, etc. It's default will process all keycodes causing
377 modifications to the buffer, but only if editing is allowed.
379 bool ctrlDown
= event
.ControlDown();
384 m_llist
->MoveCursorWord(1);
386 m_llist
->MoveCursorHorizontally(1);
390 m_llist
->MoveCursorWord(-1);
392 m_llist
->MoveCursorHorizontally(-1);
395 m_llist
->MoveCursorVertically(-1);
398 m_llist
->MoveCursorVertically(1);
401 m_llist
->MoveCursorVertically(-Y_SCROLL_PAGE
);
404 m_llist
->MoveCursorVertically(Y_SCROLL_PAGE
);
408 m_llist
->MoveCursorTo(wxPoint(0, 0));
410 m_llist
->MoveCursorToBeginOfLine();
414 m_llist
->MoveCursorTo(m_llist
->GetSize());
416 m_llist
->MoveCursorToEndOfLine();
420 if(keyCode
== 'c' && ctrlDown
)
422 // this should work even in read-only mode
425 else if( IsEditable() )
427 /* First, handle control keys */
428 if(event
.ControlDown() && ! event
.AltDown())
440 m_llist
->DeleteLines(1);
442 case 'h': // like backspace
443 if(m_llist
->MoveCursorHorizontally(-1)) m_llist
->Delete(1);
446 m_llist
->DeleteToBeginOfLine();
449 m_llist
->DeleteToEndOfLine();
457 #ifdef WXLAYOUT_DEBUG
459 m_llist
->SetFont(-1,-1,-1,-1,true); // underlined
467 else if( event
.AltDown() && ! event
.ControlDown() )
473 m_llist
->DeleteWord();
480 else if ( ! event
.AltDown() && ! event
.ControlDown())
485 if(event
.ShiftDown())
489 if(event
.ShiftDown())
494 case WXK_BACK
: // backspace
495 if(m_llist
->MoveCursorHorizontally(-1)) m_llist
->Delete(1);
499 m_llist
->WrapLine(m_WrapMargin
);
500 m_llist
->LineBreak();
503 if((!(event
.ControlDown() || event
.AltDown() || event
.MetaDown()))
504 && (keyCode
< 256 && keyCode
>= 32)
507 if(m_WrapMargin
> 0 && isspace(keyCode
))
508 m_llist
->WrapLine(m_WrapMargin
);
509 m_llist
->Insert((char)keyCode
);
520 if(event
.ShiftDown())
521 m_llist
->ContinueSelection();
524 m_llist
->EndSelection();
529 // we must call ResizeScrollbars() before ScrollToCursor(), otherwise the
530 // ne cursor position might be outside the current scrolllbar range
534 // refresh the screen
535 DoPaint(m_llist
->GetUpdateRect());
539 wxLayoutWindow::OnKeyUp(wxKeyEvent
& event
)
541 if(event
.KeyCode() == WXK_SHIFT
&& m_llist
->IsSelecting())
543 m_llist
->EndSelection();
551 wxLayoutWindow::ScrollToCursor(void)
553 wxClientDC
dc( this );
556 int x0
,y0
,x1
,y1
, dx
, dy
;
558 // Calculate where the top of the visible area is:
560 GetScrollPixelsPerUnit(&dx
, &dy
);
563 WXLO_DEBUG(("ScrollToCursor: ViewStart is %d/%d", x0
, y0
));
565 // Get the size of the visible window:
566 GetClientSize(&x1
,&y1
);
568 // notice that the client size may be (0, 0)...
569 wxASSERT(x1
>= 0 && y1
>= 0);
571 // VZ: I think this is false - if you do it here, ResizeScrollbars() won't
572 // call SetScrollbars() later
574 // As we have the values anyway, use them to avoid unnecessary scrollbar
576 if(x1
> m_maxx
) m_maxx
= x1
;
577 if(y1
> m_maxy
) m_maxy
= y1
;
580 // Make sure that the scrollbars are at a position so that the cursor is
581 // visible if we are editing
582 WXLO_DEBUG(("m_ScrollToCursor = %d", (int) m_ScrollToCursor
));
583 wxPoint cc
= m_llist
->GetCursorScreenPos(dc
);
585 // the cursor should be completely visible in both directions
586 wxPoint
cs(m_llist
->GetCursorSize());
589 if ( cc
.x
< x0
|| cc
.x
>= x0
+ x1
- cs
.x
)
596 if ( cc
.y
< y0
|| cc
.y
>= y0
+ y1
- cs
.y
)
603 if ( nx
!= -1 || ny
!= -1 )
605 // set new view start
606 Scroll(nx
== -1 ? -1 : (nx
+dx
-1)/dx
, ny
== -1 ? -1 : (ny
+dy
-1)/dy
);
609 m_ScrollToCursor
= false;
614 wxLayoutWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
))
616 wxRect region
= GetUpdateRegion().GetBox();
617 InternalPaint(®ion
);
621 wxLayoutWindow::DoPaint(const wxRect
*updateRect
)
624 InternalPaint(updateRect
);
626 Refresh(FALSE
, updateRect
); // Causes bad flicker under wxGTK!!!
628 if ( !::UpdateWindow(GetHwnd()) )
629 wxLogLastError("UpdateWindow");
634 wxLayoutWindow::InternalPaint(const wxRect
*updateRect
)
636 wxPaintDC
dc( this );
639 #ifdef WXLAYOUT_USE_CARET
640 // hide the caret before drawing anything
642 #endif // WXLAYOUT_USE_CARET
644 int x0
,y0
,x1
,y1
, dx
, dy
;
646 // Calculate where the top of the visible area is:
648 GetScrollPixelsPerUnit(&dx
, &dy
);
651 // Get the size of the visible window:
652 GetClientSize(&x1
,&y1
);
658 WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
659 updateRect
->x
, updateRect
->y
,
660 updateRect
->x
+updateRect
->width
,
661 updateRect
->y
+updateRect
->height
));
668 /* Check whether the window has grown, if so, we need to reallocate
669 the bitmap to be larger. */
670 if(x1
> m_bitmapSize
.x
|| y1
> m_bitmapSize
.y
)
672 wxASSERT(m_bitmapSize
.x
> 0);
673 wxASSERT(m_bitmapSize
.y
> 0);
675 m_memDC
->SelectObject(wxNullBitmap
);
677 m_bitmapSize
= wxPoint(x1
,y1
);
678 m_bitmap
= new wxBitmap(x1
,y1
);
679 m_memDC
->SelectObject(*m_bitmap
);
682 m_memDC
->SetDeviceOrigin(0,0);
683 m_memDC
->SetBrush(wxBrush(m_llist
->GetDefaultStyleInfo().GetBGColour(),wxSOLID
));
684 m_memDC
->SetPen(wxPen(m_llist
->GetDefaultStyleInfo().GetBGColour(),
686 m_memDC
->SetLogicalFunction(wxCOPY
);
689 // fill the background with the background bitmap
694 w
= m_BGbitmap
->GetWidth(),
695 h
= m_BGbitmap
->GetHeight();
696 for(y
= 0; y
< y1
; y
+=h
)
697 for(x
= 0; x
< x1
; x
+=w
)
698 m_memDC
->DrawBitmap(*m_BGbitmap
, x
, y
);
699 m_memDC
->SetBackgroundMode(wxTRANSPARENT
);
702 // This is the important bit: we tell the list to draw itself
706 WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
707 updateRect
->x
, updateRect
->y
,
708 updateRect
->x
+updateRect
->width
,
709 updateRect
->y
+updateRect
->height
));
713 // Device origins on the memDC are suspect, we translate manually
714 // with the translate parameter of Draw().
715 wxPoint
offset(-x0
+WXLO_XOFFSET
,-y0
+WXLO_YOFFSET
);
716 m_llist
->Draw(*m_memDC
,offset
, y0
, y0
+y1
);
718 // We start calculating a new update rect before drawing the
719 // cursor, so that the cursor coordinates get included in the next
720 // update rectangle (although they are drawn on the memDC, this is
721 // needed to erase it):
722 m_llist
->InvalidateUpdateRect();
723 if(m_CursorVisibility
!= 0)
725 m_llist
->UpdateCursorScreenPos(dc
, true, offset
);
726 m_llist
->DrawCursor(*m_memDC
,
727 m_HaveFocus
&& IsEditable(), // draw a thick
728 // cursor for editable windows with focus
732 // Now copy everything to the screen:
734 // This somehow doesn't work, but even the following bit with the
735 // whole rect at once is still a bit broken I think.
736 wxRegionIterator
ri ( GetUpdateRegion() );
740 WXLO_DEBUG(("UpdateRegion: %ld,%ld, %ld,%ld",
741 ri
.GetX(),ri
.GetY(),ri
.GetW(),ri
.GetH()));
742 dc
.Blit(x0
+ri
.GetX(),y0
+ri
.GetY(),ri
.GetW(),ri
.GetH(),
743 m_memDC
,ri
.GetX(),ri
.GetY(),wxCOPY
,FALSE
);
749 // FIXME: Trying to copy only the changed parts, but it does not seem
751 // x0 = updateRect->x; y0 = updateRect->y;
752 // if(updateRect->height < y1)
753 // y1 = updateRect->height;
754 // y1 += WXLO_YOFFSET; //FIXME might not be needed
755 dc
.Blit(x0
,y0
,x1
,y1
,m_memDC
,0,0,wxCOPY
,FALSE
);
758 #ifdef WXLAYOUT_USE_CARET
759 // show the caret back after everything is redrawn
761 #endif // WXLAYOUT_USE_CARET
764 m_ScrollToCursor
= false;
766 if ( m_StatusBar
&& m_StatusFieldCursor
!= -1 )
768 static wxPoint
s_oldCursorPos(-1, -1);
770 wxPoint
pos(m_llist
->GetCursorPos());
772 // avoid unnecessary status bar refreshes
773 if ( pos
!= s_oldCursorPos
)
775 s_oldCursorPos
= pos
;
778 label
.Printf(_("Ln:%d Col:%d"), pos
.y
+ 1, pos
.x
+ 1);
779 m_StatusBar
->SetStatusText(label
, m_StatusFieldCursor
);
784 // change the range and position of scrollbars
786 wxLayoutWindow::ResizeScrollbars(bool exact
)
788 wxPoint max
= m_llist
->GetSize();
790 WXLO_DEBUG(("ResizeScrollbars: max size = (%ld, %ld)",
791 (long int)max
.x
, (long int) max
.y
));
793 if( max
.x
> m_maxx
- WXLO_ROFFSET
|| max
.y
> m_maxy
- WXLO_BOFFSET
|| exact
)
797 // add an extra bit to the sizes to avoid future updates
798 max
.x
+= WXLO_ROFFSET
;
799 max
.y
+= WXLO_BOFFSET
;
802 ViewStart(&m_ViewStartX
, &m_ViewStartY
);
803 SetScrollbars(X_SCROLL_PAGE
, Y_SCROLL_PAGE
,
804 max
.x
/ X_SCROLL_PAGE
+ 1, max
.y
/ Y_SCROLL_PAGE
+ 1,
805 m_ViewStartX
, m_ViewStartY
,
808 m_maxx
= max
.x
+ X_SCROLL_PAGE
;
809 m_maxy
= max
.y
+ Y_SCROLL_PAGE
;
814 wxLayoutWindow::Paste(void)
817 if (wxTheClipboard
->Open())
819 #if wxUSE_PRIVATE_CLIPBOARD_FORMAT
820 wxLayoutDataObject wxldo
;
821 if (wxTheClipboard
->IsSupported( wxldo
.GetFormat() ))
823 wxTheClipboard
->GetData(&wxldo
);
826 //FIXME: missing functionality m_llist->Insert(wxldo.GetList());
831 wxTextDataObject data
;
832 if (wxTheClipboard
->IsSupported( data
.GetFormat() ))
834 wxTheClipboard
->GetData(&data
);
835 wxString text
= data
.GetText();
836 wxLayoutImportText( m_llist
, text
);
839 wxTheClipboard
->Close();
843 /* My attempt to get the primary selection, but it does not
845 if(text
.Length() == 0)
847 wxTextCtrl
tmp_tctrl(this,-1);
849 text
+= tmp_tctrl
.GetValue();
855 wxLayoutWindow::Copy(bool invalidate
)
857 // Calling GetSelection() will automatically do an EndSelection()
858 // on the list, but we need to take a note of it, too:
862 m_llist
->EndSelection();
865 wxLayoutDataObject wldo
;
866 wxLayoutList
*llist
= m_llist
->GetSelection(&wldo
, invalidate
);
869 // Export selection as text:
871 wxLayoutExportObject
*export
;
872 wxLayoutExportStatus
status(llist
);
873 while((export
= wxLayoutExport( &status
, WXLO_EXPORT_AS_TEXT
)) != NULL
)
875 if(export
->type
== WXLO_EXPORT_TEXT
)
876 text
<< *(export
->content
.text
);
881 // The exporter always appends a newline, so we chop it off if it
884 size_t len
= text
.Length();
885 if(len
> 2 && text
[len
-2] == '\r') // Windows
886 text
= text
.Mid(0,len
-2);
887 else if(len
> 1 && text
[len
-1] == '\n')
888 text
= text
.Mid(0,len
-1);
892 if (wxTheClipboard
->Open())
894 wxTextDataObject
*data
= new wxTextDataObject( text
);
895 bool rc
= wxTheClipboard
->SetData( data
);
896 #if wxUSE_PRIVATE_CLIPBOARD_FORMAT
897 rc
|= wxTheClipboard
->AddData( &wldo
);
899 wxTheClipboard
->Close();
907 wxLayoutWindow::Cut(void)
909 if(Copy(false)) // do not invalidate selection after copy
911 m_llist
->DeleteSelection();
918 wxLayoutWindow::Find(const wxString
&needle
,
923 if(fromWhere
== NULL
)
924 found
= m_llist
->FindText(needle
, m_llist
->GetCursorPos());
926 found
= m_llist
->FindText(needle
, *fromWhere
);
934 m_llist
->MoveCursorTo(found
);
942 wxLayoutWindow::MakeFormatMenu()
944 wxMenu
*m
= new wxMenu(_("Layout Menu"));
946 m
->Append(WXLOWIN_MENU_LARGER
,_("&Larger"),_("Switch to larger font."), false);
947 m
->Append(WXLOWIN_MENU_SMALLER
,_("&Smaller"),_("Switch to smaller font."), false);
948 m
->AppendSeparator();
949 m
->Append(WXLOWIN_MENU_UNDERLINE_ON
, _("&Underline on"),_("Activate underline mode."), false);
950 m
->Append(WXLOWIN_MENU_UNDERLINE_OFF
,_("&Underline off"),_("Deactivate underline mode."), false);
951 m
->Append(WXLOWIN_MENU_BOLD_ON
,_("&Bold on"),_("Activate bold mode."), false);
952 m
->Append(WXLOWIN_MENU_BOLD_OFF
,_("&Bold off"),_("Deactivate bold mode."), false);
953 m
->Append(WXLOWIN_MENU_ITALICS_ON
,_("&Italics on"),_("Activate italics mode."), false);
954 m
->Append(WXLOWIN_MENU_ITALICS_OFF
,_("&Italics off"),_("Deactivate italics mode."), false);
955 m
->AppendSeparator();
956 m
->Append(WXLOWIN_MENU_ROMAN
,_("&Roman"),_("Switch to roman font."), false);
957 m
->Append(WXLOWIN_MENU_TYPEWRITER
,_("&Typewriter"),_("Switch to typewriter font."), false);
958 m
->Append(WXLOWIN_MENU_SANSSERIF
,_("&Sans Serif"),_("Switch to sans serif font."), false);
962 void wxLayoutWindow::OnMenu(wxCommandEvent
& event
)
964 switch (event
.GetId())
966 case WXLOWIN_MENU_LARGER
:
967 m_llist
->SetFontLarger(); break;
968 case WXLOWIN_MENU_SMALLER
:
969 m_llist
->SetFontSmaller(); break;
970 case WXLOWIN_MENU_UNDERLINE_ON
:
971 m_llist
->SetFontUnderline(true); break;
972 case WXLOWIN_MENU_UNDERLINE_OFF
:
973 m_llist
->SetFontUnderline(false); break;
974 case WXLOWIN_MENU_BOLD_ON
:
975 m_llist
->SetFontWeight(wxBOLD
); break;
976 case WXLOWIN_MENU_BOLD_OFF
:
977 m_llist
->SetFontWeight(wxNORMAL
); break;
978 case WXLOWIN_MENU_ITALICS_ON
:
979 m_llist
->SetFontStyle(wxITALIC
); break;
980 case WXLOWIN_MENU_ITALICS_OFF
:
981 m_llist
->SetFontStyle(wxNORMAL
); break;
982 case WXLOWIN_MENU_ROMAN
:
983 m_llist
->SetFontFamily(wxROMAN
); break;
984 case WXLOWIN_MENU_TYPEWRITER
:
985 m_llist
->SetFontFamily(wxFIXED
); break;
986 case WXLOWIN_MENU_SANSSERIF
:
987 m_llist
->SetFontFamily(wxSWISS
); break;
992 wxLayoutWindow::OnSetFocus(wxFocusEvent
&ev
)
999 wxLayoutWindow::OnKillFocus(wxFocusEvent
&ev
)
1001 m_HaveFocus
= false;