コード例 #1
0
ファイル: link_timectrl.cpp プロジェクト: artemeliy/inf4715
int		LinkTimeControl::PaintFCurves( ParamDimensionBase *dim, HDC hdc, Rect& rcGraph, Rect& rcPaint,
			float tzoom, int tscroll, float vzoom, int vscroll, DWORD flags )
{
	const int n = NumKeys();
	if ( n == 0 )
		return 0;

	Interval valid;
	int h = rcGraph.h()-1;
	HPEN dpen,spen;
	BOOL init=FALSE;		
	Interval range = GetTimeRange(TIMERANGE_ALL);	
	SetBkMode(hdc,TRANSPARENT);	

	dpen = CreatePen(PS_DOT,0,GetColorManager()->GetColor(kFunctionCurveFloat));
	spen = CreatePen(PS_SOLID,0,GetColorManager()->GetColor(kFunctionCurveFloat));

	SIZE size;
	GetTextExtentPoint( hdc, _T("0"), 1, &size );

	float val;
	TimeValue leftTime = ScreenToTime(rcPaint.left,tzoom,tscroll);
	TimeValue rightTime = ScreenToTime(rcPaint.right,tzoom,tscroll);
	int x, y;

	// dotted line to left of keys
	if ( leftTime < range.Start() )
	{
		SelectObject(hdc,dpen);
		GetValue(range.Start(),&val,valid);
		y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
		MoveToEx(hdc,rcPaint.left,y,NULL);
		LineTo(hdc,TimeToScreen(range.Start(),tzoom,tscroll),y);
	}

	SelectObject(hdc,spen);

	// first node text
	{
		TimeValue t = GetKeyTime( 0 );
		if ( t >= leftTime && t <= rightTime )
		{
			GetValue(t,&val,valid);
			y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
			x = TimeToScreen(t,tzoom,tscroll);
			INode* node = fOwner->GetNode( 0 );
			DLTextOut( hdc, x, y-1-size.cy, node ? node->GetName() : _T("World") );
		}
	}

	// solid line between keys
	for ( int i=1; i<n; ++i )
	{
		TimeValue t0 = GetKeyTime( i-1 );
		TimeValue t1 = GetKeyTime( i );
		if ( t1 < leftTime || t0 > rightTime )
			continue;
		GetValue(t0,&val,valid);
		y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
		MoveToEx(hdc,TimeToScreen(t0,tzoom,tscroll),y,NULL);
		x = TimeToScreen(t1,tzoom,tscroll);
		LineTo(hdc,x,y);
		GetValue(t1,&val,valid);
		y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
		LineTo(hdc,x,y);

		INode* node = fOwner->GetNode( i );
		DLTextOut( hdc, x, y-1-size.cy, node ? node->GetName() : _T("World") );
	}

	// dotted line to right of keys
	if ( rightTime > range.End() )
	{
		SelectObject(hdc,dpen);
		GetValue(range.End(),&val,valid);
		y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
		MoveToEx(hdc,TimeToScreen(range.End(),tzoom,tscroll),y,NULL);
		LineTo(hdc,rcPaint.right,y);
	}

	SelectObject( hdc, spen );
	HBRUSH hUnselBrush = CreateSolidBrush(GetColorManager()->GetColor(kTrackbarKeys));
	HBRUSH hSelBrush = CreateSolidBrush(GetColorManager()->GetColor(kTrackbarSelKeys));

	// render keys themselves
	for ( int i=0; i<n; ++i )
	{
		TimeValue t = GetKeyTime( i );
		if ( t < leftTime || t > rightTime )
			continue;
		GetValue(t,&val,valid);
		y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
		x = TimeToScreen(t,tzoom,tscroll);
		SelectObject( hdc, IsKeySelected( i ) ? hSelBrush : hUnselBrush );
		Rectangle(hdc,x-3,y-3,x+3,y+3);
	}

	SetBkMode(hdc,OPAQUE);
	SelectObject(hdc,GetStockObject(BLACK_PEN));	

	DeleteObject(spen);
	DeleteObject(dpen);
	DeleteObject(hUnselBrush);
	DeleteObject(hSelBrush);

	return 0;
}
コード例 #2
0
ファイル: plAgeDescInterface.cpp プロジェクト: Hoikas/Plasma
BOOL plAgeDescInterface::DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
    case WM_INITDIALOG:
        fhDlg = hDlg;

#ifdef MAXASS_AVAILABLE
        if( fAssetManIface == nil )
            fAssetManIface = new MaxAssBranchAccess();
#endif

        // Make our bold font by getting the normal font and bolding
        if( fBoldFont == nil )
        {
            HFONT origFont = (HFONT)SendMessage( hDlg, WM_GETFONT, 0, 0 );
            LOGFONT origInfo, newInfo;
            GetObject( origFont, sizeof( origInfo ), &origInfo );
            memcpy( &newInfo, &origInfo, sizeof( newInfo ) );
            newInfo.lfWeight = FW_BOLD;

            fBoldFont = CreateFontIndirect( &newInfo );
        }

        if( fHiliteBrush == nil )
            fHiliteBrush = CreateSolidBrush( RGB( 255, 0, 0 ) );

        IInitControls();
        IFillAgeTree();
        return TRUE;

    case WM_DESTROY:
