]> git.saurik.com Git - wxWidgets.git/commitdiff
wxTipWindow added and is now used by wxSimpleHelpProvider
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 10 Sep 2000 16:30:16 +0000 (16:30 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 10 Sep 2000 16:30:16 +0000 (16:30 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8318 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

15 files changed:
distrib/msw/tmake/filelist.txt
include/wx/tipwin.h [new file with mode: 0644]
samples/help/demo.cpp
src/common/cshelp.cpp
src/files.lst
src/generic/tipwin.cpp [new file with mode: 0644]
src/gtk/files.lst
src/gtk1/files.lst
src/msw/makefile.b32
src/msw/makefile.bcc
src/msw/makefile.dos
src/msw/makefile.g95
src/msw/makefile.sc
src/msw/makefile.vc
src/msw/makefile.wat

index 4c41322c0299061668c4cb33d1894979f6e8d736..488c004db631c4c220e9ffb6702cfae8ac1ad1c1 100644 (file)
@@ -101,6 +101,7 @@ numdlgg.cpp G
 tbarsmpl.cpp   G
 textdlgg.cpp   G
 tipdlg.cpp     G
+tipwin.cpp     G
 treectlg.cpp   G
 treelay.cpp    G
 wizard.cpp     G
@@ -722,6 +723,7 @@ thread.h    W       B
 time.h W       B
 timer.h        W       B
 tipdlg.h       W
+tipwin.h       W
 tokenzr.h      W       B
 toolbar.h      W
 tooltip.h      W
diff --git a/include/wx/tipwin.h b/include/wx/tipwin.h
new file mode 100644 (file)
index 0000000..feaddc1
--- /dev/null
@@ -0,0 +1,48 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        wx/tipwin.h
+// Purpose:     wxTipWindow is a window like the one typically used for
+//              showing the tooltips
+// Author:      Vadim Zeitlin
+// Modified by:
+// Created:     10.09.00
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Licence:     wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_TIPWIN_H_
+#define _WX_TIPWIN_H_
+
+#ifdef __GNUG__
+    #pragma interface "tipwin.h"
+#endif
+
+#include "wx/frame.h"
+
+// ----------------------------------------------------------------------------
+// wxTipWindow
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxTipWindow : public wxFrame
+{
+public:
+    wxTipWindow(wxWindow *parent,
+                const wxString& text,
+                wxCoord maxLength = 100);
+
+protected:
+    // event handlers
+    void OnPaint(wxPaintEvent& event);
+    void OnMouseClick(wxMouseEvent& event);
+
+    // calculate the client rect we need to display the text
+    void Adjust(const wxString& text, wxCoord maxLength);
+
+private:
+    wxArrayString m_textLines;
+    wxCoord m_heightLine;
+
+    DECLARE_EVENT_TABLE()
+};
+
+#endif // _WX_TIPWIN_H_
index ae8ff747666d476531573f7d140de46da5ee5e15..266f3a3da33968120e500396169f78fca8424ce7 100644 (file)
@@ -635,7 +635,7 @@ MyModalDialog::MyModalDialog(wxWindow *parent)
                                       wxDefaultPosition, wxSize(300, 100),
                                       wxTE_MULTILINE);
     text->SetHelpText(_("Type text here if you have got nothing more "
-                        "more interesting to do"));
+                        "interesting to do"));
     sizerTop->Add(text, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
     sizerTop->Add(sizerRow, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
 
index c9a033d8a6e26e0fd290582b6cd09ec2c92e7364..375e9f7ce674f89935b808db7add745575f0cee8 100644 (file)
 #if wxUSE_HELP
 
 #ifndef WX_PRECOMP
-    // FIXME: temporary needed for wxSimpleHelpProvider compilation, to be
-    //        removed later
-    #include "wx/intl.h"
-    #include "wx/msgdlg.h"
+    #include "wx/tipwin.h"
 #endif
 
 #include "wx/app.h"
@@ -307,8 +304,7 @@ bool wxSimpleHelpProvider::ShowHelp(wxWindowBase *window)
     wxString text = GetHelp(window);
     if ( !text.empty() )
     {
-        wxMessageBox(text, _("Help"), wxICON_INFORMATION | wxOK,
-                     (wxWindow *)window);
+        new wxTipWindow((wxWindow *)window, text);
 
         return TRUE;
     }
index 14b8289f11718c2501da6eafbc61f03be01d6b7b..8a7b8b0fb2e543a7fedffc0ba61135459129f575 100644 (file)
@@ -1,4 +1,4 @@
-# This file was automatically generated by tmake at 20:17, 2000/03/31
+# This file was automatically generated by tmake at 19:28, 2000/09/10
 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BASE.T!
 ALL_SOURCES = \
                common/init.cpp \
@@ -48,6 +48,7 @@ ALL_SOURCES = \
                common/textfile.cpp \
                common/timercmn.cpp \
                common/tokenzr.cpp \
+               common/treebase.cpp \
                common/txtstrm.cpp \
                common/unzip.c \
                common/url.cpp \
@@ -190,6 +191,7 @@ BASE_OBJS = \
                textfile.o \
                timercmn.o \
                tokenzr.o \
+               treebase.o \
                txtstrm.o \
                unzip.o \
                url.o \
@@ -248,6 +250,7 @@ BASE_DEPS = \
                textfile.d \
                timercmn.d \
                tokenzr.d \
+               treebase.d \
                txtstrm.d \
                unzip.d \
                url.d \
@@ -313,6 +316,7 @@ BASE_DEPS = \
                textfile.d \
                timercmn.d \
                tokenzr.d \
+               treebase.d \
                txtstrm.d \
                unzip.d \
                url.d \
diff --git a/src/generic/tipwin.cpp b/src/generic/tipwin.cpp
new file mode 100644 (file)
index 0000000..6dc9d80
--- /dev/null
@@ -0,0 +1,184 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        src/generic/tipwin.cpp
+// Purpose:     implementation of wxTipWindow
+// Author:      Vadim Zeitlin
+// Modified by:
+// Created:     10.09.00
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Licence:     wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#ifdef __GNUG__
+    #pragma implementation "tipwin.h"
+#endif
+
+// For compilers that support precompilatixon, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+    #include "wx/dcclient.h"
+#endif // WX_PRECOMP
+
+#include "wx/tipwin.h"
+
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+static const wxCoord TEXT_MARGIN_X = 3;
+static const wxCoord TEXT_MARGIN_Y = 3;
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// event tables
+// ----------------------------------------------------------------------------
+
+BEGIN_EVENT_TABLE(wxTipWindow, wxFrame)
+    EVT_PAINT(wxTipWindow::OnPaint)
+
+    EVT_LEFT_DOWN(wxTipWindow::OnMouseClick)
+    EVT_RIGHT_DOWN(wxTipWindow::OnMouseClick)
+    EVT_MIDDLE_DOWN(wxTipWindow::OnMouseClick)
+END_EVENT_TABLE()
+
+// ----------------------------------------------------------------------------
+// wxTipWindow
+// ----------------------------------------------------------------------------
+
+wxTipWindow::wxTipWindow(wxWindow *parent,
+                         const wxString& text,
+                         wxCoord maxLength)
+           : wxFrame(parent, -1, _T(""),
+                     wxDefaultPosition, wxDefaultSize,
+                     wxNO_BORDER | wxFRAME_FLOAT_ON_PARENT)
+{
+    // set colours
+    SetForegroundColour(*wxBLACK);
+    SetBackgroundColour(wxColour(0xc3ffff));
+
+    // set position and size
+    int x, y;
+    wxGetMousePosition(&x, &y);
+    Move(x, y + 20);
+
+    Adjust(text, maxLength);
+
+    // capture mouse as we want to dismiss the window when it is clicked
+    CaptureMouse();
+
+    Show(TRUE);
+}
+
+void wxTipWindow::Adjust(const wxString& text, wxCoord maxLength)
+{
+    wxClientDC dc(this);
+    dc.SetFont(GetFont());
+
+    // calculate the length: we want each line be no longer than maxLength
+    // pixels and we only break lines at words boundary
+    wxString current;
+    wxCoord height, width,
+            widthMax = 0;
+    m_heightLine = 0;
+
+    bool breakLine = FALSE;
+    for ( const wxChar *p = text.c_str(); ; p++ )
+    {
+        if ( *p == _T('\n') || *p == _T('\0') )
+        {
+            dc.GetTextExtent(current, &width, &height);
+            if ( width > widthMax )
+                widthMax = width;
+
+            if ( height > m_heightLine )
+                m_heightLine = height;
+
+            m_textLines.Add(current);
+
+            if ( !*p )
+            {
+                // end of text
+                break;
+            }
+
+            current.clear();
+            breakLine = FALSE;
+        }
+        else if ( breakLine && (*p == _T(' ') || *p == _T('\t')) )
+        {
+            // word boundary - break the line here
+            m_textLines.Add(current);
+            current.clear();
+            breakLine = FALSE;
+        }
+        else // line goes on
+        {
+            current += *p;
+            dc.GetTextExtent(current, &width, &height);
+            if ( width > maxLength )
+                breakLine = TRUE;
+
+            if ( width > widthMax )
+                widthMax = width;
+
+            if ( height > m_heightLine )
+                m_heightLine = height;
+        }
+    }
+
+    // take into account the border size and the margins
+    SetClientSize(2*(TEXT_MARGIN_X + 1) + widthMax,
+                  2*(TEXT_MARGIN_Y + 1) + m_textLines.GetCount()*m_heightLine);
+}
+
+void wxTipWindow::OnPaint(wxPaintEvent& event)
+{
+    wxPaintDC dc(this);
+
+    wxRect rect;
+    wxSize size = GetClientSize();
+    rect.width = size.x;
+    rect.height = size.y;
+
+    // first filll the background
+    dc.SetBrush(wxBrush(GetBackgroundColour(), wxSOLID));
+    dc.SetPen(*wxBLACK_PEN);
+    dc.DrawRectangle(rect);
+
+    // and then draw the text line by line
+    dc.SetFont(GetFont());
+
+    wxPoint pt;
+    pt.x = TEXT_MARGIN_X;
+    pt.y = TEXT_MARGIN_Y;
+    size_t count = m_textLines.GetCount();
+    for ( size_t n = 0; n < count; n++ )
+    {
+        dc.DrawText(m_textLines[n], pt);
+
+        pt.y += m_heightLine;
+    }
+}
+
+void wxTipWindow::OnMouseClick(wxMouseEvent& event)
+{
+    ReleaseMouse();
+
+    Close();
+}
index 4571d4c6181b0b08693cc832a1f3e40da20b4ed5..56c215bf58fe1c99d56b981495aa79d70541c88c 100644 (file)
@@ -1,4 +1,4 @@
-# This file was automatically generated by tmake at 11:57, 2000/09/08
+# This file was automatically generated by tmake at 19:28, 2000/09/10
 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE GTK.T!
 ALL_SOURCES = \
                generic/busyinfo.cpp \
@@ -39,6 +39,7 @@ ALL_SOURCES = \
                generic/tbarsmpl.cpp \
                generic/textdlgg.cpp \
                generic/tipdlg.cpp \
+               generic/tipwin.cpp \
                generic/treectlg.cpp \
                generic/treelay.cpp \
                generic/wizard.cpp \
@@ -413,6 +414,7 @@ ALL_HEADERS = \
                time.h \
                timer.h \
                tipdlg.h \
+               tipwin.h \
                tokenzr.h \
                toolbar.h \
                tooltip.h \
@@ -807,6 +809,7 @@ GENERICOBJS = \
                tbarsmpl.o \
                textdlgg.o \
                tipdlg.o \
+               tipwin.o \
                treectlg.o \
                treelay.o \
                wizard.o
@@ -850,6 +853,7 @@ GENERICDEPS = \
                tbarsmpl.d \
                textdlgg.d \
                tipdlg.d \
+               tipwin.d \
                treectlg.d \
                treelay.d \
                wizard.d
index 4571d4c6181b0b08693cc832a1f3e40da20b4ed5..56c215bf58fe1c99d56b981495aa79d70541c88c 100644 (file)
@@ -1,4 +1,4 @@
-# This file was automatically generated by tmake at 11:57, 2000/09/08
+# This file was automatically generated by tmake at 19:28, 2000/09/10
 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE GTK.T!
 ALL_SOURCES = \
                generic/busyinfo.cpp \
@@ -39,6 +39,7 @@ ALL_SOURCES = \
                generic/tbarsmpl.cpp \
                generic/textdlgg.cpp \
                generic/tipdlg.cpp \
+               generic/tipwin.cpp \
                generic/treectlg.cpp \
                generic/treelay.cpp \
                generic/wizard.cpp \
@@ -413,6 +414,7 @@ ALL_HEADERS = \
                time.h \
                timer.h \
                tipdlg.h \
+               tipwin.h \
                tokenzr.h \
                toolbar.h \
                tooltip.h \
@@ -807,6 +809,7 @@ GENERICOBJS = \
                tbarsmpl.o \
                textdlgg.o \
                tipdlg.o \
+               tipwin.o \
                treectlg.o \
                treelay.o \
                wizard.o
@@ -850,6 +853,7 @@ GENERICDEPS = \
                tbarsmpl.d \
                textdlgg.d \
                tipdlg.d \
+               tipwin.d \
                treectlg.d \
                treelay.d \
                wizard.d
index ebb69f856cafa7e3ccca2bc8c868566afde66254..8e2465b4d0be36e426137a5b798db9eb0c321157 100644 (file)
@@ -1,6 +1,6 @@
 
 
-# This file was automatically generated by tmake at 11:57, 2000/09/08
+# This file was automatically generated by tmake at 19:28, 2000/09/10
 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T!
 
 #
@@ -102,6 +102,7 @@ GENERICOBJS= $(MSWDIR)\busyinfo.obj \
                $(MSWDIR)\tbarsmpl.obj \
                $(MSWDIR)\textdlgg.obj \
                $(MSWDIR)\tipdlg.obj \
+               $(MSWDIR)\tipwin.obj \
                $(MSWDIR)\treectlg.obj \
                $(MSWDIR)\treelay.obj \
                $(MSWDIR)\wizard.obj
@@ -862,6 +863,8 @@ $(MSWDIR)\textdlgg.obj: $(GENDIR)\textdlgg.$(SRCSUFF)
 
 $(MSWDIR)\tipdlg.obj: $(GENDIR)\tipdlg.$(SRCSUFF)
 
+$(MSWDIR)\tipwin.obj: $(GENDIR)\tipwin.$(SRCSUFF)
+
 $(MSWDIR)\treectlg.obj: $(GENDIR)\treectlg.$(SRCSUFF)
 
 $(MSWDIR)\treelay.obj: $(GENDIR)\treelay.$(SRCSUFF)
index b1e381a800c0452b6299fc8c3979160627edee28..a364ab42a5211590b65de3a850bd07492eaa45dc 100644 (file)
@@ -1,6 +1,6 @@
 
 
-# This file was automatically generated by tmake at 11:57, 2000/09/08
+# This file was automatically generated by tmake at 19:28, 2000/09/10
 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T!
 
 #
@@ -103,6 +103,7 @@ GENERICOBJS= $(MSWDIR)\busyinfo.obj \
                $(MSWDIR)\tbarsmpl.obj \
                $(MSWDIR)\textdlgg.obj \
                $(MSWDIR)\tipdlg.obj \
+               $(MSWDIR)\tipwin.obj \
                $(MSWDIR)\treectlg.obj \
                $(MSWDIR)\treelay.obj \
                $(MSWDIR)\wizard.obj
@@ -721,6 +722,8 @@ $(MSWDIR)\textdlgg.obj: $(GENDIR)\textdlgg.$(SRCSUFF)
 
 $(MSWDIR)\tipdlg.obj: $(GENDIR)\tipdlg.$(SRCSUFF)
 
+$(MSWDIR)\tipwin.obj: $(GENDIR)\tipwin.$(SRCSUFF)
+
 $(MSWDIR)\treectlg.obj: $(GENDIR)\treectlg.$(SRCSUFF)
 
 $(MSWDIR)\treelay.obj: $(GENDIR)\treelay.$(SRCSUFF)
index dd40f3512606dc6dc61c1dc158766ac26557113b..916ace01b2aabfb75d60f847bb17d37b676155a1 100644 (file)
@@ -1,4 +1,4 @@
-# This file was automatically generated by tmake at 11:57, 2000/09/08
+# This file was automatically generated by tmake at 19:28, 2000/09/10
 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T!
 
 #
@@ -87,6 +87,7 @@ GENERICOBJS= $(GENDIR)\busyinfo.obj \
                $(GENDIR)\tbarsmpl.obj \
                $(GENDIR)\textdlgg.obj \
                $(GENDIR)\tipdlg.obj \
+               $(GENDIR)\tipwin.obj \
                $(GENDIR)\treectlg.obj \
                $(GENDIR)\treelay.obj \
                $(GENDIR)\wizard.obj
@@ -1339,6 +1340,11 @@ $(GENDIR)/tipdlg.obj:     $*.$(SRCSUFF)
 $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
 <<
 
+$(GENDIR)/tipwin.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
 $(GENDIR)/treectlg.obj:     $*.$(SRCSUFF)
         cl @<<
 $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
index 49fd14dcaf8f6cafa7c5fc9e2ffe40d117ad77a3..0240840c68b74e8cfd632f9b067fdeab0492f355 100644 (file)
@@ -1,4 +1,4 @@
-# This file was automatically generated by tmake at 11:57, 2000/09/08
+# This file was automatically generated by tmake at 19:28, 2000/09/10
 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T!
 
 #
@@ -93,6 +93,7 @@ GENERICOBJS = \
                $(GENDIR)/tbarsmpl.$(OBJSUFF) \
                $(GENDIR)/textdlgg.$(OBJSUFF) \
                $(GENDIR)/tipdlg.$(OBJSUFF) \
+               $(GENDIR)/tipwin.$(OBJSUFF) \
                $(GENDIR)/treectlg.$(OBJSUFF) \
                $(GENDIR)/treelay.$(OBJSUFF) \
                $(GENDIR)/wizard.$(OBJSUFF)
index eb3568847c2fbb40e04fc4944dac4ab5633badc4..25562cbae315738399ab8d4d8169611773a5fe89 100644 (file)
@@ -1,6 +1,6 @@
 
 
-# This file was automatically generated by tmake at 11:57, 2000/09/08
+# This file was automatically generated by tmake at 19:28, 2000/09/10
 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T!
 
 # Symantec C++ makefile for the msw objects
@@ -50,6 +50,7 @@ GENERICOBJS= $(GENDIR)\busyinfo.obj \
                $(GENDIR)\tbarsmpl.obj \
                $(GENDIR)\textdlgg.obj \
                $(GENDIR)\tipdlg.obj \
+               $(GENDIR)\tipwin.obj \
                $(GENDIR)\treectlg.obj \
                $(GENDIR)\treelay.obj \
                $(GENDIR)\wizard.obj
index 79be1c8059f1bed81aa5cacfb8a8ac2721fc8bd6..f719d708d0640d65fac48a1d2d4424039797aea8 100644 (file)
@@ -1,4 +1,4 @@
-# This file was automatically generated by tmake at 11:57, 2000/09/08
+# This file was automatically generated by tmake at 19:28, 2000/09/10
 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T!
 
 # File:     makefile.vc
@@ -107,6 +107,7 @@ GENERICOBJS= ..\generic\$D\busyinfo.obj \
                ..\generic\$D\tbarsmpl.obj \
                ..\generic\$D\textdlgg.obj \
                ..\generic\$D\tipdlg.obj \
+               ..\generic\$D\tipwin.obj \
                ..\generic\$D\treectlg.obj \
                ..\generic\$D\treelay.obj \
                ..\generic\$D\wizard.obj
index 4adabe4f0bd93812e3e3e7a4c4d500e1a4c9565d..a6f93a7178ef032d21c83d542b8b4965283417ea 100644 (file)
@@ -1,6 +1,6 @@
 #!/binb/wmake.exe
 
-# This file was automatically generated by tmake at 11:57, 2000/09/08
+# This file was automatically generated by tmake at 19:28, 2000/09/10
 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T!
 
 #
@@ -65,6 +65,7 @@ GENERICOBJS= busyinfo.obj &
        tbarsmpl.obj &
        textdlgg.obj &
        tipdlg.obj &
+       tipwin.obj &
        treectlg.obj &
        treelay.obj &
        wizard.obj
@@ -1045,6 +1046,9 @@ textdlgg.obj:     $(GENDIR)\textdlgg.cpp
 tipdlg.obj:     $(GENDIR)\tipdlg.cpp
   *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
 
+tipwin.obj:     $(GENDIR)\tipwin.cpp
+  *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
+
 treectlg.obj:     $(GENDIR)\treectlg.cpp
   *$(CCC) $(CPPFLAGS) $(IFLAGS) $<