static Boolean MainFormHandleEvent(EventPtr event) { Boolean handled = false; int x, y; switch (event->eType) { case frmUpdateEvent: if (event->data.frmUpdate.formID == mainForm) { DIAG (("Call Redisplay\n")); Redisplay (); handled = true; } break; case frmOpenEvent: if (event->data.frmOpen.formID == mainForm) { FrmDrawForm (mainFrm); DamageBoard (); } break; case penDownEvent: if (PenLocation (event->screenX, event->screenY, &x, &y)) { pen_down = true; pen_down_x = x; pen_down_y = y; handled = true; } break; case penUpEvent: if (pen_down && PenLocation (event->screenX, event->screenY, &x, &y)) { HandleBoardPen (pen_down_x, pen_down_y, x, y); handled = true; } pen_down = false; break; case keyDownEvent: RicochetKeyHandleEvent (event); break; case menuEvent: RicochetMenuHandleEvent (event); break; default: break; } return handled; }
void BStatusBar::Draw(BRect updateRect) { rgb_color shineColor = ui_color(B_SHINE_COLOR); rgb_color shadowColor = ui_color(B_SHADOW_COLOR); rgb_color barColor = ui_color(B_STATUSBAR_COLOR); BFont font; font_height fontHeight; GetFont(&font); font.GetHeight(&fontHeight); float sHeight = fontHeight.ascent + fontHeight.descent; if (!IsEnabled()) { shineColor.disable(ViewColor()); shadowColor.disable(ViewColor()); barColor.disable(ViewColor()); } BPoint penLocation; MovePenTo(B_ORIGIN); MovePenBy(0, fontHeight.ascent + 1); if (fLabel != NULL) { if (!IsEnabled()) MovePenBy(1, 1); penLocation = PenLocation(); SetHighColor(IsEnabled() ? ui_color(B_PANEL_TEXT_COLOR) : ui_color(B_SHINE_COLOR).disable(ViewColor())); SetLowColor(ViewColor()); DrawString(fLabel); if (!IsEnabled()) { SetHighColor(ui_color(B_SHADOW_COLOR).disable(ViewColor())); DrawString(fLabel, penLocation - BPoint(1, 1)); } MovePenBy(font.Spacing() * font.Size(), 0); } if (fText != NULL) { if (!IsEnabled()) MovePenBy(1, 1); penLocation = PenLocation(); SetHighColor(IsEnabled() ? ui_color(B_PANEL_TEXT_COLOR) : ui_color(B_SHINE_COLOR).disable(ViewColor())); SetLowColor(ViewColor()); DrawString(fText); if (!IsEnabled()) { SetHighColor(ui_color(B_SHADOW_COLOR).disable(ViewColor())); DrawString(fText, penLocation - BPoint(1, 1)); } } MovePenTo(Frame().Width(), 0); MovePenBy(0, fontHeight.ascent + 1); if (fTrailingLabel != NULL) { MovePenBy(-(font.StringWidth(fTrailingLabel) + 1), 0); if (!IsEnabled()) MovePenBy(1, 1); penLocation = PenLocation(); SetHighColor(IsEnabled() ? ui_color(B_PANEL_TEXT_COLOR) : ui_color(B_SHINE_COLOR).disable(ViewColor())); SetLowColor(ViewColor()); DrawString(fTrailingLabel); if (!IsEnabled()) { SetHighColor(ui_color(B_SHADOW_COLOR).disable(ViewColor())); penLocation -= BPoint(1, 1); DrawString(fTrailingLabel, penLocation); } MovePenTo(penLocation + BPoint(-(font.Spacing() * font.Size()), 0)); } if (fTrailingText != NULL) { MovePenBy(-(font.StringWidth(fTrailingText) + 1), 0); if (!IsEnabled()) MovePenBy(1, 1); penLocation = PenLocation(); SetHighColor(IsEnabled() ? ui_color(B_PANEL_TEXT_COLOR) : ui_color(B_SHINE_COLOR).disable(ViewColor())); SetLowColor(ViewColor()); DrawString(fTrailingText); if (!IsEnabled()) { SetHighColor(ui_color(B_SHADOW_COLOR).disable(ViewColor())); DrawString(fTrailingText, penLocation - BPoint(1, 1)); } } BRect rect = Frame().OffsetToSelf(B_ORIGIN); if (fLabel != NULL || fTrailingLabel != NULL || fText != NULL || fTrailingText != NULL) rect.top += sHeight + 5; if (rect.IsValid() == false) return; rect.bottom = rect.top + fBarHeight; SetHighColor(shineColor.mix_copy(0, 0, 0, 5)); FillRect(rect); SetHighColor(shineColor); StrokeRect(rect); SetHighColor(shadowColor); StrokeLine(rect.LeftBottom(), rect.RightBottom()); StrokeLine(rect.RightTop()); rect.InsetBy(1, 1); if (rect.IsValid() == false) return; BRect barRect = rect; SetHighColor(barColor); if (fCurrentValue < fMaxValue) barRect.right = barRect.left + barRect.Width() * fCurrentValue / fMaxValue; FillRect(barRect); }
void TermView::Draw(BRect updateRect) { VTermRect updatedChars = PixelsToGlyphs(updateRect); VTermPos pos; font_height height; GetFontHeight(&height); int availableRows, availableCols; vterm_get_size(fTerm, &availableRows, &availableCols); for (pos.row = updatedChars.start_row; pos.row <= updatedChars.end_row; pos.row++) { float x = updatedChars.start_col * fFontWidth + kBorderSpacing; float y = pos.row * fFontHeight + height.ascent + kBorderSpacing + 1; MovePenTo(x, y); for (pos.col = updatedChars.start_col; pos.col <= updatedChars.end_col;) { VTermScreenCell cell; if (pos.col < 0 || pos.row < 0 || pos.col >= availableCols || pos.row >= availableRows) { // All cells outside the used terminal area are drawn with the // same background color as the top-left one. VTermPos firstPos; firstPos.row = 0; firstPos.col = 0; vterm_screen_get_cell(fTermScreen, firstPos, &cell); cell.chars[0] = 0; cell.width = 1; } else vterm_screen_get_cell(fTermScreen, pos, &cell); rgb_color foreground, background; foreground.red = cell.fg.red; foreground.green = cell.fg.green; foreground.blue = cell.fg.blue; foreground.alpha = 255; background.red = cell.bg.red; background.green = cell.bg.green; background.blue = cell.bg.blue; background.alpha = 255; if(cell.attrs.reverse) { SetLowColor(foreground); SetViewColor(foreground); SetHighColor(background); } else { SetLowColor(background); SetViewColor(background); SetHighColor(foreground); } BPoint penLocation = PenLocation(); FillRect(BRect(penLocation.x, penLocation.y - height.ascent, penLocation.x + cell.width * fFontWidth, penLocation.y + 1), B_SOLID_LOW); if (cell.chars[0] == 0) { DrawString(" "); pos.col ++; } else { char buffer[VTERM_MAX_CHARS_PER_CELL]; wcstombs(buffer, (wchar_t*)cell.chars, VTERM_MAX_CHARS_PER_CELL); DrawString(buffer); pos.col += cell.width; } } } }