void RButton::paintEvent(QPaintEvent *e)
{
    RPushButton::paintEvent(e);
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing, true);
    if (!m_drawPosition == 0) drawClock(&painter);
}
void QTodoClock::paintEvent( QPaintEvent * )
{
	if ( autoMask() )
		return;
	QPainter paint( this );
	paint.setBrush( colorGroup().foreground() );
	drawClock( &paint );
}
Exemple #3
0
/*
 * UpdateDOSClock - update the clock, if we couldn't hook timer interrupts
 */
void UpdateDOSClock( void )
{
    if( !noTimer ) {
        return;
    }
    setClockTime();
    ClockTicks++;
    drawClock();

} /* UpdateDOSClock */
Exemple #4
0
/**************************************************************************//**
 * @brief  Increments the clock quickly while PB1 is pressed.
 *         A callback is used to update either the analog or the digital clock.
 *
 *****************************************************************************/
void fastForwardTime(void (*drawClock)(struct tm*, bool redraw))
{
  unsigned int i = 0;
  struct tm    *time; 
  
  /* Wait 2 seconds before starting to adjust quickly */
  int waitForPcntIrqCount = pcntIrqCount + 2;

  while (pcntIrqCount != waitForPcntIrqCount)
  {
    /* Return if the button is released */
    if (GPIO_PinInGet(gpioPortC, 9) == 1) {
      timeIsFastForwarding = false;
      return;
    }

    /* Keep updating the second counter while waiting */
    if (updateDisplay)
    {
      time = localtime((time_t const *) &curTime);
      drawClock(time, true);
    }

    EMU_EnterEM2(false);
  }

  /* Keep incrementing the time while the button is held */
  while (GPIO_PinInGet(gpioPortC, 9) == 0)
  {
    if (i % 1000 == 0)
    {
      /* Increase time by 1 minute (60 seconds). */
      curTime += 60;

      time = localtime((time_t const *) &curTime);
      drawClock(time, true);
    }
    i++;
  }
  timeIsFastForwarding = false;
}
Exemple #5
0
/*
 * handleInt1c - int 0x1c handler (clock timer)
 */
