Added BPicture to IK for Marc Flerackers
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2943 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,212 @@
|
|||||||
|
#ifndef _PICTUREPROTOCOL_H
|
||||||
|
#define _PICTUREPROTOCOL_H
|
||||||
|
|
||||||
|
// BView dirty bits
|
||||||
|
enum {
|
||||||
|
B_PEN_SIZE_BIT = 0x00000001,
|
||||||
|
B_PEN_LOCATION_BIT = 0x00000002,
|
||||||
|
B_HIGH_COLOR_BIT = 0x00000004,
|
||||||
|
B_LOW_COLOR_BIT = 0x00000008,
|
||||||
|
B_DRAW_MODE_BIT = 0x00000010,
|
||||||
|
B_LINE_MODE_BIT = 0x00000020,
|
||||||
|
B_ORIGIN_BIT = 0x00000040,
|
||||||
|
B_FONT_BIT = 0x00000080,
|
||||||
|
B_PATTERN_BIT = 0x00000100,
|
||||||
|
B_BLEND_MODE_BIT = 0x00000200
|
||||||
|
};
|
||||||
|
|
||||||
|
// AppServer protocol
|
||||||
|
enum {
|
||||||
|
|
||||||
|
// Picture instructions
|
||||||
|
|
||||||
|
B_PIC_MOVE_PEN_BY = 0x0010,
|
||||||
|
B_PIC_STROKE_LINE = 0x0100,
|
||||||
|
B_PIC_STROKE_RECT = 0x0101,
|
||||||
|
B_PIC_FILL_RECT = 0x0102,
|
||||||
|
B_PIC_STROKE_ROUND_RECT = 0x0103,
|
||||||
|
B_PIC_FILL_ROUND_RECT = 0x0104,
|
||||||
|
B_PIC_STROKE_BEZIER = 0x0105,
|
||||||
|
B_PIC_FILL_BEZIER = 0x0106,
|
||||||
|
B_PIC_STROKE_POLYGON = 0x010B,
|
||||||
|
B_PIC_FILL_POLYGON = 0x010C,
|
||||||
|
B_PIC_STROKE_SHAPE = 0x010D,
|
||||||
|
B_PIC_FILL_SHAPE = 0x010E,
|
||||||
|
B_PIC_DRAW_STRING = 0x010F,
|
||||||
|
B_PIC_DRAW_PIXELS = 0x0110,
|
||||||
|
B_PIC_DRAW_PICTURE = 0x0112,
|
||||||
|
B_PIC_STROKE_ARC = 0x0113,
|
||||||
|
B_PIC_FILL_ARC = 0x0114,
|
||||||
|
B_PIC_STROKE_ELLIPSE = 0x0115,
|
||||||
|
B_PIC_FILL_ELLIPSE = 0x0116,
|
||||||
|
B_PIC_ENTER_STATE_CHANGE = 0x0200,
|
||||||
|
B_PIC_SET_CLIPPING_RECTS = 0x0201,
|
||||||
|
B_PIC_CLIP_TO_PICTURE = 0x0202,
|
||||||
|
B_PIC_PUSH_STATE = 0x0203,
|
||||||
|
B_PIC_POP_STATE = 0x0204,
|
||||||
|
B_PIC_CLEAR_CLIPPING_RECTS = 0x0205,
|
||||||
|
B_PIC_SET_ORIGIN = 0x0300,
|
||||||
|
B_PIC_SET_PEN_LOCATION = 0x0301,
|
||||||
|
B_PIC_SET_DRAWING_MODE = 0x0302,
|
||||||
|
B_PIC_SET_LINE_MODE = 0x0303,
|
||||||
|
B_PIC_SET_PEN_SIZE = 0x0304,
|
||||||
|
B_PIC_SET_SCALE = 0x0305,
|
||||||
|
B_PIC_SET_FORE_COLOR = 0x0306,
|
||||||
|
B_PIC_SET_BACK_COLOR = 0x0307,
|
||||||
|
B_PIC_SET_STIPLE_PATTERN = 0x0308,
|
||||||
|
B_PIC_ENTER_FONT_STATE = 0x0309,
|
||||||
|
B_PIC_SET_BLENDING_MODE = 0x030A,
|
||||||
|
B_PIC_SET_FONT_FAMILY = 0x0380,
|
||||||
|
B_PIC_SET_FONT_STYLE = 0x0381,
|
||||||
|
B_PIC_SET_FONT_SPACING = 0x0382,
|
||||||
|
B_PIC_SET_FONT_ENCODING = 0x0383,
|
||||||
|
B_PIC_SET_FONT_FLAGS = 0x0384,
|
||||||
|
B_PIC_SET_FONT_SIZE = 0x0385,
|
||||||
|
B_PIC_SET_FONT_ROTATE = 0x0386,
|
||||||
|
B_PIC_SET_FONT_SHEAR = 0x0387,
|
||||||
|
B_PIC_SET_FONT_BPP = 0x0388,
|
||||||
|
B_PIC_SET_FONT_FACE = 0x0389,
|
||||||
|
|
||||||
|
// View instructions
|
||||||
|
|
||||||
|
B_VIEW_CREATE = 0x0500,
|
||||||
|
B_VIEW_MOVE_BY = 0x0501,
|
||||||
|
// B_VIEW_MOVE_TO = 0x0502, // ????
|
||||||
|
B_VIEW_RESIZE_BY = 0x0503,
|
||||||
|
B_VIEW_RESIZE_TO = 0x0504,
|
||||||
|
B_VIEW_DELETE = 0x0505,
|
||||||
|
B_VIEW_FIND = 0x0506,
|
||||||
|
B_VIEW_BOUNDS = 0x0507, // ????
|
||||||
|
B_VIEW_SET_FLAGS = 0x0508,
|
||||||
|
B_VIEW_SET_EVENT_MASK = 0x0509,
|
||||||
|
B_VIEW_SET_MOUSE_EVENT_MASK = 0x050A,
|
||||||
|
B_VIEW_MOVE_TO = 0x050B, // ????
|
||||||
|
B_VIEW_SET_VIEW_CURSOR = 0x050C,
|
||||||
|
|
||||||
|
// Window instructions
|
||||||
|
|
||||||
|
// B_WINDOW_MOVE_BY = 0x0580,
|
||||||
|
// B_WINDOW_MOVE_TO = 0x0581,
|
||||||
|
B_WINDOW_RESIZE_BY = 0x0582,
|
||||||
|
B_WINDOW_RESIZE_TO = 0x0583,
|
||||||
|
B_WINDOW_ACTIVATE = 0x0584,
|
||||||
|
B_WINDOW_SET_OWNER = 0x0585,
|
||||||
|
B_WINDOW_SET_TITLE = 0x0587,
|
||||||
|
B_WINDOW_IS_FRONT = 0x0589,
|
||||||
|
B_WINDOW_HIDE = 0x058C,
|
||||||
|
B_WINDOW_SHOW = 0x058D,
|
||||||
|
B_WINDOW_SET_SIZE_LIMITS = 0x058E,
|
||||||
|
B_WINDOW_IS_ACTIVE = 0x058F,
|
||||||
|
// B_WINDOW_MINIMIZE = 0x0590, // ????
|
||||||
|
B_WINDOW_MINIMIZE = 0x0591,
|
||||||
|
B_WINDOW_SET_FLAGS = 0x0593,
|
||||||
|
B_WINDOW_SEND_BEHIND = 0x0594,
|
||||||
|
B_WINDOW_ADD_TO_SUBSET = 0x0595,
|
||||||
|
B_WINDOW_REMOVE_FROM_SUBSET = 0x0596,
|
||||||
|
B_WINDOW_SET_WINDOW_ALLIGNMENT = 0x0597,
|
||||||
|
B_WINDOW_GET_WINDOW_ALLIGNMENT = 0x0598,
|
||||||
|
B_WINDOW_SET_CURRENT_VIEW = 0x059A,
|
||||||
|
|
||||||
|
// Drawing instructions
|
||||||
|
|
||||||
|
B_MOVE_PEN_TO = 0x0600,
|
||||||
|
B_MOVE_PEN_BY = 0x0601,
|
||||||
|
B_STROKE_LINE = 0x0602,
|
||||||
|
B_STROKE_LINE_TO = 0x0603,
|
||||||
|
B_STROKE_RECT = 0x0604,
|
||||||
|
B_FILL_RECT = 0x0605,
|
||||||
|
B_STROKE_ARC_RECT = 0x0606,
|
||||||
|
B_FILL_ARC_RECT = 0x0607,
|
||||||
|
B_STROKE_ARC = 0x0608,
|
||||||
|
B_FILL_ARC = 0x0609,
|
||||||
|
B_STROKE_ROUND_RECT = 0x060A,
|
||||||
|
B_FILL_ROUND_RECT = 0x060B,
|
||||||
|
B_FILL_REGION = 0x060D,
|
||||||
|
B_STROKE_POLYGON = 0x060E,
|
||||||
|
B_FILL_POLYGON = 0x060F,
|
||||||
|
B_STROKE_BEZIER = 0x0610,
|
||||||
|
B_FILL_BEZIER = 0x0611,
|
||||||
|
B_STROKE_ELLIPSE_RECT = 0x0612,
|
||||||
|
B_FILL_ELLIPSE_RECT = 0x0613,
|
||||||
|
B_STROKE_ELLIPSE = 0x0614,
|
||||||
|
B_FILL_ELLIPSE = 0x0615,
|
||||||
|
B_DRAW_BITMAP = 0x0616,
|
||||||
|
B_STRETCH_BITMAP = 0x0617,
|
||||||
|
B_STRETCH_BITMAP_SRC = 0x0618,
|
||||||
|
B_DRAW_BITMAP_ASYNC = 0x0619,
|
||||||
|
B_STRETCH_BITMAP_ASYNC = 0x061A,
|
||||||
|
B_STRETCH_BITMAP_SRC_ASYNC = 0x061B,
|
||||||
|
B_DRAW_STRING = 0x061C, // ????
|
||||||
|
B_COPY_BITS = 0x061D,
|
||||||
|
B_INVERT_RECT = 0x061E,
|
||||||
|
B_DRAW_LINES = 0x061F,
|
||||||
|
B_DRAW_PICTURE = 0x0620,
|
||||||
|
B_STROKE_SHAPE = 0x0621,
|
||||||
|
B_FILL_SHAPE = 0x0622,
|
||||||
|
|
||||||
|
// Set instructions
|
||||||
|
|
||||||
|
B_SET_DRAWING_MODE = 0x0700,
|
||||||
|
B_SCROLL_TO = 0x0701,
|
||||||
|
B_SET_PEN_SIZE = 0x0702,
|
||||||
|
B_SET_VIEW_COLOR = 0x0703,
|
||||||
|
B_SET_LINE_MODE = 0x0704,
|
||||||
|
B_SET_FONT = 0x0705,
|
||||||
|
B_SET_FORE_COLOR = 0x0706,
|
||||||
|
B_SET_BACK_COLOR = 0x0707,
|
||||||
|
B_CLEAR_CLIPPING_REGION = 0x0708,
|
||||||
|
B_SET_CLIPPING_REGION = 0x0709,
|
||||||
|
B_SET_SCALE = 0x070A,
|
||||||
|
B_SET_ORIGIN = 0x070B,
|
||||||
|
B_PUSH_STATE = 0x070C,
|
||||||
|
B_POP_STATE = 0x070D,
|
||||||
|
B_SET_PATTERN = 0x070E,
|
||||||
|
B_SET_VIEW_BITMAP = 0x070F, // ????
|
||||||
|
B_FORCE_FONT_ANTIALIASING = 0x0710,
|
||||||
|
B_CLIP_TO_PICTURE = 0x0711,
|
||||||
|
B_SET_BLENDING_MODE = 0x0712,
|
||||||
|
|
||||||
|
// Get instructions
|
||||||
|
|
||||||
|
B_PEN_SIZE = 0x0780,
|
||||||
|
B_FORE_COLOR = 0x0781,
|
||||||
|
B_BACK_COLOR = 0x0782,
|
||||||
|
B_PEN_LOCATION = 0x0783,
|
||||||
|
// B_FRAME = 0x0784, // ????
|
||||||
|
B_DRAWING_MODE = 0x0785,
|
||||||
|
B_CLIPPING_REGION = 0x0786,
|
||||||
|
B_LINE_CAP_MODE = 0x0787,
|
||||||
|
B_LINE_JOIN_MODE = 0x0788,
|
||||||
|
B_LINE_MITER_LIMIT = 0x0789,
|
||||||
|
// B_ORIGIN = 0x078A,
|
||||||
|
B_BLENDING_MODE = 0x078B,
|
||||||
|
B_FONT = 0x078C,
|
||||||
|
B_FRAME = 0x078D,
|
||||||
|
|
||||||
|
// Misc instructions
|
||||||
|
|
||||||
|
B_CONVERT_TO = 0x0832,
|
||||||
|
B_CONVERT_FROM = 0x0833,
|
||||||
|
B_INVALIDATE_RECT = 0x0840,
|
||||||
|
B_DISABLE_UPDATES = 0x0841,
|
||||||
|
B_ENABLES_UPDATES = 0x0842,
|
||||||
|
//???? = 0x0845,
|
||||||
|
B_BEGIN_VIEW_TRANSACTION = 0x0846,
|
||||||
|
B_END_VIEW_TRANSACTION = 0x0847,
|
||||||
|
B_BEGIN_PICTURE = 0x0850,
|
||||||
|
B_APPEND_TO_PICTURE = 0x0851,
|
||||||
|
B_END_PICTURE = 0x0852,
|
||||||
|
B_GET_WORKSPACES = 0x0860,
|
||||||
|
B_SET_WORKSPACES = 0x0861,
|
||||||
|
|
||||||
|
B_SHOW_CURSOR = 0x0ECD,
|
||||||
|
B_HIDE_CURSOR = 0x0ECE,
|
||||||
|
B_OBSCURE_CURSOR = 0x0ECF,
|
||||||
|
|
||||||
|
B_IS_CURSOR_HIDDEN = 0x0EDA,
|
||||||
|
|
||||||
|
B_SET_CURSOR = 0x0F10,
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2001-2002, OpenBeOS
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
// File Name: TPicture.h
|
||||||
|
// Author: Marc Flerackers ([email protected])
|
||||||
|
// Description: TPicture is used to create and play picture data.
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef _TPICTURE_H
|
||||||
|
#define _TPICTURE_H
|
||||||
|
|
||||||
|
// Standard Includes -----------------------------------------------------------
|
||||||
|
|
||||||
|
// System Includes -------------------------------------------------------------
|
||||||
|
#include <GraphicsDefs.h>
|
||||||
|
#include <Point.h>
|
||||||
|
#include <Rect.h>
|
||||||
|
#include <DataIO.h>
|
||||||
|
|
||||||
|
// Project Includes ------------------------------------------------------------
|
||||||
|
|
||||||
|
// Local Includes --------------------------------------------------------------
|
||||||
|
|
||||||
|
// Local Defines ---------------------------------------------------------------
|
||||||
|
|
||||||
|
// Globals ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
// TPicture class --------------------------------------------------------------
|
||||||
|
class TPicture {
|
||||||
|
public:
|
||||||
|
TPicture();
|
||||||
|
TPicture(void *data, int32 size/*, BArray<BPicture *> **/);
|
||||||
|
virtual ~TPicture();
|
||||||
|
|
||||||
|
int16 GetOp();
|
||||||
|
bool GetBool();
|
||||||
|
int16 GetInt8();
|
||||||
|
int16 GetInt16();
|
||||||
|
int32 GetInt32();
|
||||||
|
int64 GetInt64();
|
||||||
|
float GetFloat();
|
||||||
|
BPoint GetCoord();
|
||||||
|
BRect GetRect();
|
||||||
|
rgb_color GetColor();
|
||||||
|
//void GetString(char *);
|
||||||
|
|
||||||
|
void *GetData(int32);
|
||||||
|
void GetData(void *data, int32 size);
|
||||||
|
|
||||||
|
void AddInt8(int8);
|
||||||
|
void AddInt16(int16);
|
||||||
|
void AddInt32(int32);
|
||||||
|
void AddInt64(int64);
|
||||||
|
void AddFloat(float);
|
||||||
|
void AddCoord(BPoint);
|
||||||
|
void AddRect(BRect);
|
||||||
|
void AddColor(rgb_color);
|
||||||
|
void AddString(char *);
|
||||||
|
|
||||||
|
void AddData(void *data, int32 size);
|
||||||
|
|
||||||
|
// SwapOp();
|
||||||
|
// SwapInt8();
|
||||||
|
// SwapInt16();
|
||||||
|
// SwapInt32();
|
||||||
|
// SwapInt64();
|
||||||
|
// SwapFloat();
|
||||||
|
// SwapCoord();
|
||||||
|
// SwapRect();
|
||||||
|
// SwapIRect();
|
||||||
|
// SwapColor();
|
||||||
|
// SwapString();
|
||||||
|
|
||||||
|
// Swap();
|
||||||
|
|
||||||
|
// CheckPattern();
|
||||||
|
|
||||||
|
void BeginOp(int32);
|
||||||
|
void EndOp();
|
||||||
|
|
||||||
|
void EnterStateChange();
|
||||||
|
void ExitStateChange();
|
||||||
|
|
||||||
|
void EnterFontChange();
|
||||||
|
void ExitFontChange();
|
||||||
|
|
||||||
|
status_t Play(void **callBackTable, int32 tableEntries,
|
||||||
|
void *userData);
|
||||||
|
status_t Rewind();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BMemoryIO fData;
|
||||||
|
int32 fSize;
|
||||||
|
};
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//status_t do_playback(void *, long, BArray<BPicture *> &, void **, long, void *)
|
||||||
|
|
||||||
|
#endif // _TPICTURE_H
|
||||||
|
|
||||||
@@ -0,0 +1,324 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2001-2002, OpenBeOS
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
// File Name: Picture.cpp
|
||||||
|
// Author: Marc Flerackers ([email protected])
|
||||||
|
// Description: BPicture records a series of drawing instructions that can
|
||||||
|
// be "replayed" later.
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Standard Includes -----------------------------------------------------------
|
||||||
|
|
||||||
|
// System Includes -------------------------------------------------------------
|
||||||
|
#include <Picture.h>
|
||||||
|
#include <Message.h>
|
||||||
|
#include <ByteOrder.h>
|
||||||
|
#include <TPicture.h>
|
||||||
|
#include <Errors.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
// Project Includes ------------------------------------------------------------
|
||||||
|
|
||||||
|
// Local Includes --------------------------------------------------------------
|
||||||
|
|
||||||
|
// Local Defines ---------------------------------------------------------------
|
||||||
|
|
||||||
|
// Globals ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
struct _BPictureExtent_ {
|
||||||
|
void *fNewData;
|
||||||
|
int32 fNewSize;
|
||||||
|
void *fOldData;
|
||||||
|
int32 fOldSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
BPicture::BPicture()
|
||||||
|
: token(-1),
|
||||||
|
extent(NULL),
|
||||||
|
usurped(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
BPicture::BPicture(const BPicture &picture)
|
||||||
|
: token(-1),
|
||||||
|
extent(NULL),
|
||||||
|
usurped(NULL)
|
||||||
|
{
|
||||||
|
init_data();
|
||||||
|
|
||||||
|
if (picture.extent->fNewData == NULL)
|
||||||
|
{
|
||||||
|
/* _BAppServerLink_ link;
|
||||||
|
int32 err;
|
||||||
|
|
||||||
|
link.swrite_l(0xed2);
|
||||||
|
link.swrite_l(picture->server_token);
|
||||||
|
link.sync();
|
||||||
|
link.sread(4, &server_token);*/
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
extent->fNewSize = picture.extent->fNewSize;
|
||||||
|
extent->fNewData = malloc(extent->fNewSize);
|
||||||
|
memcpy(extent->fNewData, picture.extent->fNewData, extent->fNewSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
BPicture::BPicture(BMessage *archive)
|
||||||
|
: token(-1),
|
||||||
|
extent(NULL),
|
||||||
|
usurped(NULL)
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
init_data();
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
BPicture::~BPicture()
|
||||||
|
{
|
||||||
|
delete extent;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
BArchivable *BPicture::Instantiate(BMessage *archive)
|
||||||
|
{
|
||||||
|
if (validate_instantiation(archive, "BPicture"))
|
||||||
|
return new BPicture(archive);
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
status_t BPicture::Archive(BMessage *archive, bool deep) const
|
||||||
|
{
|
||||||
|
if (!((BPicture*)this)->assert_local_copy())
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
|
status_t err = BArchivable::Archive(archive, deep);
|
||||||
|
|
||||||
|
if (err != B_OK)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
err = archive->AddInt32("_ver", 1);
|
||||||
|
|
||||||
|
if (err != B_OK)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
err = archive->AddInt8("_endian", B_HOST_IS_BENDIAN);
|
||||||
|
|
||||||
|
if (err != B_OK)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
err = archive->AddData("_data", B_RAW_TYPE, extent->fNewData,
|
||||||
|
extent->fNewSize);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
status_t BPicture::Perform(perform_code d, void *arg)
|
||||||
|
{
|
||||||
|
return BArchivable::Perform(d, arg);
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
status_t BPicture::Play(void **callBackTable, int32 tableEntries, void *user)
|
||||||
|
{
|
||||||
|
if (!assert_local_copy())
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
|
//do_playback(extent->fData, extent->fSize, ?BArray<BPicture*>&?,
|
||||||
|
// callBackTable, tableEntries, user);
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
status_t BPicture::Flatten(BDataIO *stream)
|
||||||
|
{
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
status_t BPicture::Unflatten(BDataIO *stream)
|
||||||
|
{
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
void BPicture::_ReservedPicture1() {}
|
||||||
|
void BPicture::_ReservedPicture2() {}
|
||||||
|
void BPicture::_ReservedPicture3() {}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
BPicture &BPicture::operator=(const BPicture &)
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
void BPicture::init_data()
|
||||||
|
{
|
||||||
|
token = -1;
|
||||||
|
usurped = NULL;
|
||||||
|
|
||||||
|
extent = new _BPictureExtent_;
|
||||||
|
extent->fNewData = NULL;
|
||||||
|
extent->fNewSize = 0;
|
||||||
|
extent->fOldData = NULL;
|
||||||
|
extent->fOldSize = 0;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
void BPicture::import_data(const void *data, int32 size, BPicture **subs,
|
||||||
|
int32 subCount)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
void BPicture::import_old_data(const void *data, int32 size)
|
||||||
|
{
|
||||||
|
// TODO: do we need to support old data, what is old data?
|
||||||
|
/*convert_old_to_new(data, size, &extent->fNewData, &extent->fNewSize);
|
||||||
|
|
||||||
|
_BAppServerLink_ link;
|
||||||
|
int32 err;
|
||||||
|
|
||||||
|
link.swrite_l(0xed1);
|
||||||
|
link.swrite_l(0);
|
||||||
|
link.swrite_l(extent->fNewSize);
|
||||||
|
link.swrite_l(extent->fNewSize, extent->fNewData);
|
||||||
|
link.sync();
|
||||||
|
link.sread(4, &token);*/
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
void BPicture::set_token(int32 _token)
|
||||||
|
{
|
||||||
|
token = _token;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
bool BPicture::assert_local_copy()
|
||||||
|
{
|
||||||
|
if (extent->fNewData != NULL)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (token == -1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* _BAppServerLink_ link;
|
||||||
|
int32 err;
|
||||||
|
|
||||||
|
link.swrite_l(0xed5);
|
||||||
|
link.swrite_l(server_token);
|
||||||
|
link.sync();
|
||||||
|
link.sread(4, &err);
|
||||||
|
|
||||||
|
// Read sub pictures
|
||||||
|
while (err > 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
link.sread(4, &extent->fNewSize);
|
||||||
|
extent->fNewData = malloc(extent->fNewSize);
|
||||||
|
link.sread(extent->fNewSize, &extent->fNewData);*/
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
bool BPicture::assert_old_local_copy()
|
||||||
|
{
|
||||||
|
// TODO: do we need to support old copies, what are old copies?
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
bool BPicture::assert_server_copy()
|
||||||
|
{
|
||||||
|
if (token != -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (extent->fNewData == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* BPicture *ptr = usurped;
|
||||||
|
for (BPicture *ptr = usurped; ptr != NULL; ptr++)
|
||||||
|
ptr->assert_server_copy();
|
||||||
|
|
||||||
|
_BAppServerLink_ link;
|
||||||
|
int32 err;
|
||||||
|
|
||||||
|
link.swrite_l(0xed1);
|
||||||
|
for (sub picture)
|
||||||
|
link.swrite_l(picture->token);
|
||||||
|
link.swrite_l(extent->fNewSize);
|
||||||
|
link.swrite(extent->fNewSize, extent->fNewData);
|
||||||
|
link.sync();
|
||||||
|
link.sread(4, &err);
|
||||||
|
|
||||||
|
return err == B_OK;*/
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
BPicture::BPicture(const void *data, int32 size)
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
init_data();
|
||||||
|
import_old_data(data, size);
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
const void *BPicture::Data() const
|
||||||
|
{
|
||||||
|
if (extent->fNewData == NULL)
|
||||||
|
{
|
||||||
|
const_cast<BPicture*>(this)->assert_local_copy();
|
||||||
|
//convert_new_to_old(void *, long, void **, long *);
|
||||||
|
}
|
||||||
|
|
||||||
|
return extent->fNewData;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
int32 BPicture::DataSize() const
|
||||||
|
{
|
||||||
|
if (extent->fNewData == NULL)
|
||||||
|
{
|
||||||
|
const_cast<BPicture*>(this)->assert_local_copy();
|
||||||
|
//convert_new_to_old(void *, long, void **, long *);
|
||||||
|
}
|
||||||
|
|
||||||
|
return extent->fNewSize;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
void BPicture::usurp(BPicture *lameDuck)
|
||||||
|
{
|
||||||
|
/* _BAppServerLink_ link;
|
||||||
|
int32 err;
|
||||||
|
|
||||||
|
link.swrite_l(0xed3);
|
||||||
|
link.swrite_l(token);*/
|
||||||
|
|
||||||
|
init_data();
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
BPicture *BPicture::step_down()
|
||||||
|
{
|
||||||
|
// TODO: called from EndPicture
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
status_t do_playback(void * data, int32 size, /*BArray<BPicture*>& pictures,*/
|
||||||
|
void **callBackTable, int32 tableEntries, void *user)
|
||||||
|
{
|
||||||
|
TPicture pic(data, size/*, pictures*/);
|
||||||
|
|
||||||
|
return pic.Play(callBackTable, tableEntries, user);
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,489 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2001-2002, OpenBeOS
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
// File Name: TPicture.cpp
|
||||||
|
// Author: Marc Flerackers ([email protected])
|
||||||
|
// Description: TPicture is used to create and play picture data.
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Standard Includes -----------------------------------------------------------
|
||||||
|
|
||||||
|
// System Includes -------------------------------------------------------------
|
||||||
|
#include <TPicture.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <PictureProtocol.h>
|
||||||
|
|
||||||
|
// Project Includes ------------------------------------------------------------
|
||||||
|
|
||||||
|
// Local Includes --------------------------------------------------------------
|
||||||
|
|
||||||
|
// Local Defines ---------------------------------------------------------------
|
||||||
|
|
||||||
|
// Globals ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
typedef void (*fnc)(void*);
|
||||||
|
typedef void (*fnc_BPoint)(void*, BPoint);
|
||||||
|
typedef void (*fnc_BPointBPoint)(void*, BPoint, BPoint);
|
||||||
|
typedef void (*fnc_BRect)(void*, BRect);
|
||||||
|
typedef void (*fnc_BRectBPoint)(void*, BRect, BPoint);
|
||||||
|
typedef void (*fnc_PBPoint)(void*, BPoint*);
|
||||||
|
typedef void (*fnc_i)(void*, int32);
|
||||||
|
typedef void (*fnc_iPBPointb)(void*, int32, BPoint*, bool);
|
||||||
|
typedef void (*fnc_iPBPoint)(void*, int32, BPoint*);
|
||||||
|
typedef void (*fnc_Pc)(void*, char*);
|
||||||
|
typedef void (*fnc_Pcff)(void*, char*, float, float);
|
||||||
|
typedef void (*fnc_BPointBPointff)(void*, BPoint, BPoint, float, float);
|
||||||
|
typedef void (*fnc_s)(void*, int16);
|
||||||
|
typedef void (*fnc_ssf)(void*, int16, int16, float);
|
||||||
|
typedef void (*fnc_f)(void*, float);
|
||||||
|
typedef void (*fnc_Color)(void*, rgb_color);
|
||||||
|
typedef void (*fnc_Pattern)(void*, pattern);
|
||||||
|
typedef void (*fnc_PBRecti)(void*, BRect*, int32);
|
||||||
|
typedef void (*fnc_DrawPixels)(void *, BRect, BRect, int32, int32, int32,
|
||||||
|
int32, int32, void*);
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
TPicture::TPicture(void *data, int32 size)
|
||||||
|
: fData(data, size)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
TPicture::~TPicture()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
int16 TPicture::GetOp()
|
||||||
|
{
|
||||||
|
int16 data;
|
||||||
|
|
||||||
|
fData.Read(&data, sizeof(int16));
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
bool TPicture::GetBool()
|
||||||
|
{
|
||||||
|
bool data;
|
||||||
|
|
||||||
|
fData.Read(&data, sizeof(bool));
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
int16 TPicture::GetInt16()
|
||||||
|
{
|
||||||
|
int16 data;
|
||||||
|
|
||||||
|
fData.Read(&data, sizeof(int16));
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
int32 TPicture::GetInt32()
|
||||||
|
{
|
||||||
|
int32 data;
|
||||||
|
|
||||||
|
fData.Read(&data, sizeof(int32));
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
float TPicture::GetFloat()
|
||||||
|
{
|
||||||
|
float data;
|
||||||
|
|
||||||
|
fData.Read(&data, sizeof(float));
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
BPoint TPicture::GetCoord()
|
||||||
|
{
|
||||||
|
BPoint data;
|
||||||
|
|
||||||
|
fData.Read(&data, sizeof(BPoint));
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
BRect TPicture::GetRect()
|
||||||
|
{
|
||||||
|
BRect data;
|
||||||
|
|
||||||
|
fData.Read(&data, sizeof(BRect));
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
rgb_color TPicture::GetColor()
|
||||||
|
{
|
||||||
|
rgb_color data;
|
||||||
|
|
||||||
|
fData.Read(&data, sizeof(rgb_color));
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
void TPicture::GetData(void *data, int32 size)
|
||||||
|
{
|
||||||
|
fData.Read(data, size);
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
status_t TPicture::Play(void **callBackTable, int32 tableEntries,
|
||||||
|
void *userData)
|
||||||
|
{
|
||||||
|
// TODO: we should probably check if the functions in the table are not 0
|
||||||
|
// before calling them.
|
||||||
|
|
||||||
|
int16 op;
|
||||||
|
int32 size;
|
||||||
|
off_t pos;
|
||||||
|
|
||||||
|
while (fData.Position() < size)
|
||||||
|
{
|
||||||
|
op = GetOp();
|
||||||
|
size = GetInt32();
|
||||||
|
pos = fData.Position();
|
||||||
|
|
||||||
|
switch (op)
|
||||||
|
{
|
||||||
|
case B_PIC_MOVE_PEN_BY:
|
||||||
|
{
|
||||||
|
BPoint where = GetCoord();
|
||||||
|
((fnc_BPoint)callBackTable[1])(userData, where);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_STROKE_LINE:
|
||||||
|
{
|
||||||
|
BPoint start = GetCoord();
|
||||||
|
BPoint end = GetCoord();
|
||||||
|
((fnc_BPointBPoint)callBackTable[2])(userData, start, end);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_STROKE_RECT:
|
||||||
|
{
|
||||||
|
BRect rect = GetRect();
|
||||||
|
((fnc_BRect)callBackTable[3])(userData, rect);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_FILL_RECT:
|
||||||
|
{
|
||||||
|
BRect rect = GetRect();
|
||||||
|
((fnc_BRect)callBackTable[4])(userData, rect);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_STROKE_ROUND_RECT:
|
||||||
|
{
|
||||||
|
BRect rect = GetRect();
|
||||||
|
BPoint radii = GetCoord();
|
||||||
|
((fnc_BRectBPoint)callBackTable[5])(userData, rect, radii);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_FILL_ROUND_RECT:
|
||||||
|
{
|
||||||
|
BRect rect = GetRect();
|
||||||
|
BPoint radii = GetCoord();
|
||||||
|
((fnc_BRectBPoint)callBackTable[6])(userData, rect, radii);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_STROKE_BEZIER:
|
||||||
|
{
|
||||||
|
BPoint control[4];
|
||||||
|
GetData(control, sizeof(control));
|
||||||
|
((fnc_PBPoint)callBackTable[7])(userData, control);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_FILL_BEZIER:
|
||||||
|
{
|
||||||
|
BPoint control[4];
|
||||||
|
GetData(control, sizeof(control));
|
||||||
|
((fnc_PBPoint)callBackTable[8])(userData, control);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_STROKE_POLYGON:
|
||||||
|
{
|
||||||
|
int32 numPoints = GetInt32();
|
||||||
|
BPoint *points = new BPoint[numPoints];
|
||||||
|
GetData(points, numPoints * sizeof(BPoint));
|
||||||
|
bool isClosed = GetBool();
|
||||||
|
((fnc_iPBPointb)callBackTable[13])(userData, numPoints, points, isClosed);
|
||||||
|
delete points;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_FILL_POLYGON:
|
||||||
|
{
|
||||||
|
int32 numPoints = GetInt32();
|
||||||
|
BPoint *points = new BPoint[numPoints];
|
||||||
|
GetData(points, numPoints * sizeof(BPoint));
|
||||||
|
((fnc_iPBPoint)callBackTable[14])(userData, numPoints, points);
|
||||||
|
delete points;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_STROKE_SHAPE:
|
||||||
|
case B_PIC_FILL_SHAPE:
|
||||||
|
break;
|
||||||
|
case B_PIC_DRAW_STRING:
|
||||||
|
{
|
||||||
|
int32 len = GetInt32();
|
||||||
|
char *string = new char[len + 1];
|
||||||
|
GetData(string, len);
|
||||||
|
string[len] = '\0';
|
||||||
|
float deltax = GetFloat();
|
||||||
|
float deltay = GetFloat();
|
||||||
|
((fnc_Pcff)callBackTable[17])(userData, string, deltax, deltay);
|
||||||
|
delete string;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_DRAW_PIXELS:
|
||||||
|
{
|
||||||
|
BRect src = GetRect();
|
||||||
|
BRect dest = GetRect();
|
||||||
|
int32 width = GetInt32();
|
||||||
|
int32 height = GetInt32();
|
||||||
|
int32 bytesPerRow = GetInt32();
|
||||||
|
int32 pixelFormat = GetInt32();
|
||||||
|
int32 flags = GetInt32();
|
||||||
|
char *data = new char[size - (fData.Position() - pos)];
|
||||||
|
GetData(data, size - (fData.Position() - pos));
|
||||||
|
((fnc_DrawPixels)callBackTable[18])(userData, src, dest,
|
||||||
|
width, height, bytesPerRow, pixelFormat, flags, data);
|
||||||
|
delete data;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_DRAW_PICTURE:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_STROKE_ARC:
|
||||||
|
{
|
||||||
|
BPoint center = GetCoord();
|
||||||
|
BPoint radii = GetCoord();
|
||||||
|
float startTheta = GetFloat();
|
||||||
|
float arcTheta = GetFloat();
|
||||||
|
((fnc_BPointBPointff)callBackTable[9])(userData, center, radii,
|
||||||
|
startTheta, arcTheta);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_FILL_ARC:
|
||||||
|
{
|
||||||
|
BPoint center = GetCoord();
|
||||||
|
BPoint radii = GetCoord();
|
||||||
|
float startTheta = GetFloat();
|
||||||
|
float arcTheta = GetFloat();
|
||||||
|
((fnc_BPointBPointff)callBackTable[10])(userData, center, radii,
|
||||||
|
startTheta, arcTheta);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_STROKE_ELLIPSE:
|
||||||
|
{
|
||||||
|
BRect rect = GetRect();
|
||||||
|
BPoint center;
|
||||||
|
BPoint radii((rect.Width() + 1) / 2.0f, (rect.Height() + 1) / 2.0f);
|
||||||
|
center = rect.LeftTop() + radii;
|
||||||
|
((fnc_BPointBPoint)callBackTable[11])(userData, center, radii);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_FILL_ELLIPSE:
|
||||||
|
{
|
||||||
|
BRect rect = GetRect();
|
||||||
|
BPoint center;
|
||||||
|
BPoint radii((rect.Width() + 1) / 2.0f, (rect.Height() + 1) / 2.0f);
|
||||||
|
center = rect.LeftTop() + radii;
|
||||||
|
((fnc_BPointBPoint)callBackTable[12])(userData, center, radii);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_ENTER_STATE_CHANGE:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_CLIPPING_RECTS:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_CLIP_TO_PICTURE:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_PUSH_STATE:
|
||||||
|
{
|
||||||
|
((fnc)callBackTable[22])(userData);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_POP_STATE:
|
||||||
|
{
|
||||||
|
((fnc)callBackTable[23])(userData);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_CLEAR_CLIPPING_RECTS:
|
||||||
|
{
|
||||||
|
((fnc_PBRecti)callBackTable[20])(userData, NULL, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_ORIGIN:
|
||||||
|
{
|
||||||
|
BPoint pt = GetCoord();
|
||||||
|
((fnc_BPoint)callBackTable[28])(userData, pt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_PEN_LOCATION:
|
||||||
|
{
|
||||||
|
BPoint pt = GetCoord();
|
||||||
|
((fnc_BPoint)callBackTable[29])(userData, pt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_DRAWING_MODE:
|
||||||
|
{
|
||||||
|
int16 mode = GetInt16();
|
||||||
|
((fnc_s)callBackTable[30])(userData, mode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_LINE_MODE:
|
||||||
|
{
|
||||||
|
int16 capMode = GetInt16();
|
||||||
|
int16 joinMode = GetInt16();
|
||||||
|
float miterLimit = GetFloat();
|
||||||
|
((fnc_ssf)callBackTable[31])(userData, capMode, joinMode, miterLimit);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_PEN_SIZE:
|
||||||
|
{
|
||||||
|
float size = GetFloat();
|
||||||
|
((fnc_f)callBackTable[32])(userData, size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_SCALE:
|
||||||
|
{
|
||||||
|
float scale = GetFloat();
|
||||||
|
((fnc_f)callBackTable[36])(userData, scale);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_FORE_COLOR:
|
||||||
|
{
|
||||||
|
rgb_color color = GetColor();
|
||||||
|
((fnc_Color)callBackTable[33])(userData, color);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_BACK_COLOR:
|
||||||
|
{
|
||||||
|
rgb_color color = GetColor();
|
||||||
|
((fnc_Color)callBackTable[34])(userData, color);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_STIPLE_PATTERN:
|
||||||
|
{
|
||||||
|
pattern p;
|
||||||
|
GetData(&p, sizeof(p));
|
||||||
|
((fnc_Pattern)callBackTable[35])(userData, p);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_ENTER_FONT_STATE:
|
||||||
|
{
|
||||||
|
((fnc)callBackTable[26])(userData);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_BLENDING_MODE:
|
||||||
|
{
|
||||||
|
int16 alphaSrcMode = GetInt16();
|
||||||
|
int16 alphaFncMode = GetInt16();
|
||||||
|
//((fnc_Pattern)callBackTable[??])(userData, alphaSrcMode,
|
||||||
|
// alphaFncMode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_FONT_FAMILY:
|
||||||
|
{
|
||||||
|
int32 len = GetInt32();
|
||||||
|
char *string = new char[len + 1];
|
||||||
|
GetData(string, len);
|
||||||
|
string[len] = '\0';
|
||||||
|
((fnc_Pc)callBackTable[37])(userData, string);
|
||||||
|
delete string;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_FONT_STYLE:
|
||||||
|
{
|
||||||
|
int32 len = GetInt32();
|
||||||
|
char *string = new char[len + 1];
|
||||||
|
GetData(string, len);
|
||||||
|
string[len] = '\0';
|
||||||
|
((fnc_Pc)callBackTable[38])(userData, string);
|
||||||
|
delete string;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_FONT_SPACING:
|
||||||
|
{
|
||||||
|
int32 spacing = GetInt32();
|
||||||
|
((fnc_i)callBackTable[39])(userData, spacing);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_FONT_ENCODING:
|
||||||
|
{
|
||||||
|
int32 encoding = GetInt32();
|
||||||
|
((fnc_i)callBackTable[42])(userData, encoding);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_FONT_FLAGS:
|
||||||
|
{
|
||||||
|
int32 flags = GetInt32();
|
||||||
|
((fnc_i)callBackTable[43])(userData, flags);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_FONT_SIZE:
|
||||||
|
{
|
||||||
|
float size = GetFloat();
|
||||||
|
((fnc_f)callBackTable[40])(userData, size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_FONT_ROTATE:
|
||||||
|
{
|
||||||
|
float rotation = GetFloat();
|
||||||
|
((fnc_f)callBackTable[41])(userData, rotation);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_FONT_SHEAR:
|
||||||
|
{
|
||||||
|
float shear = GetFloat();
|
||||||
|
((fnc_f)callBackTable[44])(userData, shear);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_PIC_SET_FONT_FACE:
|
||||||
|
{
|
||||||
|
int32 flags = GetInt32();
|
||||||
|
((fnc_i)callBackTable[46])(userData, flags);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we didn't read enough bytes, skip them. This is not a error
|
||||||
|
// since the instructions can change over time.
|
||||||
|
if (fData.Position() - pos < size)
|
||||||
|
fData.Seek(size - (fData.Position() - pos), SEEK_CUR);
|
||||||
|
|
||||||
|
// TODO: what if too much was read, should we return B_ERROR?
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
@@ -8,6 +8,7 @@ INTERFACE_KIT_SOURCE =
|
|||||||
Control.cpp
|
Control.cpp
|
||||||
Deskbar.cpp
|
Deskbar.cpp
|
||||||
Font.cpp
|
Font.cpp
|
||||||
|
Picture.cpp
|
||||||
PictureButton.cpp
|
PictureButton.cpp
|
||||||
Point.cpp
|
Point.cpp
|
||||||
Polygon.cpp
|
Polygon.cpp
|
||||||
@@ -18,6 +19,7 @@ INTERFACE_KIT_SOURCE =
|
|||||||
StringView.cpp
|
StringView.cpp
|
||||||
TextControl.cpp
|
TextControl.cpp
|
||||||
TextInput.cpp
|
TextInput.cpp
|
||||||
|
TPicture.cpp
|
||||||
View.cpp
|
View.cpp
|
||||||
Window.cpp
|
Window.cpp
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user