Ejemplo n.º 1
0
void  Ctrl::ScrollView(const Rect& _r, int dx, int dy)
{
	GuiLock __;
	LLOG("ScrollView " << _r << " " << dx << " " << dy);
	if(IsFullRefresh() || !IsVisible())
		return;
	Size vsz = GetSize();
	dx = sgn(dx) * min(abs(dx), vsz.cx);
	dy = sgn(dy) * min(abs(dy), vsz.cy);
	Rect r = _r & vsz;
	LLOG("ScrollView2 " << r << " " << dx << " " << dy);
	Ctrl *w;
	for(w = this; w->parent; w = w->parent)
		if(w->InFrame()) {
			Refresh();
			return;
		}
	if(!w || !w->top) return;
	Rect view = InFrame() ? GetView() : GetClippedView();
	Rect sr = (r + view.TopLeft()) & view;
	sr += GetScreenRect().TopLeft() - w->GetScreenRect().TopLeft();
	if(w->AddScroll(sr, dx, dy))
		Refresh();
	else {
		LTIMING("ScrollCtrls1");
		Top *top = GetTopCtrl()->top;
		for(Ctrl *q = GetFirstChild(); q; q = q->GetNext())
			if(q->InView())
				ScrollCtrl(top, q, r, q->GetRect(), dx, dy);
		if(parent)
			for(Ctrl *q = parent->GetFirstChild(); q; q = q->GetNext())
				if(q->InView() && q != this)
					ScrollCtrl(top, q, r, q->GetScreenRect() - GetScreenView().TopLeft(), dx, dy);
	}
}
Ejemplo n.º 2
0
HeaderCtrl& HeaderCtrl::Invisible(bool inv)
{
	invisible = inv;
	if(InFrame() && GetParent())
		RefreshParentLayout();
	return *this;
}
Ejemplo n.º 3
0
void BarCtrl::SyncBar()
{
	if(IsChild() && InFrame())
		UpdateParentLayout();
	else
		Layout();
}
Ejemplo n.º 4
0
void Ctrl::RefreshFrame(const Rect& r) {
	GuiLock __;
	if(!IsOpen() || !IsVisible() || r.IsEmpty()) return;
	LTIMING("RefreshFrame");
	LLOG("RefreshRect " << Name() << ' ' << r);
#ifdef PLATFORM_WIN32
	if(isdhctrl) {
		InvalidateRect(((DHCtrl *)this)->GetHWND(), r, false);
		return;
	}
#endif
	if(!top) {
		if(InFrame())
			parent->RefreshFrame(r + GetRect().TopLeft());
		else
			parent->Refresh(r + GetRect().TopLeft());
	}
	else {
		LLOG("WndInvalidateRect: " << r << ' ' << Name());
		LTIMING("RefreshFrame InvalidateRect");
		WndInvalidateRect(r);
#ifdef PLATFORM_WIN32
		LLOG("UpdateRect: " << GetWndUpdateRect() << ' ' << Name());
#endif
	}
}
Ejemplo n.º 5
0
Size ScrollBar::GetReducedViewSize() const {
	if(IsChild() && InFrame()) {
		Size sz = GetParent()->GetSize();
		if(!IsShown())
			(IsVert() ? sz.cx : sz.cy) -= ScrollBarSize();
		return sz;
	}
	return Size(0, 0);
}
Ejemplo n.º 6
0
F_access F_allocLocal(F_frame f, bool escape) {
  int offset = 0;
  F_accessList tail;
  for (F_accessList locals = f->locals; locals; locals = locals->tail)
    if (locals->head->kind == inFrame) offset -= F_wordSize;

  F_access l = (escape) ? InFrame(offset) : InReg(Temp_newtemp());
  f->locals = F_AccessList(l, f->locals);
  return l;
}
Ejemplo n.º 7
0
void ToolBar::Paint(Draw& w)
{
	if(IsTransparent())
		return;
	Value look = style->look;
	if(!IsNull(style->arealook) && (arealook < 0 ? InFrame() : arealook)) {
		PaintBarArea(w, this, style->arealook, GetScreenRect().bottom);
		look = Null;
	}
	PaintBar(w, style->breaksep, look);
}
Ejemplo n.º 8
0
double RulerCtrl::GetRawDelta() const
{
	if(IsNull(raw_delta)) {
		raw_delta = delta;
		if(InFrame()) {
			Point pt = GetScreenView().TopLeft(), par = GetParent() ? GetParent() -> GetScreenView().TopLeft() : pt;
			raw_delta -= (is_vert ? pt.y - par.y : pt.x - par.x);
		}
	}
	return raw_delta;
}
Ejemplo n.º 9
0
void BarCtrl::Layout()
{
	LLOG("BarCtrl::Layout");
	if(IsChild()) {
		bool dowrap = InFrame() && wrap >= 0 || wrap > 0;
		if(GetAlign() == BAR_LEFT || GetAlign() == BAR_RIGHT)
			pane.Repos(false, dowrap ? GetSize().cy : INT_MAX);
		else
			pane.Repos(true, dowrap ? GetSize().cx : INT_MAX);
	}
}
Ejemplo n.º 10
0
Ctrl *Ctrl::GetTopRect(Rect& r, bool inframe)
{
	GuiLock __;
	if(!inframe) {
		r &= Rect(GetSize());
		r.Offset(GetView().TopLeft());
	}
	if(parent) {
		r.Offset(GetRect().TopLeft());
		return parent->GetTopRect(r, InFrame());
	}
	return this;
}
Ejemplo n.º 11
0
void MenuBar::Paint(Draw& w)
{
	if(IsTransparent())
		return;
	if(GetParent())
		if(!IsNull(style->arealook) && (arealook < 0 ? InFrame() : arealook)) {
			PaintBarArea(w, this, style->arealook, (GetAlign() != BAR_TOP) ? GetScreenRect().bottom : Null);
			PaintBarArea(w, this, style->arealook);
			PaintBar(w, style->breaksep, Null);
		}
		else
			PaintBar(w, style->breaksep, style->look);
	else
		PaintBar(w, style->breaksep, style->popupbody, style->popupiconbar, Nvl(leftgap, style->leftgap));
}
Ejemplo n.º 12
0
//----------------------------------------------------------------//
void MOAIProfilerContext::LeaveScope ( const USHashedString& name ) {

	if ( !mProfilingEnabled ) {
		return;
	}

	if ( !InFrame () ) {
		return;
	}

	Frame& curFrame = mFrames [ mCurrentFrameIdx ];

	curFrame.mCurrentScope->Leave ( name );

	curFrame.mCurrentScope = curFrame.mCurrentScope->mParent;
}
Ejemplo n.º 13
0
F_frame F_newFrame(Temp_label label, U_boolList escape) {
  F_frame f = (F_frame)checked_malloc(sizeof(*f));
  f->label = label;
  int offset = 0;
  int reg = 0;

  F_accessList h = F_AccessList(NULL, NULL), p = h;
  for (; escape; escape = escape->tail) {
    if (escape->head == TRUE || reg >= regNum) {
      p->tail = F_AccessList(InFrame(offset += F_wordSize), NULL);
    } else {
      p->tail = F_AccessList(InReg(Temp_newtemp()), NULL);
    }
    p = p->tail;
  }
  f->formals = h->tail; free(h);
  return f;
}
Ejemplo n.º 14
0
void Ctrl::RefreshFrame(const Rect& r) {
	GuiLock __;
	if(!IsOpen() || !IsVisible() || r.IsEmpty()) return;
	LTIMING("RefreshFrame");
	LLOG("RefreshRect " << Name() << ' ' << r);
	if(GuiPlatformRefreshFrameSpecial(r))
		return;
	if(!top) {
		if(InFrame())
			parent->RefreshFrame(r + GetRect().TopLeft());
		else
			parent->Refresh(r + GetRect().TopLeft());
	}
	else {
		LLOG("WndInvalidateRect: " << r << ' ' << Name());
		LTIMING("RefreshFrame InvalidateRect");
		WndInvalidateRect(r);
	}
}
Ejemplo n.º 15
0
void Ctrl::RefreshFrame(const Rect& r) {
	sCheckGuiLock();
	GuiLock __; // Beware: Even if we have ThreadHasGuiLock ASSERT, we still can be the main thread!
	if(!IsOpen() || !IsVisible() || r.IsEmpty()) return;
	LTIMING("RefreshFrame");
	LLOG("RefreshRect " << Name() << ' ' << r);
	if(GuiPlatformRefreshFrameSpecial(r))
		return;
	if(!top) {
		if(InFrame())
			parent->RefreshFrame(r + GetRect().TopLeft());
		else
			parent->Refresh(r + GetRect().TopLeft());
	}
	else {
		LLOG("WndInvalidateRect: " << r << ' ' << Name());
		LTIMING("RefreshFrame InvalidateRect");
		WndInvalidateRect(r);
	}
}
Ejemplo n.º 16
0
//----------------------------------------------------------------//
void MOAIProfilerContext::EnterScope ( const USHashedString& name ) {
	
	if ( !mProfilingEnabled )
		return;

	if ( !InFrame () ) {
		return;
	}
	
	Frame& curFrame = mFrames [ mCurrentFrameIdx ];

	curFrame.mNumScopesEntered++;

	MOAIProfilerScope* scope = this->CreateScope ();
	scope->Enter ( curFrame.mCurrentScope, name );

	curFrame.mLastScope->mNext = scope;
	curFrame.mLastScope = scope;

	curFrame.mCurrentScope = scope;
}
Ejemplo n.º 17
0
//----------------------------------------------------------------//
void MOAIProfilerContext::BeginFrame ( const bool profilingEnabled ) {
	
	if ( InFrame () ) {
		EndFrame ();
	}

	if ( mProfilingEnabled != profilingEnabled )
		mProfilingEnabled = profilingEnabled;

	if ( !mProfilingEnabled )
		return;

	// Select the next frame
	mCurrentFrameIdx = ( mCurrentFrameIdx + 1 ) % NUM_FRAMES;
	Frame& curFrame = mFrames [ mCurrentFrameIdx ];

	curFrame.mNumScopesEntered = 0;

	curFrame.mCurrentScope = &curFrame.mRootScope;
	curFrame.mCurrentScope->Enter ( 0, curFrame.mCurrentScope->mName );

	curFrame.mLastScope = curFrame.mCurrentScope;
}
Ejemplo n.º 18
0
static F_accessList makeFormalAccessList(F_frame f, U_boolList formals)
{
	U_boolList fmls;
	F_accessList headList = NULL, tailList = NULL;
	int i = 1;
	for (fmls = formals; fmls; fmls = fmls->tail) {
		F_access access = NULL;
		if (i <= F_K && !fmls->head) {
			access = InReg(Temp_newtemp());
			i++;
		} else {
			/* Add 1 for return address space. */
			access = InFrame((1 + i) * F_WORD_SIZE);
		}
		if (headList) {
			tailList->tail = F_AccessList(access, NULL);
			tailList = tailList->tail;
		} else {
			headList = F_AccessList(access, NULL);
			tailList = headList;
		}
	}
	return headList;
}
Ejemplo n.º 19
0
void  Ctrl::ScrollView(const Rect& _r, int dx, int dy)
{
	GuiLock __;
	if(IsFullRefresh() || !IsVisible())
		return;
	Size vsz = GetSize();
	dx = sgn(dx) * min(abs(dx), vsz.cx);
	dy = sgn(dy) * min(abs(dy), vsz.cy);
	Rect r = _r & vsz;
	Ctrl *w;
	for(w = this; w->parent; w = w->parent)
		if(w->InFrame()) {
			Refresh();
			return;
		}
	if(!w || !w->top) return;
	Rect view = InFrame() ? GetView() : GetClippedView();
	Rect sr = (r + view.TopLeft()) & view;
	sr += GetScreenRect().TopLeft() - w->GetScreenRect().TopLeft();
	if(w->AddScroll(sr, dx, dy))
		Refresh();
	else {
		LTIMING("ScrollCtrls1");
		Top *top = GetTopCtrl()->top;
		for(Ctrl *q = GetFirstChild(); q; q = q->GetNext())
			if(q->InView()) {
				Rect cr = q->GetRect();
				if(top && r.Intersects(cr)) { // Uno: Contains -> Intersetcs
					Rect to = cr;
					GetTopRect(to, false);
					if(r.Intersects(cr.Offseted(-dx, -dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs
						Rect from = cr.Offseted(-dx, -dy);
						GetTopRect(from, false);
						MoveCtrl *m = FindMoveCtrlPtr(top->move, q);
						if(m && m->from == from && m->to == to) {
							LLOG("ScrollView Matched " << from << " -> " << to);
							m->ctrl = NULL;
							goto done;
						}
					}

					if(r.Intersects(cr.Offseted(dx, dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs
						Rect from = to;
						to = cr.Offseted(dx, dy);
						GetTopRect(to, false);
						MoveCtrl& m = top->scroll_move.Add(q);
						m.from = from;
						m.to = to;
						m.ctrl = q;
						LLOG("ScrollView Add " << UPP::Name(q) << from << " -> " << to);
						goto done;
					}
					cr &= r;
					if(!cr.IsEmpty()) {
						Refresh(cr);
						Refresh(cr + Point(dx, dy));
					}
				done:;
				}
			}
	}
}
Ejemplo n.º 20
0
//----------------------------------------------------------------//
void MOAIProfilerContext::EndFrame () {
	
	if ( !mProfilingEnabled )
		return;

	if ( !InFrame () ) {
		return;
	}
	
	Frame& curFrame = mFrames [ mCurrentFrameIdx ];

	assert( curFrame.mCurrentScope == &curFrame.mRootScope );

	curFrame.mCurrentScope->Leave ( curFrame.mCurrentScope->mName );
	curFrame.mCurrentScope = 0;
	curFrame.mLastScope = 0;

	if ( curFrame.mNumScopesEntered > 0 ) {

		// Don't allow the main thread to access the report while we are finializing it
		if ( mName != MOAIProfiler::kMainThreadName ) {
	
			mReportMutex.Lock ();
		}

		// Analyze the data and update scope averages
		mProfileReport.BeginUpdate ();

		curFrame.mCurrentScope = 0;

		MOAIProfilerScope* scope = curFrame.mRootScope.mNext;
		while ( scope ) {

			LeaveScopes ( curFrame, scope->mParent );

			mProfileReport.EnterScope ( scope->mName );
			curFrame.mCurrentScope = scope;

			scope = scope->mNext;
		}

		// Leave the first scope
		LeaveScopes ( curFrame, &curFrame.mRootScope );		
		curFrame.mCurrentScope = 0;

		mProfileReport.EndUpdate ();
	
		// The main thread can now access the report again
		if ( mName != MOAIProfiler::kMainThreadName ) {
	
			mReportMutex.Unlock ();
		}
	}

	// Clean up and get ready for next frame
	MOAIProfilerScope* scope = curFrame.mRootScope.mNext;
	while ( scope ) {

		MOAIProfilerScope* curScope = scope;
		scope = scope->mNext;
		this->RecycleScope ( curScope );
	}
}
Ejemplo n.º 21
0
F_access F_allocLocal(F_frame f, bool escape)
{
	f->local_count++;
	if (escape) return InFrame(F_WORD_SIZE * (- f->local_count));
	return InReg(Temp_newtemp());
}