~dobey/ubuntu/natty/banshee/fix-and-amz

« back to all changes in this revision

Viewing changes to src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2008-07-30 12:37:28 UTC
  • mto: (1.2.3 upstream) (94.1.1 maverick)
  • mto: This revision was merged to the branch mainline in revision 70.
  • Revision ID: james.westby@ubuntu.com-20080730123728-8y78ip4btz99ri5h
Tags: upstream-1.2.0
Import upstream version 1.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
            if (header_visible && column_controller != null) {
85
85
                PaintHeader (damage);
86
86
            }
 
87
           
87
88
            Theme.DrawFrameBorder (cairo_context, Allocation);
88
 
            PaintRows(damage);
 
89
            if (Model != null) {
 
90
                PaintRows(damage);
 
91
            }
 
92
            
89
93
            PaintDraggingColumn (damage);
90
94
            
91
95
            ((IDisposable)cairo_context.Target).Dispose ();
117
121
                    continue;
118
122
                }
119
123
                
120
 
                cell_area.X = column_cache[ci].X1 + Theme.TotalBorderWidth + header_rendering_alloc.X - (int)hadjustment.Value;
 
124
                cell_area.X = column_cache[ci].X1 + Theme.TotalBorderWidth + header_rendering_alloc.X - HadjustmentValue;
121
125
                cell_area.Width = column_cache[ci].Width;
122
126
                PaintHeaderCell (cell_area, ci, false);
123
127
            }
124
128
            
125
129
            if (pressed_column_is_dragging && pressed_column_index >= 0) {
126
 
                cell_area.X = pressed_column_x_drag + Allocation.X - (int)hadjustment.Value;
 
130
                cell_area.X = pressed_column_x_drag + Allocation.X - HadjustmentValue;
127
131
                cell_area.Width = column_cache[pressed_column_index].Width;
128
132
                PaintHeaderCell (cell_area, pressed_column_index, true);
129
133
            }
174
178
            if (sort_column_index != -1 && (!pressed_column_is_dragging || pressed_column_index != sort_column_index)) {
175
179
                CachedColumn col = column_cache[sort_column_index];
176
180
                Theme.DrawRowRule (cairo_context,
177
 
                    list_rendering_alloc.X + col.X1 - (int)hadjustment.Value,
 
181
                    list_rendering_alloc.X + col.X1 - HadjustmentValue,
178
182
                    header_rendering_alloc.Bottom + Theme.BorderWidth,
179
183
                    col.Width, list_rendering_alloc.Height + Theme.InnerBorderWidth * 2);
180
184
            }
186
190
            cell_context.Clip = clip;
187
191
            cell_context.TextAsForeground = false;
188
192
            
189
 
            int vadjustment_value = (int)vadjustment.Value;
 
193
            int vadjustment_value = VadjustmentValue;
190
194
            int first_row = vadjustment_value / RowHeight;
191
195
            int last_row = Math.Min (model.Count, first_row + RowsInView);
192
196
            int offset = list_rendering_alloc.Y - vadjustment_value % RowHeight;
194
198
            Rectangle selected_focus_alloc = Rectangle.Zero;
195
199
            Rectangle single_list_alloc = new Rectangle ();
196
200
            
197
 
            single_list_alloc.X = list_rendering_alloc.X - (int)(hadjustment.Value);
 
201
            single_list_alloc.X = list_rendering_alloc.X - HadjustmentValue;
198
202
            single_list_alloc.Y = offset;
199
203
            single_list_alloc.Width = list_rendering_alloc.Width;
200
204
            single_list_alloc.Height = RowHeight;
221
225
                            single_list_alloc.Width, single_list_alloc.Height);
222
226
                    }
223
227
                    
224
 
                    if (ri == drag_reorder_row_index && Reorderable) {
225
 
                        cairo_context.Save ();
226
 
                        cairo_context.LineWidth = 1.0;
227
 
                        cairo_context.Antialias = Cairo.Antialias.None;
228
 
                        cairo_context.MoveTo (single_list_alloc.Left, single_list_alloc.Top);
229
 
                        cairo_context.LineTo (single_list_alloc.Right, single_list_alloc.Top);
230
 
                        cairo_context.Color = Theme.Colors.GetWidgetColor (GtkColorClass.Text, StateType.Normal);
231
 
                        cairo_context.Stroke ();
232
 
                        cairo_context.Restore ();
233
 
                    }
 
228
                    PaintReorderLine (ri, single_list_alloc);
234
229
                    
