# endif // USE_PCH
# include "gui/wxlwindow.h"
#else
+# ifdef __WXMSW__
+# include <windows.h>
+
+# undef FindWindow
+# undef GetCharWidth
+# undef StartDoc
+# endif
+
# include "wxlwindow.h"
# define TRACEMESSAGE(x)
#endif
EVT_LEFT_DOWN(wxLayoutWindow::OnLeftMouseClick)
EVT_RIGHT_DOWN(wxLayoutWindow::OnRightMouseClick)
EVT_LEFT_DCLICK(wxLayoutWindow::OnMouseDblClick)
+ EVT_MENU(WXLOWIN_MENU_LARGER, wxLayoutWindow::OnMenu)
+ EVT_MENU(WXLOWIN_MENU_SMALLER, wxLayoutWindow::OnMenu)
+ EVT_MENU(WXLOWIN_MENU_UNDERLINE, wxLayoutWindow::OnMenu)
+ EVT_MENU(WXLOWIN_MENU_BOLD, wxLayoutWindow::OnMenu)
+ EVT_MENU(WXLOWIN_MENU_ITALICS, wxLayoutWindow::OnMenu)
+ EVT_MENU(WXLOWIN_MENU_ROMAN, wxLayoutWindow::OnMenu)
+ EVT_MENU(WXLOWIN_MENU_TYPEWRITER, wxLayoutWindow::OnMenu)
+ EVT_MENU(WXLOWIN_MENU_SANSSERIF, wxLayoutWindow::OnMenu)
END_EVENT_TABLE()
wxLayoutWindow::wxLayoutWindow(wxWindow *parent)
m_ScrollbarsSet = false;
m_doSendEvents = false;
m_ViewStartX = 0; m_ViewStartY = 0;
-
-
+ m_DoPopupMenu = true;
+ m_PopupMenu = NULL;
+
CoordType
max_x, max_y, lineHeight;
m_llist.GetSize(&max_x, &max_y, &lineHeight);
wxPaintDC dc( this );
PrepareDC( dc );
SetFocus();
-
+
wxPoint findPos;
findPos.x = dc.DeviceToLogicalX(event.GetX());
findPos.y = dc.DeviceToLogicalY(event.GetY());
TRACEMESSAGE(("wxLayoutWindow::OnMouse: (%d, %d) -> (%d, %d)",
event.GetX(), event.GetY(), findPos.x, findPos.y));
+ if(eventId == WXLOWIN_MENU_RCLICK && m_DoPopupMenu && m_llist.IsEditable())
+ {
+ // when does this menu get freed?
+ // how do we handle toggling? FIXME
+ PopupMenu(MakeFormatMenu(), event.GetX(), event.GetY());
+ return;
+ }
// find the object at this position
wxLayoutObjectBase *obj = m_llist.Find(findPos);
if(obj)
break;
case WXK_END:
p = m_llist.GetCursor();
- p.x = m_llist.GetLineLength(m_llist.FindCurrentObject(NULL));
+ p.x = m_llist.GetLineLength(m_llist.GetCurrentObject());
m_llist.SetCursor(p);
break;
case WXK_DELETE :
if(event.ControlDown()) // delete to end of line
{
help = m_llist.GetLineLength(
- m_llist.FindCurrentObject(NULL))
+ m_llist.GetCurrentObject())
- m_llist.GetCursor().x;
m_llist.Delete(help ? help : 1);
}
case WXK_F1:
m_llist.Debug();
break;
+ case WXK_F2:
+ m_llist.WrapLine();
+ break;
#endif
default:
String tmp;
tmp += keyCode;
m_llist.Insert(tmp);
+ m_llist.WrapLine();
}
break;
}
dc.EndDoc();
}
}
+
+wxMenu *
+wxLayoutWindow::MakeFormatMenu()
+{
+ if(m_PopupMenu)
+ return m_PopupMenu;
+
+ wxMenu *m = new wxMenu();
+
+ m->Append(WXLOWIN_MENU_LARGER ,_("&Larger"),_("Switch to larger font."), false);
+ m->Append(WXLOWIN_MENU_SMALLER ,_("&Smaller"),_("Switch to smaller font."), false);
+ m->AppendSeparator();
+ m->Append(WXLOWIN_MENU_UNDERLINE,_("&Underline"),_("Toggle underline mode."), true);
+ m->Append(WXLOWIN_MENU_BOLD ,_("&Bold"),_("Toggle bold mode."), true);
+ m->Append(WXLOWIN_MENU_ITALICS ,_("&Italics"),_("Toggle italics mode."), true);
+ m->AppendSeparator();
+ m->Append(WXLOWIN_MENU_ROMAN ,_("&Roman"),_("Toggle underline mode."), false);
+ m->Append(WXLOWIN_MENU_TYPEWRITER,_("&Typewriter"),_("Toggle bold mode."), false);
+ m->Append(WXLOWIN_MENU_SANSSERIF ,_("&Sans Serif"),_("Toggle italics mode."), false);
+
+ return m_PopupMenu = m;
+}
+
+void wxLayoutWindow::OnMenu(wxCommandEvent& event)
+{
+ if(! m_llist.IsEditable())
+ return;
+
+ switch (event.GetId())
+ {
+ case WXLOWIN_MENU_LARGER:
+ m_llist.SetFontLarger();
+ break;
+ case WXLOWIN_MENU_SMALLER:
+ m_llist.SetFontSmaller();
+ break;
+ case WXLOWIN_MENU_UNDERLINE:
+ m_llist.SetFontUnderline(
+ m_PopupMenu->IsChecked(WXLOWIN_MENU_UNDERLINE) ? false : true
+ );
+ break;
+ case WXLOWIN_MENU_BOLD:
+ m_llist.SetFontWeight(
+ m_PopupMenu->IsChecked(WXLOWIN_MENU_BOLD) ? wxNORMAL : wxBOLD
+ );
+ case WXLOWIN_MENU_ITALICS:
+ m_llist.SetFontStyle(
+ m_PopupMenu->IsChecked(WXLOWIN_MENU_ITALICS) ? wxNORMAL : wxITALIC
+ );
+ break;
+ case WXLOWIN_MENU_ROMAN:
+ m_llist.SetFontFamily(wxROMAN); break;
+ case WXLOWIN_MENU_TYPEWRITER:
+ m_llist.SetFontFamily(wxFIXED); break;
+ case WXLOWIN_MENU_SANSSERIF:
+ m_llist.SetFontFamily(wxSWISS); break;
+ }
+}