Exemplo n.º 1
0
/* TODO: De-uglify this crap: */
static void init_single_player(Screen *s, TankList *tl, Level *lvl) {
	Tank *t;
	Rect gui;
	unsigned gui_shift;
	
	/* Account for the GUI Controller: */
	gui = gamelib_gui_get_size();
	gui_shift = gui.w + !!gui.w * 15; /* << Shift out of way of thumb... */
	
	gamelib_debug("XYWH: %u %u %u %u", gui.x, gui.y, gui.w, gui.h);
	
	/* Ready the tank! */
	t = tanklist_add_tank(tl, 0, level_get_spawn(lvl, 0));
	gamelib_tank_attach(t, 0, 1);
	
	screen_add_window(s, RECT(2, 2, GAME_WIDTH-4, GAME_HEIGHT-6-STATUS_HEIGHT), t);
	screen_add_status(s, RECT(9 + gui_shift, GAME_HEIGHT - 2 - STATUS_HEIGHT, GAME_WIDTH-12 - gui_shift, STATUS_HEIGHT), t, 1);
	if(gui_shift)
		screen_add_controller(s, RECT(3, GAME_HEIGHT - 5 - gui.h, gui.w, gui.h));
	
	/* Add the GUI bitmaps: */
	screen_add_bitmap(s, RECT(3 + gui_shift, GAME_HEIGHT - 2 - STATUS_HEIGHT    , 4, 5), GUI_ENERGY, &color_status_energy);
	screen_add_bitmap(s, RECT(3 + gui_shift, GAME_HEIGHT - 2 - STATUS_HEIGHT + 6, 4, 5), GUI_HEALTH, &color_status_health);
	
	/* Fill up the rest of the slots with Twitches: */
	twitch_fill(tl, lvl, 1);
}
Exemplo n.º 2
0
RECT CItemData::GetRect(CDCHandle& dc)
{
	if ( NULL == m_pData )
		return RECT() ;

	if ( TIT_LINK != m_pData->dwType && TIT_TEXT != m_pData->dwType )
		return RECT() ;

	RECT rcItem = {0} ;
	wstring wsText ;
	switch(m_pData->dwType)
	{
	case TIT_LINK:
		{
			CFont font ;
			font.CreateFont(13,0,0,0,GetBold()?FW_BOLD:FW_NORMAL,0,TRUE,0,0,0,0,0,0,_T("Tahoma")) ;
			HFONT hOldFont = dc.SelectFont(font) ;
			wsText = m_pData->pData->pilLink->wsText ;
			dc.DrawText(wsText.c_str() , wsText.size() , &rcItem , DT_CALCRECT|DT_NOPREFIX|DT_NOCLIP|DT_SINGLELINE) ;
			dc.SelectFont(hOldFont) ;
		}
		break;
	case TIT_TEXT :
		wsText = m_pData->pData->pitText->wsText ;
		dc.DrawText(wsText.c_str() , wsText.size() , &rcItem , DT_CALCRECT|DT_NOPREFIX|DT_NOCLIP|DT_SINGLELINE) ;
		break ;
	}
	return rcItem ;
}
Exemplo n.º 3
0
Arquivo: layout.c Projeto: penma/feht2
struct rect layout_frame_rect_by_number(struct layout *l, int frame) {
    /* refuse to calculate coordinates for a frame that doesn't exist,
     * even though we could.
     * this makes it consistent with layout_frame_number_by_coord,
     * which does need to respect the frame count, to prevent returning
     * an invalid frame id.
     */

    if (frame >= l->frame_count) {
        return RECT(COORD(0, 0), COORD(0, 0));
    }

    struct rect r;

    int col = frame % l->_frames_per_row;
    int row = frame / l->_frames_per_row;

    r.tl.x = (col + 1) * l->_frame_spacing
             +  col      * l->frame.width;
    r.tl.y = (row + 1) * l->spacing.vertical
             +  row      * l->frame.height;

    r.dim = l->frame;

