source: CMT/v1r10p20011126/src/install_utils.h @ 1

Last change on this file since 1 was 1, checked in by arnault, 19 years ago

Import all tags

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