]> git.saurik.com Git - wxWidgets.git/blobdiff - user/wxLayout/wxlwindow.cpp
added printing
[wxWidgets.git] / user / wxLayout / wxlwindow.cpp
index 8d5b14e234e668d9571a4f28b8c5b3c72573b761..0b1c7a69cab79e5f8a15ca884b50f5d2b68aacbb 100644 (file)
 #define   VAR(x)   cout << #x"=" << x << endl;
 
 BEGIN_EVENT_TABLE(wxLayoutWindow,wxScrolledWindow)
-   EVT_PAINT  (wxLayoutWindow::OnPaint)
-   EVT_CHAR   (wxLayoutWindow::OnChar)
+   EVT_PAINT    (wxLayoutWindow::OnPaint)
+   EVT_CHAR     (wxLayoutWindow::OnChar)
    EVT_LEFT_DOWN(wxLayoutWindow::OnMouse)
 END_EVENT_TABLE()
 
 wxLayoutWindow::wxLayoutWindow(wxWindow *parent)
-   : wxScrolledWindow(parent)
+   : wxScrolledWindow(parent, -1, wxDefaultPosition, wxDefaultSize,
+                      wxHSCROLL | wxVSCROLL | wxBORDER)
+
 {
    m_ScrollbarsSet = false;
    m_EventId = -1;
 }
 
+#ifdef __WXMSW__
+long
+wxLayoutWindow::MSWGetDlgCode()
+{
+   // if we don't return this, we won't get OnChar() events
+   return DLGC_WANTCHARS | DLGC_WANTARROWS | DLGC_WANTMESSAGE;
+}
+#endif //MSW
+
+
 void
 wxLayoutWindow::OnMouse(wxMouseEvent& event)
 {
+   SetFocus();
+
    if(m_EventId == -1) // nothing to do
       return;
    
@@ -38,7 +52,8 @@ wxLayoutWindow::OnMouse(wxMouseEvent& event)
    m_FoundObject = NULL;
 
 #ifdef   WXLAYOUT_DEBUG
-   cerr << "OnMouse: " << m_FindPos.x << ',' << m_FindPos.y << endl;
+   //doesn't work, undefined functions
+   //wxLogTrace("OnMouse: (%d, %d)", m_FindPos.x, m_FindPos.y);
 #endif
    Refresh();
    if(m_FoundObject)
@@ -68,6 +83,7 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
    
    long keyCode = event.KeyCode();
    wxPoint p;
+   CoordType help;
    
    switch(event.KeyCode())
    {
@@ -100,11 +116,19 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
       m_llist.SetCursor(p);
       break;
    case WXK_DELETE :
-      m_llist.Delete(1);
+      if(event.ControlDown()) // delete to end of line
+      {
+         help = m_llist.GetLineLength(
+            m_llist.FindCurrentObject(NULL))
+            - m_llist.GetCursor().x;
+         m_llist.Delete(help ? help : 1);
+      }
+      else
+         m_llist.Delete(1);
       break;
    case WXK_BACK: // backspace
-      m_llist.MoveCursor(-1);
-      m_llist.Delete(1);
+      if(m_llist.MoveCursor(-1))
+         m_llist.Delete(1);
       break;
    case WXK_RETURN:
       m_llist.LineBreak();