From 4005cc780c59b38290754ff3fb5199e792e4f094 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 17 Jun 1999 21:40:49 +0000 Subject: [PATCH] fixes to work in M git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2821 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/richedit/wxLayout.cpp | 6 +++++- samples/richedit/wxlwindow.cpp | 37 +++++++++++++++++++++++-------------- samples/richedit/wxlwindow.h | 4 +++- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/samples/richedit/wxLayout.cpp b/samples/richedit/wxLayout.cpp index 679f83a..c23c455 100644 --- a/samples/richedit/wxLayout.cpp +++ b/samples/richedit/wxLayout.cpp @@ -125,6 +125,7 @@ MyFrame::MyFrame(void) : m_lwin->SetFocus(); Clear(); +#if 0 // create and set the background bitmap (this will result in a lattice) static const int sizeBmp = 10; wxBitmap *bitmap = new wxBitmap(sizeBmp, sizeBmp); @@ -140,6 +141,7 @@ MyFrame::MyFrame(void) : dcMem.SelectObject( wxNullBitmap ); m_lwin->SetBackgroundBitmap(bitmap); +#endif // 0 }; void @@ -236,7 +238,9 @@ MyFrame::AddSampleText(wxLayoutList *llist) void MyFrame::Clear(void) { - m_lwin->Clear(wxROMAN,16,wxNORMAL,wxNORMAL, false); + wxColour colBg(0, 255, 255); + + m_lwin->Clear(wxROMAN,16,wxNORMAL,wxNORMAL, false, wxGREEN, &colBg); } diff --git a/samples/richedit/wxlwindow.cpp b/samples/richedit/wxlwindow.cpp index 7793430..e767192 100644 --- a/samples/richedit/wxlwindow.cpp +++ b/samples/richedit/wxlwindow.cpp @@ -153,11 +153,6 @@ wxLayoutWindow::wxLayoutWindow(wxWindow *parent) m_bitmap = new wxBitmap(4,4); m_bitmapSize = wxPoint(4,4); m_llist = new wxLayoutList(); -#ifdef __WXMSW__ - SetAutoDeleteSelection(true); -#else - SetAutoDeleteSelection(false); -#endif m_BGbitmap = NULL; m_ScrollToCursor = false; SetWrapMargin(0); @@ -173,13 +168,20 @@ wxLayoutWindow::wxLayoutWindow(wxWindow *parent) wxCaret *caret = new wxCaret(this, 2, 20); SetCaret(caret); m_llist->SetCaret(caret); - caret->Show(); #endif // WXLAYOUT_USE_CARET + m_HaveFocus = FALSE; m_HandCursor = FALSE; m_CursorVisibility = -1; SetCursor(wxCURSOR_IBEAM); SetDirty(); + + // at least under Windows, this should be the default behaviour +#ifdef __WXMSW__ + m_AutoDeleteSelection = TRUE; +#else // !Windows + m_AutoDeleteSelection = FALSE; +#endif // Win/!Win } wxLayoutWindow::~wxLayoutWindow() @@ -206,7 +208,12 @@ wxLayoutWindow::Clear(int family, ResizeScrollbars(true); SetDirty(); SetModified(false); - wxScrolledWindow::Clear(); + +#ifdef WXLAYOUT_USE_CARET + if ( m_CursorVisibility == 1 ) + GetCaret()->Show(); +#endif // WXLAYOUT_USE_CARET + DoPaint((wxRect *)NULL); } @@ -331,7 +338,7 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event) if(m_CursorVisibility != 0) { - // draw a thick cursor for editable windows with focus + // draw a thick cursor for editable windows with focus m_llist->DrawCursor(dc, m_HaveFocus && IsEditable(), offset); } @@ -720,12 +727,13 @@ void wxLayoutWindow::DoPaint(const wxRect *updateRect) { #ifdef __WXGTK__ + // Calling Refresh() causes bad flicker under wxGTK!!! InternalPaint(updateRect); -#else // Causes bad flicker under wxGTK!!! +#else + // shouldn't specify the update rectangle if it doesn't include all the + // changed locations - otherwise, they won't be repainted at all because + // the system clips the display to the update rect Refresh(FALSE); //, updateRect); - - if ( !::UpdateWindow(GetHwnd()) ) - wxLogLastError("UpdateWindow"); #endif } @@ -764,6 +772,7 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect) m_llist->Layout(dc); ResizeScrollbars(); } + /* Check whether the window has grown, if so, we need to reallocate the bitmap to be larger. */ if(x1 > m_bitmapSize.x || y1 > m_bitmapSize.y) @@ -779,7 +788,7 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect) } m_memDC->SetDeviceOrigin(0,0); - m_memDC->SetBrush(wxBrush(m_llist->GetDefaultStyleInfo().GetBGColour(),wxSOLID)); + m_memDC->SetBackground(wxBrush(m_llist->GetDefaultStyleInfo().GetBGColour(),wxSOLID)); m_memDC->SetPen(wxPen(m_llist->GetDefaultStyleInfo().GetBGColour(), 0,wxTRANSPARENT)); m_memDC->SetLogicalFunction(wxCOPY); @@ -855,7 +864,7 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect) #ifdef WXLAYOUT_USE_CARET // show the caret back after everything is redrawn - m_caret->Show(); + GetCaret()->Show(); #endif // WXLAYOUT_USE_CARET ResetDirty(); diff --git a/samples/richedit/wxlwindow.h b/samples/richedit/wxlwindow.h index 60bc28c..c0dbd63 100644 --- a/samples/richedit/wxlwindow.h +++ b/samples/richedit/wxlwindow.h @@ -39,6 +39,7 @@ enum WXLOWIN_MENU_DBLCLICK, WXLOWIN_MENU_MDOWN, WXLOWIN_MENU_LDOWN, + WXLOWIN_MENU_LCLICK = WXLOWIN_MENU_LDOWN, WXLOWIN_MENU_LUP, WXLOWIN_MENU_MOUSEMOVE, WXLOWIN_MENU_LAST = WXLOWIN_MENU_MOUSEMOVE @@ -82,7 +83,8 @@ public: m_BGbitmap = bitmap; } /// Enable or disable editing, i.e. processing of keystrokes. - void SetEditable(bool toggle) { m_Editable = toggle; } + void SetEditable(bool toggle) + { m_Editable = toggle; SetCursorVisibility(toggle); } /// Query whether list can be edited by user. bool IsEditable(void) const { return m_Editable; } /** Sets cursor visibility, visible=1, invisible=0, -- 2.7.4