Beispiel #1
0
void CSizingControlBar::OnNcPaint()
{
    // get window DC that is clipped to the non-client area
    CWindowDC dc(this); // the HDC will be released by the destructor

    CRect rcClient, rcBar;
    GetClientRect(rcClient);
    //mpc-hc custom code start
    //ClientToScreen(rcClient);
    //mpc-hc custom code end
    GetWindowRect(rcBar);
    //mpc-hc custom code start
    // Convert to client coordinates to account for possible RTL layout
    ScreenToClient(rcBar);
    //mpc-hc custom code end
    rcClient.OffsetRect(-rcBar.TopLeft());
    rcBar.OffsetRect(-rcBar.TopLeft());

    CDC mdc;
    mdc.CreateCompatibleDC(&dc);
    
    CBitmap bm;
    bm.CreateCompatibleBitmap(&dc, rcBar.Width(), rcBar.Height());
    CBitmap* pOldBm = mdc.SelectObject(&bm);

    // draw borders in non-client area
    CRect rcDraw = rcBar;
    DrawBorders(&mdc, rcDraw);

    // erase the NC background
//mpc-hc custom code start
    mdc.FillRect(rcDraw, CBrush::FromHandle(
        (HBRUSH) GetClassLongPtr(m_hWnd, GCLP_HBRBACKGROUND)));
//mpc-hc custom code end

    if (m_dwSCBStyle & SCBS_SHOWEDGES)
    {
        CRect rcEdge; // paint the sizing edges
        for (int i = 0; i < 4; i++)
            if (GetEdgeRect(rcBar, GetEdgeHTCode(i), rcEdge))
                mdc.Draw3dRect(rcEdge, ::GetSysColor(COLOR_BTNHIGHLIGHT),
                    ::GetSysColor(COLOR_BTNSHADOW));
    }

    NcPaintGripper(&mdc, rcClient);

    // client area is not our bussiness :)
    dc.IntersectClipRect(rcBar);
    dc.ExcludeClipRect(rcClient);

    dc.BitBlt(0, 0, rcBar.Width(), rcBar.Height(), &mdc, 0, 0, SRCCOPY);

    mdc.SelectObject(pOldBm);
    bm.DeleteObject();
    mdc.DeleteDC();
}
Beispiel #2
0
void CControlBar::DoPaint(CDC* pDC)
{
	ASSERT_VALID(this);
	ASSERT_VALID(pDC);

	// paint inside client area
	CRect rect;
	GetClientRect(rect);
	DrawBorders(pDC, rect);
}
Beispiel #3
0
void CDockBar::OnNcPaint()
{
	CWindowDC dc(this);

	// paint inside non-client area
	CRect rect;
	GetWindowRect(rect);
	rect.OffsetRect(-rect.left, -rect.top);
	DrawBorders(&dc, rect);
}
Beispiel #4
0
/**
 * @brief Toolbar paint function.
 */
