diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-04-30 10:20:00 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-04-30 10:20:00 +0200 |
commit | 3ead3ad52f9bb2f9d1d6cf8dfc73a0a25e6778ed (patch) | |
tree | bdfd28afe5a452060e3d985c5f01b45f4b7bc2cd /include/vcl/menu.hxx | |
parent | 57d254d42b6e1d836bd21e6fb2e968af2b511c7d (diff) |
Gradually typed Link
Turn the Link class into a template abstracting over the link's argument and
return types, but provide default template arguments that keep the generic,
unsafe "void* in, sal_IntPtr out" behvior. That way, individual uses of the
Link class can be updated over time.
All the related macros are duplicated with ..._TYPED counterparts, that
additionally take the RetType (except for LINK_TYPED, which manages to infer the
relevant types from the supplied Member).
(It would have been attractive to change the "untyped" LinkStubs from taking a
void* to a properly typed ArgType parameter, too, but that would cause
-fsanitize=function to flag uses of "untyped" Link::Call.)
Change-Id: I3b0140378bad99abbf240140ebb4a46a05d2d2f8
Diffstat (limited to 'include/vcl/menu.hxx')
-rw-r--r-- | include/vcl/menu.hxx | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx index 32dfd5a73d28..2af6a530cb27 100644 --- a/include/vcl/menu.hxx +++ b/include/vcl/menu.hxx @@ -126,10 +126,10 @@ private: Menu* pStartedFrom; VclPtr<vcl::Window> pWindow; - Link aActivateHdl; // Active-Handler - Link aDeactivateHdl; // Deactivate-Handler - Link aHighlightHdl; // Highlight-Handler - Link aSelectHdl; // Highlight-Handler + Link<> aActivateHdl; // Active-Handler + Link<> aDeactivateHdl; // Deactivate-Handler + Link<> aHighlightHdl; // Highlight-Handler + Link<> aSelectHdl; // Highlight-Handler VclEventListeners maEventListeners; VclEventListeners maChildEventListeners; @@ -320,24 +320,24 @@ public: void SetHelpId( sal_uInt16 nItemId, const OString& rHelpId ); OString GetHelpId( sal_uInt16 nItemId ) const; - void SetActivateHdl( const Link& rLink ) { aActivateHdl = rLink; } - const Link& GetActivateHdl() const { return aActivateHdl; } + void SetActivateHdl( const Link<>& rLink ) { aActivateHdl = rLink; } + const Link<>& GetActivateHdl() const { return aActivateHdl; } - void SetDeactivateHdl( const Link& rLink ) { aDeactivateHdl = rLink; } - const Link& GetDeactivateHdl() const { return aDeactivateHdl; } + void SetDeactivateHdl( const Link<>& rLink ) { aDeactivateHdl = rLink; } + const Link<>& GetDeactivateHdl() const { return aDeactivateHdl; } - void SetHighlightHdl( const Link& rLink ) { aHighlightHdl = rLink; } - const Link& GetHighlightHdl() const { return aHighlightHdl; } + void SetHighlightHdl( const Link<>& rLink ) { aHighlightHdl = rLink; } + const Link<>& GetHighlightHdl() const { return aHighlightHdl; } - void SetSelectHdl( const Link& rLink ) { aSelectHdl = rLink; } - const Link& GetSelectHdl() const { return aSelectHdl; } + void SetSelectHdl( const Link<>& rLink ) { aSelectHdl = rLink; } + const Link<>& GetSelectHdl() const { return aSelectHdl; } bool HasLogo() const { return pLogo != nullptr; } - void AddEventListener( const Link& rEventListener ); - void RemoveEventListener( const Link& rEventListener ); - void AddChildEventListener( const Link& rEventListener ); - void RemoveChildEventListener( const Link& rEventListener ); + void AddEventListener( const Link<>& rEventListener ); + void RemoveEventListener( const Link<>& rEventListener ); + void AddChildEventListener( const Link<>& rEventListener ); + void RemoveChildEventListener( const Link<>& rEventListener ); Menu& operator =( const Menu& rMenu ); @@ -393,9 +393,9 @@ namespace vcl class VCL_DLLPUBLIC MenuBar : public Menu { - Link maCloseHdl; - Link maFloatHdl; - Link maHideHdl; + Link<> maCloseHdl; + Link<> maFloatHdl; + Link<> maHideHdl; bool mbCloseBtnVisible; bool mbFloatBtnVisible; bool mbHideBtnVisible; @@ -447,12 +447,12 @@ public: bool HandleMenuCommandEvent(Menu *pMenu, sal_uInt16 nEventId) const; bool HandleMenuButtonEvent(Menu *pMenu, sal_uInt16 nEventId); - void SetCloseButtonClickHdl( const Link& rLink ) { maCloseHdl = rLink; } - const Link& GetCloseButtonClickHdl() const { return maCloseHdl; } - void SetFloatButtonClickHdl( const Link& rLink ) { maFloatHdl = rLink; } - const Link& GetFloatButtonClickHdl() const { return maFloatHdl; } - void SetHideButtonClickHdl( const Link& rLink ) { maHideHdl = rLink; } - const Link& GetHideButtonClickHdl() const { return maHideHdl; } + void SetCloseButtonClickHdl( const Link<>& rLink ) { maCloseHdl = rLink; } + const Link<>& GetCloseButtonClickHdl() const { return maCloseHdl; } + void SetFloatButtonClickHdl( const Link<>& rLink ) { maFloatHdl = rLink; } + const Link<>& GetFloatButtonClickHdl() const { return maFloatHdl; } + void SetHideButtonClickHdl( const Link<>& rLink ) { maHideHdl = rLink; } + const Link<>& GetHideButtonClickHdl() const { return maHideHdl; } // - by default a menubar is displayable // - if a menubar is not displayable, its MenuBarWindow will never be shown @@ -470,11 +470,11 @@ public: // add an arbitrary button to the menubar (will appear next to closer) // passed link will be call with a MenuBarButtonCallbackArg on press // passed string will be set as tooltip - sal_uInt16 AddMenuBarButton( const Image&, const Link&, const OUString&, sal_uInt16 nPos = 0 ); + sal_uInt16 AddMenuBarButton( const Image&, const Link<>&, const OUString&, sal_uInt16 nPos = 0 ); // set the highlight link for additional button with ID nId // highlight link will be called with a MenuBarButtonHighlightArg // the bHighlight member of that struct shall contain the new state - void SetMenuBarButtonHighlightHdl( sal_uInt16 nId, const Link& ); + void SetMenuBarButtonHighlightHdl( sal_uInt16 nId, const Link<>& ); // returns the rectangle occupied by the additional button named nId // coordinates are relative to the systemwindiow the menubar is attached to // if the menubar is unattached an empty rectangle is returned |