more wxToolTip changes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1548 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 1999-02-01 00:05:03 +00:00
parent cd4718483a
commit 9f3362c440
3 changed files with 90 additions and 52 deletions

View File

@ -6,7 +6,7 @@
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_WINDOW_H_
@ -66,6 +66,7 @@ class WXDLLEXPORT wxPen;
class WXDLLEXPORT wxIcon;
class WXDLLEXPORT wxDC;
class WXDLLEXPORT wxValidator;
class WXDLLEXPORT wxToolTip;
#if wxUSE_DRAG_AND_DROP
class WXDLLEXPORT wxDropTarget;
@ -103,7 +104,7 @@ public:
wxStringClientData( wxString &data ) { m_data = data; }
void SetData( wxString &data ) { m_data = data; }
wxString GetData() const { return m_data; }
private:
wxString m_data;
};
@ -261,6 +262,14 @@ public:
wxDropTarget *GetDropTarget() const { return m_pDropTarget; }
#endif
// tooltips
// create a tooltip with this text
void SetToolTip(const wxString &tip);
// pointer may be NULL to remove the tooltip
void SetToolTip(wxToolTip *tooltip);
// get the current tooltip (may return NULL if none)
wxToolTip* GetToolTip() const { return m_tooltip; }
// Accept files for dragging
virtual void DragAcceptFiles(bool accept);
@ -371,7 +380,7 @@ public:
// be searched)
void PushEventHandler(wxEvtHandler *handler) ;
wxEvtHandler *PopEventHandler(bool deleteHandler = FALSE) ;
// Close the window by calling OnClose, posting a deletion
virtual bool Close(bool force = FALSE);
@ -454,9 +463,6 @@ public:
void OnEraseBackground(wxEraseEvent& event);
void OnChar(wxKeyEvent& event);
void OnKeyDown(wxKeyEvent& event);
void OnKeyUp(wxKeyEvent& event);
void OnPaint(wxPaintEvent& event);
void OnIdle(wxIdleEvent& event);
// Does this window want to accept keyboard focus?
@ -466,7 +472,7 @@ public:
public:
////////////////////////////////////////////////////////////////////////
//// IMPLEMENTATION
// For implementation purposes - sometimes decorations make the client area
// smaller
virtual wxPoint GetClientAreaOrigin() const;
@ -641,13 +647,13 @@ public:
// Detach "Window" menu from menu bar so it doesn't get deleted
void MSWDetachWindowMenu();
inline WXFARPROC MSWGetOldWndProc() const;
inline void MSWSetOldWndProc(WXFARPROC proc);
// Define for each class of dialog and control
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
inline void SetShowing(bool show);
inline bool IsUserEnabled() const;
@ -669,8 +675,8 @@ public:
protected:
wxAcceleratorTable m_acceleratorTable;
int m_windowId;
long m_windowStyle; // Store the window's style
wxEvtHandler * m_windowEventHandler; // Usually is 'this'
long m_windowStyle; // Store the window's style
wxEvtHandler * m_windowEventHandler; // Usually is 'this'
wxLayoutConstraints * m_constraints; // Constraints for this window
wxList * m_constraintsInvolvedIn; // List of constraints we're involved in
wxSizer * m_windowSizer; // Window's top-level sizer (if any)
@ -682,7 +688,7 @@ protected:
WXFARPROC m_oldWndProc;
bool m_useCtl3D; // Using CTL3D for this control
bool m_inOnSize; // Protection against OnSize reentry
bool m_inOnSize; // Protection against OnSize reentry
#ifndef _WX_WIN32__
// Pointer to global memory, for EDIT controls that need
// special treatment to reduce USER area consumption.
@ -730,7 +736,7 @@ protected:
#endif //USE_DRAG_AND_DROP
public:
WXHWND m_hWnd; // MS Windows window handle
WXHWND m_hWnd; // MS Windows window handle
WXUINT m_lastMsg;
WXWPARAM m_lastWParam;
WXLPARAM m_lastLParam;
@ -754,6 +760,9 @@ private:
// common part of all ctors
void Init();
// the associated tooltip (may be NULL if none)
wxToolTip *m_tooltip;
DECLARE_EVENT_TABLE()
};