void ToolBarXPThemes::DoPaint(CDC* pDC)
{
	ASSERT_VALID(this);
	ASSERT_VALID(pDC);

	// Paint inside the client area.
	CRect rect;
	GetClientRect(rect);
	DrawBorders(pDC, rect);
	DrawGripper(pDC, rect);
}
void CWinXPToolbar::DoPaint(CDC* pDC)
{
	ASSERT_VALID(this);
	ASSERT_VALID(pDC);

	//Paint the client area
	CRect rect;
	GetClientRect(rect);
	DrawBorders(pDC, rect);
	DrawGripper(pDC, rect);
}
Beispiel #6
0
void CSizingControlBar::OnNcPaint()
{
    // get window DC that is clipped to the non-client area
    CWindowDC dc(this);

    CRect rcClient, rcBar;
    GetClientRect(rcClient);
    ClientToScreen(rcClient);
    GetWindowRect(rcBar);
    rcClient.OffsetRect(-rcBar.TopLeft());
    rcBar.OffsetRect(-rcBar.TopLeft());

    CDC mdc;
    mdc.CreateCompatibleDC(&dc);
    
    CBitmap bm;
    bm.CreateCompatibleBitmap(&dc, rcBar.Width(), rcBar.Height());
    CBitmap* pOldBm = mdc.SelectObject(&bm);

    // draw borders in non-client area
    CRect rcDraw = rcBar;
    DrawBorders(&mdc, rcDraw);

    // erase the NC background
    mdc.FillRect(rcDraw, CBrush::FromHandle(
        (HBRUSH) GetClassLong(m_hWnd, GCL_HBRBACKGROUND)));

    if (m_dwSCBStyle & SCBS_SHOWEDGES)
    {
        CRect rcEdge; // paint the sizing edges
        for (int i = 0; i < 4; i++)
            if (GetEdgeRect(rcBar, GetEdgeHTCode(i), rcEdge))
                mdc.Draw3dRect(rcEdge, ::GetSysColor(COLOR_BTNHIGHLIGHT),
                    ::GetSysColor(COLOR_BTNSHADOW));
    }

    NcPaintGripper(&mdc, rcClient);

    // client area is not our bussiness :)
    dc.IntersectClipRect(rcBar);
    dc.ExcludeClipRect(rcClient);

    dc.BitBlt(0, 0, rcBar.Width(), rcBar.Height(), &mdc, 0, 0, SRCCOPY);

    // cycy for BoundsChecker Debug 
	//ReleaseDC(&dc);

    mdc.SelectObject(pOldBm);
    bm.DeleteObject();
    mdc.DeleteDC();
}
Beispiel #7
0
void CCoolBarCtrl::DoPaint(CDC* pDC)
{
	ASSERT_VALID( this );
	ASSERT_VALID( pDC );
	
	CRect rc;
	GetClientRect( &rc );
	
	if ( m_bBuffered || m_bmImage.m_hObject != NULL )
	{
		CDC* pBuffer = CoolInterface.GetBuffer( *pDC, rc.Size() );
		
		if ( CoolInterface.DrawWatermark( pBuffer, &rc, &m_bmImage ) )
		{
			CalcInsideRect( rc, FALSE );
			rc.left -= m_cyTopBorder;
			rc.top -= m_cxLeftBorder;
			rc.right += m_cyBottomBorder;
			rc.bottom += m_cxRightBorder;
		}
		else
		{
			DrawBorders( pBuffer, rc );
		}
		
		DoPaint( pBuffer, rc, TRUE );
		
		GetClientRect( &rc );
		pDC->BitBlt( 0, 0, rc.Width(), rc.Height(), pBuffer, 0, 0, SRCCOPY );
		pBuffer->SelectClipRgn( NULL );
	}
	else
	{
		DrawBorders( pDC, rc );
		DoPaint( pDC, rc, FALSE );
		pDC->FillSolidRect( &rc, CoolInterface.m_crMidtone );
	}
}
Beispiel #8
0
void CControlBar::EraseNonClient()
/********************************/
{
    CWindowDC   dc( this );
    CRect       rectClient;
    CRect       rectWindow;
    GetClientRect( &rectClient );
    ClientToScreen( &rectClient );
    GetWindowRect( &rectWindow );
    rectClient.OffsetRect( -rectWindow.left, -rectWindow.top );
    rectWindow.OffsetRect( -rectWindow.left, -rectWindow.top );
    dc.ExcludeClipRect( &rectClient );
    DrawBorders( &dc, rectWindow );
    DrawGripper( &dc, rectWindow );
}
Beispiel #9
0
void CCJSizeDockBar::EraseNonClient()
{
	CWindowDC dc(this);
	CRect rectClient;
	GetClientRect(rectClient);
	CRect rectWindow;
	GetWindowRect(rectWindow);
	ScreenToClient(rectWindow);
	rectClient.OffsetRect(-rectWindow.left, -rectWindow.top);
	dc.ExcludeClipRect(rectClient);
	rectWindow.OffsetRect(-rectWindow.left, -rectWindow.top);
	DrawBorders(&dc, rectWindow);
	dc.IntersectClipRect(rectWindow);
	SendMessage(WM_ERASEBKGND, (WPARAM)dc.m_hDC);
}
Beispiel #10
0
		void EquipmentUI::Draw(Player* player) {

			unsigned int lines = 2;

			Out::PrintlnAt(_position.x + 2, _position.y + lines, "Equipment");

			lines += 2;

			for (auto& equipment : player->getEquipmentSlots()) {
				Out::PrintlnAt(_position.x + 2, _position.y + lines, "%s", equipment.GetNameAndItem().c_str());
				lines++;
			}

			DrawBorders();
		}
