From 1e151594721201f2048aa295dcf35acd28f012b9 Mon Sep 17 00:00:00 2001 From: Ryan Norton Date: Fri, 8 Oct 2004 01:26:43 +0000 Subject: [PATCH] various cleanups git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29727 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 4 ++ include/wx/cocoa/tooltip.h | 19 ++++---- src/cocoa/display.mm | 4 +- src/cocoa/tooltip.mm | 91 ++++++++++++++++++++++++++++++++++++++ src/cocoa/window.mm | 9 ++-- 5 files changed, 111 insertions(+), 16 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index a77b61aa77..97ccb2b81d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -262,6 +262,10 @@ wxCOCOA: - Added UNICODE layer for OSX so that you can build wxWidgets in UNICODE mode in OSX 10.2 (and possibly lower) with wxMAC and wxCOCOA (RN) - Fixed so that wxCOCOA runs in 10.2 (and possibly lower) (RN) +- Tooltips now supported - Enable and SetDelay not implemented (RN) +- wxSound now supported (RN) +- wxDisplay now supported (RN) +- Cursors (hopefully) now supported (RN) wxMac: diff --git a/include/wx/cocoa/tooltip.h b/include/wx/cocoa/tooltip.h index 403445363b..42433e2398 100644 --- a/include/wx/cocoa/tooltip.h +++ b/include/wx/cocoa/tooltip.h @@ -11,29 +11,32 @@ #include "wx/object.h" +class wxWindow; + class wxToolTip : public wxObject { public: // ctor & dtor - wxToolTip(const wxString &tip) : m_text(tip), m_window(0) {} - virtual ~wxToolTip() {} + wxToolTip(const wxString &tip); + virtual ~wxToolTip(); // accessors // tip text - void SetTip(const wxString& tip) { m_text = tip; } - const wxString& GetTip() const { return m_text; } + void SetTip(const wxString& tip); + const wxString& GetTip() const; // the window we're associated with - wxWindow *GetWindow() const { return m_window; } + wxWindow *GetWindow() const; // controlling tooltip behaviour: globally change tooltip parameters // enable or disable the tooltips globally - static void Enable(bool flag) {} + static void Enable(bool flag); // set the delay after which the tooltip appears - static void SetDelay(long milliseconds) {} + static void SetDelay(long milliseconds); private: - void SetWindow(wxWindow* window) {m_window = window;} + void SetWindow(wxWindow* window); + friend class wxWindow; wxString m_text; // tooltip text diff --git a/src/cocoa/display.mm b/src/cocoa/display.mm index 5bfc26bef7..e54ed5c107 100644 --- a/src/cocoa/display.mm +++ b/src/cocoa/display.mm @@ -1,11 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/cocoa/display.cpp +// Name: src/cocoa/display.mm // Purpose: Cocoa implementation of wxDisplay class // Author: Ryan Norton // Modified by: // Created: 2004-10-03 // RCS-ID: $Id$ -// Copyright: (c) wxWidgets team +// Copyright: (c) Ryan Norton // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// diff --git a/src/cocoa/tooltip.mm b/src/cocoa/tooltip.mm index 8b13789179..fd2907bbdc 100644 --- a/src/cocoa/tooltip.mm +++ b/src/cocoa/tooltip.mm @@ -1 +1,92 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/cocoa/tooltip.mm +// Purpose: Cocoa tooltips +// Author: Ryan Norton +// Modified by: +// Created: 2004-10-03 +// RCS-ID: $Id$ +// Copyright: (c) Ryan Norton +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// +// =========================================================================== +// declarations +// =========================================================================== + +// --------------------------------------------------------------------------- +// headers +// --------------------------------------------------------------------------- + +#include "wx/defs.h" + +#if wxUSE_TOOLTIPS + +#include "wx/window.h" +#include "wx/tooltip.h" + +#include "wx/cocoa/autorelease.h" +#include "wx/cocoa/string.h" + +#import + +//----------------------------------------------------------------------------- +// wxToolTip +//----------------------------------------------------------------------------- + +IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject) + +wxToolTip::wxToolTip(const wxString &tip) : + m_text(tip), m_window(0) +{ +} + +wxToolTip::~wxToolTip() +{ +} + +void wxToolTip::SetTip(const wxString& tip) +{ + m_text = tip; +} + +const wxString& wxToolTip::GetTip() const +{ + return m_text; +} + +// the window we're associated with +wxWindow *wxToolTip::GetWindow() const +{ + return m_window; +} + +// enable or disable the tooltips globally +//static + void wxToolTip::Enable(bool flag) +{ + //TODO + wxFAIL_MSG(wxT("Not implemented")); +} + +// set the delay after which the tooltip appears +//static + void SetDelay(long milliseconds) +{ + //TODO + wxFAIL_MSG(wxT("Not implemented")); +} + +void wxToolTip::SetWindow(wxWindow* window) +{ + wxAutoNSAutoreleasePool pool; + + m_window = window; + + //set the tooltip - empty string means remove + if (m_text.IsEmpty()) + [m_window->GetNSView() setToolTip:nil]; + else + [m_window->GetNSView() setToolTip:wxNSStringWithWxString(m_text)]; +} + +#endif //wxUSE_TOOLTIPS diff --git a/src/cocoa/window.mm b/src/cocoa/window.mm index 96e4777abe..0395a461c1 100644 --- a/src/cocoa/window.mm +++ b/src/cocoa/window.mm @@ -25,7 +25,6 @@ #import #import #import -#import #include @@ -611,22 +610,20 @@ void wxWindowCocoa::DoSetSize(int x, int y, int width, int height, int sizeFlags DoMoveWindow(x,y,width,height); } -//We should really get rid of wxToolTip :) -IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject) +#if wxUSE_TOOLTIPS void wxWindowCocoa::DoSetToolTip( wxToolTip *tip ) { wxWindowBase::DoSetToolTip(tip); - wxAutoNSAutoreleasePool pool; - if ( m_tooltip ) { m_tooltip->SetWindow((wxWindow *)this); - [GetNSView() setToolTip:wxNSStringWithWxString(m_tooltip->GetTip())]; } } +#endif + void wxWindowCocoa::DoMoveWindow(int x, int y, int width, int height) { wxAutoNSAutoreleasePool pool;