Ejemplo n.º 1
0
// DetachBst Method
bool cSocketContextPool::DetachBst(PerSocketContext* perSocketContext)
{
	PerSocketContext* parent = perSocketContext->parent;
	PerSocketContext* left   = perSocketContext->left;
	PerSocketContext* right  = perSocketContext->right;
	PerSocketContext* child  = NULL;

	if ( left == NULL )
	{
		child = right;
	}
	else if ( right == NULL )
	{
		child = left;
	}
	else
	{
		child = right;
		while ( child->left != NULL ) child = child->left;

		if ( child->parent != NULL && child->parent != perSocketContext )
		{
			SetLeft( child->parent, child->right );
			SetRight( child, right );
		}
		child->parent = parent;
		SetLeft( child, left );
	}

	if ( mBstRoot == perSocketContext )
	{
		mBstRoot = child;
		if ( mBstRoot != NULL ) mBstRoot->parent = NULL;
	}
	else if ( perSocketContext == parent->left )
	{
		SetLeft( parent, child );
	}
	else
	{
		SetRight( parent, child );
	}

	perSocketContext->parent = NULL;
	perSocketContext->left   = NULL;
	perSocketContext->right  = NULL;

	return true;
}
Ejemplo n.º 2
0
void wxRect2DDouble::Union( const wxPoint2DDouble &pt )
{
    wxDouble x = pt.m_x;
    wxDouble y = pt.m_y;

    if ( x < m_x )
    {
        SetLeft( x );
    }
    else if ( x < m_x + m_width )
    {
        // contained
    }
    else
    {
        SetRight( x );
    }

    if ( y < m_y )
    {
        SetTop( y );
    }
    else if ( y < m_y + m_height )
    {
        // contained
    }
    else
    {
        SetBottom( y );
    }
}
Ejemplo n.º 3
0
// AttachBst Method
bool cSocketContextPool::AttachBst(PerSocketContext* perSocketContext)
{
	PerSocketContext* parent = NULL;
	PerSocketContext* child  = mBstRoot;
	int               result;


	//2014-7-28 14:57:34, oiooooio
	//原来是while(child != NULL),因为这里出现过死循环,故加了一个条件判断
	for (int i = mQuotaPagedPoolUsage*2; i > 0 && child != NULL; --i)
	{
		parent = child;
		result = CompareCID( child->cid, perSocketContext->cid );

		if ( result == 0 ) return false;
		else if ( result > 0 ) child = child->left;
		else if ( result < 0 ) child = child->right;
	}

	if ( parent == NULL )
	{
		mBstRoot = perSocketContext;
	}
	else if ( CompareCID( parent, perSocketContext ) > 0 )
	{
		SetLeft( parent, perSocketContext );
	}
	else // if ( CompareCID( parent, perSocketContext ) < 0 )
	{
		SetRight( parent, perSocketContext );
	}
	return true;
}
Ejemplo n.º 4
0
		BaseForm::DialogResult BaseForm::ShowModal(BaseForm * owner)
		{
			MSG msg;
			dlgOwner = owner;
			dlgOwner->SetEnabled(false);
			dlgResult = BaseForm::Cancel;
			if (firstShown)
			{
				int l = (owner->GetWidth()-GetWidth())/2;
				int t = (owner->GetHeight()-GetHeight())/2;
				SetLeft(l+owner->GetLeft());
				SetTop(t+owner->GetTop());
				firstShown = false;
			}
			Show();

			while (GetMessage(&msg, NULL, 0,0)>0)
			{
				HWND hwnd = GetActiveWindow();
				if (!accelTable || !TranslateAccelerator(hwnd, 
					accelTable->GetHandle(), &msg))
				{
					TranslateMessage(&msg);
					DispatchMessage(&msg);
				}
				if (closed)
					break;
			}
			dlgOwner->SetEnabled(true);
			//SetActiveWindow(dlgOwner->GetHandle());
			dlgOwner = NULL;
			return dlgResult;
		}
Ejemplo n.º 5
0
 JoystickFeature(const JOYSTICK_FEATURE& feature) :
     m_name(feature.name ? feature.name : ""),
     m_type(feature.type)
 {
     switch (m_type)
     {
     case JOYSTICK_FEATURE_TYPE_SCALAR:
         SetPrimitive(feature.scalar.primitive);
         break;
     case JOYSTICK_FEATURE_TYPE_ANALOG_STICK:
         SetUp(feature.analog_stick.up);
         SetDown(feature.analog_stick.down);
         SetRight(feature.analog_stick.right);
         SetLeft(feature.analog_stick.left);
         break;
     case JOYSTICK_FEATURE_TYPE_ACCELEROMETER:
         SetPositiveX(feature.accelerometer.positive_x);
         SetPositiveY(feature.accelerometer.positive_y);
         SetPositiveZ(feature.accelerometer.positive_z);
         break;
     case JOYSTICK_FEATURE_TYPE_MOTOR:
         SetPrimitive(feature.motor.primitive);
         break;
     default:
         break;
     }
 }
