예제 #1
0
파일: scroll.cpp 프로젝트: edeproject/efltk
int main(int argc, char** argv) {
  Fl_Window window(5*75,400);
  window.box(FL_NO_BOX);
  Fl_Scroll scroll(0,0,5*75,300);

  Fl_Group g(0, 0, 5*75, 8*25);
  int n = 0;
  for (int y=0; y<16; y++) for (int x=0; x<5; x++) {
    char buf[20]; sprintf(buf,"%d",n++);
    if (y==8 && x==0) g.end();
    Fl_Button* b = new Fl_Button(x*75,y*25+(y>=8?5*75:0),75,25,strdup(buf));
    b->color(n);
    b->selection_color(n);
    b->label_color(FL_WHITE);
    b->selection_text_color(FL_WHITE);
  }
  g.end();
  Drawing drawing(0,8*25,5*75,5*75,0);
  scroll.end();
  window.resizable(scroll);

  Fl_Box box(0,300,5*75,window.h()-300); // gray area below the scroll
  box.box(FL_FLAT_BOX);

  Fl_Toggle_Button but1(150, 310, 200, 25, "box");
  but1.set();
  but1.callback(box_cb);
  
  Fl_Choice choice(150, 335, 200, 25, "type():");
  choice.menu(choices);
  choice.value(3);

  Fl_Choice achoice(150, 360, 200, 25, "scrollbar_align():");
  achoice.menu(align_choices);
  achoice.value(3);

  thescroll = &scroll;

  //scroll.box(FL_DOWN_BOX);
  //scroll.type(Fl_Scroll::VERTICAL);
  window.end();
  window.show(argc,argv);
  return Fl::run();
}
예제 #2
0
void OpenSGViewer::initScene(void)
{
   vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL) << "OpenSGViewer::initScene: Called.\n" << vprDEBUG_FLUSH;
   
   // --- Initialize vrj devices --- //
   std::string wand("VJWand");
   std::string but0("VJButton0");
   std::string but1("VJButton1");
   std::string but2("VJButton2");
   mWandPos.init(wand);
   mButton0.init(but0);
   mButton1.init(but1);
   mButton2.init(but2);

   // Load the model to use
   if (mFileToLoad ==  std::string("none"))
   {
      std::cout << "OpenSGViewere::initScene: No model specified!!! Loading torus.\n";
      mWorldRoot = OSG::makeTorus(.5, 2, 16, 16);      
   }
   else
   {
      std::cout << "OpenSGViewer::initScene: Loading [" << mFileToLoad.c_str() << "]\n";
      mWorldRoot = OSG::SceneFileHandler::the().read((OSG::Char8 *)(mFileToLoad.c_str()));
   }

   mSelectableNodes.push_back(mWorldRoot);

   // --- Light setup --- //
   // - Add directional light for scene
   // - Create a beacon for it and connect to that beacon
   mLightNode   = OSG::Node::create();
   mLightBeacon = OSG::Node::create();
   OSG::DirectionalLightPtr light_core = OSG::DirectionalLight::create();
   OSG::TransformPtr light_beacon_core = OSG::Transform::create();
   
   // Setup light beacon
   OSG::Matrix light_pos;
   light_pos.setTransform(OSG::Vec3f( 2.0f, 5.0f, 4.0f));
   
   OSG::beginEditCP(light_beacon_core, OSG::Transform::MatrixFieldMask);
      light_beacon_core->setMatrix(light_pos);
   OSG::endEditCP(light_beacon_core, OSG::Transform::MatrixFieldMask);
   
   OSG::beginEditCP(mLightBeacon);
      mLightBeacon->setCore(light_beacon_core);
   OSG::endEditCP(mLightBeacon);
   
   // Setup light node
   OSG::addRefCP(mLightNode);
   OSG::beginEditCP(mLightNode);
      mLightNode->setCore(light_core);
      mLightNode->addChild(mLightBeacon);
   OSG::endEditCP(mLightNode);
   
   OSG::beginEditCP(light_core);
      light_core->setAmbient   (.9, .8, .8, 1);
      light_core->setDiffuse   ( 0.6,  0.6,  0.6, 1);
      light_core->setSpecular  ( 1,  1,  1, 1);
      light_core->setDirection ( 0,  0,  1);
      light_core->setBeacon    (mLightNode);
   OSG::endEditCP(light_core);
   
   // --- Setup Scene -- //
   // add the loaded scene to the light node, so that it is lit by the light
   OSG::addRefCP(mWorldRoot);
   OSG::beginEditCP(mLightNode);
      mLightNode->addChild(mWorldRoot);
   OSG::endEditCP(mLightNode);
   
   // create the root.
   mSceneRoot = OSG::Node::create();
   mSceneTransform = OSG::Transform::create();
   
   OSG::beginEditCP(mSceneRoot);
      mSceneRoot->setCore(mSceneTransform);
      mSceneRoot->addChild(mLightNode);
   OSG::endEditCP(mSceneRoot);
   
   // --- Add scene to root node --- //
   vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL) << "OpenSGViewer::initScene finished\n" << vprDEBUG_FLUSH;
}