Пример #1
0
void MyMainFrame::prepareSignal(MyWindow* win, WORD signal)
{
	PegMessage msg(this,MYMF_SEND_SIGNAL);
	msg.iData = signal;
	msg.pSource = win;
	MessageQueue()->Push(msg);
}
Пример #2
0
unsigned int RawIDA::InsertInputChannel(word32 channelId)
{
	if (m_lastMapPosition != m_inputChannelMap.end())
	{
		if (m_lastMapPosition->first == channelId)
			goto skipFind;
		++m_lastMapPosition;
		if (m_lastMapPosition != m_inputChannelMap.end() && m_lastMapPosition->first == channelId)
			goto skipFind;
	}
	m_lastMapPosition = m_inputChannelMap.find(channelId);

skipFind:
	if (m_lastMapPosition == m_inputChannelMap.end())
	{
		if (m_inputChannelIds.size() == size_t(m_threshold))
			return m_threshold;

		m_lastMapPosition = m_inputChannelMap.insert(InputChannelMap::value_type(channelId, (unsigned int)m_inputChannelIds.size())).first;
		m_inputQueues.push_back(MessageQueue());
		m_inputChannelIds.push_back(channelId);

		if (m_inputChannelIds.size() == size_t(m_threshold))
			PrepareInterpolation();
	}
	return m_lastMapPosition->second;
}
Пример #3
0
/*--------------------------------------------------------------------------*/
void PegMenuButton::SetChecked(BOOL State)
{
    if (State)
    {
        mwStyle |= BF_CHECKED;
    }
    else
    {
        mwStyle &= ~BF_CHECKED;
    }

    if (Id())
    {
        PegMessage NewMessage;
        NewMessage.pTarget = mpOwner;
        NewMessage.pSource = this;
        NewMessage.iData = Id();
        NewMessage.wType = 0;

        if (mwStyle & BF_CHECKED)
        {
            if (GetSignals() & SIGMASK(PSF_CHECK_ON))
            {
                NewMessage.wType = PEG_SIGNAL(Id(), PSF_CHECK_ON);
            }
        }
        else
        {
            if (GetSignals() & SIGMASK(PSF_CHECK_OFF))
            {
                NewMessage.wType = PEG_SIGNAL(Id(), PSF_CHECK_OFF);
            }
        }

        if (NewMessage.wType)
        {
            MessageQueue()->Push(NewMessage);
        }
    }
}
Пример #4
0
/*--------------------------------------------------------------------------*/
void PegMenuButton::SendOwnerMessage(void)
{
    if (mpSubMenu || !mpOwner || Parent()->Type() == TYPE_MENU_BAR)
    {
        return;
    }
    Presentation()->MoveFocusTree(mpOwner);
            
    if (mwStyle & BF_CHECKABLE)
    {
        if (mwStyle & BF_CHECKED)
        {
            SetChecked(FALSE);
        }
        else
        {
            SetChecked(TRUE);
        }
    }
    else
    {
        if (mwStyle & BF_DOTABLE)
        {
            RemoveSiblingDots();
            SetDotted(TRUE);
        }
        else
        {
            if (Id())
            {
                PegMessage NewMessage(mpOwner, PEG_SIGNAL(Id(), PSF_CLICKED));
                NewMessage.iData = Id();
                NewMessage.pSource = this;
                MessageQueue()->Push(NewMessage);
            }
        }
    }
}
Пример #5
0
/*--------------------------------------------------------------------------*/
SIGNED PegWindow::Message(const PegMessage &Mesg)
{
    SIGNED Result = 0;
    PegMessage NewMessage;

    switch(Mesg.wType)
    {
    case PM_POINTER_MOVE:
        if (muMoveMode)
        {
            if (Mesg.Point.x != mMovePoint.x ||
                Mesg.Point.y != mMovePoint.y)
            {
                DrawMoveFrame(TRUE);
                mMovePoint = Mesg.Point;
                DrawMoveFrame(FALSE);
            }
        }
        else
        {
            if (StatusIs(PSF_SIZEABLE) && !mbMaximized)
            {
                UCHAR uTemp = BorderContains(Mesg.Point);

                if (uTemp != mbShowPointer)
                {
                    mbShowPointer = uTemp;

                    switch(uTemp)
                    {
                    case PMM_MOVELEFT:
                    case PMM_MOVERIGHT:
                        SetPointerType(PPT_HSIZE);
                        break;

                    case PMM_MOVETOP:
                    case PMM_MOVEBOTTOM:
                        SetPointerType(PPT_VSIZE);
                        break;

                    case PMM_MOVEUR:
                    case PMM_MOVELL:
                        SetPointerType(PPT_NESW_SIZE);
                        break;

                    case PMM_MOVEUL:
                    case PMM_MOVELR:
                        SetPointerType(PPT_NWSE_SIZE);
                        break;

                    default:
                        SetPointerType(PPT_NORMAL);
                        break;
                    }
                }
            }
        }
        break;

    case PM_SHOW:
        PegThing::Message(Mesg);

       #if defined(PEG_KEYBOARD_SUPPORT) && defined(PEG_TAB_KEY_SUPPORT)
        SetDefaultTabLinks();
       #endif

        if (muScrollMode & WSM_AUTOSCROLL)
        {
            CheckAutoScroll();
        }
        break;

    #if defined(PEG_KEYBOARD_SUPPORT)

    case PM_GAINED_KEYBOARD:
        if (!StatusIs(PSF_KEEPS_CHILD_FOCUS))
        {
            MoveFocusToFirstClientChild();
        }
        break;

    #else

    case PM_CURRENT:
        PegThing::Message(Mesg);
        if (Presentation()->GetCurrentThing() == this &&
            !StatusIs(PSF_KEEPS_CHILD_FOCUS))
        {
            MoveFocusToFirstClientChild();
        }
        break;

    #endif

    case PM_ADDICON:
        AddIcon((PegIcon *) Mesg.pData);
        break;

    case PM_BEGIN_MOVE:
        if (!muMoveMode && StatusIs(PSF_MOVEABLE))
        {
            muMoveMode = (UCHAR) Mesg.iData;
            mbMoveFrame = FALSE;
            CapturePointer();
            mStartMove = Mesg.Point;
            mMovePoint = mStartMove;

            if (muMoveMode == PMM_MOVELR)
            {
                SetPointerType(PPT_NWSE_SIZE);
                mbShowPointer = TRUE;
            }
        }
        break;

    case PM_POINTER_EXIT:
        if (mbShowPointer)
        {
            SetPointerType(PPT_NORMAL);
            mbShowPointer = 0;
        }
        PegThing::Message(Mesg);
        break;

    case PM_LBUTTONDOWN:
        if (!muMoveMode && StatusIs(PSF_SIZEABLE) && !mbMaximized)
        {
            muMoveMode = BorderContains(Mesg.Point);

            if (muMoveMode)
            {
                mbMoveFrame = FALSE;
                CapturePointer();
                mStartMove = Mesg.Point;
                mMovePoint = mStartMove;
            }
        }
        break;

    case PM_LBUTTONUP:
        if (muMoveMode)
        {
            DrawMoveFrame(TRUE);
            SetPointerType(PPT_NORMAL);
            ReleasePointer();
            PegRect OldSize = mReal;

            if (mStartMove.x == mMovePoint.x &&
                mStartMove.y == mMovePoint.y)
            {
                muMoveMode = 0;
                break;  // didn't really move or size anything
            }

            PegRect NewSize = mReal;
            int xShift = mMovePoint.x - mStartMove.x;
            int yShift = mMovePoint.y - mStartMove.y;

            switch(muMoveMode)
            {
            case PMM_MOVEALL:
                NewSize.Shift(xShift, yShift);
                break;

            case PMM_MOVERIGHT:
                NewSize.wRight += xShift;
                break;

            case PMM_MOVELEFT:
                NewSize.wLeft += xShift;
                break;

            case PMM_MOVETOP:
                NewSize.wTop += yShift;
                break;

            case PMM_MOVEBOTTOM:
                NewSize.wBottom += yShift;
                break;

            case PMM_MOVEUL:
                NewSize.wLeft += xShift;
                NewSize.wTop += yShift;
                break;

            case PMM_MOVELL:
                NewSize.wLeft += xShift;
                NewSize.wBottom += yShift;
                break;

            case PMM_MOVEUR:
                NewSize.wRight += xShift;
                NewSize.wTop += yShift;
                break;

            case PMM_MOVELR:
                NewSize.wRight += xShift;
                NewSize.wBottom += yShift;
                break;
            }
            CheckResizeRect(NewSize);

            NewMessage.wType = PM_SIZE;
            NewMessage.Rect = NewSize;
            Message(NewMessage);

            if (StatusIs(PSF_VISIBLE))
            {
                if (mReal.Contains(OldSize))
                {
                    Draw();
                }
                else
                {
                    Parent()->Draw();
                }
            }
            muMoveMode = 0;
        }
        break;

    case PM_VSCROLL:
        MoveClientObjects(0, Mesg.iData - (SIGNED) Mesg.lData);
        break;

    case PM_HSCROLL:
        MoveClientObjects(Mesg.iData - (SIGNED) Mesg.lData, 0);
        break;

    case PM_MAXIMIZE:
        if (StatusIs(PSF_SIZEABLE))
        {
            mbMaximized = TRUE;
            mRestore = mReal;
            NewMessage.wType = PM_SIZE;
            NewMessage.Rect = Parent()->mClient;
            Message(NewMessage);
            Draw();
        }
        break;

    case PM_MINIMIZE:
        if (StatusIs(PSF_SIZEABLE) && !IsModal())
        {
            NewMessage.wType = PM_ADDICON;
            PegIcon *pIcon = new PegIcon(this, mpIconMap);
            pIcon->Id(Id());
            NewMessage.pData = pIcon;
            NewMessage.pTarget = Parent();
            MessageQueue()->Push(NewMessage);
            Parent()->Remove(this);
        }
        break;

    case PM_RESTORE:
        if (StatusIs(PSF_SIZEABLE))
        {
            if (mbMaximized)
            {
                mbMaximized = FALSE;
                NewMessage.wType = PM_SIZE;
                NewMessage.Rect = mRestore;
                Message(NewMessage);
                Parent()->Draw();
            }
        }
        break;

   #ifdef PEG_KEYBOARD_SUPPORT
    case PM_KEY:
        if (Parent() == Presentation() &&
            Mesg.iData == PK_F4 &&
            (Mesg.lData & KF_CTRL))
        {
            NewMessage.wType = PM_CLOSE;
            NewMessage.pTarget = this;
            MessageQueue()->Push(NewMessage);
        }
        else
        {
            return PegThing::Message(Mesg);
        }
        break;
   #endif

    case PM_CLOSE:
        Destroy(this);
        return(IDB_CLOSE);

    case PEG_SIGNAL(IDB_CLOSE, PSF_CLICKED):
    case PEG_SIGNAL(IDB_OK, PSF_CLICKED):
    case PEG_SIGNAL(IDB_CANCEL, PSF_CLICKED):
    case PEG_SIGNAL(IDB_YES, PSF_CLICKED):
    case PEG_SIGNAL(IDB_NO, PSF_CLICKED):
    case PEG_SIGNAL(IDB_RETRY, PSF_CLICKED):
    case PEG_SIGNAL(IDB_ABORT, PSF_CLICKED):
    case PEG_SIGNAL(IDB_APPLY, PSF_CLICKED):
        Destroy(this);
        return(Mesg.iData);

    default:
        return (PegThing::Message(Mesg));
    }
    return (Result);
}
Пример #6
0
/*--------------------------------------------------------------------------*/
SIGNED PegWindow::GlobalModalExecute(void)
{
    PegMessage pSend;
    PegThing *Current;
    mbModal = TRUE;
    SIGNED iReturn = 0;

    if (CURRENT_TASK != PEG_TASK_PTR)
    {
        Presentation()->BeginSubTaskExecute(this);
    }

    CapturePointer();
    Presentation()->Add(this);

    while(1)
    {
        MessageQueue()->Pop(&pSend);

        switch (pSend.wType)
        {
        case PM_LBUTTONDOWN:
        case PM_RBUTTONDOWN:
        case PM_LBUTTONUP:
        case PM_RBUTTONUP:
        case PM_POINTER_MOVE:

           #if defined(PEG_MOUSE_SUPPORT)
            if (pSend.wType == PM_POINTER_MOVE)
            {
                Screen()->SetPointer(pSend.Point);
            }
           #endif

            if (muMoveMode)
            {
                Message(pSend);
                break;
            }

            if (Presentation()->First() == this)
            {
                Current = Presentation()->GetPointerOwner();
                    
                if (Current != this)
                {
                    // One of my children has captured the pointer,
                    // let him have the pointer messages:

                    iReturn = Current->Message(pSend);
                }
                else
                {
                    if (mReal.Contains(pSend.Point))
                    {
                        Current = Presentation()->FindLowestThingContaining(this, pSend.Point);

                        if (Current)
                        {
                            if (Current != Presentation()->LastPointerOver())
                            {
                                if (Presentation()->LastPointerOver())
                                {
                                    Presentation()->LastPointerOver()->Message(PegMessage(PM_POINTER_EXIT));
                                }
                                Presentation()->LastPointerOver(Current);
                                Current->Message(PegMessage(PM_POINTER_ENTER));
                            }

                            if ((pSend.wType == PM_LBUTTONDOWN || pSend.wType == PM_RBUTTONDOWN) &&
                                Current != Presentation()->GetCurrentThing())
                            {
                                if (Current->StatusIs(PSF_ACCEPTS_FOCUS))
                                {
                                    Presentation()->MoveFocusTree(Current);
                                }
                            }
                            iReturn = Current->Message(pSend);
                        }
                    }
                }
            }
            else
            {
                // If we get here, it means another task is modally executing
                // a window, and it is now on top. Try to pass mouse messages
                // to that task:

                if (CURRENT_TASK == PEG_TASK_PTR)
                {
                    Presentation()->RouteMessageToTask(&pSend);
                }
            }
            break;

       #ifdef PEG_KEYBOARD_SUPPORT
        case PM_KEY:
            if (pSend.iData == PK_TAB && (pSend.lData & KF_CTRL))
            {
                break;
            }
            // fall throught to the default case:
       #endif
   
        default:
            iReturn = Presentation()->DispatchMessage(this, &pSend);
            break;
        }
        if (iReturn)
        {
            Presentation()->EndSubTaskExecute(this);
            ReleasePointer();
            return(iReturn);
        }
    }
}
Пример #7
0
/*--------------------------------------------------------------------------*/
SIGNED PegWindow::Execute(void)
{
    PegMessage pSend;
    mbModal = TRUE;
    SIGNED iReturn;

   #ifdef PEG_MULTITHREAD

    if (CURRENT_TASK != PEG_TASK_PTR)
    {
        Presentation()->BeginSubTaskExecute(this);
    }

   #endif

    if (!StatusIs(PSF_VISIBLE))
    {
        Presentation()->Add(this);
    }

    while(1)
    {
        MessageQueue()->Pop(&pSend);

        switch (pSend.wType)
        {
        case PM_LBUTTONDOWN:
        case PM_RBUTTONDOWN:
        case PM_LBUTTONUP:
        case PM_RBUTTONUP:
           #ifdef PEG_MULTITHREAD
            if (CURRENT_TASK == PEG_TASK_PTR)
            {
                if (Presentation()->RouteMessageToTask(&pSend))
                {
                    break;
                }
            }
           #endif

            if (mReal.Contains(pSend.Point) ||
                Presentation()->IsPointerCaptured())
            {
                //Presentation()->DispatchMessage(this, &pSend);
                Presentation()->DispatchMessage(Presentation(), &pSend);
            }
            break;

        case PM_POINTER_MOVE:
           #ifdef PEG_MULTITHREAD
            if (CURRENT_TASK == PEG_TASK_PTR)
            {
                if (Presentation()->RouteMessageToTask(&pSend))
                {
                    break;
                }
            }
           #endif
            if (mReal.Contains(pSend.Point) ||
                Presentation()->IsPointerCaptured())
            {
                //Presentation()->DispatchMessage(this, &pSend);
                Presentation()->DispatchMessage(Presentation(), &pSend);
            }
            else
            {
                if (mbShowPointer)
                {
                    SetPointerType(PPT_NORMAL);
                    mbShowPointer = 0;
                }
                Screen()->SetPointer(pSend.Point);
            }
            break;

       #ifdef PEGWIN32
        // When running under Windows, the user might close the development
        // window, without first closing the modal PEG window. There seems to be
        // no way to prevent this. In order to terminate correctly, we push
        // a couple of PM_EXIT messages, to be sure that all modal windows are
        // terminated, and PegPresentationManager returns.

        case PM_EXIT:
			{
				PegMessage NewMessage;
				NewMessage.wType = PM_EXIT;
				NewMessage.pTarget = Presentation();
				NewMessage.pSource = NULL;
				MessageQueue()->Push(NewMessage);
				MessageQueue()->Push(NewMessage);
				return(PM_EXIT);
			}
       #endif

       #ifdef PEG_KEYBOARD_SUPPORT
        case PM_KEY:
            if (pSend.iData == PK_TAB && (pSend.lData & KF_CTRL))
            {
                break;
            }
            // fall throught to the default case:
       #endif
   
        default:

           #ifdef PEG_MULTITHREAD
            if (CURRENT_TASK == PEG_TASK_PTR)
            {
                if (Presentation()->RouteMessageToTask(&pSend))
                {
                    break;
                }
            }
           #endif

            iReturn = Presentation()->DispatchMessage(this, &pSend);
            if (iReturn)
            {
               #ifdef PEG_MULTITHREAD
                Presentation()->EndSubTaskExecute(this);
               #endif
                return(iReturn);
            }
        }
    }
}
Пример #8
0
/*--------------------------------------------------------------------------*/
void PegWindow::SetScrollMode(UCHAR uMode)
{
    muScrollMode = uMode;

    if (uMode & WSM_CONTINUOUS)
    {
        AddStatus(PSF_CONTINUOUS_SCROLL);
    }
    else
    {
        RemoveStatus(PSF_CONTINUOUS_SCROLL);
    }

    if ((uMode & WSM_AUTOSCROLL) && StatusIs(PSF_VISIBLE))
    {
        CheckAutoScroll();
    }
    else
    {
	    if (uMode & WSM_HSCROLL)    
	    {
	        if (!mpHScroll)
	        {
	            mpHScroll = new PegHScroll();
	            mClient.wBottom -= PEG_SCROLL_WIDTH;
	
	            if ((uMode & WSM_VSCROLL) && !mpVScroll)
	            {
	                mClient.wRight -= PEG_SCROLL_WIDTH;
	                Add(mpHScroll);
	                mClient.wRight += PEG_SCROLL_WIDTH;
	            }
	            else
	            {
	                Add(mpHScroll);
	            }
	        }
	    }
	    else
	    {
	        if (mpHScroll)
	        {
	            Remove(mpHScroll);
	            mClient.wBottom += PEG_SCROLL_WIDTH;
	            MessageQueue()->Purge(mpHScroll);
	            delete mpHScroll;
	            mpHScroll = NULL;
	        }
	    }
	
	    if (uMode & WSM_VSCROLL)
	    {
	        if (!mpVScroll)
	        {
	            mpVScroll = new PegVScroll();
	            mClient.wRight -= PEG_SCROLL_WIDTH;
	            Add(mpVScroll);
	        }
	    }
	    else
	    {
	        if (mpVScroll)
	        {
	            Remove(mpVScroll);
	            mClient.wRight += PEG_SCROLL_WIDTH;
	            MessageQueue()->Purge(mpVScroll);
	            delete mpVScroll;
	            mpVScroll = NULL;
	        }
	    }
    }

    if (StatusIs(PSF_VISIBLE))
    {
        if (mpVScroll && mpHScroll)
        {
            Invalidate(mReal);
            BeginDraw();
            FillScrollCorner();
            EndDraw();
        }
        else
        {
            Invalidate(mReal);
            Draw();
        }
    }
}
Пример #9
0
/*--------------------------------------------------------------------------*/
BOOL PegWindow::CheckAutoScroll(void)
{
    PegScrollInfo mInfo;
    PegMessage NewMessage;

    BOOL bChange = FALSE;

    if (muScrollMode & WSM_AUTOHSCROLL)
    {
        GetHScrollInfo(&mInfo);
        if (mInfo.wMax - mInfo.wMin >= mInfo.wVisible)
        {
            // we need a horizontal scroll

            if (!mpHScroll)
	        {
	            mpHScroll = new PegHScroll();
	            mClient.wBottom -= PEG_SCROLL_WIDTH;
                Add(mpHScroll, FALSE);

                if (mpVScroll && StatusIs(PSF_VISIBLE))
                {
                    NewMessage.wType = PM_PARENTSIZED;
                    mpVScroll->Message(NewMessage);
                }
                bChange = TRUE;
            }
            else
            {
                if (mInfo.wCurrent + mInfo.wVisible > mInfo.wMax)
                {
                    NewMessage.wType = PM_HSCROLL;
                    NewMessage.lData = mInfo.wMax - mInfo.wVisible + 1;
                    NewMessage.iData = mInfo.wCurrent;
                    NewMessage.pTarget = this;
                    MessageQueue()->Push(NewMessage);
                    mInfo.wCurrent = (SIGNED) NewMessage.lData;
                }
                mpHScroll->Reset(&mInfo);
            }      
        }
        else
        {
            // we don't need an HScroll:
            if (mpHScroll)
            {
                mClient.wBottom += PEG_SCROLL_WIDTH;
	            Remove(mpHScroll, FALSE);
	            MessageQueue()->Purge(mpHScroll);
	            delete mpHScroll;
	            mpHScroll = NULL;
                bChange = TRUE;

                if (mpVScroll && StatusIs(PSF_VISIBLE))
                {
                     NewMessage.wType = PM_PARENTSIZED;
                     mpVScroll->Message(NewMessage);
                }

                NewMessage.wType = PM_HSCROLL;
                NewMessage.lData = mInfo.wMin;
                NewMessage.iData = mInfo.wCurrent;
                NewMessage.pTarget = this;
                MessageQueue()->Push(NewMessage);
            }
        }
    }

    if (muScrollMode & WSM_AUTOVSCROLL)
    {
        GetVScrollInfo(&mInfo);
        if (mInfo.wMax - mInfo.wMin >= mInfo.wVisible)
        {
            // we need a vertical scroll

            if (!mpVScroll) // don't have one?
            {
	            mpVScroll = new PegVScroll();
	            mClient.wRight -= PEG_SCROLL_WIDTH;
	            Add(mpVScroll, FALSE);

                if (mpHScroll && StatusIs(PSF_VISIBLE))
                {
                    NewMessage.wType = PM_PARENTSIZED;
                    mpHScroll->Message(NewMessage);
                }
                mpVScroll->Reset(&mInfo);
                bChange = TRUE;
            }
            else
            {
                if (mInfo.wCurrent + mInfo.wVisible > mInfo.wMax)
                {
                    NewMessage.wType = PM_VSCROLL;
                    NewMessage.lData = mInfo.wMax - mInfo.wVisible + 1;
                    NewMessage.iData = mInfo.wCurrent;
                    NewMessage.pTarget = this;
                    MessageQueue()->Push(NewMessage);
                    mInfo.wCurrent = (SIGNED) NewMessage.lData;
                }
                mpVScroll->Reset(&mInfo);
            }      
        }
        else
        {
            // here if we don't need a vertical scroll

            if (mpVScroll)  // do we have one?
            {
	            mClient.wRight += PEG_SCROLL_WIDTH;
	            Remove(mpVScroll, FALSE);
	            MessageQueue()->Purge(mpVScroll);
	            delete mpVScroll;
	            mpVScroll = NULL;
                bChange = TRUE;

                if (mpHScroll && StatusIs(PSF_VISIBLE))
                {
                    NewMessage.wType = PM_PARENTSIZED;
                    mpHScroll->Message(NewMessage);
                }

                NewMessage.wType = PM_VSCROLL;
                NewMessage.lData = mInfo.wMin;
                NewMessage.iData = mInfo.wCurrent;
                NewMessage.pTarget = this;
                MessageQueue()->Push(NewMessage);
            }
        }
    }
    if (bChange)
    {
        CheckAutoScroll();
    }
    return bChange;
}
Пример #10
0
void DrawLooper::MessageReceived(BMessage *msg)
{
	switch (msg->what) {
		case MSG_NEW_BUFFER: {	// New data buffer arrived, redraw oscilloscope
			int i, j;
			uint8 *p, *q, *r;
			int16 *buf;
			uint8 black = c_black;	// Local variables are faster
			uint8 *bits = this->bits;
			int xmod = this->xmod;

			// Prevent backlog
			BMessage *msg2;
			MessageQueue()->Lock();
			while ((msg2 = MessageQueue()->FindMessage(0L)) != NULL) {
				MessageQueue()->RemoveMessage(msg2);
				delete msg2;
			}
			MessageQueue()->Unlock();

			// Get pointer to data buffer
			if (msg->FindPointer("buffer", (void**) &buf) != B_NO_ERROR)
				break;

			// Draw dark green background
			memset(bits, c_dark_green, xmod * SCOPE_HEIGHT);

			// Draw data
			if (Stereo) {
				draw_data(buf, SCOPE_HEIGHT / 4, SCOPE_HEIGHT / 2);
				draw_data(buf + SCOPE_WIDTH * 2, SCOPE_HEIGHT * 3/4, SCOPE_HEIGHT / 2);
			} else
				if (RightChannel)
					draw_data(buf + SCOPE_WIDTH * 2, SCOPE_HEIGHT / 2, SCOPE_HEIGHT);
				else
					draw_data(buf, SCOPE_HEIGHT / 2, SCOPE_HEIGHT);

			// Draw grid and ticks
			for (i=0; i<NUM_Y_DIVS; i++) {
				memset(bits + xmod * (i * SCOPE_HEIGHT / NUM_Y_DIVS), black, SCOPE_WIDTH); 
				for (j=1; j<TICKS_PER_DIV; j++)
					memset(bits + SCOPE_WIDTH / 2 - 3 + xmod * (i * SCOPE_HEIGHT / NUM_Y_DIVS + j * SCOPE_HEIGHT / (NUM_Y_DIVS * TICKS_PER_DIV)), black, 7); 
			}
			memset(bits + xmod * (SCOPE_HEIGHT-1), black, SCOPE_WIDTH);

			p = bits;
			for (i=0; i<SCOPE_HEIGHT; i++) {
				for (j=0; j<NUM_X_DIVS; j++)
					p[j * SCOPE_WIDTH / NUM_X_DIVS] = black;
				p[SCOPE_WIDTH-1] = black;
				p += xmod;
			}
			p = bits + xmod * (SCOPE_HEIGHT / 2 - 3);
			q = bits + xmod * (SCOPE_HEIGHT / 4 - 2);
			r = bits + xmod * (SCOPE_HEIGHT * 3/4 - 2);
			for (i=0; i<NUM_X_DIVS; i++)
				for (j=1; j<TICKS_PER_DIV; j++) {
					int ofs = i * SCOPE_WIDTH / NUM_X_DIVS + j * SCOPE_WIDTH / (NUM_X_DIVS * TICKS_PER_DIV);
					p[ofs] = black;
					p[ofs + xmod] = black;
					p[ofs + xmod * 2] = black;
					p[ofs + xmod * 3] = black;
					p[ofs + xmod * 4] = black;
					p[ofs + xmod * 5] = black;
					p[ofs + xmod * 6] = black;
					q[ofs] = black;
					q[ofs + xmod] = black;
					q[ofs + xmod * 2] = black;
					q[ofs + xmod * 3] = black;
					q[ofs + xmod * 4] = black;
					r[ofs] = black;
					r[ofs + xmod] = black;
					r[ofs + xmod * 2] = black;
					r[ofs + xmod * 3] = black;
					r[ofs + xmod * 4] = black;
					bits[ofs + xmod * (SCOPE_HEIGHT * 3/16)] = black;
					bits[ofs + xmod * (SCOPE_HEIGHT * 13/16)] = black;
				}

			// Blit bitmap to screen
			if (the_window->LockWithTimeout(100000) == B_OK) {
				the_view->Draw(the_bounds);
				the_window->Unlock();
			}
			break;
		}

		default:
			BLooper::MessageReceived(msg);
	}
}
Пример #11
0
void MacWindow::MessageReceived(BMessage *msg)
{
	BMessage *msg2;

	switch (msg->what) {
		case MSG_REDRAW: {

			// Prevent backlog of messages
			MessageQueue()->Lock();
			while ((msg2 = MessageQueue()->FindMessage(MSG_REDRAW, 0)) != NULL) {
				MessageQueue()->RemoveMessage(msg2);
				delete msg2;
			}
			MessageQueue()->Unlock();
			
			// Convert Mac screen buffer to BeOS palette and blit
			const video_mode &mode = monitor.get_current_mode();
			BRect update_rect = BRect(0, 0, mode.x-1, mode.y-1);
			main_view->DrawBitmapAsync(the_bitmap, update_rect, update_rect);
			break;
		}

		case MSG_ABOUT_REQUESTED: {
			ShowAboutWindow();
			break;
		}

		case MSG_REF_5HZ:
			PrefsReplaceInt32("frameskip", frame_skip = 12);
			break;

		case MSG_REF_7_5HZ:
			PrefsReplaceInt32("frameskip", frame_skip = 8);
			break;

		case MSG_REF_10HZ:
			PrefsReplaceInt32("frameskip", frame_skip = 6);
			break;

		case MSG_REF_15HZ:
			PrefsReplaceInt32("frameskip", frame_skip = 4);
			break;

		case MSG_REF_30HZ:
			PrefsReplaceInt32("frameskip", frame_skip = 2);
			break;

		case MSG_REF_60HZ:
			PrefsReplaceInt32("frameskip", frame_skip = 1);
			break;

		case MSG_MOUNT: {
			BMenuItem *source = NULL;
			msg->FindPointer("source", (void **)&source);
			if (source)
				SysMountVolume(source->Label());
			break;
		}

#if DEBUGGER_AVAILABLE
		case MSG_DEBUGGER:
			extern int debugging;
			debugging = 1;
			regs.spcflags |= SPCFLAG_BRK;
			break;
#endif

		default:
			BDirectWindow::MessageReceived(msg);
	}
}