Ejemplo n.º 6
0
void UI::Element::Maximize()
{
	SetLeft(0);
	SetBottom(0);
	SetWidth(app->Screen->w);
	SetHeight(app->Screen->h);
}
Ejemplo n.º 7
0
void wxRect2DInt::ConstrainTo( const wxRect2DInt &rect )
{
    if ( GetLeft() < rect.GetLeft() )
        SetLeft( rect.GetLeft() );

    if ( GetRight() > rect.GetRight() )
        SetRight( rect.GetRight() );

    if ( GetBottom() > rect.GetBottom() )
        SetBottom( rect.GetBottom() );

    if ( GetTop() < rect.GetTop() )
        SetTop( rect.GetTop() );
}
Ejemplo n.º 8
0
//--------------------------------------------------------------------
void CForm::Create( IGUIControl* p_pParent, int p_nLeft, int p_nTop,
                    int p_nWidth, int p_nHeight )
{
    IGUIControl::Create();
    SetParent( p_pParent );
    SetLeft( p_nLeft );
    SetTop( p_nTop );
    SetWidth( p_nWidth );
    SetHeight( p_nHeight );
    if( m_pColor == NULL )
    {
        SetFontColor( *(new CColor( CColor::WHITE )) );
    }
}
Ejemplo n.º 9
0
	//--------------------------------------------------------------------
	void CButton::Create( IGUIControl* p_pParent, int p_nLeft, int p_nTop, 
		CBitmap& p_Bitmap,const std::wstring& p_szCaption )
	{
		IGUIControl::Create();
		SetParent( p_pParent );
		SetLeft( p_nLeft );
		SetTop( p_nTop );
		SetGlygh( p_Bitmap );
		SetCaption( p_szCaption );
		if( m_pColor == NULL )
		{
			SetFontColor( *(new CColor( CColor::WHITE )) );
		}
	}
Ejemplo n.º 10
0
//--------------------------------------------------------------------
void CForm::MouseMove( POINT p_Point )
{
    if( !m_bMoveable )
    {
        return;
    }

    if( m_bHolding )
    {
        SetLeft( p_Point.x - m_OffsetPT.x );
        SetTop( p_Point.y - m_OffsetPT.y );
    }

    IGUIControl::MouseMove( p_Point );
}
Ejemplo n.º 11
0
//--------------------------------------------------------------------
void CForm::Create( IGUIControl* p_pParent, int p_nLeft, int p_nTop,
                    CBitmap& p_Bitmap )
{
    IGUIControl::Create();
    SetParent( p_pParent );
    SetLeft( p_nLeft );
    SetTop( p_nTop );
    SetBG( p_Bitmap );
    SetWidth( p_Bitmap.Width() );
    SetHeight( p_Bitmap.Height() );
    if( m_pColor == NULL )
    {
        SetFontColor( *(new CColor( CColor::WHITE )) );
    }
}
Ejemplo n.º 12
0
KString& KString::SetMid(size_t szStart, size_t szCount)
{
	if(szStart > GetLength())
		throw 1;

	if(szCount == UINT_MAX)
		szCount = GetLength() - szStart;

	if(szStart + szCount > GetLength())
		throw 1;

	return SetLeft(szStart + szCount).SetRight(szCount);

	return *this;
}
Ejemplo n.º 13
0
	//--------------------------------------------------------------------
	void CScrollBar::Create(  IGUIControl* p_pParent, int p_nLeft, int p_nTop,
		ENUM_ScrollBarType p_eType, CBitmap& p_Bitmap, int p_nLength )
	{
		IGUIControl::Create();

		SetParent( p_pParent );
		SetLeft( p_nLeft );
		SetTop( p_nTop );
		SetType( p_eType );
		SetLength( p_nLength );
		SetSlider( p_Bitmap );
		if( m_pColor == NULL )
		{
			SetFontColor( *(new CColor( CColor::WHITE )) );
		}
	}
