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
)
89 EVT_CHAR (wxLayoutWindow::OnChar
)
90 EVT_KEY_UP (wxLayoutWindow::OnKeyUp
)
92 EVT_LEFT_DOWN(wxLayoutWindow::OnLeftMouseClick
)
93 EVT_RIGHT_DOWN(wxLayoutWindow::OnRightMouseClick
)
94 EVT_LEFT_DCLICK(wxLayoutWindow::OnMouseDblClick
)
95 EVT_MOTION (wxLayoutWindow::OnMouseMove
)
97 EVT_UPDATE_UI(WXLOWIN_MENU_UNDERLINE
, wxLayoutWindow::OnUpdateMenuUnderline
)
98 EVT_UPDATE_UI(WXLOWIN_MENU_BOLD
, wxLayoutWindow::OnUpdateMenuBold
)
99 EVT_UPDATE_UI(WXLOWIN_MENU_ITALICS
, wxLayoutWindow::OnUpdateMenuItalic
)
100 EVT_MENU_RANGE(WXLOWIN_MENU_FIRST
, WXLOWIN_MENU_LAST
, wxLayoutWindow::OnMenu
)
102 EVT_SET_FOCUS(wxLayoutWindow::OnSetFocus
)
103 EVT_KILL_FOCUS(wxLayoutWindow::OnKillFocus
)
106 // ===========================================================================
108 // ===========================================================================
110 /* LEAVE IT HERE UNTIL WXGTK WORKS AGAIN!!! */
112 /// allows me to compare to wxPoints
113 static bool operator != (wxPoint
const &p1
, wxPoint
const &p2
)
115 return p1
.x
!= p2
.x
|| p1
.y
!= p2
.y
;
119 #ifndef wxWANTS_CHARS
120 #define wxWANTS_CHARS 0
123 // ----------------------------------------------------------------------------
125 // ----------------------------------------------------------------------------
127 wxLayoutWindow::wxLayoutWindow(wxWindow
*parent
)
128 : wxScrolledWindow(parent
, -1,
129 wxDefaultPosition
, wxDefaultSize
,
130 wxHSCROLL
| wxVSCROLL
|
134 SetStatusBar(NULL
); // don't use statusbar
136 m_doSendEvents
= false;
137 m_ViewStartX
= 0; m_ViewStartY
= 0;
138 m_DoPopupMenu
= true;
139 m_PopupMenu
= MakeFormatMenu();
140 m_memDC
= new wxMemoryDC
;
141 m_bitmap
= new wxBitmap(4,4);
142 m_bitmapSize
= wxPoint(4,4);
143 m_llist
= new wxLayoutList();
146 m_ScrollToCursor
= false;
148 wxPoint max
= m_llist
->GetSize();
149 SetScrollbars(X_SCROLL_PAGE
, Y_SCROLL_PAGE
,
150 max
.x
/ X_SCROLL_PAGE
+ 1, max
.y
/ Y_SCROLL_PAGE
+ 1);
151 EnableScrolling(true, true);
152 m_maxx
= max
.x
+ X_SCROLL_PAGE
;
153 m_maxy
= max
.y
+ Y_SCROLL_PAGE
;
156 #ifdef WXLAYOUT_USE_CARET
157 // FIXME cursor size shouldn't be hardcoded
158 wxCaret
*caret
= new wxCaret(this, 2, 20);
160 m_llist
->SetCaret(caret
);
162 #endif // WXLAYOUT_USE_CARET
164 m_HandCursor
= FALSE
;
165 m_CursorVisibility
= -1;
166 SetCursor(wxCURSOR_IBEAM
);
170 wxLayoutWindow::~wxLayoutWindow()
172 delete m_memDC
; // deletes bitmap automatically (?)
176 SetBackgroundBitmap(NULL
);
180 wxLayoutWindow::Clear(int family
,
188 GetLayoutList()->Clear(family
,size
,style
,weight
,underline
,fg
,bg
);
189 SetBackgroundColour(GetLayoutList()->GetDefaultStyleInfo().GetBGColour());
190 ResizeScrollbars(true);
193 wxScrolledWindow::Clear();
194 DoPaint((wxRect
*)NULL
);
198 wxLayoutWindow::OnMouse(int eventId
, wxMouseEvent
& event
)
200 wxClientDC
dc( this );
202 if ( eventId
!= WXLOWIN_MENU_MOUSEMOVE
)
204 // moving the mouse in a window shouldn't give it the focus!
209 findPos
.x
= dc
.DeviceToLogicalX(event
.GetX());
210 findPos
.y
= dc
.DeviceToLogicalY(event
.GetY());
212 findPos
.x
-= WXLO_XOFFSET
;
213 findPos
.y
-= WXLO_YOFFSET
;
215 if(findPos
.x
< 0) findPos
.x
= 0;
216 if(findPos
.y
< 0) findPos
.y
= 0;
218 m_ClickPosition
= wxPoint(event
.GetX(), event
.GetY());
222 wxLayoutObject
*obj
= m_llist
->FindObjectScreen(dc
, findPos
,
224 wxLayoutObject::UserData
*u
= obj
? obj
->GetUserData() : NULL
;
226 //has the mouse only been moved?
227 if(eventId
== WXLOWIN_MENU_MOUSEMOVE
)
229 // found is only true if we are really over an object, not just
231 if(found
&& u
&& ! m_Selecting
)
234 SetCursor(wxCURSOR_HAND
);
236 if(m_StatusBar
&& m_StatusFieldLabel
!= -1)
238 const wxString
&label
= u
->GetLabel();
240 m_StatusBar
->SetStatusText(label
,
247 SetCursor(wxCURSOR_IBEAM
);
248 m_HandCursor
= FALSE
;
249 if(m_StatusBar
&& m_StatusFieldLabel
!= -1)
250 m_StatusBar
->SetStatusText("", m_StatusFieldLabel
);
252 if(event
.LeftIsDown())
256 m_llist
->StartSelection(wxPoint(-1, -1), m_ClickPosition
);
258 DoPaint(); // TODO: we don't have to redraw everything!
262 m_llist
->ContinueSelection(cursorPos
, m_ClickPosition
);
263 DoPaint(); // TODO: we don't have to redraw everything!
266 if(m_Selecting
&& ! event
.LeftIsDown())
268 m_llist
->EndSelection(cursorPos
, m_ClickPosition
);
270 DoPaint(); // TODO: we don't have to redraw everything!
279 else if(eventId
== WXLOWIN_MENU_LCLICK
)
281 // always move cursor to mouse click:
282 m_llist
->MoveCursorTo(cursorPos
);
284 // clicking a mouse removes the selection
285 if ( m_llist
->HasSelection() )
287 m_llist
->DiscardSelection();
288 DoPaint(); // TODO: we don't have to redraw everything!
291 // Calculate where the top of the visible area is:
295 GetScrollPixelsPerUnit(&dx
, &dy
);
298 wxPoint
offset(-x0
+WXLO_XOFFSET
, -y0
+WXLO_YOFFSET
);
300 if(m_CursorVisibility
== -1)
301 m_CursorVisibility
= 1;
303 if(m_CursorVisibility
!= 0)
305 // draw a thick cursor for editable windows with focus
306 m_llist
->DrawCursor(dc
, m_HaveFocus
&& IsEditable(), offset
);
309 // VZ: this should be unnecessary because mouse can only click on a
310 // visible part of the canvas
316 DoPaint(); // DoPaint suppresses flicker under GTK
320 // notify about mouse events?
323 // only do the menu if activated, editable and not on a clickable object
324 if(eventId
== WXLOWIN_MENU_RCLICK
326 && (! obj
|| u
== NULL
))
328 PopupMenu(m_PopupMenu
, m_ClickPosition
.x
, m_ClickPosition
.y
);
333 // find the object at this position
336 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, eventId
);
337 commandEvent
.SetEventObject( this );
338 commandEvent
.SetClientData((char *)obj
);
339 GetEventHandler()->ProcessEvent(commandEvent
);
348 * Some simple keyboard handling.
351 wxLayoutWindow::OnChar(wxKeyEvent
& event
)
353 int keyCode
= event
.KeyCode();
355 #ifdef WXLAYOUT_DEBUG
356 if(keyCode
== WXK_F1
)
363 if(! m_Selecting
&& event
.ShiftDown())
376 m_llist
->StartSelection();
383 // If needed, make cursor visible:
384 if(m_CursorVisibility
== -1)
385 m_CursorVisibility
= 1;
387 /* These two nested switches work like this:
388 The first one processes all non-editing keycodes, to move the
389 cursor, etc. It's default will process all keycodes causing
390 modifications to the buffer, but only if editing is allowed.
392 bool ctrlDown
= event
.ControlDown();
397 m_llist
->MoveCursorWord(1);
399 m_llist
->MoveCursorHorizontally(1);
403 m_llist
->MoveCursorWord(-1);
405 m_llist
->MoveCursorHorizontally(-1);
408 m_llist
->MoveCursorVertically(-1);
411 m_llist
->MoveCursorVertically(1);
414 m_llist
->MoveCursorVertically(-Y_SCROLL_PAGE
);
417 m_llist
->MoveCursorVertically(Y_SCROLL_PAGE
);
421 m_llist
->MoveCursorTo(wxPoint(0, 0));
423 m_llist
->MoveCursorToBeginOfLine();
427 m_llist
->MoveCursorTo(m_llist
->GetSize());
429 m_llist
->MoveCursorToEndOfLine();
433 if(keyCode
== 'c' && ctrlDown
)
435 // this should work even in read-only mode
438 else if( IsEditable() )
440 /* First, handle control keys */
441 if(event
.ControlDown() && ! event
.AltDown())
453 m_llist
->DeleteLines(1);
455 case 'h': // like backspace
456 if(m_llist
->MoveCursorHorizontally(-1)) m_llist
->Delete(1);
459 m_llist
->DeleteToBeginOfLine();
462 m_llist
->DeleteToEndOfLine();
470 #ifdef WXLAYOUT_DEBUG
472 m_llist
->SetFont(-1,-1,-1,-1,true); // underlined
480 else if( event
.AltDown() && ! event
.ControlDown() )
486 m_llist
->DeleteWord();
493 else if ( ! event
.AltDown() && ! event
.ControlDown())
498 if(event
.ShiftDown())
502 if(event
.ShiftDown())
507 case WXK_BACK
: // backspace
508 if(m_llist
->MoveCursorHorizontally(-1)) m_llist
->Delete(1);
512 m_llist
->WrapLine(m_WrapMargin
);
513 m_llist
->LineBreak();
516 if((!(event
.ControlDown() || event
.AltDown() || event
.MetaDown()))
517 && (keyCode
< 256 && keyCode
>= 32)
520 if(m_WrapMargin
> 0 && isspace(keyCode
))
521 m_llist
->WrapLine(m_WrapMargin
);
522 m_llist
->Insert((char)keyCode
);
533 if(event
.ShiftDown())
534 m_llist
->ContinueSelection();
537 m_llist
->EndSelection();
542 // we must call ResizeScrollbars() before ScrollToCursor(), otherwise the
543 // ne cursor position might be outside the current scrolllbar range
547 // refresh the screen
548 DoPaint(m_llist
->GetUpdateRect());
552 wxLayoutWindow::OnKeyUp(wxKeyEvent
& event
)
554 if(event
.KeyCode() == WXK_SHIFT
&& m_llist
->IsSelecting())
556 m_llist
->EndSelection();
564 wxLayoutWindow::ScrollToCursor(void)
566 wxClientDC
dc( this );
569 int x0
,y0
,x1
,y1
, dx
, dy
;
571 // Calculate where the top of the visible area is:
573 GetScrollPixelsPerUnit(&dx
, &dy
);
576 WXLO_DEBUG(("ScrollToCursor: ViewStart is %d/%d", x0
, y0
));
578 // Get the size of the visible window:
579 GetClientSize(&x1
,&y1
);
581 // notice that the client size may be (0, 0)...
582 wxASSERT(x1
>= 0 && y1
>= 0);
584 // VZ: I think this is false - if you do it here, ResizeScrollbars() won't
585 // call SetScrollbars() later
587 // As we have the values anyway, use them to avoid unnecessary scrollbar
589 if(x1
> m_maxx
) m_maxx
= x1
;
590 if(y1
> m_maxy
) m_maxy
= y1
;
593 // Make sure that the scrollbars are at a position so that the cursor is
594 // visible if we are editing
595 WXLO_DEBUG(("m_ScrollToCursor = %d", (int) m_ScrollToCursor
));
596 wxPoint cc
= m_llist
->GetCursorScreenPos(dc
);
598 // the cursor should be completely visible in both directions
599 wxPoint
cs(m_llist
->GetCursorSize());
602 if ( cc
.x
< x0
|| cc
.x
>= x0
+ x1
- cs
.x
)
609 if ( cc
.y
< y0
|| cc
.y
>= y0
+ y1
- cs
.y
)
616 if ( nx
!= -1 || ny
!= -1 )
618 // set new view start
619 Scroll(nx
== -1 ? -1 : (nx
+dx
-1)/dx
, ny
== -1 ? -1 : (ny
+dy
-1)/dy
);
622 m_ScrollToCursor
= false;
627 wxLayoutWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
))
629 wxRect region
= GetUpdateRegion().GetBox();
630 InternalPaint(®ion
);
634 wxLayoutWindow::DoPaint(const wxRect
*updateRect
)
636 // Causes bad flicker under wxGTK!!!
638 InternalPaint(updateRect
);
640 Refresh(FALSE
); //, updateRect);
642 if ( !::UpdateWindow(GetHwnd()) )
643 wxLogLastError("UpdateWindow");
648 wxLayoutWindow::InternalPaint(const wxRect
*updateRect
)
650 wxPaintDC
dc( this );
653 #ifdef WXLAYOUT_USE_CARET
654 // hide the caret before drawing anything
656 #endif // WXLAYOUT_USE_CARET
658 int x0
,y0
,x1
,y1
, dx
, dy
;
660 // Calculate where the top of the visible area is:
662 GetScrollPixelsPerUnit(&dx
, &dy
);
665 // Get the size of the visible window:
666 GetClientSize(&x1
,&y1
);
672 WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
673 updateRect
->x
, updateRect
->y
,
674 updateRect
->x
+updateRect
->width
,
675 updateRect
->y
+updateRect
->height
));
682 /* Check whether the window has grown, if so, we need to reallocate
683 the bitmap to be larger. */
684 if(x1
> m_bitmapSize
.x
|| y1
> m_bitmapSize
.y
)
686 wxASSERT(m_bitmapSize
.x
> 0);
687 wxASSERT(m_bitmapSize
.y
> 0);
689 m_memDC
->SelectObject(wxNullBitmap
);
691 m_bitmapSize
= wxPoint(x1
,y1
);
692 m_bitmap
= new wxBitmap(x1
,y1
);
693 m_memDC
->SelectObject(*m_bitmap
);
696 m_memDC
->SetDeviceOrigin(0,0);
697 m_memDC
->SetBrush(wxBrush(m_llist
->GetDefaultStyleInfo().GetBGColour(),wxSOLID
));
698 m_memDC
->SetPen(wxPen(m_llist
->GetDefaultStyleInfo().GetBGColour(),
700 m_memDC
->SetLogicalFunction(wxCOPY
);
703 // fill the background with the background bitmap
708 w
= m_BGbitmap
->GetWidth(),
709 h
= m_BGbitmap
->GetHeight();
710 for(y
= 0; y
< y1
; y
+=h
)
711 for(x
= 0; x
< x1
; x
+=w
)
712 m_memDC
->DrawBitmap(*m_BGbitmap
, x
, y
);
713 m_memDC
->SetBackgroundMode(wxTRANSPARENT
);
716 // This is the important bit: we tell the list to draw itself
720 WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
721 updateRect
->x
, updateRect
->y
,
722 updateRect
->x
+updateRect
->width
,
723 updateRect
->y
+updateRect
->height
));
727 // Device origins on the memDC are suspect, we translate manually
728 // with the translate parameter of Draw().
729 wxPoint
offset(-x0
+WXLO_XOFFSET
,-y0
+WXLO_YOFFSET
);
730 m_llist
->Draw(*m_memDC
,offset
, y0
, y0
+y1
);
732 // We start calculating a new update rect before drawing the
733 // cursor, so that the cursor coordinates get included in the next
734 // update rectangle (although they are drawn on the memDC, this is
735 // needed to erase it):
736 m_llist
->InvalidateUpdateRect();
737 if(m_CursorVisibility
!= 0)
739 // draw a thick cursor for editable windows with focus
740 m_llist
->DrawCursor(*m_memDC
,
741 m_HaveFocus
&& IsEditable(),
745 // Now copy everything to the screen:
747 // This somehow doesn't work, but even the following bit with the
748 // whole rect at once is still a bit broken I think.
749 wxRegionIterator
ri ( GetUpdateRegion() );
753 WXLO_DEBUG(("UpdateRegion: %ld,%ld, %ld,%ld",
754 ri
.GetX(),ri
.GetY(),ri
.GetW(),ri
.GetH()));
755 dc
.Blit(x0
+ri
.GetX(),y0
+ri
.GetY(),ri
.GetW(),ri
.GetH(),
756 m_memDC
,ri
.GetX(),ri
.GetY(),wxCOPY
,FALSE
);
762 // FIXME: Trying to copy only the changed parts, but it does not seem
764 // x0 = updateRect->x; y0 = updateRect->y;
765 // if(updateRect->height < y1)
766 // y1 = updateRect->height;
767 // y1 += WXLO_YOFFSET; //FIXME might not be needed
768 dc
.Blit(x0
,y0
,x1
,y1
,m_memDC
,0,0,wxCOPY
,FALSE
);
771 #ifdef WXLAYOUT_USE_CARET
772 // show the caret back after everything is redrawn
774 #endif // WXLAYOUT_USE_CARET
777 m_ScrollToCursor
= false;
779 if ( m_StatusBar
&& m_StatusFieldCursor
!= -1 )
781 static wxPoint
s_oldCursorPos(-1, -1);
783 wxPoint
pos(m_llist
->GetCursorPos());
785 // avoid unnecessary status bar refreshes
786 if ( pos
!= s_oldCursorPos
)
788 s_oldCursorPos
= pos
;
791 label
.Printf(_("Ln:%d Col:%d"), pos
.y
+ 1, pos
.x
+ 1);
792 m_StatusBar
->SetStatusText(label
, m_StatusFieldCursor
);
797 // change the range and position of scrollbars
799 wxLayoutWindow::ResizeScrollbars(bool exact
)
801 wxPoint max
= m_llist
->GetSize();
803 WXLO_DEBUG(("ResizeScrollbars: max size = (%ld, %ld)",
804 (long int)max
.x
, (long int) max
.y
));
806 if( max
.x
> m_maxx
- WXLO_ROFFSET
|| max
.y
> m_maxy
- WXLO_BOFFSET
|| exact
)
810 // add an extra bit to the sizes to avoid future updates
811 max
.x
+= WXLO_ROFFSET
;
812 max
.y
+= WXLO_BOFFSET
;
815 ViewStart(&m_ViewStartX
, &m_ViewStartY
);
816 SetScrollbars(X_SCROLL_PAGE
, Y_SCROLL_PAGE
,
817 max
.x
/ X_SCROLL_PAGE
+ 1, max
.y
/ Y_SCROLL_PAGE
+ 1,
818 m_ViewStartX
, m_ViewStartY
,
821 m_maxx
= max
.x
+ X_SCROLL_PAGE
;
822 m_maxy
= max
.y
+ Y_SCROLL_PAGE
;
827 wxLayoutWindow::Paste(void)
830 if (wxTheClipboard
->Open())
832 #if wxUSE_PRIVATE_CLIPBOARD_FORMAT
833 wxLayoutDataObject wxldo
;
834 if (wxTheClipboard
->IsSupported( wxldo
.GetFormat() ))
836 wxTheClipboard
->GetData(&wxldo
);
839 //FIXME: missing functionality m_llist->Insert(wxldo.GetList());
844 wxTextDataObject data
;
845 if (wxTheClipboard
->IsSupported( data
.GetFormat() ))
847 wxTheClipboard
->GetData(&data
);
848 wxString text
= data
.GetText();
849 wxLayoutImportText( m_llist
, text
);
852 wxTheClipboard
->Close();
856 /* My attempt to get the primary selection, but it does not
858 if(text
.Length() == 0)
860 wxTextCtrl
tmp_tctrl(this,-1);
862 text
+= tmp_tctrl
.GetValue();
868 wxLayoutWindow::Copy(bool invalidate
)
870 // Calling GetSelection() will automatically do an EndSelection()
871 // on the list, but we need to take a note of it, too:
875 m_llist
->EndSelection();
878 wxLayoutDataObject wldo
;
879 wxLayoutList
*llist
= m_llist
->GetSelection(&wldo
, invalidate
);
882 // Export selection as text:
884 wxLayoutExportObject
*export
;
885 wxLayoutExportStatus
status(llist
);
886 while((export
= wxLayoutExport( &status
, WXLO_EXPORT_AS_TEXT
)) != NULL
)
888 if(export
->type
== WXLO_EXPORT_TEXT
)
889 text
<< *(export
->content
.text
);
894 // The exporter always appends a newline, so we chop it off if it
897 size_t len
= text
.Length();
898 if(len
> 2 && text
[len
-2] == '\r') // Windows
899 text
= text
.Mid(0,len
-2);
900 else if(len
> 1 && text
[len
-1] == '\n')
901 text
= text
.Mid(0,len
-1);
905 if (wxTheClipboard
->Open())
907 wxTextDataObject
*data
= new wxTextDataObject( text
);
908 bool rc
= wxTheClipboard
->SetData( data
);
909 #if wxUSE_PRIVATE_CLIPBOARD_FORMAT
910 rc
|= wxTheClipboard
->AddData( &wldo
);
912 wxTheClipboard
->Close();
920 wxLayoutWindow::Cut(void)
922 if(Copy(false)) // do not invalidate selection after copy
924 m_llist
->DeleteSelection();
931 wxLayoutWindow::Find(const wxString
&needle
,
936 if(fromWhere
== NULL
)
937 found
= m_llist
->FindText(needle
, m_llist
->GetCursorPos());
939 found
= m_llist
->FindText(needle
, *fromWhere
);
947 m_llist
->MoveCursorTo(found
);
955 wxLayoutWindow::MakeFormatMenu()
957 wxMenu
*m
= new wxMenu(_("Layout Menu"));
959 m
->Append(WXLOWIN_MENU_LARGER
,_("&Larger"),_("Switch to larger font."), false);
960 m
->Append(WXLOWIN_MENU_SMALLER
,_("&Smaller"),_("Switch to smaller font."), false);
961 m
->AppendSeparator();
962 m
->Append(WXLOWIN_MENU_UNDERLINE
, _("&Underline"),_("Underline mode."), true);
963 m
->Append(WXLOWIN_MENU_BOLD
, _("&Bold"),_("Bold mode."), true);
964 m
->Append(WXLOWIN_MENU_ITALICS
, _("&Italics"),_("Italics mode."), true);
965 m
->AppendSeparator();
966 m
->Append(WXLOWIN_MENU_ROMAN
,_("&Roman"),_("Switch to roman font."), false);
967 m
->Append(WXLOWIN_MENU_TYPEWRITER
,_("&Typewriter"),_("Switch to typewriter font."), false);
968 m
->Append(WXLOWIN_MENU_SANSSERIF
,_("&Sans Serif"),_("Switch to sans serif font."), false);
973 void wxLayoutWindow::OnUpdateMenuUnderline(wxUpdateUIEvent
& event
)
975 event
.Check(m_llist
->IsFontUnderlined());
978 void wxLayoutWindow::OnUpdateMenuBold(wxUpdateUIEvent
& event
)
980 event
.Check(m_llist
->IsFontBold());
983 void wxLayoutWindow::OnUpdateMenuItalic(wxUpdateUIEvent
& event
)
985 event
.Check(m_llist
->IsFontItalic());
988 void wxLayoutWindow::OnMenu(wxCommandEvent
& event
)
990 switch (event
.GetId())
992 case WXLOWIN_MENU_LARGER
:
993 m_llist
->SetFontLarger();
995 case WXLOWIN_MENU_SMALLER
:
996 m_llist
->SetFontSmaller();
999 case WXLOWIN_MENU_UNDERLINE
:
1000 m_llist
->ToggleFontUnderline();
1002 case WXLOWIN_MENU_BOLD
:
1003 m_llist
->ToggleFontWeight();
1005 case WXLOWIN_MENU_ITALICS
:
1006 m_llist
->ToggleFontItalics();
1009 case WXLOWIN_MENU_ROMAN
:
1010 m_llist
->SetFontFamily(wxROMAN
); break;
1011 case WXLOWIN_MENU_TYPEWRITER
:
1012 m_llist
->SetFontFamily(wxFIXED
); break;
1013 case WXLOWIN_MENU_SANSSERIF
:
1014 m_llist
->SetFontFamily(wxSWISS
); break;
1019 wxLayoutWindow::OnSetFocus(wxFocusEvent
&ev
)
1026 wxLayoutWindow::OnKillFocus(wxFocusEvent
&ev
)
1028 m_HaveFocus
= false;