void GColourSelect::OnPaint(GSurface *pDC) { GDropDown::OnPaint(pDC); GRect r = GetClient(); r.x2 -= 14; r.Size(5, 5); if (IsOpen()) r.Offset(1, 1); bool HasColour = Enabled() && c32 != 0; pDC->Colour(HasColour ? LC_BLACK : LC_LOW, 24); pDC->Box(&r); r.Size(1, 1); pDC->Colour(HasColour ? c32 : Rgb24To32(LC_LOW), 32); if (HasColour) { pDC->Rectangle(&r); } else { pDC->Line(r.x1, r.y1, r.x2, r.y2); pDC->Line(r.x1, r.y2, r.x2, r.y1); } }
void GDialog::OnPosChange() { if (Children.Length() == 1) { List<GViewI>::I it = Children.Start(); GTableLayout *t = dynamic_cast<GTableLayout*>((GViewI*)it.First()); if (t) { GRect r = GetClient(); r.Size(GTableLayout::CellSpacing, GTableLayout::CellSpacing); t->SetPos(r); } } }
GRect &GView::GetClient(bool ClientSpace) { int Edge = (Sunken() || Raised()) ? _BorderSize : 0; static GRect c; if (ClientSpace) { c.ZOff(Pos.X() - 1 - (Edge<<1), Pos.Y() - 1 - (Edge<<1)); } else { c.ZOff(Pos.X()-1, Pos.Y()-1); c.Size(Edge, Edge); } return c; }
void OnMouseClick(GMouse &m) { GRect r = GetClient(); r.Size(2, 2); if (r.Overlap(m.x, m.y)) { int i = m.y / Ly; if (i == 0) { Colour->Value(0); } else { Colour->Value(Colour->Presets[i-1]); } Visible(false); } }
void GSplitter::CalcRegions(bool Follow) { GRect Rect = GetClient(); d->PosA = Rect; if (Border()) { d->PosA.Size(SPLITER_BORDER, SPLITER_BORDER); } d->PosB = d->PosA; if (d->SplitFollow && Follow) { d->SplitPos = max(1, ((d->Vertical) ? X()-10 : Y()-10) + d->SplitSet); } else if (Rect.Valid()) { int Max = d->Vertical ? X()-10 : Y()-10; if (Max > 0) { d->SplitPos = max(1, d->SplitPos); d->SplitPos = min(Max, d->SplitPos); } } if (d->Vertical) { d->PosA.x2 = d->PosA.x1 + d->SplitPos; d->PosB.x1 = d->PosA.x2 + d->BarSize; } else { d->PosA.y2 = d->PosA.y1 + d->SplitPos; d->PosB.y1 = d->PosA.y2 + d->BarSize; } GRect r = d->PosA; if (d->BorderA) { r.Size(SPLITER_INSET, SPLITER_INSET); } if (d->ViewA) { if (d->ViewA->IsAttached()) { if (r.Valid()) { GRegion Rgn(r); d->ViewA->SetPos(r); d->ViewA->Pour(Rgn); } d->ViewA->Visible(r.Valid()); } else { d->ViewA->SetPos(r); } } r = d->PosB; if (d->BorderB) { r.Size(SPLITER_INSET, SPLITER_INSET); } if (d->ViewB) { if (d->ViewB->IsAttached()) { if (r.Valid()) { GRegion Rgn(r); d->ViewB->SetPos(r); d->ViewB->Pour(Rgn); } d->ViewB->Visible(r.Valid()); } else { d->ViewB->SetPos(r); } } #if 0 if (d->ViewA && !stricmp(d->ViewA->GetClass(), "GTree")) { printf("Split::OnPosChange cli=%s a=%s b=%s\n", GetClient().GetStr(), d->PosA.GetStr(), d->PosB.GetStr()); } #endif // printf("CalcPos Client=%s Value=%i A=%s B=%s\n", GetClient().GetStr(), (int)Value(), d->PosA.GetStr(), d->PosB.GetStr()); }