Exemplo n.º 1
0
void CMenu::Move(int n)
{
    int lines = SafeConvert<int>(m_MenuList.size()), curyoffset = m_iYOffset, curcursor = m_iCursorLine;
    int h = Height()-2;

    if (n < 0)
    {
        int nabs = abs(n);
        if (nabs > m_iCursorLine)
        {
            int rest = (nabs - m_iCursorLine);
            
            if (rest > m_iYOffset)
            {
                m_iYOffset = 0;
                VScroll(0, false);
            }
            else
                m_iYOffset -= rest;
            
            m_iCursorLine = 0;
        }
        else
            m_iCursorLine -= nabs;
    }
    else
    {
        int newpos = m_iCursorLine + n;
        if (((newpos+m_iYOffset) >= lines) || (newpos < m_iCursorLine)) // Don't go past menu size and prevent overflows
            newpos = ((lines-1) - m_iYOffset);
        
        m_iCursorLine = newpos;
    }

    if (m_iCursorLine >= h)
    {
        m_iYOffset += (m_iCursorLine - (h-1));
        
        int max = lines - h;
        if (m_iYOffset > max)
            m_iYOffset = max;
                
        m_iCursorLine = h-1;
    }
    
    if (curyoffset != m_iYOffset)
        VScroll(m_iYOffset, false);
    
    if ((curyoffset != m_iYOffset) || (curcursor != m_iCursorLine))
    {
        RequestQueuedDraw();
        PushEvent(EVENT_DATACHANGED);
    }
}
Exemplo n.º 2
0
void ScrollViewUp( LPCLASSDATA lpcd )
{
	int	nLines = ArrayGetSize( lpcd->lpLines ) - 1;

	/*
	 *	Are we there already?
	 */
	if (( lpcd->ptViewPos.y + lpcd->szViewSize.cy - 1 ) < nLines )
	{
		/*
		 *	Go down one.
		 */
		lpcd->ptViewPos.y++;
		VScroll( lpcd, -1 );

		/*
		 *	Setup the scroller.
		 */
		SetupVScroller( lpcd );

		/*
		 *	Caret OK?
		 */
		if ( lpcd->ptCaretPos.y < lpcd->ptViewPos.y )
		{
			/*
			 *	Make it visible.
			 */
			lpcd->ptCaretPos.y = lpcd->ptViewPos.y;
			lpcd->ptCaretPos.x = lpcd->nLastColumnPos = 0;
			UpdateCaret( lpcd );
		}
	}
}
Exemplo n.º 3
0
void ScrollViewDown( LPCLASSDATA lpcd )
{
	/*
	 *	Are we there already?
	 */
	if ( lpcd->ptViewPos.y > 0 )
	{
		/*
		 *	Go up one.
		 */
		lpcd->ptViewPos.y--;
		VScroll( lpcd, 1 );

		/*
		 *	Setup the scroller.
		 */
		SetupVScroller( lpcd );

		/*
		 *	Caret OK?
		 */
		if ( lpcd->ptCaretPos.y > ( lpcd->ptViewPos.y + lpcd->szViewSize.cy - 1 ))
		{
			/*
			 *	Make it visible.
			 */
			lpcd->ptCaretPos.y = lpcd->ptViewPos.y + lpcd->szViewSize.cy - 1;
			lpcd->ptCaretPos.x = lpcd->nLastColumnPos = 0;
			UpdateCaret( lpcd );
		}
	}
}
Exemplo n.º 4
0
// could use Window event table for this stuff
BOOL Window::WndProc(TMSG &Msg)
{
	// handle internal actions
	switch (Msg.Msg)
	{
		case WM_QUERYENDSESSION:
		case WM_CLOSE:
			if (!CanClose()) return TRUE; //returns 0
			break;
		case WM_DESTROY:  // quit if main window
			if (this==App::MainWindow) App::Quit();
			if (Flags & W_SAVEPOS) SaveWindowState();
			Flags|=W_DESTROYED;
			Destroy();
			// MainWindow is deleted on program exit
			if (this==App::MainWindow) App::Quit();
			else delete this;
			return TRUE;
		case WM_PAINT:
			PAINTSTRUCT  ps;
			BeginPaint(hWnd, (LPPAINTSTRUCT) &ps);
			SetWindowOrgEx(ps.hdc,xPos,yPos,NULL);
			Paint(ps.hdc,ps.fErase,ps.rcPaint);

			if (StatBar) // draw statbar after window
			{
				SetWindowOrgEx(ps.hdc,0,0,NULL); // dont scroll statbar
				StatBar->Paint(ps.hdc);
			}
			EndPaint(hWnd, (LPPAINTSTRUCT) &ps);
			break;

		case WM_HSCROLL:			HScroll(Msg); break;
		case WM_VSCROLL:			VScroll(Msg); break;
		case WM_SIZE:				WMSize(Msg); break;
		case WM_GETMINMAXINFO:	WMGetMinMaxInfo(Msg); break;
		case WM_COMMAND:
		{
			int id=LOWORD(Msg.wParam);
			if (id>MRU_ID && id<=MRU_ID+MRU_MAX)
			{
				OpenFile(MruList[id-MRU_ID-1]);
				return TRUE;
			}
			else if (id>MRU2_ID && id<=MRU2_ID+MRU_MAX)
			{
				OpenFile2(MruList2[id-MRU2_ID-1]);
				return TRUE;
			}
			break;
		}
		case WM_INITMENU:
			InitMenu((HMENU) Msg.wParam); // handle of menu to initialize 
			break;
 	}
	if (StatBar) StatBar->EV_FIND(Msg);
	//allow user to grab any message
	return EV_FIND(Msg);
}
Exemplo n.º 5
0
void batch_crop(){
  if(!batchGUI){
    batchGUI = new HSplit;
    (*batchGUI) << ( VBox()
                     << String("").handle("ipat").label("input file pattern")
                     << String("converted-####.png").handle("opat").label("output file pattern")
                     << Button("do it!").handle("do it")
                   )
                << VScroll().handle("matches").label("matching files")
                << Create();
    (*batchGUI)["ipat"].registerCallback(batch_pattern_changed<false>);
    (*batchGUI)["do it"].registerCallback(batch_pattern_changed<true>);
  }
  (*batchGUI).show();
}
Exemplo n.º 6
0
BOOL CompositeDlg::PanelProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) 
	{
	int id = LOWORD(wParam);
	int code = HIWORD(wParam);
    switch (msg)    {
		case WM_INITDIALOG: {			
			hScroll	= GetDlgItem(hWnd,IDC_COMP_SCROLL);
			SetScrollRange(hScroll,SB_CTL,0,theTex->NumSubTexmaps()-NDLG,FALSE);
			SetScrollPos(hScroll,SB_CTL,theTex->offset,TRUE);
			EnableWindow(hScroll,theTex->NumSubTexmaps()>NDLG);
			for (int i=0; i<NDLG; i++) {
				iBut[i] = GetICustButton(GetDlgItem(hWnd,IDC_COMP_TEX1+i));
				iBut[i]->SetDADMgr(&dadMgr);
//				if (i-theTex->offset<theTex->mapOn.Count())
//					SetCheckBox(hWnd, mapOnIDs[i], theTex->mapOn[i-theTex->offset]);
				}
			return TRUE;
			}
			
		case WM_PAINT:
			if (!valid) {
				valid = TRUE;
				ReloadDialog();
				}
			return FALSE;

		case WM_VSCROLL:
			VScroll(LOWORD(wParam),(short int)HIWORD(wParam));
			break;
			
		case WM_COMMAND: 		    		 	
			switch (id) {		
				case IDC_COMP_TEX1: PostMessage(hwmedit,WM_TEXMAP_BUTTON,theTex->offset,(LPARAM)theTex); break;
				case IDC_COMP_TEX2: PostMessage(hwmedit,WM_TEXMAP_BUTTON,theTex->offset+1,(LPARAM)theTex); break;
				case IDC_COMP_TEX3: PostMessage(hwmedit,WM_TEXMAP_BUTTON,theTex->offset+2,(LPARAM)theTex); break;
				case IDC_COMP_TEX4: PostMessage(hwmedit,WM_TEXMAP_BUTTON,theTex->offset+3,(LPARAM)theTex); break;
				case IDC_COMP_TEX5: PostMessage(hwmedit,WM_TEXMAP_BUTTON,theTex->offset+4,(LPARAM)theTex); break;
				case IDC_COMP_TEX6: PostMessage(hwmedit,WM_TEXMAP_BUTTON,theTex->offset+5,(LPARAM)theTex); break;

				case IDC_MAPON1:							
				case IDC_MAPON2:							
				case IDC_MAPON3:							
				case IDC_MAPON4:							
				case IDC_MAPON5:							
				case IDC_MAPON6:
					theTex->pblock->SetValue(comptex_ons,0,GetCheckBox(hWnd, id),id-IDC_MAPON1+theTex->offset);
//					theTex->mapOn[id-IDC_MAPON1+theTex->offset] = GetCheckBox(hWnd, id);
					theTex->NotifyChanged();
					break;							
									
				case IDC_COMP_SETNUM:
					SetNumMaps();
					break;
				}			
			break;
				
		case WM_DESTROY:
			Destroy(hWnd);
			break;
    	}
	return FALSE;
	}
