reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit d60e9ec705d4ebc99cacbc8e19e4b86e78729eca
parent 90ef17acb2649dcabd3768995bc5833768c7b0d9
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Mon,  1 Feb 2016 16:58:55 -0500

remove the Description tab from the about dialog when text is empty or invalid

Diffstat:
Msrc/about.cpp | 7+++++--
Msrc/richedit.cpp | 10++++++++--
Msrc/richedit.hpp | 2+-
Msrc/richedit.mm | 4+++-
Msrc/tabbar.cpp | 8++++++++
Msrc/tabbar.hpp | 1+
6 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/src/about.cpp b/src/about.cpp @@ -87,7 +87,7 @@ void About::populate() SetWindowText(handle(), title); - m_about->setRichText( + const char *tmpRtf = \ "{\\rtf1\\ansi\\ansicpg1252\\cocoartf1348\\cocoasubrtf170\n" "{\\fonttbl\\f0\\fnil\\fcharset134 STHeitiSC-Light;}\n" "{\\colortbl;\\red255\\green255\\blue255;}\n" @@ -95,7 +95,10 @@ void About::populate() "\\pard\\tx566\\tx1133\\tx1700\\tx2267\\tx2834\\tx3401\\tx3968\\tx4535\\tx5102\\tx5669\\tx6236\\tx6803\\pardirnatural\n" "\\f0\\fs24 \\cf0 http://perdu.com test" "{\\field{\\*\\fldinst{HYPERLINK \"https://msdn.microsoft.com/en-us/library/windows/desktop/bb787974%28v=vs.85%29.aspx\"}}{\\fldrslt \\f0\\fs24 \\cf0 \\'d0\\'c2\\'ca\\'c0\\'bd\\'e7\\'a4\\'e8\\'a4\\'ea}}}\n" - ); + ; + + if(!m_about->setRichText(tmpRtf)) + m_tabs->removeTab(0); m_cats->addRow({AUTO_STR("<All Categories>")}); diff --git a/src/richedit.cpp b/src/richedit.cpp @@ -73,15 +73,21 @@ void RichEdit::handleLink(LPARAM lParam) } // OS X implementation of setRichText in richedit.mm -void RichEdit::setRichText(const string &rtf) +bool RichEdit::setRichText(const string &rtf) { SETTEXTEX st{}; - SendMessage(handle(), EM_SETTEXTEX, (WPARAM)&st, (LPARAM)rtf.c_str()); + if(!SendMessage(handle(), EM_SETTEXTEX, (WPARAM)&st, (LPARAM)rtf.c_str())) + return false; GETTEXTLENGTHEX tl{}; LONG length = (LONG)SendMessage(handle(), EM_GETTEXTLENGTHEX, (WPARAM)&tl, 0); + if(!length) + return false; + CHARRANGE cr{length, length}; SendMessage(handle(), EM_EXSETSEL, 0, (LPARAM)&cr); + + return true; } #endif diff --git a/src/richedit.hpp b/src/richedit.hpp @@ -28,7 +28,7 @@ public: RichEdit(HWND); - void setRichText(const std::string &); + bool setRichText(const std::string &); protected: void onNotify(LPNMHDR, LPARAM) override; diff --git a/src/richedit.mm b/src/richedit.mm @@ -21,7 +21,7 @@ using namespace std; -void RichEdit::setRichText(const string &rtf) +bool RichEdit::setRichText(const string &rtf) { NSString *str = [NSString stringWithCString:rtf.c_str() @@ -46,4 +46,6 @@ void RichEdit::setRichText(const string &rtf) // hack: restore NSTextView's default mouse cursors (eg. hover links) // this doesn't fix the shy link tooltips SetCapture(handle()); + + return [[textView string] length]; } diff --git a/src/tabbar.cpp b/src/tabbar.cpp @@ -54,6 +54,14 @@ int TabBar::currentIndex() const return TabCtrl_GetCurSel(handle()); } +void TabBar::removeTab(const int index) +{ + if(TabCtrl_DeleteItem(handle(), index)) { + m_pages.erase(m_pages.begin() + index); + switchPage(); + } +} + void TabBar::onNotify(LPNMHDR info, LPARAM) { switch(info->code) { diff --git a/src/tabbar.hpp b/src/tabbar.hpp @@ -33,6 +33,7 @@ public: TabBar(const Tabs &tabs, HWND handle); int addTab(const Tab &); int currentIndex() const; + void removeTab(const int); protected: void onNotify(LPNMHDR, LPARAM) override;