Example #1
0
int GDialog::DoModal(OsView OverideParent)
{
	d->ModalStatus = 0;

	if (Wnd && Attach(0))
	{
		GWindow *Owner = GetParent() ? GetParent()->GetWindow() : 0;
		if (Owner)
		{
			GRect Pr = Owner->GetPos();
			GRect Mr = GetPos();
			Mr.Offset(	Pr.x1 + (Pr.X() - Mr.X()) / 2 - Mr.x1,
						Pr.y1 + (Pr.Y() - Mr.Y()) / 2 - Mr.y1);
			SetPos(Mr);
			Owner->SetChildDialog(this);
		}
		
		d->IsModal = true;
		AttachChildren();
		Visible(true);
		
		RunAppModalLoopForWindow(Wnd);

		if (Owner) Owner->SetChildDialog(0);
	}

	return d->ModalStatus;
}
Example #2
0
bool GWindow::SetPos(GRect &p, bool Repaint)
{
	if (Wnd)
	{
		if (p.x1 < -100)
		{
			printf("%s:%i - Weird setpos(%s)\n", __FILE__, __LINE__, p.GetStr());
		}
		
		bool Lock = Wnd->Lock();

		Wnd->MoveTo(p.x1, p.y1);
		Wnd->ResizeTo(p.X(), p.Y());
		
		if (!Handle()->Parent())
		{
			// Our view is not attached yet, so move it ourself
			BRect r = Wnd->Bounds();
			Handle()->MoveTo(0, 0);
			Handle()->ResizeTo(r.Width(), r.Height());
		}

		if (Lock) Wnd->Unlock();

		Pos = p;

		return true;
	}

	return false;
}
Example #3
0
void GSlider::OnPaint(GSurface *pDC)
{
	pDC->Colour(LC_MED, 24);
	pDC->Rectangle();
	
	GRect r = GetClient();
	int y = r.Y() >> 1;
	r.y1 = y - 2;
	r.y2 = r.y1 + 3;
	r.x1 += 3;
	r.x2 -= 3;
	LgiWideBorder(pDC, r, DefaultSunkenEdge);
	
	if (Min <= Max)
	{
		int x = Val * r.X() / (Max-Min);
		Thumb.ZOff(5, 9);
		Thumb.Offset(r.x1 + x - 3, y - 5);
		GRect b = Thumb;
		LgiWideBorder(pDC, b, DefaultRaisedEdge);
		pDC->Rectangle(&b);		
	}
}
Example #4
0
bool GPanel::Pour(GRegion &r)
{
	int Sx = CalcWidth();
	GRect *Best = 0;
	if (Open())
	{
		Best = FindLargest(r);
	}
	else
	{
		Best = FindSmallestFit(r, Sx, ClosedSize);
		if (!Best)
		{
			Best = FindLargest(r);
		}
	}

	if (Best)
	{
		GRect r = *Best;
		if (OpenSize > 0)
		{
			int Size = ((Open()) ? OpenSize : ClosedSize);
			int Limit = 30;
			if (TestFlag(Align, GV_EDGE_RIGHT) ||
				TestFlag(Align, GV_EDGE_LEFT))
			{
				Limit = min(Size, r.X()-1);
			}
			else /* if (TestFlag(Align, GV_EDGE_BOTTOM) ||
					 TextFlag(Align, GV_EDGE_TOP)) */
			{
				Limit = min(Size, r.Y()-1);
			}
			
			if (Align & GV_EDGE_RIGHT)
			{
				r.x1 = r.x2 - Limit;
			}
			else if (Align & GV_EDGE_BOTTOM)
			{
				r.y1 = r.y2 - Limit;
			}
			else if (Align & GV_EDGE_LEFT)
			{
				r.x2 = r.x1 + Limit;
			}
			else // if (Align & GV_EDGE_TOP)
			{
				r.y2 = r.y1 + Limit;
			}
			
			if (!Open())
			{
				r.x2 = r.x1 + Sx - 1;
			}
		}
		else
		{
			r.y2 = r.y1 - OpenSize;
		}

		SetPos(r, true);

		return true;
	}

	return false;
}
Example #5
0
void GSplitter::OnPaint(GSurface *pDC)
{
	GRect r = GetClient();

	pDC->Colour(LC_MED, 24);
	if (Border())
	{
		LgiFlatBorder(pDC, r, SPLITER_BORDER);
	}

	// bar
	pDC->Colour(LC_MED, 24);
	if (d->Vertical)
	{
		/* Old Win32
		pDC->Rectangle(PosA.x2, PosA.y1, PosB.x1, PosA.y2);
		pDC->Rectangle(PosA.x1, PosA.y2, PosA.x2, PosB.y1);
		*/
		pDC->Rectangle(d->PosA.x2+1, r.y1, d->PosB.x1-1, r.y2);
	}
	else
	{
		pDC->Rectangle(r.x1, d->PosA.y2+1, r.x2, d->PosB.y1-1);
	}

	// PosA region
	r = d->PosA;
	if (r.X() > SPLITER_MIN_X && r.Y() > SPLITER_MIN_Y)
	{
		if (d->BorderA)
		{
			LgiWideBorder(pDC, r, DefaultSunkenEdge);
		}

		if (d->ViewA)
		{
			#ifdef WIN32
			if (!d->ViewA->Handle())
			{
				pDC->SetClient(&d->PosA);
				d->ViewA->OnPaint(pDC);
				pDC->SetClient(NULL);
			}
			else
			#endif
			{
				// View is real and will paint itself
			}
		}
		else
		{
			pDC->Colour(LC_WORKSPACE, 24);
			pDC->Rectangle(&r);
		}
	}
	else
	{
		// too small
	}

	r = d->PosB;
	if (r.X() > SPLITER_MIN_X && r.Y() > SPLITER_MIN_Y)
	{
		if (d->BorderB)
		{
			LgiWideBorder(pDC, r, DefaultSunkenEdge);
		}

		if (d->ViewB)
		{
			#ifdef WIN32
			if (!d->ViewB->Handle())
			{
				pDC->SetClient(&d->PosB);
				d->ViewB->OnPaint(pDC);
				pDC->SetClient(NULL);
			}
			else
			#endif
			{
				// View is real and will paint itself
			}
		}
		else
		{
			pDC->Colour(LC_WORKSPACE, 24);
			pDC->Rectangle(&r);
		}
	}
	else
	{
		// too small
	}
}
Example #6
0
GInput::GInput(GViewI *parent, const char *InitStr, const char *Msg, const char *Title, bool Password, GInputCallback callback, void *callbackparam)
{
	Callback = callback;
	CallbackParam = callbackparam;

	GText *Txt = new GText(-1, 5, 5, -1, -1, Msg);
	GDisplayString MsgDs(SysFont, ValidStr(InitStr)?InitStr:"A");
	int Dx = LgiApp->GetMetric(LGI_MET_DECOR_X) + 10;
	int Dy = LgiApp->GetMetric(LGI_MET_DECOR_Y);
	
	int ContextX = 400;
	ContextX = max(ContextX, MsgDs.X() + 40);
	ContextX = min(ContextX, (int)(GdcD->X() * 0.8));
	int EditX = ContextX;
	int CallbackX = callback ? GBUTTON_MIN_X + 20 : 0;
	ContextX = max(ContextX, Txt->X() + CallbackX);

	GRect r(0, 0, ContextX + CallbackX + Dx, 70 + Txt->Y() + Dy);

	SetParent(parent);
	Name(Title);
	SetPos(r);
	MoveToCenter();

	GRect c = GetClient();
	Children.Insert(Txt);
	Children.Insert(Edit = new GEdit(IDC_EDIT, 5, Txt->GetPos().y2 + 5, EditX - 1, MsgDs.Y()+7, InitStr));
	if (Edit)
	{
		Edit->Password(Password);
		Edit->Focus(true);
		if (Callback)
		{
			GRect e = Edit->GetPos();
			Children.Insert(new GButton(IDC_CALLBACK, c.X() - (CallbackX-5) - 6, e.y1, CallbackX-5, e.Y()-1, "..."));
		}
	}

	GButton *Ok = new GButton(IDOK, 0, 0, -1, -1, LgiLoadString(L_BTN_OK, "Ok"));
	GButton *Cancel = new GButton(IDCANCEL, 0, 0, -1, -1, LgiLoadString(L_BTN_CANCEL, "Cancel"));
	int BtnX = max(Ok->X(), Cancel->X());
	int BtnY = Edit->GetPos().y2 + 11;
	
	GRect p = Cancel->GetPos();
	p.x2 = p.x1 + BtnX - 1;
	p.Offset(c.X() - Cancel->X() - 5, BtnY);
	Cancel->SetPos(p);
	
	p = Ok->GetPos();
	p.x2 = p.x1 + BtnX - 1;
	p.Offset(Cancel->GetPos().x1 - p.X() - 5, BtnY);
	Ok->SetPos(p);

	Children.Insert(Ok);
	Children.Insert(Cancel);
	Ok->Default(true);
}