[BACK]Return to GPView.cpp CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gnuplot / beos

Annotation of OpenXM_contrib/gnuplot/beos/GPView.cpp, Revision 1.1

1.1     ! ohara       1: /*[
        !             2:  * Copyright 1986 - 1993, 1998   Thomas Williams, Colin Kelley
        !             3:  *
        !             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.
        !             9:  *
        !            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,
        !            14:  * provided you
        !            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
        !            22:  *    software.
        !            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.
        !            26:  *
        !            27:  * This software is provided "as is" without express or implied warranty
        !            28:  * to the extent permitted by applicable law.
        !            29: ]*/
        !            30:
        !            31: #include <stdio.h>
        !            32: #include <stdlib.h>
        !            33: #include <string.h>
        !            34:
        !            35: #include "GPBitmap.h"
        !            36: #include "GPView.h"
        !            37: #include "constants.h"
        !            38: #include <Region.h>
        !            39: #include <ScrollBar.h>
        !            40:
        !            41:
        !            42: /*******************************************************************/
        !            43: // GPView
        !            44:
        !            45: GPView::GPView(BRect rect, ulong resizeMode,
        !            46:        ulong flags, GPBitmap *bitmap)
        !            47:        : BView(rect,"BitmapEditor",resizeMode,flags|B_SUBPIXEL_PRECISE|B_FRAME_EVENTS)
        !            48: {
        !            49:        m_bitmap = (bitmap) ? bitmap : new GPBitmap(rect.Width(), rect.Height());
        !            50:        SetScale(1);
        !            51: };
        !            52:
        !            53: void GPView::GetMaxSize(float *width, float *height)
        !            54: {
        !            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);
        !            58: };
        !            59:
        !            60: void GPView::MessageReceived(BMessage *msg)
        !            61: {
        !            62:        switch (msg->what) {
        !            63:                case bmsgBitmapDirty:
        !            64:                {
        !            65: //                     m_bitmap->Lock();
        !            66: //                     m_bitmap->display();
        !            67: //                     m_bitmap->Unlock();
        !            68: //                     printf("view (dirty) displaying %d commands\n",m_bitmap->ncommands);
        !            69:                        Draw(Bounds());
        !            70:                        break;
        !            71:                };
        !            72:                case bmsgBitmapResize:
        !            73:                {
        !            74:                        BRect r;
        !            75:                        msg->FindRect("rect",&r);
        !            76:                        m_bitmap->ResizeTo(r.Width(),r.Height(),0);
        !            77:                        break;
        !            78:                };
        !            79:                case bmsgNewCmd:
        !            80:                {
        !            81:                        char *cmd = NULL;
        !            82:                        int32 i, num;
        !            83:                        num = msg->FindInt32("numcmds");
        !            84:                        m_bitmap->addCommands(msg,num);
        !            85: //                     printf("view (new cmds) displaying %d commands\n",m_bitmap->ncommands);
        !            86:                        Draw(Bounds());
        !            87:                        break;
        !            88:                }
        !            89:                case bmsgClrCmd:
        !            90:                {
        !            91:                        m_bitmap->clearCommands();
        !            92:                        break;
        !            93:                }
        !            94:                default:
        !            95:                        BView::MessageReceived(msg);
        !            96:        };
        !            97: };
        !            98:
        !            99: GPView::~GPView()
        !           100: {
        !           101: };
        !           102:
        !           103: void GPView::SetScale(float scale)
        !           104: {
        !           105:        m_scale = scale;
        !           106: //     FixupScrollbars();
        !           107:        Invalidate();
        !           108: };
        !           109:
        !           110: float GPView::Scale()
        !           111: {
        !           112:        return m_scale;
        !           113: };
        !           114:
        !           115: void GPView::FrameResized(float width, float height)
        !           116: {
        !           117:        uint32 buttons;
        !           118:        BPoint cursor;
        !           119:        printf("resising\n");
        !           120: //     ResizeTo(width, height);
        !           121: //     GetMouse(&cursor, &buttons);
        !           122:        m_bitmap->Lock();
        !           123:        m_bitmap->ResizeTo(width, height,1);
        !           124:        BBitmap *b = m_bitmap->RealBitmap();
        !           125:        DrawBitmap(b,b->Bounds(),Bounds());
        !           126:        Sync();
        !           127:        m_bitmap->Unlock();
        !           128: //     Draw(Bounds());
        !           129: //     FixupScrollbars();
        !           130: };
        !           131:
        !           132: void GPView::AttachedToWindow()
        !           133: {
        !           134: //     FixupScrollbars();
        !           135:        SetViewColor(B_TRANSPARENT_32_BIT);
        !           136: };
        !           137:
        !           138: void GPView::MouseDown(BPoint point)
        !           139: {
        !           140:        printf("Mouse Down\n");
        !           141: };
        !           142:
        !           143: void GPView::MouseUp(BPoint point)
        !           144: {
        !           145:        printf("Mouse Up\n");
        !           146:        Draw(Bounds());
        !           147: };
        !           148:
        !           149: void GPView::Draw(BRect updateRect)
        !           150: {
        !           151:        m_bitmap->Lock();
        !           152:        m_bitmap->display(Bounds().Width(),Bounds().Height());
        !           153:        BBitmap *b = m_bitmap->RealBitmap();
        !           154:        DrawBitmap(b,b->Bounds(),Bounds());
        !           155:        Sync();
        !           156:        m_bitmap->Unlock();
        !           157: };
        !           158:
        !           159: void GPView::FixupScrollbars()
        !           160: {
        !           161: };
        !           162:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>