4 ==============================================================================
6 This file is part of the mini timer
7 Copyright 2005-10 by Satoshi Fujiwara.
9 mini timer can be redistributed and/or modified under the terms of the
10 GNU General Public License, as published by the Free Software Foundation;
11 either version 2 of the License, or (at your option) any later version.
13 mini timer is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with mini timer; if not, visit www.gnu.org/licenses or write to the
20 Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21 Boston, MA 02111-1307 USA
23 ==============================================================================
26 #include "exception.h"
33 //struct thumb_button : boost::noncopyable
35 // typedef std::shared_ptr<thumb_button> ptr;
36 // static ptr create_thumb_button();
37 // virtual void show() = 0;
38 // virtual void hide() = 0;
39 // virtual void enable() = 0;
40 // virtual void disable() = 0;
48 struct thumb_button_manager
50 friend struct taskbar;
51 // Thumb Buttonは最大7個まで
52 static const int THUMB_BUTTON_MAX = 7;
54 // THUMBBUTTON構造体操作クラス
58 thumb_button(uint32_t id ,const icon& i,const std::wstring& tool_tip,THUMBBUTTON& t) : thumb_(t)
60 BOOST_ASSERT(tool_tip.size() < 259);
61 memset(&thumb_,0,sizeof(THUMBBUTTON));
62 thumb_.dwMask = THB_ICON | THB_TOOLTIP | THB_FLAGS;
63 thumb_.hIcon = i.get();
65 std::copy(tool_tip.begin(),tool_tip.end(),thumb_.szTip);
66 //thumb_.szTip = const_cast<wchar_t*>(tool_tip_.c_str());
70 thumb_button& set_icon(icon& ic) {thumb_.hIcon = ic.get(); return *this;};
72 thumb_button& id(uint32_t v) {thumb_.iId = v; return *this;}
74 thumb_button& tool_tip(const std::wstring& v) {
75 BOOST_ASSERT(v.size() < 259);
76 std::copy(v.begin(),v.end(),thumb_.szTip);
77 thumb_.szTip[v.size()] = L'\0';
81 thumb_button& enable(bool v){v?(thumb_.dwFlags &= ~THBF_ENABLED):(thumb_.dwFlags |= THBF_DISABLED); return *this;}
82 /** クリックされたらサムネイルを閉じるか */
83 thumb_button& dismission_click(bool v){ v?(thumb_.dwFlags |= THBF_DISMISSONCLICK):(thumb_.dwFlags &= ~THBF_DISMISSONCLICK); return *this;}
84 /** ボタンの外枠を描画するかどうか */
85 thumb_button& no_background(bool v){v?(thumb_.dwFlags |= THBF_NOBACKGROUND):(thumb_.dwFlags &= ~THBF_NOBACKGROUND);return *this;}
87 thumb_button& hidden(bool v){v?(thumb_.dwFlags |= THBF_HIDDEN):(thumb_.dwFlags &= ~ THBF_HIDDEN);return *this;}
88 /** ボタンアクションを起こすかどうか。ボタンを通知目的で使用する際に用いる。*/
89 thumb_button& no_interacive(bool v){v?(thumb_.dwFlags |= THBF_NONINTERACTIVE):(thumb_.dwFlags &= ~THBF_NONINTERACTIVE);return *this;}
95 thumb_button_manager() : is_added(false) {}
97 // Thumb Buttonは7個までに制限されている
98 thumb_button& add_thumb_button(uint32_t id,const icon& i,const std::wstring& str)
101 BOOST_ASSERT(thumb_buttons_.size() < 7 && is_added == false);
103 thumbbuttons_.push_back(THUMBBUTTON());
104 thumb_buttons_.push_back(thumb_button(id,i,str, (thumbbuttons_.at(thumbbuttons_.size() - 1))));
106 return thumb_buttons_.at(thumb_buttons_.size() - 1);
109 thumb_button& at(uint32_t i){
110 BOOST_ASSERT(i < thumb_buttons_.size());
111 return thumb_buttons_.at(i);
114 size_t size() const {return thumb_buttons_.size();}
116 mutable bool is_added;
117 // メモリ配列を合わせるためにこうした。
118 std::vector<THUMBBUTTON> thumbbuttons_;
119 std::vector<thumb_button> thumb_buttons_;
120 //typedef boost::ptr_vector<thumb_button> thumb_buttons;
123 /** タスクバーAPIのラップクラス。本来であればインターフェースにする方が良いかもしれないけれど */
124 struct taskbar : boost::noncopyable
127 : public sf::win32_error_exception
129 exception(uint32_t hr) : win32_error_exception(hr) {};
130 exception() : win32_error_exception() {} ;
137 void overlay_icon(const sf::base_window& w,const icon& ic,const std::wstring& description);
138 void progress_state(const sf::base_window& w,int state);
139 void progress_value(const sf::base_window& w,boost::uint64_t completed, boost::uint64_t total);
141 void add_thumb_buttons(const sf::base_window& w,const thumb_button_manager& tm);
142 void update_thumb_buttons(const sf::base_window& w,const thumb_button_manager& tm);
143 bool is_create() const;
145 static long register_message();
147 static const int none;
148 static const int indeterminate;
149 static const int normal;
150 static const int error;
151 static const int paused;
155 std::shared_ptr<impl> impl_;