void JXSearchTextButton::Draw ( JXWindowPainter& p, const JRect& rect ) { const JRect bounds = GetBounds(); JRect r; r.top = bounds.ycenter() - kArrowHalfHeight; r.bottom = r.top + 2*kArrowHalfHeight + 1; r.left = bounds.xcenter() - kArrowHalfWidth; r.right = r.left + 2*kArrowHalfWidth; const JColorIndex colorIndex = IsActive() ? (p.GetColormap())->GetGrayColor(40) : (p.GetColormap())->GetInactiveLabelColor(); if (itsFwdFlag) { r.right++; JXFillArrowRight(p, r, colorIndex); } else { r.left--; JXFillArrowLeft(p, r, colorIndex); } }
void JX3DWidget::DrawBorder ( JXWindowPainter& p, const JRect& frame ) { const JSize borderWidth = GetBorderWidth(); if (itsShowFocusFlag && HasFocus() && borderWidth > 0) { p.SetLineWidth(borderWidth); p.SetPenColor((p.GetColormap())->GetWhiteColor()); p.RectInside(frame); } else { JXDrawDownFrame(p, frame, borderWidth); } }
void JXDocktab::Draw ( JXWindowPainter& p, const JRect& rect ) { const JColormap* cmap = p.GetColormap(); // drag region JXWindow* w = GetWindow(); JXWindow* focusWindow; JXDockWidget* dock; if (w->GetDockWidget(&dock) && (dock->GetDockDirector())->GetFocusWindow(&focusWindow) && focusWindow == w) { p.SetPenColor(itsFocusColor); p.SetFilling(kJTrue); p.JPainter::Rect(rect); p.SetPenColor((GetColormap())->GetBlackColor()); p.SetFilling(kJFalse); p.SetPenColor(cmap->GetWhiteColor()); } else { p.SetPenColor(cmap->GetGrayColor(60)); } const JRect ap = GetAperture(); const JCoordinate y1 = ap.top + 1; const JCoordinate y2 = ap.bottom - 2; p.Line(3, y1, 3, y2); p.Line(5, y1, 5, y2); }
void JXHorizPartition::Draw ( JXWindowPainter& p, const JRect& rect ) { p.SetPenColor((p.GetColormap())->GetGray60Color()); const JRect ap = GetAperture(); const JCoordinate y1 = ap.top+1; const JCoordinate y2 = ap.bottom-2; const JSize compartmentCount = GetCompartmentCount(); JCoordinate x = 0; for (JIndex i=1; i<compartmentCount; i++) { x += GetCompartmentSize(i); p.Line(x+1, y1, x+1, y2); p.Line(x+3, y1, x+3, y2); x += kDragRegionSize; } }
void JXVertPartition::Draw ( JXWindowPainter& p, const JRect& rect ) { p.SetPenColor((p.GetColormap())->GetGray60Color()); const JRect ap = GetAperture(); const JCoordinate x1 = ap.left+1; const JCoordinate x2 = ap.right-2; const JSize compartmentCount = GetCompartmentCount(); JCoordinate y = 0; for (JIndex i=1; i<compartmentCount; i++) { y += GetCompartmentSize(i); p.Line(x1, y+1, x2, y+1); p.Line(x1, y+3, x2, y+3); y += kDragRegionSize; } }
void JXInputField::DrawBorder ( JXWindowPainter& p, const JRect& frame ) { if (itsTable != NULL) { if (IsDNDTarget()) { p.SetPenColor((p.GetColormap())->GetDefaultDNDBorderColor()); } else { p.SetPenColor((GetColormap())->GetBlackColor()); } p.JPainter::Rect(frame); } else { JXTEBase::DrawBorder(p, frame); } }
void JXTabGroup::DrawTabBorder ( JXWindowPainter& p, const JRect& rect, const JBoolean isSelected ) { JXDrawUpFrame(p, rect, kBorderWidth); const JColormap* cmap = p.GetColormap(); if (itsEdge == kTop) { p.SetPenColor(cmap->GetDefaultBackColor()); p.JPainter::Point(rect.topLeft()); p.JPainter::Point(rect.topRight() + JPoint(-1,0)); p.JPainter::Point(rect.topRight() + JPoint(-2,0)); p.JPainter::Point(rect.topRight() + JPoint(-1,1)); p.JPainter::Point(rect.topRight() + JPoint(-1,2)); p.SetPenColor(cmap->Get3DLightColor()); p.JPainter::Point(rect.topLeft() + JPoint(kBorderWidth, kBorderWidth)); p.SetPenColor(cmap->Get3DShadeColor()); p.JPainter::Point(rect.topRight() + JPoint(-kBorderWidth-1, kBorderWidth)); if (isSelected) { JRect r(rect.bottom - kBorderWidth, rect.left + kBorderWidth, rect.bottom, rect.right - kBorderWidth); p.SetPenColor(cmap->GetGrayColor(kSelGrayPercentage)); p.JPainter::Rect(r); p.JPainter::Point(rect.topLeft() + JPoint(-1,kSelMargin+kBorderWidth)); p.SetPenColor(cmap->Get3DLightColor()); p.JPainter::Point(rect.bottomLeft() + JPoint(1,-1)); p.JPainter::Point(rect.bottomRight() + JPoint(-2,-1)); p.JPainter::Point(rect.bottomRight() + JPoint(-1,-2)); p.JPainter::Point(rect.bottomRight() + JPoint(-1,-1)); } } else if (itsEdge == kLeft) { p.SetPenColor(cmap->GetDefaultBackColor()); p.JPainter::Point(rect.topLeft()); p.JPainter::Point(rect.bottomLeft() + JPoint(0,-1)); p.JPainter::Point(rect.bottomLeft() + JPoint(0,-2)); p.JPainter::Point(rect.bottomLeft() + JPoint(1,-1)); p.JPainter::Point(rect.bottomLeft() + JPoint(2,-1)); p.SetPenColor(cmap->Get3DLightColor()); p.JPainter::Point(rect.topLeft() + JPoint(kBorderWidth, kBorderWidth)); p.SetPenColor(cmap->Get3DShadeColor()); p.JPainter::Point(rect.bottomLeft() + JPoint(kBorderWidth, -kBorderWidth-1)); if (isSelected) { JRect r(rect.top + kBorderWidth, rect.right - kBorderWidth, rect.bottom - kBorderWidth, rect.right); p.SetPenColor(cmap->GetGrayColor(kSelGrayPercentage)); p.JPainter::Rect(r); p.JPainter::Point(rect.topLeft() + JPoint(kSelMargin+kBorderWidth,-1)); p.SetPenColor(cmap->Get3DLightColor()); p.JPainter::Point(rect.topRight() + JPoint(-1,1)); if (rect.bottom < (GetAperture()).bottom) { p.JPainter::Point(rect.bottomRight() + JPoint(-1,-1)); p.JPainter::Point(rect.bottomRight() + JPoint(-2,-1)); p.JPainter::Point(rect.bottomRight() + JPoint(-1,-2)); } } } else if (itsEdge == kBottom) { p.SetPenColor(cmap->GetDefaultBackColor()); p.JPainter::Point(rect.bottomLeft() + JPoint(0,-1)); p.JPainter::Point(rect.bottomLeft() + JPoint(0,-2)); p.JPainter::Point(rect.bottomLeft() + JPoint(1,-1)); p.JPainter::Point(rect.bottomLeft() + JPoint(2,-1)); p.JPainter::Point(rect.bottomRight() + JPoint(-1,-1)); p.SetPenColor(cmap->Get3DLightColor()); p.JPainter::Point(rect.bottomLeft() + JPoint(kBorderWidth, -kBorderWidth-1)); p.SetPenColor(cmap->Get3DShadeColor()); p.JPainter::Point(rect.bottomRight() + JPoint(-kBorderWidth-1, -kBorderWidth-1)); if (isSelected) { JRect r(rect.top, rect.left + kBorderWidth, rect.top + kBorderWidth, rect.right - kBorderWidth); p.SetPenColor(cmap->GetGrayColor(kSelGrayPercentage)); p.JPainter::Rect(r); p.SetPenColor(cmap->Get3DShadeColor()); if (rect.left > (GetAperture()).left) { p.JPainter::Point(rect.topLeft()); } p.JPainter::Point(rect.topRight() + JPoint(-1,0)); p.JPainter::Point(rect.topRight() + JPoint(-2,0)); p.JPainter::Point(rect.topRight() + JPoint(-2,1)); } } else if (itsEdge == kRight) { p.SetPenColor(cmap->GetDefaultBackColor()); p.JPainter::Point(rect.topRight() + JPoint(-1,0)); p.JPainter::Point(rect.topRight() + JPoint(-2,0)); p.JPainter::Point(rect.topRight() + JPoint(-1,1)); p.JPainter::Point(rect.topRight() + JPoint(-1,2)); p.JPainter::Point(rect.bottomRight() + JPoint(-1,-1)); p.SetPenColor(cmap->Get3DLightColor()); p.JPainter::Point(rect.topRight() + JPoint(-kBorderWidth-1, kBorderWidth)); p.SetPenColor(cmap->Get3DShadeColor()); p.JPainter::Point(rect.bottomRight() + JPoint(-kBorderWidth-1, -kBorderWidth-1)); if (isSelected) { JRect r(rect.top + kBorderWidth, rect.left, rect.bottom - kBorderWidth, rect.left + kBorderWidth); p.SetPenColor(cmap->GetGrayColor(kSelGrayPercentage)); p.JPainter::Rect(r); p.SetPenColor(cmap->Get3DShadeColor()); if (rect.top > (GetAperture()).top) { p.JPainter::Point(rect.topLeft()); } p.JPainter::Point(rect.bottomLeft() + JPoint(0,-1)); p.JPainter::Point(rect.bottomLeft() + JPoint(0,-2)); p.JPainter::Point(rect.bottomLeft() + JPoint(1,-2)); } } }
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); }
void JXTabGroup::DrawScrollButtons ( JXWindowPainter& p, const JCoordinate lineHeight ) { itsScrollUpRect = itsScrollDownRect = JRect(0,0,0,0); if (!itsCanScrollUpFlag && !itsCanScrollDownFlag) { return; } const JCoordinate w = 2*(kArrowWidth + kBorderWidth); const JCoordinate h = kSelMargin + kBorderWidth + 2*kTextMargin + lineHeight; const JRect ap = GetAperture(); const JColormap* cmap = p.GetColormap(); if (itsEdge == kTop) { JRect r(ap.top, ap.right - w, ap.top + h, ap.right); p.SetPenColor(cmap->GetDefaultBackColor()); p.SetFilling(kJTrue); p.JPainter::Rect(r); p.SetFilling(kJFalse); r.Shrink(kBorderWidth, 0); r.top = r.bottom = r.ycenter(); r.top -= kArrowWidth/2; r.bottom += kArrowWidth/2 + kArrowWidth%2; r.right = r.left + kArrowWidth; if (itsCanScrollUpFlag && itsScrollUpPushedFlag) { JXDrawDownArrowLeft(p, r, kBorderWidth); } else if (itsCanScrollUpFlag) { JXDrawUpArrowLeft(p, r, kBorderWidth); } else { JXFillArrowLeft(p, r, cmap->GetInactiveLabelColor()); } itsScrollUpRect = r; r.left += kArrowWidth; r.right += kArrowWidth; if (itsCanScrollDownFlag && itsScrollDownPushedFlag) { JXDrawDownArrowRight(p, r, kBorderWidth); } else if (itsCanScrollDownFlag) { JXDrawUpArrowRight(p, r, kBorderWidth); } else { JXFillArrowRight(p, r, cmap->GetInactiveLabelColor()); } itsScrollDownRect = r; } else if (itsEdge == kLeft) { JRect r(ap.top, ap.left, ap.top + w, ap.left + h); p.SetPenColor(cmap->GetDefaultBackColor()); p.SetFilling(kJTrue); p.JPainter::Rect(r); p.SetFilling(kJFalse); r.Shrink(0, kBorderWidth); r.left = r.right = r.xcenter(); r.left -= kArrowWidth/2; r.right += kArrowWidth/2 + kArrowWidth%2; r.bottom = r.top + kArrowWidth; if (itsCanScrollDownFlag && itsScrollDownPushedFlag) { JXDrawDownArrowUp(p, r, kBorderWidth); } else if (itsCanScrollDownFlag) { JXDrawUpArrowUp(p, r, kBorderWidth); } else { JXFillArrowUp(p, r, cmap->GetInactiveLabelColor()); } itsScrollDownRect = r; r.top += kArrowWidth; r.bottom += kArrowWidth; if (itsCanScrollUpFlag && itsScrollUpPushedFlag) { JXDrawDownArrowDown(p, r, kBorderWidth); } else if (itsCanScrollUpFlag) { JXDrawUpArrowDown(p, r, kBorderWidth); } else { JXFillArrowDown(p, r, cmap->GetInactiveLabelColor()); } itsScrollUpRect = r; } else if (itsEdge == kBottom) { JRect r(ap.bottom - h, ap.right - w, ap.bottom, ap.right); p.SetPenColor(cmap->GetDefaultBackColor()); p.SetFilling(kJTrue); p.JPainter::Rect(r); p.SetFilling(kJFalse); r.Shrink(kBorderWidth, 0); r.top = r.bottom = r.ycenter(); r.top -= kArrowWidth/2; r.bottom += kArrowWidth/2 + kArrowWidth%2; r.right = r.left + kArrowWidth; if (itsCanScrollUpFlag && itsScrollUpPushedFlag) { JXDrawDownArrowLeft(p, r, kBorderWidth); } else if (itsCanScrollUpFlag) { JXDrawUpArrowLeft(p, r, kBorderWidth); } else { JXFillArrowLeft(p, r, cmap->GetInactiveLabelColor()); } itsScrollUpRect = r; r.left += kArrowWidth; r.right += kArrowWidth; if (itsCanScrollDownFlag && itsScrollDownPushedFlag) { JXDrawDownArrowRight(p, r, kBorderWidth); } else if (itsCanScrollDownFlag) { JXDrawUpArrowRight(p, r, kBorderWidth); } else { JXFillArrowRight(p, r, cmap->GetInactiveLabelColor()); } itsScrollDownRect = r; } else if (itsEdge == kRight) { JRect r(ap.bottom - w, ap.right - h, ap.bottom, ap.right); p.SetPenColor(cmap->GetDefaultBackColor()); p.SetFilling(kJTrue); p.JPainter::Rect(r); p.SetFilling(kJFalse); r.Shrink(0, kBorderWidth); r.left = r.right = r.xcenter(); r.left -= kArrowWidth/2; r.right += kArrowWidth/2 + kArrowWidth%2; r.bottom = r.top + kArrowWidth; if (itsCanScrollUpFlag && itsScrollUpPushedFlag) { JXDrawDownArrowUp(p, r, kBorderWidth); } else if (itsCanScrollUpFlag) { JXDrawUpArrowUp(p, r, kBorderWidth); } else { JXFillArrowUp(p, r, cmap->GetInactiveLabelColor()); } itsScrollUpRect = r; r.top += kArrowWidth; r.bottom += kArrowWidth; if (itsCanScrollDownFlag && itsScrollDownPushedFlag) { JXDrawDownArrowDown(p, r, kBorderWidth); } else if (itsCanScrollDownFlag) { JXDrawUpArrowDown(p, r, kBorderWidth); } else { JXFillArrowDown(p, r, cmap->GetInactiveLabelColor()); } itsScrollDownRect = r; } }