Beispiel #11
0
void CMonitorBarCtrl::DoPaint(CDC* pDC)
{
	CRect rcClient;
	GetClientRect( &rcClient );

	CSize size = rcClient.Size();
	CDC* pMemDC = CoolInterface.GetBuffer( *pDC, size );
	if ( Settings.General.LanguageRTL )
		SetLayout( pMemDC->m_hDC, 0 );

	if ( ! CoolInterface.DrawWatermark( pMemDC, &rcClient, &m_bmWatermark ) )
		pMemDC->FillSolidRect( &rcClient, CoolInterface.m_crMidtone );

	if ( Skin.m_bBordersEnabled )
		DrawBorders( pMemDC, rcClient );
	else
		rcClient.DeflateRect( 2, 3, 2, 1 );

	for ( int nY = rcClient.top + 4 ; nY < rcClient.bottom - 4 ; nY += 2 )
	{
		pMemDC->Draw3dRect( rcClient.left + 3, nY, 4, 1,
			CoolInterface.m_crDisabled, CoolInterface.m_crDisabled );
	}

	DrawIconEx( pMemDC->GetSafeHdc(), rcClient.right - 16, rcClient.bottom - 16, m_hUpDown, 16, 16, 0, NULL, DI_NORMAL );

	m_pTxItem->SetHistory( rcClient.Width(), TRUE );
	m_pRxItem->SetHistory( rcClient.Width(), TRUE );

	CRect rcHistory( rcClient.left + 10, rcClient.top + 2, rcClient.right - 15, rcClient.bottom - 6 );
	PaintHistory( pMemDC, &rcHistory );

	CRect rcCurrent( rcClient.right - 7, rcClient.top + 2, rcClient.right - 2, rcClient.bottom - 6 );
	PaintCurrent( pMemDC, &rcCurrent, m_pRxItem );
	rcCurrent.OffsetRect( -6, 0 );
	PaintCurrent( pMemDC, &rcCurrent, m_pTxItem );

	m_rcTrack.SetRect( rcClient.left + 6, rcClient.bottom - 8, rcClient.right, rcClient.bottom - 2 );
	PaintTab( pMemDC );

	GetClientRect( &rcClient );
	pDC->BitBlt( rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height(),
		pMemDC, 0, 0, SRCCOPY );
	if ( Settings.General.LanguageRTL )
		SetLayout( pMemDC->m_hDC, LAYOUT_RTL );
}
Beispiel #12
0
void CCJToolBar::EraseNonClient(BOOL)
{
	// get window DC that is clipped to the non-client area
	CWindowDC dc(this);
	CRect rectClient;
	GetClientRect(rectClient);
	CRect rectWindow;
	GetWindowRect(rectWindow);
	ScreenToClient(rectWindow);
	rectClient.OffsetRect(-rectWindow.left, -rectWindow.top);
	dc.ExcludeClipRect(rectClient);     // draw borders in non-client area

	// draw borders in non-client area
	rectWindow.OffsetRect(-rectWindow.left, -rectWindow.top);
	DrawBorders(&dc, rectWindow);     // erase parts not drawn
	dc.IntersectClipRect(rectWindow);
	SendMessage(WM_ERASEBKGND, (WPARAM)dc.m_hDC);
	DrawGripper(dc);
}
Beispiel #13
0
void CSizingControlBar::OnNcPaint() 
{
    // get window DC that is clipped to the non-client area
    CWindowDC dc(this);

    CRect rcClient, rcBar;
    GetClientRect(rcClient);
    ClientToScreen(rcClient);
    GetWindowRect(rcBar);
    rcClient.OffsetRect(-rcBar.TopLeft());
    rcBar.OffsetRect(-rcBar.TopLeft());

    // client area is not our bussiness :)
    dc.ExcludeClipRect(rcClient);

    // draw borders in non-client area
    CRect rcDraw = rcBar;
    DrawBorders(&dc, rcDraw);

    // erase parts not drawn
    dc.IntersectClipRect(rcDraw);

    // erase NC background the hard way
    HBRUSH hbr = (HBRUSH)GetClassLong(m_hWnd, GCL_HBRBACKGROUND);
    ::FillRect(dc.m_hDC, rcDraw, hbr);

    if (m_dwSCBStyle & SCBS_SHOWEDGES)
    {
        CRect rcEdge; // paint the sizing edges
        for (int i = 0; i < 4; i++)
            if (GetEdgeRect(rcBar, GetEdgeHTCode(i), rcEdge))
                dc.Draw3dRect(rcEdge, ::GetSysColor(COLOR_BTNHIGHLIGHT),
                    ::GetSysColor(COLOR_BTNSHADOW));
    }

    if (m_cyGripper && !IsFloating())
        NcPaintGripper(&dc, rcClient);

    ReleaseDC(&dc);
}
void CWinXPToolbar::EraseNonClient(void)
{
	//Get DC that is clipped to the non-client area
	CWindowDC dc(this);
	CRect rectClient;
	GetClientRect(rectClient);
	CRect rectWindow;
	GetWindowRect(rectWindow);
	ScreenToClient(rectWindow);
	rectClient.OffsetRect(-rectWindow.left, -rectWindow.top);
	dc.ExcludeClipRect(rectClient);

	//Draw borders in the nclient area
	rectWindow.OffsetRect(-rectWindow.left, -rectWindow.top);
	DrawBorders(&dc, rectWindow);

	//Erase parts that don't get drawn
	dc.IntersectClipRect(rectWindow);
	SendMessage(WM_ERASEBKGND, (WPARAM)dc.m_hDC);

	//Draw the gripper
	DrawGripper(&dc, rectWindow);
}
void CGLPlanarWorkspace::paintGL() {
    if(!iImage) {
        glEnable(GL_BLEND);
        return;
    }
    iImage->PreparePlanarSlice('z',iPlanarCrossPosition);
    iImage->PreparePlanarSlice('x',iPlanarCrossPosition);
    iImage->PreparePlanarSlice('y',iPlanarCrossPosition);

    CGLWidget::GetInstance()->resetGLView();
    //Translate();
    DrawBorderRect();
    DrawInnerRect();
    int ypos= CGLWidget::GetInstance()->GetSize().y()
              -iSize.y()
              -iPosition.y()+GetBorders().bottom;
    glViewport(iPosition.x()+GetBorders().left,
               ypos ,
               iSize.x()-GetBorders().left-GetBorders().right
               , iSize.y()-GetBorders().top-GetBorders().bottom);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 1 , 0,1, 0.1, 90);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(0,0,-50);
    glDisable(GL_BLEND);

    iImage->DrawSliceZ();
    iImage->DrawSliceX();
    iImage->DrawSliceY();

    DrawBorders();

    glEnable(GL_BLEND);
}
Beispiel #16
0
/**
 * @brief Toolbar Erase non-client area and draw gripper.
 */
