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.
37 #include "constants.h"
39 #include <ScrollBar.h>
42 /*******************************************************************/
45 GPView::GPView(BRect rect, ulong resizeMode,
46 ulong flags, GPBitmap *bitmap)
47 : BView(rect,"BitmapEditor",resizeMode,flags|B_SUBPIXEL_PRECISE|B_FRAME_EVENTS)
49 m_bitmap = (bitmap) ? bitmap : new GPBitmap(rect.Width(), rect.Height());
53 void GPView::GetMaxSize(float *width, float *height)
55 BRect r = m_bitmap->Bounds();
56 *width = floor((r.right+1)*m_scale - 0.5);
57 *height = floor((r.bottom+1)*m_scale - 0.5);
60 void GPView::MessageReceived(BMessage *msg)
66 // m_bitmap->display();
67 // m_bitmap->Unlock();
68 // printf("view (dirty) displaying %d commands\n",m_bitmap->ncommands);
72 case bmsgBitmapResize:
75 msg->FindRect("rect",&r);
76 m_bitmap->ResizeTo(r.Width(),r.Height(),0);
83 num = msg->FindInt32("numcmds");
84 m_bitmap->addCommands(msg,num);
85 // printf("view (new cmds) displaying %d commands\n",m_bitmap->ncommands);
91 m_bitmap->clearCommands();
95 BView::MessageReceived(msg);
103 void GPView::SetScale(float scale)
106 // FixupScrollbars();
110 float GPView::Scale()
115 void GPView::FrameResized(float width, float height)
119 printf("resising\n");
120 // ResizeTo(width, height);
121 // GetMouse(&cursor, &buttons);
123 m_bitmap->ResizeTo(width, height,1);
124 BBitmap *b = m_bitmap->RealBitmap();
125 DrawBitmap(b,b->Bounds(),Bounds());
129 // FixupScrollbars();
132 void GPView::AttachedToWindow()
134 // FixupScrollbars();
135 SetViewColor(B_TRANSPARENT_32_BIT);
138 void GPView::MouseDown(BPoint point)
140 printf("Mouse Down\n");
143 void GPView::MouseUp(BPoint point)
145 printf("Mouse Up\n");
149 void GPView::Draw(BRect updateRect)
152 m_bitmap->display(Bounds().Width(),Bounds().Height());
153 BBitmap *b = m_bitmap->RealBitmap();
154 DrawBitmap(b,b->Bounds(),Bounds());
159 void GPView::FixupScrollbars()