Esempio n. 1
0
void TSplitter::DoMouseUp(const TPoint& mouse, TMouseButton button, TModifierState state)
{
	if (fTracking && button == kLeftButton)
	{
		TPoint point;
		ConstrainMouse(mouse, point);

		if (!fLiveDrag)
		{
			TRect	rect;
			GetTrackingRect(fLastMouse, rect);
			DrawTrackingRect(rect);

			TRect bounds;
			GetLocalBounds(bounds);

			if (fVertical)
				fRatio = (float)point.h / (float)bounds.GetWidth();	
			else
				fRatio = (float)point.v / (float)bounds.GetHeight();
			
			if (fRatio < 0.0)
				fRatio = 0.0;
			else if (fRatio > 1.0)
				fRatio = 1.0;

			ResizeChildren();
		}

		fTracking = false;
	}
}
Esempio n. 2
0
void View::Resize(const Viewport& p)
{
    // Compute Bounds based on specification
    v.l = AttachAbs(p.l,p.r(),left);
    v.b = AttachAbs(p.b,p.t(),bottom);
    int r = AttachAbs(p.l,p.r(),right);
    int t = AttachAbs(p.b,p.t(),top);

    // Make sure left and right, top and bottom are correct order
    if( t < v.b ) std::swap(t,v.b);
    if( r < v.l ) std::swap(r,v.l);

    v.w = r - v.l;
    v.h = t - v.b;

    vp = v;

    // Adjust based on aspect requirements
    if( aspect != 0 )
    {
        const float current_aspect = (float)v.w / (float)v.h;
        if( aspect > 0 )
        {
            // Fit to space
            if( current_aspect < aspect )
            {
                //Adjust height
                const int nh = (int)(v.w / aspect);
                v.b += vlock == LockBottom ? 0 : (vlock == LockCenter ? (v.h-nh)/2 : (v.h-nh) );
                v.h = nh;
            }else if( current_aspect > aspect )
            {
                //Adjust width
                const int nw = (int)(v.h * aspect);
                v.l += hlock == LockLeft? 0 : (hlock == LockCenter ? (v.w-nw)/2 : (v.w-nw) );
                v.w = nw;
            }
        }else{
            // Overfit
            double true_aspect = -aspect;
            if( current_aspect < true_aspect )
            {
                //Adjust width
                const int nw = (int)(v.h * true_aspect);
                v.l += hlock == LockLeft? 0 : (hlock == LockCenter ? (v.w-nw)/2 : (v.w-nw) );
                v.w = nw;
            }else if( current_aspect > true_aspect )
            {
                //Adjust height
                const int nh = (int)(v.w / true_aspect);
                v.b += vlock == LockBottom ? 0 : (vlock == LockCenter ? (v.h-nh)/2 : (v.h-nh) );
                v.h = nh;
            }
        }
    }

    ResizeChildren();
}
LRESULT CPropertyEditWindow::OnAdd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
    CPropertyAddDialog dialog;

    // Add the property categories
    for(size_t i = 0; i < m_arrPropertyInfo.GetCount(); i++)
    {
        if(m_arrPropertyInfo.GetAt(i)->IsWriteable() == S_OK)
        {
            LPWSTR szPropertyCategory;
            TED_ATTRIBUTE_CATEGORY Category;
            m_arrPropertyInfo.GetAt(i)->GetPropertyInfoName(&szPropertyCategory, &Category);
        
            dialog.AddPropertyCategory(szPropertyCategory, Category, (DWORD) i);
        
            CoTaskMemFree(szPropertyCategory);
        }
    }
    
    // Fill dialog properties
    if(dialog.DoModal() == IDOK)
    {
        DWORD dwIndex = dialog.GetChosenCategory();
        CAtlStringW strName = dialog.GetChosenProperty();
        CAtlStringW strValue = dialog.GetValue();
        ITedPropertyInfo* pPropertyInfo = m_arrPropertyInfo.GetAt(dwIndex);
        
        for(DWORD i = 0; i < TEDGetAttributeListLength(); i++)
        {
            if(TEDGetAttributeName(i) == strName)
            {
                DWORD dwPropertyCount;
                
                pPropertyInfo->GetPropertyCount(&dwPropertyCount);
                pPropertyInfo->SetProperty(dwPropertyCount, strName.GetBuffer(), TEDGetAttributeType(i), strValue.GetBuffer());

                RECT clientRect;
                GetClientRect(&clientRect);
                DWORD dwViewWidth = clientRect.right - clientRect.left - 5;
        
                RECT rectNextLabel;
                rectNextLabel.top = 5 + (ms_LabelHeight * dwPropertyCount);
                rectNextLabel.left = 5;
                rectNextLabel.right = rectNextLabel.left + dwViewWidth / 2;
                rectNextLabel.bottom = rectNextLabel.top + ms_LabelHeight;
                
                CreatePropertyInterfaceForIndex(dwIndex, dwPropertyCount, rectNextLabel);
                ResizeChildren();

                break;
            }
        }
    }

    return 0;
}
Esempio n. 4
0
OptionsDialog::OptionsDialog()
	: Frame(gui, "OptionsDialog", rect(), "Options", true, false, true, true)
{	
	Button* b;
	int x;
	
	SetSize(265, 185);
	Center();

//Create section frames
	rect r(10,55,mPosition.w - 20, mPosition.h - 55);
	
	mFrameUser = new Frame(this, "User", r);
	mFrameNetwork = new Frame(this, "Network", r);
	mFrameAudio = new Frame(this, "Audio", r);
	mFrameGraphics = new Frame(this, "Graphics", r);

	_buildFrameUser();
	_buildFrameNetwork();
	_buildFrameAudio();
	_buildFrameGraphics();

	Toggle("User");
	
//Create toggle buttons
	x = 10;
	b = new Button(this, "User",rect(x,30,20,20), "", callback_optionsDialogTab);
		b->mHoverText = "User";
		b->SetImage("assets/buttons/options_user.png");
	x += 25;
	
	b = new Button(this, "Network",rect(x,30,20,20), "", callback_optionsDialogTab);
		b->mHoverText = "Network";
		b->SetImage("assets/buttons/options_network.png");
	x += 25;
	
/*	b = new Button(this, "Audio",rect(x,30,20,20), "", callback_optionsDialogTab);
		b->mHoverText = "Audio";
		b->SetImage("assets/buttons/options_audio.png");
	x += 25;
*/	
	b = new Button(this, "Graphics",rect(x,30,20,20), "", callback_optionsDialogTab);
		b->mHoverText = "Graphics";
		b->SetImage("assets/buttons/options_video.png");
	x += 25;
	
//Create save button
	b = new Button(this, "save",rect(Width()-30,Height()-30,20,20), "", callback_optionsDialogSave);
		b->mHoverText = "Save Options";
		b->SetImage("assets/buttons/okay.png");

	ResizeChildren();
}
Esempio n. 5
0
// Called when one of the children have changed size
void CGridContainerNode::RecalculateParentSize(MSWindows::HDC hDC)
{
	ASSERT(0);
#if 0
	m_size.cx = 0;

	int maxx = GetChildrenWidth();
	ResizeChildren(hDC, maxx);

	CalculateChildrenSize();

	int y = 0;

	UPOSITION pos = m_childList.GetHeadPosition();
	while (pos)
	{
		CGridItem* pChild = (CGridItem*)m_childList.GetNext(pos);

		pChild->m_pos.y = y;
		y += pChild->m_size.cy;
	}

	if (m_parent)
	{
		CComBSTR tagName;
		m_domNode->get_nodeName(&tagName);

		SelectObject(hDC, m_pUI->m_hFont[Font_ElementName]);

		CRect rc(0,0,0,0);
		DrawText(hDC, sysstring(tagName), tagName.Length(), &rc, DT_CALCRECT | DT_SINGLELINE);

		m_nameHeight = rc.Height();

		m_size.cx += m_childrenIndent;//20;
		m_size.cy += m_nameHeight;

		{
			UPOSITION pos = m_childList.GetHeadPosition();
			while (pos)
			{
				CGridItem* pChild = (CGridItem*)m_childList.GetNext(pos);

				pChild->m_pos.x = m_childrenIndent;//20;
				pChild->m_pos.y += m_nameHeight;
			}
		}

		m_parent->RecalculateParentSize(hDC);
	}
#endif
}
Esempio n. 6
0
FReply SSplitter2x2::OnMouseMove( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
{
	const FVector2D LocalMousePos = MyGeometry.AbsoluteToLocal( MouseEvent.GetScreenSpacePosition() );

	if ( bIsResizing && this->HasMouseCapture() )
	{	
		TArray<FLayoutGeometry> LayoutChildren = ArrangeChildrenForLayout(MyGeometry);
		ResizeChildren( MyGeometry, LayoutChildren, LocalMousePos );
		return FReply::Handled();
	}
	else
	{	
		ResizingAxis = CalculateResizingAxis( MyGeometry, LocalMousePos );
		return FReply::Unhandled();
	}
}
Esempio n. 7
0
void TSplitter::DoMouseMoved(const TPoint& mouse, TModifierState state)
{
	if (fTracking)
	{
		TPoint point;
		ConstrainMouse(mouse, point);

		if ((fVertical && fLastMouse.h != point.h) ||
			(!fVertical && fLastMouse.v != point.v))
		{
			if (fLiveDrag)
			{
				TRect bounds;
				GetLocalBounds(bounds);

				if (fVertical)
					fRatio = (float)point.h / (float)bounds.GetWidth();	
				else
					fRatio = (float)point.v / (float)bounds.GetHeight();
				
				if (fRatio < 0.0)
					fRatio = 0.0;
				else if (fRatio > 1.0)
					fRatio = 1.0;

				ResizeChildren();

				TDrawContext	context(this);
				DrawSplitterRect(context);
			}
			else
			{
				TRect	rect;

				GetTrackingRect(fLastMouse, rect);
				DrawTrackingRect(rect);
				GetTrackingRect(point, rect);
				DrawTrackingRect(rect);
			}
		}

		fLastMouse = point;
	}
}
Esempio n. 8
0
void TSplitter::SetChildren(TWindow* child1, TWindow* child2)
{
	ASSERT(!fChild1 && !fChild2);
	
	fChild1 = child1;
	fChild2 = child2;

	if (child1)
	{
		ASSERT(child1->GetParent() == this);
		//child1->SetParent(this);
	}
	if (child2)
	{
		ASSERT(child2->GetParent() == this);
		//child2->SetParent(this);
	}

	ResizeChildren();
}
Esempio n. 9
0
OpenUrl::OpenUrl(string url)
	: Frame(gui, "OpenUrl", rect(0,0,300,100), "Open Url", true, false, true, true)
{
	mUrl = url;
	
	url = "How do you want to open: \\c239" + url;
	
	Label* l;
	l = new Label(this, "caption", rect(5, 30, 0, 0));
	l->mMaxWidth = OPENURL_MAX_WIDTH - 10;
	l->SetCaption(url);
	
	//set width based on label caption, up to max
	uShort w = l->Width();
	uShort h = l->Height();

	w += 10;
	h += 30 + 30;
	
	if (w < OPENURL_MIN_WIDTH)
		w = OPENURL_MIN_WIDTH;

	SetSize(w, h);
	
	//center label
	l->Center();

	Button* b;
	b = new Button(this, "", rect(Width()-25,Height()-25,20,20), "", callback_OpenUrlDefaultBrowser);
		b->mHoverText = "Open in default web browser";
		b->SetImage("assets/buttons/web.png");
					
	b = new Button(this, "", rect(Width()-50,Height()-25,20,20), "", callback_OpenUrlCopy);
		b->mHoverText = "Copy to clipboard";
		b->SetImage("assets/buttons/clipboard.png");

	ResizeChildren();
	Center();
	DemandFocus();
}
Esempio n. 10
0
void GameManager::Process(uLong ms)
{
	if (mLoader && mLoader->m_state == WorldLoader::WORLD_READY)
	{
		mLoader->DisplayWorld();
		mLoader->Die();
		mLoader = NULL;
		ResizeChildren();
	}

	//Keep map at lowest level of our widgets
	if (!IsMapLoading() && mMap)
	{
		if (loginDialog)
			loginDialog->Die();

		mMap->MoveToBottom();
		mMap->Process();
	}

	MoveToBottom(); //keep game at the bottom of the screen.
}
Esempio n. 11
0
AvatarCreator::AvatarCreator(int workingIndex, string url)
    : Frame(gui, "AvatarCreator", rect(), "Avatar Designer (BETA)", true, false, true, true)
{
    SetSize(230, 225);
    Center();

    mHeadColor = mBodyColor = mHairColor = color(255,255,255);
    mHead = mBody = mHair = mFullComposite = mCompositePreview = NULL;
    mRedraw = false;
    mWorkingIndex = workingIndex;

    CreateControls();
    ResizeChildren();

    mBase = avatarBases[0];
    mHeadFile = mBase + ".head.default.png";
    mBodyFile = mBase + ".body.default.png";
    mHairFile = mBase + ".hair.default.png";

    resman->Unload(mHead);
    mHead = resman->LoadImg(DIR_AVA + mHeadFile);
    if (!mHead)
        SetError("Could not load " + mHeadFile);

    resman->Unload(mBody);
    mBody = resman->LoadImg(DIR_AVA + mBodyFile);
    if (!mBody)
        SetError("Could not load " + mBodyFile);

    resman->Unload(mHair);
    mHair = resman->LoadImg(DIR_AVA + mHairFile);
    if (!mHair)
        SetError("Could not load " + mHairFile);

    Update();

    if (!url.empty())
        ImportUrl(url);
}
Esempio n. 12
0
void TSplitter::NotifyBoundsChanged(const TRect& /*oldBounds*/)
{
	ResizeChildren();
}
LRESULT CPropertyEditWindow::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    ResizeChildren();

    return 0;
}
Esempio n. 14
0
/*ARGSUSED*/
static Boolean
Layout(FormWidget fw, unsigned int width, unsigned int height,
       Bool force_relayout)
{
    int num_children = fw->composite.num_children;
    WidgetList children = fw->composite.children;
    Widget *childP;
    Dimension maxx, maxy;
    Boolean ret_val;

    for (childP = children; childP - children < num_children; childP++) {
	FormConstraints form = (FormConstraints)(*childP)->core.constraints;
	form->form.layout_state = LayoutPending;
    }

    maxx = maxy = 1;
    for (childP = children; childP - children < num_children; childP++) {
	if (XtIsManaged(*childP)) {
	    FormConstraints form;
	    Position x, y;

	    form = (FormConstraints)(*childP)->core.constraints;

	    LayoutChild(*childP);

	    x = form->form.new_x + XtWidth(*childP)
		+ (XtBorderWidth(*childP) << 1);
	    if (x > (int)maxx)
		maxx = x;

	    y = form->form.new_y + XtHeight(*childP)
		+ (XtBorderWidth(*childP) << 1);
	    if (y > (int)maxy)
		maxy = y;
	}
    }

    fw->form.preferred_width = (maxx += fw->form.default_spacing);
    fw->form.preferred_height = (maxy += fw->form.default_spacing);

    if (fw->form.resize_in_layout) {
	Boolean always_resize_children;

	always_resize_children =
	    ChangeFormGeometry((Widget)fw, False, maxx, maxy, NULL, NULL);

#ifdef OLDXAW
	fw->form.old_width  = fw->core.width;
	fw->form.old_height = fw->core.height;
#endif

	if (force_relayout)
	    ret_val = True;
	else
	    ret_val = always_resize_children ||
			(XtWidth(fw) >= maxx && XtHeight(fw) >= maxy);

	if (ret_val)
	    ResizeChildren((Widget)fw);
    }
    else
	ret_val = False;

    fw->form.needs_relayout = False;

    return (ret_val);
}
Esempio n. 15
0
void GameManager::Event(SDL_Event* event)
{
	MessageData md;
	switch (event->type)
	{
		case SDL_VIDEORESIZE:
			SetSize(gui->Width(), gui->Height());
			ResizeChildren();
			break;
		case SDL_MOUSEBUTTONDOWN:
			if (mMap && mMap->HasMouseFocus())
			{
				md.SetId("MAP_MOUSEDOWN");
				md.WriteInt("id", event->button.button);
				messenger.Dispatch(md);
			}
			break;
		case SDL_MOUSEBUTTONUP:
			if (mMap && mMap->HasMouseFocus())
			{
				md.SetId("MAP_MOUSEUP");
				md.WriteInt("id", event->button.button);
				messenger.Dispatch(md);
			}
			break;
		case SDL_MOUSEMOTION:
			if (mMap && mMap->HasMouseFocus())
			{
				md.SetId("MAP_MOUSEMOVE");
				md.WriteInt("x", event->motion.x);
				md.WriteInt("y", event->motion.y);
				messenger.Dispatch(md);
			}
			break;
		case SDL_KEYDOWN:
			if (HasKeyFocusInTree())
			{
				md.SetId("MAP_KEYDOWN");
				md.WriteInt("id", event->key.keysym.sym);
				messenger.Dispatch(md);

				if (event->key.keysym.sym == SDLK_TAB && mGameMode != MODE_DUEL)
				{
					ToggleGameMode( (mGameMode == MODE_ACTION) ? MODE_CHAT : MODE_ACTION );
				}
			}
			break;
		case SDL_KEYUP:
			if (HasKeyFocusInTree())
			{
				/*if (event->key.keysym.sym == SDLK_RSHIFT || event->key.keysym.sym == SDLK_LSHIFT)
				{
					achievement_StickyKeys();
				}*/

				md.SetId("MAP_KEYUP");
				md.WriteInt("id", event->key.keysym.sym);
				messenger.Dispatch(md);
			}
			break;
		default: break;
	}

	Frame::Event(event);

	if (!gui->hasKeyFocus || gui->hasKeyFocus == mMap)
	{
        if (mMap)
        { //TODO: Better redirection of mChat's focus
    		if (mGameMode != MODE_ACTION)
    			mMap->mChat->mInput->SetKeyFocus();
    		else if (mMap)
    			mMap->SetKeyFocus(true);
        }
	}
}