View File

@ -9,18 +9,18 @@
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "controls.h"
#pragma implementation "controls.h"
#endif
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#include "wx/wx.h"
#endif
#include "wx/spinbutt.h"
@ -28,10 +28,7 @@
#include "wx/imaglist.h"
#include "wx/spinbutt.h"
#include "wx/clipbrd.h"
#ifdef __WXGTK__
#include "wx/tooltip.h"
#endif
#if defined(__WXGTK__) || defined(__WXMOTIF__)
#define USE_XPM
@ -127,7 +124,7 @@ class MyFrame: public wxFrame
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
bool OnClose(void) { return TRUE; }
void OnIdle( wxIdleEvent& event );
DECLARE_EVENT_TABLE()
};
@ -400,9 +397,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
// panel->SetBackgroundColour("cadet blue");
// panel->SetForegroundColour("blue");
m_listbox = new wxListBox( panel, ID_LISTBOX, wxPoint(10,10), wxSize(120,70), 5, choices );
#ifdef __WXGTK__
m_listbox->SetToolTip( "This is a list box" );
#endif
// m_listbox->SetBackgroundColour("wheat");
(void)new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
@ -410,16 +406,12 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
(void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
button = new wxButton( panel, ID_LISTBOX_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) );
#ifdef __WXGTK__
button->SetToolTip( "Press here to set italic font" );
#endif
// button->SetForegroundColour( "red" );
m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) );
m_checkbox->SetValue(FALSE);
#ifdef __WXGTK__
m_checkbox->SetToolTip( "Click here to disable the listbox" );
#endif
m_notebook->AddPage(panel, "wxList", TRUE, Image_List);
panel = new wxPanel(m_notebook);
@ -453,22 +445,29 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
panel = new wxPanel(m_notebook);
// panel->SetBackgroundColour("cadet blue");
// panel->SetForegroundColour("blue");
m_textentry = new MyTextCtrl( panel, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(320,28));
m_textentry = new MyTextCtrl( panel, -1, "Write text here.",
wxPoint(10,10), wxSize(320,28),
wxTE_PROCESS_ENTER);
(*m_textentry) << " More text.";
// m_textentry->SetBackgroundColour("wheat");
m_multitext = new MyTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(320,160), wxTE_MULTILINE );
m_multitext = new MyTextCtrl( panel, ID_TEXT, "And here.",
wxPoint(10,50), wxSize(320,80),
wxTE_MULTILINE );
(*m_multitext) << " More text."
<< "\nPress Fn keys to test different wxTextCtrl functions";
// m_multitext->SetBackgroundColour("wheat");
(void)new wxStaticBox( panel, -1, "Move cursor to the end of:",
(void)new MyTextCtrl( panel, -1, "This one is with wxTE_PROCESS_TAB style.",
wxPoint(10,140), wxSize(320,80), wxTE_MULTILINE | wxTE_PROCESS_TAB);
(void)new wxStaticBox( panel, -1, "&Move cursor to the end of:",
wxPoint(345, 0), wxSize(160, 100) );
(void)new wxButton(panel, ID_MOVE_END_ENTRY, "Text entry",
(void)new wxButton(panel, ID_MOVE_END_ENTRY, "Text &entry",
wxPoint(370, 20), wxSize(110, 30));
(void)new wxButton(panel, ID_MOVE_END_ZONE, "Text zone",
(void)new wxButton(panel, ID_MOVE_END_ZONE, "Text &zone",
wxPoint(370, 60), wxSize(110, 30));
(void)new wxStaticBox( panel, -1, "wxClipboard", wxPoint(345,120), wxSize(160,100) );
(void)new wxButton( panel, ID_COPY_TEXT, "Copy line 1", wxPoint(370,140), wxSize(110,30) );
(void)new wxButton( panel, ID_PASTE_TEXT, "Paste text", wxPoint(370,180), wxSize(110,30) );
(void)new wxStaticBox( panel, -1, "wx&Clipboard", wxPoint(345,120), wxSize(160,100) );
(void)new wxButton( panel, ID_COPY_TEXT, "C&opy line 1", wxPoint(370,140), wxSize(110,30) );
(void)new wxButton( panel, ID_PASTE_TEXT, "&Paste text", wxPoint(370,180), wxSize(110,30) );
m_notebook->AddPage(panel, "wxTextCtrl" , FALSE, Image_Text);
wxString choices2[] =
@ -480,8 +479,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
panel = new wxPanel(m_notebook);
// panel->SetBackgroundColour("cadet blue");
// panel->SetForegroundColour("blue");
m_radio = new wxRadioBox( panel, ID_RADIOBOX, "That", wxPoint(10,160), wxSize(-1,-1), 2, choices2, 1, wxRA_SPECIFY_ROWS );
// m_radio->SetBackgroundColour("wheat");
(void)new wxRadioBox( panel, ID_RADIOBOX, "That", wxPoint(10,160), wxSize(-1,-1), 2, choices2, 1, wxRA_SPECIFY_ROWS );
m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), 5, choices, 2, wxRA_SPECIFY_COLS );
// m_radio->SetBackgroundColour("wheat");
(void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
@ -862,12 +860,15 @@ MyPanel::~MyPanel()
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(MINIMAL_QUIT, MyFrame::OnQuit)
EVT_MENU(MINIMAL_ABOUT, MyFrame::OnAbout)
EVT_IDLE(MyFrame::OnIdle)
END_EVENT_TABLE()
MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h):
wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h)
: wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
{
(void)new MyPanel( this, 10, 10, 300, 100 );
CreateStatusBar();
(void)new MyPanel( this, 10, 10, 300, 100 );
}
void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) )
@ -880,3 +881,27 @@ void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
wxMessageDialog dialog(this, "This is a control sample", "About Controls", wxOK );
dialog.ShowModal();
}
void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(event) )
{
// track the window which has the focus in the status bar
static wxWindow *s_windowFocus = (wxWindow *)NULL;
wxWindow *focus = wxWindow::FindFocus();
if ( focus && (focus != s_windowFocus) )
{
s_windowFocus = focus;
wxString msg;
msg.Printf("Focus: wxWindow = %p"
#ifdef __WXMSW__
", HWND = %08x"
#endif // wxMSW
, s_windowFocus
#ifdef __WXMSW__
, s_windowFocus->GetHWND()
#endif // wxMSW
);
SetStatusText(msg);
}
}

