void CBEditTextPrefsDialog::SetReverseVideoColors() { JXColormap* cmap = GetColormap(); ChangeColor(CBPrefsManager::kTextColorIndex, cmap->GetWhiteColor()); ChangeColor(CBPrefsManager::kBackColorIndex, cmap->GetBlackColor()); ChangeColor(CBPrefsManager::kCaretColorIndex, cmap->GetWhiteColor()); ChangeColor(CBPrefsManager::kSelColorIndex, cmap->GetBlueColor()); ChangeColor(CBPrefsManager::kSelLineColorIndex, cmap->GetCyanColor()); ChangeColor(CBPrefsManager::kRightMarginColorIndex, cmap->GetGrayColor(80)); }
void CBEditTextPrefsDialog::SetDefaultColors() { JXColormap* cmap = GetColormap(); ChangeColor(CBPrefsManager::kTextColorIndex, cmap->GetBlackColor()); ChangeColor(CBPrefsManager::kBackColorIndex, cmap->GetWhiteColor()); ChangeColor(CBPrefsManager::kCaretColorIndex, cmap->GetRedColor()); ChangeColor(CBPrefsManager::kSelColorIndex, cmap->GetDefaultSelectionColor()); ChangeColor(CBPrefsManager::kSelLineColorIndex, cmap->GetBlueColor()); ChangeColor(CBPrefsManager::kRightMarginColorIndex, cmap->GetGrayColor(70)); }
ClipboardWidget::ClipboardWidget ( const JCharacter* text, JXMenuBar* menuBar, 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), itsText(text) { // Set the background color. JXColormap* cmap = GetColormap(); SetBackColor(cmap->GetWhiteColor()); // Create the menu and attach it to the menu bar. itsEditMenu = menuBar->AppendTextMenu(kEditMenuTitleStr); // Set the menu items. itsEditMenu->SetMenuItems(kEditMenuStr); // The menu items don't need to be disabled itsEditMenu->SetUpdateAction(JXMenu::kDisableNone); // Listen for messages from the menu. ListenTo(itsEditMenu); // Register the data types that we support. The atoms that we need // here, namely text atoms, are already defined, so we don't need to // define them again. If we had a special selection type we would use // GetDisplay()->RegisterXAtom(OurAtomString) to register it. }
void TestDirector::BuildIconMenus ( JXWindow* window, JXMenuBar* menuBar ) { JIndex i; // create icons JXDisplay* display = window->GetDisplay(); JXColormap* colormap = window->GetColormap(); const JColorIndex kSmileyColor[] = { colormap->GetWhiteColor(), colormap->GetRedColor(), colormap->GetBlueColor(), colormap->GetBlackColor() }; JXImage* image[kSmileyBitmapCount]; for (i=0; i<kSmileyBitmapCount; i++) { image[i] = new JXImage(display, kSmileyBitmap[i], kSmileyColor[i]); assert( image[i] != NULL ); } // create 1x6 menu in menu bar -- this owns the icons itsSmileyMenu = new JXImageMenu(kIconMenuTitleStr, 6, menuBar, JXWidget::kFixedLeft, JXWidget::kVElastic, 0,0, 10,10); assert( itsSmileyMenu != NULL ); itsSmileyMenu->SetUpdateAction(JXMenu::kDisableNone); menuBar->AppendMenu(itsSmileyMenu); for (i=0; i<kSmileyBitmapCount; i++) { itsSmileyMenu->AppendItem(image[i], kJTrue); } // create 2x2 submenu of radio buttons itsIconMenu = new JXImageMenu(2, itsSmileyMenu, 2, menuBar); assert( itsIconMenu != NULL ); itsIconMenu->SetUpdateAction(JXMenu::kDisableNone); for (i=0; i<kSmileyBitmapCount; i++) { itsIconMenu->AppendItem(image[i], kJFalse, JXMenu::kRadioType); } itsIconMenuItem = 1; ListenTo(itsIconMenu); // create 3x5 submenu that has a few unused cells JXImageMenu* submenu = new JXImageMenu(5, itsSmileyMenu, 4, menuBar); assert( submenu != NULL ); submenu->SetUpdateAction(JXMenu::kDisableNone); for (JIndex j=1; j<=3; j++) { for (i=0; i<kSmileyBitmapCount; i++) { submenu->AppendItem(image[i], kJFalse); } } }
void JXColorWheel::Draw ( JXWindowPainter& p, const JRect& rect ) { JXColormap* colormap = GetColormap(); const JColorIndex black = colormap->GetBlackColor(); const JRect bounds = GetBoundsGlobal(); const JCoordinate max = JMin(bounds.height(), bounds.width() - kSliderWidth - kSliderMargin); const JCoordinate size = max - 2*kWheelMargin - 1; const JCoordinate center = size/2 + kWheelMargin; if (itsImage == NULL || itsImage->GetWidth() != max || itsColor.brightness != itsLastDrawBrightness) { p.SetFilling(kJTrue); p.SetPenColor(black); p.Ellipse(kWheelMargin, kWheelMargin, size, size); p.SetFilling(kJFalse); JRect r = bounds; r.bottom = r.top + max; r.right = r.left + max; jdelete itsImage; itsImage = jnew JXImage(GetDisplay(), p.GetDrawable(), r); assert( itsImage != NULL ); itsLastDrawBrightness = itsColor.brightness; for (JCoordinate x=0; x<max; x++) { const JCoordinate dx = - x + center; for (JCoordinate y=0; y<max; y++) { if (itsImage->GetColor(x,y) == black) { const JCoordinate dy = y - center; const JFloat r = sqrt(dx*dx + dy*dy) / center; const JFloat a = 0.5 + atan2(dy, dx) / (2.0 * kJPi); JHSB color(JRound(a * kJMaxHSBValue), JRound(r * kJMaxHSBValue), itsLastDrawBrightness); itsImage->SetColor(x,y, colormap->JColormap::GetColor(color)); } } } itsImage->ConvertToRemoteStorage(); } p.JPainter::Image(*itsImage, itsImage->GetBounds(), 0,0); const JFloat r = (itsColor.saturation / kJMaxHSBValueF) * size/2; const JFloat a = ((itsColor.hue / kJMaxHSBValueF) - 0.5) * 2.0 * kJPi; const JCoordinate x = center - JRound(r * cos(a)); const JCoordinate y = center + JRound(r * sin(a)); JRect mark(y-kWheelMargin, x-kWheelMargin, y+kWheelMargin+1, x+kWheelMargin+1); p.SetPenColor(colormap->GetWhiteColor()); p.SetFilling(kJTrue); p.JPainter::Rect(mark); p.SetFilling(kJFalse); p.SetPenColor(black); p.JPainter::Rect(mark); }