Subversion Repositories Kolibri OS

Rev

Rev 1805 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1805 Rev 5123
1
#ifndef _HEADER_BUTTONS_H
1
#ifndef _HEADER_BUTTONS_H
2
#define _HEADER_BUTTONS_H
2
#define _HEADER_BUTTONS_H
3
 
-
 
4
#ifndef __MENUET__
3
 
5
#include 
4
#include 
6
#include 
5
#include 
7
#include 
6
#include 
8
#endif
-
 
9
#include "gr-draw.h"
7
#include "gr-draw.h"
10
 
8
 
11
struct TXButton
9
struct TXButton
12
{
10
{
13
  TXButton(int n = -1, int w = 100, int h = 20) : num(n), w(w), h(h), drw(1) {}
11
  TXButton(int n = -1, int w = 100, int h = 20) : num(n), w(w), h(h), drw(1) {}
14
  TXButton(const TXButton &b) : w(b.w), h(b.h) {}
12
  TXButton(const TXButton &b) : w(b.w), h(b.h) {}
15
 
13
 
16
  TXButton &operator=(const TXButton &b) {w = b.w; h = b.h; num = b.num; return *this;}
14
  TXButton &operator=(const TXButton &b) {w = b.w; h = b.h; num = b.num; return *this;}
17
 
15
 
18
  virtual void Draw(TGraphDraw *drw, int x0, int y0,
16
  virtual void Draw(TGraphDraw *drw, int x0, int y0,
19
      unsigned long dcolor, unsigned long lcolor, unsigned long tcolor, int ins = 0);
17
      unsigned long dcolor, unsigned long lcolor, unsigned long tcolor, int ins = 0);
20
  virtual int ButtonPnt(int xp, int yp, int &n, int kind = 0);
18
  virtual int ButtonPnt(int xp, int yp, int &n, int kind = 0);
21
 
19
 
22
  int num, w, h, drw;
20
  int num, w, h, drw;
23
};
21
};
24
 
22
 
25
void TXButton::Draw(TGraphDraw *drw, int x0, int y0,
23
void TXButton::Draw(TGraphDraw *drw, int x0, int y0,
26
         unsigned long dcolor, unsigned long /*lcolor*/,
24
         unsigned long dcolor, unsigned long /*lcolor*/,
27
         unsigned long /*tcolor*/, int /*ins*/)
25
         unsigned long /*tcolor*/, int /*ins*/)
28
{
26
{
29
  if (!drw || !drw->IsDraw()) return;
27
  if (!drw || !drw->IsDraw()) return;
30
  drw->SetColor(dcolor);
28
  drw->SetColor(dcolor);
31
  drw->DrawLine(x0, y0, x0 + w, y0);
29
  drw->DrawLine(x0, y0, x0 + w, y0);
32
  drw->DrawLine(x0, y0, x0, y0 + h);
30
  drw->DrawLine(x0, y0, x0, y0 + h);
33
  drw->DrawLine(x0 + w, y0, x0 + w, y0 + h);
31
  drw->DrawLine(x0 + w, y0, x0 + w, y0 + h);
34
  drw->DrawLine(x0, y0 + h, x0 + w, y0 + h);
32
  drw->DrawLine(x0, y0 + h, x0 + w, y0 + h);
35
}
33
}
36
 
34
 
37
int TXButton::ButtonPnt(int xp, int yp, int &n, int /*kind*/)
35
int TXButton::ButtonPnt(int xp, int yp, int &n, int /*kind*/)
38
{
36
{
39
  n = num;
37
  n = num;
40
  return (xp >= 0 && yp >= 0 && xp <= w && yp <= h) ? 1 : INT_MIN;
38
  return (xp >= 0 && yp >= 0 && xp <= w && yp <= h) ? 1 : INT_MIN;
41
}
39
}
42
 
40
 
43
 
41
 