    return r;
}
void AEyeXSimpleInteractorPawn::BeginPlay()
{
	Super::BeginPlay();
	MyRegion = new ActivatableRegion(IEyeXEyetracking::Get().GetNextUniqueRegionId(), RECT());
	IEyeXEyetracking::Get().AddActivatableRegion(*MyRegion);
	IEyeXEyetracking::Get().OnFocusedRegionChanged().AddUObject(this, &AEyeXSimpleInteractorPawn::FocusedObjectChanged);

	BaseScale = GetActorScale();
	FocusedScale = BaseScale * 2;
}
Exemplo n.º 5
0
RECT Object::getBound()
{
	RECT tempBound = RECT();

	tempBound.left		= (long)(m_Position.x - m_Sprite->getAnimation()->getFrameSize().x / 2);
	tempBound.right		= (long)(tempBound.left + m_Sprite->getAnimation()->getFrameSize().x);
	tempBound.top		= (long)(m_Position.y + m_Sprite->getAnimation()->getFrameSize().y / 2);
	tempBound.bottom	= (long)(tempBound.top - m_Sprite->getAnimation()->getFrameSize().y);

	return tempBound;
}
Exemplo n.º 6
0
//sudoku methods
void COverlappedWindow::initData() {

	loadResources();


	//grid init
	sudoku.getRandomGrid(grid);

	is_digit_pressed_ = false;
	i_pressed_ = 0;
	j_pressed_ = 0;

	//menu buttons init
	menu_buttons_.resize(11);
	menu_buttons_[10] = menu_button_BMP_;
	for (int i = 0; i <= 9; ++i) {
		menu_buttons_[i] = menu_digits_[i];
	}

	//menu rectangles init
	menu_rects_.resize(11);

	RECT rect = {
		win_size_ + (menu_width_ / 2 - menu_item_size_ / 2),
		(win_size_ - menu_margin_bottom_ - menu_margin_top_ - 10 * menu_item_size_) / 2 - menu_item_size_ / 2,
		win_size_ + (menu_width_ / 2 - menu_item_size_ / 2) + menu_item_size_,
		(win_size_ - menu_margin_bottom_ - menu_margin_top_ - 10 * menu_item_size_) / 2 + menu_item_size_ / 2 };

	menu_rects_[10] = rect;

	for (int i = 0; i <= 9; ++i) {
		RECT rect = {
			win_size_ + (menu_width_ / 2 - menu_item_size_ / 2),
			win_size_ - menu_margin_bottom_ - 10 * menu_item_size_ + i * menu_item_size_,
			win_size_ + (menu_width_ / 2 - menu_item_size_ / 2) + menu_item_size_,
			win_size_ - menu_margin_bottom_ - 10 * menu_item_size_ + i * menu_item_size_ + menu_item_size_ };

		menu_rects_[i] = rect;
	}


	field_rects_ = std::vector<std::vector<RECT> >(9, std::vector<RECT>(9, RECT()));

	for (int i = 0; i < 9; ++i) {
		for (int j = 0; j < 9; ++j) {
			field_rects_[i][j].top = j * cell_size_;
			field_rects_[i][j].bottom = (j + 1) * cell_size_;
			field_rects_[i][j].left = i * cell_size_;
			field_rects_[i][j].right = (i + 1) * cell_size_;
		}
	}
}
Exemplo n.º 7
0
RECT ShadowBeast::ShadowMouth::getBounding()
{
	int index = _animation->getIndex();
	if ( index >= 2 && index <= 6)
	{
		auto basebound = BaseObject::getBounding();
		basebound.left += 38 * this->getScale().x;
		basebound.right -= 38 * this->getScale().x;
		basebound.top += 14 * this->getScale().y;
		return basebound;
	}
	return RECT();
}
Exemplo n.º 8
0
FloatRect	UIObjectMenu::getHitBox(Vector2f Position)const
{
    std::string	STRING(mName);
    STRING.erase(STRING.begin());
    sf::Text	NAME(STRING);
    NAME.setPosition(Position);
    NAME.setCharacterSize(mSize);
    FloatRect RECT(Position,mMaxSize);
    if(!mSelected)
    {
        RECT.height=NAME.getGlobalBounds().height+4;
        RECT.width=mMaxSize.x;
    }
    return RECT;
}
Exemplo n.º 9
0
/* \brief set camera's viewport */
GLHCKAPI void glhckCameraViewport(glhckCamera *object, const glhckRect *viewport)
{
   CALL(1, "%p, "RECTS, object, RECT(viewport));
   assert(object);

   if (object->view.viewport.x == viewport->x &&
	 object->view.viewport.y == viewport->y &&
	 object->view.viewport.w == viewport->w &&
	 object->view.viewport.h == viewport->h)
      return;

   memcpy(&object->view.viewport, viewport, sizeof(glhckRect));
   _glhckCameraProjectionMatrix(object);
   object->view.update = 1;
   object->view.updateViewport = 1;
}
Exemplo n.º 10
0
/* \brief set renderer's viewport */
GLHCKAPI void glhckRenderViewport(const glhckRect *viewport)
{
   kmMat4 ortho;
   GLHCK_INITIALIZED();
   CALL(1, RECTS, RECT(viewport));
   assert(viewport->x >= 0 && viewport->y >= 0 && viewport->w > 0 && viewport->h > 0);
   if (!_glhckRenderInitialized()) return;

   /* set viewport on render */
   GLHCKRA()->viewport(viewport->x, viewport->y, viewport->w, viewport->h);
   memcpy(&GLHCKRP()->viewport, viewport, sizeof(glhckRect));

   /* update orthographic matrix */
   kmMat4OrthographicProjection(&ortho, viewport->x, viewport->w, viewport->h, viewport->y, -1.0f, 1.0f);
   GLHCKRA()->setOrthographic(&ortho);
   memcpy(&GLHCKRD()->view.orthographic, &ortho, sizeof(kmMat4));
}
Exemplo n.º 11
0
void			ft_drawimage(t_image *dst, t_image *src, t_pt pos, t_rect part)
{
	t_byte			*dstpos;
	t_byte			*srcpos;

	if (pos.x < 0)
		part.width += pos.x;
	if (pos.y < 0)
		part.height += pos.y;
	pos = PT((pos.x < 0) ? 0 : pos.x, (pos.y < 0) ? 0 : pos.y);
	ft_resrect(&part, RECT(part.x, part.y, part.x + dst->width - pos.x,
		part.y + dst->height - pos.y));
	if (pos.x >= dst->width || pos.y >= dst->width || part.width <= 0
		|| part.height <= 0 || dst->opp != src->opp)
		return ;
	part.width *= dst->opp;
	dstpos = dst->data + ((pos.y * (dst->width - 1) + pos.x) * dst->opp);
	srcpos = src->data + ((part.y * (src->width - 1) + part.x) * dst->opp);
	while (part.height-- > 0)
		ft_memmove(dstpos += dst->width * dst->opp,
			srcpos += src->width * dst->opp, part.width);
}
Exemplo n.º 12
0
static void init_double_player(Screen *s, TankList *tl, Level *lvl) {
	Tank *t;
	
	/* Ready the tanks! */
	t = tanklist_add_tank(tl, 0, level_get_spawn(lvl, 0));
	gamelib_tank_attach(t, 0, 2);
	screen_add_window(s, RECT(2, 2, GAME_WIDTH/2-3, GAME_HEIGHT-6-STATUS_HEIGHT), t);
	screen_add_status(s, RECT(3, GAME_HEIGHT - 2 - STATUS_HEIGHT, GAME_WIDTH/2-5-2, STATUS_HEIGHT), t, 0);
	
	/* Load up two controllable tanks: */
	t = tanklist_add_tank(tl, 1, level_get_spawn(lvl, 1));
	
	/*controller_twitch_attach(t);  << Attach a twitch to a camera tank, so we can see if they're getting smarter... */
	gamelib_tank_attach(t, 1, 2);
	screen_add_window(s, RECT(GAME_WIDTH/2+1, 2, GAME_WIDTH/2-3, GAME_HEIGHT-6-STATUS_HEIGHT), t);
	screen_add_status(s, RECT(GAME_WIDTH/2+2+2, GAME_HEIGHT - 2 - STATUS_HEIGHT, GAME_WIDTH/2-5-3, STATUS_HEIGHT), t, 1);

	/* Add the GUI bitmaps: */
	screen_add_bitmap(s, RECT(GAME_WIDTH/2-2, GAME_HEIGHT - 2 - STATUS_HEIGHT    , 4, 5), GUI_ENERGY, &color_status_energy);
	screen_add_bitmap(s, RECT(GAME_WIDTH/2-2, GAME_HEIGHT - 2 - STATUS_HEIGHT + 6, 4, 5), GUI_HEALTH, &color_status_health);
	
	/* Fill up the rest of the slots with Twitches: */
	twitch_fill(tl, lvl, 2);
}
Exemplo n.º 13
0
sint32 osWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, sint32 nCmdShow)
{
	MSG msg;

	RegisterOpenPopClass(hInstance);

	HWND hWnd;

	RECT rect = RECT();
	rect.right = 640;
	rect.bottom = 480;
	
	AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, NULL);

	hWnd = CreateWindowA(
		APPTITLE,
		APPTITLE,
		WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		rect.right - rect.left,
		rect.bottom - rect.top,
		NULL,
		NULL,
		hInstance,
		NULL);

	//sint32 error = GetLastError();

	if (!hWnd)
		return FALSE;

	//Display the window
	ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);


	game = new OpenPop();
	game->hWnd = hWnd;

	if (!game->Init())
		return 0;

	//main message loop
	sint32 done = 0;
	while (!done) {
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
			//look for quit message
			if (msg.message == WM_QUIT) {
				done = 1;
			}

			//decode and pass messages on to WndProc
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		} else {
			//process game loop
			game->Run();
		}
	}

	return msg.wParam;
}
Exemplo n.º 14
0
//---------------------------------------------------------------------------
void __fastcall TTVPHintWindow::Paint(void)
{
    // create bitmap to be piled with a mask bitmap
    Graphics::TBitmap *mask=new Graphics::TBitmap();
    Graphics::TBitmap *disp=new Graphics::TBitmap();
    Graphics::TBitmap *main=new Graphics::TBitmap();

    // set pixelformat and size
    mask->PixelFormat=pf8bit;
    TVP_TB_SetGrayscalePalette(mask);
    mask->Width=BackBMP->Width;
    mask->Height=BackBMP->Height;
    disp->PixelFormat=pf32bit;
    disp->Width=BackBMP->Width;
    disp->Height=BackBMP->Height;
    main->PixelFormat=pf32bit;
    main->Width=BackBMP->Width;
    main->Height=BackBMP->Height;

    // set up bmprect ...
    RECT bmprect;
    bmprect.left=0;
    bmprect.top=0;
    bmprect.right=BackBMP->Width;
    bmprect.bottom=BackBMP->Height;

    // fill mask with gray
    for(int i = 0; i<mask->Height; i++)
        memset(mask->ScanLine[i], 192, mask->Width);

    // fill main with clInfoBk
    main->Canvas->Brush->Color=clInfoBk;
    main->Canvas->Brush->Style=bsSolid;
    main->Canvas->FillRect(TRect(bmprect));

    // draw text
    mask->Canvas->Font=Canvas->Font;
    main->Canvas->Font=Canvas->Font;
    mask->Canvas->Brush->Style=bsClear;
    main->Canvas->Brush->Style=bsClear;
    main->Canvas->Font->Color=clInfoBk;
    RECT r=RECT(ClientRect);
    r.left+=3;
    r.right+=3;
    r.top+=3;
    r.bottom+=3;

    main->Canvas->Font->Color=clInfoBk;
    mask->Canvas->Font->Color=(TColor)0x00e0e0e0;
    {
        RECT r2=r;
        r2.left --;
        r2.top --;
        r2.right --;
        r2.bottom --;
        DrawText(mask->Canvas->Handle, Caption.c_str(), -1, &r2,
                 DT_LEFT | DT_NOPREFIX | DT_WORDBREAK);
    }

    {
        RECT r2=r;
        r2.left ++;
        r2.top --;
        r2.right ++;
        r2.bottom --;
        DrawText(mask->Canvas->Handle, Caption.c_str(), -1, &r2,
                 DT_LEFT | DT_NOPREFIX | DT_WORDBREAK);
    }

    {
        RECT r2=r;
        r2.left --;
        r2.top ++;
        r2.right --;
        r2.bottom ++;
        DrawText(mask->Canvas->Handle, Caption.c_str(), -1, &r2,
                 DT_LEFT | DT_NOPREFIX | DT_WORDBREAK);
    }

    {
        RECT r2=r;
        r2.left ++;
        r2.top ++;
        r2.right ++;
        r2.bottom ++;
        DrawText(mask->Canvas->Handle, Caption.c_str(), -1, &r2,
                 DT_LEFT | DT_NOPREFIX | DT_WORDBREAK);
    }


    main->Canvas->Font->Color=clInfoText;
    DrawText(main->Canvas->Handle, Caption.c_str(), -1, &r,
             DT_LEFT | DT_NOPREFIX | DT_WORDBREAK);

    mask->Canvas->Font->Color=(TColor)0x00ffffff;

    DrawText(mask->Canvas->Handle, Caption.c_str(), -1, &r,
             DT_LEFT | DT_NOPREFIX | DT_WORDBREAK);

    // draw frame
    mask->Canvas->Pen->Width=1;
    mask->Canvas->Pen->Color=(TColor)0x00ffffff;
    mask->Canvas->MoveTo(0,0);
    mask->Canvas->LineTo(mask->Width-1,0);
    mask->Canvas->LineTo(mask->Width-1,mask->Height-1);
    mask->Canvas->LineTo(0,mask->Height-1);
    mask->Canvas->LineTo(0,0);

    // bind
    for(int i = 0; i<mask->Height; i++)
        TVPBindMaskToMain((tjs_uint32*)main->ScanLine[i],
                          (const tjs_uint8*)mask->ScanLine[i], mask->Width);

    // copy BackBMP to disp
    for(int i = 0; i<mask->Height; i++)
        memcpy(disp->ScanLine[i],
               BackBMP->ScanLine[i], BackBMP->Width * sizeof(tjs_uint32));

    // pile main to disp via pixel alpha blending
    for(int i = 0; i<mask->Height; i++)
        TVPAlphaBlend((tjs_uint32*)disp->ScanLine[i],
                      (const tjs_uint32*)main->ScanLine[i], mask->Width);

    // draw to the canvas
    Canvas->Draw(0, 0, disp);

    // delete bitmaps
    delete disp;
    delete mask;
    delete main;

}
Exemplo n.º 15
0
void CalcDist::Excute()
{
	
	m_cursor = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_CURSOR2));
	m_oldCursor = SetCursor(m_cursor);

	HDC	hdc = GetDC(m_hWnd);
	HDC memoryDC = CreateCompatibleDC(hdc);
	HBITMAP memoryBitmap = CreateCompatibleBitmap(hdc, m_maxWidth, m_maxHeight);
	HBITMAP oldBitmap = (HBITMAP)SelectObject(memoryDC, memoryBitmap);
	WCHAR temp[100] = { 0, };
	Rectangle(memoryDC, 0, 0, m_maxWidth, m_maxHeight); //흰색 바탕 칠하기

	/* line 그리기 */
	// y = ax + b
	// ax - y + b = 0;
	double x1 = 550, y1 = -100, x2 = 250, y2 = 900;
	double angle = (y2 - y1) / (x2 - x1); // a
	double b = -angle * x2 + y2; // b
	double distance = abs(angle * g_mousex - g_mousey + b) / sqrt(angle*angle + 1);
	MoveToEx(memoryDC, x1, y1, PS_SOLID);
	LineTo(memoryDC, x2, y2);

	/*법선그리기*/
	double crossAngle = -1 / angle; //법선 기울기
	// ax + b = y
	// b = y - ax
	double crossB = g_mousey - crossAngle * g_mousex;
	double crossX = -(b - crossB) / (angle - crossAngle);
	double crossY = crossX * crossAngle + crossB;
	MoveToEx(memoryDC, crossX, crossY, PS_SOLID);
	LineTo(memoryDC, g_mousex, g_mousey);

	Circle myCircle = Circle(g_mousex, g_mousey, 20.0);
	Circle targetCircle = Circle(500, 300, 60);
	RECT targetRect = RECT();
	targetRect.bottom = 350;
	targetRect.top = 250;
	targetRect.left = 100;
	targetRect.right = 200;
	
	COLORREF targetRectColor;
	if (CollideChecker::IsCollision(targetRect, myCircle))
		targetRectColor = RGB(255, 0, 0);
	else
		targetRectColor = RGB(0, 0, 255);

	COLORREF targetCircleColor;
	if (CollideChecker::IsCollision(myCircle, targetCircle))
		targetCircleColor = RGB(200, 200, 0);
	else
		targetCircleColor = RGB(0, 200, 200);

	COLORREF myColor = RGB(20, 100, 100);

	DrawRectWithColor(memoryDC, targetRect, targetRectColor);
	targetCircle.Draw(memoryDC, targetCircleColor);
	myCircle.Draw(memoryDC, myColor);
	MoveToEx(memoryDC, targetCircle.m_cx, targetCircle.m_cy, PS_SOLID);
	LineTo(memoryDC, myCircle.m_cx, myCircle.m_cy);

	wsprintf(temp, L"X : %d", (int)g_mousex);
	TextOut(memoryDC, 10, 10, temp, lstrlen(temp));
	wsprintf(temp, L"Y : %d", (int)g_mousey);
	TextOut(memoryDC, 10, 30, temp, lstrlen(temp));
	wsprintf(temp, L"Distance : %d", (int)distance);
	TextOut(memoryDC, 10, 50, temp, lstrlen(temp));

	//memoryDC에 버퍼링된 이미지 그리기.
	BitBlt(hdc, 0, 0, m_maxWidth, m_maxHeight, memoryDC, 0, 0, SRCCOPY);

	/* 리소스 반환 */
	//memoryDC 제거
	SelectObject(memoryDC, oldBitmap);
	DeleteDC(memoryDC);
	DeleteObject(memoryBitmap);

	ReleaseDC(m_hWnd, hdc);
}
Exemplo n.º 16
0
LRESULT ProgressDialog::dialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    const auto updateDialogTimerID = 1U;
    const auto progressDialogShowDetailedOutputSetting = String("ProgressDialogShowDetailedOutput");

    switch (message)
    {
    case WM_INITDIALOG:
    {
        detailedOutput_.clear();
        isTaskComplete_ = false;
        currentTaskString_.clear();

        // Set the exporter version label
        SetWindowTextA(GetDlgItem(hDlg, IDC_VERSION), ("Version " + BuildInfo::getVersion()).cStr());

        // Hide the Close button
        ShowWindow(GetDlgItem(hDlg, IDC_CLOSE), SW_HIDE);

        // Start a timer to update the progress bar at 25Hz
        SetTimer(hDlg, updateDialogTimerID, 40, nullptr);

        // Set range of progress bar to 0-1000
        SendMessage(GetDlgItem(hDlg, IDC_PROGRESS), PBM_SETRANGE32, 0, 1000);

        // Move the Close button on top of the Cancel button, only one is available at any given time
        auto cancelRect = RECT();
        GetWindowRect(GetDlgItem(hDlg, IDC_CANCEL), &cancelRect);
        auto p = POINT{cancelRect.left, cancelRect.top};
        ScreenToClient(hDlg, &p);
        SetWindowPos(GetDlgItem(hDlg, IDC_CLOSE), nullptr, p.x, p.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);

        // Initialize the show detailed output checkbox and state
        if (settings().getBoolean(progressDialogShowDetailedOutputSetting))
            CheckDlgButton(hDlg, IDC_SHOW_DETAILED_OUTPUT, BST_CHECKED);
        else
        {
            CheckDlgButton(hDlg, IDC_SHOW_DETAILED_OUTPUT, BST_UNCHECKED);
            dialogProc(hDlg, WM_COMMAND, MAKEWPARAM(IDC_SHOW_DETAILED_OUTPUT, 0), 0);
        }

        // Create events used for inter-thread communication
        hUpdateOutputEvent_ = CreateEvent(nullptr, FALSE, FALSE, nullptr);
        hWorkerCompleteEvent_ = CreateEvent(nullptr, FALSE, FALSE, nullptr);
        hWorkerSucceededEvent_ = CreateEvent(nullptr, FALSE, FALSE, nullptr);

        // Start worker thread
        workerThread_ = HANDLE(_beginthreadex(nullptr, 0, staticWorkerThreadMain, this, 0, nullptr));
        if (workerThread_)
            SetThreadPriority(workerThread_, THREAD_PRIORITY_BELOW_NORMAL);

        return TRUE;
    }

    case WM_DESTROY:
    {
        // The worker thread should be finished by now assuming everything worked correctly. However, it is
        // important to check it is finished, as odd behavior or crashes could result from lurking worker threads.
        auto workerThreadExitCode = DWORD();
        GetExitCodeThread(workerThread_, &workerThreadExitCode);
        if (workerThreadExitCode == STILL_ACTIVE)
        {
            // Give the worker thread more time to close
            Sleep(10000);

            // Check the thread state again
            GetExitCodeThread(workerThread_, &workerThreadExitCode);
            if (workerThreadExitCode == STILL_ACTIVE)
            {
                LOG_WARNING << "Worker thread is still active after progress dialog closed";

                MessageBoxA(GetParent(hDlg), "Warning: Worker thread still active after progress dialog closed",
                            Globals::getClientName().cStr(), MB_ICONERROR);
            }
        }

        // Cleanup
        CloseHandle(workerThread_);
        CloseHandle(hUpdateOutputEvent_);
        CloseHandle(hWorkerCompleteEvent_);
        CloseHandle(hWorkerSucceededEvent_);

        break;
    }

    case WM_TIMER:
    {
        if (wParam == updateDialogTimerID)
        {
            events().dispatchEvent(UpdateEvent());

            // Update log output display if required
            if (WaitForSingleObject(hUpdateOutputEvent_, 0) == WAIT_OBJECT_0)
            {
                auto lock = ScopedMutexLock(detailedOutputMutex_);

                // Update text in the output editbox from the 'output' variable
                SetWindowTextW(GetDlgItem(hDlg, IDC_OUTPUT), detailedOutput_.toUTF16().as<wchar_t>());
            }

            if (WaitForSingleObject(hWorkerCompleteEvent_, 0) == WAIT_OBJECT_0)
            {
                isTaskComplete_ = true;

                // Hide the Cancel button and show the Close button
                ShowWindow(GetDlgItem(hDlg, IDC_CANCEL), SW_HIDE);
                ShowWindow(GetDlgItem(hDlg, IDC_CLOSE), SW_SHOW);
                SetFocus(GetDlgItem(hDlg, IDC_CLOSE));

                // Check if job completed successfully
                if (WaitForSingleObject(hWorkerSucceededEvent_, 0) == WAIT_OBJECT_0)
                {
                    // Set task label to 'Done' and progress bar to full
                    SetWindowTextA(GetDlgItem(hDlg, IDC_TASK), "Done");
                    PostMessage(GetDlgItem(hDlg, IDC_PROGRESS), PBM_SETPOS, 1000, 0);
                }
                else
                {
                    // The job did not complete successfully

                    if (runnable_->isCancelled())
                    {
                        // Close the dialog following cancellation
                        EndDialog(hDlg, IDC_CLOSE);
                    }
                    else
                        SetWindowTextA(GetDlgItem(hDlg, IDC_TASK), "Failed");
                }
            }

            if (!isTaskComplete_)
            {
                // Update current task display
                if (runnable_->isTaskStringDirty())
                {
                    auto newTaskString = String();
                    if (IsDlgButtonChecked(hDlg, IDC_SHOW_DETAILED_OUTPUT))
                        newTaskString = runnable_->getTaskString();
                    else
                        newTaskString = runnable_->getSimpleTaskString();

                    newTaskString += " ...";

                    // Check the new task string is different
                    if (currentTaskString_ != newTaskString)
                    {
                        SetWindowTextA(GetDlgItem(hDlg, IDC_TASK), newTaskString.cStr());
                        currentTaskString_ = newTaskString;
                    }
                }

                // Update progress bar position
                if (runnable_->isPercentageDirty())
                {
                    auto position = runnable_->getPercentage() * 10.0f;
                    PostMessage(GetDlgItem(hDlg, IDC_PROGRESS), PBM_SETPOS, int(position), 0);
                }
            }
        }

        return TRUE;
    }

    case WM_CLOSE:
    {
        // Close the dialog if the task is complete, otherwise cancel it
        if (isTaskComplete_)
            EndDialog(hDlg, IDC_CLOSE);
        else
            dialogProc(hDlg, WM_COMMAND, MAKEWPARAM(IDC_CANCEL, 0), 0);

        return TRUE;
    }

    case WM_COMMAND:
    {
        if (LOWORD(wParam) == IDC_CANCEL)
        {
            runnable_->cancel();
            EnableWindow(GetDlgItem(hDlg, IDC_CANCEL), FALSE);
            SetWindowTextA(GetDlgItem(hDlg, IDC_TASK), "Cancelling ...");
        }
        else if (LOWORD(wParam) == IDC_CLOSE)
        {
            // Close the dialog
            EndDialog(hDlg, IDC_CLOSE);
        }
        else if (LOWORD(wParam) == IDC_SHOW_DETAILED_OUTPUT)
        {
            // Show/hide the detailed output
            auto showDetailedOutput = (IsDlgButtonChecked(hDlg, IDC_SHOW_DETAILED_OUTPUT) == BST_CHECKED);

            // Update output window visibility
            ShowWindow(GetDlgItem(hDlg, IDC_OUTPUT), showDetailedOutput);

            // Get sizes of the dialog items needed to do resize the dialog window correctly
            auto cancelRect = RECT();
            auto outputRect = RECT();
            auto dialogRect = RECT();
            GetWindowRect(GetDlgItem(hDlg, IDC_CANCEL), &cancelRect);
            GetWindowRect(GetDlgItem(hDlg, IDC_OUTPUT), &outputRect);
            GetWindowRect(hDlg, &dialogRect);

            auto heightDelta = (outputRect.bottom - cancelRect.bottom);
            if (!showDetailedOutput)
                heightDelta = -heightDelta;

            // Update dialog size
            SetWindowPos(hDlg, nullptr, 0, 0, dialogRect.right - dialogRect.left,
                         dialogRect.bottom - dialogRect.top + heightDelta, SWP_NOZORDER | SWP_NOMOVE);

            // Force the task string to update
            runnable_->setTaskStringDirty();

            // Update the persistent show detailed output setting
            settings().set(progressDialogShowDetailedOutputSetting, showDetailedOutput);
        }

        break;
    }
    }

    return FALSE;
}
Exemplo n.º 17
0
HRESULT WINAPI D3D9Present(IDirect3DDevice9 *pDev, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) {
    D3D9FrameGrabber *d3d9FrameGrabber = D3D9FrameGrabber::getInstance();
    Logger *logger = d3d9FrameGrabber->m_logger;
    DWORD errorcode;
    if (WAIT_OBJECT_0 == (errorcode = WaitForSingleObject(d3d9FrameGrabber->m_syncRunMutex, 0))) {
        IPCContext *ipcContext = d3d9FrameGrabber->m_ipcContext;
        logger->reportLogDebug(L"D3D9Present");
        HRESULT hRes;

        RECT newRect = RECT();
        IDirect3DSurface9 *pBackBuffer = NULL;
        IDirect3DSurface9 *pDemultisampledSurf = NULL;
        IDirect3DSurface9 *pOffscreenSurf = NULL;
        IDirect3DSwapChain9 *pSc = NULL;
        D3DPRESENT_PARAMETERS params;

        if(FAILED( hRes = pDev->GetSwapChain(0, &pSc))) {
            logger->reportLogError(L"d3d9present couldn't get swapchain. result 0x%x", hRes);
            goto end;
        }

        hRes = pSc->GetPresentParameters(&params);
        if (FAILED(hRes) || params.Windowed) {
            goto end;
        }

        if(FAILED( hRes = pDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer))) {
            goto end;
        }

        D3DSURFACE_DESC surfDesc;
        pBackBuffer->GetDesc(&surfDesc);

        hRes = pDev->CreateRenderTarget(
            surfDesc.Width, surfDesc.Height,
            surfDesc.Format, D3DMULTISAMPLE_NONE, 0, false,
            &pDemultisampledSurf, NULL );
        if (FAILED(hRes))
        {
            logger->reportLogError(L"GetFramePrep: FAILED to create demultisampled render target. 0x%x, width=%u, height=%u, format=%x", hRes, surfDesc.Width, surfDesc.Height, surfDesc.Format );
            goto end;
        }

        hRes = pDev->StretchRect(pBackBuffer, NULL, pDemultisampledSurf, NULL, D3DTEXF_LINEAR );
        if (FAILED(hRes))
        {
            logger->reportLogError(L"GetFramePrep: StretchRect FAILED for image surfacee. 0x%x, width=%u, height=%u, format=%x", hRes, surfDesc.Width, surfDesc.Height, surfDesc.Format );
            goto end;
        }

        hRes = pDev->CreateOffscreenPlainSurface(
            surfDesc.Width, surfDesc.Height,
            surfDesc.Format, D3DPOOL_SYSTEMMEM,
            &pOffscreenSurf, NULL );
        if (FAILED(hRes))
        {
            logger->reportLogError(L"GetFramePrep: FAILED to create image surface. 0x%x, width=%u, height=%u, format=%x", hRes, surfDesc.Width, surfDesc.Height, surfDesc.Format );
            goto end;
        }

        hRes = pDev->GetRenderTargetData(pDemultisampledSurf, pOffscreenSurf );
        if (FAILED(hRes))
        {
            logger->reportLogError(L"GetFramePrep: GetRenderTargetData() FAILED for image surfacee. 0x%x, width=%u, height=%u, format=%x", hRes, surfDesc.Width, surfDesc.Height, surfDesc.Format );
            goto end;
        }

        D3DLOCKED_RECT lockedSrcRect;
        newRect.right = surfDesc.Width;
        newRect.bottom = surfDesc.Height;
        hRes = pOffscreenSurf->LockRect( &lockedSrcRect, &newRect, 0);
        if (FAILED(hRes))
        {
            logger->reportLogError(L"GetFramePrep: FAILED to lock source rect. (0x%x)", hRes );
            goto end;
        }

        ipcContext->m_memDesc.width = surfDesc.Width;
        ipcContext->m_memDesc.height = surfDesc.Height;
        ipcContext->m_memDesc.rowPitch = lockedSrcRect.Pitch;
        ipcContext->m_memDesc.frameId++;
        ipcContext->m_memDesc.format = getCompatibleBufferFormat(surfDesc.Format);

        DWORD errorcode;
        if (WAIT_OBJECT_0 == (errorcode = WaitForSingleObject(ipcContext->m_hMutex, 0))) {
    //        reportLog(EVENTLOG_INFORMATION_TYPE, L"d3d9 writing description to mem mapped file");
            memcpy(ipcContext->m_pMemMap, &(ipcContext->m_memDesc), sizeof (ipcContext->m_memDesc));
    //        reportLog(EVENTLOG_INFORMATION_TYPE, L"d3d9 writing data to mem mapped file");
            PVOID pMemDataMap = incPtr(ipcContext->m_pMemMap, sizeof (ipcContext->m_memDesc));
            if (static_cast<UINT>(lockedSrcRect.Pitch) == surfDesc.Width * 4) {
                memcpy(pMemDataMap, lockedSrcRect.pBits, surfDesc.Width * surfDesc.Height * 4);
            } else {
                UINT i = 0, cleanOffset = 0, pitchOffset = 0;
                while (i < surfDesc.Height) {
                    memcpy(incPtr(pMemDataMap, cleanOffset), incPtr(lockedSrcRect.pBits, pitchOffset), surfDesc.Width * 4);
                    cleanOffset += surfDesc.Width * 4;
                    pitchOffset += lockedSrcRect.Pitch;
                    i++;
                }
            }
            ReleaseMutex(ipcContext->m_hMutex);
            SetEvent(ipcContext->m_hFrameGrabbedEvent);
        } else {
            logger->reportLogError(L"d3d9 couldn't wait mutex. errocode = 0x%x", errorcode);
        }
        end:
        if(pOffscreenSurf) pOffscreenSurf->Release();
        if(pDemultisampledSurf) pDemultisampledSurf->Release();
        if(pBackBuffer) pBackBuffer->Release();
        if(pSc) pSc->Release();

        ProxyFuncJmp *d3d9PresentProxyFuncJmp = d3d9FrameGrabber->m_d3d9PresentProxyFuncJmp;
        if(!d3d9PresentProxyFuncJmp->removeHook()) {
            int i = GetLastError();
            logger->reportLogError(L"d3d9 error occured while trying to removeHook before original call0x%x", i);
        }
        HRESULT result = pDev->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);

        if(!d3d9PresentProxyFuncJmp->installHook()) {
            int i = GetLastError();
            logger->reportLogError(L"d3d9 error occured while trying to installHook after original call0x%x", i);
        }
        ReleaseMutex(d3d9FrameGrabber->m_syncRunMutex);

        return result;
    } else {
        logger->reportLogError(L"d3d9sc present is skipped because mutex is busy");
        return S_FALSE;
    }
}
Exemplo n.º 18
0
IoObject *IoCairoRectangle_height(IoCairoRectangle *self, IoObject *locals, IoMessage *m)
{
	return IONUMBER(RECT(self)->height);
}
Exemplo n.º 19
0
Arquivo: iclass.c Projeto: Limsik/e17
static void
ImagestateDrawBevel(ImageState * is, Drawable win, GC gc,
		    int x, int y, int w, int h)
{
   ImagestateColorsAlloc(is);

   switch (is->bevelstyle)
     {
     case BEVEL_AMIGA:
	XSetForeground(disp, gc, is->hihi_pixel);
	LINE(0, 0, w - 2, 0);
	LINE(0, 0, 0, h - 2);
	XSetForeground(disp, gc, is->lolo_pixel);
	LINE(1, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	break;
     case BEVEL_MOTIF:
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(0, 0, w - 1, 0);
	LINE(0, 0, 0, h - 1);
	LINE(1, 1, w - 2, 1);
	LINE(1, 1, 1, h - 2);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(0, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	LINE(1, h - 2, w - 2, h - 2);
	LINE(w - 2, 2, w - 2, h - 2);
	break;
     case BEVEL_NEXT:
	XSetForeground(disp, gc, is->hihi_pixel);
	LINE(0, 0, w - 1, 0);
	LINE(0, 0, 0, h - 1);
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(1, 1, w - 2, 1);
	LINE(1, 1, 1, h - 2);
	XSetForeground(disp, gc, is->lolo_pixel);
	LINE(1, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(2, h - 2, w - 2, h - 2);
	LINE(w - 2, 2, w - 2, h - 2);
	break;
     case BEVEL_DOUBLE:
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(0, 0, w - 2, 0);
	LINE(0, 0, 0, h - 2);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(1, 1, w - 3, 1);
	LINE(1, 1, 1, h - 3);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(1, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(2, h - 2, w - 2, h - 2);
	LINE(w - 2, 2, w - 2, h - 2);
	break;
     case BEVEL_WIDEDOUBLE:
	XSetForeground(disp, gc, is->hihi_pixel);
	LINE(0, 0, w - 1, 0);
	LINE(0, 0, 0, h - 1);
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(1, 1, w - 2, 1);
	LINE(1, 1, 1, h - 2);
	LINE(3, h - 4, w - 4, h - 4);
	LINE(w - 4, 3, w - 4, h - 4);
	XSetForeground(disp, gc, is->lolo_pixel);
	LINE(1, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(2, h - 2, w - 2, h - 2);
	LINE(w - 2, 2, w - 2, h - 2);
	LINE(3, 3, w - 4, 3);
	LINE(3, 3, 3, h - 4);
	break;
     case BEVEL_THINPOINT:
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(0, 0, w - 2, 0);
	LINE(0, 0, 0, h - 2);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(1, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	XSetForeground(disp, gc, is->hihi_pixel);
	LINE(0, 0, 1, 0);
	LINE(0, 0, 0, 1);
	XSetForeground(disp, gc, is->lolo_pixel);
	LINE(w - 2, h - 1, w - 1, h - 1);
	LINE(w - 1, h - 2, w - 1, h - 1);
	break;
     case BEVEL_THICKPOINT:
	XSetForeground(disp, gc, is->hi_pixel);
	RECT(x, y, w - 1, h - 1);
	break;
     default:
	break;
     }
}
Exemplo n.º 20
0
IoCairoRectangle *IoCairoRectangle_newWithRawRectangle_(void *state, cairo_rectangle_t *rect)
{
	IoCairoRectangle *self = IOCLONE(IoState_protoWithId_(state, protoId));
	memcpy(RECT(self), rect, sizeof(cairo_rectangle_t));
	return self;
}
Exemplo n.º 21
0
#include "Camera.h"
#include "Class\Game\Scene\PopupInfo.h"
#include "Class\Game\Entity\Map\MapManager.h"

vector3d			CCamera::m_Position					= vector3dZero;
matrix				CCamera::m_MatrixTransform;
vector4d			CCamera::m_Viewport;
float*				CCamera::m_ViewportX				= 0;
float*				CCamera::m_ViewportY				= 0;
RECT				CCamera::m_LimitRect				= RECT();
CCamera*			CCamera::m_Instance					= NULL;
CAMERASTATE			CCamera::m_StateCamera				= CAMERASTATE::CAMERA_NORMAL;

CCamera::CCamera()
{
	m_Position		= vector3d(0, BACKBUFFER_HEIGHT, 0);
	m_ViewportX		= &m_Position.x;
	m_ViewportY		= &m_Position.y;
	setLimitRectOfCurrentMap(CMapManager::getInstance()->getListMapInGame().at(CMapManager::getInstance()->getCurrentMapINT())->m_sizeX, 
		CMapManager::getInstance()->getListMapInGame().at(CMapManager::getInstance()->getCurrentMapINT())->m_sizeY);
	D3DXMatrixIdentity(&m_MatrixTransform);
	
}


CCamera::~CCamera()
{
	SAFE_RELEASE(m_ViewportX);
	SAFE_RELEASE(m_ViewportY);
	SAFE_RELEASE(m_Instance);
Exemplo n.º 22
0
RECT ShadowBeast::ShadowArm::getBounding()
{
	if (this->getStatus() != eStatus::NORMAL)
		return RECT();
	return BaseObject::getBounding();
}
Exemplo n.º 23
0
void	UIObjectMenu::handleEvent(const sf::Event& Current,Vector2f	Position)
{
    sf::Text	NAME(mName);
    NAME.setPosition(Position);
    NAME.setCharacterSize(mSize);
    if(Current.type==sf::Event::EventType::MouseButtonPressed&&Current.mouseButton.button==sf::Mouse::Button::Left)
    {
        int i=0;
        for(IconVector::iterator it=mIcons.begin(); it!=mIcons.end(); it++)
        {
            Vector2i	pos((i)%int(mMaxSize.x/64),((i)/int(mMaxSize.x/64)));

            int	MaxRows=(mMaxSize.y/64);
            FloatRect	HITBOX=(*it)->getHitBox(Position+Vector2f(pos.x*64,(pos.y*64)+NAME.getGlobalBounds().height-((mBotRow-MaxRows)*64)));
            if(HITBOX.contains(Current.mouseButton.x,Current.mouseButton.y)
                    &&pos.y>=mBotRow-int(mMaxSize.y/64))
            {
                if((*it)->getType()=="Player")
                {
                    mHolder->setPlayer(new	Player(Vector2f(0,0)));
                    mHolder->mChange=true;
                }
                else
                {
                    if((*it)->getType()=="Platform")
                    {
                        mHolder->setUnit(new Platform(Vector2f(0,0),(*it)->getSpriteName(),(*it)->getSize(),(*it)->getOffset()));
                    }
                    else if((*it)->getType()=="DialogueBox")
                    {
                        mHolder->setUnit(new DialogueBox(Vector2f(0,0),(*it)->getSpriteName(),"",true,true,"DialogueBox"));
                    }
                    else if((*it)->getType()=="Checkpoint")
                    {
                        mHolder->setUnit(new Checkpoint(Vector2f(0,0),(*it)->getSize(),(*it)->getOffset(),new Animation((*it)->getSpriteName(),(*it)->getSpeed(),(*it)->getFrames())));
                    }
                    else if((*it)->getType()=="LaserHolder")
                    {
                        mHolder->setUnit(new LaserHolder(new Laser(Vector2f(0,0),"Blue",true,100,0),"LaserBlueId",Vector2f(200,300),Vector2f(-100,-100)));
                    }
                    else if((*it)->getType()=="Trigger")
                    {
                        mHolder->setUnit(new Trigger(Vector2f(0,0),(*it)->getSize(),(*it)->getOffset(),(*it)->getType(),(*it)->getSpriteName(),0,""));
                    }
                    else if((*it)->getType()=="Meanix")
                    {
                        Player* play=0;
                        if(mHolder->getPlayCont().isActive())
                        {
                            play = mHolder->getPlayCont().getObject();
                        }
                        else
                        {
                            play = new Player(Vector2f(0,0));
                        }
                        mHolder->setUnit(new Meanix(Vector2f(0,0),"MeanixAni","MeanixAniL",play));
                    }
                    else
                    {
                        sf::Vector2f	offset=(*it)->getOffset(),size=(*it)->getSize();
                        if((*it)->getFrames()>1)
                        {
                            if(size.x>0||size.y>0||offset.x>0||offset.y>0)
                            {
                                mHolder->setUnit(new Unit(Vector2f(0,0),size,offset,(*it)->getType(),new Animation((*it)->getSpriteName(),(*it)->getSpeed(),(*it)->getFrames())));
                            }
                            else
                            {
                                mHolder->setUnit(new Unit(Vector2f(0,0),(*it)->getType(),new Animation((*it)->getSpriteName(),(*it)->getSpeed(),(*it)->getFrames())));
                            }
                        }
                        else
                        {
                            if(size.x>0||size.y>0||offset.x>0||offset.y>0)
                            {
                                mHolder->setUnit(new Unit(Vector2f(0,0),size,offset,(*it)->getType(),(*it)->getSpriteName()));
                            }
                            else
                            {
                                mHolder->setUnit(new Unit(Vector2f(0,0),(*it)->getType(),(*it)->getSpriteName()));
                            }
                        }
                    }
                    mHolder->mChange=true;
                }
                mSelected=false;
                mHolder->mChange=true;
                break;
            }
            i++;
        }
        if(!mHolder->mChange)
        {
            sf::FloatRect	RECT(Position,Vector2f(0,0));
            RECT.height=NAME.getGlobalBounds().height+4;
            RECT.width=mMaxSize.x;
            if(RECT.contains(Current.mouseButton.x,Current.mouseButton.y))
            {
                mSelected=false;
            }
            else
            {
                mSelected=true;
            }
        }
    }
    else if(Current.type==sf::Event::EventType::KeyPressed)
    {
        if(Current.key.code==sf::Keyboard::Up&&mBotRow>int(mMaxSize.y/64))
        {
            mBotRow--;
        }
        else if(Current.key.code==sf::Keyboard::Down&&mBotRow<int(mIcons.size()/2))
        {
            mBotRow++;
        }
    }
}
Exemplo n.º 24
0
RECT RockCreator::getBounding()
{
	return RECT();
}
Exemplo n.º 25
0
	ComponentGroup::ComponentGroup()
		: Component(NULL, RECT()),
		  mFocusedComponent(NULL), mName("Root Component")
	{
	}
Exemplo n.º 26
0
IoObject *IoCairoRectangle_width(IoCairoRectangle *self, IoObject *locals, IoMessage *m)
{
	return IONUMBER(RECT(self)->width);
}
Exemplo n.º 27
0
Arquivo: ps.c Projeto: 00001/plan9port
Document*
initps(Biobuf *b, int argc, char **argv, uchar *buf, int nbuf)
{
	Document *d;
	PSInfo *ps;
	char *p;
	char *q, *r;
	char eol;
	char *nargv[1];
	char fdbuf[20];
	char tmp[32];
	int fd;
	int i;
	int incomments;
	int cantranslate;
	int trailer=0;
	int nesting=0;
	int dumb=0;
	int landscape=0;
	long psoff;
	long npage, mpage;
	Page *page;
	Rectangle bbox = Rect(0,0,0,0);

	if(argc > 1) {
		fprint(2, "can only view one ps file at a time\n");
		return nil;
	}

	fprint(2, "reading through postscript...\n");
	if(b == nil){	/* standard input; spool to disk (ouch) */
		fd = spooltodisk(buf, nbuf, nil);
		sprint(fdbuf, "/dev/fd/%d", fd);
		b = Bopen(fdbuf, OREAD);
		if(b == nil){
			fprint(2, "cannot open disk spool file\n");
			wexits("Bopen temp");
		}
		nargv[0] = fdbuf;
		argv = nargv;
	}

	/* find %!, perhaps after PCL nonsense */
	Bseek(b, 0, 0);
	psoff = 0;
	eol = 0;
	for(i=0; i<16; i++){
		psoff = Boffset(b);
		if(!(p = Brdline(b, eol='\n')) && !(p = Brdline(b, eol='\r'))) {
			fprint(2, "cannot find end of first line\n");
			wexits("initps");
		}
		if(p[0]=='\x1B')
			p++, psoff++;
		if(p[0] == '%' && p[1] == '!')
			break;
	}
	if(i == 16){
		werrstr("not ps");
		return nil;
	}

	/* page counting */
	npage = 0;
	mpage = 16;
	page = emalloc(mpage*sizeof(*page));
	memset(page, 0, mpage*sizeof(*page));

	cantranslate = goodps;
	incomments = 1;
Keepreading:
	while(p = Brdline(b, eol)) {
		if(p[0] == '%')
			if(chatty) fprint(2, "ps %.*s\n", utfnlen(p, Blinelen(b)-1), p);
		if(npage == mpage) {
			mpage *= 2;
			page = erealloc(page, mpage*sizeof(*page));
			memset(&page[npage], 0, npage*sizeof(*page));
		}

		if(p[0] != '%' || p[1] != '%')
			continue;

		if(prefix(p, "%%BeginDocument")) {
			nesting++;
			continue;
		}
		if(nesting > 0 && prefix(p, "%%EndDocument")) {
			nesting--;
			continue;
		}
		if(nesting)
			continue;

		if(prefix(p, "%%EndComment")) {
			incomments = 0;
			continue;
		}
		if(reverse == -1 && prefix(p, "%%PageOrder")) {
			/* glean whether we should reverse the viewing order */
			p[Blinelen(b)-1] = 0;
			if(strstr(p, "Ascend"))
				reverse = 0;
			else if(strstr(p, "Descend"))
				reverse = 1;
			else if(strstr(p, "Special"))
				dumb = 1;
			p[Blinelen(b)-1] = '\n';
			continue;
		} else if(prefix(p, "%%Trailer")) {
			incomments = 1;
			page[npage].offset = Boffset(b)-Blinelen(b);
			trailer = 1;
			continue;
		} else if(incomments && prefix(p, "%%Orientation")) {
			if(strstr(p, "Landscape"))
				landscape = 1;
		} else if(incomments && Dx(bbox)==0 && prefix(p, q="%%BoundingBox")) {
			bbox = rdbbox(p+strlen(q)+1);
			if(chatty)
				/* can't use %R because haven't initdraw() */
				fprint(2, "document bbox [%d %d %d %d]\n",
					RECT(bbox));
			continue;
		}

		/*
		 * If they use the initgraphics command, we can't play our translation tricks.
		 */
		p[Blinelen(b)-1] = 0;
		if((q=strstr(p, "initgraphics")) && ((r=strchr(p, '%'))==nil || r > q))
			cantranslate = 0;
		p[Blinelen(b)-1] = eol;

		if(!prefix(p, "%%Page:"))
			continue;

		/* 
		 * figure out of the %%Page: line contains a page number
		 * or some other page description to use in the menu bar.
		 * 
		 * lines look like %%Page: x y or %%Page: x
		 * we prefer just x, and will generate our
		 * own if necessary.
		 */
		p[Blinelen(b)-1] = 0;
		if(chatty) fprint(2, "page %s\n", p);
		r = p+7;
		while(*r == ' ' || *r == '\t')
			r++;
		q = r;
		while(*q && *q != ' ' && *q != '\t')
			q++;
		free(page[npage].name);
		if(*r) {
			if(*r == '"' && *q == '"')
				r++, q--;
			if(*q)
				*q = 0;
			page[npage].name = estrdup(r);
			*q = 'x';
		} else {
			snprint(tmp, sizeof tmp, "p %ld", npage+1);
			page[npage].name = estrdup(tmp);
		}

		/*
		 * store the offset info for later viewing
		 */
		trailer = 0;
		p[Blinelen(b)-1] = eol;
		page[npage++].offset = Boffset(b)-Blinelen(b);
	}
	if(Blinelen(b) > 0){
		fprint(2, "page: linelen %d\n", Blinelen(b));
		Bseek(b, Blinelen(b), 1);
		goto Keepreading;
	}

	if(Dx(bbox) == 0 || Dy(bbox) == 0)
		bbox = Rect(0,0,612,792);	/* 8½×11 */
	/*
	 * if we didn't find any pages, assume the document
	 * is one big page
	 */
	if(npage == 0) {
		dumb = 1;
		if(chatty) fprint(2, "don't know where pages are\n");
		reverse = 0;
		goodps = 0;
		trailer = 0;
		page[npage].name = "p 1";
		page[npage++].offset = 0;
	}

	if(npage+2 > mpage) {
		mpage += 2;
		page = erealloc(page, mpage*sizeof(*page));
		memset(&page[mpage-2], 0, 2*sizeof(*page));
	}

	if(!trailer)
		page[npage].offset = Boffset(b);

	Bseek(b, 0, 2); /* EOF */
	page[npage+1].offset = Boffset(b);

	d = emalloc(sizeof(*d));
	ps = emalloc(sizeof(*ps));
	ps->page = page;
	ps->npage = npage;
	ps->bbox = bbox;
	ps->psoff = psoff;

	d->extra = ps;
	d->npage = ps->npage;
	d->b = b;
	d->drawpage = psdrawpage;
	d->pagename = pspagename;

	d->fwdonly = ps->clueless = dumb;
	d->docname = argv[0];
	/*
	 * "tag" the doc as an image for now since there still is the "blank page"
	 * problem for ps files.
	 */
	d->type = Tgfx;

	if(spawngs(&ps->gs, "-dSAFER") < 0)
		return nil;

	if(!cantranslate)
		bbox.min = ZP;
	setdim(&ps->gs, bbox, ppi, landscape);

	if(goodps){
		/*
		 * We want to only send the page (i.e. not header and trailer) information
	 	 * for each page, so initialize the device by sending the header now.
		 */
		pswritepage(d, ps->gs.gsfd, -1);
		waitgs(&ps->gs);
	}

	if(dumb) {
		fprint(ps->gs.gsfd, "(%s) run\n", argv[0]);
		fprint(ps->gs.gsfd, "(/dev/fd/3) (w) file dup (THIS IS NOT A PLAN9 BITMAP 01234567890123456789012345678901234567890123456789\\n) writestring flushfile\n");
	}

	ps->bbox = bbox;

	return d;
}
Exemplo n.º 28
0
#include <stdlib.h>
#include <types.h>
#include <gamelib.h>
#include "androiddata.h"

#include "require_android.h"

AndroidData _DATA = {
	.prev          = RECT(0,0,0,0),
	.next_event    = GAME_EVENT_NONE,
	.c_touch       = VECTOR(0,0),
	.c_dir         = VECTOR(0,0),
	.c_button      = 0,
	.c_is_touching = 0,
	.env           = NULL,
	.bitmap        = NULL,
	.gd            = NULL,
	.was_init      = 0,
	.pixels        = NULL
};

Exemplo n.º 29
0
 rectangle() : m_rect(RECT()) {}
Exemplo n.º 30
0
RECT ShadowBeast::getBounding()
{
	return RECT();
}