1 // DeskBand.h --- CDeskBand definitions
2 //
3 // Copyright (C) 2004, 2005, 2007 Raymond Penners <raymond@dotsphinx.com>
4 // All rights reserved.
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 //
19
20 #include <windows.h>
21 #include <shlobj.h>
22 #include <time.h>
23
24 #include "Globals.h"
25 #include "Applet.hh"
26
27 #ifndef DESKBAND_H
28 #define DESKBAND_H
29
30 #define DB_CLASS_NAME (TEXT("WorkraveApplet"))
31
32 #define DB_MIN_SIZE_X 10
33 #define DB_MIN_SIZE_Y 10
34
35 class TimerBox;
36
37 class CDeskBand : public IDeskBand2,
38 public IInputObject,
39 public IObjectWithSite,
40 public IPersistStream,
41 public IContextMenu
42 {
43 protected:
44 DWORD m_ObjRefCount;
45
46 public:
47 CDeskBand();
48 ~CDeskBand();
49
50 //IUnknown methods
51 STDMETHODIMP QueryInterface(REFIID, LPVOID*);
52 STDMETHODIMP_(DWORD) AddRef();
53 STDMETHODIMP_(DWORD) Release();
54
55 //IOleWindow methods
56 STDMETHOD (GetWindow) (HWND*);
57 STDMETHOD (ContextSensitiveHelp) (BOOL);
58
59 //IDockingWindow methods
60 STDMETHOD (ShowDW) (BOOL fShow);
61 STDMETHOD (CloseDW) (DWORD dwReserved);
62 STDMETHOD (ResizeBorderDW) (LPCRECT prcBorder, IUnknown* punkToolbarSite, BOOL fReserved);
63
64 //IDeskBand methods
65 STDMETHOD (GetBandInfo) (DWORD, DWORD, DESKBANDINFO*);
66
67 //IDeskBand2 methods
68 STDMETHOD ( CanRenderComposited )( BOOL * );
69 STDMETHOD ( GetCompositionState )( BOOL * );
70 STDMETHOD ( SetCompositionState )( BOOL );
71
72 //IInputObject methods
73 STDMETHOD (UIActivateIO) (BOOL, LPMSG);
74 STDMETHOD (HasFocusIO) ();
75 STDMETHOD (TranslateAcceleratorIO) (LPMSG);
76
77 //IObjectWithSite methods
78 STDMETHOD (SetSite) (IUnknown*);
79 STDMETHOD (GetSite) (REFIID, LPVOID*);
80
81 //IPersistStream methods
82 STDMETHOD (GetClassID) (LPCLSID);
83 STDMETHOD (IsDirty) ();
84 STDMETHOD (Load) (LPSTREAM);
85 STDMETHOD (Save) (LPSTREAM, BOOL);
86 STDMETHOD (GetSizeMax) (ULARGE_INTEGER*);
87
88 //IContextMenu methods
89 STDMETHOD (QueryContextMenu)(HMENU, UINT, UINT, UINT, UINT);
90 STDMETHOD (InvokeCommand)(LPCMINVOKECOMMANDINFO);
91 STDMETHOD (GetCommandString)(UINT_PTR, UINT, LPUINT, LPSTR, UINT);
92
93 HWND get_command_window() const;
94
95 private:
96 BOOL m_bFocus;
97 HWND m_hwndParent;
98 HWND m_hWnd;
99 DWORD m_dwViewMode;
100 DWORD m_dwBandID;
101 IInputObjectSite *m_pSite;
102 TimerBox *m_TimerBox;
103 time_t m_LastCopyData;
104 AppletMenuData m_AppletMenu;
105 BOOL m_HasAppletMenu;
106 BOOL m_CompositionEnabled;
107
108 private:
109 void FocusChange(BOOL);
110 LRESULT OnKillFocus();
111 LRESULT OnSetFocus();
112 static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
113 LRESULT OnCommand(WPARAM wParam, LPARAM lParam);
114 LRESULT OnCopyData(PCOPYDATASTRUCT data);
115 LRESULT OnSize(LPARAM);
116 LRESULT OnTimer(WPARAM wParam, LPARAM lParam);
117 LRESULT OnWindowPosChanging(WPARAM wParam, LPARAM lParam);
118 BOOL RegisterAndCreateWindow();
119 };
120
121 inline HWND
get_command_window()122 CDeskBand::get_command_window() const
123 {
124 return (HWND)LongToHandle( m_AppletMenu.command_window );
125 }
126
127 #endif //DESKBAND_H
128
129