44
struct TextButton : public TXButton
42
struct TextButton : public TXButton
45
{
43
{
46
  enum {thick_def = 3};
44
  enum {thick_def = 3};
47
 
45
 
48
  TextButton(int n = -1, int w = 100, int h = 20, char *text = 0, int thick = thick_def)
46
  TextButton(int n = -1, int w = 100, int h = 20, char *text = 0, int thick = thick_def)
49
               : TXButton(n, w, h), text(text), thick(thick) {CheckDefW();}
47
               : TXButton(n, w, h), text(text), thick(thick) {CheckDefW();}
50
  TextButton(const TXButton &b, char *text = 0, int thick = thick_def)
48
  TextButton(const TXButton &b, char *text = 0, int thick = thick_def)
51
               : TXButton(b), text(text), thick(thick) {CheckDefW();}
49
               : TXButton(b), text(text), thick(thick) {CheckDefW();}
52
  TextButton(const TextButton &b) : TXButton(b), text(b.text), thick(b.thick) {}
50
  TextButton(const TextButton &b) : TXButton(b), text(b.text), thick(b.thick) {}
53
 
51
 
54
  TextButton &operator=(const TextButton &b);
52
  TextButton &operator=(const TextButton &b);
55
 
53
 
56
  virtual void Draw(TGraphDraw *drw, int x0, int y0,
54
  virtual void Draw(TGraphDraw *drw, int x0, int y0,
57
      unsigned long dcolor, unsigned long lcolor, unsigned long tcolor, int ins = 0);
55
      unsigned long dcolor, unsigned long lcolor, unsigned long tcolor, int ins = 0);
58
  void CheckDefW();
56
  void CheckDefW();
59
 
57
 
60
  int thick;
58
  int thick;
61
  char *text;
59
  char *text;
62
};
60
};
63
 
61
 
64
inline TextButton &TextButton::operator=(const TextButton &b)
62
inline TextButton &TextButton::operator=(const TextButton &b)
65
{
63
{
66
  text = b.text;
64
  text = b.text;
67
  TXButton::operator=(b);
65
  TXButton::operator=(b);
68
  return *this;
66
  return *this;
69
}
67
}
70
 
68
 
71
void TextButton::Draw(TGraphDraw *drw, int x0, int y0,
69
void TextButton::Draw(TGraphDraw *drw, int x0, int y0,
72
           unsigned long dcolor, unsigned long lcolor, unsigned long tcolor, int ins)
70
           unsigned long dcolor, unsigned long lcolor, unsigned long tcolor, int ins)
73
{
71
{
74
  if (!drw || !drw->IsDraw()) return;
72
  if (!drw || !drw->IsDraw()) return;
75
  int i;
73
  int i;
76
  if (thick <= -1 && thick >= -5)
74
  if (thick <= -1 && thick >= -5)
77
  {
75
  {
78
    drw->SetColor(dcolor);
76
    drw->SetColor(dcolor);
79
    for (i = 0; i < -thick; i++)
77
    for (i = 0; i < -thick; i++)
80
    {
78
    {
81
      drw->DrawLine(x0 + i, y0 + i, x0 + w - i, y0 + i);
79
      drw->DrawLine(x0 + i, y0 + i, x0 + w - i, y0 + i);
82
      drw->DrawLine(x0 + i, y0 + i, x0 + i, y0 + h - i);
80
      drw->DrawLine(x0 + i, y0 + i, x0 + i, y0 + h - i);
83
      drw->DrawLine(x0 + w - i, y0 + i, x0 + w - i, y0 + h - i);
81
      drw->DrawLine(x0 + w - i, y0 + i, x0 + w - i, y0 + h - i);
84
      drw->DrawLine(x0 + i, y0 + h - i, x0 + w - i, y0 + h - i);
82
      drw->DrawLine(x0 + i, y0 + h - i, x0 + w - i, y0 + h - i);
85
    }
83
    }
86
  }
84
  }
87
  else if (thick > 0)
85
  else if (thick > 0)
88
  {
86
  {
89
    for (i = 0; i < thick; i++)
87
    for (i = 0; i < thick; i++)
90
    {
88
    {
91
      drw->SetColor(ins ? dcolor : lcolor);
89
      drw->SetColor(ins ? dcolor : lcolor);
92
      drw->DrawLine(x0 + i, y0 + i, x0 + w - i, y0 + i);
90
      drw->DrawLine(x0 + i, y0 + i, x0 + w - i, y0 + i);
93
      drw->DrawLine(x0 + i, y0 + i, x0 + i, y0 + h - i);
91
      drw->DrawLine(x0 + i, y0 + i, x0 + i, y0 + h - i);
94
      drw->SetColor(ins ? lcolor : dcolor);
92
      drw->SetColor(ins ? lcolor : dcolor);
95
      drw->DrawLine(x0 + w - i, y0 + i, x0 + w - i, y0 + h - i);
93
      drw->DrawLine(x0 + w - i, y0 + i, x0 + w - i, y0 + h - i);
96
      drw->DrawLine(x0 + i, y0 + h - i, x0 + w - i, y0 + h - i);
94
      drw->DrawLine(x0 + i, y0 + h - i, x0 + w - i, y0 + h - i);
97
    }
95
    }
98
  }
96
  }
99
  else TXButton::Draw(drw, x0, y0, dcolor, lcolor, tcolor, ins);
97
  else TXButton::Draw(drw, x0, y0, dcolor, lcolor, tcolor, ins);
100
  if (text)
98
  if (text)
101
  {
99
  {
102
    drw->SetColor(tcolor);
100
    drw->SetColor(tcolor);
103
    drw->DrawText(x0 + 7, y0 + (h - drw->GetTextH(text)) / 2, text);
101
    drw->DrawText(x0 + 7, y0 + (h - drw->GetTextH(text)) / 2, text);
104
  }
102
  }
105
}
103
}
106
 
