]> git.saurik.com Git - wxWidgets.git/commitdiff
Popup menu and cursor corrected. Some bugs fixed.
authorKarsten Ballüder <ballueder@usa.net>
Thu, 10 Jun 1999 17:22:02 +0000 (17:22 +0000)
committerKarsten Ballüder <ballueder@usa.net>
Thu, 10 Jun 1999 17:22:02 +0000 (17:22 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2743 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/richedit/wxLayout.cpp
samples/richedit/wxllist.cpp
samples/richedit/wxllist.h
samples/richedit/wxlwindow.cpp
samples/richedit/wxlwindow.h

index b4cd05060cd1ddc487ff046642c510cb8e67bcfb..265ead4ebc5810d1deb4aab8b6ab4013a1e9c757 100644 (file)
@@ -36,7 +36,9 @@ IMPLEMENT_APP(MyApp)
    enum ids{ ID_ADD_SAMPLE = 1, ID_CLEAR, ID_PRINT,
              ID_PRINT_SETUP, ID_PAGE_SETUP, ID_PREVIEW, ID_PRINT_PS,
              ID_PRINT_SETUP_PS, ID_PAGE_SETUP_PS,ID_PREVIEW_PS,
-             ID_WRAP, ID_NOWRAP, ID_PASTE, ID_COPY, ID_CUT, ID_FIND,
+             ID_WRAP, ID_NOWRAP, ID_PASTE, ID_COPY, ID_CUT,
+             ID_PASTE_PRIMARY,
+             ID_FIND,
              ID_WXLAYOUT_DEBUG, ID_QUIT, ID_CLICK, ID_HTML, ID_TEXT,
              ID_TEST, ID_LINEBREAKS_TEST, ID_LONG_TEST, ID_URL_TEST };
 
@@ -99,7 +101,10 @@ MyFrame::MyFrame(void) :
    edit_menu->AppendSeparator();
    edit_menu->Append(ID_COPY, "&Copy", "Copy text to clipboard.");
    edit_menu->Append(ID_CUT, "Cu&t", "Cut text to clipboard.");
+#ifdef __WXGTK__
    edit_menu->Append(ID_PASTE,"&Paste", "Paste text from clipboard.");
+#endif
+   edit_menu->Append(ID_PASTE_PRIMARY,"&Paste primary", "Paste text from primary selection.");
    edit_menu->Append(ID_FIND, "&Find", "Find text.");
    menu_bar->Append(edit_menu, "&Edit" );
 
@@ -267,6 +272,12 @@ void MyFrame::OnCommand( wxCommandEvent &event )
       m_lwin->Paste();
       m_lwin->Refresh(FALSE);
       break;
+#ifdef __WXGTK__
+   case ID_PASTE_PRIMARY:
+      m_lwin->Paste(TRUE);
+      m_lwin->Refresh(FALSE);
+      break;
+#endif
    case ID_COPY:
       m_lwin->Copy();
       m_lwin->Refresh(FALSE);
index 6548ea34ebd80d51651adc1ec855460a33e72d62..40f8b756a14830c7bc79be258c06f0c4b9864830 100644 (file)
@@ -1071,6 +1071,7 @@ wxLayoutLine::Layout(wxDC &dc,
                      wxLayoutList *llist,
                      wxPoint *cursorPos,
                      wxPoint *cursorSize,
+                     wxLayoutStyleInfo *cursorStyle,
                      int cx,
                      bool suppressSIupdate)
 {
@@ -1134,6 +1135,8 @@ wxLayoutLine::Layout(wxDC &dc,
                   str = WXLO_CURSORCHAR;
                dc.GetTextExtent(str, &width, &height, &descent);
 
+               if(cursorStyle) // set style info
+                  *cursorStyle = llist->GetStyleInfo();
                if ( cursorSize )
                {
                   // Just in case some joker inserted an empty string object:
@@ -1144,14 +1147,15 @@ wxLayoutLine::Layout(wxDC &dc,
                   cursorSize->x = width;
                   cursorSize->y = height;
                }
-
+               
                cursorFound = true; // no more checks
             }
             else
             {
                // on some other object
                CoordType top, bottom; // unused
-               *cursorSize = obj->GetSize(&top,&bottom);
+               if(cursorSize)
+                  *cursorSize = obj->GetSize(&top,&bottom);
                cursorPos->y = m_Position.y;
                cursorFound = true; // no more checks
             }
@@ -1554,6 +1558,7 @@ wxLayoutList::InternalClear(void)
    m_DefaultStyleInfo.m_bg = *wxWHITE;
 
    m_CurrentStyleInfo = m_DefaultStyleInfo;
+   m_CursorStyleInfo = m_DefaultStyleInfo;
 }
 
 void
@@ -2153,11 +2158,13 @@ wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll,
          if(line == m_CursorLine)
             line->Layout(dc, this,
                          (wxPoint *)&m_CursorScreenPos,
-                         (wxPoint *)&m_CursorSize, m_CursorPos.x);
+                         (wxPoint *)&m_CursorSize,
+                         &m_CursorStyleInfo,
+                         m_CursorPos.x);
          if(cpos && line->GetLineNumber() == cpos->y)
             line->Layout(dc, this,
                          cpos,
-                         csize, cpos->x);
+                         csize, NULL, cpos->x);
          else
             line->Layout(dc, this);
          // little condition to speed up redrawing:
index a8eaf78ec0bf02d3ac0c1fea4fda30b88e1953f4..63be75e0d15b580b9e76633384f97bf306f8623f 100644 (file)
@@ -580,6 +580,7 @@ public:
        @param llist th   e wxLayoutList
        @param cursorPos if not NULL, set cursor screen position in there
        @param cursorSize if not cursorPos != NULL, set cursor size in there
+       @param cursorStyle if non NULL where to store styleinfo for cursor pos
        @param cx if cursorPos != NULL, the cursor x position
        @param suppressStyleUpdate FALSe normally, only to suppress updating of m_StyleInfo
    */
@@ -587,6 +588,7 @@ public:
                wxLayoutList *llist,
                wxPoint *cursorPos = NULL,
                wxPoint *cursorSize = NULL,
+               wxLayoutStyleInfo *cursorStyle = NULL,
                int cx = 0,
                bool suppressStyleUpdate = FALSE);
    /** This function finds an object belonging to a given cursor
@@ -919,13 +921,14 @@ public:
    wxLayoutStyleInfo &GetDefaultStyleInfo(void) { return m_DefaultStyleInfo ; }
    wxLayoutStyleInfo &GetStyleInfo(void) { return m_CurrentStyleInfo ; }
    const wxLayoutStyleInfo &GetStyleInfo(void) const { return m_CurrentStyleInfo ; }
+   const wxLayoutStyleInfo &GetCursorStyleInfo(void) const { return m_CursorStyleInfo ; }
 
    /// is the current font underlined?
-   bool IsFontUnderlined() const { return GetStyleInfo().underline != 0; }
+   bool IsFontUnderlined() const { return GetCursorStyleInfo().underline != 0; }
    /// is the current font bold?
-   bool IsFontBold() const { return GetStyleInfo().weight == wxBOLD; }
+   bool IsFontBold() const { return GetCursorStyleInfo().weight == wxBOLD; }
    /// is the current font italic?
-   bool IsFontItalic() const { return GetStyleInfo().style == wxITALIC; }
+   bool IsFontItalic() const { return GetCursorStyleInfo().style == wxITALIC; }
 
    /// set underline if it was off, turn it off if it was on
    void ToggleFontUnderline()
@@ -1162,6 +1165,8 @@ private:
    wxLayoutStyleInfo m_DefaultStyleInfo;
    /// the current setting:
    wxLayoutStyleInfo m_CurrentStyleInfo;
+   /// the current setting:
+   wxLayoutStyleInfo m_CursorStyleInfo;
    //@}
 };
 
index c4e292a1a9757dcbf5ea24ad1d9da5cdb219966d..d8389b7f8df7da7bc23275836702a54a57e85579 100644 (file)
@@ -95,6 +95,7 @@ BEGIN_EVENT_TABLE(wxLayoutWindow,wxScrolledWindow)
    EVT_LEFT_UP(wxLayoutWindow::OnLeftMouseUp)
    EVT_RIGHT_DOWN(wxLayoutWindow::OnRightMouseClick)
    EVT_LEFT_DCLICK(wxLayoutWindow::OnMouseDblClick)
+   EVT_MIDDLE_DOWN(wxLayoutWindow::OnMiddleMouseDown)
    EVT_MOTION    (wxLayoutWindow::OnMouseMove)
 
    EVT_UPDATE_UI(WXLOWIN_MENU_UNDERLINE, wxLayoutWindow::OnUpdateMenuUnderline)
@@ -340,8 +341,8 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
          }
          break;
 
-      case WXLOWIN_MENU_RCLICK:
-         // remove the selection if mouse click is outside it (TODO)
+      case WXLOWIN_MENU_MDOWN:
+         Paste(TRUE);
          break;
 
       case WXLOWIN_MENU_DBLCLICK:
@@ -911,14 +912,19 @@ wxLayoutWindow::ResizeScrollbars(bool exact)
 
 // ----------------------------------------------------------------------------
 // clipboard operations
+//
 // ----------------------------------------------------------------------------
 
 void
-wxLayoutWindow::Paste(void)
+wxLayoutWindow::Paste(bool primary)
 {
    // Read some text
    if (wxTheClipboard->Open())
    {
+#if __WXGTK__
+      if(primary)
+         wxTheClipboard->UsePrimarySelection();
+#endif
 #if wxUSE_PRIVATE_CLIPBOARD_FORMAT
       wxLayoutDataObject wxldo;
       if (wxTheClipboard->IsSupported( wxldo.GetFormat() ))
@@ -1089,28 +1095,21 @@ void wxLayoutWindow::OnMenu(wxCommandEvent& event)
    switch (event.GetId())
    {
    case WXLOWIN_MENU_LARGER:
-      m_llist->SetFontLarger();
-      break;
+      m_llist->SetFontLarger(); Refresh(FALSE); break;
    case WXLOWIN_MENU_SMALLER:
-      m_llist->SetFontSmaller();
-      break;
-
+      m_llist->SetFontSmaller(); Refresh(FALSE); break;
    case WXLOWIN_MENU_UNDERLINE:
-      m_llist->ToggleFontUnderline();
-      break;
+      m_llist->ToggleFontUnderline(); Refresh(FALSE); break;
    case WXLOWIN_MENU_BOLD:
-      m_llist->ToggleFontWeight();
-      break;
+      m_llist->ToggleFontWeight(); Refresh(FALSE); break;
    case WXLOWIN_MENU_ITALICS:
-      m_llist->ToggleFontItalics();
-      break;
-
+      m_llist->ToggleFontItalics(); Refresh(FALSE); break;
    case WXLOWIN_MENU_ROMAN:
-      m_llist->SetFontFamily(wxROMAN); break;
+      m_llist->SetFontFamily(wxROMAN); Refresh(FALSE); break;
    case WXLOWIN_MENU_TYPEWRITER:
-      m_llist->SetFontFamily(wxFIXED); break;
+      m_llist->SetFontFamily(wxFIXED); Refresh(FALSE); break;
    case WXLOWIN_MENU_SANSSERIF:
-      m_llist->SetFontFamily(wxSWISS); break;
+      m_llist->SetFontFamily(wxSWISS); Refresh(FALSE); break;
    }
 }
 
index e0ddabd6276a1ea5d491f5a219b2cdb5b4456350..edf9de631e80337cde91f90d6b1db79ff6ddc6aa 100644 (file)
@@ -37,6 +37,7 @@ enum
    WXLOWIN_MENU_SANSSERIF,
    WXLOWIN_MENU_RCLICK,
    WXLOWIN_MENU_DBLCLICK,
+   WXLOWIN_MENU_MDOWN,
    WXLOWIN_MENU_LDOWN,
    WXLOWIN_MENU_LUP,
    WXLOWIN_MENU_MOUSEMOVE,
@@ -89,7 +90,7 @@ public:
       m_CursorVisibility = visibility; return v;}
 
    /// Pastes text from clipboard.
-   void Paste(void);
+   void Paste(bool usePrimarySelection = FALSE);
    /** Copies selection to clipboard.
        @param invalidate used internally, see wxllist.h for details
    */
@@ -138,6 +139,7 @@ public:
    void OnLeftMouseDown(wxMouseEvent& event)   { OnMouse(WXLOWIN_MENU_LDOWN, event); }
    void OnLeftMouseUp(wxMouseEvent& event)     { OnMouse(WXLOWIN_MENU_LUP, event); }
    void OnRightMouseClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_RCLICK, event); }
+   void OnMiddleMouseDown(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_MDOWN, event); }
    void OnMouseDblClick(wxMouseEvent& event)   { OnMouse(WXLOWIN_MENU_DBLCLICK, event); }
    void OnMouseMove(wxMouseEvent &event)       { OnMouse(WXLOWIN_MENU_MOUSEMOVE, event) ; }
    void OnSetFocus(wxFocusEvent &ev);