Example #1
0
int DockPane::GetMinPos(int notix)
{
	int n = 0;
	int msz = 0;
	for (Ctrl *c = GetFirstChild(); c; c = c->GetNext()) {
		if (n != notix) msz += ClientToPos(c->GetMinSize());
		n++;
	}
	return msz;
}
Example #2
0
void ButcherView::RepositionScroll(int orientation)
{
    int sw, sh;
/*
    dwindow_->GetViewStart(&sw, &sh);

    wxLogDebug(wxT("RepositionScroll VS = sw: %d [%d] - sh: %d [%d]"),
        sw, ClientToPos(sw), sh, ClientToPos(sh));

*/
    dwindow_->CalcUnscrolledPosition(0, 0, &sw, &sh);

/*
    wxLogDebug(wxT("RepositionScroll = sw: %d [%d] - sh: %d [%d] - pos: %d"),
        sw, ClientToPos(sw), sh, ClientToPos(sh), orientation);
*/

    switch (orientation) {
    case wxVERTICAL:
    case wxBOTH:
        ruler_left_->SetStart(ClientToPos(sh));
        ruler_right_->SetStart(ClientToPos(sh));
        break;
    default:
        break;
    }

    switch (orientation) {
    case wxHORIZONTAL:
    case wxBOTH:
        ruler_top_->SetStart(ClientToPos(sw));
        ruler_bottom_->SetStart(ClientToPos(sw));
        break;
    default:
        break;
    }
}
Example #3
0
void DockPane::SmartRepos(int ix, int inc)
{
	int cnt = pos.GetCount();
	if (cnt == 1) {
		pos[0] = 10000;
		return;
	}

	for (int i = cnt-1; i > 0; i--)
		pos[i] -= pos[i-1];

	int n = 0;
	int msz = 0;
	int tsz = 0;
	Vector<int>minpos;
	minpos.SetCount(cnt);

	for (Ctrl *c = GetFirstChild(); c; c = c->GetNext()) {
		if (n != ix) {
			minpos[n] = min(ClientToPos(c->GetMinSize()), pos[n]);
			msz += minpos[n];
			tsz += pos[n];
		}
		n++;
	}
	int dif = tsz - inc - msz;
	tsz -= msz;

	pos[ix] += inc;
	if (tsz != 0 && dif != 0) {
		if (tsz <= 0) dif = -dif;
		int isz = pos[ix];
		for (int i = 0; i < cnt; i++) {
			if (i != ix)
				pos[i] = minpos[i] + (dif * (pos[i] - minpos[i])) / tsz;
		}
	}
	for (int i = 1; i < cnt; i++)
		pos[i] += pos[i-1];
}