104
 
107
inline void TextButton::CheckDefW()
105
inline void TextButton::CheckDefW()
108
{
106
{
109
  if (w < 0 && text) w = 15 + strlen(text) * 8;
107
  if (w < 0 && text) w = 15 + strlen(text) * 8;
110
}
108
}
111
 
109
 
112
class TXButtonArray
110
class TXButtonArray
113
{
111
{
114
public:
112
public:
115
  TXButtonArray(int d = 10) : button(0), nbutton(0), mbutton(0),
113
  TXButtonArray(int d = 10) : button(0), nbutton(0), mbutton(0),
116
                              delt(d), ins(-1), k_ins(0) {}
114
                              delt(d), ins(-1), k_ins(0) {}
117
  ~TXButtonArray() {Clear();}
115
  ~TXButtonArray() {Clear();}
118
 
116
 
119
  void Clear();
117
  void Clear();
120
  void Add(TXButton *bt);
118
  void Add(TXButton *bt);
121
  void Add(int n = -1, int w = 100, int h = 20, char *str = 0,
119
  void Add(int n = -1, int w = 100, int h = 20, char *str = 0,
122
           int thick = TextButton::thick_def);
120
           int thick = TextButton::thick_def);
123
  TXButton *operator[](int i) {return button[i];}
121
  TXButton *operator[](int i) {return button[i];}
124
  int GetNButton() const {return nbutton;}
122
  int GetNButton() const {return nbutton;}
125
  int GetInsert() const {return ins;}
123
  int GetInsert() const {return ins;}
126
  TXButton *GetButton(int n);
124
  TXButton *GetButton(int n);
127
 
125
 
128
  int GetDelt() const {return delt;}
126
  int GetDelt() const {return delt;}
129
  void SetDelt(int d) {delt = d;}
127
  void SetDelt(int d) {delt = d;}
130
 
128
 
131
  int GetParam(int w, int p) const;
129
  int GetParam(int w, int p) const;
132
  int GetNumStr(int w) const {return GetParam(w, 0);}
130
  int GetNumStr(int w) const {return GetParam(w, 0);}
133
  int GetHeight(int w) const {return GetParam(w, 1);}
131
  int GetHeight(int w) const {return GetParam(w, 1);}
134
  int GetFWidth() const;
132
  int GetFWidth() const;
135
 
133
 
136
  void Draw(TGraphDraw *drw, int x0, int y0, int w);
134
  void Draw(TGraphDraw *drw, int x0, int y0, int w);
137
  void Draw(TGraphDraw *drw, int x0, int y0, int w,
135
  void Draw(TGraphDraw *drw, int x0, int y0, int w,
138
     unsigned long dcolor, unsigned long lcolor, unsigned long tcolor, int insd = 1);
136
     unsigned long dcolor, unsigned long lcolor, unsigned long tcolor, int insd = 1);
139
  int ButtonPnt(int xp, int yp, int w, int &n, int kind = 0);
137
  int ButtonPnt(int xp, int yp, int w, int &n, int kind = 0);
140
protected:
138
protected:
141
  void Extend(int n = -1);
139
  void Extend(int n = -1);
142
 
140
 
143
  TXButton **button;
141
  TXButton **button;
144
  int nbutton, mbutton;
142
  int nbutton, mbutton;
145
  int delt;
143
  int delt;
146
  int ins, k_ins;
144
  int ins, k_ins;
147
};
145
};
148
 
