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); } }
JIndex JNamedConstant::PrepareToRender ( const JExprRenderer& renderer, const JPoint& upperLeft, const JSize fontSize, JExprRectList* rectList ) { if (strcmp(JPGetStdNamedConstName(itsNameIndex), JPGetPiString()) == 0) { JRect ourRect; ourRect.top = upperLeft.y; ourRect.left = upperLeft.x; ourRect.bottom = upperLeft.y + renderer.GetLineHeight(fontSize); ourRect.right = upperLeft.x + renderer.GetGreekCharWidth(fontSize, kGreekPiChar); const JCoordinate ourMidline = ourRect.ycenter(); return rectList->AddRect(ourRect, ourMidline, fontSize, this); } else { return JFunction::PrepareToRender(renderer, upperLeft, fontSize, rectList); } }
void CBCommandTable::HandleDNDHere ( const JPoint& pt, const JXWidget* source ) { JIndex newRowIndex = itsDNDRowIndex; JPoint cell; if (GetCell(JPinInRect(pt, GetBounds()), &cell)) { const JRect r = GetCellRect(cell); if (pt.y <= r.ycenter()) { newRowIndex = cell.y; } else { newRowIndex = cell.y + 1; } } if (newRowIndex != itsDNDRowIndex) { itsDNDRowIndex = newRowIndex; Refresh(); } }
void JXTextMenuTable::Draw ( JXWindowPainter& p, const JRect& rect ) { JXMenuTable::Draw(p, rect); const JCoordinate w = GetApertureWidth(); const JSize rowCount = GetRowCount(); for (JIndex i=1; i<rowCount; i++) // ignore separator after last item { if (itsTextMenuData->HasSeparator(i)) { JRect r = GetCellRect(JPoint(1,i)); r.top = r.bottom - kSeparatorHeight; r.right = r.left + w; // JXDrawDownFrame(p, r, kSeparatorHeight/2); r.top = r.ycenter() - 1; r.bottom = r.top + 2; JXDrawDownFrame(p, r, 1); } } if (itsHilightRow != 0) { const JRect r = GetCellRect(JPoint(1, itsHilightRow)); JRect r1 = AdjustRectForSeparator(itsHilightRow, r); r1.right = r1.left + w; JXDrawUpFrame(p, r1, kHilightBorderWidth); } }
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 JXColHeaderWidget::HandleMouseDrag ( const JPoint& origPt, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { if (itsDragType != kInvalidDrag) { JPoint pt = origPt; // keep col width larger than minimum if (pt.x < itsDragCellRect.left + itsMinColWidth) { pt.x = itsDragCellRect.left + itsMinColWidth; } // check if we have moved if (pt.x != itsPrevPt.x) { 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 y = tableAp.ycenter(); const JRect tableRect(y-1, ptT.x-1, y+1, ptT.x+1); if (itsTable->ScrollToRect(tableRect)) { (GetWindow())->Update(); enclAp = JXContainer::GlobalToLocal(enclApG); // local coords changed } else { // erase the old line p->Line(itsPrevPt.x, enclAp.top, itsPrevPt.x, enclAp.bottom); } // draw the new line p->Line(pt.x, enclAp.top, pt.x, enclAp.bottom); // ready for next call itsPrevPt = pt; } } }
void JXTextCheckbox::Draw ( JXWindowPainter& p, const JRect& rect ) { const JRect bounds = GetBounds(); const JCoordinate y = bounds.ycenter(); // draw button const JRect boxRect(y - kBoxHalfHeight, kMarginWidth, y + kBoxHalfHeight, kMarginWidth + kBoxHeight); const JBoolean drawChecked = DrawChecked(); const JBoolean isActive = IsActive(); if (drawChecked && isActive) { JXDrawDownFrame(p, boxRect, kJXDefaultBorderWidth, kJTrue, itsPushedColor); } else if (isActive) { JXDrawUpFrame(p, boxRect, kJXDefaultBorderWidth, kJTrue, itsNormalColor); } else { p.SetFilling(kJTrue); if (drawChecked) { p.SetPenColor(itsPushedColor); } else { p.SetPenColor(itsNormalColor); } p.JPainter::Rect(boxRect); p.SetFilling(kJFalse); p.SetLineWidth(kJXDefaultBorderWidth); p.SetPenColor((GetColormap())->GetInactiveLabelColor()); p.RectInside(boxRect); } // draw text JRect textRect = bounds; textRect.left += 2*kMarginWidth + kBoxHeight; p.SetFont(itsFontName, itsFontSize, itsFontStyle); p.String(textRect.left, textRect.top, itsLabel, itsULIndex, textRect.width(), JPainter::kHAlignLeft, textRect.height(), JPainter::kVAlignCenter); }
void CBSearchDocument::PlaceCmdLineWidgets() { CBExecOutputDocument::PlaceCmdLineWidgets(); JXWindow* window = GetWindow(); JXWidget::HSizingOption hSizing; JXWidget::VSizingOption vSizing; const JRect frame = GetFileDisplayInfo(&hSizing, &vSizing); itsIndicator->Place(frame.left, frame.ycenter() - kIndicatorHeight/2); itsIndicator->SetSize(frame.width(), kIndicatorHeight); }
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 SVNTabGroup::DrawTab ( const JIndex index, JXWindowPainter& p, const JRect& rect, const Edge edge ) { if (index == itsBusyIndex) { JXImage* image = itsImageList->NthElement(itsSpinnerIndex); p.JPainter::Image(*image, image->GetBounds(), rect.left + kMarginWidth, rect.ycenter() - (image->GetHeight()/2)); } }
JIndex JFunction::PrepareToRender ( const JExprRenderer& renderer, const JPoint& upperLeft, const JSize fontSize, JExprRectList* rectList ) { const JString text = Print(); JRect ourRect; ourRect.top = upperLeft.y; ourRect.left = upperLeft.x; ourRect.bottom = upperLeft.y + renderer.GetLineHeight(fontSize); ourRect.right = upperLeft.x + renderer.GetStringWidth(fontSize, text); const JCoordinate ourMidline = ourRect.ycenter(); return rectList->AddRect(ourRect, ourMidline, fontSize, this); }
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 JParallel::Render ( const JExprRenderer& renderer, const JExprRectList& rectList ) const { // find ourselves in the list JIndex ourIndex; const JBoolean found = rectList.FindFunction(this, &ourIndex); assert( found ); const JRect ourRect = rectList.GetRect(ourIndex); const JCoordinate ourMidline = rectList.GetMidline(ourIndex); const JSize fontSize = rectList.GetFontSize(ourIndex); // draw ourselves const JSize spaceWidth = renderer.GetStringWidth(fontSize, " "); const JSize barWidth = renderer.GetVertBarWidth(); const JSize lineHeight = renderer.GetLineHeight(fontSize); JSize maxBarLength; if (((JSize) ourRect.height()) > lineHeight) { maxBarLength = JLFloor(ourRect.height()/2.0); } else { maxBarLength = ourRect.height(); } JSize barLength; if (ourMidline > ourRect.ycenter()) { barLength = 2*(ourRect.bottom - ourMidline); } else { barLength = 2*(ourMidline - ourRect.top); } if (barLength > maxBarLength) { barLength = maxBarLength; } const JCoordinate barTop = ourMidline - barLength/2; const JSize argCount = GetArgCount(); for (JIndex i=1; i<=argCount; i++) { const JFunction* arg = GetArg(i); arg->Render(renderer, rectList); JIndex argIndex; const JBoolean found = rectList.FindFunction(arg, &argIndex); assert( found ); const JRect argRect = rectList.GetRect(argIndex); JCoordinate h = argRect.right + spaceWidth; if (ParenthesizeArgForRender(*this, *arg)) { renderer.DrawParentheses(argRect); h += renderer.GetParenthesisWidth(argRect.height()); } if (i < argCount) { renderer.DrawVertBar(h, barTop, barLength); renderer.DrawVertBar(h + barWidth, barTop, barLength); } } }
JIndex JFunctionWithVar::PrepareToRender ( const JExprRenderer& renderer, const JPoint& upperLeft, const JSize fontSize, JExprRectList* rectList ) { // intialize our rectangle and midline JString baseName, subscript; itsVariableList->GetVariableName(itsVariableIndex, &baseName, &subscript); JRect ourRect; ourRect.top = upperLeft.y; ourRect.left = upperLeft.x; ourRect.bottom = upperLeft.y + renderer.GetLineHeight(fontSize); ourRect.right = upperLeft.x + GetStringWidth(renderer, fontSize, baseName); JCoordinate ourMidline = ourRect.ycenter(); // add in subscript if (!subscript.IsEmpty()) { const JSize subFontSize = renderer.GetSuperSubFontSize(fontSize); const JCoordinate subHeight = renderer.GetLineHeight(subFontSize); if (ourMidline + subHeight > ourRect.bottom) { ourRect.bottom = ourMidline + subHeight; } ourRect.right += GetStringWidth(renderer, subFontSize, subscript); } // add in array index if (itsArrayIndex != NULL) { // get rectangle for array index JPoint argUpperLeft(ourRect.right, ourRect.top); const JIndex argIndex = itsArrayIndex->PrepareToRender(renderer, argUpperLeft, fontSize, rectList); ourRect = JCovering(ourRect, rectList->GetRect(argIndex)); ourMidline = rectList->GetMidline(argIndex); // shift array index to make space for left bracket const JSize bracketWidth = renderer.GetSquareBracketWidth(ourRect.height()); rectList->ShiftRect(argIndex, bracketWidth, 0); // we need space for two brackets ourRect.right += 2*bracketWidth; } // save our rectangle return rectList->AddRect(ourRect, ourMidline, fontSize, this); }