//> //ColorModel.cpp //Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. #include <oz++/motif/ApplicationView.h> #include <oz++/motif/DC.h> #include <oz++/motif/Color.h> #include <oz++/motif/Pixelmap.h> namespace OZ { class MainView :public ApplicationView { private: SmartPtr<Pixelmap> pixelmap; SmartPtr<DC> back; void draw(Event& event) { DC dc(this); dc.copyArea(pixelmap->get(), 0, 0, 150,150, 20, 20); } public: MainView(Application& applet, const char* name, Args& args) :ApplicationView(applet, name, args) { Display* display = getDisplay(); const int num = 64;//256; const int US = 65535; pixelmap = new Pixelmap(display, num*2, num*2); back = new DC(display, pixelmap->get()); Color color(display); back -> setForeground(color.allocNamedColor("white")); back -> fillRectangle(0, 0, num*2, num*2); for (int r = 0; r<num; r+=2 ) { for(int g = 0; g<num; g+=2) { for(int b = 0; b<num; b+=2) { XColor c; c.red = US-(num-r)*US/num;; c.green = US-(num-g)*US/num; c.blue = US-(num-b)*US/num; back->setForeground(color.allocColor(&c)); back->fillRectangle(b + r, g + r, 2, 2); } } } addEventHandler(ExposureMask, this, (Handler)&MainView::draw, NULL); } ~MainView() { } }; } // int main(int argc, char** argv) { try { const char* appclass = argv[0]; Application applet(appclass, argc, argv); Args args; args.set(XmNgeometry, "300x300"); MainView view(applet, argv[0], args); view.realize(); applet.run(); } catch (Exception& ex) { caught(ex); } return 0; } |