146
 
149
void TXButtonArray::Clear()
147
void TXButtonArray::Clear()
150
{
148
{
151
  int i;
149
  int i;
152
  if (button)
150
  if (button)
153
  {
151
  {
154
    for (i = 0; i < nbutton; i++) if (button[i]) delete button[i];
152
    for (i = 0; i < nbutton; i++) if (button[i]) delete button[i];
155
    delete[] button;
153
    delete[] button;
156
  }
154
  }
157
  button = 0; nbutton = 0; mbutton = 0;
155
  button = 0; nbutton = 0; mbutton = 0;
158
}
156
}
159
 
157
 
160
void TXButtonArray::Extend(int n)
158
void TXButtonArray::Extend(int n)
161
{
159
{
162
  if (n < 0) n = nbutton + 1;
160
  if (n < 0) n = nbutton + 1;
163
  if (mbutton < n)
161
  if (mbutton < n)
164
  {
162
  {
165
    typedef TXButton *TXButtonPnt;
163
    typedef TXButton *TXButtonPnt;
166
    TXButton **b_old = button;
164
    TXButton **b_old = button;
167
    int m_old = mbutton;
165
    int m_old = mbutton;
168
    mbutton = n * 2;
166
    mbutton = n * 2;
169
    button = new TXButtonPnt[mbutton];
167
    button = new TXButtonPnt[mbutton];
170
    for (int i = 0; i < mbutton; i++) button[i] = 0;
168
    for (int i = 0; i < mbutton; i++) button[i] = 0;
171
    if (b_old)
169
    if (b_old)
172
    {
170
    {
173
      for (int i = 0; i < m_old; i++) button[i] = b_old[i];
171
      for (int i = 0; i < m_old; i++) button[i] = b_old[i];
174
      delete[] b_old;
172
      delete[] b_old;
175
    }
173
    }
176
  }
174
  }
177
}
175
}
178
 
176
 
179
void TXButtonArray::Add(TXButton *bt)
177
void TXButtonArray::Add(TXButton *bt)
180
{
178
{
181
  Extend();
179
  Extend();
182
  if (button[nbutton]) delete[] button[nbutton];
180
  if (button[nbutton]) delete[] button[nbutton];
183
  button[nbutton] = bt;
181
  button[nbutton] = bt;
184
  nbutton++;
182
  nbutton++;
185
}
183
}
186
 
184
 
187
void TXButtonArray::Add(int n, int w, int h, char *str, int thick)
185
void TXButtonArray::Add(int n, int w, int h, char *str, int thick)
188
{
186
{
189
  if (thick < 0 && !str) Add(new TXButton(n, w, h));
187
  if (thick < 0 && !str) Add(new TXButton(n, w, h));
190
  else Add(new TextButton(n, w, h, str, thick));
188
  else Add(new TextButton(n, w, h, str, thick));
191
}
189
}
192
 
190
 
