const JCharacter* JXMenu::GetDefaultFont ( JSize* size ) { if (!theDefaultMenuFontInitFlag) { theDefaultMenuFontInitFlag = kJTrue; theDefaultFontName = JGetDefaultFontName(); theDefaultFontSize = kJDefaultFontSize; JString fileName; if (JExpandHomeDirShortcut(kMenuFontFileName, &fileName)) { ifstream input(fileName); input >> ws; JString name = JReadLine(input); name.TrimWhitespace(); JSize size; input >> size; if (input.good()) { theDefaultFontName = name; theDefaultFontSize = size; } }
JXTextCheckbox::JXTextCheckbox ( const JCharacter* label, JXContainer* enclosure, const HSizingOption hSizing, const VSizingOption vSizing, const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h ) : JXCheckbox(enclosure, hSizing, vSizing, x,y, w,h), itsLabel(label), itsFontName(JGetDefaultFontName()) { itsShortcuts = NULL; itsULIndex = 0; itsFontSize = kJDefaultFontSize; // itsFontStyle already initialized to correct default JXColormap* colormap = GetColormap(); itsNormalColor = colormap->GetDefaultBackColor(); itsPushedColor = colormap->GetDefaultSelButtonColor(); itsTrueLabelColor = itsFontStyle.color; if (!IsActive()) { itsFontStyle.color = colormap->GetInactiveLabelColor(); } }
void GPMListHeaderWidget::TableDrawCell ( JPainter& p, const JPoint& cell, const JRect& rect ) { JXDrawUpFrame(p, rect, kJXDefaultBorderWidth); JString str; if (!GetColTitle(cell.x, &str)) { str = JString(cell.x, JString::kBase10); } JSize underLines = 0; if (itsList->ListColIsSelected(cell.x)) { underLines = 1; } p.SetFont(JGetDefaultFontName(), kJDefaultRowColHeaderFontSize, JFontStyle(kJTrue, kJFalse, underLines, kJFalse, (p.GetColormap())->GetBlackColor())); p.String(rect, str, JPainter::kHAlignCenter, JPainter::kVAlignCenter); }
void JXColHeaderWidget::TableDrawCell ( JPainter& p, const JPoint& cell, const JRect& rect ) { JXDrawUpFrame(p, rect, kCellFrameWidth); JString str; JBoolean hasTitle = kJFalse; if (itsTitles != NULL) { const JString* title = itsTitles->NthElement(cell.x); if (title != NULL) { str = *title; hasTitle = kJTrue; } } if (!hasTitle) { str = JString(cell.x, 0); } p.SetFont(JGetDefaultFontName(), kFontSize, JFontStyle(kJTrue, kJFalse, 0, kJFalse, (p.GetColormap())->GetBlackColor())); p.String(rect, str, JPainter::kHAlignCenter, JPainter::kVAlignCenter); }
TestFloatTable::TestFloatTable ( JFloatTableData* data, JXMenuBar* menuBar, JXScrollbarSet* scrollbarSet, JXContainer* enclosure, const HSizingOption hSizing, const VSizingOption vSizing, const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h ) : JXFloatTable(data, 4, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h) { JIndex i,j; itsMouseAction = kInsertCol; (GetEditMenuHandler())->AppendEditMenu(menuBar); itsTableMenu = menuBar->AppendTextMenu(kTableMenuTitleStr); itsTableMenu->SetMenuItems(kTableMenuStr); itsTableMenu->SetUpdateAction(JXMenu::kDisableNone); ListenTo(itsTableMenu); itsSizeMenu = new JXFontSizeMenu(JGetDefaultFontName(), "Size", menuBar, kFixedLeft, kFixedTop, 0,0, 10,10); assert( itsSizeMenu != NULL ); menuBar->AppendMenu(itsSizeMenu); ListenTo(itsSizeMenu); itsStyleMenu = new JXStyleTableMenu(this, menuBar, kFixedLeft, kFixedTop, 0,0, 10,10); assert( itsStyleMenu != NULL ); menuBar->AppendMenu(itsStyleMenu); JSize fontSize; const JString& fontName = GetFont(&fontSize); itsSizeMenu->SetFontName(fontName); itsSizeMenu->SetFontSize(fontSize); data->AppendRows(kInitRowCount); data->AppendCols(kInitColCount); JKLRand r; for (j=1; j<=kInitColCount; j++) { for (i=1; i<=kInitRowCount; i++) { data->SetElement(i,j, r.UniformClosedProb()); } } }
void CBSymbolTable::TableDrawCell ( JPainter& p, const JPoint& cell, const JRect& rect ) { HilightIfSelected(p, cell, rect); const JIndex symbolIndex = CellToSymbolIndex(cell); CBLanguage lang; CBSymbolList::Type type; const JString& symbolName = itsSymbolList->GetSymbol(symbolIndex, &lang, &type); const JString* signature; itsSymbolList->GetSignature(symbolIndex, &signature); if (CalcColWidths(symbolName, signature)) { AdjustColWidths(); } const JXImage* icon = NULL; const JFontStyle& style = (CBGetSymbolTypeList())->GetStyle(type, &icon); // draw icon if (icon != NULL) { JRect r = rect; r.right = r.left + kIconWidth; p.Image(*icon, icon->GetBounds(), r); } // draw name p.SetFontStyle(style); JRect r = rect; r.left += kIconWidth + kHMarginWidth; p.String(r, symbolName, JPainter::kHAlignLeft, JPainter::kVAlignCenter); if (signature != NULL) { r.left += (GetFontManager())->GetStringWidth( JGetDefaultFontName(), kJDefaultFontSize, JFontStyle(), symbolName); p.String(r, *signature, JPainter::kHAlignLeft, JPainter::kVAlignCenter); } }
JBoolean JXStringCompletionMenu::AddString ( const JCharacter* str ) { const JIndex i = GetItemCount()+1; if (i <= kMaxItemCount) { if (IsEmpty()) { JFontID id; JSize size; JFontStyle style; itsTE->GetDefaultFont(&id, &size, &style); SetDefaultFont(id, size, style, kJFalse); } JString shortcut; if (i <= 10) { shortcut = JString(i%10, JString::kBase10); } else if (i <= 36) { shortcut = " "; shortcut.SetCharacter(1, 'a' + i - 11); } JString s = kItemPrefixStr; s += str; if (!shortcut.IsEmpty()) { s.SetCharacter(1, shortcut.GetFirstCharacter()); s.SetCharacter(3, '-'); } AppendItem(s, kPlainType, shortcut); return kJTrue; } else if (i == kMaxItemCount+1) { AppendItem(kTruncationStr); SetItemFont(i, JGetDefaultFontName(), kJDefaultFontSize, JFontStyle(kJFalse, kJTrue, 0, kJFalse)); return kJFalse; } else { return kJFalse; } }
GMAccountList::GMAccountList ( GMAccountDialog* dialog, JPtrArray<GMAccount>* accounts, 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), itsDialog(dialog), itsAccountInfo(accounts) { itsMinColWidth = 1; JXColormap* colormap = GetColormap(); const JColorIndex blackColor = colormap->GetBlackColor(); SetRowBorderInfo(0, blackColor); SetColBorderInfo(0, blackColor); const JSize fontHeight = (GetFontManager())->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()); const JCoordinate rowHeight = fontHeight + 2*kVMarginWidth; SetDefaultRowHeight(rowHeight); SetAllRowHeights(rowHeight); itsLineHeight = GetFontManager()->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()) + 2 * kVMarginWidth; ListenTo(itsAccountInfo); }
JXTabGroup::JXTabGroup ( JXContainer* enclosure, const HSizingOption hSizing, const VSizingOption vSizing, const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h ) : JXWidget(enclosure, hSizing, vSizing, x,y, w,h), itsEdge(kTop), itsFontName(JGetDefaultFontName()), itsFontSize(kJDefaultFontSize), itsCanScrollUpFlag(kJFalse), itsCanScrollDownFlag(kJFalse), itsFirstDrawIndex(1), itsLastDrawIndex(1), itsContextMenu(NULL), itsPrevTabIndex(0), itsDragAction(kInvalidClick), itsScrollUpPushedFlag(kJFalse), itsScrollDownPushedFlag(kJFalse), itsMouseIndex(0), itsClosePushedFlag(kJFalse) { itsTitles = new JPtrArray<JString>(JPtrArrayT::kDeleteAll); assert( itsTitles != NULL ); itsTabInfoList = new JArray<TabInfo>; assert( itsTabInfoList != NULL ); itsCloseImage = new JXImage(GetDisplay(), jx_tab_close); assert( itsCloseImage != NULL ); itsClosePushedImage = new JXImage(GetDisplay(), jx_tab_close_pushed); assert( itsClosePushedImage != NULL ); itsTabRects = new JArray<JRect>; assert( itsTabRects != NULL ); itsCardFile = new JXCardFile(this, kHElastic, kVElastic, 0,0, 100,100); assert( itsCardFile != NULL ); PlaceCardFile(); }
GLFitParameterTable::GLFitParameterTable ( 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), itsHasStartValues(kJTrue), itsColHeaderWidget(NULL) { itsMinColWidth = 1; const JFontManager* fontMgr = GetFontManager(); const JSize rowHeight = 2*kVMarginWidth + fontMgr->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()); SetDefaultRowHeight(rowHeight); itsNameList = new JPtrArray<JString>(JPtrArrayT::kDeleteAll); assert(itsNameList != NULL); itsStartValues = new JArray<JFloat>; assert(itsStartValues != NULL); itsFitValues = new JArray<JFloat>; assert(itsFitValues != NULL); itsErrorValues = new JArray<JFloat>; assert(itsErrorValues != NULL); AppendCols(4, kDefColWidth); AdjustColWidth(); JXColormap* colormap = GetColormap(); // SetRowBorderInfo(0, colormap->GetBlackColor()); // SetColBorderInfo(0, colormap->GetBlackColor()); }
CBSymbolTable::CBSymbolTable ( CBSymbolDirector* symbolDirector, CBSymbolList* symbolList, JXScrollbarSet* scrollbarSet, JXContainer* enclosure, const HSizingOption hSizing, const VSizingOption vSizing, const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h ) : JXTable(10, 10, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h) { itsSymbolDirector = symbolDirector; itsSymbolList = symbolList; itsMaxStringWidth = 0; itsVisibleList = new JArray<JIndex>(CBSymbolList::kBlockSize); assert( itsVisibleList != NULL ); itsVisibleListLockedFlag = kJFalse; itsNameFilter = NULL; itsNameLiteral = NULL; const JIndex blackColor = (GetColormap())->GetBlackColor(); SetRowBorderInfo(0, blackColor); SetColBorderInfo(0, blackColor); AppendCols(1); SetDefaultRowHeight((GetFontManager())-> GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()) + 2*kVMarginWidth); SetSelectionBehavior(kJTrue, kJTrue); ListenTo(itsSymbolList); ListenTo(CBGetSymbolTypeList()); }
void GMAccountList::TableDrawCell ( JPainter& p, const JPoint& cell, const JRect& rect ) { HilightIfSelected(p, cell, rect); JFontStyle fontstyle; if (itsDialog->GetDefaultIndex() == (JIndex)cell.y) { fontstyle.bold = kJTrue; } p.SetFont(JGetDefaultFontName(), kJDefaultFontSize, fontstyle); JString str = itsAccountInfo->NthElement(cell.y)->GetNickname(); // check that column is wide enough const JCoordinate w = p.GetStringWidth(str) + 2*kHMarginWidth; if (w > GetColWidth(1)) { itsMinColWidth = w; } // draw string JRect r = rect; r.left += kHMarginWidth; p.String(r, str, JPainter::kHAlignLeft, JPainter::kVAlignCenter); if (cell.y == JCoordinate(itsAccountInfo->GetElementCount())) { AdjustColWidth(); } }
void GMFilterNameTable::GMFilterNameTableX() { AppendCols(1, kDefColWidth); AdjustColWidths(); const JFontManager* fm = GetFontManager(); itsRowHeight = fm->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()) + kRowHeightAdjust; const JSize count = itsFilters->GetElementCount(); AppendRows(count, itsRowHeight); AdjustButtons(); WantInput(kJFalse); ListenTo(itsNewButton); ListenTo(itsRemoveButton); const Atom dndName = GetDNDManager()->GetDNDSelectionName(); GetDisplay()->RegisterXAtom(kDragFilterXAtomName); }
void JXRowHeaderWidget::TableDrawCell ( JPainter& p, const JPoint& cell, const JRect& rect ) { JXDrawUpFrame(p, rect, kCellFrameWidth); JString str; JBoolean hasTitle = kJFalse; if (itsTitles != NULL) { const JString* title = itsTitles->NthElement(cell.y); if (title != NULL) { str = *title; hasTitle = kJTrue; } } if (!hasTitle) { str = JString(cell.y, JString::kBase10); } p.SetFont(JGetDefaultFontName(), kJDefaultRowColHeaderFontSize, JFontStyle(kJTrue, kJFalse, 0, kJFalse, (p.GetColormap())->GetBlackColor())); p.String(rect, str, JPainter::kHAlignCenter, JPainter::kVAlignCenter); const JCoordinate wmin = p.GetStringWidth(str) + 2*itsHMarginWidth; if (rect.width() < wmin && itsMaxBcastWidth < wmin) { Broadcast(NeedsToBeWidened(wmin - itsMaxBcastWidth)); itsMaxBcastWidth = wmin; } }
XFontStruct* #endif JXFontManager::ApproximateFont ( const JCharacter* origName, const JCharacter* origCharSet, const JSize origSize, const JFontStyle& origStyle ) const { JString name = origName; JString charSet = origCharSet; JSize size = origSize; JFontStyle style = origStyle; #ifdef _J_USE_XFT XftFont* xfont = NULL; #else XFontStruct* xfont = NULL; #endif while (xfont == NULL) { if (size % 2 == 1) { size--; // even sizes are more common } else if (size < 12) { size += 2; } else if (size > 12) { size -= 2; } else if (style.bold) { style.bold = kJFalse; size = origSize; } else if (style.italic) { style.italic = kJFalse; size = origSize; } else if (name != JGetDefaultFontName()) { name = JGetDefaultFontName(); size = origSize; style = origStyle; } else if (!charSet.IsEmpty()) { charSet.Clear(); name = origName; size = origSize; style = origStyle; } else { // this should never happen, but it does with some Win95 X servers cerr << "The X server does not have any PostScript fonts at all, not even "; cerr << JGetDefaultFontName() << endl; JXApplication::Abort(JXDocumentManager::kServerDead, kJFalse); } xfont = GetNewFont(name, charSet, size, style); } return xfont; }
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(JXGetTimesFontName()); 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(JGetDefaultFontName(), kJXDefaultFontSize, colormap->GetBlackColor()); 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.Rect(310, 70, 80, 80); p.String( 0.0, 310, 70, "Hello", 80, JPainter::kHAlignCenter, 80, JPainter::kVAlignCenter); p.String( 90.0, 310,150, "Hello", 80, JPainter::kHAlignCenter, 80, JPainter::kVAlignCenter); p.String(180.0, 390,150, "Hello", 80, JPainter::kHAlignCenter, 80, JPainter::kVAlignCenter); p.String(270.0, 390, 70, "Hello", 80, JPainter::kHAlignCenter, 80, JPainter::kVAlignCenter); 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->GetYellowColor()); JRect r(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); // animated colors p.SetFilling(kJTrue); JCoordinate x = 25; const JSize animColorCount = itsAnimColorList->GetElementCount(); for (i=1; i<=animColorCount; i++) { p.SetPenColor(itsAnimColorList->GetElement(i)); p.Rect(x, 150, 10, 10); x += 10; } // icons p.Image(*itsXPMImage, itsXPMImage->GetBounds(), 33,110); p.Image(*itsPartialXPMImage, itsXPMImage->GetBounds(), 50,121); // *NEVER* do this in your code! I do it here ONLY to test JXColormap. // (Besides, look at how messy it is!) unsigned long xPixel; if (colormap->CalcPreallocatedXPixel(62720, 56832, 45824, &xPixel)) { JXDisplay* display = GetDisplay(); Display* xdisplay = display->GetXDisplay(); GC gc = DefaultGC(xdisplay, display->GetScreen()); XSetForeground(xdisplay, gc, xPixel); XFillRectangle(xdisplay, (GetWindow())->GetXWindow(), gc, 110,40, 20,20); } }
JXFSBindingTable::JXFSBindingTable ( JFSBindingList* list, JXTextButton* addButton, JXTextButton* removeButton, JXTextButton* duplicateButton, JXScrollbarSet* scrollbarSet, JXContainer* enclosure, const HSizingOption hSizing, const VSizingOption vSizing, const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h ) : JXEditTable(1,1, scrollbarSet, enclosure, hSizing, vSizing, x, y, w, h), itsBindingList(list), itsAddButton(addButton), itsRemoveButton(removeButton), itsDuplicateButton(duplicateButton), itsTextInput(NULL) { // row height const JSize rowHeight = 2*kVMarginWidth + JMax( (GetFontManager())->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()), (GetFontManager())->GetLineHeight(JGetMonospaceFontName(), kJDefaultMonoFontSize, JFontStyle())); SetDefaultRowHeight(rowHeight); // buttons ListenTo(itsAddButton); ListenTo(itsRemoveButton); ListenTo(itsDuplicateButton); // type menu itsTypeMenu = new JXTextMenu("", this, kFixedLeft, kFixedTop, 0,0, 10,10); assert( itsTypeMenu != NULL ); itsTypeMenu->Hide(); itsTypeMenu->SetToHiddenPopupMenu(kJTrue); itsTypeMenu->SetMenuItems(kTypeMenuStr); itsTypeMenu->SetUpdateAction(JXMenu::kDisableNone); ListenTo(itsTypeMenu); // regex for testing itsTestRegex = new JRegex; assert( itsTestRegex != NULL ); // data for (JIndex i=1; i<=kColCount; i++) { AppendCols(1, kInitColWidth[i-1]); } UpdateColWidths(); const JSize rowCount = itsBindingList->GetElementCount(); AppendRows(rowCount); UpdateButtons(); ListenTo(&(GetTableSelection())); }
CBCommandTable::CBCommandTable ( const CBCommandManager::CmdList& cmdList, JXTextButton* addCmdButton, JXTextButton* removeCmdButton, JXTextButton* duplicateCmdButton, JXScrollbarSet* scrollbarSet, JXContainer* enclosure, const HSizingOption hSizing, const VSizingOption vSizing, const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h ) : JXEditTable(1,1, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h) { itsTextInput = NULL; itsDNDRowIndex = 0; itsCommandXAtom = (GetDisplay())->RegisterXAtom(CBCommandSelection::GetCommandXAtomName()); // font (CBGetPrefsManager())->GetDefaultFont(&itsFontName, &itsFontSize); const JSize rowHeight = 2*kVMarginWidth + JMax( (GetFontManager())->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()), (GetFontManager())->GetLineHeight(itsFontName, itsFontSize, JFontStyle())); SetDefaultRowHeight(rowHeight); // buttons itsAddCmdButton = addCmdButton; itsRemoveCmdButton = removeCmdButton; itsDuplicateCmdButton = duplicateCmdButton; ListenTo(itsAddCmdButton); ListenTo(itsRemoveCmdButton); ListenTo(itsDuplicateCmdButton); // type menu itsOptionsMenu = new JXTextMenu("", this, kFixedLeft, kFixedTop, 0,0, 10,10); assert( itsOptionsMenu != NULL ); itsOptionsMenu->SetToHiddenPopupMenu(); itsOptionsMenu->SetMenuItems(kOptionsMenuStr); itsOptionsMenu->SetUpdateAction(JXMenu::kDisableNone); ListenTo(itsOptionsMenu); // base path CBProjectDocument* doc = NULL; if ((CBGetDocumentManager())->GetActiveProjectDocument(&doc)) { itsBasePath = doc->GetFilePath(); } // data itsCmdList = new CBCommandManager::CmdList(cmdList); assert( itsCmdList != NULL ); FinishCmdListCopy(itsCmdList); for (JIndex i=1; i<=kColCount; i++) { AppendCols(1, kInitColWidth[i-1]); } AppendRows(itsCmdList->GetElementCount()); UpdateButtons(); ListenTo(&(GetTableSelection())); }
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(JGetDefaultFontName(), kJDefaultFontSize, colormap->GetBlackColor()); 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); }