// set a pixel at position x, y 
int screenmatrix_setpixel(screenmatrix_t *screenmatrix, unsigned char x, unsigned char y, screenmatrix_color_t color) {
  //const int colorSendBufferSize = SCREENMATRIX_PIXEL_SIZE * SCREENMATRIX_PIXEL_SIZE;
  //static uint16_t colorSendBuffer[colorSendBufferSize];
  if (screenmatrix_isLegalMove(x, y)) {
    // set the value in the matrix
    screenmatrix->matrix[x][y] = color;
    
    // write the corresponding stm color into the send buffer
    uint16_t stm32Color = screenmatrix_convertColor(color);
    /*int i;
    for (i = 0; i < colorSendBufferSize; i++) {
      colorSendBuffer[i] = stm32Color;
      }*/
    
    // push the colors onto the LCD screen
    int startX = SCREENMATRIX_PIXEL_SIZE * x;
    int startY = SCREENMATRIX_PIXEL_SIZE * y;
    //ST7735_setAddrWindow(startX, startX + SCREENMATRIX_PIXEL_SIZE, startY, startY + SCREENMATRIX_PIXEL_SIZE, MADCTLGRAPHICS);
    //ST7735_pushColor(colorSendBuffer, colorSendBufferSize);
    rect_t r;
    initRect(&r, startX, startY, SCREENMATRIX_PIXEL_SIZE, SCREENMATRIX_PIXEL_SIZE, stm32Color);
    redrawRect(&r);
    return 1;
  }
  return 0;
}
Esempio n. 2
0
/** DialogControl::redrawRect()
 *
 *  Immediately redraws the specified rectangle in this control.
 *
 *  @param  The coordinates of the rectangle.
 *    Form 1:  A .Rect object.
 *    Form 2:  A .Point object and a .Point object.
 *    Form 3:  x1, y1, y1, y2
 *
 *  @param erase  [OPITONAL]  Whether the background should be erased first.
 *                The default is false.
 *
 *  @return  0 on success, 1 on error.
 *
 *  @note  Sets the .SystemErrorCode.
 */
RexxMethod2(RexxObjectPtr, dlgctrl_redrawRect, ARGLIST, args, CSELF, pCSelf)
{
    oodResetSysErrCode(context->threadContext);

    bool doErase = false;
    RECT r = {0};
    size_t arraySize;
    size_t argsUsed;

    if ( ! getRectFromArglist(context, args, &r, true, 1, 5, &arraySize, &argsUsed) )
    {
        return TheOneObj;
    }

    if ( arraySize > argsUsed + 1 )
    {
        return tooManyArgsException(context->threadContext, argsUsed + 1);
    }
    else if ( arraySize == (argsUsed + 1) )
    {
        // The object at argsUsed + 1 has to exist, otherwise arraySize would
        // equal argsUsed.
        RexxObjectPtr obj = context->ArrayAt(args, argsUsed + 1);

        logical_t erase;
        if ( ! context->Logical(obj, &erase) )
        {
            return notBooleanException(context->threadContext, argsUsed + 2, obj);
        }
        doErase = erase ? true : false;
    }

    return redrawRect(context, getDChCtrl(pCSelf), &r, doErase, true);
}
Esempio n. 3
0
void IgorEngine::handleOptionsMenu_paintCtrl() {
	static const char *textsStrTable1[] = {
		"Sound effects OFF",
		"Sound effects ON",
		"Sound effects UNAVAILABLE"
	};
	static int textsPosTable1[] = { 106, 110, 77 };
	int i = _gameState.configSoundEnabled;
	redrawRect(_screenTextLayer, 1, false);
	drawString(_screenTextLayer, textsStrTable1[i], textsPosTable1[i], 41 - 15, 0xF7, -1, 0);

	redrawRect(_screenTextLayer, 2, false);
	drawString(_screenTextLayer, "Only TEXT AVAILABLE", 93, 63 - 15, 0xF7, -1, 0);

	static const char *textsStrTable2[] = {
		"Music OFF",
		"Music ON",
		"Music UNAVAILABLE"
	};
	static int textsPosTable2[] = { 129, 133, 100 };
	i = 1;
	redrawRect(_screenTextLayer, 3, false);
	drawString(_screenTextLayer, textsStrTable2[i], textsPosTable2[i], 85 - 15, 0xF7, -1, 0);

	static const char *textsStrTable3[] = {
		"Text speed VERY SLOW",
		"Text speed SLOW",
		"Text speed NORMAL",
		"Text speed FAST",
		"Text speed VERY FAST"
	};
	static int textsPosTable3[] = { 93, 110, 102, 111, 94 };
	i = _gameState.talkSpeed - 1;
	redrawRect(_screenTextLayer, 4, true);
	drawString(_screenTextLayer, textsStrTable3[i], textsPosTable3[i], 107 - 15, 0xF6, -1, 0);
}
void CMainWindow::HandlePointerMoveBufferReady()
	{
	TPoint pnts[KPointerMoveBufferSize];
	TPtr8 ptr((TUint8 *) &pnts, sizeof(pnts));
	TInt numPnts = Window().RetrievePointerMoveBuffer(ptr);
	TRect redrawRect(Window().Position(), Window().Size());

	CWindowGc* gc = SystemGc();
	gc->Activate(Window());
	gc->SetPenColor(KRgbBlue);
	gc->SetPenSize(TSize(2, 2));
	Window().Invalidate();
	Window().BeginRedraw(redrawRect); // N.B. Redrawer::RunL() gets called with this 
	// rectangle - must give it a non-zero value
	for (TInt index = 0; index < numPnts; index++)
		{
		gc->DrawLineTo(pnts[index]);
		}
	Window().EndRedraw();
	gc->Deactivate();
	}