193
TXButton *TXButtonArray::GetButton(int n)
191
TXButton *TXButtonArray::GetButton(int n)
194
{
192
{
195
  int i;
193
  int i;
196
  for (i = 0; i < nbutton; i++)
194
  for (i = 0; i < nbutton; i++)
197
  {
195
  {
198
    if (button[i] && button[i]->num == n) return button[i];
196
    if (button[i] && button[i]->num == n) return button[i];
199
  }
197
  }
200
  return 0;
198
  return 0;
201
}
199
}
202
 
200
 
203
int TXButtonArray::GetFWidth() const
201
int TXButtonArray::GetFWidth() const
204
{
202
{
205
  int i, x = 0;
203
  int i, x = 0;
206
  for (i = 0; i < nbutton; i++)
204
  for (i = 0; i < nbutton; i++)
207
  {
205
  {
208
    if (button[i] && button[i]->drw > 0) x += button[i]->w + delt;
206
    if (button[i] && button[i]->drw > 0) x += button[i]->w + delt;
209
  }
207
  }
210
  if (x != 0) x -= delt;
208
  if (x != 0) x -= delt;
211
  return x;
209
  return x;
212
}
210
}
213
 
211
 
214
int TXButtonArray::GetParam(int w, int p) const
212
int TXButtonArray::GetParam(int w, int p) const
215
{
213
{
216
  int i, k = 0;
214
  int i, k = 0;
217
  int x = 0, y = 0, ym = 0;
215
  int x = 0, y = 0, ym = 0;
218
  for (i = 0; i < nbutton; i++) if (button[i] && button[i]->drw > 0)
216
  for (i = 0; i < nbutton; i++) if (button[i] && button[i]->drw > 0)
219
  {
217
  {
220
    int xx = x + button[i]->w + delt;
218
    int xx = x + button[i]->w + delt;
221
    if (x != 0 && xx > w + delt)
219
    if (x != 0 && xx > w + delt)
222
    {
220
    {
223
      k++; y += ym + delt; ym = 0;
221
      k++; y += ym + delt; ym = 0;
224
      x = 0; xx = x + button[i]->w + delt;
222
      x = 0; xx = x + button[i]->w + delt;
225
    }
223
    }
226
    x = xx;
224
    x = xx;
227
    if (ym < button[i]->h) ym = button[i]->h;
225
    if (ym < button[i]->h) ym = button[i]->h;
228
  }
226
  }
229
  if (x != 0) {k++; y += ym;}
227
  if (x != 0) {k++; y += ym;}
230
  else if (y != 0) y -= delt;
228
  else if (y != 0) y -= delt;
231
  if (p == 0) return k;
229
  if (p == 0) return k;
232
  else if (p == 1) return y;
230
  else if (p == 1) return y;
233
  else return -1;
231
  else return -1;
234
}
232
}
235
 
233
 
236
void TXButtonArray::Draw(TGraphDraw *drw, int x0, int y0, int w)
234
void TXButtonArray::Draw(TGraphDraw *drw, int x0, int y0, int w)
237
{
235
{
238
  const unsigned short power_gray = 49152U;
236
  const unsigned short power_gray = 49152U;
239
  unsigned long black = drw->GetBlackColor();
237
  unsigned long black = drw->GetBlackColor();
240
  unsigned long grey = drw->CreateColor(power_gray, power_gray, power_gray);
238
  unsigned long grey = drw->CreateColor(power_gray, power_gray, power_gray);
241
  Draw(drw, x0, y0, w, black, grey, black, 1);
239
  Draw(drw, x0, y0, w, black, grey, black, 1);
242
  drw->FreeColor(grey);
240
  drw->FreeColor(grey);
243
}
241
}
244
 
242
 
245
void TXButtonArray::Draw(TGraphDraw *drw, int x0, int y0, int w,
243
void TXButtonArray::Draw(TGraphDraw *drw, int x0, int y0, int w,
246
        unsigned long dcolor, unsigned long lcolor, unsigned long tcolor, int insd)
244
        unsigned long dcolor, unsigned long lcolor, unsigned long tcolor, int insd)
