source: CMT/v1r19/Visual/cmtw_utils.h@ 11

Last change on this file since 11 was 11, checked in by arnault, 21 years ago

Changing eol-style property

  • Property svn:eol-style set to native
File size: 6.1 KB
RevLine 
[5]1#ifndef __cmtw_utils_h__
2#define __cmtw_utils_h__
3
4#include <windows.h>
5#include "cmt.h"
6
7//-------------------------------------------------------------------
8class WWindow
9{
10public:
11 WWindow ();
12
13 void enable ();
14 void disable ();
15 void show ();
16 void hide ();
17
18protected:
19 HWND _window;
20};
21//-------------------------------------------------------------------
22
23//-------------------------------------------------------------------
24class WEdit : public WWindow
25{
26public:
27 WEdit ();
28 WEdit (HWND edit);
29 WEdit (HWND container, int id);
30
31 void init (HWND container, int id);
32 WEdit& operator = (HWND edit);
33 void set (const char* text);
34 void set (const cmt_string& text);
35 void clear ();
36 cmt_string get () const;
37 void copy (const WEdit& other);
38
39private:
40 HWND _edit;
41};
42//-------------------------------------------------------------------
43
44//-------------------------------------------------------------------
45class WRadio : public WWindow
46{
47public:
48 WRadio ();
49 WRadio (HWND radio);
50 WRadio (HWND container, int id);
51
52 void init (HWND container, int id);
53 WRadio& operator = (HWND radio);
54 void set (bool state);
55 bool get () const;
56 void copy (const WRadio& other);
57
58private:
59 HWND _radio;
60};
61//-------------------------------------------------------------------
62
63//-------------------------------------------------------------------
64class WList : public WWindow
65{
66public:
67 WList ();
68 WList (HWND list);
69 WList (HWND container, int id);
70
71 void init (HWND container, int id);
72 WList& operator = (HWND list);
73 void append (const char* text);
74 void append (const cmt_string& text);
75 void insert (int index, const cmt_string& text);
76 void modify (int index, const cmt_string& text);
77 void delete_item (int index);
78 void clear ();
79 void cancel_selection ();
80 int get_selected_index ();
81 void set_selected_index (int index);
82 cmt_string get_selected ();
83 int get_item_count () const;
84 cmt_string get_item (int index) const;
85 void get_item (int index, cmt_string& text) const;
86 int get_item_length (int index) const;
87 void copy (const WList& other);
88 void set (const CmtSystem::cmt_string_vector& v, int first = 0);
89 void set (const cmt_string& file_name);
90 void get (CmtSystem::cmt_string_vector& v) const;
91 void get (cmt_string& s) const;
92 void set_extent ();
93 int get_width () const;
94 int get_extent () const;
95
96private:
97 HWND _list;
98 int _selected_index;
99 int _width;
100};
101//-------------------------------------------------------------------
102
103//-------------------------------------------------------------------
104class WTab
105{
106public:
107 void add (const cmt_string& key, WWindow& window, WRadio& radio);
108 void select (const cmt_string& key);
109
110private:
111 cmt_vector<cmt_string> _keys;
112 cmt_vector<WWindow*> _windows;
113 cmt_vector<WRadio*> _radios;
114};
115//-------------------------------------------------------------------
116
117/*---------------------------------------------------------------------*/
118class mysb :public streambuf
119{
120public:
121 mysb (WList& list);
122 ~mysb ();
123
124private:
125 int_type overflow (int_type c);
126 int underflow ();
127
128 streambuf* _old;
129 cmt_string* _buf;
130 WList& _list;
131};
132/*---------------------------------------------------------------------*/
133
134/*---------------------------------------------------------------------*/
135class WDialog
136{
137public:
138 WDialog ();
139
140 virtual void action (UINT message_type,
141 WPARAM parameter1,
142 LPARAM parameter2);
143 virtual void init_action ();
144 virtual void menu_action (int menu_item,
145 WPARAM parameter1,
146 LPARAM parameter2);
147
148protected:
149
150 int run (HINSTANCE instance, HWND father, int id);
151
152 HWND _dialog;
153
154private:
155
156 static LRESULT CALLBACK proc (HWND dialog,
157 UINT message_type,
158 WPARAM parameter1,
159 LPARAM parameter2);
160};
161/*---------------------------------------------------------------------*/
162
163/*---------------------------------------------------------------------*/
164class TextEditor : public WDialog
165{
166public:
167 TextEditor (cmt_string& ref);
168
169 int run (HINSTANCE instance, HWND father);
170 virtual void action (UINT message_type,
171 WPARAM parameter1,
172 LPARAM parameter2);
173 void init_action ();
174 void menu_action (int menu_item, WPARAM parameter1, LPARAM parameter2);
175
176private:
177 cmt_string& _ref;
178 WEdit _edit;
179};
180/*---------------------------------------------------------------------*/
181
182/*---------------------------------------------------------------------*/
183class ListEditor : public WDialog
184{
185public:
186 ListEditor (WList& list);
187
188 int run (HINSTANCE instance, HWND father);
189 virtual void action (UINT message_type,
190 WPARAM parameter1,
191 LPARAM parameter2);
192 void set_position (int index);
193 void init_action ();
194 void menu_action (int menu_item, WPARAM parameter1, LPARAM parameter2);
195
196private:
197 WList& _ref_list;
198 WList _list;
199 HINSTANCE _instance;
200 int _selected_index;
201 int _last_index;
202 int _ref_selected_index;
203};
204/*---------------------------------------------------------------------*/
205
206/*---------------------------------------------------------------------*/
207class CmtMutex
208{
209public:
210 CmtMutex ();
211 ~CmtMutex ();
212
213 void lock ();
214 void unlock ();
215
216private:
217 CRITICAL_SECTION _section;
218};
219/*---------------------------------------------------------------------*/
220
221/*---------------------------------------------------------------------*/
222class CmtThread
223{
224public:
225 CmtThread ();
226 virtual ~CmtThread ();
227
228 virtual void run ();
229 bool is_running ();
230 void set_running ();
231 void reset_running ();
232 bool start ();
233 void stop ();
234
235private:
236 static void run_it (CmtThread* thread);
237
238 HANDLE _thread;
239 DWORD _id;
240 CmtMutex _mutex;
241 bool _shutdown;
242 bool _running;
243};
244/*---------------------------------------------------------------------*/
245
246
247#endif
Note: See TracBrowser for help on using the repository browser.