2 * Copyright 1986 - 1993, 1998, 2004 Thomas Williams, Colin Kelley
4 * Permission to use, copy, and distribute this software and its
5 * documentation for any purpose with or without fee is hereby granted,
6 * provided that the above copyright notice appear in all copies and
7 * that both that copyright notice and this permission notice appear
8 * in supporting documentation.
10 * Permission to modify the software is granted, but not the right to
11 * distribute the complete modified source code. Modifications are to
12 * be distributed as patches to the released version. Permission to
13 * distribute binaries produced by compiling modified sources is granted,
15 * 1. distribute the corresponding source modifications from the
16 * released version in the form of a patch file along with the binaries,
17 * 2. add special version identification to distinguish your version
18 * in addition to the base release version number,
19 * 3. provide your name and address as the primary contact for the
20 * support of your modified version, and
21 * 4. retain our contact information in regard to use of the base
23 * Permission to distribute the released version of the source code along
24 * with corresponding source modifications in the form of a patch file is
25 * granted with same provisions 2 through 4 for binary distributions.
27 * This software is provided "as is" without express or implied warranty
28 * to the extent permitted by applicable law.
34 #include <SupportDefs.h>
35 #include <GraphicsDefs.h>
40 #define bmsgZoomIn 'zmin'
41 #define bmsgZoomOut 'zmot'
42 #define bmsgSetScale 'zset'
51 BBitmap * m_bufbitmap;
56 thread_id drawing_thread;
59 float width, height, nwidth, nheight, pointsize, xscale, yscale;
60 int32 ncommands, max_commands;
64 //int gX = 100, gY = 100;
65 //unsigned int gW = 640, gH = 450;
67 GPBitmap(float width, float height);
68 GPBitmap(float width, float height, char **cmds);
71 BBitmap * RealBitmap() { return m_bitmap; };
73 void Lock() { m_bitmap->Lock(); };
74 void Unlock() { m_bitmap->Unlock(); };
76 BRect Bounds() { return m_bitmap->Bounds(); };
77 void * Bits() { return m_bitmap->Bits(); };
78 color_space ColorSpace() { return m_bitmap->ColorSpace(); };
79 int32 BitsLength() { return m_bitmap->BitsLength(); };
80 int32 BytesPerRow() { return m_bitmap->BytesPerRow(); };
82 BView * View() { return m_view; };
83 void SetDirty(BRegion *r);
85 void ResizeTo(float width, float height, uint32 btns);
87 rgb_color PixelAtRGB(int x, int y) {
88 rgb_color c = *((rgb_color*)(((char*)Bits()) + x*4 + y*BytesPerRow()));
92 int32 drawing_loop(void *data);
93 void addCommand(char *cmd);
94 void addCommands(BMessage *msg, int32 numCmds);
96 void display(float v_width, float v_height);
97 void doDiamond(int x, int y, int px, int py);
98 void doPlus(int x, int y, int px, int py);
99 void doBox(int x, int y, int px, int py);
100 void doCross(int x, int y, int px, int py);
101 void doTriangle(int x, int y, int px, int py);
102 void doStar(int x, int y, int px, int py);
103 void doDot(int x, int y);
105 inline float X(int x) { return x * xscale; };
106 inline float Y(int y) { return (4095-(y)) * yscale; }