コード例 #1
0
void
ActiveWindow::MoveTo(const Rect& r)
{
    if (rect.x == r.x &&
            rect.y == r.y &&
            rect.w == r.w &&
            rect.h == r.h)
    return;

    rect = r;
    CalcGrid();

    ListIter<View> v = view_list;
    while (++v)
    v->OnWindowMove();

    if (layout)
    layout->DoLayout(this);
}
コード例 #2
0
ファイル: DCollision.cpp プロジェクト: RaoMiao/freestyle
void Physics::AddHash( DActor *Actor, SBox Bound )
{
	DLogWriteSystem("Func AddHash Actor = %p, Bound=(%f,%f,%f ~ %f,%f,%f)", Actor, Bound.Min.X, Bound.Min.Y, Bound.Min.Z, Bound.Max.X, Bound.Max.Y, Bound.Max.Z );

	int SX = CalcGrid( Bound.Min, X ), SY = CalcGrid( Bound.Min, Y ), SZ = CalcGrid( Bound.Min, Z );
	int EX = CalcGrid( Bound.Max, X ), EY = CalcGrid( Bound.Max, Y ), EZ = CalcGrid( Bound.Max, Z );

	For( int X = SX; X <= EX; ++X ) For( int Y = SY; Y <= EY; ++Y ) For( int Z = SZ; Z <= EZ; ++Z )
	{

		// allocate memory if neccesary
		if( !Available )
		{
			AllocatedMemory.AddItem( Available = (SHashNode*) appMalloc( ONCE_ALLOC_NUM*sizeof(SHashNode), "Collision Hash" ) );
			For( int i = 0; i < ONCE_ALLOC_NUM-1; ++i )
				Available[i].Next = Available + i + 1;
			Available[ONCE_ALLOC_NUM-1].Next = NULL;
		}

		// Hash link
		SHashNode *Node = Available;
		Available = Available->Next;

		SHashNode *&Head = GetHashNode( X, Y, Z );
		Node->Next = Head;
		Head = Node;

		// set new node
#ifdef _DISABLE_REPMODE
		Node->nX = X;
		Node->nY = Y;
		Node->nZ = Z;
#else
		Node->Represent = CalcRepresent( X, Y, Z );
#endif
		Node->Actor		= Actor;
	}
コード例 #3
0
void
FormWindow::Init(const FormDef& def)
{
	if (def.GetRect().w > 0 && def.GetRect().h > 0) {
		// if form size is specified in def, and it is 
		// smaller than the current screen size,
		// center the form on the display:

		Rect r = def.GetRect();

		if (r.w < screen->Width()) {
			r.x = (screen->Width()  - r.w) / 2;
		}
		else {
			r.x = 0;
			r.w = screen->Width();
		}

		if (r.h < screen->Height()) {
			r.y = (screen->Height() - r.h) / 2;
		}
		else {
			r.y = 0;
			r.h = screen->Height();
		}

		MoveTo(r);
	}

	SetMargins(def.GetMargins());
	SetTextInsets(def.GetTextInsets());
	SetCellInsets(def.GetCellInsets());
	SetCells(def.GetCells());
	SetFixedWidth(def.GetFixedWidth());
	SetFixedHeight(def.GetFixedHeight());

	UseLayout(def.GetLayout().x_mins,
	def.GetLayout().y_mins,
	def.GetLayout().x_weights,
	def.GetLayout().y_weights);

	if (def.GetTexture().length() > 0) {
		DataLoader* loader = DataLoader::GetLoader();
		loader->SetDataPath("Screens/");
		loader->LoadTexture(def.GetTexture(), texture);
		loader->SetDataPath("");
	}

	SetBackColor(def.GetBackColor());
	SetForeColor(def.GetForeColor());

	Font* f = FontMgr::Find(def.GetFont());
	if (f) SetFont(f);

	SetTransparent(def.GetTransparent());

	ListIter<CtrlDef> ctrl = def.GetControls();
	while (++ctrl) {
		switch (ctrl->GetType()) {
		case WIN_DEF_FORM:
		case WIN_DEF_LABEL:
		default:
			CreateDefLabel(*ctrl);
			break;

		case WIN_DEF_BUTTON:
			CreateDefButton(*ctrl);
			break;

		case WIN_DEF_COMBO:
			CreateDefCombo(*ctrl);
			break;

		case WIN_DEF_IMAGE:
			CreateDefImage(*ctrl);
			break;

		case WIN_DEF_EDIT:
			CreateDefEdit(*ctrl);
			break;

		case WIN_DEF_LIST:
			CreateDefList(*ctrl);
			break;

		case WIN_DEF_SLIDER:
			CreateDefSlider(*ctrl);
			break;

		case WIN_DEF_RICH:
			CreateDefRichText(*ctrl);
			break;
		}
	}

	RegisterControls();
	DoLayout();
	CalcGrid();
}
コード例 #4
0
void
ActiveWindow::SetMargins(const Insets& m)
{
    margins = m;
    CalcGrid();
}