Esempio n. 5
0
static Bool moverHandler(EVENT evt, long param, int more, CITWINDOW *wnd)
	{
	switch (evt)
		{
		case EVT_DRAWINT:
			{
			if (wnd->flags.visible)
				{
				if (buildClipArray(wnd))
					{
					CitWindowOutStr(wnd, 2, 1, getcwmsg(1), cfg.attr);
					freeClipArray();
					}
				}

			break;
			}

		case EVT_MSTAT:
			{
			if (more & 1)
				{
				SRECT rect = wnd->parent->extents;
				SRECT rect2 = rect;
				int i, h, w;

				h = rect.bottom - rect.top + 1;
				w = rect.right - rect.left + 1;

				i = long_HI(param);

				i = min(i, (scrollpos + 1 - h));
				rect.top = i;
				rect.bottom = rect.top + h - 1;

				i = long_LO(param);

				i = min(i, (conCols - w));
				rect.left = i;
				rect.right = rect.left + w - 1;

				if ((wnd->parent->func)(EVT_CHECKNEWEXT, (long) &rect, 0,
						wnd->parent))
					{
					wnd->parent->extents = rect;

					(wnd->parent->func)(EVT_DRAWALL, 0, 0, wnd->parent);
					redrawRect(rect2);
					}
				}
			else
				{
				destroyCitWindow(wnd, FALSE);
				}

			break;
			}

		case EVT_INKEY:
			{
			if (param == ESC)
				{
				destroyCitWindow(wnd, FALSE);
				}
			else if (param > 256)
				{
				switch (param >> 8)
					{
					case CURS_DOWN:
						{
						if (wnd->parent->extents.bottom < scrollpos)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.top++;
							rect.bottom++;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}
							}

						break;
						}

					case CURS_UP:
						{
						if (wnd->parent->extents.top)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.top--;
							rect.bottom--;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}
							}

						break;
						}

					case CURS_LEFT:
						{
						if (wnd->parent->extents.left)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.left--;
							rect.right--;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}
							}

						break;
						}

					case CURS_RIGHT:
						{
						if (wnd->parent->extents.right < conCols - 1)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.left++;
							rect.right++;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}
							}

						break;
						}
					}
				}

			break;
			}

		default:
			{
			return (defaultHandler(evt, param, more, wnd));
			}
		}

	return (TRUE);
	}