235
230
                    if (Selection != null && Selection.FocusedIndex == ri && !Selection.Contains (ri) && HasFocus) {
236
231
                        CairoCorners corners = CairoCorners.All;
259
254
                single_list_alloc.Y += single_list_alloc.Height;
260
255
            }
261
256
            
 
257
            // In case the user is dragging to the end of the list
 
258
            PaintReorderLine (last_row, single_list_alloc);
 
259
            
262
260
            if (selection_height > 0) {
263
261
                Theme.DrawRowSelection (cairo_context, list_rendering_alloc.X, selection_y, 
264
262
                    list_rendering_alloc.Width, selection_height);
278
276
            
279
277
            cairo_context.ResetClip ();
280
278
        }
 
279
        
 
280
        private void PaintReorderLine (int row_index, Rectangle single_list_alloc)
 
281
        {
 
282
            if (row_index == drag_reorder_row_index && Reorderable) {
 
283
                cairo_context.Save ();
 
284
                cairo_context.LineWidth = 1.0;
 
285
                cairo_context.Antialias = Cairo.Antialias.None;
 
286
                cairo_context.MoveTo (single_list_alloc.Left, single_list_alloc.Top);
 
287
                cairo_context.LineTo (single_list_alloc.Right, single_list_alloc.Top);
 
288
                cairo_context.Color = Theme.Colors.GetWidgetColor (GtkColorClass.Text, StateType.Normal);
 
289
                cairo_context.Stroke ();
 
290
                cairo_context.Restore ();
 
291
            }
 
292
        }
281
293
 
282
294
        private void PaintRow (int row_index, Rectangle area, StateType state)
283
295
        {
287
299
            
288
300
            object item = model[row_index];
289
301
            bool sensitive = IsRowSensitive (item);
 
302
            bool bold = IsRowBold (item);
290
303
            
291
304
            Rectangle cell_area = new Rectangle ();
292
305
            cell_area.Height = RowHeight;
299
312
                
300
313
                cell_area.Width = column_cache[ci].Width;
301
314
                cell_area.X = column_cache[ci].X1 + area.X;
302
 
                PaintCell (item, ci, row_index, cell_area, sensitive, state, false);
 
315
                PaintCell (item, ci, row_index, cell_area, sensitive, bold, state, false);
303
316
            }
304
317
            
305
318
            if (pressed_column_is_dragging && pressed_column_index >= 0) {
306
319
                cell_area.Width = column_cache[pressed_column_index].Width;
307
320
                cell_area.X = pressed_column_x_drag + list_rendering_alloc.X - list_interaction_alloc.X;
308
 
                PaintCell (item, pressed_column_index, row_index, cell_area, sensitive, state, true);
 
321
                PaintCell (item, pressed_column_index, row_index, cell_area, sensitive, bold, state, true);
309
322
            }
310
323
        }
311
324
        
312
 
        private void PaintCell (object item, int column_index, int row_index, Rectangle area, bool sensitive,
 
325
        private void PaintCell (object item, int column_index, int row_index, Rectangle area, bool sensitive, bool bold,
313
326
            StateType state, bool dragging)
314
327
        {
315
328
            ColumnCell cell = column_cache[column_index].Column.GetCell (0);
316
329
            cell.BindListItem (item);
317
330
            ColumnCellDataProvider (cell, item);
318
331
            
 
332
            ColumnCellText text_cell = cell as ColumnCellText;
 
333
            if (text_cell != null) {
 
334
                text_cell.FontWeight = bold ? Pango.Weight.Bold : Pango.Weight.Normal;
 
335
            }
 
336
            
319
337
            if (dragging) {
320
338
                Cairo.Color fill_color = Theme.Colors.GetWidgetColor (GtkColorClass.Base, StateType.Normal);
321
339
                fill_color.A = 0.5;
340
358
            
341
359
            CachedColumn column = column_cache[pressed_column_index];
342
360
            
343
 
            int x = pressed_column_x_drag + Allocation.X + 1 - (int)hadjustment.Value;
 
361
            int x = pressed_column_x_drag + Allocation.X + 1 - HadjustmentValue;
344
362
            
345
363
            Cairo.Color fill_color = Theme.Colors.GetWidgetColor (GtkColorClass.Base, StateType.Normal);
346
364
            fill_color.A = 0.45;
414
432
        }
415
433
        
416
434
        private int row_height = 32;
417
 
        private int RowHeight {
 
435
        protected int RowHeight {
418
436
            get {
419
437
                if (RecomputeRowHeight) {
420
438
                    row_height = RowHeightProvider != null