2 * Copyright 2005, Jérôme Duval. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Reworked from DarkWyrm version in CDPlayer
8 #include "DrawButton.h"
9 #include "DrawingTidbits.h"
11 DrawButton::DrawButton(BRect frame
, const char *name
, const unsigned char *on
,
12 const unsigned char *off
, BMessage
*msg
, int32 resize
, int32 flags
)
13 : BControl(frame
, name
, "", msg
, resize
, flags
| B_WILL_DRAW
),
18 fOff
.SetBits(off
, (frame
.Width() + 1) * (frame
.Height() + 1), 0, B_CMAP8
);
19 fOn
.SetBits(on
, (frame
.Width() + 1) * (frame
.Height() + 1), 0, B_CMAP8
);
23 DrawButton::~DrawButton(void)
29 DrawButton::AttachedToWindow()
31 SetViewColor(B_TRANSPARENT_COLOR
);
32 ReplaceTransparentColor(&fOn
, Parent()->ViewColor());
33 ReplaceTransparentColor(&fOff
, Parent()->ViewColor());
38 DrawButton::MouseUp(BPoint pt
)
40 fButtonState
= fButtonState
? false : true;
47 DrawButton::Draw(BRect update
)
50 DrawBitmap(&fOn
, BPoint(0,0));
52 DrawBitmap(&fOff
, BPoint(0,0));