void JXTabGroup::DrawCloseButton ( const JIndex index, JXWindowPainter& p, const JRect& rect ) { if (index != itsMouseIndex) { return; } else if (!TabCanClose(index)) { itsCloseRect.Set(0,0,0,0); return; } if (itsEdge == kTop || itsEdge == kBottom) { itsCloseRect.top = rect.ycenter() - itsCloseImage->GetHeight()/2; itsCloseRect.bottom = itsCloseRect.top + itsCloseImage->GetHeight(); itsCloseRect.right = rect.right - kCloseMarginWidth; itsCloseRect.left = itsCloseRect.right - itsCloseImage->GetWidth(); } else if (itsEdge == kLeft) { itsCloseRect.top = rect.top + kCloseMarginWidth; itsCloseRect.bottom = itsCloseRect.top + itsCloseImage->GetHeight(); itsCloseRect.left = rect.xcenter() - itsCloseImage->GetWidth()/2; itsCloseRect.right = itsCloseRect.left + itsCloseImage->GetWidth(); } else // itsEdge == kRight { itsCloseRect.bottom = rect.bottom - kCloseMarginWidth; itsCloseRect.top = itsCloseRect.bottom - itsCloseImage->GetHeight(); itsCloseRect.left = rect.xcenter() - itsCloseImage->GetWidth()/2; itsCloseRect.right = itsCloseRect.left + itsCloseImage->GetWidth(); } if (itsClosePushedFlag) { p.Image(*itsClosePushedImage, itsClosePushedImage->GetBounds(), itsCloseRect); } else { p.Image(*itsCloseImage, itsCloseImage->GetBounds(), itsCloseRect); } }
void JXExprEditor::GetDrawingOffset ( JPoint* delta ) const { const JRect bounds = GetBounds(); const JExprRectList* rectList = GetRectList(); const JRect exprBounds = rectList->GetBoundsRect(); delta->x = bounds.xcenter() - exprBounds.xcenter(); delta->y = bounds.ycenter() - exprBounds.ycenter(); }
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 JXRowHeaderWidget::HandleMouseDrag ( const JPoint& origPt, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { if (itsDragType != kInvalidDrag) { JPoint pt = origPt; // keep col width larger than minimum if (pt.y < itsDragCellRect.top + itsMinRowHeight) { pt.y = itsDragCellRect.top + itsMinRowHeight; } // check if we have moved if (pt.y != itsPrevPt.y) { JPainter* p = NULL; const JBoolean ok = GetDragPainter(&p); assert( ok ); const JRect enclApG = (GetEnclosure())->GetApertureGlobal(); JRect enclAp = JXContainer::GlobalToLocal(enclApG); // scroll, if necessary const JPoint ptG = JXContainer::LocalToGlobal(pt); const JPoint ptT = JPinInRect(itsTable->JXContainer::GlobalToLocal(ptG), itsTable->GetBounds()); const JRect tableAp = itsTable->GetAperture(); const JCoordinate x = tableAp.xcenter(); const JRect tableRect(ptT.y-1, x-1, ptT.y+1, x+1); if (itsTable->ScrollToRect(tableRect)) { (GetWindow())->Update(); enclAp = JXContainer::GlobalToLocal(enclApG); // local coords changed } else { // erase the old line p->Line(enclAp.left, itsPrevPt.y, enclAp.right, itsPrevPt.y); } // draw the new line p->Line(enclAp.left, pt.y, enclAp.right, pt.y); // ready for next call itsPrevPt = pt; } } }
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 CMLineIndexTable::DrawBreakpoints ( JPainter& p, const JPoint& cell, const JRect& rect ) { // check for breakpoint(s) on this line JBoolean hasMultiple; if (!FindNextBreakpoint(cell.y, &hasMultiple)) { return; } // draw breakpoint(s) JRect r = rect; r.Shrink(kMarginWidth, kMarginWidth); if (hasMultiple) { if (r.height() < 9) // to allow concentric circles to be distinguished { r.top = rect.ycenter() - 4; r.bottom = r.top + 9; r.left = rect.xcenter() - 4; r.right = r.left + 9; } p.Ellipse(r); r.Shrink(3, 3); p.Ellipse(r); } else { DrawBreakpoint(itsBPList->NthElement(itsBPDrawIndex), p, GetColormap(), r); } }
void JXWidget::CenterWithinEnclosure ( const JBoolean adjustHoriz, const JBoolean adjustVert ) { const JRect frame = GetFrame(); const JPoint oldPt = frame.topLeft(); const JRect enclBounds = (GetEnclosure())->GetBounds(); JCoordinate dx=0, dy=0; if (adjustHoriz) { dx = (enclBounds.xcenter() - frame.width()/2) - oldPt.x; } if (adjustVert) { dy = (enclBounds.ycenter() - frame.height()/2) - oldPt.y; } Move(dx,dy); }
void JXMenuBar::WidthChanged() { if (itsMenus->IsEmpty() || itsIgnoreWidthChangedCount > 0) { return; } itsIgnoreWidthChangedCount++; // put all menus back in menubar ClearOverflowMenu(); // check if menus fit on menubar const JRect ap = GetAperture(); JXMenu* m = itsMenus->LastElement(); JRect frame = m->GetFrame(); if (frame.xcenter() < ap.right) { assert( itsIgnoreWidthChangedCount > 0 ); itsIgnoreWidthChangedCount--; return; } // create menu to hold overflow JXImage* image = new JXImage(GetDisplay(), jx_down_chevron); assert( image != NULL ); JXTextMenu* overflowMenu = new JXTextMenu(image, kJTrue, this, kFixedLeft, kFixedTop, 0,0, 10,10); assert( overflowMenu != NULL ); overflowMenu->SetUpdateAction(JXMenu::kDisableNone); overflowMenu->SetMenuBar(this); // don't show down arrow at right of title const JCoordinate extraWidth = overflowMenu->GetFrameWidth(); overflowMenu->SetMenuBar(NULL); // move menus to overflow menu while (frame.right > ap.right - extraWidth) { const JString& title = m->GetTitleText(); if (title.IsEmpty()) { break; } overflowMenu->PrependItem(title); overflowMenu->AttachSubmenu(1, m); if (itsMenus->IsEmpty()) { break; } m = itsMenus->LastElement(); frame = m->GetFrame(); } if (overflowMenu->IsEmpty()) { delete overflowMenu; overflowMenu = NULL; } else { AppendMenu(overflowMenu); itsOverflowMenu = overflowMenu; } assert( itsIgnoreWidthChangedCount > 0 ); itsIgnoreWidthChangedCount--; }