void CBCommandTable::Draw ( JXWindowPainter& p, const JRect& rect ) { JXEditTable::Draw(p, rect); if (itsDNDRowIndex > 0) { p.ResetClipRect(); const JSize origLineWidth = p.GetLineWidth(); p.SetLineWidth(3); const JRect b = GetBounds(); if (RowIndexValid(itsDNDRowIndex)) { const JRect r = GetCellRect(JPoint(1, itsDNDRowIndex)); p.Line(b.left, r.top, b.right, r.top); } else { const JRect r = GetCellRect(JPoint(1, GetRowCount())); p.Line(b.left, r.bottom, b.right, r.bottom); } p.SetLineWidth(origLineWidth); } }
void GMFilterNameTable::Draw ( JXWindowPainter& p, const JRect& rect ) { JXEditTable::Draw(p, rect); if (itsDNDIsValid) { p.ResetClipRect(); p.SetLineWidth(kDragLineWidth); if (itsCurrentDNDIndex == 0) { JRect crect = GetCellRect(JPoint(1, GetRowCount())); p.Line(0, crect.bottom, GetBoundsWidth(), crect.bottom); } else { JRect crect = GetCellRect(JPoint(1, itsCurrentDNDIndex)); p.Line(0, crect.top, GetBoundsWidth(), crect.top); } } }
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 GLFitParameterTable::HandleKeyPress ( const int key, const JXKeyModifiers& modifiers ) { JPoint cell; if (key == kJReturnKey && GetEditedCell(&cell)) { if (EndEditing()) { if (!modifiers.shift() && cell.y < (JCoordinate)GetRowCount()) { BeginEditing(JPoint(cell.x, cell.y + 1)); } else if (modifiers.shift() && cell.y > 1) { BeginEditing(JPoint(cell.x, cell.y - 1)); } } } else if (key == kJTabKey) { // do nothing } else { JXEditTable::HandleKeyPress(key, modifiers); } }
void JXTextMenuTable::GetSubmenuPoints ( const JIndex itemIndex, JPoint* leftPt, JPoint* rightPt ) { const JRect cellRect = GetCellRect(JPoint(1,itemIndex)); const JRect ap = GetAperture(); *leftPt = JPoint(ap.left+1, cellRect.top); *rightPt = JPoint(ap.right-1, cellRect.top); }
void THXVarTable::NewConstant() { const JIndex rowIndex = itsVarList->NewFunction() - THXVarList::kUserFnOffset; InsertRows(rowIndex, 1); BeginEditing(JPoint(1,rowIndex)); }
void CMLineIndexTable::TableDrawCell ( JPainter& p, const JPoint& cell, const JRect& rect ) { HilightIfSelected(p, cell, rect); if (JIndex(cell.x) == kBreakpointColumn) { DrawBreakpoints(p, cell, rect); } else if (JIndex(cell.x) == kExecPointColumn && cell.y == itsCurrentLineIndex) { // We can't use a static polygon because line heights can vary, // e.g. due to underlines. const JCoordinate delta = rect.height()/2; JPolygon poly; poly.AppendElement(JPoint(rect.left+kMarginWidth, rect.top)); poly.AppendElement(JPoint(rect.left+kMarginWidth+delta, rect.top + delta)); poly.AppendElement(JPoint(rect.left+kMarginWidth, rect.top + 2*delta)); p.SetPenColor(GetCurrentLineMarkerColor()); p.SetFilling(kJTrue); p.Polygon(poly); p.SetPenColor(GetColormap()->GetBlackColor()); p.SetFilling(kJFalse); p.Polygon(poly); } else if (JIndex(cell.x) == kLineNumberColumn) { p.SetFont(itsText->GetDefaultFont()); JRect r = rect; r.right -= kMarginWidth; const JString str = GetLineText(cell.y); p.String(r, str, JPainter::kHAlignRight); } }
JPoint JXWidget::LocalToGlobal ( const JCoordinate x, const JCoordinate y ) const { return JPoint(x + itsBoundsG.left, y + itsBoundsG.top); }
void CBSymbolTable::SelectSingleEntry ( const JIndex index, const JBoolean scroll ) { SelectSingleCell(JPoint(1, index), scroll); itsKeyBuffer.Clear(); }
void CBCommandTable::DuplicateCommand() { JPoint cell; if ((GetTableSelection()).GetFirstSelectedCell(&cell) && EndEditing()) { itsCmdList->AppendElement((itsCmdList->GetElement(cell.y)).Copy()); AppendRows(1); BeginEditing(JPoint(kCommandColumn, itsCmdList->GetElementCount())); } }
void JXTreeListWidget::ScrollToNode ( const JTreeNode* node ) { JIndex index; if (itsTreeList->FindNode(node, &index)) { TableScrollToCell(JPoint(1, index)); } }
void CBMacroTable::ReadData ( const JCharacter* fileName, const JBoolean replace ) { JStringTableData* data = GetStringData(); if (replace) { data->RemoveAllRows(); } JIndex firstNewRow = 0; ifstream input(fileName); JString macro, script; JIndex state = 1; while (!input.eof() && !input.fail()) { if (state == 1) { macro = JReadLine(input); if (!macro.IsEmpty()) { state = 2; } } else if (state == 2) { script = JReadLine(input); if (!script.IsEmpty()) { data->AppendRows(1); const JSize rowCount = data->GetRowCount(); data->SetString(rowCount,kMacroColumn, macro); data->SetString(rowCount,kScriptColumn, script); if (firstNewRow == 0) { firstNewRow = rowCount; } state = 1; } } } if (firstNewRow != 0) { ScrollTo((GetBounds()).bottomLeft()); BeginEditing(JPoint(kMacroColumn, firstNewRow)); } }
JX2DCurveNameList::JX2DCurveNameList ( const JArray<J2DCurveInfo>& curveInfo, const JIndex startIndex, JXScrollbarSet* scrollbarSet, JXContainer* enclosure, const HSizingOption hSizing, const VSizingOption vSizing, const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h ) : JXEditTable(1, kDefColWidth, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h), itsInput(NULL) { itsMinColWidth = 1; const JFontManager* fontMgr = GetFontManager(); const JSize rowHeight = 2*kVMarginWidth + fontMgr->GetDefaultFont().GetLineHeight(); SetDefaultRowHeight(rowHeight); const JSize count = curveInfo.GetElementCount(); itsNameList = jnew JPtrArray<JString>(JPtrArrayT::kForgetAll, count); assert(itsNameList != NULL); AppendRows(count); for (JIndex i=1; i<=count; i++) { const J2DCurveInfo info = curveInfo.GetElement(i); itsNameList->Append(info.name); const JCoordinate width = 2*kHMarginWidth + fontMgr->GetDefaultFont().GetStringWidth(*(info.name)); if (width > itsMinColWidth) { itsMinColWidth = width; } } AppendCols(1); AdjustColWidth(); JXColormap* colormap = GetColormap(); SetRowBorderInfo(0, colormap->GetBlackColor()); SetColBorderInfo(0, colormap->GetBlackColor()); BeginEditing(JPoint(1, startIndex)); }
void JXGC::SetClipRect ( const JRect& clipRect ) { ClearPrivateClipping(); XRectangle xrect = JXJToXRect(clipRect); itsClipRegion = JXRectangleRegion(&xrect); itsClipOffset = JPoint(0,0); XSetClipRectangles(*itsDisplay, itsXGC, 0,0, &xrect, 1, Unsorted); }
void CBCommandTable::AddCommand() { if (EndEditing()) { CBCommandManager::CmdInfo info(new JString("./"), new JString, new JString, new JString, new JString, new JString); assert( info.path != NULL && info.cmd != NULL && info.name != NULL && info.menuText != NULL && info.menuShortcut != NULL ); itsCmdList->AppendElement(info); AppendRows(1); BeginEditing(JPoint(kCommandColumn, itsCmdList->GetElementCount())); } }
JBoolean JTableSelectionIterator::Prev ( JPoint* cell ) { if (AtBeginning()) { *cell = JPoint(0,0); return kJFalse; } while (PrevCell()) { if (itsTableSelection->IsSelected(itsCursor)) { *cell = itsCursor; return kJTrue; } } *cell = JPoint(0,0); return kJFalse; }
void SyGBeginEditingTask::Perform() { itsTable->itsEditTask = NULL; // first action: allows it to create another one, if necessary JPoint cell; if ((itsTable->GetTableSelection()).GetSingleSelectedCell(&cell) && (itsTable->GetFileTreeList())->GetSyGNode(cell.y) == itsNode) { itsTable->BeginEditing(cell); itsTable->TableScrollToCell(JPoint(itsTable->GetToggleOpenColIndex(), cell.y)); } jdelete this; }
void JXFSBindingTable::AddPattern() { if (EndEditing()) { const JFSBinding* b = itsBindingList->GetDefaultCommand(); JFSBinding::CommandType type; JBoolean singleFile; const JString& cmd = b->GetCommand(&type, &singleFile); const JIndex rowIndex = itsBindingList->AddBinding("", cmd, type, singleFile); InsertRows(rowIndex, 1); BeginEditing(JPoint(kPatternColumn, rowIndex)); Broadcast(DataChanged()); } }
void JXGC::ClearPrivateClipping() { itsClipOffset = JPoint(0,0); if (itsClipRegion != NULL) { XDestroyRegion(itsClipRegion); itsClipRegion = NULL; } if (itsClipPixmap != None) { XFreePixmap(*itsDisplay, itsClipPixmap); itsClipPixmap = None; } }
void TestWidget::Receive ( JBroadcaster* sender, const Message& message ) { JXWindow* window = GetWindow(); // insure that it isn't const JXWindowIcon* windowIcon = NULL; if (sender == itsAnimButton && message.Is(JXButton::kPushed)) { if (GetCursorAnimator() == NULL) { CreateCursorAnimator(); itsAnimButton->SetShortcuts("^o^m"); itsAnimButton->SetLabel("Stop"); if (itsAnimColorTask != NULL) { (JXGetApplication())->InstallIdleTask(itsAnimColorTask); } } else { RemoveCursorAnimator(); itsAnimButton->SetLabel("Start"); itsAnimButton->SetShortcuts("#a"); (JXGetApplication())->RemoveIdleTask(itsAnimColorTask); } } else if (sender == itsQuitButton && message.Is(JXButton::kPushed)) { (JXGetApplication())->Quit(); } else if (window->GetIconWidget(&windowIcon) && sender == windowIcon && message.Is(JXWindowIcon::kHandleDrop)) { const JXWindowIcon::HandleDrop* data = dynamic_cast(const JXWindowIcon::HandleDrop*, &message); assert( data != NULL ); HandleDNDDrop(JPoint(0,0), data->GetTypeList(), data->GetAction(), data->GetTime(), data->GetSource()); } else if (sender == window && message.Is(JXWindow::kIconified))
void JXGC::SetClipRegion ( const Region clipRegion ) { ClearPrivateClipping(); itsClipRegion = JXCopyRegion(clipRegion); itsClipOffset = JPoint(0,0); XSetRegion(*itsDisplay, itsXGC, clipRegion); const unsigned long valueMask = GCClipXOrigin | GCClipYOrigin; XGCValues values; values.clip_x_origin = 0; values.clip_y_origin = 0; XChangeGC(*itsDisplay, itsXGC, valueMask, &values); }
JBoolean JTableSelectionIterator::Next ( JPoint* cell ) { while (!AtEnd()) { *cell = itsCursor; NextCell(); if (itsTableSelection->IsSelected(*cell)) { return kJTrue; } } *cell = JPoint(0,0); return kJFalse; }
void JXFSBindingTable::DuplicatePattern() { JPoint cell; if ((GetTableSelection()).GetFirstSelectedCell(&cell) && EndEditing()) { const JFSBinding* b = itsBindingList->GetBinding(cell.y); JFSBinding::CommandType type; JBoolean singleFile; const JString& cmd = b->GetCommand(&type, &singleFile); const JIndex rowIndex = itsBindingList->AddBinding("", cmd, type, singleFile); InsertRows(rowIndex, 1); BeginEditing(JPoint(kPatternColumn, rowIndex)); Broadcast(DataChanged()); } }
void JXTextMenuTable::Receive ( JBroadcaster* sender, const Message& message ) { if (sender == const_cast<JXTextMenuData*>(itsTextMenuData) && message.Is(JXTextMenuData::kImageChanged)) { const JXTextMenuData::ImageChanged* item = dynamic_cast<const JXTextMenuData::ImageChanged*>(&message); assert( item != NULL ); TableRefreshCell(JPoint(kImageColumnIndex, item->GetIndex())); } else { JXMenuTable::Receive(sender, message); } }
void JXFSBindingTable::HandleKeyPress ( const int key, const JXKeyModifiers& modifiers ) { JPoint cell; if (GetEditedCell(&cell) && cell.x == kPatternColumn && (key == kJTabKey || (modifiers.meta() && (key == kJRightArrow || key == '6')))) { if (EndEditing() && (GetTableSelection()).GetSingleSelectedCell(&cell)) { BeginEditing(JPoint(kCommandColumn, cell.y)); } } else { JXEditTable::HandleKeyPress(key, modifiers); } }
void SVNListBase::HandleKeyPress ( const int key, const JXKeyModifiers& modifiers ) { JTableSelection& s = GetTableSelection(); const JBoolean hadSelection = s.HasSelection(); itsSavedSelection->CleanOut(); if (key == kJReturnKey) { OpenSelectedItems(); } // space->clear is handled by JXStringList else if (key == kJUpArrow || key == kJDownArrow) { ClearIncrementalSearchBuffer(); if (!hadSelection && key == kJUpArrow && GetRowCount() > 0) { SelectSingleCell(JPoint(1, GetRowCount())); } else { HandleSelectionKeyPress(key, modifiers); } } else { JXStringList::HandleKeyPress(key, modifiers); } }
#include "JPoint.h" char* theJPoint = JPoint().Register(); void JPoint::writeContent(JOutputStream& os) { JObject::writeContent(os); putInteger(os, "x", x); putInteger(os, "y", y); } void JPoint::readContent(JDictionary& dict) { JObject::readContent(dict); x = getInteger(dict, "x"); y = getInteger(dict, "y"); } const char* JPoint::className() const { return "JPoint";} int JPoint::hashCode() const { return (x^(y*31))&hashMask;} JObject* JPoint::clone() const { return new JPoint(*this);} int JPoint::compareTo(const JObject& s) const { if (className() != s.className()) return JObject::compareTo(s); int result = y-((JPoint*)&s)->y; if (!result) result = x-((JPoint*)&s)->x; return result; } JPoint::JPoint() { x = y = 0;} JPoint::JPoint(int _x, int _y) { x = _x;
void TestStringTable::HandleMouseDown ( const JPoint& pt, const JXMouseButton button, const JSize clickCount, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { itsIsDraggingFlag = kJFalse; if (button > kJXRightButton) { ScrollForWheel(button, modifiers); return; } JPoint cell; if (!GetCell(pt, &cell)) { return; } JStringTableData* data = GetStringData(); JTableSelection& s = GetTableSelection(); if (button == kJXMiddleButton) { BeginEditing(cell); } else if (itsMouseAction == kSelectCells) { if (button == kJXLeftButton && !modifiers.shift()) { s.ClearSelection(); s.SetBoat(cell); s.SetAnchor(cell); s.SelectCell(cell); itsIsDraggingFlag = kJTrue; } else { itsIsDraggingFlag = s.ExtendSelection(cell); } } else if (itsMouseAction == kSelectRows) { if (button == kJXLeftButton && !modifiers.shift()) { s.ClearSelection(); } s.SetBoat(JPoint(1, cell.y)); s.SetAnchor(JPoint(GetColCount(), cell.y)); s.SelectRow(cell.y); } else if (itsMouseAction == kSelectCols) { if (button == kJXLeftButton && !modifiers.shift()) { s.ClearSelection(); } s.SetBoat(JPoint(cell.x, 1)); s.SetAnchor(JPoint(cell.x, GetRowCount())); s.SelectCol(cell.x); } // row manipulations else if (button == kJXLeftButton && itsMouseAction == kInsertRow) { data->InsertRows(cell.y, 1); } else if (button == kJXRightButton && itsMouseAction == kInsertRow) { data->InsertRows(cell.y+1, 1); } else if (button == kJXLeftButton && itsMouseAction == kDuplicateRow) { data->DuplicateRow(cell.y, cell.y); } else if (button == kJXRightButton && itsMouseAction == kDuplicateRow) { data->DuplicateRow(cell.y, cell.y+1); } else if (button == kJXLeftButton && itsMouseAction == kMoveRow && cell.y > 1) { data->MoveRow(cell.y, cell.y-1); } else if (button == kJXRightButton && itsMouseAction == kMoveRow && ((JIndex) cell.y) < GetRowCount()) { data->MoveRow(cell.y, cell.y+1); } else if (itsMouseAction == kRemoveRow) { data->RemoveRow(cell.y); } // column manipulations else if (button == kJXLeftButton && itsMouseAction == kInsertCol) { data->InsertCols(cell.x, 1); } else if (button == kJXRightButton && itsMouseAction == kInsertCol) { data->InsertCols(cell.x+1, 1); } else if (button == kJXLeftButton && itsMouseAction == kDuplicateCol) { data->DuplicateCol(cell.x, cell.x); } else if (button == kJXRightButton && itsMouseAction == kDuplicateCol) { data->DuplicateCol(cell.x, cell.x+1); } else if (button == kJXLeftButton && itsMouseAction == kMoveCol && cell.x > 1) { data->MoveCol(cell.x, cell.x-1); } else if (button == kJXRightButton && itsMouseAction == kMoveCol && ((JIndex) cell.x) < GetColCount()) { data->MoveCol(cell.x, cell.x+1); } else if (itsMouseAction == kRemoveCol) { data->RemoveCol(cell.x); } }
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 TestWidget::DrawStuff ( JPainter& p ) { JIndex i; JXColormap* colormap = GetColormap(); p.SetPenColor(colormap->GetGreenColor()); JRect ellipseRect(100,50,150,300); p.Ellipse(ellipseRect); p.SetPenColor(colormap->GetBlackColor()); if (itsFillFlag) { p.SetFilling(kJTrue); } JRect ap = GetAperture(); p.Line(ap.topLeft(), ap.bottomRight()); p.Line(ap.topRight(), ap.bottomLeft()); p.SetLineWidth(2); p.SetFontName("Times"); p.SetFontSize(18); p.Image(*itsHomeImage, itsHomeImage->GetBounds(), itsHomeRect); its2Rect = JRect(150, 5, 200, 30); p.SetPenColor(colormap->GetRedColor()); p.Rect(its2Rect); p.SetFontStyle(colormap->GetRedColor()); p.String(its2Rect.topLeft(), "2", its2Rect.width(), JPainter::kHAlignCenter, its2Rect.height(), JPainter::kVAlignCenter); its3Rect = JRect(10, 150, 40, 200); p.SetPenColor(colormap->GetBlueColor()); p.Rect(its3Rect); p.SetFontStyle(colormap->GetBlueColor()); p.String(its3Rect.topLeft(), "3", its3Rect.width(), JPainter::kHAlignCenter, its3Rect.height(), JPainter::kVAlignCenter); p.SetLineWidth(1); p.SetFont(GetFontManager()->GetDefaultFont()); p.ShiftOrigin(10,10); p.Point(0,0); for (i=1; i<=itsRandPointCount; i++) { p.Point(itsRNG.UniformLong(0,200), itsRNG.UniformLong(0,200)); } p.SetPenColor(colormap->GetRedColor()); p.Line(10,0, 0,10); p.SetPenColor(colormap->GetGreenColor()); p.LineTo(10,20); p.SetPenColor(colormap->GetBlueColor()); p.LineTo(0,30); p.ShiftOrigin(2,0); JPoint textPt(40,30); p.String( 0.0, textPt, "Hello"); p.String( 90.0, textPt, "Hello"); p.String(180.0, textPt, "Hello"); p.String(270.0, textPt, "Hello"); p.ShiftOrigin(-2, 0); p.SetPenColor(colormap->GetBlueColor()); JRect r(70, 290, 150, 390); p.Rect(r); /* for (JCoordinate y=70; y<150; y++) { p.SetPenColor(colormap->GetGrayColor(y-50)); p.Line(290,y, 390,y); } for (JCoordinate x=290; x<390; x++) { p.SetPenColor(colormap->GetGrayColor(x-290)); p.Line(x,70, x,150); } p.SetLineWidth(2); for (JCoordinate y=70; y<150; y+=2) { p.SetPenColor(colormap->GetGrayColor(y%4 ? 40 : 60)); p.Line(290,y, 390,y); } p.SetLineWidth(1); p.SetLineWidth(2); for (JCoordinate x=290; x<390; x+=2) { p.SetPenColor(colormap->GetGrayColor(x%4 ? 40 : 60)); p.Line(x,70, x,150); } p.SetLineWidth(1); */ p.String( 0.0, r, "Hello", JPainter::kHAlignCenter, JPainter::kVAlignCenter); p.String( 90.0, r, "Hello", JPainter::kHAlignCenter, JPainter::kVAlignCenter); p.String(180.0, r, "Hello", JPainter::kHAlignCenter, JPainter::kVAlignCenter); p.String(270.0, r, "Hello", JPainter::kHAlignCenter, JPainter::kVAlignCenter); p.String( 0.0, r, "Hello", JPainter::kHAlignRight, JPainter::kVAlignBottom); p.String( 90.0, r, "Hello", JPainter::kHAlignRight, JPainter::kVAlignBottom); p.String(180.0, r, "Hello", JPainter::kHAlignRight, JPainter::kVAlignBottom); p.String(270.0, r, "Hello", JPainter::kHAlignRight, JPainter::kVAlignBottom); p.SetPenColor(colormap->GetBlueColor()); p.Rect(200, 10, 100, 50); p.String(200, 10, "Hello", 100, JPainter::kHAlignLeft); p.String(200, 10+p.GetLineHeight(), "Hello", 100, JPainter::kHAlignCenter); p.String(200, 10+2*p.GetLineHeight(), "Hello", 100, JPainter::kHAlignRight); p.SetPenColor(colormap->GetDarkGreenColor()); p.SetFilling(kJTrue); p.Rect(290, 160, 100, 80); p.SetFilling(kJFalse); /* for (JCoordinate y=160; y<240; y++) { p.SetPenColor(colormap->GetGrayColor(y-140)); p.Line(290,y, 390,y); } for (JCoordinate x=290; x<390; x++) { p.SetPenColor(colormap->GetGrayColor(x-290)); p.Line(x,160, x,240); } p.SetLineWidth(2); for (JCoordinate y=160; y<240; y+=2) { p.SetPenColor(colormap->GetGrayColor(y%4 ? 40 : 60)); p.Line(290,y, 390,y); } p.SetLineWidth(1); p.SetLineWidth(2); for (JCoordinate x=290; x<390; x+=2) { p.SetPenColor(colormap->GetGrayColor(x%4 ? 40 : 60)); p.Line(x,160, x,240); } p.SetLineWidth(1); */ textPt.Set(340, 200); p.SetFontName("Times"); p.SetFontStyle(colormap->GetBlueColor()); p.String( 0.0, textPt, "Hello"); p.String( 90.0, textPt, "Hello"); p.SetFontStyle(colormap->GetYellowColor()); p.String(180.0, textPt, "Hello"); p.String(270.0, textPt, "Hello"); p.SetPenColor(colormap->GetYellowColor()); r.Set(0,11,80,91); p.Rect(r); r.Shrink(1,1); p.SetPenColor(colormap->GetBlueColor()); p.Ellipse(r); r.Shrink(1,1); p.SetPenColor(colormap->GetRedColor()); p.Arc(r, 270.0-45.0, -270.0); JPolygon poly; poly.AppendElement(JPoint(0,85)); poly.AppendElement(JPoint(10,85)); poly.AppendElement(JPoint(5,95)); p.Polygon(poly); p.Line(0,100, 2,98); p.LineTo(4,100); p.LineTo(2,102); p.LineTo(0,100); poly.SetElement(1, JPoint(0,5)); poly.SetElement(2, JPoint(2,0)); poly.SetElement(3, JPoint(4,5)); p.Polygon(2,105, poly); // test filling rule p.SetPenColor(colormap->GetRedColor()); p.SetFilling(kJTrue); JPolygon fillRulePoly; fillRulePoly.AppendElement(JPoint(175,45)); fillRulePoly.AppendElement(JPoint(165,65)); fillRulePoly.AppendElement(JPoint(190,50)); fillRulePoly.AppendElement(JPoint(160,50)); fillRulePoly.AppendElement(JPoint(185,65)); p.Polygon(fillRulePoly); p.SetFilling(kJFalse); // dashed lines p.DrawDashedLines(kJTrue); p.SetPenColor(colormap->GetBlackColor()); JArray<JSize> dashList; // pixel rulers dashList.AppendElement(1); dashList.AppendElement(1); p.SetDashList(dashList); p.Line(100,110, 200,110); p.Line(100,114, 200,114); p.Line(100,118, 200,118); dashList.SetElement(1, 2); // simple pattern dashList.SetElement(2, 3); p.SetDashList(dashList); p.Line(100,112, 200,112); p.SetFontStyle(JFontStyle(kJFalse, kJFalse, 1, kJFalse)); p.String(130,155, "underline without dashes"); p.SetDashList(dashList, 3); // test offset p.Line(100,116, 200,116); dashList.SetElement(1, 1); // example with odd # of values from X manuals dashList.SetElement(2, 2); dashList.AppendElement(3); p.SetDashList(dashList); p.Line(100,120, 200,120); dashList.SetElement(1, 5); // dash-dot pattern dashList.SetElement(2, 2); dashList.SetElement(3, 1); dashList.AppendElement(2); p.SetDashList(dashList); p.Line(100,122, 200,122); p.Ellipse(210,110, 20,20); p.DrawDashedLines(kJFalse); p.Ellipse(213,113, 14,14); p.Rect(207,107, 26,26); p.SetPenColor(colormap->GetYellowColor()); p.DrawDashedLines(kJTrue); p.Ellipse(213,113, 14,14); // icons p.Image(*itsXPMImage, itsXPMImage->GetBounds(), 33,110); p.Image(*itsPartialXPMImage, itsXPMImage->GetBounds(), 50,121); }