Esempio n. 6
0
static Bool sizerHandler(EVENT evt, long param, int more, CITWINDOW *wnd)
	{
	switch (evt)
		{
		case EVT_DRAWINT:
			{
			if (wnd->flags.visible)
				{
				if (buildClipArray(wnd))
					{
					CitWindowOutStr(wnd, 2, 1, getcwmsg(2), cfg.attr);
					freeClipArray();
					}
				}

			break;
			}

		case EVT_MSTAT:
			{
			if (more & 1)
				{
				SRECT rect = wnd->parent->extents;
				SRECT rect2 = rect;

				switch (((sizerData *) wnd->LocalData)->c)
					{
					case TOPLEFT:
						{
						int i;

						i = long_HI(param);

						i = min(i, (rect.bottom - 1));
						rect.top = i;

						i = long_LO(param);

						i = min(i, (rect.right - 10));
						rect.left = i;

						break;
						}

					case BOTTOMRIGHT:
						{
						int i;

						i = long_HI(param);

						i = max(i, (rect.top + 1));
						i = min(i, scrollpos);
						rect.bottom = i;

						i = long_LO(param);

						i = max(i, (rect.left + 10));
						rect.right = i;

						break;
						}

					case TOPRIGHT:
						{
						int i;

						i = long_HI(param);

						i = min(i, (rect.bottom - 1));
						rect.top = i;

						i = long_LO(param);

						i = max(i, (rect.left + 10));
						rect.right = i;

						break;
						}

					case BOTTOMLEFT:
						{
						int i;

						i = long_HI(param);

						i = max(i, (rect.top + 1));
						i = min(i, scrollpos);
						rect.bottom = i;

						i = long_LO(param);

						i = min(i, (rect.right - 10));
						rect.left = i;

						break;
						}
					}

				if ((wnd->parent->func)(EVT_CHECKNEWEXT, (long) &rect, 0,
						wnd->parent))
					{
					wnd->parent->extents = rect;

					(wnd->parent->func)(EVT_DRAWALL, 0, 0, wnd->parent);
					redrawRect(rect2);
					}
				}
			else
				{
				destroyCitWindow(wnd, FALSE);
				}

			break;
			}

		case EVT_INKEY:
			{
			if (param == ESC)
				{
				destroyCitWindow(wnd, FALSE);
				}
			else if (param > 256)
				{
				switch (param >> 8)
					{
					case CURS_DOWN:
						{
						if (wnd->parent->extents.bottom < scrollpos)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.bottom++;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}
							}

						break;
						}

					case CURS_UP:
						{
						if (wnd->parent->extents.bottom >
								wnd->parent->extents.top + 1)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.bottom--;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}
							}

						break;
						}

					case CURS_LEFT:
						{
						if (wnd->parent->extents.right >
								wnd->parent->extents.left + 5)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.right--;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}
							}

						break;
						}

					case CURS_RIGHT:
						{
						if (wnd->parent->extents.right < conCols - 1)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.right++;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}

							wnd->parent->extents.right++;
							(wnd->parent->func)(EVT_DRAWALL, param, 0, wnd->parent);
							}

						break;
						}
					}
				}

			break;
			}

		default:
			{
			return (defaultHandler(evt, param, more, wnd));
			}
		}

	return (TRUE);
	}
