1435492aeSPhilippe Houdoin/*
2435492aeSPhilippe Houdoin * Copyright 2011, Haiku.
3435492aeSPhilippe Houdoin * Distributed under the terms of the MIT License.
4435492aeSPhilippe Houdoin *
5435492aeSPhilippe Houdoin * Authors:
6435492aeSPhilippe Houdoin *		Philippe Houdoin
7435492aeSPhilippe Houdoin */
8435492aeSPhilippe Houdoin#ifndef PICTURE_VIEW_H
9435492aeSPhilippe Houdoin#define PICTURE_VIEW_H
10435492aeSPhilippe Houdoin
11435492aeSPhilippe Houdoin
12435492aeSPhilippe Houdoin#include <Node.h>
13f22fe14cSPhilippe Houdoin#include <String.h>
14435492aeSPhilippe Houdoin#include <View.h>
15435492aeSPhilippe Houdoin
16435492aeSPhilippe Houdoin
17435492aeSPhilippe Houdoinclass BBitmap;
18f22fe14cSPhilippe Houdoinclass BFilePanel;
19435492aeSPhilippe Houdoin
20bb0416a2SPhilippe Houdoinconst uint32	kMsgLoadImage	= 'mLIM';
21bb0416a2SPhilippe Houdoin
22bb0416a2SPhilippe Houdoin
23435492aeSPhilippe Houdoinclass PictureView : public BView {
24435492aeSPhilippe Houdoinpublic:
25435492aeSPhilippe Houdoin								PictureView(float width, float height,
26435492aeSPhilippe Houdoin									const entry_ref* ref);
27435492aeSPhilippe Houdoin	virtual						~PictureView();
28435492aeSPhilippe Houdoin
29435492aeSPhilippe Houdoin			bool				HasChanged();
30435492aeSPhilippe Houdoin			void				Revert();
3189aa6cbeSPhilippe Houdoin			void				Update();
327a9ea6dfSPhilippe Houdoin			void				Update(const entry_ref* ref);
33435492aeSPhilippe Houdoin
347a9ea6dfSPhilippe Houdoin			BBitmap*			Bitmap();
35f22fe14cSPhilippe Houdoin			uint32				SuggestedType();
36f22fe14cSPhilippe Houdoin			const char*			SuggestedMIMEType();
37435492aeSPhilippe Houdoin
38435492aeSPhilippe Houdoin	virtual	void				MessageReceived(BMessage* message);
39435492aeSPhilippe Houdoin	virtual	void				Draw(BRect updateRect);
40bb0416a2SPhilippe Houdoin	virtual	void				MouseDown(BPoint point);
41bb0416a2SPhilippe Houdoin	virtual	void				KeyDown(const char* bytes, int32 numBytes);
42bb0416a2SPhilippe Houdoin	virtual void				WindowActivated(bool active);
43bb0416a2SPhilippe Houdoin	virtual	void				MakeFocus(bool focused);
44435492aeSPhilippe Houdoin
45435492aeSPhilippe Houdoinprivate:
46bb0416a2SPhilippe Houdoin			void				_BeginDrag(BPoint sourcePoint);
47bb0416a2SPhilippe Houdoin			void				_HandleDrop(BMessage* message);
48bb0416a2SPhilippe Houdoin			void				_ShowPopUpMenu(BPoint screen);
49bb0416a2SPhilippe Houdoin			BBitmap*			_CopyPicture(uint8 alpha);
50bb0416a2SPhilippe Houdoin
51f22fe14cSPhilippe Houdoin			status_t			_LoadPicture(const entry_ref* ref);
52e23bbaffSPhilippe Houdoin			void				_SetPicture(BBitmap* bitmap);
53bb0416a2SPhilippe Houdoin
54435492aeSPhilippe Houdoin			BBitmap*			fPicture;
55435492aeSPhilippe Houdoin			BBitmap*			fOriginalPicture;
56435492aeSPhilippe Houdoin			BBitmap*			fDefaultPicture;
57bb0416a2SPhilippe Houdoin			bool				fShowingPopUpMenu;
58bb0416a2SPhilippe Houdoin			BRect				fPictureRect;
59f22fe14cSPhilippe Houdoin			uint32				fPictureType;
60f22fe14cSPhilippe Houdoin			BString				fPictureMIMEType;
61f22fe14cSPhilippe Houdoin			bool 				fFocusChanging;
62f22fe14cSPhilippe Houdoin			BFilePanel*			fOpenPanel;
63435492aeSPhilippe Houdoin};
64435492aeSPhilippe Houdoin
65435492aeSPhilippe Houdoin#endif
66