Corretto errore update bottoni post-mortem

git-svn-id: svn://10.65.10.50/trunk@1228 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-04-11 08:28:52 +00:00
parent 7179711a44
commit 9285b6486e

View File

@ -23,9 +23,9 @@ extern "C"
class TPicture_array : public TArray class TPicture_array : public TArray
{ {
public: public:
TImage* add(short id, bool convert = FALSE); TImage& add(short id, bool convert = FALSE);
TImage& image(short id) { return (TImage&)operator[](id); } //TImage& image(short id) { return (TImage&)operator[](id); }
const TImage& image(short id) const { return (const TImage&)operator[](id); } const TImage& image(short id) const { return (const TImage&)operator[](id); }
bool exist(short id) const { return objptr(id) != NULL; } bool exist(short id) const { return objptr(id) != NULL; }
@ -33,7 +33,7 @@ public:
~TPicture_array() {} ~TPicture_array() {}
}; };
TImage* TPicture_array::add(short id, bool convert) TImage& TPicture_array::add(short id, bool convert)
{ {
TImage* i = (TImage*)objptr(id); TImage* i = (TImage*)objptr(id);
@ -45,7 +45,7 @@ TImage* TPicture_array::add(short id, bool convert)
i->convert_to_default_colors(); i->convert_to_default_colors();
} }
return i; return *i;
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -493,7 +493,7 @@ void TButton::check(bool on)
class TPush_button : public TButton class TPush_button : public TButton
{ {
TImage *_picup, *_picdn; short _picup, _picdn;
short _accel, _dx, _dy; short _accel, _dx, _dy;
protected: protected:
@ -512,7 +512,7 @@ TPush_button::TPush_button(short left, short top, short right, short bottom,
long flags, long app_data, short id) long flags, long app_data, short id)
: TButton(left-(id == DLG_F9), top, right, bottom, : TButton(left-(id == DLG_F9), top, right, bottom,
capt, parent, flags, app_data, id), capt, parent, flags, app_data, id),
_picup(NULL), _picdn(NULL) _picup(0), _picdn(0)
{ {
switch(id) switch(id)
{ {
@ -589,23 +589,17 @@ TPush_button::TPush_button(short left, short top, short right, short bottom,
const char* diesis = strchr(capt, '#'); const char* diesis = strchr(capt, '#');
if (diesis != NULL) if (diesis != NULL)
{ {
int pid = atoi(++diesis); _picup = atoi(++diesis);
_picup = cpb.add(pid); const TImage& pic = cpb.add(_picup);
diesis = strchr(diesis, '#'); diesis = strchr(diesis, '#');
if (diesis != NULL) if (diesis != NULL)
{ {
pid = atoi(++diesis); _picdn = atoi(++diesis);
_picdn = cpb.add(pid); cpb.add(_picdn);
} }
_dx = (width - _picup->width()) >> 1; _dx = (width - pic.width()) >> 1;
_dy = (height - _picup->height()) >> 1; _dy = (height - pic.height()) >> 1;
/*
_picup->set_pos(_dx, _dy);
if (_picdn)
_picdn->set_pos(_dx+DEPTH, _dy+DEPTH);
*/
_accel = -1; _accel = -1;
} }
@ -631,13 +625,17 @@ void TPush_button::draw_pressed(bool pressed) const
if (_picup) if (_picup)
{ {
const TImage* i = (pressed && _picdn) ? _picdn : _picup; const short pic = (pressed && _picdn) ? _picdn : _picup;
RCT dst = i->rect(); if (cpb.exist(pic))
if (pressed) {
xvt_rect_offset(&dst, _dx+DEPTH, _dy+DEPTH); const TImage& i = cpb.image(pic);
else RCT dst = i.rect();
xvt_rect_offset(&dst, _dx, _dy); if (pressed)
i->draw(_hdc, dst); xvt_rect_offset(&dst, _dx+DEPTH, _dy+DEPTH);
else
xvt_rect_offset(&dst, _dx, _dy);
i.draw(_hdc, dst);
}
} }
else else
{ {
@ -886,15 +884,15 @@ TCheckbox::TCheckbox(
{ {
if (!cpb.exist(BMP_CHECK_ON)) if (!cpb.exist(BMP_CHECK_ON))
{ {
TImage* i = cpb.add(BMP_CHECK_ON, TRUE); TImage& i = cpb.add(BMP_CHECK_ON, TRUE);
const short dx = 0; const short dx = 0;
const short dy = BASEY - i->height() + 2; const short dy = BASEY - i.height() + 2;
i->set_pos(dx, dy); i.set_pos(dx, dy);
i = cpb.add(BMP_CHECK_OFF, TRUE); i->set_pos(dx, dy); cpb.add(BMP_CHECK_OFF, TRUE).set_pos(dx, dy);
i = cpb.add(BMP_RADIO_ON, TRUE); i->set_pos(dx, dy); cpb.add(BMP_RADIO_ON, TRUE).set_pos(dx, dy);
i = cpb.add(BMP_RADIO_OFF, TRUE); i->set_pos(dx, dy); cpb.add(BMP_RADIO_OFF, TRUE).set_pos(dx, dy);
} }
} }