Style changes courtesy of Vasilis Kaoutsis - thanks!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21507 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-06-26 14:13:05 +00:00
parent d2d8f91af5
commit cba2053487
6 changed files with 331 additions and 346 deletions
+40 -38
View File
@@ -1,5 +1,7 @@
#include "PlayList.h" #include "PlayList.h"
#include <OS.h> #include <OS.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -12,8 +14,10 @@
#define STRACE(x) /* nothing */ #define STRACE(x) /* nothing */
#endif #endif
PlayList::PlayList(int16 count, int16 start) PlayList::PlayList(int16 count, int16 start)
: fTrackCount(count), :
fTrackCount(count),
fTrackIndex(0), fTrackIndex(0),
fStartingTrack(start), fStartingTrack(start),
fRandom(false), fRandom(false),
@@ -25,8 +29,7 @@ PlayList::PlayList(int16 count, int16 start)
if (fTrackCount < 0) if (fTrackCount < 0)
fTrackCount = 0; fTrackCount = 0;
else else if (fTrackCount > 500)
if(fTrackCount > 500)
fTrackCount = 500; fTrackCount = 500;
if (fStartingTrack >= fTrackCount) if (fStartingTrack >= fTrackCount)
@@ -40,6 +43,7 @@ PlayList::PlayList(int16 count, int16 start)
Unrandomize(); Unrandomize();
} }
void void
PlayList::SetTrackCount(const int16 &count) PlayList::SetTrackCount(const int16 &count)
{ {
@@ -47,13 +51,11 @@ PlayList::SetTrackCount(const int16 &count)
STRACE(("PlayList::SetTrackCount(%d)\n",count)); STRACE(("PlayList::SetTrackCount(%d)\n",count));
if(count <= 0) if (count <= 0) {
{
fTrackCount = 0; fTrackCount = 0;
fTrackIndex = 0; fTrackIndex = 0;
} }
else else if (count > 500)
if(count > 500)
fTrackCount = 500; fTrackCount = 500;
else else
fTrackCount = count; fTrackCount = count;
@@ -64,6 +66,7 @@ PlayList::SetTrackCount(const int16 &count)
fLocker.Unlock(); fLocker.Unlock();
} }
void void
PlayList::SetStartingTrack(const int16 &start) PlayList::SetStartingTrack(const int16 &start)
{ {
@@ -76,8 +79,9 @@ PlayList::SetStartingTrack(const int16 &start)
fLocker.Unlock(); fLocker.Unlock();
} }
void void
PlayList::Rewind(void) PlayList::Rewind()
{ {
STRACE(("PlayList::Rewind()\n")); STRACE(("PlayList::Rewind()\n"));
fLocker.Lock(); fLocker.Lock();
@@ -87,6 +91,7 @@ PlayList::Rewind(void)
fLocker.Unlock(); fLocker.Unlock();
} }
void void
PlayList::SetShuffle(const bool &random) PlayList::SetShuffle(const bool &random)
{ {
@@ -103,6 +108,7 @@ PlayList::SetShuffle(const bool &random)
fLocker.Unlock(); fLocker.Unlock();
} }
void void
PlayList::SetLoop(const bool &loop) PlayList::SetLoop(const bool &loop)
{ {
@@ -114,6 +120,7 @@ PlayList::SetLoop(const bool &loop)
fLocker.Unlock(); fLocker.Unlock();
} }
void void
PlayList::SetCurrentTrack(const int16 &track) PlayList::SetCurrentTrack(const int16 &track)
{ {
@@ -124,10 +131,8 @@ PlayList::SetCurrentTrack(const int16 &track)
fLocker.Lock(); fLocker.Lock();
for(int16 i=0; i<fTrackCount; i++) for (int16 i = 0; i < fTrackCount; i++) {
{ if (fTrackList[i] == track) {
if(fTrackList[i] == track)
{
fTrackIndex = i; fTrackIndex = i;
break; break;
} }
@@ -136,8 +141,9 @@ PlayList::SetCurrentTrack(const int16 &track)
fLocker.Unlock(); fLocker.Unlock();
} }
int16 int16
PlayList::GetCurrentTrack(void) PlayList::GetCurrentTrack()
{ {
fLocker.Lock(); fLocker.Lock();
@@ -148,24 +154,22 @@ PlayList::GetCurrentTrack(void)
return value; return value;
} }
int16 int16
PlayList::GetNextTrack(void) PlayList::GetNextTrack()
{ {
fLocker.Lock(); fLocker.Lock();
if(fTrackCount < 1) if (fTrackCount < 1) {
{
fLocker.Unlock(); fLocker.Unlock();
STRACE(("PlayList::GetNextTrack()=-1 (no tracks)\n")); STRACE(("PlayList::GetNextTrack()=-1 (no tracks)\n"));
return -1; return -1;
} }
if(fTrackIndex > (fTrackCount - fStartingTrack)) if (fTrackIndex > (fTrackCount - fStartingTrack)) {
{
if (fLoop) if (fLoop)
fTrackIndex = 0; fTrackIndex = 0;
else else {
{
fLocker.Unlock(); fLocker.Unlock();
STRACE(("PlayList::GetNextTrack()=-1 (track index out of range)\n")); STRACE(("PlayList::GetNextTrack()=-1 (track index out of range)\n"));
return -1; return -1;
@@ -181,24 +185,22 @@ PlayList::GetNextTrack(void)
return value; return value;
} }
int16 int16
PlayList::GetPreviousTrack(void) PlayList::GetPreviousTrack()
{ {
fLocker.Lock(); fLocker.Lock();
if(fTrackCount < 1) if (fTrackCount < 1) {
{
fLocker.Unlock(); fLocker.Unlock();
STRACE(("PlayList::GetPreviousTrack()=-1 (no tracks)\n")); STRACE(("PlayList::GetPreviousTrack()=-1 (no tracks)\n"));
return -1; return -1;
} }
if(fTrackIndex == 0) if (fTrackIndex == 0) {
{
if (fLoop) if (fLoop)
fTrackIndex = (fTrackCount - fStartingTrack); fTrackIndex = (fTrackCount - fStartingTrack);
else else {
{
fLocker.Unlock(); fLocker.Unlock();
STRACE(("PlayList::GetPreviousTrack()=-1 (track index out of range)\n")); STRACE(("PlayList::GetPreviousTrack()=-1 (track index out of range)\n"));
return -1; return -1;
@@ -213,13 +215,13 @@ PlayList::GetPreviousTrack(void)
return value; return value;
} }
int16 int16
PlayList::GetLastTrack(void) PlayList::GetLastTrack()
{ {
fLocker.Lock(); fLocker.Lock();
if(fTrackCount < 1) if (fTrackCount < 1) {
{
fLocker.Unlock(); fLocker.Unlock();
STRACE(("PlayList::GetLastTrack()=-1 (no tracks)\n")); STRACE(("PlayList::GetLastTrack()=-1 (no tracks)\n"));
return -1; return -1;
@@ -232,13 +234,13 @@ PlayList::GetLastTrack(void)
return value; return value;
} }
int16 int16
PlayList::GetFirstTrack(void) PlayList::GetFirstTrack()
{ {
fLocker.Lock(); fLocker.Lock();
if(fTrackCount < 1) if (fTrackCount < 1) {
{
fLocker.Unlock(); fLocker.Unlock();
STRACE(("PlayList::GetFirstTrack()=-1 (no tracks)\n")); STRACE(("PlayList::GetFirstTrack()=-1 (no tracks)\n"));
return -1; return -1;
@@ -251,8 +253,9 @@ PlayList::GetFirstTrack(void)
return value; return value;
} }
void void
PlayList::Randomize(void) PlayList::Randomize()
{ {
STRACE(("PlayList::Randomize()\n")); STRACE(("PlayList::Randomize()\n"));
@@ -267,8 +270,7 @@ PlayList::Randomize(void)
int32 swapcount = listcount * 2; int32 swapcount = listcount * 2;
int16 temp, first, second; int16 temp, first, second;
for(int32 i=0; i< swapcount; i++) for (int32 i = 0; i < swapcount; i++) {
{
// repeatedly pick two elements at random and swap them // repeatedly pick two elements at random and swap them
// This way we are sure to not have any duplicates and still have // This way we are sure to not have any duplicates and still have
// all tracks eventually be played. // all tracks eventually be played.
@@ -287,11 +289,11 @@ PlayList::Randomize(void)
#endif #endif
} }
void void
PlayList::Unrandomize(void) PlayList::Unrandomize()
{ {
STRACE(("PlayList::Unrandomize()\n")); STRACE(("PlayList::Unrandomize()\n"));
for (int16 i = fStartingTrack; i <= fTrackCount; i++) for (int16 i = fStartingTrack; i <= fTrackCount; i++)
fTrackList[i - fStartingTrack] = i; fTrackList[i - fStartingTrack] = i;
} }
+15 -16
View File
@@ -1,40 +1,39 @@
#ifndef PLAYLIST_H #ifndef PLAYLIST_H
#define PLAYLIST_H #define PLAYLIST_H
#include <SupportDefs.h>
#include <Locker.h> #include <Locker.h>
#include <SupportDefs.h>
class PlayList class PlayList {
{
public: public:
PlayList(int16 tracks = 0, int16 startingtrack = 1); PlayList(int16 tracks = 0, int16 startingtrack = 1);
void SetTrackCount(const int16 &count); void SetTrackCount(const int16 &count);
int16 TrackCount(void) const { return fTrackCount; } int16 TrackCount() const { return fTrackCount; }
void SetStartingTrack(const int16 &start); void SetStartingTrack(const int16 &start);
int16 StartingTrack(void) const { return fStartingTrack; } int16 StartingTrack() const { return fStartingTrack; }
void Rewind(void); void Rewind();
void SetShuffle(const bool &random); void SetShuffle(const bool &random);
bool IsShuffled(void) const { return fRandom; } bool IsShuffled() const { return fRandom; }
void SetLoop(const bool &loop); void SetLoop(const bool &loop);
bool IsLoop(void) const { return fLoop; } bool IsLoop() const { return fLoop; }
void SetCurrentTrack(const int16 &track); void SetCurrentTrack(const int16 &track);
int16 GetCurrentTrack(void); int16 GetCurrentTrack();
int16 GetNextTrack(void); int16 GetNextTrack();
int16 GetPreviousTrack(void); int16 GetPreviousTrack();
int16 GetFirstTrack(void); int16 GetFirstTrack();
int16 GetLastTrack(void); int16 GetLastTrack();
private: private:
void Randomize(void); void Randomize();
void Unrandomize(void); void Unrandomize();
int16 fTrackCount; int16 fTrackCount;
int16 fTrackIndex; int16 fTrackIndex;
@@ -47,4 +46,4 @@ private:
BLocker fLocker; BLocker fLocker;
}; };
#endif #endif // PLAYLIST_H
+37 -48
View File
@@ -1,15 +1,17 @@
#include "TrackMenu.h"
#include <Font.h>
#include <Message.h> #include <Message.h>
#include <Region.h> #include <Region.h>
#include <Window.h>
#include <String.h> #include <String.h>
#include <Font.h> #include <Window.h>
#include "TrackMenu.h"
#include <stdio.h> #include <stdio.h>
TrackMenu::TrackMenu(const BRect &frame, const char *name, BMessage *msg, TrackMenu::TrackMenu(const BRect &frame, const char *name, BMessage *msg,
const int32 &resize, const int32 &flags) const int32 &resize, const int32 &flags)
: BView(frame,name,resize,flags), : BView(frame, name, resize, flags), BInvoker(msg, NULL),
BInvoker(msg,NULL),
fCurrentItem(-1), fCurrentItem(-1),
fCount(0), fCount(0),
fIsTracking(false) fIsTracking(false)
@@ -29,12 +31,14 @@ TrackMenu::TrackMenu(const BRect &frame, const char *name, BMessage *msg,
fFontHeight = fh.ascent + fh.descent + fh.leading; fFontHeight = fh.ascent + fh.descent + fh.leading;
} }
TrackMenu::~TrackMenu(void)
TrackMenu::~TrackMenu()
{ {
} }
void void
TrackMenu::AttachedToWindow(void) TrackMenu::AttachedToWindow()
{ {
if (!Messenger().IsValid()) if (!Messenger().IsValid())
SetTarget(Window()); SetTarget(Window());
@@ -42,24 +46,22 @@ TrackMenu::AttachedToWindow(void)
BView::AttachedToWindow(); BView::AttachedToWindow();
} }
void void
TrackMenu::MessageReceived(BMessage *msg) TrackMenu::MessageReceived(BMessage *msg)
{ {
switch(msg->what) switch (msg->what) {
{
default: default:
{
BView::MessageReceived(msg); BView::MessageReceived(msg);
break; break;
} }
} }
}
void void
TrackMenu::SetItemCount(const int32 &count) TrackMenu::SetItemCount(const int32 &count)
{ {
if(count < 0) if (count < 0) {
{
fCount = 0; fCount = 0;
fCurrentItem = -1; fCurrentItem = -1;
Invalidate(); Invalidate();
@@ -70,33 +72,32 @@ TrackMenu::SetItemCount(const int32 &count)
if (fCurrentItem > fCount - 1) if (fCurrentItem > fCount - 1)
fCurrentItem = fCount - 1; fCurrentItem = fCount - 1;
else else if(fCurrentItem < 0)
if(fCurrentItem < 0)
fCurrentItem = 0; fCurrentItem = 0;
Invalidate(); Invalidate();
} }
void void
TrackMenu::SetValue(const int32 &value) TrackMenu::SetValue(const int32 &value)
{ {
if (value < 0 || value > fCount) if (value < 0 || value > fCount)
return; return;
if(value != Value()) if (value != Value()) {
{
fCurrentItem = value; fCurrentItem = value;
Invalidate(); Invalidate();
} }
} }
int32 int32
TrackMenu::ItemAt(const BPoint &pt) TrackMenu::ItemAt(const BPoint &pt)
{ {
// TODO: Optimize. This is simple, but costly in performance // TODO: Optimize. This is simple, but costly in performance
BRect r(fItemRect); BRect r(fItemRect);
for(int32 i=0; i<fCount; i++) for (int32 i = 0; i < fCount; i++) {
{
if (r.Contains(pt)) if (r.Contains(pt))
return i; return i;
r.OffsetBy(r.Width()+1,0); r.OffsetBy(r.Width()+1,0);
@@ -105,6 +106,7 @@ TrackMenu::ItemAt(const BPoint &pt)
return -1; return -1;
} }
void void
TrackMenu::MouseDown(BPoint point) TrackMenu::MouseDown(BPoint point)
{ {
@@ -112,23 +114,19 @@ TrackMenu::MouseDown(BPoint point)
int32 saveditem = fCurrentItem; int32 saveditem = fCurrentItem;
int32 item = ItemAt(pt); int32 item = ItemAt(pt);
if(item >= 0) if (item >= 0) {
{
fCurrentItem = item; fCurrentItem = item;
Invalidate(); Invalidate();
// Shamelessly stolen from BButton. :D // Shamelessly stolen from BButton. :D
if (Window()->Flags() & B_ASYNCHRONOUS_CONTROLS) if (Window()->Flags() & B_ASYNCHRONOUS_CONTROLS) {
{
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
fIsTracking = true; fIsTracking = true;
} else } else {
{
uint32 buttons; uint32 buttons;
do do {
{
Window()->UpdateIfNeeded(); Window()->UpdateIfNeeded();
snooze(40000); snooze(40000);
@@ -136,8 +134,7 @@ TrackMenu::MouseDown(BPoint point)
GetMouse(&pt, &buttons, true); GetMouse(&pt, &buttons, true);
int32 mouseitem = ItemAt(pt); int32 mouseitem = ItemAt(pt);
if(mouseitem > -1) if (mouseitem > -1) {
{
fCurrentItem = mouseitem; fCurrentItem = mouseitem;
Draw(Bounds()); Draw(Bounds());
} }
@@ -150,6 +147,7 @@ TrackMenu::MouseDown(BPoint point)
} }
} }
void void
TrackMenu::MouseUp(BPoint pt) TrackMenu::MouseUp(BPoint pt)
{ {
@@ -164,6 +162,7 @@ TrackMenu::MouseUp(BPoint pt)
fIsTracking = false; fIsTracking = false;
} }
void void
TrackMenu::MouseMoved(BPoint pt, uint32 transit, const BMessage *msg) TrackMenu::MouseMoved(BPoint pt, uint32 transit, const BMessage *msg)
{ {
@@ -172,13 +171,13 @@ TrackMenu::MouseMoved(BPoint pt, uint32 transit, const BMessage *msg)
int32 item = ItemAt(pt); int32 item = ItemAt(pt);
if(item >= 0) if (item >= 0) {
{
fCurrentItem = item; fCurrentItem = item;
Invalidate(); Invalidate();
} }
} }
void void
TrackMenu::Draw(BRect update) TrackMenu::Draw(BRect update)
{ {
@@ -206,8 +205,7 @@ TrackMenu::Draw(BRect update)
// Draw the items // Draw the items
BRect r(fItemRect); BRect r(fItemRect);
for(int32 i=0; i<fCount; i++) for (int32 i = 0; i < fCount; i++) {
{
// Draw the item's frame // Draw the item's frame
if (i == fCurrentItem) if (i == fCurrentItem)
SetHighColor(dark); SetHighColor(dark);
@@ -221,8 +219,7 @@ TrackMenu::Draw(BRect update)
pt2.Set(r.left, r.bottom); pt2.Set(r.left, r.bottom);
StrokeLine(pt1, pt2); StrokeLine(pt1, pt2);
if(i == fCurrentItem) if (i == fCurrentItem) {
{
SetHighColor(light); SetHighColor(light);
pt1.Set(r.right, r.bottom); pt1.Set(r.right, r.bottom);
pt2.Set(r.right, r.top + 1); pt2.Set(r.right, r.top + 1);
@@ -235,9 +232,7 @@ TrackMenu::Draw(BRect update)
FillRect(r.InsetByCopy(1, 1)); FillRect(r.InsetByCopy(1, 1));
SetHighColor(dark); SetHighColor(dark);
} }
else else if (i == fCount - 1) {
if(i == fCount - 1)
{
SetHighColor(light); SetHighColor(light);
pt1.Set(r.right, r.bottom); pt1.Set(r.right, r.bottom);
pt2.Set(r.right, r.top + 1); pt2.Set(r.right, r.top + 1);
@@ -253,30 +248,24 @@ TrackMenu::Draw(BRect update)
labelpt.x = r.left + (r.Width() - StringWidth(label.String())) / 2 + 2; labelpt.x = r.left + (r.Width() - StringWidth(label.String())) / 2 + 2;
labelpt.y = r.bottom - (r.Height() - fFontHeight + 4) / 2; labelpt.y = r.bottom - (r.Height() - fFontHeight + 4) / 2;
if(i == fCurrentItem) if (i == fCurrentItem) {
{
SetHighColor(dark); SetHighColor(dark);
SetLowColor(light); SetLowColor(light);
} } else {
else
{
SetHighColor(light); SetHighColor(light);
SetLowColor(dark); SetLowColor(dark);
} }
DrawString(label.String(), labelpt); DrawString(label.String(), labelpt);
// Setup for next iteration // Setup for next iteration
r.OffsetBy(r.Width() + 1, 0); r.OffsetBy(r.Width() + 1, 0);
if(r.left > Bounds().right - 2) if (r.left > Bounds().right - 2) {
{
ConstrainClippingRegion(NULL); ConstrainClippingRegion(NULL);
break; break;
} }
if(r.right > Bounds().right - 2) if (r.right > Bounds().right - 2) {
{
r.right = Bounds().right - 2; r.right = Bounds().right - 2;
BRegion reg(r); BRegion reg(r);
ConstrainClippingRegion(&reg); ConstrainClippingRegion(&reg);
+7 -8
View File
@@ -1,28 +1,27 @@
#ifndef TRACKMENU_H #ifndef TRACKMENU_H
#define TRACKMENU_H #define TRACKMENU_H
#include <View.h>
#include <Invoker.h> #include <Invoker.h>
#include <View.h>
class TrackMenu : public BView, public BInvoker class TrackMenu : public BView, public BInvoker {
{
public: public:
TrackMenu(const BRect &frame, const char *name, BMessage *msg, TrackMenu(const BRect &frame, const char *name, BMessage *msg,
const int32 &resize = B_FOLLOW_LEFT | B_FOLLOW_TOP, const int32 &resize = B_FOLLOW_LEFT | B_FOLLOW_TOP,
const int32 &flags = B_WILL_DRAW); const int32 &flags = B_WILL_DRAW);
~TrackMenu(void); ~TrackMenu();
void AttachedToWindow(void); void AttachedToWindow();
void MessageReceived(BMessage *msg); void MessageReceived(BMessage *msg);
void Draw(BRect update); void Draw(BRect update);
void MouseDown(BPoint pt); void MouseDown(BPoint pt);
void MouseUp(BPoint pt); void MouseUp(BPoint pt);
void MouseMoved(BPoint pt, uint32 transit, const BMessage *msg); void MouseMoved(BPoint pt, uint32 transit, const BMessage *msg);
int32 CountItems(void) const { return fCount; } int32 CountItems() const { return fCount; }
void SetItemCount(const int32 &count); void SetItemCount(const int32 &count);
int32 Value(void) const { return fCurrentItem; } int32 Value() const { return fCurrentItem; }
void SetValue(const int32 &value); void SetValue(const int32 &value);
private: private:
@@ -37,4 +36,4 @@ private:
float fFontHeight; float fFontHeight;
}; };
#endif #endif // TRACKMENU_H
+12 -16
View File
@@ -3,13 +3,15 @@
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Author: * Author:
* DarkWyrm <[email protected]> * DarkWyrm, [email protected]
*/ */
#include "TwoStateDrawButton.h" #include "TwoStateDrawButton.h"
TwoStateDrawButton::TwoStateDrawButton(BRect frame, const char *name, BBitmap *upone, TwoStateDrawButton::TwoStateDrawButton(BRect frame, const char *name, BBitmap *upone,
BBitmap *downone, BBitmap *uptwo, BBitmap *downone, BBitmap *uptwo, BBitmap *downtwo, BMessage *msg,
BBitmap *downtwo, BMessage *msg,
const int32 &resize, const int32 &flags) const int32 &resize, const int32 &flags)
: BButton(frame, name, "", msg, resize, flags), : BButton(frame, name, "", msg, resize, flags),
fUpOne(upone), fUpOne(upone),
@@ -25,7 +27,7 @@ TwoStateDrawButton::TwoStateDrawButton(BRect frame, const char *name, BBitmap *u
} }
TwoStateDrawButton::~TwoStateDrawButton(void) TwoStateDrawButton::~TwoStateDrawButton()
{ {
delete fUpOne; delete fUpOne;
delete fDownOne; delete fDownOne;
@@ -37,24 +39,19 @@ TwoStateDrawButton::~TwoStateDrawButton(void)
void void
TwoStateDrawButton::ResizeToPreferred(void) TwoStateDrawButton::ResizeToPreferred()
{ {
if (fUpOne) if (fUpOne)
ResizeTo(fUpOne->Bounds().Width(), fUpOne->Bounds().Height()); ResizeTo(fUpOne->Bounds().Width(), fUpOne->Bounds().Height());
else else if (fDownOne)
if(fDownOne)
ResizeTo(fDownOne->Bounds().Width(), fDownOne->Bounds().Height()); ResizeTo(fDownOne->Bounds().Width(), fDownOne->Bounds().Height());
else else if (fUpTwo)
if(fUpTwo)
ResizeTo(fUpTwo->Bounds().Width(),fUpTwo->Bounds().Height()); ResizeTo(fUpTwo->Bounds().Width(),fUpTwo->Bounds().Height());
else else if (fDownTwo)
if(fDownTwo)
ResizeTo(fDownTwo->Bounds().Width(), fDownTwo->Bounds().Height()); ResizeTo(fDownTwo->Bounds().Width(), fDownTwo->Bounds().Height());
else else if (fDisabledOne)
if(fDisabledOne)
ResizeTo(fDisabledOne->Bounds().Width(), fDisabledOne->Bounds().Height()); ResizeTo(fDisabledOne->Bounds().Width(), fDisabledOne->Bounds().Height());
else else if(fDisabledTwo)
if(fDisabledTwo)
ResizeTo(fDisabledTwo->Bounds().Width(), fDisabledTwo->Bounds().Height()); ResizeTo(fDisabledTwo->Bounds().Width(), fDisabledTwo->Bounds().Height());
} }
@@ -167,4 +164,3 @@ TwoStateDrawButton::Draw(BRect update)
} }
} }
} }
+12 -12
View File
@@ -8,35 +8,35 @@
#ifndef _TWOSTATE_DRAWBUTTON_H #ifndef _TWOSTATE_DRAWBUTTON_H
#define _TWOSTATE_DRAWBUTTON_H #define _TWOSTATE_DRAWBUTTON_H
#include <Window.h>
#include <View.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <Button.h> #include <Button.h>
#include <View.h>
#include <Window.h>
class TwoStateDrawButton : public BButton class TwoStateDrawButton : public BButton {
{
public: public:
TwoStateDrawButton(BRect frame, const char *name, BBitmap *upone, TwoStateDrawButton(BRect frame, const char *name, BBitmap *upone,
BBitmap *downone, BBitmap *uptwo, BBitmap *downtwo, BBitmap *downone, BBitmap *uptwo, BBitmap *downtwo,
BMessage *msg, const int32 &resize, BMessage *msg, const int32 &resize, const int32 &flags);
const int32 &flags);
~TwoStateDrawButton(void); ~TwoStateDrawButton();
void Draw(BRect update); void Draw(BRect update);
void SetBitmaps(BBitmap *upone, BBitmap *downone, BBitmap *uptwo, void SetBitmaps(BBitmap *upone, BBitmap *downone, BBitmap *uptwo,
BBitmap *downtwo); BBitmap *downtwo);
void SetBitmaps(const int32 state, BBitmap *up, BBitmap *down); void SetBitmaps(const int32 state, BBitmap *up, BBitmap *down);
void ResizeToPreferred(void); void ResizeToPreferred();
void SetDisabled(BBitmap *disabledone, BBitmap *disabledtwo); void SetDisabled(BBitmap *disabledone, BBitmap *disabledtwo);
void MouseUp(BPoint pt); void MouseUp(BPoint pt);
int32 GetState(void) { return fButtonState ? 1 : 0; }; int32 GetState() { return fButtonState ? 1 : 0; };
void SetState(int32 value); void SetState(int32 value);
private: private:
BBitmap *fUpOne, BBitmap *fUpOne,
*fDownOne, *fDownOne,
*fUpTwo, *fUpTwo,
@@ -44,8 +44,8 @@ private:
*fDisabledOne, *fDisabledOne,
*fDisabledTwo; *fDisabledTwo;
// true if in state two
bool fButtonState; bool fButtonState;
// true if in state two
}; };
#endif #endif // _TWOSTATE_DRAWBUTTON_H