View File

@ -17,19 +17,19 @@
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/setup.h"
#include "wx/frame.h"
#include "wx/menu.h"
#include "wx/app.h"
#include "wx/utils.h"
#include "wx/dialog.h"
#include "wx/settings.h"
#include "wx/dcclient.h"
#endif
#include "wx/setup.h"
#include "wx/frame.h"
#include "wx/menu.h"
#include "wx/app.h"
#include "wx/utils.h"
#include "wx/dialog.h"
#include "wx/settings.h"
#include "wx/dcclient.h"
#endif // WX_PRECOMP
#include "wx/msw/private.h"
#include "wx/statusbr.h"
@ -41,7 +41,7 @@
#endif
#if wxUSE_NATIVE_STATUSBAR
#include <wx/msw/statbr95.h>
#include <wx/msw/statbr95.h>
#endif
extern wxList wxModelessWindows;
@ -63,9 +63,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
#endif
#if wxUSE_NATIVE_STATUSBAR
bool wxFrame::m_useNativeStatusBar = TRUE;
bool wxFrame::m_useNativeStatusBar = TRUE;
#else
bool wxFrame::m_useNativeStatusBar = FALSE;
bool wxFrame::m_useNativeStatusBar = FALSE;
#endif
wxFrame::wxFrame(void)
@ -86,6 +86,10 @@ bool wxFrame::Create(wxWindow *parent,
long style,
const wxString& name)
{
#if wxUSE_TOOLTIPS
m_hwndToolTip = 0;
#endif
if (!parent)
wxTopLevelWindows.Append(this);