#ifdef MAXASS_AVAILABLE
        delete fAssetManIface;
        fAssetManIface = nil;
#endif
        return TRUE;

    // Day length spinner changed
    case CC_SPINNER_CHANGE:
        if (LOWORD(wParam) == IDC_DAYLEN_SPINNER ||
            LOWORD(wParam) == IDC_CAP_SPINNER ||
            LOWORD(wParam) == IDC_SEQPREFIX_SPIN )
        {
            fDirty = true;
            return TRUE;
        }
        break;

    case WM_CLOSE:
        ::SendMessage( fhDlg, WM_COMMAND, IDOK, 0 );
        return true;

    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDOK:
        case IDCANCEL:
            if( IMakeSureCheckedIn() )
            {
#ifdef MAXASS_AVAILABLE
                IUpdateCurAge();
#endif
                DestroyWindow(fhDlg);
                fhDlg = nil;
                fDirty = false;
                fCurAge = -1;
                fSpin = nil;
            }
            return TRUE;

//      case IDC_AGE_LIST:
//          if (HIWORD(wParam) == LBN_SELCHANGE)
//          {
//              IUpdateCurAge();
//              return TRUE;
//          }
//          break;
        
        case IDC_AGE_CHECKOUT:
            ICheckOutCurrentAge();
            return TRUE;

        case IDC_AGE_CHECKIN:
            ICheckInCurrentAge();
            return TRUE;

        case IDC_AGE_UNDOCHECKOUT:
            IUndoCheckOutCurrentAge();
            return TRUE;

        case IDC_AGE_NEW:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                INewAge();
                return TRUE;
            }
            break;

        case IDC_PAGE_NEW:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                INewPage();
                return TRUE;
            }
            break;

        case IDC_PAGE_DEL:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                HWND hPage = GetDlgItem(hDlg, IDC_PAGE_LIST);
                int sel = ListBox_GetCurSel(hPage);
                if (sel != LB_ERR)
                {
                    RemovePageItem( hPage, sel );
                    fDirty = true;
                }
                return TRUE;
            }
            break;

        case IDC_PAGE_LIST:
            if( HIWORD( wParam ) == LBN_SELCHANGE )
            {
                // Sel change
                HWND list = GetDlgItem( hDlg, IDC_PAGE_LIST );
                int sel = ListBox_GetCurSel( list );
                if( sel != LB_ERR )
                {
                    IEnablePageControls(true);

                    plAgePage *page = (plAgePage *)ListBox_GetItemData( list, sel );
                    CheckDlgButton( hDlg, IDC_ADM_DONTLOAD, ( page->GetFlags() & plAgePage::kPreventAutoLoad ) ? TRUE : FALSE );
                    CheckDlgButton( hDlg, IDC_ADM_LOADSDL, ( page->GetFlags() & plAgePage::kLoadIfSDLPresent ) ? TRUE : FALSE );
                    CheckDlgButton( hDlg, IDC_ADM_LOCAL_ONLY, ( page->GetFlags() & plAgePage::kIsLocalOnly ) ? TRUE : FALSE );
                    CheckDlgButton( hDlg, IDC_ADM_VOLATILE, ( page->GetFlags() & plAgePage::kIsVolatile ) ? TRUE : FALSE );
                }
                else
                    IEnablePageControls(false);
            }
            break;

        case IDC_ADM_DONTLOAD:
        case IDC_ADM_LOADSDL:
        case IDC_ADM_LOCAL_ONLY:
        case IDC_ADM_VOLATILE:
            ICheckedPageFlag(LOWORD(wParam));
            break;

        case IDC_EDITREG:
            // Ask the user to make sure they really want to do this
            if( GetAsyncKeyState( VK_SHIFT ) & (~1) )
            {
                if( MessageBox( hDlg, "Are you sure you wish to reassign the sequence prefix for this age?", "WARNING", MB_YESNO | MB_ICONEXCLAMATION ) == IDYES )
                {
                    int32_t prefix = (int32_t)IGetNextFreeSequencePrefix( IsDlgButtonChecked( hDlg, IDC_RSVDCHECK ) );
                    fSeqPrefixSpin->SetValue( ( prefix >= 0 ) ? prefix : -prefix, false );
                    fDirty = true;
                }
            }
            else
            {
                if( MessageBox( hDlg, "Editing the registry data for an age can be extremely dangerous and "
                                    "can cause instabilities and crashes, particularly with multiplayer. "
                                    "Are you sure you want to do this?", "WARNING", MB_YESNO | MB_ICONEXCLAMATION ) == IDYES )
                {
                    // Enable the controls
                    EnableWindow( GetDlgItem( hDlg, IDC_RSVDCHECK ), TRUE );
                    EnableWindow( GetDlgItem( hDlg, IDC_SEQPREFIX_EDIT ), TRUE );
                    EnableWindow( GetDlgItem( hDlg, IDC_SEQPREFIX_SPIN ), TRUE );
                }
            }
            return TRUE;

        case IDC_RSVDCHECK:
            fDirty = true;
            return FALSE;   // Still process as normal

        case IDC_BRANCHCOMBO:
            if( HIWORD( wParam ) == CBN_SELCHANGE )
            {
                int idx = SendDlgItemMessage( hDlg, IDC_BRANCHCOMBO, CB_GETCURSEL, 0, 0 );
                if( idx != CB_ERR )
                {
                    int id = SendDlgItemMessage( hDlg, IDC_BRANCHCOMBO, CB_GETITEMDATA, idx, 0 );

#ifdef MAXASS_AVAILABLE
                    fAssetManIface->SetCurrBranch( id );
#endif
                    IFillAgeTree();
                }
            }
            return TRUE;
        }
        break;

    case WM_PAINT:
        PAINTSTRUCT paintInfo;

        BeginPaint( hDlg, &paintInfo );

        if( fCurrAgeCheckedOut )
        {
            RECT    r;
            HWND    dummy = GetDlgItem( hDlg, IDC_AGEDESC );
            GetClientRect( dummy, &r );
            MapWindowPoints( dummy, hDlg, (POINT *)&r, 2 );

            for( int i = 0; i < 3; i++ )
            {
                InflateRect( &r, -1, -1 );
                FrameRect( paintInfo.hdc, &r, fHiliteBrush );
            }
        }

        EndPaint( hDlg, &paintInfo );
        return TRUE;

    case WM_NOTIFY:
        {
            NMHDR *hdr = (NMHDR*)lParam;

            // Message from the start date/time controls
            if (hdr->idFrom == IDC_DATE || hdr->idFrom == IDC_TIME)
            {
                if (hdr->code == NM_KILLFOCUS)
                {
                    plMaxAccelerators::Enable();
                    return TRUE;
                }
                else if (hdr->code == NM_SETFOCUS)
                {
                    plMaxAccelerators::Disable();
                    return TRUE;
                }
                // Time or date changed, set dirty
                else if (hdr->code == DTN_DATETIMECHANGE)
                {
                    fDirty = true;
                    return TRUE;
                }   
            }
            else if( hdr->idFrom == IDC_AGE_LIST )
            {
                if( hdr->code == NM_CUSTOMDRAW )
                {
                    // Custom draw notifications for our treeView control
                    LPNMTVCUSTOMDRAW    treeNotify = (LPNMTVCUSTOMDRAW)lParam;

                    if( treeNotify->nmcd.dwDrawStage == CDDS_PREPAINT )
                    {
                        // Sent at the start of redraw, lets us request more specific notifys
                        SetWindowLong( hDlg, DWL_MSGRESULT, CDRF_NOTIFYITEMDRAW );
                        return TRUE;
                    }
                    else if( treeNotify->nmcd.dwDrawStage == CDDS_ITEMPREPAINT )
                    {
                        // Prepaint on an item. We get to change item font and color here
                        int idx = SGetTreeData( hdr->hwndFrom, (HTREEITEM)treeNotify->nmcd.dwItemSpec );
/*                      if( item == nil || item->fType != plAgeFile::kBranch )
                        {
                            // Default drawing, with default font and such
                            SetWindowLong( hDlg, DWL_MSGRESULT, CDRF_DODEFAULT );
                            return TRUE;
                        }       
*/
                        // Color change (only if the item isn't selected)
                        if( (HTREEITEM)treeNotify->nmcd.dwItemSpec != TreeView_GetSelection( hdr->hwndFrom ) )
                        {
                            treeNotify->clrText = GetColorManager()->GetColor( kText );
                            treeNotify->clrTextBk = GetColorManager()->GetColor( kWindow );
                        }

                        if (idx == -1)
                        {
                            // Set a bold font for the branch headers
                            if( fBoldFont != nil )
                                SelectObject( treeNotify->nmcd.hdc, fBoldFont );
                        }

                        // Let Windows know we changed the font
                        SetWindowLong( hDlg, DWL_MSGRESULT, CDRF_NEWFONT );
                        return TRUE;
                    }
                    else
                        // Let the default handle it
                        return FALSE;
                }
                else if( hdr->code == TVN_SELCHANGING )
                {
                    SetWindowLong( hDlg, DWL_MSGRESULT, !IMakeSureCheckedIn() );
                    return TRUE;
                }
                else if( hdr->code == TVN_SELCHANGED )
                {
                    // Update the viewing age
                    IUpdateCurAge();
                    return TRUE;
                }
            }
        }
        break;
    }

    return FALSE;
}