1#ifndef _VIEW_BUFFER_H_
2#define _VIEW_BUFFER_H_
3
4#include <SupportDefs.h>
5#include <View.h>
6
7typedef void (*resize_callback)(int32 width, int32 height, void *data);
8
9class ViewBuffer : public BView {
10public:
11							ViewBuffer(BRect frame);
12virtual						~ViewBuffer();
13
14virtual	void				FrameResized(float new_width, float new_height);
15		void				SetResizeCallback(resize_callback callback, void *data);
16		status_t			GetSize(int32 *width, int32 *height);
17
18		uint8				ForegroundColor(uint8 attr);
19		uint8				BackgroundColor(uint8 attr);
20		rgb_color			GetPaletteEntry(uint8 index);
21
22		void				PutGlyph(int32 x, int32 y, uint8 glyph, uint8 attr);
23		void				FillGlyph(int32 x, int32 y, int32 width, int32 height, uint8 glyph, uint8 attr);
24		void				RenderGlyph(int32 x, int32 y, uint8 glyph, uint8 attr);
25
26virtual	void				Draw(BRect updateRect);
27
28		void				DrawCursor(int32 x, int32 y);
29		void				MoveCursor(int32 x, int32 y);
30
31		void				Blit(int32 srcx, int32 srcy, int32 width, int32 height, int32 destx, int32 desty);
32		void				Clear(uint8 attr);
33
34private:
35		void				_RenderGlyph(int32 x, int32 y, const char* string, uint8 attr, bool fill = true);
36
37		int32				fColumns;
38		int32				fRows;
39
40		uint16*				fGlyphGrid;
41
42		resize_callback		fResizeCallback;
43		void				*fResizeCallbackData;
44		int32				fCursorX;
45		int32				fCursorY;
46
47		rgb_color			fPalette[8];
48};
49
50#endif
51