247
{
245
{
248
  int i;
246
  int i;
249
  int x = 0, y = 0, ym = 0;
247
  int x = 0, y = 0, ym = 0;
250
  if (!insd && ins >= 0) k_ins = 2;
248
  if (!insd && ins >= 0) k_ins = 2;
251
  for (i = 0; i < nbutton; i++) if (button[i] && button[i]->drw > 0)
249
  for (i = 0; i < nbutton; i++) if (button[i] && button[i]->drw > 0)
252
  {
250
  {
253
    int xx = x + button[i]->w + delt;
251
    int xx = x + button[i]->w + delt;
254
    if (x != 0 && xx > w + delt)
252
    if (x != 0 && xx > w + delt)
255
    {
253
    {
256
      y += ym + delt; ym = 0;
254
      y += ym + delt; ym = 0;
257
      x = 0; xx = x + button[i]->w + delt;
255
      x = 0; xx = x + button[i]->w + delt;
258
    }
256
    }
259
    button[i]->Draw(drw, x0 + x, y0 + y,
257
    button[i]->Draw(drw, x0 + x, y0 + y,
260
                    dcolor, lcolor, tcolor, k_ins == 1 && ins == i);
258
                    dcolor, lcolor, tcolor, k_ins == 1 && ins == i);
261
    x = xx;
259
    x = xx;
262
    if (ym < button[i]->h) ym = button[i]->h;
260
    if (ym < button[i]->h) ym = button[i]->h;
263
  }
261
  }
264
}
262
}
265
 
263
 
266
int TXButtonArray::ButtonPnt(int xp, int yp, int w, int &n, int kind)
264
int TXButtonArray::ButtonPnt(int xp, int yp, int w, int &n, int kind)
267
{
265
{
268
  int i;
266
  int i;
269
  int x = 0, y = 0, ym = 0;
267
  int x = 0, y = 0, ym = 0;
270
  if (ins < 0 && (kind == 2 || kind == 3)) return INT_MIN;
268
  if (ins < 0 && (kind == 2 || kind == 3)) return INT_MIN;
271
  for (i = 0; i < nbutton; i++) if (button[i] && button[i]->drw > 0)
269
  for (i = 0; i < nbutton; i++) if (button[i] && button[i]->drw > 0)
272
  {
270
  {
273
    int xx = x + button[i]->w + delt;
271
    int xx = x + button[i]->w + delt;
274
    if (x != 0 && xx > w + delt)
272
    if (x != 0 && xx > w + delt)
275
    {
273
    {
276
      y += ym + delt; ym = 0;
274
      y += ym + delt; ym = 0;
277
      x = 0; xx = x + button[i]->w + delt;
275
      x = 0; xx = x + button[i]->w + delt;
278
    }
276
    }
279
    if (ins < 0 || i == ins)
277
    if (ins < 0 || i == ins)
280
    {
278
    {
281
      int wh = button[i]->ButtonPnt(xp - x, yp - y, n, kind);
279
      int wh = button[i]->ButtonPnt(xp - x, yp - y, n, kind);
282
      if (n == -1) n = i;
280
      if (n == -1) n = i;
283
      if (i == ins)
281
      if (i == ins)
284
      {
282
      {
285
        if (kind == 1) return wh;
283
        if (kind == 1) return wh;
286
        else if (kind == 2)
284
        else if (kind == 2)
287
        {
285
        {
288
          if (wh == INT_MIN || n < 0)
286
          if (wh == INT_MIN || n < 0)
289
          {
287
          {
290
            if (k_ins != 2) {k_ins = 2; n = -10; return 1000;}
288
            if (k_ins != 2) {k_ins = 2; n = -10; return 1000;}
291
          }
289
          }
292
          else if (k_ins != 1) {k_ins = 1; return 1000;}
290
          else if (k_ins != 1) {k_ins = 1; return 1000;}
293
          return wh;
291
          return wh;
294
        }
292
        }
295
        else if (kind == 3)
293
        else if (kind == 3)
296
        {
294
        {
297
          if (wh == INT_MIN)
295
          if (wh == INT_MIN)
298
          {
296
          {
299
            n = -10;
297
            n = -10;
300
            if (k_ins == 1) wh = 1000;
298
            if (k_ins == 1) wh = 1000;
301
          }
299
          }
302
          k_ins = 0; ins = -1;
300
          k_ins = 0; ins = -1;
303
          return wh;
301
          return wh;
304
        }
302
        }
305
        else return wh;
303
        else return wh;
306
      }
304
      }
307
      else if (wh != INT_MIN)
305
      else if (wh != INT_MIN)
308
      {
306
      {
309
        if (kind == 1) {ins = i; k_ins = 1; return wh;}
307
        if (kind == 1) {ins = i; k_ins = 1; return wh;}
310
        else if (kind == 2 || kind == 3) return INT_MIN;
308
        else if (kind == 2 || kind == 3) return INT_MIN;
311
        else return wh;
309
        else return wh;
312
      }
310
      }
313
    }
311
    }
314
    x = xx;
312
    x = xx;
315
    if (ym < button[i]->h) ym = button[i]->h;
313
    if (ym < button[i]->h) ym = button[i]->h;
316
  }
314
  }
317
  n = -10;
315
  n = -10;
318
  return INT_MIN;
316
  return INT_MIN;
319
}
317
}
320
 
