1a8c4b88dSAxel Dörfler/*
2b2f1b918SStefano Ceccherini * Copyright 2001-2010, Haiku, Inc.
3a8c4b88dSAxel Dörfler * Distributed under the terms of the MIT license.
4a8c4b88dSAxel Dörfler *
5a8c4b88dSAxel Dörfler * Authors:
6a8c4b88dSAxel Dörfler *		Graham MacDonald (macdonag@btopenworld.com)
7a8c4b88dSAxel Dörfler */
8ac52c378Sejakowatz
9c109d7e0SJohn Scipione
10a8c4b88dSAxel Dörfler#include <PictureButton.h>
11ac52c378Sejakowatz
1216835369SKarsten Heimrich#include <new>
13ac52c378Sejakowatz
148cc8b1b7SStephan Aßmus#include <binary_compatibility/Interface.h>
158cc8b1b7SStephan Aßmus
1616835369SKarsten Heimrich
1716835369SKarsten HeimrichBPictureButton::BPictureButton(BRect frame, const char* name,
18c109d7e0SJohn Scipione	BPicture* off, BPicture* on, BMessage* message,
19c109d7e0SJohn Scipione	uint32 behavior, uint32 resizingMode, uint32 flags)
208cc8b1b7SStephan Aßmus	:
21c109d7e0SJohn Scipione	BControl(frame, name, "", message, resizingMode, flags),
228cc8b1b7SStephan Aßmus	fEnabledOff(new(std::nothrow) BPicture(*off)),
238cc8b1b7SStephan Aßmus	fEnabledOn(new(std::nothrow) BPicture(*on)),
248cc8b1b7SStephan Aßmus	fDisabledOff(NULL),
258cc8b1b7SStephan Aßmus	fDisabledOn(NULL),
268cc8b1b7SStephan Aßmus	fBehavior(behavior)
27ac52c378Sejakowatz{
28ac52c378Sejakowatz}
29ac52c378Sejakowatz
30ac52c378Sejakowatz
3116835369SKarsten HeimrichBPictureButton::BPictureButton(BMessage* data)
328cc8b1b7SStephan Aßmus	:
338cc8b1b7SStephan Aßmus	BControl(data),
3407c052f7SAlexandre Deckner	fEnabledOff(NULL),
3507c052f7SAlexandre Deckner	fEnabledOn(NULL),
3607c052f7SAlexandre Deckner	fDisabledOff(NULL),
3707c052f7SAlexandre Deckner	fDisabledOn(NULL)
38ac52c378Sejakowatz{
39ac52c378Sejakowatz	BMessage pictureArchive;
40a8c4b88dSAxel Dörfler
41ac52c378Sejakowatz	// Default to 1 state button if not here - is this valid?
42c109d7e0SJohn Scipione	if (data->FindInt32("_behave", (int32*)&fBehavior) != B_OK)
43ac52c378Sejakowatz		fBehavior = B_ONE_STATE_BUTTON;
44a8c4b88dSAxel Dörfler
45ac52c378Sejakowatz	// Now expand the pictures:
46ac52c378Sejakowatz	if (data->FindMessage("_e_on", &pictureArchive) == B_OK)
478cc8b1b7SStephan Aßmus		fEnabledOn = new(std::nothrow) BPicture(&pictureArchive);
48a8c4b88dSAxel Dörfler
49ac52c378Sejakowatz	if (data->FindMessage("_e_off", &pictureArchive) == B_OK)
508cc8b1b7SStephan Aßmus		fEnabledOff = new(std::nothrow) BPicture(&pictureArchive);
51ac52c378Sejakowatz
5207c052f7SAlexandre Deckner	if (data->FindMessage("_d_on", &pictureArchive) == B_OK)
538cc8b1b7SStephan Aßmus		fDisabledOn = new(std::nothrow) BPicture(&pictureArchive);
54a8c4b88dSAxel Dörfler
5507c052f7SAlexandre Deckner	if (data->FindMessage("_d_off", &pictureArchive) == B_OK)
568cc8b1b7SStephan Aßmus		fDisabledOff = new(std::nothrow) BPicture(&pictureArchive);
57ac52c378Sejakowatz}
58ac52c378Sejakowatz
59ac52c378Sejakowatz
60ac52c378SejakowatzBPictureButton::~BPictureButton()
61ac52c378Sejakowatz{
62ac52c378Sejakowatz	delete fEnabledOn;
63ac52c378Sejakowatz	delete fEnabledOff;
64a8c4b88dSAxel Dörfler	delete fDisabledOn;
65a8c4b88dSAxel Dörfler	delete fDisabledOff;
66ac52c378Sejakowatz}
67ac52c378Sejakowatz
68ac52c378Sejakowatz
6916835369SKarsten HeimrichBArchivable*
7016835369SKarsten HeimrichBPictureButton::Instantiate(BMessage* data)
71ac52c378Sejakowatz{
722be66b51SStefano Ceccherini	if (validate_instantiation(data, "BPictureButton"))
7316835369SKarsten Heimrich		return new (std::nothrow) BPictureButton(data);
74a8c4b88dSAxel Dörfler
75a8c4b88dSAxel Dörfler	return NULL;
76ac52c378Sejakowatz}
77ac52c378Sejakowatz
78ac52c378Sejakowatz
79ac52c378Sejakowatzstatus_t
8016835369SKarsten HeimrichBPictureButton::Archive(BMessage* data, bool deep) const
81ac52c378Sejakowatz{
82ac52c378Sejakowatz	status_t err = BControl::Archive(data, deep);
83a8c4b88dSAxel Dörfler	if (err != B_OK)
84a8c4b88dSAxel Dörfler		return err;
85ac52c378Sejakowatz
86ac52c378Sejakowatz	// Fill out message, depending on whether a deep copy is required or not.
87a8c4b88dSAxel Dörfler	if (deep) {
88ac52c378Sejakowatz		BMessage pictureArchive;
89a8c4b88dSAxel Dörfler		if (fEnabledOn->Archive(&pictureArchive, deep) == B_OK) {
90ac52c378Sejakowatz			err = data->AddMessage("_e_on", &pictureArchive);
91a8c4b88dSAxel Dörfler			if (err != B_OK)
92a8c4b88dSAxel Dörfler				return err;
93ac52c378Sejakowatz		}
94ac52c378Sejakowatz
95b2f1b918SStefano Ceccherini		pictureArchive.MakeEmpty();
96a8c4b88dSAxel Dörfler		if (fEnabledOff->Archive(&pictureArchive, deep) == B_OK) {
97ac52c378Sejakowatz			err = data->AddMessage("_e_off", &pictureArchive);
98a8c4b88dSAxel Dörfler			if (err != B_OK)
99a8c4b88dSAxel Dörfler				return err;
100ac52c378Sejakowatz		}
101ac52c378Sejakowatz
102b2f1b918SStefano Ceccherini		pictureArchive.MakeEmpty();
10307c052f7SAlexandre Deckner		if (fDisabledOn && fDisabledOn->Archive(&pictureArchive, deep) == B_OK) {
10407c052f7SAlexandre Deckner			err = data->AddMessage("_d_on", &pictureArchive);
10507c052f7SAlexandre Deckner			if (err != B_OK)
10607c052f7SAlexandre Deckner				return err;
10707c052f7SAlexandre Deckner		}
108a8c4b88dSAxel Dörfler
109b2f1b918SStefano Ceccherini		pictureArchive.MakeEmpty();
11007c052f7SAlexandre Deckner		if (fDisabledOff && fDisabledOff->Archive(&pictureArchive, deep) == B_OK) {
11107c052f7SAlexandre Deckner			err = data->AddMessage("_d_off", &pictureArchive);
11207c052f7SAlexandre Deckner			if (err != B_OK)
11307c052f7SAlexandre Deckner				return err;
114ac52c378Sejakowatz		}
115ac52c378Sejakowatz	}
116ac52c378Sejakowatz
117a8c4b88dSAxel Dörfler	return data->AddInt32("_behave", fBehavior);
118ac52c378Sejakowatz}
119ac52c378Sejakowatz
120ac52c378Sejakowatz
1218cc8b1b7SStephan Aßmusvoid
1228cc8b1b7SStephan AßmusBPictureButton::AttachedToWindow()
1238cc8b1b7SStephan Aßmus{
1248cc8b1b7SStephan Aßmus	BControl::AttachedToWindow();
1258cc8b1b7SStephan Aßmus}
1268cc8b1b7SStephan Aßmus
1278cc8b1b7SStephan Aßmus
1288cc8b1b7SStephan Aßmusvoid
1298cc8b1b7SStephan AßmusBPictureButton::DetachedFromWindow()
1308cc8b1b7SStephan Aßmus{
1318cc8b1b7SStephan Aßmus	BControl::DetachedFromWindow();
1328cc8b1b7SStephan Aßmus}
1338cc8b1b7SStephan Aßmus
1348cc8b1b7SStephan Aßmus
1358cc8b1b7SStephan Aßmusvoid
1368cc8b1b7SStephan AßmusBPictureButton::AllAttached()
1378cc8b1b7SStephan Aßmus{
1388cc8b1b7SStephan Aßmus	BControl::AllAttached();
1398cc8b1b7SStephan Aßmus}
1408cc8b1b7SStephan Aßmus
1418cc8b1b7SStephan Aßmus
1428cc8b1b7SStephan Aßmusvoid
1438cc8b1b7SStephan AßmusBPictureButton::AllDetached()
1448cc8b1b7SStephan Aßmus{
1458cc8b1b7SStephan Aßmus	BControl::AllDetached();
1468cc8b1b7SStephan Aßmus}
1478cc8b1b7SStephan Aßmus
1488cc8b1b7SStephan Aßmus
1498cc8b1b7SStephan Aßmusvoid
1508cc8b1b7SStephan AßmusBPictureButton::ResizeToPreferred()
1518cc8b1b7SStephan Aßmus{
1528cc8b1b7SStephan Aßmus	BControl::ResizeToPreferred();
1538cc8b1b7SStephan Aßmus}
1548cc8b1b7SStephan Aßmus
1558cc8b1b7SStephan Aßmus
1568cc8b1b7SStephan Aßmusvoid
1578cc8b1b7SStephan AßmusBPictureButton::GetPreferredSize(float* _width, float* _height)
1588cc8b1b7SStephan Aßmus{
1598cc8b1b7SStephan Aßmus	BControl::GetPreferredSize(_width, _height);
1608cc8b1b7SStephan Aßmus}
1618cc8b1b7SStephan Aßmus
1628cc8b1b7SStephan Aßmus
1638cc8b1b7SStephan Aßmusvoid
1648cc8b1b7SStephan AßmusBPictureButton::FrameMoved(BPoint newPosition)
1658cc8b1b7SStephan Aßmus{
1668cc8b1b7SStephan Aßmus	BControl::FrameMoved(newPosition);
1678cc8b1b7SStephan Aßmus}
1688cc8b1b7SStephan Aßmus
1698cc8b1b7SStephan Aßmus
1708cc8b1b7SStephan Aßmusvoid
1718cc8b1b7SStephan AßmusBPictureButton::FrameResized(float newWidth, float newHeight)
1728cc8b1b7SStephan Aßmus{
1738cc8b1b7SStephan Aßmus	BControl::FrameResized(newWidth, newHeight);
1748cc8b1b7SStephan Aßmus}
1758cc8b1b7SStephan Aßmus
1768cc8b1b7SStephan Aßmus
1778cc8b1b7SStephan Aßmusvoid
1781f424632SJohn ScipioneBPictureButton::WindowActivated(bool active)
1798cc8b1b7SStephan Aßmus{
1801f424632SJohn Scipione	BControl::WindowActivated(active);
1818cc8b1b7SStephan Aßmus}
1828cc8b1b7SStephan Aßmus
1838cc8b1b7SStephan Aßmus
1848cc8b1b7SStephan Aßmusvoid
1851f424632SJohn ScipioneBPictureButton::MakeFocus(bool focus)
1868cc8b1b7SStephan Aßmus{
1871f424632SJohn Scipione	BControl::MakeFocus(focus);
1888cc8b1b7SStephan Aßmus}
1898cc8b1b7SStephan Aßmus
1908cc8b1b7SStephan Aßmus
191ac52c378Sejakowatzvoid
192a8c4b88dSAxel DörflerBPictureButton::Draw(BRect updateRect)
193ac52c378Sejakowatz{
19407c052f7SAlexandre Deckner	if (IsEnabled()) {
19507c052f7SAlexandre Deckner		if (Value() == B_CONTROL_ON)
19607c052f7SAlexandre Deckner			DrawPicture(fEnabledOn);
19707c052f7SAlexandre Deckner		else
19807c052f7SAlexandre Deckner			DrawPicture(fEnabledOff);
19907c052f7SAlexandre Deckner	} else {
20016835369SKarsten Heimrich
20107c052f7SAlexandre Deckner		if (fDisabledOff == NULL
20207c052f7SAlexandre Deckner			|| (fDisabledOn == NULL && fBehavior == B_TWO_STATE_BUTTON))
20307c052f7SAlexandre Deckner			debugger("Need to set the 'disabled' pictures for this BPictureButton ");
20416835369SKarsten Heimrich
20507c052f7SAlexandre Deckner		if (Value() == B_CONTROL_ON)
20607c052f7SAlexandre Deckner			DrawPicture(fDisabledOn);
20707c052f7SAlexandre Deckner		else
20807c052f7SAlexandre Deckner			DrawPicture(fDisabledOff);
209ac52c378Sejakowatz	}
210a8c4b88dSAxel Dörfler
211a8c4b88dSAxel Dörfler	if (IsFocus()) {
212a8c4b88dSAxel Dörfler		SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
21316835369SKarsten Heimrich		StrokeRect(Bounds(), B_SOLID_HIGH);
214ac52c378Sejakowatz	}
215ac52c378Sejakowatz}
216ac52c378Sejakowatz
217ac52c378Sejakowatz
2188cc8b1b7SStephan Aßmusvoid
219c109d7e0SJohn ScipioneBPictureButton::MessageReceived(BMessage* message)
2208cc8b1b7SStephan Aßmus{
221c109d7e0SJohn Scipione	BControl::MessageReceived(message);
2228cc8b1b7SStephan Aßmus}
2238cc8b1b7SStephan Aßmus
2248cc8b1b7SStephan Aßmus
2258cc8b1b7SStephan Aßmusvoid
2268cc8b1b7SStephan AßmusBPictureButton::KeyDown(const char* bytes, int32 numBytes)
2278cc8b1b7SStephan Aßmus{
2288cc8b1b7SStephan Aßmus	if (numBytes == 1) {
2298cc8b1b7SStephan Aßmus		switch (bytes[0]) {
2308cc8b1b7SStephan Aßmus			case B_ENTER:
2318cc8b1b7SStephan Aßmus			case B_SPACE:
2328cc8b1b7SStephan Aßmus				if (fBehavior == B_ONE_STATE_BUTTON) {
2338cc8b1b7SStephan Aßmus					SetValue(B_CONTROL_ON);
2348cc8b1b7SStephan Aßmus					snooze(50000);
2358cc8b1b7SStephan Aßmus					SetValue(B_CONTROL_OFF);
2368cc8b1b7SStephan Aßmus				} else {
2378cc8b1b7SStephan Aßmus					if (Value() == B_CONTROL_ON)
2388cc8b1b7SStephan Aßmus						SetValue(B_CONTROL_OFF);
2398cc8b1b7SStephan Aßmus					else
2408cc8b1b7SStephan Aßmus						SetValue(B_CONTROL_ON);
2418cc8b1b7SStephan Aßmus				}
2428cc8b1b7SStephan Aßmus				Invoke();
2438cc8b1b7SStephan Aßmus				return;
2448cc8b1b7SStephan Aßmus		}
2458cc8b1b7SStephan Aßmus	}
2468cc8b1b7SStephan Aßmus
2478cc8b1b7SStephan Aßmus	BControl::KeyDown(bytes, numBytes);
2488cc8b1b7SStephan Aßmus}
2498cc8b1b7SStephan Aßmus
2508cc8b1b7SStephan Aßmus
251ac52c378Sejakowatzvoid
252c109d7e0SJohn ScipioneBPictureButton::MouseDown(BPoint where)
253ac52c378Sejakowatz{
254a8c4b88dSAxel Dörfler	if (!IsEnabled()) {
255c109d7e0SJohn Scipione		BControl::MouseDown(where);
256ac52c378Sejakowatz		return;
257ac52c378Sejakowatz	}
258ac52c378Sejakowatz
259a8c4b88dSAxel Dörfler	SetMouseEventMask(B_POINTER_EVENTS,
260a8c4b88dSAxel Dörfler		B_NO_POINTER_HISTORY | B_SUSPEND_VIEW_FOCUS);
261ac52c378Sejakowatz
262a8c4b88dSAxel Dörfler	if (fBehavior == B_ONE_STATE_BUTTON) {
263ac52c378Sejakowatz		SetValue(B_CONTROL_ON);
264a8c4b88dSAxel Dörfler	} else {
265ac52c378Sejakowatz		if (Value() == B_CONTROL_ON)
266ac52c378Sejakowatz			SetValue(B_CONTROL_OFF);
267ac52c378Sejakowatz		else
268ac52c378Sejakowatz			SetValue(B_CONTROL_ON);
269ac52c378Sejakowatz	}
270ac52c378Sejakowatz	SetTracking(true);
271ac52c378Sejakowatz}
272ac52c378Sejakowatz
273ac52c378Sejakowatz
274ac52c378Sejakowatzvoid
275c109d7e0SJohn ScipioneBPictureButton::MouseUp(BPoint where)
276a8c4b88dSAxel Dörfler{
277a8c4b88dSAxel Dörfler	if (IsEnabled() && IsTracking()) {
278c109d7e0SJohn Scipione		if (Bounds().Contains(where)) {
279a8c4b88dSAxel Dörfler			if (fBehavior == B_ONE_STATE_BUTTON) {
280a8c4b88dSAxel Dörfler				if (Value() == B_CONTROL_ON) {
281ac52c378Sejakowatz					snooze(75000);
282ac52c378Sejakowatz					SetValue(B_CONTROL_OFF);
283ac52c378Sejakowatz				}
284ac52c378Sejakowatz			}
285a8c4b88dSAxel Dörfler			Invoke();
286ac52c378Sejakowatz		}
287a8c4b88dSAxel Dörfler
288ac52c378Sejakowatz		SetTracking(false);
289ac52c378Sejakowatz	}
290ac52c378Sejakowatz}
291ac52c378Sejakowatz
292ac52c378Sejakowatz
293ac52c378Sejakowatzvoid
2941f424632SJohn ScipioneBPictureButton::MouseMoved(BPoint where, uint32 code,
2951f424632SJohn Scipione	const BMessage* dragMessage)
296ac52c378Sejakowatz{
297a8c4b88dSAxel Dörfler	if (IsEnabled() && IsTracking()) {
2981f424632SJohn Scipione		if (code == B_EXITED_VIEW)
299ac52c378Sejakowatz			SetValue(B_CONTROL_OFF);
3001f424632SJohn Scipione		else if (code == B_ENTERED_VIEW)
301ac52c378Sejakowatz			SetValue(B_CONTROL_ON);
302a8c4b88dSAxel Dörfler	} else
3031f424632SJohn Scipione		BControl::MouseMoved(where, code, dragMessage);
304ac52c378Sejakowatz}
305ac52c378Sejakowatz
306ac52c378Sejakowatz
3078cc8b1b7SStephan Aßmus// #pragma mark -
308ac52c378Sejakowatz
309ac52c378Sejakowatz
310ac52c378Sejakowatzvoid
311c109d7e0SJohn ScipioneBPictureButton::SetEnabledOn(BPicture* picture)
312ac52c378Sejakowatz{
313a8c4b88dSAxel Dörfler	delete fEnabledOn;
314c109d7e0SJohn Scipione	fEnabledOn = new (std::nothrow) BPicture(*picture);
315ac52c378Sejakowatz}
316ac52c378Sejakowatz
317ac52c378Sejakowatz
318ac52c378Sejakowatzvoid
319c109d7e0SJohn ScipioneBPictureButton::SetEnabledOff(BPicture* picture)
320ac52c378Sejakowatz{
321a8c4b88dSAxel Dörfler	delete fEnabledOff;
322c109d7e0SJohn Scipione	fEnabledOff = new (std::nothrow) BPicture(*picture);
323ac52c378Sejakowatz}
324ac52c378Sejakowatz
325ac52c378Sejakowatz
326ac52c378Sejakowatzvoid
327c109d7e0SJohn ScipioneBPictureButton::SetDisabledOn(BPicture* picture)
328ac52c378Sejakowatz{
329a8c4b88dSAxel Dörfler	delete fDisabledOn;
330c109d7e0SJohn Scipione	fDisabledOn = new (std::nothrow) BPicture(*picture);
331ac52c378Sejakowatz}
332ac52c378Sejakowatz
333ac52c378Sejakowatz
334ac52c378Sejakowatzvoid
335c109d7e0SJohn ScipioneBPictureButton::SetDisabledOff(BPicture* picture)
336ac52c378Sejakowatz{
337a8c4b88dSAxel Dörfler	delete fDisabledOff;
338c109d7e0SJohn Scipione	fDisabledOff = new (std::nothrow) BPicture(*picture);
339ac52c378Sejakowatz}
340ac52c378Sejakowatz
341ac52c378Sejakowatz
34216835369SKarsten HeimrichBPicture*
343a8c4b88dSAxel DörflerBPictureButton::EnabledOn() const
344ac52c378Sejakowatz{
345ac52c378Sejakowatz	return fEnabledOn;
346ac52c378Sejakowatz}
347ac52c378Sejakowatz
348ac52c378Sejakowatz
34916835369SKarsten HeimrichBPicture*
350a8c4b88dSAxel DörflerBPictureButton::EnabledOff() const
351ac52c378Sejakowatz{
352ac52c378Sejakowatz	return fEnabledOff;
353ac52c378Sejakowatz}
354ac52c378Sejakowatz
355ac52c378Sejakowatz
35616835369SKarsten HeimrichBPicture*
357a8c4b88dSAxel DörflerBPictureButton::DisabledOn() const
358ac52c378Sejakowatz{
359ac52c378Sejakowatz	return fDisabledOn;
360ac52c378Sejakowatz}
361ac52c378Sejakowatz
362ac52c378Sejakowatz
36316835369SKarsten HeimrichBPicture*
364ac52c378SejakowatzBPictureButton::DisabledOff() const
365ac52c378Sejakowatz{
366ac52c378Sejakowatz	return fDisabledOff;
367ac52c378Sejakowatz}
368ac52c378Sejakowatz
369ac52c378Sejakowatz
370ac52c378Sejakowatzvoid
371a8c4b88dSAxel DörflerBPictureButton::SetBehavior(uint32 behavior)
372ac52c378Sejakowatz{
373ac52c378Sejakowatz	fBehavior = behavior;
374ac52c378Sejakowatz}
375ac52c378Sejakowatz
376ac52c378Sejakowatz
377ac52c378Sejakowatzuint32
378a8c4b88dSAxel DörflerBPictureButton::Behavior() const
379ac52c378Sejakowatz{
380ac52c378Sejakowatz	return fBehavior;
381ac52c378Sejakowatz}
382ac52c378Sejakowatz
383ac52c378Sejakowatz
384ac52c378Sejakowatzvoid
385a8c4b88dSAxel DörflerBPictureButton::SetValue(int32 value)
386ac52c378Sejakowatz{
387ac52c378Sejakowatz	BControl::SetValue(value);
388ac52c378Sejakowatz}
389ac52c378Sejakowatz
390ac52c378Sejakowatz
391ac52c378Sejakowatzstatus_t
392c109d7e0SJohn ScipioneBPictureButton::Invoke(BMessage* message)
393ac52c378Sejakowatz{
394c109d7e0SJohn Scipione	return BControl::Invoke(message);
395ac52c378Sejakowatz}
396ac52c378Sejakowatz
397ac52c378Sejakowatz
39816835369SKarsten HeimrichBHandler*
399c109d7e0SJohn ScipioneBPictureButton::ResolveSpecifier(BMessage* message, int32 index,
4001f424632SJohn Scipione	BMessage* specifier, int32 what, const char* property)
401ac52c378Sejakowatz{
4021f424632SJohn Scipione	return BControl::ResolveSpecifier(message, index, specifier,
4031f424632SJohn Scipione		what, property);
404ac52c378Sejakowatz}
405ac52c378Sejakowatz
406ac52c378Sejakowatz
407ac52c378Sejakowatzstatus_t
40816835369SKarsten HeimrichBPictureButton::GetSupportedSuites(BMessage* data)
409ac52c378Sejakowatz{
410ac52c378Sejakowatz	return BControl::GetSupportedSuites(data);
411ac52c378Sejakowatz}
412ac52c378Sejakowatz
413ac52c378Sejakowatz
414ac52c378Sejakowatzstatus_t
41539fbf550SOliver TappeBPictureButton::Perform(perform_code code, void* _data)
41639fbf550SOliver Tappe{
41739fbf550SOliver Tappe	switch (code) {
41839fbf550SOliver Tappe		case PERFORM_CODE_MIN_SIZE:
41939fbf550SOliver Tappe			((perform_data_min_size*)_data)->return_value
42039fbf550SOliver Tappe				= BPictureButton::MinSize();
42139fbf550SOliver Tappe			return B_OK;
42239fbf550SOliver Tappe		case PERFORM_CODE_MAX_SIZE:
42339fbf550SOliver Tappe			((perform_data_max_size*)_data)->return_value
42439fbf550SOliver Tappe				= BPictureButton::MaxSize();
42539fbf550SOliver Tappe			return B_OK;
42639fbf550SOliver Tappe		case PERFORM_CODE_PREFERRED_SIZE:
42739fbf550SOliver Tappe			((perform_data_preferred_size*)_data)->return_value
42839fbf550SOliver Tappe				= BPictureButton::PreferredSize();
42939fbf550SOliver Tappe			return B_OK;
43039fbf550SOliver Tappe		case PERFORM_CODE_LAYOUT_ALIGNMENT:
43139fbf550SOliver Tappe			((perform_data_layout_alignment*)_data)->return_value
43239fbf550SOliver Tappe				= BPictureButton::LayoutAlignment();
43339fbf550SOliver Tappe			return B_OK;
43439fbf550SOliver Tappe		case PERFORM_CODE_HAS_HEIGHT_FOR_WIDTH:
43539fbf550SOliver Tappe			((perform_data_has_height_for_width*)_data)->return_value
43639fbf550SOliver Tappe				= BPictureButton::HasHeightForWidth();
43739fbf550SOliver Tappe			return B_OK;
43839fbf550SOliver Tappe		case PERFORM_CODE_GET_HEIGHT_FOR_WIDTH:
43939fbf550SOliver Tappe		{
44039fbf550SOliver Tappe			perform_data_get_height_for_width* data
44139fbf550SOliver Tappe				= (perform_data_get_height_for_width*)_data;
44239fbf550SOliver Tappe			BPictureButton::GetHeightForWidth(data->width, &data->min, &data->max,
44339fbf550SOliver Tappe				&data->preferred);
44439fbf550SOliver Tappe			return B_OK;
4458cc8b1b7SStephan Aßmus		}
44639fbf550SOliver Tappe		case PERFORM_CODE_SET_LAYOUT:
44739fbf550SOliver Tappe		{
44839fbf550SOliver Tappe			perform_data_set_layout* data = (perform_data_set_layout*)_data;
44939fbf550SOliver Tappe			BPictureButton::SetLayout(data->layout);
45039fbf550SOliver Tappe			return B_OK;
45139fbf550SOliver Tappe		}
452eee4243dSAlex Wilson		case PERFORM_CODE_LAYOUT_INVALIDATED:
45339fbf550SOliver Tappe		{
454eee4243dSAlex Wilson			perform_data_layout_invalidated* data
455eee4243dSAlex Wilson				= (perform_data_layout_invalidated*)_data;
456eee4243dSAlex Wilson			BPictureButton::LayoutInvalidated(data->descendants);
45739fbf550SOliver Tappe			return B_OK;
45839fbf550SOliver Tappe		}
45939fbf550SOliver Tappe		case PERFORM_CODE_DO_LAYOUT:
46039fbf550SOliver Tappe		{
46139fbf550SOliver Tappe			BPictureButton::DoLayout();
46239fbf550SOliver Tappe			return B_OK;
46339fbf550SOliver Tappe		}
464be436742SIngo Weinhold		case PERFORM_CODE_SET_ICON:
465be436742SIngo Weinhold		{
466be436742SIngo Weinhold			perform_data_set_icon* data = (perform_data_set_icon*)_data;
467be436742SIngo Weinhold			return BPictureButton::SetIcon(data->icon, data->flags);
468be436742SIngo Weinhold		}
46939fbf550SOliver Tappe	}
47039fbf550SOliver Tappe
47139fbf550SOliver Tappe	return BControl::Perform(code, _data);
472ac52c378Sejakowatz}
473ac52c378Sejakowatz
474ac52c378Sejakowatz
475be436742SIngo Weinholdstatus_t
476be436742SIngo WeinholdBPictureButton::SetIcon(const BBitmap* icon, uint32 flags)
477be436742SIngo Weinhold{
478be436742SIngo Weinhold	return BControl::SetIcon(icon, flags);
479be436742SIngo Weinhold}
480be436742SIngo Weinhold
481be436742SIngo Weinhold
482c109d7e0SJohn Scipione// #pragma mark - BPictureButton private methods
4838cc8b1b7SStephan Aßmus
4848cc8b1b7SStephan Aßmus
485a8c4b88dSAxel Dörflervoid BPictureButton::_ReservedPictureButton1() {}
486a8c4b88dSAxel Dörflervoid BPictureButton::_ReservedPictureButton2() {}
487a8c4b88dSAxel Dörflervoid BPictureButton::_ReservedPictureButton3() {}
488ac52c378Sejakowatz
489ac52c378Sejakowatz
49016835369SKarsten HeimrichBPictureButton&
491ac52c378SejakowatzBPictureButton::operator=(const BPictureButton &button)
492ac52c378Sejakowatz{
493ac52c378Sejakowatz	return *this;
494ac52c378Sejakowatz}
495ac52c378Sejakowatz
496