Exemplo n.º 7
0
static void MakeVisible( LPCLASSDATA lpcd, BOOL bRedraw )
{
	int	nDiffY = lpcd->ptViewPos.y;
	BOOL	bRender = FALSE;

	/*
	 *	Is the caret visible?
	 */
	if ( CaretInView( lpcd ) == FALSE )
	{
		/*
		 *	Get "real" caret position.
		 */
		int	nXPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

		/*
		 *	Is it in the view horizontally?
		 */
		if (( nXPos < lpcd->ptViewPos.x ) || ( nXPos > lpcd->ptViewPos.x + ( lpcd->szViewSize.cx - 1 )))
		{
			lpcd->ptViewPos.x = max( 0, nXPos - ( lpcd->szViewSize.cx ) / 2 );
			bRender = TRUE;
		}

		/*
		 *	Is it in the view vertically?
		 */
		if ( lpcd->ptCaretPos.y < lpcd->ptViewPos.y )
		{
			lpcd->ptViewPos.y = lpcd->ptCaretPos.y;
		}
		else if ( lpcd->ptCaretPos.y > lpcd->ptViewPos.y + ( lpcd->szViewSize.cy - 1 ))
		{
			lpcd->ptViewPos.y = max( 0, lpcd->ptCaretPos.y - ( lpcd->szViewSize.cy - 1 ));
		}

		/*
		 *	Redraw?
		 */
		if ( bRedraw )
		{
			/*
			 *	Compute difference in Y direction.
			 */
			nDiffY = nDiffY - lpcd->ptViewPos.y;

			/*
			 *	View moved?
			 */
			if ( nDiffY != 0 && bRender == FALSE )
			{
				/*
				 *	Scroll view.
				 */
				VScroll( lpcd, nDiffY );

				/*
				 *	Setup vertical scroller.
				 */
				SetupVScroller( lpcd );
			}
			else if ( bRender == TRUE )
			{
				/*
				 *	Setup scrollers.
				 */
				SetupHScroller( lpcd );
				SetupVScroller( lpcd );

				/*
				 *	Re-render.
				 */
				InvalidateRect( lpcd->hWnd, NULL, TRUE );
			}
		}
	}
}
Exemplo n.º 8
0
Arquivo: game.c Projeto: yxrkt/DigiPen
//******************//
// Helper Functions //
//******************//
void Move()
{
    struct ControllerState cont = GetControllerState();
    bool moving = FALSE;
    
    // move player
    if ( cont.left  )
    {
        if ( g_cam_x > 0 && ((g_hippy.x + g_hippy.w / 2) == (SCREEN_WIDTH / 2)) )
            HScroll(-WALK_SPEED);
        else if ( g_hippy.x > 0 )
            g_hippy.x -= WALK_SPEED;

        g_hippy.baseFrame = FACE_SIDE;
        ham_SetObjHFlip(g_hippy.sprite, FALSE);
        moving = TRUE;
    }
    if ( cont.right  )
    {
        if ( g_cam_x < (MAP_WIDTH - SCREEN_WIDTH - 1) && ((g_hippy.x + g_hippy.w / 2) == (SCREEN_WIDTH / 2)) )
            HScroll(WALK_SPEED);
        else if ( g_hippy.x < (SCREEN_WIDTH - g_hippy.w) )
            g_hippy.x += WALK_SPEED;

        if ( !moving )
        {
            g_hippy.baseFrame = FACE_SIDE;
            ham_SetObjHFlip(g_hippy.sprite, TRUE);
            moving = TRUE;
        }
    }
    if ( cont.up  )
    {
        if ( g_cam_y > 0 && ((g_hippy.y + g_hippy.h / 2) == (SCREEN_HEIGHT / 2)) )
            VScroll(-WALK_SPEED);
        else if ( g_hippy.y > 0 )
            g_hippy.y -= WALK_SPEED;

        if ( !moving )
        {
            g_hippy.baseFrame = FACE_UP;
            moving = TRUE;
        }
    }
    if ( cont.down  )
    {
        if ( g_cam_y < (MAP_HEIGHT - SCREEN_HEIGHT - 1) && ((g_hippy.y + g_hippy.h / 2) == (SCREEN_HEIGHT / 2)) )
            VScroll(WALK_SPEED);
        else if ( g_hippy.y < (SCREEN_HEIGHT - g_hippy.h) )
            g_hippy.y += WALK_SPEED;

        if ( !moving )
        {
            g_hippy.baseFrame = FACE_DOWN;
            moving = TRUE;
        }
    }

    // move player
    ham_SetBgXY(0, g_cam_x, g_cam_y);
    ham_SetObjXY(g_hippy.sprite, g_hippy.x, g_hippy.y);
    
    // move shroom
    ham_SetObjXY(g_shroom.sprite, g_shroom.x, g_shroom.y);
    
    // move key
    ham_SetObjXY(g_key.sprite, g_key.x, g_key.y);
    
    // set hippy frame
    int animIndex = g_hippy.w * g_hippy.h * (g_hippy.baseFrame + g_hippy.frameDif);
    ham_UpdateObjGfx(g_hippy.sprite, (void *)&hippy_bitmap[animIndex]);
    
    g_count++;
    if ( moving && ((g_count % HIPPY_TPF) == 0) )
        g_hippy.frameDif =(g_hippy.frameDif + 1) % HIPPY_FRAMES;
}