static void interrupt handleInt1c( void )
{
    ClockTicks++;
    cTick1--;
    if( cTick1 == 0 ) {
        cTick2--;
        if( cTick2 == 0 ) {
            cTick2 = 5;
            cTick1 = 19;
        } else {
            cTick1 = 18;
        }
        tSec2++;
        if( tSec2 > '9' ) {
            tSec2 = '0';
            tSec1++;
            if( tSec1 > '5' ) {
                tSec1 = '0';
                tMin2++;
                if( tMin2 > '9' ) {
                    tMin2 = '0';
                    tMin1++;
                    if( tMin1 > '5' ) {
                        tMin1 = '0';
                        tHour2++;
                        if( tHour2 > '9' ) {
                            tHour2 = '0';
                            tHour1++;
                        } else if( tHour2 == '4' && tHour1 == '2' ) {
                            tHour2 = tHour1 = '0';
                        }
                    }
                }
            }
        }
        drawClock();
    }
    if( EditFlags.ClockActive && EditFlags.SpinningOurWheels && EditFlags.Spinning ) {
        *SpinLoc = SpinData[SpinCount];
        SpinCount++;
        if( SpinCount >= 4 ) {
            SpinCount = 0;
        }
    }

#if defined( _M_I86 ) || defined( __4G__ )
    _chain_intr( oldInt1c );
#endif

} /* handleInt1c */
void QTodoClock::updateMask()  // paint clock mask
{
	QBitmap bm( size() );
	bm.fill( color0 );                  //transparent

	QPainter paint;
	paint.begin( &bm, this );
	paint.setBrush( color1 );           // use non-transparent color
	paint.setPen( color1 );

	drawClock( &paint );

	paint.end();
	setMask( bm );
}
Exemple #7
0
void PILHandler(struct isrregs *r) {
  static uint32_t totalTicks = 0;
  uint32_t time_hours, time_minutes, time_seconds;

  //one tick
  totalTicks++;

  //rough conversion to total seconds
  time_seconds = totalTicks / 18;

  //number of hours
  time_hours = time_seconds / 3600;
  time_seconds %= 3600;

  //number of minutes
  time_minutes = time_seconds / 60;
  time_seconds %= 60;

  //draw the clock
  drawClock(time_hours, time_minutes, time_seconds);
  
  return;
}
Exemple #8
0
static void draw()
{
	glfwGetWindowSize(window, &winWidth, &winHeight);
	glfwGetFramebufferSize(window, &fbWidth, &fbHeight);

	// Calculate pixel ration for hi-dpi devices.
	pxRatio = (float)fbWidth / (float)winWidth;

	// Update and render
	glViewport(0, 0, fbWidth, fbHeight);
	glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);

	nvgBeginFrame(vg, winWidth, winHeight, pxRatio);

	double t1 = glfwGetTime();
	drawClock(vg, winWidth, winHeight);
	double t2 = glfwGetTime();

	usleep(fmax((1.0 / fps - (t2 - t1)) * 1000000, 0));
	nvgEndFrame(vg);

	glfwSwapBuffers(window);
}
Exemple #9
0
void demo(MGLDC *dc)
{
	int				numpages,aPage,vPage;
	int				sizex,sizey,bits;
	rect_t			fullView,oldView;
	pixel_format_t	pf;
	palette_t		pal[256];
	MGLDC			*memdc;

	/* The first way to do simple page flipping is using two display
	 * pages for 'double' buffering. The MGL has functions to set the
	 * system into double buffered modes and flip pages for you, so
	 * this method is very easy. We use MGL_doubleBuffer() to change
	 * to double buffered mode and MGL_swapBuffers() to change display
	 * pages.
	 */
	if (!MGL_doubleBuffer(dc))
		MGL_fatalError("Double buffereing not available!");
	mainWindow(dc,"Page Flip Demo");
	statusLine("Method 1: Double buffering with two pages");
	MGL_swapBuffers(dc,true);

	/* Draw to the hidden page */
	mainWindow(dc,"Page Flip Demo");
	statusLine("Method 1: Double buffering with two pages");

	initAnimation();
	do {
		/* Clear the entire display device before drawing the next frame */
		MGL_clearViewport();

		/* Draw the clock at the current location and move it */
		drawClock();
		moveClock();

		/* Swap the display buffers */
		MGL_swapBuffers(dc,true);
		} while (!checkEvent());
	waitEvent();

	/* Return to single buffered mode */
	MGL_singleBuffer(dc);

	/* The second way to use page flipping is with multiple display
	 * pages (3+) to do multi-buffering. Because we are using multiple
	 * display pages, we can turn off the wait for retrace flag when we
	 * swap visual pages. In order for triple buffering to work properly,
	 * we need to be doing a complete re-paint of the screen each frame
	 * without doing a screen clear (otherwise you will see flicker).
	 * Games like Quake and Duke3D repaint the entire frame from top to
	 * bottom without any overdraw, which allows them to use triple
	 * buffering techniques like this. We simulate this here by rendering
	 * to a system buffer and blitting to the screen constantly to achieve
	 * a similar effect for this sample program.
	 *
	 * Note that VBE/Core 3.0 and VBE/AF 2.0 include full support for
	 * hardware triple buffering that can be used to eliminate this problem.
	 * When these standards are ratified, the MGL will be updated to support
	 * this and you will be able to do 'real' triple buffering without
	 * any flicker on the screen.
	 */
	numpages = MGL_maxPage(dc)+1;
	if (numpages < 3)
		return;

	/* Get the display device size, color depth and pixel format so that we
	 * can create a compatible memory device context. Note that we also
	 * need to copy the palette from the display DC to the memory DC.
	 */
	sizex = MGL_sizex(dc);
	sizey = MGL_sizey(dc);
	bits = MGL_getBitsPerPixel(dc);
	MGL_getPixelFormat(dc,&pf);
	if ((memdc = MGL_createMemoryDC(sizex+1,sizey+1,bits,&pf)) == NULL)
		MGL_fatalError(MGL_errorMsg(MGL_result()));
	if (bits == 8) {
		MGL_getPalette(dc,pal,256,0);
		MGL_setPalette(memdc,pal,256,0);
		MGL_realizePalette(memdc,256,0,true);
        }
	MGL_makeCurrentDC(memdc);

	/* Make the fullViewport for the display DC the full screen, as the
	 * above code has changed it to a smaller value.
	 */
	fullView.left = 0;
	fullView.top = 0;
	fullView.right = sizex+1;
	fullView.bottom = sizey+1;
	MGL_setViewportDC(dc,fullView);

	/* Draw the main window display on the memory buffer */
	mainWindow(memdc,"Page Flip Demo");
	statusLine("Method 2: Multi-buffering with 3+ pages");
	initAnimation();
	MGL_setActivePage(dc,aPage = 1);
	MGL_setVisualPage(dc,vPage = 0,false);
	MGL_getViewport(&oldView);
	do {
		/* Clear the fullViewport before drawing the next frame */
		MGL_clearViewport();

		/* Draw the clock at the current location and move it */
		drawClock();
		moveClock();

		/* Copy the memory device to the display device */
		MGL_setViewport(fullView);
		MGL_bitBlt(dc,memdc,fullView,0,0,MGL_REPLACE_MODE);
		MGL_setViewport(oldView);

		/* Swap the hardware display buffers */
		aPage = (aPage+1) % numpages;
		vPage = (vPage+1) % numpages;
		MGL_setActivePage(dc,aPage);
		MGL_setVisualPage(dc,vPage,false);
		} while (!checkEvent());
	waitEvent();
}