+ * Draw the background layer. Fills the background of the control's name
+ * space and states space, updates the background of items if necessary,
+ * and draws the item's name text and middle line.
+ *
+ * @param bounds
+ * The bounds of the control
+ * @param nameSpace
+ * The name space width
+ * @param gc
+ * Graphics context
+ * @since 2.0
+ */
+ protected void drawBackground(Rectangle bounds, int nameSpace, GC gc) {
+ // draw empty name space background
+ gc.setBackground(getColorScheme().getBkColor(false, false, true));
+ drawBackground(gc, bounds.x, bounds.y, nameSpace, bounds.height);
+
+ // draw empty states space background
+ gc.setBackground(getColorScheme().getColor(TimeGraphColorScheme.BACKGROUND));
+ drawBackground(gc, bounds.x + nameSpace, bounds.y, bounds.width - nameSpace, bounds.height);
+
+ for (int i = fTopIndex; i < fItemData.fExpandedItems.length; i++) {
+ Rectangle itemRect = getItemRect(bounds, i);
+ if (itemRect.y >= bounds.y + bounds.height) {
+ break;
+ }
+ Item item = fItemData.fExpandedItems[i];
+ // draw the background of selected item and items with no time events
+ if (! item.fEntry.hasTimeEvents()) {
+ gc.setBackground(getColorScheme().getBkColorGroup(item.fSelected, fIsInFocus));
+ gc.fillRectangle(itemRect);
+ } else if (item.fSelected) {
+ gc.setBackground(getColorScheme().getBkColor(true, fIsInFocus, true));
+ gc.fillRectangle(itemRect.x, itemRect.y, nameSpace, itemRect.height);
+ gc.setBackground(getColorScheme().getBkColor(true, fIsInFocus, false));
+ gc.fillRectangle(nameSpace, itemRect.y, itemRect.width - nameSpace, itemRect.height);
+ }
+ // draw the name and middle line
+ if (! item.fEntry.hasTimeEvents()) {
+ drawName(item, itemRect, gc);
+ } else {
+ Rectangle nameRect = new Rectangle(itemRect.x, itemRect.y, nameSpace, itemRect.height);
+ drawName(item, nameRect, gc);
+ Rectangle rect = new Rectangle(nameSpace, itemRect.y, itemRect.width - nameSpace, itemRect.height);
+ drawMidLine(rect, gc);
+ }
+ }
+ }
+
+ /**
+ * Draw the grid lines
+ *
+ * @param bounds
+ * The bounds of the control
+ * @param gc
+ * Graphics context
+ * @since 2.0
+ */
+ public void drawGridLines(Rectangle bounds, GC gc) {
+ if (!fGridLinesVisible) {
+ return;
+ }
+ gc.setForeground(fGridLineColor);
+ gc.setAlpha(fGridLineColor.getAlpha());
+ for (int x : fTimeGraphScale.getTickList()) {
+ gc.drawLine(x, bounds.y, x, bounds.y + bounds.height);
+ }
+ gc.setAlpha(255);
+ }
+
+ /**
+ * Draw the markers