318
 
321
struct TMultiButton : public TXButton
319
struct TMultiButton : public TXButton
322
{
320
{
323
  TMultiButton(int n = -1, int w = 100, int h = 20, int d = 2)
321
  TMultiButton(int n = -1, int w = 100, int h = 20, int d = 2)
324
                         : TXButton(n, w, h), a(d) {}
322
                         : TXButton(n, w, h), a(d) {}
325
 
323
 
326
  virtual void Draw(TGraphDraw *drw, int x0, int y0, unsigned long dcolor,
324
  virtual void Draw(TGraphDraw *drw, int x0, int y0, unsigned long dcolor,
327
                    unsigned long lcolor, unsigned long tcolor, int ins = 0);
325
                    unsigned long lcolor, unsigned long tcolor, int ins = 0);
328
  virtual int ButtonPnt(int xp, int yp, int &n, int kind = 0);
326
  virtual int ButtonPnt(int xp, int yp, int &n, int kind = 0);
329
 
327
 
330
  void SetDefW();
328
  void SetDefW();
331
 
329
 
332
  TXButtonArray a;
330
  TXButtonArray a;
333
};
331
};
334
 
332
 
335
void TMultiButton::Draw(TGraphDraw *drw, int x0, int y0, unsigned long dcolor,
333
void TMultiButton::Draw(TGraphDraw *drw, int x0, int y0, unsigned long dcolor,
336
                        unsigned long lcolor, unsigned long tcolor, int ins)
334
                        unsigned long lcolor, unsigned long tcolor, int ins)
337
{
335
{
338
  a.Draw(drw, x0, y0, w, dcolor, lcolor, tcolor, ins);
336
  a.Draw(drw, x0, y0, w, dcolor, lcolor, tcolor, ins);
339
}
337
}
340
 
338
 
341
int TMultiButton::ButtonPnt(int xp, int yp, int &n, int kind)
339
int TMultiButton::ButtonPnt(int xp, int yp, int &n, int kind)
342
{
340
{
343
  if (a.GetInsert() < 0 && (xp < 0 || yp < 0 || xp > w || yp > h)) return INT_MIN;
341
  if (a.GetInsert() < 0 && (xp < 0 || yp < 0 || xp > w || yp > h)) return INT_MIN;
344
  return a.ButtonPnt(xp, yp, w, n, kind);
342
  return a.ButtonPnt(xp, yp, w, n, kind);
345
}
343
}
346
 
344
 
347
void TMultiButton::SetDefW()
345
void TMultiButton::SetDefW()
348
{
346
{
349
  w = a.GetFWidth();
347
  w = a.GetFWidth();
350
  if (w < 0) w = 0;
348
  if (w < 0) w = 0;
351
  h = a.GetHeight(w);
349
  h = a.GetHeight(w);
352
}
350
}
353
 
351
 
354
#endif  //_HEADER_BUTTONS_H
352
#endif  //_HEADER_BUTTONS_H