void ToolBarXPThemes::EraseNonClient()
{

	// Get window DC that is clipped to the non-client area.
	CWindowDC dc(this);
	CRect rectClient;
	GetClientRect(rectClient);
	CRect rectWindow;
	GetWindowRect(rectWindow);
	ScreenToClient(rectWindow);
	rectClient.OffsetRect(-rectWindow.left, -rectWindow.top);
	dc.ExcludeClipRect(rectClient);

	// Draw the borders in the non-client area.
	rectWindow.OffsetRect(-rectWindow.left, -rectWindow.top);
	DrawBorders(&dc, rectWindow);

	// Erase the parts that are not drawn.
	dc.IntersectClipRect(rectWindow);
	SendMessage(WM_ERASEBKGND, (WPARAM)dc.m_hDC);

	// Draw the gripper in the non-client area.
	DrawGripper(&dc, rectWindow);
}
Beispiel #17
0
int main(int argc, char **argv)
{
	int Inc = 1;
	struct BALL Ball = { 0 };
	struct PADDLE Paddle = { 0 };
	Bool DoLoadGame = false;
	int GotoLevel = 0;
	
	for (; Inc < argc; ++Inc)
	{ /*Argument parsing.*/
		if (!strcmp("--nocolor", argv[Inc]))
		{
			UseColor = false;
		}
		else if (!strcmp("--version", argv[Inc]))
		{
			printf("Bricktick brick breaker v" BRICKTICK_VERSION "\n"
					"By Subsentient.\n");
			fflush(NULL);
			exit(0);
		}
		else if (!strcmp("--help", argv[Inc]))
		{
			printf("Command line options:\n\t"
					"--help: Show this help.\n\t"
					"--nocolor: Run Bricktick with no color.\n\t"
					"--version: Display version and exit.\n");
			fflush(NULL);
			exit(0);
		}
		else if (!strncmp("--level=", argv[Inc], sizeof "--level=" - 1))
		{
			GotoLevel = atoi(argv[Inc] + sizeof "--level=" - 1);
			
			if (GotoLevel > sizeof Levels / sizeof *Levels)
			{
				fprintf(stderr, "The maximum level is %d.\n", sizeof Levels / sizeof *Levels); fflush(NULL);
				exit(1);
			}
		}
		else
		{
			fprintf(stderr, "Bad command line argument \"%s\".\n"
					"Use --help for command line options.\n", argv[Inc]);
			exit(1);
		}
	}
	
	
	initscr(); /*Fire up ncurses.*/
	
	if (COLS < BRICKTICK_MAX_X || LINES < BRICKTICK_MAX_Y)
	{
		endwin();
		fprintf(stderr, "Please use a console with a resolution of at least %dx%d.\n", BRICKTICK_MAX_X, BRICKTICK_MAX_Y);
		exit(1);
		
	}
	
	/*Color not supported.*/
	if (!has_colors()) UseColor = false;
	
	/*Various ncurses things.*/
	noecho();
	
	if (UseColor)
	{ /*Color fireup.*/
		start_color();
		init_pair(1, COLOR_CYAN, COLOR_BLACK);
		init_pair(2, COLOR_GREEN, COLOR_BLACK);
		init_pair(3, COLOR_BLACK, COLOR_WHITE);
		init_pair(4, COLOR_BLUE, COLOR_BLACK);
		init_pair(5, COLOR_GREEN, COLOR_BLACK);
		init_pair(6, COLOR_YELLOW, COLOR_BLACK);
		init_pair(7, COLOR_RED, COLOR_BLACK);
		
		
		/*Fire up colors for the bricks.*/
		init_pair(BRICK_COLORS_START, COLOR_GREEN, COLOR_BLACK);
		init_pair(BRICK_COLORS_START + 1, COLOR_BLUE, COLOR_BLACK);
		init_pair(BRICK_COLORS_START + 2, COLOR_YELLOW, COLOR_BLACK);
		init_pair(BRICK_COLORS_START + 3, COLOR_MAGENTA, COLOR_BLACK);
		init_pair(BRICK_COLORS_START + 4, COLOR_CYAN, COLOR_BLACK);
		init_pair(BRICK_COLORS_END, COLOR_RED, COLOR_BLACK);
	}
	
	/*Draw borders for consoles bigger than our 80x24 playing area.*/
	DrawBorders();
	
	/*Greeting.*/
GreetAsk:

	if (!GotoLevel)
	{ /*If they specified a level let them go straigth to game start.*/
		DrawGreeting();
		switch (getch())
		{
			case 27: /*27 is ESC key*/
				endwin();
				exit(0);
				break;
			case ' ':
				clear(); /*Wipe the message from the screen.*/
				DrawBorders(); /*Redraw borders.*/
				break;
			case 'o':
				clear();
				DrawBorders();
				DoLoadGame = true;
				LoadGame(&Ball, &Paddle);
				break;
			default:
				goto GreetAsk;
		}
	}
	else
	{
		clear();
		DrawBorders();
	}
	
	halfdelay(1);
	keypad(stdscr, true);
#if NCURSES_VERSION_MAJOR >= 5 && NCURSES_VERSION_MINOR >=4
	set_escdelay(25);
#endif
	curs_set(0);
	

	if (DoLoadGame)
	{
		DrawStats();
		DrawBall(&Ball);
		DrawPaddle(&Paddle);
		DrawAllBricks();
	}
	else
	{
		/*Show our initial lives count.*/
		DrawStats();
	
		/*Reset to level 1 if we haven't specified a level.*/
		SetLevel(GotoLevel ? GotoLevel : 1);
		
		ResetBall(&Ball);
		ResetPaddle(&Paddle);
		
		DrawBall(&Ball);
		DrawPaddle(&Paddle);
		ResetBricks();
		DrawAllBricks();
	}
	
	/*Wait for L key.*/
	WaitForUserLaunch();
	DrawAllBricks(); /*Redraw to fix goofing by WaitForUserLaunch().*/
	
	/*Set up the number generator.*/
	srand(time(NULL));

	/**
	 * Main loop for the game!
	 **/
Reloop:
	GameLoop(&Ball, &Paddle);
	
	DrawMessage("Really quit Bricktick? y/n");
	cbreak();
	
	/*When the game loop exits.*/
	switch (getch())
	{
		case 'y':
		case 'Y':
			break;
		default:
			DeleteMessage();
			refresh();
			halfdelay(1);
			DrawAllBricks(); /*Fix damage to brick display resulting from the message.*/
			goto Reloop;
			break;
	}
	DeleteBall(&Ball);
	DeletePaddle(&Paddle);
	
	endwin();
	
	return 0;
}
Beispiel #18
0
static void GameLoop(struct BALL *const Ball, struct PADDLE *const Paddle)
{ /*Primary loop where most events get processed.*/
	
	struct BRICKSTRIKE Strike;
	int Key = 0;
	int SecTick = 0;
	Bool PaddleMovedLastTick;
	DirectionX PaddleMoveDir;
	int Inc = 0;
	Bool Flip = false;
	int SlowBallTicks = 0, BallNukeTicks = 0;
	
	while ((Key = getch()) != 27) /*27 is ESC*/
	{		
		if (SecTick == 10)
		{ /*We get score every second for just surviving.*/
			Score += 2;
			DrawStats();
			SecTick = 0;
		}
		++SecTick;

		if (Ball->Y == 1)
		{ /*We hit the ceiling.*/
			BounceBallY(Ball, DOWN);
		}
		else if (Ball->Y >= BRICKTICK_MAX_Y - 2)
		{ /*More happens when we hit the floor.*/
			if (!CheckBallHitPaddle(Ball, Paddle))
			{
				DeleteBall(Ball);
				Ball->Y = BRICKTICK_MAX_Y - 1;
				DrawBall(Ball);
				
				if (Lives == 1)
				{ /*We ran out of lives.*/
					ProcessGameOver(Ball, Paddle);
				}
				else
				{
					--Lives;
					DrawStats();
					
					WaitForUserLaunch();
							
					DeleteBall(Ball);
					DeletePaddle(Paddle);
					
					ResetBall(Ball);
					ResetPaddle(Paddle);
					
					DrawPaddle(Paddle);
					DrawBall(Ball);
					
					/*Redraw but don't reset.*/
					DrawAllBricks();
				}
			}
			else
			{
				BounceBallY(Ball, UP);
				
				if (PaddleMovedLastTick)
				{ /*We can "whack" the ball with our Paddle->*/
					Ball->DirX = PaddleMoveDir;
				}
				else
				{ /*We cut the paddle into thirds for the X direction after bounce.*/
#define PADDLE_THIRD (Paddle->Length / 3)
					if (Ball->X <= Paddle->X + PADDLE_THIRD)
					{
						Ball->DirX = LEFT;
					}
					else if (Ball->X  > Paddle->X + PADDLE_THIRD && Ball->X <= Paddle->X + (PADDLE_THIRD * 2))
					{
						/*Make whether we hit up or not as a chance.*/
						Bool StraightUp = rand() & 1;
						if (StraightUp) Ball->DirX = X_NEUTRAL;
					}
					else
					{
						Ball->DirX = RIGHT;
					}
				}
			}
		}
		PaddleMovedLastTick = false;
		/*Bounce off left and right walls.*/
		if (Ball->X >= BRICKTICK_MAX_X - 1)
		{
			Ball->X = BRICKTICK_MAX_X - 1;
			BounceBallX(Ball, LEFT);
		}
		else if (Ball->X <= 0)
		{
			Ball->X = 0;
			BounceBallX(Ball, RIGHT);
		}
			
	
		/*Check if a charm hit the paddle.*/
		for (Inc = 0; Inc < BRICK_MAX_NUMLINES * BRICK_MAX_PERLINE; ++Inc)
		{
			if (Charms[Inc].Type == CHARM_NONE || !Charms[Inc].Dropped || Charms[Inc].Y != BRICKTICK_MAX_Y - 2) continue;
			
			if (CheckCharmHitPaddle(Paddle, Charms + Inc))
			{
				void *Ptr = NULL;
				const char *const Strings[] = { "+1,000 Score", "+1 Lives",
											"10 Second Slow Ball", "3 second nuke mode" };
					
				switch (Charms[Inc].Type)
				{
					case CHARM_SCORE:
						Ptr = &Score;
						break;
					case CHARM_LIFE:
						Ptr = &Lives;
						break;
					case CHARM_SLOW:
						Ptr = &SlowBallTicks;
						break;
					case CHARM_NUKE:
						Ptr = &BallNukeTicks;
						break;
					default:
						break;
				}
				
				if (Charms[Inc].Type != CHARM_NONE)
				{ /*Show a message on what type of charm we have here.*/
					DrawMessage(Strings[Charms[Inc].Type - 1]); fflush(NULL);
					usleep(500000);
					DeleteMessage();
					DrawAllBricks();
					DrawStats();
				}
				
				/*Do the thing the charm does.*/
				ProcessCharmAction(Charms + Inc, Ptr);
			}
			
			/*In any case, we're done with it.*/
			DeleteCharm(Charms + Inc);
			Charms[Inc].Type = CHARM_NONE;
		}
		
		/*We hit a brick.*/
		if (BallStruckBrick(Ball, &Strike))
		{
			
			if (BallNukeTicks == 0) /*Nuclear ball passes through.*/
			{
				switch (Strike.StrikeV)
				{
					case STRIKE_TOP:
						Ball->DirY = UP;
						break;
					case STRIKE_BOTTOM:
						Ball->DirY = DOWN;
						break;
					default:
						break;
				}
				
				switch (Strike.StrikeH)
				{
					case STRIKE_LEFT:
						Ball->DirX = LEFT;
						break;
					case STRIKE_RIGHT:
						Ball->DirX = RIGHT;
						break;
					default:
					{
						if (Ball->DirX != X_NEUTRAL) break;
						else
						{
							Bool Dir = rand() & 1;
							Ball->DirX = (DirectionX)Dir;
						}
						break;
					}
				}
			}
			
			DeleteBrick(Strike.Brick);
			Score += 100;
			DrawStats();
			
			if (!BricksLeft())
			{ /*Move to next level.*/

				if (SetLevel(Level + 1))
				{ /*We have more levels to go before we win.*/
					DeleteAllBricks();
					DeleteAllCharms();
					DeleteBall(Ball);
					DeletePaddle(Paddle);
					DrawStats();
					
					Score += 1000; /*Reward for making it this far.*/
					Lives = BRICKTICK_NUMLIVES;
					
					ResetBall(Ball);
					ResetPaddle(Paddle);
					ResetBricks();
					
					DrawAllBricks();
					DrawPaddle(Paddle);
					WaitForUserLaunch();
					DrawBall(Ball);
					DrawAllBricks(); /*Redraw to fix WaitForUserLaunch() goofing.*/
				}
				else
				{ /*WE WON!!!!*/
					char WonBuf[256];
					
					snprintf(WonBuf, sizeof WonBuf, "You Won! Score is %d! Hit ESC to exit or space to play again.", Score);
					DrawMessage(WonBuf);
					
				WinRegetch:
					switch (getch())
					{
						case 27: /*27 is ESC*/
							endwin();
							exit(0);
							break;
						case ' ':
						{
							DeleteMessage();
							
							SetLevel(1);
							
							Lives = BRICKTICK_NUMLIVES;
							Score = 0;
							
							DeleteAllBricks();
							DeleteAllCharms();
							DeleteBall(Ball);
							DeletePaddle(Paddle);
							DrawStats();
							
							ResetBall(Ball);
							ResetPaddle(Paddle);
							ResetBricks();
							
							DrawAllBricks();
							DrawPaddle(Paddle);
							WaitForUserLaunch();
							DrawBall(Ball);
							DrawAllBricks(); /*Redraw to fix WaitForUserLaunch() goofing.*/

							continue; /*For the loop we are in.*/
						}
						default:
							goto WinRegetch;
					}
				}

				continue;
			}
			else
			{ /*Charm drops.*/
				struct CHARM *Charm = GetCharmByBrick(Strike.Brick);
				
				if (Charm)
				{ /*We DO have a charm for this brick.*/
					PerformCharmDrop(Charm); /*Mark it dropped.*/

					/*Now draw the charm.*/
					DrawCharm(Charm);
				}
			}
		}
		
		switch (Key)
		{ /*Paddle movement.*/
			case KEY_LEFT:
				MovePaddle(Paddle, LEFT);
				PaddleMovedLastTick = true;
				PaddleMoveDir = LEFT;
				break;
			case KEY_RIGHT:
				MovePaddle(Paddle, RIGHT);
				PaddleMovedLastTick = true;
				PaddleMoveDir = RIGHT;
				break;
			case 's': /*They want to save the game.*/
				if (SaveGame(Ball, Paddle))
				{
					DrawMessage("Game saved.");
				}
				else
				{
					DrawMessage("Failed to save game.");
				}
				fflush(NULL);
				usleep(500000);
				
				DeleteMessage();
				DrawAllBricks(); /*Redraw bricks if damaged.*/
				
				break;
			case 'o': /*They want us to load a game.*/
			{
				const Bool LoadedOk = LoadGame(Ball, Paddle);
				
				if (LoadedOk)
				{
					/*Restore the state.*/
					clear();
					DrawBorders(); /*Need to redraw these after clearing the screen.*/
					
					DrawBall(Ball);
					DrawPaddle(Paddle);
					DrawStats();
					DrawAllBricks();
					
					DrawMessage("Game loaded.");
				}
				else
				{
					DrawMessage("Failed to load game.");
				}

				fflush(NULL);
				usleep(500000);
				
				DeleteMessage();
				DrawAllBricks();
				break;
			}
			case ' ':
			{
				DrawMessage("PAUSED");
				cbreak();
				
			PauseRegetch:
				switch (getch())
				{
					case ' ':
						DeleteMessage();
						DrawAllBricks(); /*Redraw to fix what deleting the message messed up.*/
						halfdelay(1);
						break;
					case 27: /*27 is ESC*/
						endwin();
						exit(0);
						break;
					default:
						goto PauseRegetch;
				}
			}
			default:
				break;
		}
		
		Flip = !Flip;

		/*Ball movement, obviously. Flip is used to keep it at half speed if we got a 'slow' charm.*/
		if (Flip || SlowBallTicks == 0) MoveBall(Ball);
		
		/*Decrement slow ball ticks until zero, then the ball goes fast again.*/
		if (SlowBallTicks > 0) --SlowBallTicks;
		
		/*Decrement nuclear ball until ticks hit zero.*/
		if (BallNukeTicks > 0) --BallNukeTicks;
		
		/*Charm movement.*/		
		for (Inc = 0; Inc < BRICK_MAX_NUMLINES * BRICK_MAX_PERLINE; ++Inc)
		{
			if (Charms[Inc].Type == CHARM_NONE || !Charms[Inc].Dropped) continue;
			
			if (Flip) MoveCharm(Charms + Inc);
		}
		
		/*Redraw borders in case of terminal resize.*/
		DrawBorders();
	}
}
Beispiel #19
0
void CCellView::SelectCell(BPoint where)
{
	cell curCell, anchorCell, oldCurCell, tmpCell, prevCurCell;
	BPoint cPoint;
	range r, prevSel;
	BRegion lastSelectionRgn, newSelectionRgn;
	bool updateBorders = (fSelection.top == 1 && fSelection.bottom == kRowCount) ||
						 (fSelection.left == 1 && fSelection.right == kColCount);
	BMessage * current = Window()->CurrentMessage();
	int32 modifiers;
	FailOSErr(current->FindInt32("modifiers", &modifiers), errMessageMissing);

	prevSel = fSelection;
	prevCurCell = fCurCell;

	StClipCells clip(this);

	ClearAnts();

	cPoint = where;
	(void)GetCellHitBy(cPoint, curCell);

	if (!fEntering)
		HiliteSelection(false, false);

	if (!fEntering && modifiers & B_SHIFT_KEY)
	{
		if (curCell.v < fSelection.top)
			anchorCell.v = fSelection.bottom;
		else
			anchorCell.v = fSelection.top;
		if (curCell.h < fSelection.left)
			anchorCell.h = fSelection.right;
		else
			anchorCell.h = fSelection.left;

		fSelection.Set(std::min(anchorCell.h, curCell.h),
					   std::min(anchorCell.v, curCell.v),
					   std::max(anchorCell.h, curCell.h),
					   std::max(anchorCell.v, curCell.v));
	}
	else
	{
		anchorCell.h = r.right = r.left = curCell.h;
		anchorCell.v = r.bottom = r.top = curCell.v;
			
		fCurCell = curCell;
		fSelection = r;
	}

	if (!fEntering)
		HiliteSelection(false, true);

	DrawStatus();
	if (updateBorders)
		DrawBorders();

	oldCurCell = curCell;

	ulong buttons;
	GetMouse(&cPoint, &buttons);
	while (buttons)
	{
		(void)GetCellHitBy(cPoint, curCell);

		SelectionToRegion(lastSelectionRgn);

		if (curCell.v == anchorCell.v)
			r.bottom = r.top = curCell.v;
		else if (curCell.v < anchorCell.v)
		{
			r.top = curCell.v;
			r.bottom = anchorCell.v;
		}
		else
		{
			r.bottom = curCell.v;
			r.top = anchorCell.v;
		}

		if (curCell.h == anchorCell.h)
			r.right = r.left = curCell.h;
		else if (curCell.h < anchorCell.h)
		{
			r.left = curCell.h;
			r.right = anchorCell.h;
		}
		else
		{
			r.right = curCell.h;
			r.left = anchorCell.h;
		}

		if (fEntering && ((oldCurCell.v != curCell.v) || (oldCurCell.h != curCell.h)))
			ClearAnts();

		fSelection = r;
		SelectionToRegion(newSelectionRgn);

		if (!fEntering)
			ChangeSelection(&lastSelectionRgn, &newSelectionRgn);

		if (((fCurCell.v != fSelection.top) ||
			(fCurCell.h != fSelection.left)) && !fEntering)
			ClearAnts();
		fCurCell = fSelection.TopLeft();

		if (oldCurCell.v != curCell.v || oldCurCell.h != curCell.h)
		{
			DrawStatus();

			tmpCell = fCurCell;
			fCurCell = curCell;
			if (fEntering)
				fSelection = prevSel;
			AdjustScrollBars();
			ScrollToSelection();
			fSelection = r;
			fCurCell = tmpCell;
		}

		MarchAnts();

		oldCurCell = curCell;
		GetMouse(&cPoint, &buttons);
	}

	if (fEntering)
	{
		ClearAnts();
		fEditBox->EnterRange(fSelection);

		fSelection = prevSel;
		fCurCell = prevCurCell;
	}
	else
		fCurCell = fSelection.TopLeft();

	AdjustScrollBars();
	DrawStatus();
}
Beispiel #20
0
void
CCellView::SelectCol(BPoint where, int colNr)
{
	BPoint curPoint;
	cell oldAnts, curCurCell = fCurCell;
	range curSelection = fSelection, tmpSelection;
	long anchorCol, curCol, lastCol, y;
	float l, r;
	BRegion oldSel, newSel, oldClip;
	ulong modifiers = Window()->CurrentMessage()->FindInt32("modifiers");

	curPoint = where;

	curCol = colNr;

	ClearAnts();

	if (!fEntering && (modifiers & B_SHIFT_KEY))
	{
		if (curCol > fSelection.right)
			anchorCol = fSelection.left;
		else
			anchorCol = fSelection.right;
	}
	else
		anchorCol = curCol;
	lastCol = curCol;

	if (!fEntering)
		SelectionToRegion(oldSel);
	
	if (anchorCol > curCol)
		fSelection.Set(curCol, 1, anchorCol, kRowCount);
	else
		fSelection.Set(anchorCol, 1, curCol, kRowCount);
		
	fCurCell = fSelection.TopLeft();
	DrawStatus();
	DrawBorders();

	if (!fEntering)
	{
		SelectionToRegion(newSel);
		ChangeSelection(&oldSel, &newSel);
	}

	ulong buttons;
	GetMouse(&curPoint, &buttons);
	while (buttons)
	{
		oldAnts = fCurCell;

		cell c;
		GetCellHitBy(curPoint, c);
		curCol = std::max((int)c.h, 1);
	
		fCurCell.h = curCol;
		if (fEntering)
		{
			tmpSelection = fSelection;
			fSelection = curSelection;
		}
		ScrollToSelection();
		if (fEntering)
			fSelection = tmpSelection;
		fCurCell = oldAnts;

		if (lastCol != curCol)
		{
			if (fEntering)
				ClearAnts();
			else
				SelectionToRegion(oldSel);

			if (curCol > anchorCol)
				fSelection.Set(anchorCol, 1, curCol, kRowCount);
			else
				fSelection.Set(curCol, 1, anchorCol, kRowCount);
			
//			SetFontName("Emily");
//			SetFontSize(12);

			if (lastCol > curCol)
			{
				r = lastCol; l = curCol;
			}
			else
			{
				r = curCol; l = lastCol;
			}
			
			for (y =  static_cast<long>(l) ;
				 y <= static_cast<long>(r) ;
				 y++ )
			{
				c.h = y;
				BRect r;
				char s[10];
				
				GetCellRect(c, r);
				r.top = 1.0;
				r.bottom = fBorderHeight - 1.0;
				
				if (r.left != r.right)
				{
					NumToAString(y, s);
					FillRect3D(this, r, y >= fSelection.left && y <= fSelection.right, true, s);
				}
			}
				
			if (!fEntering)
			{
				SelectionToRegion(newSel);
				ChangeSelection(&oldSel, &newSel);
			}

			if (!fEntering && fCurCell.h != fSelection.left)
				ClearAnts();

			fCurCell = fSelection.TopLeft();
			DrawStatus();
		}

		MarchAnts();
		lastCol = curCol;
		GetMouse(&curPoint, &buttons);
	}

	if (fEntering)
	{
		fEditBox->EnterRange(fSelection);
		ClearAnts();
		fSelection = curSelection;
		fCurCell = curCurCell;
		DrawStatus();
		DrawBorders();
	}
} 
Beispiel #21
0
void
CCellView::SelectRow(BPoint where, int rowNr)
{
	BPoint curPoint;
	cell oldAnts, curCurCell = fCurCell;
	range curSelection = fSelection, tmpSelection;
	long anchorRow, curRow, lastRow;
	float t, b;
	BRegion oldSel, newSel, oldClip;
	ulong modifiers = Window()->CurrentMessage()->FindInt32("modifiers");

	curPoint = where;
	curRow = rowNr;

	ClearAnts();

	if (!fEntering && (modifiers & B_SHIFT_KEY))
	{
		if (curRow > fSelection.bottom)
			anchorRow = fSelection.top;
		else
			anchorRow = fSelection.bottom;
	}
	else
		anchorRow = curRow;
	lastRow = curRow;

	if (!fEntering)
		SelectionToRegion(oldSel);

	if (anchorRow > curRow)
		fSelection.Set(1, curRow, kColCount, anchorRow);
	else
		fSelection.Set(1, anchorRow, kColCount, curRow);

	fCurCell = fSelection.TopLeft();
	DrawStatus();
	DrawBorders();
	
	if (!fEntering)
	{
		SelectionToRegion(newSel);
		ChangeSelection(&oldSel, &newSel);
	}

	ulong buttons;
	GetMouse(&curPoint, &buttons);
	while (buttons)
	{
		oldAnts = fCurCell;

		cell c;
		GetCellHitBy(curPoint, c);
		curRow = c.v;

		fCurCell.v = curRow;
		if (fEntering)
		{
			tmpSelection = fSelection;
			fSelection = curSelection;
		}
		ScrollToSelection();
		if (fEntering)
			fSelection = tmpSelection;
		fCurCell = oldAnts;

		if (lastRow != curRow)
		{

			if (fEntering)
				ClearAnts();
			else
				SelectionToRegion(oldSel);

			if (curRow > anchorRow)
				fSelection.Set(1, anchorRow, kColCount, curRow);
			else
				fSelection.Set(1, curRow, kColCount, anchorRow);
			
//			SetFontName("Emily");
//			SetFontSize(12);

			if (lastRow > curRow)
			{
				b = lastRow; t = curRow;
			}
			else
			{
				b = curRow; t = lastRow;
			}
			for (long x = static_cast<long>(t) ;
			     x <= static_cast<long>(b) ;
				 x++ )
			{
				BRect r;
				char s[10];
				
				c.v = x;
				GetCellRect(c, r);
				r.left = 0.0;
				r.right = fBorderWidth - 1.0;

				if (r.top != r.bottom)
				{
					sprintf(s, "%d", x);
					FillRect3D(this, r, x >= fSelection.top && x <= fSelection.bottom, true, s);
				}
			}
			
			if (!fEntering)
			{
				SelectionToRegion(newSel);
				ChangeSelection(&oldSel, &newSel);
			}

			if (!fEntering && fCurCell.v != fSelection.top)
				ClearAnts();

			fCurCell = fSelection.TopLeft();
			DrawStatus();
		}

		MarchAnts();
		lastRow = curRow;
		GetMouse(&curPoint, &buttons);
	}
	
	if (fEntering)
	{
		fEditBox->EnterRange(fSelection);
		ClearAnts();
		fSelection = curSelection;
		fCurCell = curCurCell;
		DrawStatus();
		DrawBorders();
	}
} /* SelectRow */
Beispiel #22
0
// Position and size subwindows.
// Note that the border size applies to each subwindow, not
// including the edges next to the sash.
void wxSashWindow::SizeWindows()
{
    int cw, ch;
    GetClientSize(&cw, &ch);

    if (GetChildren().GetCount() == 1)
    {
        wxWindow* child = GetChildren().GetFirst()->GetData();

        int x = 0;
        int y = 0;
        int width = cw;
        int height = ch;

        // Top
        if (m_sashes[0].m_show)
        {
            y = m_borderSize;
            height -= m_borderSize;
        }
        y += m_extraBorderSize;

        // Left
        if (m_sashes[3].m_show)
        {
            x = m_borderSize;
            width -= m_borderSize;
        }
        x += m_extraBorderSize;

        // Right
        if (m_sashes[1].m_show)
        {
            width -= m_borderSize;
        }
        width -= 2*m_extraBorderSize;

        // Bottom
        if (m_sashes[2].m_show)
        {
            height -= m_borderSize;
        }
        height -= 2*m_extraBorderSize;

        child->SetSize(x, y, width, height);
    }
    else if (GetChildren().GetCount() > 1)
    {
        // Perhaps multiple children are themselves sash windows.
        // TODO: this doesn't really work because the subwindows sizes/positions
        // must be set to leave a gap for the parent's sash (hit-test and decorations).
        // Perhaps we can allow for this within LayoutWindow, testing whether the parent
        // is a sash window, and if so, allowing some space for the edges.
        wxLayoutAlgorithm layout;
        layout.LayoutWindow(this);
    }

    wxClientDC dc(this);
    DrawBorders(dc);
    DrawSashes(dc);
}
Beispiel #23
0
void CUISimpleBG::DrawIntern( void )
{
    DrawBackGround( );
    DrawBorders( );
}