private void UpdateAdjustments() { int layoutWidth, layoutHeight; Layout.GetPixelSize(out layoutWidth, out layoutHeight); if (hadjustment != null) { hadjustment.Upper = ContentArea.Width; hadjustment.StepIncrement = 10.0; if (hadjustment.Value + hadjustment.PageSize > hadjustment.Upper) { hadjustment.Value = hadjustment.Upper - hadjustment.PageSize; } if (hadjustment.Upper > 0 && hadjustment.Upper < hadjustment.PageSize) { hadjustment.Upper = hadjustment.PageSize; } hadjustment.Change(); } if (vadjustment != null) { vadjustment.Upper = ContentArea.Height; vadjustment.StepIncrement = layoutHeight; if (vadjustment.Value + vadjustment.PageSize > vadjustment.Upper) { vadjustment.Value = vadjustment.Upper - vadjustment.PageSize; } if (vadjustment.Upper > 0 && vadjustment.Upper < vadjustment.PageSize) { vadjustment.Upper = vadjustment.PageSize; } vadjustment.Change(); } }
private void UpdateAdjustments() { // FIXME: with ViewLayout, hadj and vadj should be unified // since the layout will take the header into account... if (hadjustment != null) { hadjustment.Upper = header_width; hadjustment.StepIncrement = 10.0; if (hadjustment.Value + hadjustment.PageSize > hadjustment.Upper) { hadjustment.Value = Math.Max(0, hadjustment.Upper - hadjustment.PageSize); } if (hadjustment.Upper > 0 && hadjustment.Upper < hadjustment.PageSize) { hadjustment.Upper = hadjustment.PageSize; } } if (vadjustment != null) { if (model != null && model.Count > 0) { // FIXME: hard-coded grid logic if (ViewLayout != null) { vadjustment.Upper = ViewLayout.VirtualSize.Height; vadjustment.StepIncrement = ViewLayout.ChildSize.Height; } else { vadjustment.Upper = ChildSize.Height * model.Count; vadjustment.StepIncrement = ChildSize.Height; } if (vadjustment.Value + vadjustment.PageSize > vadjustment.Upper) { vadjustment.Value = Math.Max(0, vadjustment.Upper - vadjustment.PageSize); } if (vadjustment.Upper > 0 && vadjustment.Upper < vadjustment.PageSize) { vadjustment.Upper = vadjustment.PageSize; } } else { vadjustment.Upper = 0; vadjustment.Lower = 0; vadjustment.PageSize = 0; vadjustment.PageIncrement = 0; vadjustment.StepIncrement = 0; vadjustment.Value = 0; } } if (hadjustment != null) { hadjustment.Change(); } if (vadjustment != null) { vadjustment.Change(); } }
private void Redraw(Cairo.Context cr) { // Clear the background cr.Rectangle(0, 0, Allocation.Width, Allocation.Height); Gdk.CairoHelper.SetSourceColor(cr, Style.Base(State)); cr.Fill(); if (model == null) { if (hadj != null) { hadj.Upper = hadj.Lower = 0; hadj.Change(); } if (vadj != null) { vadj.Upper = 0; vadj.Change(); } return; } if (rows == 0 || cols == 0) { return; } Gdk.Rectangle background_area = cell_size; background_area.Width += padding; background_area.Height += padding; TreeIter iter; if (model.GetIterFirst(out iter)) { do { TreePath path = model.GetPath(iter); int x, y; GetCellPosition(path.Indices[0], out x, out y); if (hadj != null && (x + cell_size.Width < hadj.Value || x > hadj.Value + hadj.PageSize)) { continue; } if (vadj != null && (y + cell_size.Height < vadj.Value || y > vadj.Value + vadj.PageSize)) { continue; } if (data_func != null) { data_func(this, renderer, model, iter); } cell_size.X = x; cell_size.Y = y; if (hadj != null) { cell_size.X -= (int)hadj.Value; } if (vadj != null) { cell_size.Y -= (int)vadj.Value; } background_area.X = cell_size.X - (padding / 2); background_area.Y = cell_size.Y - (padding / 2); cr.Rectangle(background_area.X, background_area.Y, background_area.Width, background_area.Height); cr.Clip(); renderer.Render(cr, this, background_area, cell_size, GetCellState(path)); cr.ResetClip(); } while (model.IterNext(ref iter)); } if (have_rubberband_selection) { int hadj_val = (hadj != null) ? (int)hadj.Value : 0; int vadj_val = (vadj != null) ? (int)vadj.Value : 0; cr.Rectangle(sel_rect.X - hadj_val + 0.5f, sel_rect.Y - vadj_val + 0.5f, sel_rect.Width, sel_rect.Height); Cairo.Color sel_cairo_color = CairoHelper.GetCairoColor(Style.Background(StateType.Selected)); //cr.Color = sel_cairo_color; cr.SetSourceRGBA(sel_cairo_color.R, sel_cairo_color.G, sel_cairo_color.B, sel_cairo_color.A); cr.LineWidth = 1.0f; cr.StrokePreserve(); sel_cairo_color.A = 0.3f; //cr.Color = sel_cairo_color; cr.SetSourceRGBA(sel_cairo_color.R, sel_cairo_color.G, sel_cairo_color.B, sel_cairo_color.A); cr.Fill(); } }
private void UpdateAdjustments(Adjustment hadj, Adjustment vadj) { bool vchange = false; bool hchange = false; if (hadj != null) { hadjustment = hadj; } if (vadj != null) { vadjustment = vadj; } if (hadjustment != null) { if (hadjustment.Upper != header_width) { hadjustment.Upper = header_width; hchange = true; } if (hadjustment.StepIncrement != 10.0) { hadjustment.StepIncrement = 10.0; hchange = true; } if (hadjustment.Value + hadjustment.PageSize > hadjustment.Upper) { hadjustment.Value = hadjustment.Upper - hadjustment.PageSize; hchange = true; } } if (vadjustment != null && model != null) { if (vadjustment.Upper != RowHeight * model.Count) { vadjustment.Upper = RowHeight * model.Count; vchange = true; } if (vadjustment.StepIncrement != RowHeight) { vadjustment.StepIncrement = RowHeight; vchange = true; } if (vadjustment.Value + vadjustment.PageSize > vadjustment.Upper) { vadjustment.Value = vadjustment.Upper - vadjustment.PageSize; vchange = true; } } if (hadjustment != null && hchange) { hadjustment.Change(); } if (vadjustment != null && vchange) { vadjustment.Change(); } }