Ejemplo n.º 14
0
void Scrollbar::Thumb::Arrange()
{
  if (auto sb = _scrollbar.lock())
  {
    auto scrollDelegate = sb->GetScrollDelegate();

    auto p = GetParent();
    SetLeft(p->GetLeft());
    SetRight(p->GetRight());
    auto trackHeight = p->GetHeight();
    auto height      = scrollDelegate->GetThumbSizePercent() * trackHeight;
    auto top         = p->GetTop() + (scrollDelegate->GetCurrentOffsetPercent() * trackHeight);
    SetTop(std::round(top));
    SetBottom(std::round(top + height));
  }
}
Ejemplo n.º 15
0
void CDiagramEntity::SetRect( double left, double top, double right, double bottom )
/* ============================================================
	Function :		CDiagramEntity::SetRect
	Description :	Sets the object rect.
					
	Return :		void
	Parameters :	double left		-	Left edge
					double top		-	Top edge
					double right	-	Right edge
					double bottom	-	Bottom edge
					
	Usage :			Call to place the object.

   ============================================================*/
{

	SetLeft( left );
	SetTop( top );
	SetRight( right );
	SetBottom( bottom );

	if( GetMinimumSize().cx != -1 )
		if( GetRect().Width() < GetMinimumSize().cx )
			SetRight( GetLeft() + GetMinimumSize().cx );

	if( GetMinimumSize().cy != -1 )
		if( GetRect().Height() < GetMinimumSize().cy )
			SetBottom( GetTop() + GetMinimumSize().cy );

	if( GetMaximumSize().cx != -1 )
		if( GetRect().Width() > GetMaximumSize().cx )
			SetRight( GetLeft() + GetMaximumSize().cx );

	if( GetMaximumSize().cy != -1 )
		if( GetRect().Height() > GetMaximumSize().cy )
			SetBottom( GetTop() + GetMaximumSize().cy );

  if( GetPropertySheet() )
		GetPropertySheet()->SetValues();

}
Ejemplo n.º 16
0
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg,
        WPARAM wParam, LPARAM lParam)
{
    switch(uMsg)
    {
        case WM_CREATE:
            OleInitialize(NULL);
            PaneRegisterClassW();
            TypeLibRegisterClassW();
            if(!CreatePanedWindow(hWnd, &globals.hPaneWnd, globals.hMainInst))
                PostQuitMessage(0);
            SetLeft(globals.hPaneWnd, CreateTreeWindow(globals.hMainInst));
            SetRight(globals.hPaneWnd, CreateDetailsWindow(globals.hMainInst));
            SetFocus(globals.hTree);
            break;
        case WM_COMMAND:
            MenuCommand(LOWORD(wParam), hWnd);
            break;
        case WM_DESTROY:
            OleUninitialize();
            EmptyTree();
            PostQuitMessage(0);
            break;
        case WM_MENUSELECT:
            UpdateStatusBar(LOWORD(wParam));
            break;
        case WM_SETFOCUS:
            SetFocus(globals.hTree);
            break;
        case WM_SIZE:
            if(wParam == SIZE_MINIMIZED) break;
            ResizeChild();
            break;
        default:
            return DefWindowProcW(hWnd, uMsg, wParam, lParam);
    }
    return 0;
}
Ejemplo n.º 17
0
void UI::Element::SetCenter(const ScreenPoint& center)
{
	SetLeft(center[0] - GetWidth() / 2);
	SetBottom(center[1] - GetHeight() / 2);
}
Ejemplo n.º 18
0
int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE /*hPrevInstance*/,
                       LPTSTR    lpCmdLine,
                       int       /*nCmdShow*/)
{
    SetDllDirectory(L"");
    SetTaskIDPerUUID();
    CRegStdDWORD loc = CRegStdDWORD(L"Software\\TortoiseGit\\LanguageID", 1033);
    long langId = loc;
    CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);

    CLangDll langDLL;
    hResource = langDLL.Init(L"TortoiseIDiff", langId);
    if (!hResource)
        hResource = hInstance;

    git_libgit2_init();

    CCmdLineParser parser(lpCmdLine);

    if (parser.HasKey(L"?") || parser.HasKey(L"help"))
    {
        TCHAR buf[1024] = { 0 };
        LoadString(hResource, IDS_COMMANDLINEHELP, buf, _countof(buf));
        MessageBox(nullptr, buf, L"TortoiseIDiff", MB_ICONINFORMATION);
        langDLL.Close();
        return 0;
    }


    MSG msg;
    hInst = hInstance;

    INITCOMMONCONTROLSEX used = {
        sizeof(INITCOMMONCONTROLSEX),
        ICC_STANDARD_CLASSES | ICC_BAR_CLASSES | ICC_WIN95_CLASSES
    };
    InitCommonControlsEx(&used);

    // load the cursors we need
    curHand = static_cast<HCURSOR>(LoadImage(hInst, MAKEINTRESOURCE(IDC_PANCUR), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE));
    curHandDown = static_cast<HCURSOR>(LoadImage(hInst, MAKEINTRESOURCE(IDC_PANDOWNCUR), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE));

    auto mainWindow = std::make_unique<CMainWindow>(hResource);
    mainWindow->SetRegistryPath(L"Software\\TortoiseGit\\TortoiseIDiffWindowPos");
    std::wstring leftfile = parser.HasVal(L"left") ? parser.GetVal(L"left") : L"";
    std::wstring rightfile = parser.HasVal(L"right") ? parser.GetVal(L"right") : L"";
    if ((leftfile.empty()) && (lpCmdLine[0] != 0))
    {
        int nArgs;
        LPWSTR * szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
        if (szArglist)
        {
            if (nArgs == 3)
            {
                // Four parameters:
                // [0]: Program name
                // [1]: left file
                // [2]: right file
                if (PathFileExists(szArglist[1]) && PathFileExists(szArglist[2]))
                {
                    leftfile = szArglist[1];
                    rightfile = szArglist[2];
                }
            }
        }

        // Free memory allocated for CommandLineToArgvW arguments.
        LocalFree(szArglist);
    }
    mainWindow->SetLeft(leftfile.c_str(), parser.HasVal(L"lefttitle") ? parser.GetVal(L"lefttitle") : L"");
    mainWindow->SetRight(rightfile.c_str(), parser.HasVal(L"righttitle") ? parser.GetVal(L"righttitle") : L"");
    if (parser.HasVal(L"base"))
        mainWindow->SetSelectionImage(FileTypeBase, parser.GetVal(L"base"), parser.HasVal(L"basetitle") ? parser.GetVal(L"basetitle") : L"");
    if (parser.HasVal(L"mine"))
        mainWindow->SetSelectionImage(FileTypeMine, parser.GetVal(L"mine"), parser.HasVal(L"minetitle") ? parser.GetVal(L"minetitle") : L"");
    if (parser.HasVal(L"theirs"))
        mainWindow->SetSelectionImage(FileTypeTheirs, parser.GetVal(L"theirs"), parser.HasVal(L"theirstitle") ? parser.GetVal(L"theirstitle") : L"");
    if (parser.HasVal(L"result"))
        mainWindow->SetSelectionResult(parser.GetVal(L"result"));
    mainWindow->resolveMsgWnd = parser.HasVal(L"resolvemsghwnd") ? reinterpret_cast<HWND>(parser.GetLongLongVal(L"resolvemsghwnd")) : 0;
    mainWindow->resolveMsgWParam = parser.HasVal(L"resolvemsgwparam") ? static_cast<WPARAM>(parser.GetLongLongVal(L"resolvemsgwparam")) : 0;
    mainWindow->resolveMsgLParam = parser.HasVal(L"resolvemsglparam") ? static_cast<LPARAM>(parser.GetLongLongVal(L"resolvemsglparam")) : 0;
    if (mainWindow->RegisterAndCreateWindow())
    {
        HACCEL hAccelTable = LoadAccelerators(hResource, MAKEINTRESOURCE(IDR_TORTOISEIDIFF));
        if (!parser.HasVal(L"left") && parser.HasVal(L"base") && !parser.HasVal(L"mine") && !parser.HasVal(L"theirs"))
        {
            PostMessage(*mainWindow, WM_COMMAND, ID_FILE_OPEN, 0);
        }
        if (parser.HasKey(L"overlay"))
        {
            PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_OVERLAPIMAGES, 0);
        }
        if (parser.HasKey(L"fit"))
        {
            PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_FITIMAGEHEIGHTS, 0);
            PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_FITIMAGEWIDTHS, 0);
        }
        if (parser.HasKey(L"fitwidth"))
        {
            PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_FITIMAGEWIDTHS, 0);
        }
        if (parser.HasKey(L"fitheight"))
        {
            PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_FITIMAGEHEIGHTS, 0);
        }
        if (parser.HasKey(L"showinfo"))
        {
            PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_IMAGEINFO, 0);
        }
        // Main message loop:
        while (GetMessage(&msg, nullptr, 0, 0))
        {
            if (!TranslateAccelerator(*mainWindow, hAccelTable, &msg))
            {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
        }
        return static_cast<int>(msg.wParam);
    }
    langDLL.Close();
    DestroyCursor(curHand);
    DestroyCursor(curHandDown);
    CoUninitialize();
    git_libgit2_shutdown();
    return 1;
}
Ejemplo n.º 19
0
	inline void VMatrix::SetBasisVectors( const Vector &vForward, const Vector &vLeft, const Vector &vUp ) {
		SetForward( vForward );
		SetLeft( vLeft );
		SetUp( vUp );
	}