void JXFSBindingTable::TableDrawCell ( JPainter& p, const JPoint& cell, const JRect& rect ) { JPoint editCell; if (GetEditedCell(&editCell) && cell == editCell) { return; } HilightIfSelected(p, cell, rect); const JFSBinding* b = itsBindingList->GetBinding(cell.y); JFSBinding::CommandType type; JBoolean singleFile; const JString& cmd = b->GetCommand(&type, &singleFile); if (cell.x == kPatternColumn) { p.SetFont(JGetMonospaceFontName(), kJDefaultMonoFontSize, JFontStyle()); JRect r = rect; r.left += kHMarginWidth; p.String(r, b->GetPattern(), JPainter::kHAlignLeft, JPainter::kVAlignCenter); p.SetFont(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()); } else if (cell.x == kCommandColumn) { p.SetFont(JGetMonospaceFontName(), kJDefaultMonoFontSize, JFontStyle()); JRect r = rect; r.left += kHMarginWidth; p.String(r, cmd, JPainter::kHAlignLeft, JPainter::kVAlignCenter); p.SetFont(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()); } else if (cell.x == kTypeColumn) { const JString& str = itsTypeMenu->GetItemText(kCmdTypeToMenuIndex[type]); p.String(rect, str, JPainter::kHAlignCenter, JPainter::kVAlignCenter); } else if (cell.x == kSingleFileColumn && singleFile) { JRect r; r.top = rect.ycenter(); r.left = rect.xcenter(); r.bottom = r.top+1; r.right = r.left+1; r.Expand(3, 3); p.SetFilling(kJTrue); p.Ellipse(r); p.SetFilling(kJFalse); } }
void JXTabGroup::Draw ( JXWindowPainter& p, const JRect& rect ) { const JRect ap = GetAperture(); p.SetFont(itsFontName, itsFontSize, itsFontStyle); const JSize lineHeight = p.GetLineHeight(); const JSize tabHeight = 2*(kBorderWidth + kTextMargin) + lineHeight; JIndex selIndex; JRect selRect; const JBoolean hasSelection = itsCardFile->GetCurrentCardIndex(&selIndex); itsTabRects->RemoveAll(); itsCanScrollUpFlag = JI2B(itsFirstDrawIndex > 1); itsCanScrollDownFlag = kJFalse; const JCoordinate scrollArrowWidth = 2*(kArrowWidth + kBorderWidth); const JSize count = itsTitles->GetElementCount(); itsLastDrawIndex = JMax(count, itsFirstDrawIndex); const JColormap* cmap = p.GetColormap(); if (itsEdge == kTop) { JRect r(ap.top + kSelMargin, ap.left + kSelMargin, ap.top + kSelMargin + tabHeight, ap.left + kSelMargin); for (JIndex i=itsFirstDrawIndex; i<=count; i++) { const JString* title = itsTitles->NthElement(i); const JBoolean isSel = JI2B(hasSelection && i == selIndex); const TabInfo info = itsTabInfoList->GetElement(i); r.right += 2*kBorderWidth + info.preMargin +info.postMargin + p.GetStringWidth(*title); if (info.closable) { r.right += kCloseMarginWidth + itsCloseImage->GetWidth(); } JPoint titlePt(r.left + kBorderWidth + info.preMargin, r.top + kBorderWidth + kTextMargin); if (isSel) { // titlePt.y -= kSelMargin; r.top -= kSelMargin; r.Expand(kSelMargin, 0); selRect = r; } if (isSel) { p.SetPenColor(cmap->GetGrayColor(kSelGrayPercentage)); p.SetFilling(kJTrue); p.JPainter::Rect(r); p.SetFilling(kJFalse); } else { DrawTabBorder(p, r, kJFalse); } p.JPainter::String(titlePt, *title); itsTabRects->AppendElement(r); if (isSel) { r.top += kSelMargin; r.Shrink(kSelMargin, 0); } r.Shrink(kBorderWidth, kBorderWidth); DrawTab(i, p, r, itsEdge); DrawCloseButton(i, p, r); r.Expand(kBorderWidth, kBorderWidth); if (r.right >= ap.right - scrollArrowWidth) { if (itsFirstDrawIndex == 1 && i == count && r.right <= ap.right) { break; } itsCanScrollDownFlag = JI2B( itsFirstDrawIndex < count ); itsLastDrawIndex = i; if (r.right > ap.right - scrollArrowWidth && i > itsFirstDrawIndex) { itsLastDrawIndex--; } break; } r.left = r.right; } } else if (itsEdge == kLeft) { JRect r(ap.bottom - kSelMargin, ap.left + kSelMargin, ap.bottom - kSelMargin, ap.left + kSelMargin + tabHeight); for (JIndex i=itsFirstDrawIndex; i<=count; i++) { const JString* title = itsTitles->NthElement(i); const JBoolean isSel = JI2B(hasSelection && i == selIndex); const TabInfo info = itsTabInfoList->GetElement(i); r.top -= 2*kBorderWidth + info.preMargin + info.postMargin + p.GetStringWidth(*title); if (info.closable) { r.top -= kCloseMarginWidth + itsCloseImage->GetWidth(); } JPoint titlePt(r.left + kBorderWidth + kTextMargin, r.bottom - kBorderWidth - info.preMargin); if (isSel) { // titlePt.x -= kSelMargin; r.left -= kSelMargin; r.Expand(0, kSelMargin); selRect = r; } if (isSel) { p.SetPenColor(cmap->GetGrayColor(kSelGrayPercentage)); p.SetFilling(kJTrue); p.JPainter::Rect(r); p.SetFilling(kJFalse); } else { DrawTabBorder(p, r, kJFalse); } p.JPainter::String(90, titlePt, *title); itsTabRects->AppendElement(r); if (isSel) { r.left += kSelMargin; r.Shrink(0, kSelMargin); } r.Shrink(kBorderWidth, kBorderWidth); DrawTab(i, p, r, itsEdge); DrawCloseButton(i, p, r); r.Expand(kBorderWidth, kBorderWidth); if (r.top <= ap.top + scrollArrowWidth) { if (itsFirstDrawIndex == 1 && i == count && r.top >= ap.top) { break; } itsCanScrollDownFlag = JI2B( itsFirstDrawIndex < count ); itsLastDrawIndex = i; if (r.top < ap.top + scrollArrowWidth && i > itsFirstDrawIndex) { itsLastDrawIndex--; } break; } r.bottom = r.top; } } else if (itsEdge == kBottom) { JRect r(ap.bottom - kSelMargin - tabHeight, ap.left + kSelMargin, ap.bottom - kSelMargin, ap.left + kSelMargin); for (JIndex i=itsFirstDrawIndex; i<=count; i++) { const JString* title = itsTitles->NthElement(i); const JBoolean isSel = JI2B(hasSelection && i == selIndex); const TabInfo info = itsTabInfoList->GetElement(i); r.right += 2*kBorderWidth + info.preMargin + info.postMargin + p.GetStringWidth(*title); if (info.closable) { r.right += kCloseMarginWidth + itsCloseImage->GetWidth(); } JPoint titlePt(r.left + kBorderWidth + info.preMargin, r.top + kBorderWidth + kTextMargin); if (isSel) { // titlePt.y += kSelMargin; r.bottom += kSelMargin; r.Expand(kSelMargin, 0); selRect = r; } if (isSel) { p.SetPenColor(cmap->GetGrayColor(kSelGrayPercentage)); p.SetFilling(kJTrue); p.JPainter::Rect(r); p.SetFilling(kJFalse); } else { DrawTabBorder(p, r, kJFalse); } p.JPainter::String(titlePt, *title); itsTabRects->AppendElement(r); if (isSel) { r.bottom -= kSelMargin; r.Shrink(kSelMargin, 0); } r.Shrink(kBorderWidth, kBorderWidth); DrawTab(i, p, r, itsEdge); DrawCloseButton(i, p, r); r.Expand(kBorderWidth, kBorderWidth); if (r.right >= ap.right - scrollArrowWidth) { if (itsFirstDrawIndex == 1 && i == count && r.right <= ap.right) { break; } itsCanScrollDownFlag = JI2B( itsFirstDrawIndex < count ); itsLastDrawIndex = i; if (r.right > ap.right - scrollArrowWidth && i > itsFirstDrawIndex) { itsLastDrawIndex--; } break; } r.left = r.right; } } else if (itsEdge == kRight) { JRect r(ap.top + kSelMargin, ap.right - kSelMargin - tabHeight, ap.top + kSelMargin, ap.right - kSelMargin); for (JIndex i=itsFirstDrawIndex; i<=count; i++) { const JString* title = itsTitles->NthElement(i); const JBoolean isSel = JI2B(hasSelection && i == selIndex); const TabInfo info = itsTabInfoList->GetElement(i); r.bottom += 2*kBorderWidth + info.preMargin + info.postMargin + p.GetStringWidth(*title); if (info.closable) { r.bottom += kCloseMarginWidth + itsCloseImage->GetWidth(); } JPoint titlePt(r.right - kBorderWidth - kTextMargin, r.top + kBorderWidth + info.preMargin); if (isSel) { // titlePt.x += kSelMargin; r.right += kSelMargin; r.Expand(0, kSelMargin); selRect = r; } if (isSel) { p.SetPenColor(cmap->GetGrayColor(kSelGrayPercentage)); p.SetFilling(kJTrue); p.JPainter::Rect(r); p.SetFilling(kJFalse); } else { DrawTabBorder(p, r, kJFalse); } p.JPainter::String(-90, titlePt, *title); itsTabRects->AppendElement(r); if (isSel) { r.right -= kSelMargin; r.Shrink(0, kSelMargin); } r.Shrink(kBorderWidth, kBorderWidth); DrawTab(i, p, r, itsEdge); DrawCloseButton(i, p, r); r.Expand(kBorderWidth, kBorderWidth); if (r.bottom >= ap.bottom - scrollArrowWidth) { if (itsFirstDrawIndex == 1 && i == count && r.bottom <= ap.bottom) { break; } itsCanScrollDownFlag = JI2B( itsFirstDrawIndex < count ); itsLastDrawIndex = i; if (r.bottom > ap.bottom - scrollArrowWidth && i > itsFirstDrawIndex) { itsLastDrawIndex--; } break; } r.top = r.bottom; } } JRect r = itsCardFile->GetFrame(); r.Expand(kBorderWidth, kBorderWidth); JXDrawUpFrame(p, r, kBorderWidth); if (!selRect.IsEmpty()) { DrawTabBorder(p, selRect, kJTrue); } DrawScrollButtons(p, lineHeight); }