]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/tipwin.cpp
Implement left indentation and tab stops support in wxTextCtrl, patch #1518114 -...
[wxWidgets.git] / src / generic / tipwin.cpp
index 84d8d86f623cc3eba50fa78897ff341115474026..12087b7b4b838565f27af2ca741420db9f5d4560 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     10.09.00
 // RCS-ID:      $Id$
 // Copyright:   (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
 // headers
 // ----------------------------------------------------------------------------
 
-#ifdef __GNUG__
-    #pragma implementation "tipwin.h"
-#endif
-
-// For compilers that support precompilatixon, includes "wx/wx.h".
+// For compilers that support precompilation, includes "wx/wx.h".
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
     #pragma hdrstop
 #endif
 
-#ifndef WX_PRECOMP
-    #include "wx/dcclient.h"
-#endif // WX_PRECOMP
+#if wxUSE_TIPWINDOW
 
 #include "wx/tipwin.h"
 
-#if wxUSE_TIPWINDOW
+#ifndef WX_PRECOMP
+    #include "wx/dcclient.h"
+    #include "wx/timer.h"
+    #include "wx/settings.h"
+#endif // WX_PRECOMP
 
-#include "wx/timer.h"
-#include "wx/settings.h"
+#ifdef __WXGTK__
+    #include <gtk/gtk.h>
+#endif
 
 // ----------------------------------------------------------------------------
 // constants
@@ -76,6 +75,7 @@ private:
 #endif // !wxUSE_POPUPWIN
 
     DECLARE_EVENT_TABLE()
+    DECLARE_NO_COPY_CLASS(wxTipWindowView)
 };
 
 // ============================================================================
@@ -123,7 +123,7 @@ wxTipWindow::wxTipWindow(wxWindow *parent,
 #if wxUSE_POPUPWIN
            : wxPopupTransientWindow(parent)
 #else
-           : wxFrame(parent, -1, _T(""),
+           : wxFrame(parent, wxID_ANY, wxEmptyString,
                      wxDefaultPosition, wxDefaultSize,
                      wxNO_BORDER | wxFRAME_NO_TASKBAR )
 #endif
@@ -154,11 +154,15 @@ wxTipWindow::wxTipWindow(wxWindow *parent,
     y += wxSystemSettings::GetMetric(wxSYS_CURSOR_Y) / 2;
 
 #if wxUSE_POPUPWIN
-    Position(wxPoint(x, y), wxSize(0, 0));
+    Position(wxPoint(x, y), wxSize(0,0));
     Popup(m_view);
+    #ifdef __WXGTK__
+        if (!GTK_WIDGET_HAS_GRAB(m_widget))
+            gtk_grab_add( m_widget );
+    #endif
 #else
     Move(x, y);
-    Show(TRUE);
+    Show(true);
 #endif
 }
 
@@ -168,6 +172,12 @@ wxTipWindow::~wxTipWindow()
     {
         *m_windowPtr = NULL;
     }
+    #ifdef wxUSE_POPUPWIN
+        #ifdef __WXGTK__
+            if (GTK_WIDGET_HAS_GRAB(m_widget))
+                gtk_grab_remove( m_widget );
+        #endif
+    #endif
 }
 
 void wxTipWindow::OnMouseClick(wxMouseEvent& WXUNUSED(event))
@@ -216,7 +226,11 @@ void wxTipWindow::Close()
     }
 
 #if wxUSE_POPUPWIN
-    Show(FALSE);
+    Show(false);
+    #ifdef __WXGTK__
+        if (GTK_WIDGET_HAS_GRAB(m_widget))
+            gtk_grab_remove( m_widget );
+    #endif
     Destroy();
 #else
     wxFrame::Close();
@@ -228,7 +242,7 @@ void wxTipWindow::Close()
 // ----------------------------------------------------------------------------
 
 wxTipWindowView::wxTipWindowView(wxWindow *parent)
-               : wxWindow(parent, -1,
+               : wxWindow(parent, wxID_ANY,
                           wxDefaultPosition, wxDefaultSize,
                           wxNO_BORDER)
 {
@@ -255,7 +269,7 @@ void wxTipWindowView::Adjust(const wxString& text, wxCoord maxLength)
             widthMax = 0;
     m_parent->m_heightLine = 0;
 
-    bool breakLine = FALSE;
+    bool breakLine = false;
     for ( const wxChar *p = text.c_str(); ; p++ )
     {
         if ( *p == _T('\n') || *p == _T('\0') )
@@ -276,21 +290,21 @@ void wxTipWindowView::Adjust(const wxString& text, wxCoord maxLength)
             }
 
             current.clear();
-            breakLine = FALSE;
+            breakLine = false;
         }
         else if ( breakLine && (*p == _T(' ') || *p == _T('\t')) )
         {
             // word boundary - break the line here
             m_parent->m_textLines.Add(current);
             current.clear();
-            breakLine = FALSE;
+            breakLine = false;
         }
         else // line goes on
         {
             current += *p;
             dc.GetTextExtent(current, &width, &height);
             if ( width > maxLength )
-                breakLine = TRUE;
+                breakLine = true;
 
             if ( width > widthMax )
                 widthMax = width;
@@ -302,7 +316,7 @@ void wxTipWindowView::Adjust(const wxString& text, wxCoord maxLength)
 
     // take into account the border size and the margins
     width  = 2*(TEXT_MARGIN_X + 1) + widthMax;
-    height = 2*(TEXT_MARGIN_Y + 1) + m_parent->m_textLines.GetCount()*m_parent->m_heightLine;
+    height = 2*(TEXT_MARGIN_Y + 1) + wx_truncate_cast(wxCoord, m_parent->m_textLines.GetCount())*m_parent->m_heightLine;
     m_parent->SetClientSize(width, height);
     SetSize(0, 0, width, height);
 }
@@ -348,7 +362,7 @@ void wxTipWindowView::OnMouseMove(wxMouseEvent& event)
     const wxRect& rectBound = m_parent->m_rectBound;
 
     if ( rectBound.width &&
-            !rectBound.Inside(ClientToScreen(event.GetPosition())) )
+            !rectBound.Contains(ClientToScreen(event.GetPosition())) )
     {
         // mouse left the bounding rect, disappear
         m_parent->Close();