void CTConeInvalidateAppUi::RunTestStepL(TInt aStepNum)
	{
		#define DRAW_SIZE   48
		#define DRAW_BORDER 8
		#define PARENT_HALF_WIDTH 64
		
		//Clear the offscreen bitmap to solid black, so that at each iteration we can see what is drawn during that frame.
		CTransGc *pOffGc = ((CTransGc*)iViewControl->iOffScreen->OffScreenGc());
		pOffGc->SetOrigin(TPoint(0,0));
		pOffGc->SetAlphaLevel(KAlphaOpaque);
		pOffGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
		pOffGc->SetBrushColor(TRgb(0,0,0,0));
		pOffGc->Clear();		

		//1/4 transparent (or 3/4 opaque).
		pOffGc->SetAlphaLevel(192);

		//Clear the 2nd offscreen bitmap 
		pOffGc = ((CTransGc*)iViewControl->iOffScreen2->OffScreenGc());
		pOffGc->SetOrigin(TPoint(0,0));
		pOffGc->SetAlphaLevel(KAlphaOpaque);
		pOffGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
		pOffGc->SetBrushColor(TRgb(0,0,0,0));
		pOffGc->Clear();		
		//1/4 transparent (or 3/4 opaque).
		pOffGc->SetAlphaLevel(192);

		TPoint drawOffset;		
		
		TInt Phase = aStepNum - 1;
				
		if (Phase<KNumTestSteps)
		{			
			//Create the control and setup its parameters. The top 2 bits of Phase define window ownership combination for 
			//the 2 sub levels of the animated control. 
			TInt OwnerMask = (Phase>>2);
			//The LSB is set to 1 (the parent which is always window owning). 
			iViewControl->CreateComponentControlL(1, OwnerMask<<1|1);
			
			//Set backgrounds for the original control and the overlayed controls.
	    	iViewControl->iControl->SetBackground(iViewControl->iControl);
	    	iViewControl->iControlImage->SetBackground(iViewControl->iControlImage);
	    	iViewControl->iControlImage2->SetBackground(iViewControl->iControlImage2);

			//The lower two bits of Phase define the redraw rectangle position in the sequence (tl, tr, br, bl) and repeats this cycle.		
			
			TInt Region = Phase & 3;
																						
			switch (Region)
				{
				case 0: drawOffset = TPoint(DRAW_BORDER,    			   DRAW_BORDER); 					break;
				case 1: drawOffset = TPoint(PARENT_HALF_WIDTH+DRAW_BORDER, DRAW_BORDER);					break;
				case 2: drawOffset = TPoint(PARENT_HALF_WIDTH+DRAW_BORDER, PARENT_HALF_WIDTH+DRAW_BORDER);	break;
				case 3: drawOffset = TPoint(DRAW_BORDER,    			   PARENT_HALF_WIDTH+DRAW_BORDER);	break;
				default : break;
				}
	
	
			INFO_PRINTF6(_L("Invalidate rect: Step=%2d, OwnerMask=%1d%1d%1d, Region=%1d"), aStepNum, OwnerMask>>1&1, OwnerMask&1, 1, Region);

			//Set up the redraw rectangle for this test run																		
			TRect redrawRect(drawOffset, TSize(DRAW_SIZE,DRAW_SIZE));
			
			//Draw the main control, before we set any special Gcs
			iViewControl->iControl->DrawNow();
								
			//Now set each control to an offscreen Gc in "chequer board fashion"
			
			for (TInt j=0; j<4; j++)
				for (TInt k=0; k<4; k++)
				{
					CCoeControl *pControl = iViewControl->iControl-> ComponentControl(j)->
																   ComponentControl(k);
												
					if ((k==0)||(k==3)) //is the chequer pattern
						pControl->SetGc(iViewControl->iOffScreen->OffScreenGc());
					else																												
						pControl->SetGc(iViewControl->iOffScreen2->OffScreenGc());														
					

				}

			
			//and set the control without a background, for the subrect redraw
			iViewControl->iControl->SetBackground(NULL);			
																
			for (TInt i=0; i<50; i++) //Animation cycle whilst the rectangular region is being updated
				{
				
				//Reset the Gcs' window cache variable, required every redraw cycle so the Gc knows when a clear is required
				((CTransGc*)iViewControl->iOffScreen->OffScreenGc())->iWin = NULL;
				((CTransGc*)iViewControl->iOffScreen2->OffScreenGc())->iWin = NULL;
				
				//Animate the controls
				iViewControl->iControl->AnimateComponents();		

				//Instruct the control the redraw the desired rectangle
				iViewControl->iControl->DrawNow(redrawRect);						

				//Draw the whole offscreen image so that we can check the correct part of the rectangle was drawn
				iViewControl->iControlImage->DrawNow();
				
				//Draw the offscreen image blended over background.
				iViewControl->iControlImage2->DrawNow();
				
				User::After(TTimeIntervalMicroSeconds32(1000));			
				}
		}