Ejemplo n.º 1
0
RtMainFrame::RtMainFrame(const TGWindow* p) :
    TGMainFrame(p, 800, 600)
{
    // Create canvas
    TRootEmbeddedCanvas* eCanvas = new TRootEmbeddedCanvas("Embedded canvas",this,800,600);
    m_canvas = eCanvas->GetCanvas();
	AddFrame(eCanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,
                                        10, 10, 10, 1));

    // ========================================
    // Tooltip
    m_canvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
                       "RtMainFrame", this, "eventHandler(Int_t,Int_t,Int_t,TObject*)");
    m_tip = new TGToolTip( gClient->GetDefaultRoot(), eCanvas, "", 0 );

    // ========================================
    // Buttons
	TGHorizontalFrame *hframe= new TGHorizontalFrame(this, 200,40);
    // Exit button
    hframe->AddFrame( new TGTextButton(hframe, "&Quit", "gApplication->Terminate()")
					, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
    // Save button
    TGTextButton* buttonPDF = new TGTextButton(hframe, "Save &PDF");
    TQObject::Connect(buttonPDF, "Clicked()",
                     "RtMainFrame", this, "savePDF()" );
    hframe->AddFrame( buttonPDF
                    , new TGLayoutHints(kLHintsCenterX,5,5,3,4));
    AddFrame(hframe,new TGLayoutHints(kLHintsCenterX,2,2,2,2));
    
	// Sets window name and shows the main frame
	SetWindowName("RT-Biplot");
	MapSubwindows();
	Resize(GetDefaultSize());
	MapWindow();
}
Ejemplo n.º 2
0
/*!
@brief コンストラクタ(通常)
@par   関数説明
変数を初期化する。
*/
Window::Window( void )
{
	wd.wcx.cbSize = sizeof( WNDCLASSEX );
	wd.wcx.hIcon = wd.wcx.hIconSm = NULL;
	strcpy_s( CLASSNAME, WBUFLEN, MIKANCLASSNAME );
	//クラスネームの設定
	wd.wcx.lpszClassName = TEXT( MIKANCLASSNAME );//SetClassNameEx( "MikanWindow" );
	//ウィンドウの名前の設定
	SetWindowName( "Window" );//TEXT( __FILE__ )
	//wd.wc.lpszClassName = wd.ClassName;
	//ウィンドウスタイルの設定
	SetWindowStyle( WT_DEFAULT );
	//拡張ウィンドウスタイルの設定
	SetWindowStyleExDirect( NULL );
	//ウィンドウを標準の位置に設定
	SetPositionXY( 0, 0 );//CW_USEDEFAULT, CW_USEDEFAULT );
	//ウィンドウサイズを640*480に設定
	//  SetWindowSize( WF_WIDTH  + GetSystemMetrics(SM_CXEDGE) + GetSystemMetrics(SM_CXBORDER) + GetSystemMetrics(SM_CXDLGFRAME),
	//                 WF_HEIGHT + GetSystemMetrics(SM_CYEDGE) + GetSystemMetrics(SM_CYBORDER) + GetSystemMetrics(SM_CYDLGFRAME) + GetSystemMetrics(SM_CYCAPTION));
	SetScreenSize( WF_WIDTH, WF_HEIGHT );
	//ウィンドウハンドルの設定
	SetWindowHandle( NULL );
	SetParentWindowHandle( NULL );
	//  SetWindowClass( NULL );
	wd.Screen = NULL;
	wd.hMenu = NULL;
	wd.hInstance = NULL;
	wd.lpParam = NULL;
	drophandle = NULL;
	dragfilesmax = 0;
	ReceiveDragFiles_ = NULL;
	dragfilepath[ 0 ] = '\0';
	fullscreen = 0;
}
Ejemplo n.º 3
0
CUICustomMap::CUICustomMap ()
{
	m_BoundRect.set			(0,0,0,0);
	SetWindowName			("map");
	m_flags.zero			();
	SetPointerDistance		(0.0f);
}
Ejemplo n.º 4
0
SetStandardHints(Display * display, Window window, char app_name[], char
                 wind_name[], int x, int y, int width, int height)
{
    SetSizeHints(display, window, x, y, width, height);
    SetWindowName(display, window, wind_name);
    SetClassHints(display, window, app_name, APP_CLASS);
    SetWMHints(display, window, NormalState);
}
Ejemplo n.º 5
0
void KVLVEntry::Refresh()
{
   // Update the object characteristics and ask for redraw

   KVLVContainer* cnt = (KVLVContainer*)GetParent();
   TObject* obj = (TObject*)fUserData;
   SetItemName(cnt->fColData[0]->GetDataString(obj));
   for (int i = 0; fSubnames[i] != 0; i++) fSubnames[i]->SetString(cnt->fColData[i + 1]->GetDataString(obj));
   for (int i = 0; fSubnames[i] != 0; ++i)
      fCtw[i] = gVirtualX->TextWidth(fFontStruct, fSubnames[i]->GetString(),
                                     fSubnames[i]->GetLength());
   SetWindowName();
   TGPosition pos = cnt->GetPagePosition();
   cnt->DrawRegion(GetX() - pos.fX, GetY() - pos.fY, GetWidth(), GetHeight());
}
Ejemplo n.º 6
0
KVLVEntry::KVLVEntry(TObject* obj, const Char_t* objclass, const KVLVContainer* cnt, UInt_t ncols, KVLVColumnData** coldata)
   : TGLVEntry(cnt, TString(coldata[0]->GetDataString(obj)),
               TString(objclass), 0, kVerticalFrame, GetWhitePixel()), fDisconnectRefresh(kFALSE)
{
   // Exactly same as default constructor, but class of object used by TGLVEntry is given separately,
   // not neccessarily the same as obj->ClassName()

   fEditMode = kFALSE;
   if (!fgGreyPixel) {
      if (!fClient->GetColorByName("#f0f0f0", fgGreyPixel)) fgGreyPixel = 0;
      fgBGColor = fgWhitePixel;
   }
   fBGColor = -1;

   fUserData = obj;
   fSubnames = new TGString* [ncols];
   fBoolean = new Bool_t [ncols];
   for (int i = 0; i < (int)ncols - 1; i++) {
      fSubnames[i] = new TGString(coldata[i + 1]->GetDataString(obj));
      fBoolean[i] = coldata[i + 1]->IsBoolean();
   }
   fSubnames[ncols - 1] = 0;
   fBoolean[ncols - 1] = kFALSE;
   int j;
   for (j = 0; fSubnames[j] != 0; ++j)
      ;
   fCtw = new int[j + 1];
   fCtw[j] = 0;
   for (int i = 0; fSubnames[i] != 0; ++i)
      fCtw[i] = gVirtualX->TextWidth(fFontStruct, fSubnames[i]->GetString(),
                                     fSubnames[i]->GetLength());
   SetWindowName();

   // to update display of object characteristics when object is changed,
   // the object must have a "Connect" method (for signals-slots) and a "Modified"
   // method which emits the "Modified" signal when object is changed.
   // N.B. the object does not have to inherit from TQObject (can use RQ_OBJECT macro)
   // the "Modified" signal is connected to the KVLVEntry::Refresh method
   if (obj->IsA()->GetMethodAllAny("Modified") && obj->IsA()->GetMethodAllAny("Connect")) {
      gInterpreter->Execute(obj, obj->IsA(), "Connect",
                            Form("\"Modified()\",\"KVLVEntry\",(KVLVEntry*)%ld,\"Refresh()\"", (ULong_t)this));
      fDisconnectRefresh = kTRUE;
   }
}
Ejemplo n.º 7
0
MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) :
   TGMainFrame(p, w, h)
{
   // Create a main frame

   TString name = "myicon";
   ULong_t yellow;
   gClient->GetColorByName("yellow", yellow);

   // Create a picture from the XPM data 
   TGPicturePool *picpool = gClient->GetResourcePool()->GetPicturePool();
   const TGPicture *iconpic = picpool->GetPicture(name.Data(),icon1);
   TGIcon *icon = new TGIcon(this, iconpic, 40, 40, kChildFrame, yellow);
   AddFrame(icon, new TGLayoutHints(kLHintsLeft, 1,15,1,1));
   
   TGTextButton *exit = new TGTextButton(this, "&Exit","gApplication->Terminate(0)");
   AddFrame(exit, new TGLayoutHints(kLHintsExpandX,2,0,2,2));
   
   SetWindowName("Icon test");
   MapSubwindows();
   Resize(GetDefaultSize());
   MapWindow();
}
Ejemplo n.º 8
0
KVLVEntry::KVLVEntry(TObject* obj, const KVLVContainer* cnt,
                     UInt_t ncols, KVLVColumnData** coldata)
   : TGLVEntry(cnt, TString(coldata[0]->GetDataString(obj)),
               TString(obj->ClassName()), 0, kVerticalFrame, GetWhitePixel()), fDisconnectRefresh(kFALSE)
{
   // Default constructor
   fEditMode = kFALSE;
   if (!fgGreyPixel) {
      if (!fClient->GetColorByName("#f0f0f0", fgGreyPixel)) fgGreyPixel = 0;
      fgBGColor = fgWhitePixel;
   }
   fBGColor = -1;

   fUserData = obj;
   fSubnames = new TGString* [ncols];
   fBoolean = new Bool_t [ncols];
   for (int i = 0; i < (int)ncols - 1; i++) {
      fSubnames[i] = new TGString(coldata[i + 1]->GetDataString(obj));
      fBoolean[i] = coldata[i + 1]->IsBoolean();
   }
   fSubnames[ncols - 1] = 0;
   fBoolean[ncols - 1] = kFALSE;
   int j;
   for (j = 0; fSubnames[j] != 0; ++j)
      ;
   fCtw = new int[j + 1];
   fCtw[j] = 0;
   for (int i = 0; fSubnames[i] != 0; ++i)
      fCtw[i] = gVirtualX->TextWidth(fFontStruct, fSubnames[i]->GetString(),
                                     fSubnames[i]->GetLength());
   SetWindowName();

   // to update display of object characteristics when object is changed,
   // the object must have a "Connect" method (for signals-slots) and a "Modified"
   // method which emits the "Modified" signal when object is changed.
   // N.B. the object does not have to inherit from TQObject (can use RQ_OBJECT macro)
   // the "Modified" signal is connected to the KVLVEntry::Refresh method
   if (obj->IsA()->GetMethodAllAny("Modified") && obj->IsA()->GetMethodAllAny("Connect")) {
      gInterpreter->Execute(obj, obj->IsA(), "Connect",
                            Form("\"Modified()\",\"KVLVEntry\",(KVLVEntry*)%ld,\"Refresh()\"", (ULong_t)this));
      fDisconnectRefresh = kTRUE;
   }

   fColoured = kFALSE;
   // objects of classes with a method "const Char_t* GetLVEntryColour()" will be displayed with
   // the background colour returned by this method (either in hexadecimal format, i.e. "#f0f0f0"
   // or by name, i.e. "pink")
   if (obj->IsA()->GetMethodAllAny("GetLVEntryColour")) {

      TMethodCall mt;
      mt.InitWithPrototype(obj->IsA(), "GetLVEntryColour", "");
      if (mt.IsValid()) {
         if (mt.ReturnType() == TMethodCall::kString) {
            Char_t* ret;
            mt.Execute(obj, "", &ret);
            if (fClient->GetColorByName(ret, fBGColor)) {
               fColoured = kTRUE;
            }
            else {
               Warning("KVLVEntry", "Unknown color %s requested for entry", ret);
            }
         }
         else {
            Warning("KVLVEntry", "Object of class %s has GetLVEntryColour() method with wrong return type",
                    obj->ClassName());
         }
      }
      else {
         Warning("KVLVEntry", "GetLVEntryColour() method not valid for class %s", obj->ClassName());
      }
   }
}
sis3316_flash::sis3316_flash(const TGWindow *p, UInt_t w, UInt_t h, Bool_t *b) : TGMainFrame(p, w, h)
{
	// use hierarchical cleaning
	SetCleanup(kDeepCleanup);
	if(b){
		fBSetup = b;
		*fBSetup = kTRUE;
	}
	// main window icon and general setup
	SetWindowName("SIS3316 - Flash Programmer");
	SetIconPixmap("sis1.png");

	fClient->GetColorByName("green", this->green);
	fClient->GetColorByName("red", this->red);
	reboot_prevent_flag = 0;

	// vertical frame
	fVert1 = new TGVerticalFrame(this, GetDefaultWidth(), GetDefaultHeight());
	AddFrame(fVert1, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));


	// VME FPGA Programming section
	fGrpVME = new TGGroupFrame(fVert1, "VME FPGA Programming");  // hints, left, right, top, bottom
	fVert1->AddFrame(fGrpVME, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5));
	
	fLblVMEImg = new TGLabel(fGrpVME, "VME FPGA Image");
	fGrpVME->AddFrame(fLblVMEImg, new TGLayoutHints(kLHintsNormal, 0, 0, 10, 5));
	
	fHor1 = new TGHorizontalFrame(fGrpVME);
	fGrpVME->AddFrame(fHor1, new TGLayoutHints(kLHintsExpandX));

	fVMEImgPath = new TGTextEntry(fHor1, "test VME Image.bin");
	fHor1->AddFrame(fVMEImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	fVMEImgPath->SetWidth(240);
	
	fButVMEBrowse = new TGTextButton(fHor1, "...", BTN_VME_BROWSE);
	fButVMEBrowse->ChangeOptions(fButVMEBrowse->GetOptions() | kFixedWidth);
	fButVMEBrowse->SetWidth(50);
	fButVMEBrowse->Associate(this);
	fHor1->AddFrame(fButVMEBrowse, new TGLayoutHints(kLHintsRight, 5, 5, 5, 5));

	fButVMEProg = new TGTextButton(fGrpVME, "Program VME FPGA", BTN_VME_PROG);
	fButVMEProg->Associate(this);
	fGrpVME->AddFrame(fButVMEProg, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 15));



	// ADC FPGA Programming section
	fGrpADC = new TGGroupFrame(fVert1, "ADC FPGA Programming");
	//fVert1->AddFrame(fGrpADC, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 10, 5));
	fVert1->AddFrame(fGrpADC, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5));
	
	// ADC1
	fLblADC1Img = new TGLabel(fGrpADC, "ADC FPGA Image");
	fGrpADC->AddFrame(fLblADC1Img, new TGLayoutHints(kLHintsNormal, 0, 0, 10, 5));
	
	fHorADC1 = new TGHorizontalFrame(fGrpADC);
	fGrpADC->AddFrame(fHorADC1, new TGLayoutHints(kLHintsExpandX));

	fADC1ImgPath = new TGTextEntry(fHorADC1, "test ADC Image.bin");
	fHorADC1->AddFrame(fADC1ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	fADC1ImgPath->SetWidth(240);
	
	fButADC1Browse = new TGTextButton(fHorADC1, "...", BTN_ADC1_BROWSE);
	fButADC1Browse->ChangeOptions(fButADC1Browse->GetOptions() | kFixedWidth);
	fButADC1Browse->SetWidth(50);
	fButADC1Browse->Associate(this);
	fHorADC1->AddFrame(fButADC1Browse, new TGLayoutHints(kLHintsRight, 5, 5, 5, 5));

	fButADCProg = new TGTextButton(fGrpADC, "Program ADC FPGAs", BTN_ADC_PROG);
	fGrpADC->AddFrame(fButADCProg, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 15));
	fButADCProg->Associate(this);

#ifdef NOT_IMPLEMENTED	
	// ADC2
	fLblADC2Img = new TGLabel(fGrpADC, "ADC2 FPGA Image");
	fGrpADC->AddFrame(fLblADC2Img, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));

	fHorADC2 = new TGHorizontalFrame(fGrpADC);
	fGrpADC->AddFrame(fHorADC2, new TGLayoutHints(kLHintsExpandX));

	fADC2ImgPath = new TGTextEntry(fHorADC2, "test ADC2 Image.bin");
	fHorADC2->AddFrame(fADC2ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	fADC2ImgPath->SetWidth(187);

	fButADC2Browse = new TGTextButton(fHorADC2, "...", BTN_ADC2_BROWSE);
	fButADC2Browse->ChangeOptions(fButADC2Browse->GetOptions() | kFixedWidth);
	fButADC2Browse->SetWidth(50);
	fButADC2Browse->Associate(this);
	fHorADC2->AddFrame(fButADC2Browse, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	
	// ADC3
	fLblADC3Img = new TGLabel(fGrpADC, "ADC3 FPGA Image");
	fGrpADC->AddFrame(fLblADC3Img, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));

	fHorADC3 = new TGHorizontalFrame(fGrpADC);
	fGrpADC->AddFrame(fHorADC3, new TGLayoutHints(kLHintsExpandX));

	fADC3ImgPath = new TGTextEntry(fHorADC3, "test ADC2 Image.bin");
	fHorADC3->AddFrame(fADC3ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	fADC3ImgPath->SetWidth(187);

	fButADC3Browse = new TGTextButton(fHorADC3, "...", BTN_ADC3_BROWSE);
	fButADC3Browse->ChangeOptions(fButADC3Browse->GetOptions() | kFixedWidth);
	fButADC3Browse->SetWidth(50);
	fButADC3Browse->Associate(this);
	fHorADC3->AddFrame(fButADC3Browse, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	
	// ADC4
	fLblADC4Img = new TGLabel(fGrpADC, "ADC4 FPGA Image");
	fGrpADC->AddFrame(fLblADC4Img, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));

	fHorADC4 = new TGHorizontalFrame(fGrpADC);
	fGrpADC->AddFrame(fHorADC4, new TGLayoutHints(kLHintsExpandX));

	fADC4ImgPath = new TGTextEntry(fHorADC4, "test ADC4 Image.bin");
	fHorADC4->AddFrame(fADC4ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	fADC4ImgPath->SetWidth(187);

	fButADC4Browse = new TGTextButton(fHorADC4, "...", BTN_ADC4_BROWSE);
	fButADC4Browse->ChangeOptions(fButADC4Browse->GetOptions() | kFixedWidth);
	fButADC4Browse->SetWidth(50);
	fButADC4Browse->Associate(this);
	fHorADC4->AddFrame(fButADC4Browse, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	

	fChkADCImgSelect = new TGCheckButton(fGrpADC, "ADC FPGAs have unique images");
	fChkADCImgSelect->SetState(kButtonDown)   ; // is ON !
	fChkADCImgSelect->SetEnabled(kFALSE); //
	//fChkADCImgSelect->Associate(this);
	fGrpADC->AddFrame(fChkADCImgSelect);

#endif	
	//fGrpProgram = new TGGroupFrame(fVert1, "Programming");
	//fVert1->AddFrame(fGrpProgram, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 10, 10, 0, 0));

	fGrpBarProg = new TGGroupFrame(fVert1, "Programming progress");  // hints, left, right, top, bottom
	fVert1->AddFrame(fGrpBarProg, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5));


	fBar_prog = new TGHProgressBar(fGrpBarProg);
	fBar_prog->ShowPosition(kTRUE, kTRUE);
	fBar_prog->SetBarColor("blue");
	fBar_prog->SetForegroundColor(0x000000);
	fGrpBarProg->AddFrame(fBar_prog, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 10, 20, 10)); // hints, left, right, top, bottom


	fGrpBarVerify = new TGGroupFrame(fVert1, "Verifying progress");  // hints, left, right, top, bottom
	fVert1->AddFrame(fGrpBarVerify, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5));

	fBar_verify = new TGHProgressBar(fGrpBarVerify);
	fBar_verify->ShowPosition(kTRUE, kTRUE);
	fBar_verify->SetBarColor("blue");
	fBar_verify->SetForegroundColor(0x000000);
	fGrpBarVerify->AddFrame(fBar_verify, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 10, 20, 20)); // hints, left, right, top, bottom

	fGrpReboot = new TGGroupFrame(fVert1, "Reboot");  // hints, left, right, top, bottom
	fVert1->AddFrame(fGrpReboot, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5));

	fButReboot = new TGTextButton(fGrpReboot, "Reboot SIS3316 FPGAs", BTN_REBOOT);
	fButReboot->Associate(this);
	fButReboot->ChangeBackground(this->green);
	fGrpReboot->AddFrame(fButReboot, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 15));



	fLabel_reboot_note = new TGLabel(fGrpReboot,"Note: the watchdog has to be enabled -> SW80-7 ON ");
	fLabel_reboot_note->SetTextJustify(kTextLeft + kTextCenterX );
	fLabel_reboot_note->SetMargins(0,0,0,0);
	fLabel_reboot_note->SetWrapLength(-1);
	fGrpReboot->AddFrame(fLabel_reboot_note, new TGLayoutHints(kLHintsExpandX,2,2,15,2));



	
	// draw everything
	SetWMSizeHints(w, h, w, h, 1, 1);
	Resize(GetDefaultSize());   // resize to default size
	MapSubwindows();
	// initially hidden
#ifdef NOT_IMPLEMENTED	
	fGrpADC->HideFrame(fHorADC2);
	fGrpADC->HideFrame(fHorADC3);
	fGrpADC->HideFrame(fHorADC4);
	fGrpADC->HideFrame(fLblADC2Img);
	fGrpADC->HideFrame(fLblADC3Img);
	fGrpADC->HideFrame(fLblADC4Img);
#endif
	MapWindow();
 
}
Ejemplo n.º 10
0
/*******************************************************************************\
|* openXwindow                                                                 *|
\*******************************************************************************/
void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits, 
		 int pixmask_width, int pixmask_height, int withdrawn) {

	unsigned int	borderwidth = 0;
	XClassHint     	classHint;
	char	       	*display_name = NULL;
	XTextProperty	name;
	XGCValues      	gcv;
	unsigned long	gcm;
	Status			status;
	int				dummy=0, i;
  
	wname = PACKAGE;
	
	for (i=1; argv[i]; i++) {
		if ((!strcmp(argv[i], "-display")) || (!strcmp(argv[i], "-d")))
			display_name = argv[i+1];
	}
  
  if (!(display = XOpenDisplay(display_name))) {
    fprintf(stderr, "%s: can't open display %s\n", 
	    wname, XDisplayName(display_name));
    exit(1);
  }

  if ( !withdrawn )
	borderwidth = 5;

  screen  = DefaultScreen(display);
  Root    = RootWindow(display, screen);
  d_depth = DefaultDepth(display, screen);
  x_fd    = XConnectionNumber(display);
  
  /* Convert XPM to XImage */
  GetXPM(&wmgen, pixmap_bytes);
  
  /* Create a window to hold the stuff */
  mysizehints.flags = USSize | USPosition;
  mysizehints.x = 0;
  mysizehints.y = 0;
  
  back_pix = GetColor("white");
  fore_pix = GetColor("black");
  
  XWMGeometry(display, screen, Geometry, NULL, borderwidth, &mysizehints,
	      &mysizehints.x, &mysizehints.y,&mysizehints.width,&mysizehints.height, &dummy);
  
  mysizehints.min_width = 
    mysizehints.max_width =
    mysizehints.width = 64;
  
  mysizehints.min_height =
    mysizehints.max_height =
    mysizehints.height = 64;
  mysizehints.flags |= PMinSize|PMaxSize;
  
  win = XCreateSimpleWindow(display, Root, mysizehints.x, mysizehints.y,
			    mysizehints.width, mysizehints.height, borderwidth, 
			    fore_pix, back_pix);
  
  iconwin = XCreateSimpleWindow(display, win, mysizehints.x, mysizehints.y,
				mysizehints.width, mysizehints.height, borderwidth, 
				fore_pix, back_pix);
  
  /* Activate hints */
  XSetWMNormalHints(display, win, &mysizehints);
  XSetWMNormalHints(display, iconwin, &mysizehints); /* new AQ */
  classHint.res_name = wname;
  classHint.res_class = wname;
  XSetClassHint(display, win, &classHint);
  
  XSelectInput(display, win, 
	       ButtonPressMask | ExposureMask | 
	       ButtonReleaseMask | /*PointerMotionMask |*/ StructureNotifyMask);
  XSelectInput(display, iconwin, 
	       ButtonPressMask | ExposureMask | 
	       ButtonReleaseMask | /*PointerMotionMask |*/ StructureNotifyMask);


/*	if (XStringListToTextProperty(&fullname, 1, &name) == 0) { */  
	if (XStringListToTextProperty(&wname, 1, &name) == 0) {
		fprintf(stderr, "%s: can't allocate window name\n", wname);
		exit(1);
	}

	XSetWMName(display, win, &name);
	if ( !withdrawn ) {
		XSetWMIconName(display, win, &name);
		SetWindowName(wname);
	}

  /* Create GC for drawing */
  
  gcm = GCForeground | GCBackground | GCGraphicsExposures;
  gcv.foreground = fore_pix;
  gcv.background = back_pix;
  gcv.graphics_exposures = 0;
  NormalGC = XCreateGC(display, Root, gcm, &gcv);
  
  /* ONLYSHAPE ON */

  if ( withdrawn ) {
    pixmask = XCreateBitmapFromData(display, win, pixmask_bits, 
				    pixmask_width, pixmask_height);
    XShapeCombineMask(display, win, ShapeBounding, 0, 0, pixmask, ShapeSet);
    XShapeCombineMask(display, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);
  }
  /* ONLYSHAPE OFF */
  
  mywmhints.initial_state = withdrawn ? WithdrawnState : NormalState;
  mywmhints.icon_window = iconwin;
  mywmhints.flags = StateHint | IconWindowHint;

  if ( withdrawn ) {
    mywmhints.window_group = win;
    mywmhints.flags |= WindowGroupHint | IconPositionHint;
    mywmhints.icon_x = mysizehints.x;
    mywmhints.icon_y = mysizehints.y;
  }
  
  XSetWMHints(display, win, &mywmhints);
  XSetCommand(display, win, argv, argc);
  
  /* Set up the event for quitting the window */
  wm_delete_window = XInternAtom(display, 
				 "WM_DELETE_WINDOW",	/* atom_name */
				 False);		/* only_if_exists */

  wm_protocols = XInternAtom(display,
			     "WM_PROTOCOLS",		/* atom_name */
			     False);			/* only_if_exists */

  status = XSetWMProtocols(display, win, &wm_delete_window, 1);
  status = XSetWMProtocols(display, iconwin, &wm_delete_window,	1);

  XMapWindow(display, win);

}
Ejemplo n.º 11
0
KVFileDialog::KVFileDialog(const TGWindow *p, const TGWindow *main,
                           EKVFileDialogMode dlg_type, TGFileInfo *file_info) :
   TGTransientFrame(p, main, 10, 10, kVerticalFrame)
{
   // Create a file selection dialog. Depending on the dlg_type it can be
   // used for opening or saving a file or selecting a directory.

   fDlgMode=dlg_type;
   SetCleanup(kDeepCleanup);
   Connect("CloseWindow()", "KVFileDialog", this, "CloseWindow()");
   DontCallClose();

   int i;

   if (!p && !main) {
      MakeZombie();
      return;
   }
   if (!file_info) {
      Error("KVFileDialog", "file_info argument not set");
      fFileInfo = &gInfo;
      if (fFileInfo->fIniDir) {
         delete [] fFileInfo->fIniDir;
         fFileInfo->fIniDir = 0;
      }
      if (fFileInfo->fFilename) {
         delete [] fFileInfo->fFilename;
         fFileInfo->fFilename = 0;
      }
      fFileInfo->fFileTypeIdx = 0;
   } else
      fFileInfo = file_info;

   if (!fFileInfo->fFileTypes)
      fFileInfo->fFileTypes = gDefTypes;

   if (!fFileInfo->fIniDir)
      fFileInfo->fIniDir = StrDup(".");

   TGHorizontalFrame *fHtop = new TGHorizontalFrame(this, 10, 10);
   
   //--- top toolbar elements
   TGLabel *fLookin = new TGLabel(fHtop, new TGHotString((dlg_type == kKVFDSave)
                                                  ? "S&ave in:" : "&Look in:"));
   fTreeLB = new TGFSComboBox(fHtop, kIDF_FSLB);
   fTreeLB->Associate(this);

   fPcdup = fClient->GetPicture("tb_uplevel.xpm");
   fPnewf = fClient->GetPicture("tb_newfolder.xpm");
   fPlist = fClient->GetPicture("tb_list.xpm");
   fPdetails = fClient->GetPicture("tb_details.xpm");

   if (!(fPcdup && fPnewf && fPlist && fPdetails))
      Error("KVFileDialog", "missing toolbar pixmap(s).\n");

   fCdup    = new TGPictureButton(fHtop, fPcdup, kIDF_CDUP);
   fNewf    = new TGPictureButton(fHtop, fPnewf, kIDF_NEW_FOLDER);
   fList    = new TGPictureButton(fHtop, fPlist, kIDF_LIST);
   fDetails = new TGPictureButton(fHtop, fPdetails, kIDF_DETAILS);

   fCdup->SetStyle(gClient->GetStyle());
   fNewf->SetStyle(gClient->GetStyle());
   fList->SetStyle(gClient->GetStyle());
   fDetails->SetStyle(gClient->GetStyle());

   fCdup->SetToolTipText("Up One Level");
   fNewf->SetToolTipText("Create New Folder");
   fList->SetToolTipText("List");
   fDetails->SetToolTipText("Details");

   fCdup->Associate(this);
   fNewf->Associate(this);
   fList->Associate(this);
   fDetails->Associate(this);

   fList->AllowStayDown(kTRUE);
   fDetails->AllowStayDown(kTRUE);

   fTreeLB->Resize(200, fTreeLB->GetDefaultHeight());

   fHtop->AddFrame(fLookin, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
   fHtop->AddFrame(fTreeLB, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 3, 0, 2, 2));
   fHtop->AddFrame(fCdup, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
   fHtop->AddFrame(fNewf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
   fHtop->AddFrame(fList, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
   fHtop->AddFrame(fDetails, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 0, 8, 2, 2));

   if (dlg_type == kKVFDSave) {
      fCheckB = new TGCheckButton(fHtop, "&Overwrite", kIDF_CHECKB);
      fCheckB->SetToolTipText("Overwrite a file without displaying a message if selected");
   } else {
      fCheckB = new TGCheckButton(fHtop, "&Multiple files", kIDF_CHECKB);
      fCheckB->SetToolTipText("Allows multiple file selection when SHIFT is pressed");
      fCheckB->Connect("Toggled(Bool_t)","TGFileInfo",fFileInfo,"SetMultipleSelection(Bool_t)");
   }
   fHtop->AddFrame(fCheckB, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
   fCheckB->SetOn(fFileInfo->fMultipleSelection);
   AddFrame(fHtop, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1));

   //--- file view

   fFv = new TGListView(this, 400, 161);

   fFc = new TGFileContainer(fFv->GetViewPort(),
                             10, 10, kHorizontalFrame, fgWhitePixel);
   fFc->Associate(this);

   fFv->GetViewPort()->SetBackgroundColor(fgWhitePixel);
   fFv->SetContainer(fFc);
   fFv->SetViewMode(kLVList);
   fFv->SetIncrements(1, 19); // set vertical scroll one line height at a time

   TGTextButton** buttons = fFv->GetHeaderButtons();
   if (buttons) {
      buttons[0]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByName)");
      buttons[1]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByType)");
      buttons[2]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortBySize)");
      buttons[3]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByOwner)");
      buttons[4]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByGroup)");
      buttons[5]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByDate)");
   }

   fFc->SetFilter(fFileInfo->fFileTypes[fFileInfo->fFileTypeIdx+1]);
   fFc->Sort(kSortByName);
   fFc->ChangeDirectory(fFileInfo->fIniDir);
   fFc->SetMultipleSelection(fFileInfo->fMultipleSelection);
   fTreeLB->Update(fFc->GetDirectory());

   fList->SetState(kButtonEngaged);

   AddFrame(fFv, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 4, 4, 3, 1));

   if (dlg_type == kKVFDOpen) {
      fCheckB->Connect("Toggled(Bool_t)","TGFileContainer",fFc,"SetMultipleSelection(Bool_t)");
      fCheckB->Connect("Toggled(Bool_t)","TGFileContainer",fFc,"UnSelectAll()");
   }
   
   //--- file name and types

   TGHorizontalFrame *fHf = new TGHorizontalFrame(this, 10, 10);

   TGVerticalFrame *fVf = new TGVerticalFrame(fHf, 10, 10);

   TGHorizontalFrame *fHfname = new TGHorizontalFrame(fVf, 10, 10);

   TGLabel *fLfname = new TGLabel(fHfname, new TGHotString("File &name:"));
   fTbfname = new TGTextBuffer(1034);
   fName = new TGTextEntry(fHfname, fTbfname);
   fName->Resize(230, fName->GetDefaultHeight());
   fName->Associate(this);

   fHfname->AddFrame(fLfname, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
   fHfname->AddFrame(fName, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2));

   fVf->AddFrame(fHfname, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));

   TGHorizontalFrame *fHftype = new TGHorizontalFrame(fVf, 10, 10);

   TGLabel *fLftypes = new TGLabel(fHftype, new TGHotString("Files of &type:"));
   fTypes = new TGComboBox(fHftype, kIDF_FTYPESLB);
   fTypes->Associate(this);
   fTypes->Resize(230, fName->GetDefaultHeight());

   TString s;
   for (i = 0; fFileInfo->fFileTypes[i] != 0; i += 2) {
      s.Form("%s (%s)", fFileInfo->fFileTypes[i], fFileInfo->fFileTypes[i+1]);
      fTypes->AddEntry(s.Data(), i);
   }
   fTypes->Select(fFileInfo->fFileTypeIdx);

   // Show all items in combobox without scrollbar
   //TGDimension fw = fTypes->GetListBox()->GetContainer()->GetDefaultSize();
   //fTypes->GetListBox()->Resize(fw.fWidth, fw.fHeight);

   if (fFileInfo->fFilename && fFileInfo->fFilename[0])
      fTbfname->AddText(0, fFileInfo->fFilename);
   else
      fTbfname->Clear();

   fTypes->GetListBox()->Resize(230, 120);
   fHftype->AddFrame(fLftypes, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
   fHftype->AddFrame(fTypes, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2));

   fVf->AddFrame(fHftype, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));

   fHf->AddFrame(fVf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));

   //--- Open/Save and Cancel buttons

   TGVerticalFrame *fVbf = new TGVerticalFrame(fHf, 10, 10, kFixedWidth);

   fOk = new TGTextButton(fVbf, new TGHotString((dlg_type == kKVFDSave)
                                                 ? "&Save" : "&Open"), kIDF_OK);
   fCancel = new TGTextButton(fVbf, new TGHotString("Cancel"), kIDF_CANCEL);

   fOk->Associate(this);
   fCancel->Associate(this);

   fVbf->AddFrame(fOk, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));
   fVbf->AddFrame(fCancel, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));

   UInt_t width = TMath::Max(fOk->GetDefaultWidth(), fCancel->GetDefaultWidth()) + 20;
   fVbf->Resize(width + 20, fVbf->GetDefaultHeight());

   fHf->AddFrame(fVbf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));

   AddFrame(fHf, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1));
   SetEditDisabled(kEditDisable);

   MapSubwindows();

   TGDimension size = GetDefaultSize();

   Resize(size);

   //---- position relative to the parent's window

   CenterOnParent();

   //---- make the message box non-resizable

   SetWMSize(size.fWidth, size.fHeight);
   SetWMSizeHints(size.fWidth, size.fHeight, 10000, 10000, 1, 1);

   const char *wname = ((dlg_type == kKVFDSave) ? "Save As..." : (dlg_type==kKVFDOpen) ? "Open" : "Choose directory...");
   SetWindowName(wname);
   SetIconName(wname);
   SetClassHints("FileDialog", "FileDialog");

   SetMWMHints(kMWMDecorAll | kMWMDecorResizeH  | kMWMDecorMaximize |
                              kMWMDecorMinimize | kMWMDecorMenu,
               kMWMFuncAll |  kMWMFuncResize    | kMWMFuncMaximize |
                              kMWMFuncMinimize,
               kMWMInputModeless);

   MapWindow();
   fFc->DisplayDirectory();
   fClient->WaitFor(this);
}
Ejemplo n.º 12
0
Archivo: mygraph.c Proyecto: ombt/ombt
// main entry point
main(int argc, char **argv)
{
	// get command line options
	int nextarg;
	if (cmdopts(argc, argv, nextarg) != OK)
	{
		fprintf(stderr, "invalid command line option [%s].\n",
			argv[nextarg]);
		return(2);
	}

	// get data 
	if (getdata(argc, argv, nextarg) != OK)
	{
		fprintf(stderr, "unable to get data.");
		return(2);
	}

	// connect to server
	Display *xdisplay = NULL;
	if (OpenDisplay(display, xdisplay) != OK)
	{
		fprintf(stderr, "unable to open display to server %s.\n",
			XDisplayName(display));
		return(2);
	}

	// get physical screen attributes
	int xscreen;
	unsigned int display_width, display_height;
	if (GetDisplayAttributes(xdisplay, xscreen, 
			display_width, display_height) != OK)
	{
		fprintf(stderr, "unable to get display attributes.\n");
		CloseDisplay(xdisplay);
		return(2);
	}

	// determine window geometry and location
	int window_width, window_height, window_x, window_y;
	if (GetWindowGeometry(display_width, display_height, 
			window_width, window_height, 
			window_x, window_y) != OK)
	{
		fprintf(stderr, "unable to get window geometry.\n");
		CloseDisplay(xdisplay);
		return(2);
	}

	// default black and white pixels
	unsigned long black = BlackPixel(xdisplay, xscreen);
	unsigned long white = WhitePixel(xdisplay, xscreen);

	// get pseudo-color display, if any
	int window_depth;
	Visual *window_visual;
	if (GetPseudoColorVisual(xdisplay, xscreen, 
			window_visual, window_depth) != OK)
	{
		fprintf(stderr, "unable to get a color visual.\n");
		CloseDisplay(xdisplay);
		return(2);
	}

	// create a window
	unsigned int window_border_width = 4;
	Window root_window = RootWindow(xdisplay, xscreen);
window_visual=CopyFromParent;
window_depth=CopyFromParent;
	Window window = CreateWindow(
		xdisplay, root_window, 
		window_x, window_y, window_width, window_height, 
		black, white, EventMask,
		window_visual, window_border_width, window_depth);

	// set size hints
	if (SetSizeHints(xdisplay, window, 
		window_x, window_y, window_width, window_height) != OK)
	{
		fprintf(stderr, "unable to set window size hints.\n");
		CloseDisplay(xdisplay);
		return(2);
	}

	// set window name
	if (SetWindowName(xdisplay, window, title) != OK)
	{
		fprintf(stderr, "unable to set window title.\n");
		CloseDisplay(xdisplay);
		return(2);
	}

	// set class hints
	if (SetClassHints(xdisplay, window, argv[0], argv[0]) != OK)
	{
		fprintf(stderr, "unable to set class hints.\n");
		CloseDisplay(xdisplay);
		return(2);
	}

	// set other window manager hints
	int initstate = 
		(strcmp(iconic, "YES") == 0) ? IconicState : NormalState;
	if (SetWMHints(xdisplay, window, initstate) != OK)
	{
		fprintf(stderr, "unable to set WM hints.\n");
		CloseDisplay(xdisplay);
		return(2);
	}

	// set up color map for window
	Colormap window_colormap;
	if (SetUpColorMap(xdisplay, xscreen, 
			window, window_visual, window_colormap) != OK)
	{
		fprintf(stderr, "unable to set up a color map.\n");
		CloseDisplay(xdisplay);
		return(2);
	}

	// allocate colors for background and foreground
	unsigned long window_background = 
		AllocateColorByName(xdisplay, window_colormap, 
				background, white);
	unsigned long window_foreground = 
		AllocateColorByName(xdisplay, window_colormap, 
				foreground, black);

	// get font for writing
	XFontStruct *xfont = LoadFont(xdisplay, font, "fixed");
	if (xfont == NULL)
	{
		fprintf(stderr, "unable to load font.\n");
		CloseDisplay(xdisplay);
		return(2);
	}

	// create GC for drawing
	GC gc = CreateGC(xdisplay, window, xfont, 
			window_foreground, window_background);
	GC xor_gc = CreateXorGC(xdisplay, window, xfont, 
			window_foreground, window_background);

	// map window
	XMapRaised(xdisplay, window);
	XFlush(xdisplay);

	// event loop
	int start_x = -1;
	int start_y = -1;
	int last_x = -1;
	int last_y = -1;
	XEvent event;
	KeySym keysym;
	char string[BUFSIZ];
	for (int done = 0; !done; )
	{
		XNextEvent(xdisplay, &event);
		switch (event.type)
		{
		case Expose:
			if (event.xexpose.count == 0)
			{
				redraw(xdisplay, window, gc, xfont, 
					window_width, window_height);
			}
			break;
		case ConfigureNotify:
			window_x = event.xconfigure.x;
			window_y = event.xconfigure.y;
			window_width = event.xconfigure.width;
			window_height = event.xconfigure.height;
			break;
		case KeyPress:
			done = DecodeKeyPress(&event.xkey, &keysym, string);
			break;
		case MappingNotify:
			XRefreshKeyboardMapping(&event.xmapping);
			break;
		case ButtonPress:
			if (event.xbutton.button == Button1)
			{
				start_x = event.xbutton.x;
				start_y = event.xbutton.y;
				last_x = start_x;
				last_y = start_y;
				DrawBox(xdisplay, window, xor_gc, 
					start_x, start_y, last_x, last_y);
				XFlush(xdisplay);
			}
			break;
		case ButtonRelease:
			if (event.xbutton.button == Button1)
			{
				if (start_x != last_x && start_y != last_y)
				{
					DrawBox(xdisplay, window, xor_gc, 
						start_x, start_y, 
						last_x, last_y);
					XFlush(xdisplay);
					UpdateLimits(start_x, start_y, 
						last_x, last_y,
						window_width, window_height);
					XClearWindow(xdisplay, window);
					XFlush(xdisplay);
					redraw(xdisplay, window, gc, xfont, 
						window_width, window_height);
					XFlush(xdisplay);
				}
				start_x = -1;
				start_y = -1;
				last_x = -1;
				last_y = -1;
			}
			else 
			{
				// reset to original values.
				rminxval = reset_rminxval;
				rmaxxval = reset_rmaxxval;
				rminyval = reset_rminyval;
				rmaxyval = reset_rmaxyval;
				XClearWindow(xdisplay, window);
				XFlush(xdisplay);
				redraw(xdisplay, window, gc, xfont, 
					window_width, window_height);
				XFlush(xdisplay);
			}
			break;
		case MotionNotify:
			if (event.xbutton.button == Button1)
			{
				DrawBox(xdisplay, window, xor_gc, 
					start_x, start_y, last_x, last_y);
				last_x = event.xmotion.x;
				last_y = event.xmotion.y;
				DrawBox(xdisplay, window, xor_gc, 
					start_x, start_y, last_x, last_y);
				XFlush(xdisplay);
			}
			break;
		}
	}

	// close display
	CloseDisplay(xdisplay);

	// all done
	return(0);
}
Ejemplo n.º 13
0
MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) :
  TGMainFrame(p, w, h)
{
   // Create horizontal splitter
   TGVerticalFrame *fVf = new TGVerticalFrame(this, 10, 10);

   TGHorizontalFrame *fH1 = new TGHorizontalFrame(fVf, 10, 50, kFixedHeight);
   TGHorizontalFrame *fH2 = new TGHorizontalFrame(fVf, 10, 10);
   TGCompositeFrame *fFtop = new TGCompositeFrame(fH1, 10, 10, kSunkenFrame);
   TGCompositeFrame *fFbottom = new TGCompositeFrame(fH2, 10, 10, kSunkenFrame);

   TGLabel *fLtop = new TGLabel(fFtop, "Top Frame");
   TGLabel *fLbottom = new TGLabel(fFbottom, "Bottom Frame");

   fFtop->AddFrame(fLtop, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
                                            3, 0, 0, 0));
   fFbottom->AddFrame(fLbottom, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
                                                  3, 0, 0, 0));

   fH1->AddFrame(fFtop, new TGLayoutHints(kLHintsTop | kLHintsExpandY | 
                                          kLHintsExpandX, 0, 0, 1, 2));
   fH2->AddFrame(fFbottom, new TGLayoutHints(kLHintsTop | kLHintsExpandY | 
                                             kLHintsExpandX, 0, 0, 1, 2));

   fH1->Resize(fFtop->GetDefaultWidth(), fH1->GetDefaultHeight()+20);
   fH2->Resize(fFbottom->GetDefaultWidth(), fH2->GetDefaultHeight()+20);
   fVf->AddFrame(fH1, new TGLayoutHints(kLHintsTop | kLHintsExpandX));

   TGHSplitter *hsplitter = new TGHSplitter(fVf,2,2);
   hsplitter->SetFrame(fH1, kTRUE);
   fVf->AddFrame(hsplitter, new TGLayoutHints(kLHintsTop | kLHintsExpandX));

   fVf->AddFrame(fH2, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));   
   
   // button frame
   TGVerticalFrame *hframe = new TGVerticalFrame(this, 10, 10);
   TGCompositeFrame *cframe2 = new TGCompositeFrame(hframe, 170, 50, 
                                             kHorizontalFrame | kFixedWidth);
   TGTextButton *save = new TGTextButton(cframe2, "&Save");
   cframe2->AddFrame(save, new TGLayoutHints(kLHintsTop | kLHintsExpandX,
                                             3, 2, 2, 2));
   save->Connect("Clicked()", "MyMainFrame", this, "DoSave()");
   save->SetToolTipText("Click on the button to save the application as C++ macro");
   
   TGTextButton *exit = new TGTextButton(cframe2, "&Exit ","gApplication->Terminate(0)");
   cframe2->AddFrame(exit, new TGLayoutHints(kLHintsTop | kLHintsExpandX,
                                             2, 0, 2, 2));
   hframe->AddFrame(cframe2, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
   
   AddFrame(fVf, new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY));
   AddFrame(hframe, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
   
   // What to clean up in dtor
   SetCleanup(kDeepCleanup);
     
   // Set a name to the main frame   
   SetWindowName("Horizontal Splitter");
   SetWMSizeHints(300, 250, 600, 600, 0, 0);
   MapSubwindows();
   Resize(GetDefaultSize());
   MapWindow();
}
Ejemplo n.º 14
0
void CUITalkDialogWnd::InitTalkDialogWnd()
{
	m_uiXml						= xr_new<CUIXml>();
	m_uiXml->Load				(CONFIG_PATH, UI_PATH, TALK_XML);
	CUIXmlInit					ml_init;

	CUIXmlInit::InitWindow		(*m_uiXml, "main", 0, this);

//	CUIXmlInit::InitStatic		(*m_uiXml, "right_character_icon", 0, &UIOurIcon);

//	CUIXmlInit::InitStatic		(*m_uiXml, "left_character_icon", 0, &UIOthersIcon);

//	UIOurIcon.AttachChild		(&UICharacterInfoLeft);
//	UICharacterInfoLeft.InitCharacterInfo(Fvector2().set(0,0), UIOurIcon.GetWndSize(), "talk_character.xml");

//	UIOthersIcon.AttachChild	(&UICharacterInfoRight);
//	UICharacterInfoRight.InitCharacterInfo(Fvector2().set(0,0), UIOthersIcon.GetWndSize(), "talk_character.xml");

//	AttachChild					(&UIOurIcon);
//	AttachChild					(&UIOthersIcon);

	// Фрейм с нащими фразами
//	AttachChild					(&UIDialogFrameBottom);
//	CUIXmlInit::InitStatic		(*m_uiXml, "frame_bottom", 0, &UIDialogFrameBottom);

	//основной фрейм диалога
//	AttachChild					(&UIDialogFrameTop);
//	CUIXmlInit::InitStatic		(*m_uiXml, "frame_top", 0, &UIDialogFrameTop);


	//Ответы
	UIAnswersList				= xr_new<CUIScrollView>();
	UIAnswersList->SetAutoDelete(true);
//	UIDialogFrameTop.AttachChild(UIAnswersList);
	AttachChild(UIAnswersList);
	CUIXmlInit::InitScrollView	(*m_uiXml, "answers_list", 0, UIAnswersList);
	UIAnswersList->SetWindowName("---UIAnswersList");

	//Вопросы
	UIQuestionsList				= xr_new<CUIScrollView>();
	UIQuestionsList->SetAutoDelete(true);
//	UIDialogFrameBottom.AttachChild(UIQuestionsList);
	AttachChild(UIQuestionsList);
	CUIXmlInit::InitScrollView	(*m_uiXml, "questions_list", 0, UIQuestionsList);
	UIQuestionsList->SetWindowName("---UIQuestionsList");


	//кнопка перехода в режим торговли
	AttachChild					(&UIToTradeButton);
	CUIXmlInit::Init3tButton	(*m_uiXml, "button", 0, &UIToTradeButton);

	//AttachChild					(&UIToExitButton);
	//CUIXmlInit::Init3tButton	(*m_uiXml, "button_exit", 0, &UIToExitButton);

	//m_btn_pos[0]				= UIToTradeButton.GetWndPos();
	//m_btn_pos[1]				= UIToExitButton.GetWndPos();
	//m_btn_pos[2].x				= (m_btn_pos[0].x+m_btn_pos[1].x)/2.0f;
	//m_btn_pos[2].y				= m_btn_pos[0].y;
	// шрифт для индикации имени персонажа в окне разговора
	CUIXmlInit::InitFont		(*m_uiXml, "font", 0, m_iNameTextColor, m_pNameTextFont);

	CGameFont * pFont			= NULL;
	CUIXmlInit::InitFont		(*m_uiXml, "font", 1, m_uOurReplicsColor, pFont);


	SetWindowName				("----CUITalkDialogWnd");

	Register					(&UIToTradeButton);
	AddCallbackStr				("question_item",LIST_ITEM_CLICKED,CUIWndCallback::void_function(this, &CUITalkDialogWnd::OnQuestionClicked));
	AddCallback					(&UIToTradeButton,BUTTON_CLICKED,CUIWndCallback::void_function(this, &CUITalkDialogWnd::OnTradeClicked));
//	AddCallback					(&UIToExitButton,BUTTON_CLICKED,CUIWndCallback::void_function(this, &CUITalkDialogWnd::OnExitClicked));
}
Ejemplo n.º 15
0
//______________________________________________________________________________
ButtonWindow::ButtonWindow() 
    : TGMainFrame(gClient->GetRoot(), 600, 500)
{
    // Main test window.
    SetWindowName("CaLib Control Panel");
    
    // ---------------------------------------------------------------------------------
    TGGroupFrame* config_frame = new TGGroupFrame(this, "Calibration and set configuration", kHorizontalFrame);
    config_frame->SetTitlePos(TGGroupFrame::kLeft);
    
    TGVerticalFrame* ver_frame_1 = new TGVerticalFrame(config_frame);
    
    // calibration selection
    fCBox_Calibration = new TGComboBox(ver_frame_1, "Choose calibration");
    fCBox_Calibration->Resize(260, 25);
    ver_frame_1->AddFrame(fCBox_Calibration, new TGLayoutHints(kLHintsLeft, 0, 5, 10, 0));
      
    // fill calibrations
    gCalibrations = TCMySQLManager::GetManager()->GetAllCalibrations();
    for (Int_t i = 0; i < gCalibrations->GetSize(); i++)
    {
        TObjString* s = (TObjString*) gCalibrations->At(i);
        fCBox_Calibration->AddEntry(s->GetString().Data(), i);
    }
    
    fCBox_Calibration->Connect("Selected(Int_t)", "ButtonWindow", this, "EnableModuleSelection(Int_t)");

    // calibration module selection
    fCBox_Module = new TGComboBox(ver_frame_1, "Choose calibration module");
    fCBox_Module->Resize(260, 25);
    ver_frame_1->AddFrame(fCBox_Module, new TGLayoutHints(kLHintsLeft, 0, 5, 10, 0));
  
    // fill modules
    for (Int_t i = 0; i < gCaLibModules->GetSize(); i++)
    {
        TCCalib* cmod = (TCCalib*) gCaLibModules->At(i);
        fCBox_Module->AddEntry(cmod->GetTitle(), i);
    }

    fCBox_Module->Connect("Selected(Int_t)", "ButtonWindow", this, "ReadRunsets(Int_t)");
    
    config_frame->AddFrame(ver_frame_1, new TGLayoutHints(kLHintsFillX));
    
    TGVerticalFrame* ver_frame_2 = new TGVerticalFrame(config_frame);
    
    // runset selection
    fLB_RunSet = new TGListBox(ver_frame_2);
    fLB_RunSet->SetMultipleSelections(kTRUE);
    fLB_RunSet->Resize(120, 60);
    ver_frame_2->AddFrame(fLB_RunSet, new TGLayoutHints(kLHintsLeft | kLHintsExpandY | kLHintsExpandX, 5, 0, 10, 0));
    
    config_frame->AddFrame(ver_frame_2, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
    AddFrame(config_frame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));

    // ---------------------------------------------------------------------------------
    
    // control buttons
    TGGroupFrame* control_frame = new TGGroupFrame(this, "Calibration control", kHorizontalFrame);
    control_frame->SetTitlePos(TGGroupFrame::kLeft);
    
    fTB_Init = new TGTextButton(control_frame, "Start module");
    ResizeFrame(fTB_Init);
    fTB_Init->Connect("Clicked()", "ButtonWindow", this, "StartModule()");
    control_frame->AddFrame(fTB_Init, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));

    fTB_Write = new TGTextButton(control_frame, "Write to DB");
    ResizeFrame(fTB_Write);
    fTB_Write->Connect("Clicked()", "ButtonWindow", this, "DoWrite()");
    control_frame->AddFrame(fTB_Write, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));

    fTB_Print = new TGTextButton(control_frame, "Print values");
    ResizeFrame(fTB_Print);
    fTB_Print->Connect("Clicked()", "ButtonWindow", this, "Print()");
    control_frame->AddFrame(fTB_Print, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));

    fTB_PrintChanges = new TGTextButton(control_frame, "Print changes");
    ResizeFrame(fTB_PrintChanges);
    fTB_PrintChanges->Connect("Clicked()", "ButtonWindow", this, "PrintChanges()");
    control_frame->AddFrame(fTB_PrintChanges, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));

    fTB_Quit = new TGTextButton(control_frame, "Quit");
    ResizeFrame(fTB_Quit);
    fTB_Quit->Connect("Clicked()", "ButtonWindow", this, "Quit()");
    control_frame->AddFrame(fTB_Quit, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
    
    AddFrame(control_frame, new TGLayoutHints(kLHintsExpandX, 5, 5, 0, 5));

    // ---------------------------------------------------------------------------------
    
    TGHorizontalFrame* nav_main_frame = new TGHorizontalFrame(this);
    
    // manual navigation
    TGGroupFrame* nav_man_frame = new TGGroupFrame(nav_main_frame, "Manual navigation", kHorizontalFrame);
    nav_man_frame->SetTitlePos(TGGroupFrame::kLeft);

    fTB_Prev = new TGTextButton(nav_man_frame, "Previous");
    ResizeFrame(fTB_Prev);
    fTB_Prev->SetToolTipText("Go to previous element", 200);
    fTB_Prev->Connect("Clicked()", "ButtonWindow", this, "DoPrev()");
    nav_man_frame->AddFrame(fTB_Prev, new TGLayoutHints(kLHintsLeft, 0, 0, 10, 0));
    
    fTB_Next = new TGTextButton(nav_man_frame, "   Next   ");
    ResizeFrame(fTB_Next);
    fTB_Next->SetToolTipText("Go to next element", 200);
    fTB_Next->Connect("Clicked()", "ButtonWindow", this, "DoNext()");
    nav_man_frame->AddFrame(fTB_Next, new TGLayoutHints(kLHintsLeft, 0, 0, 10, 0));
    
    fTB_Ignore = new TGTextButton(nav_man_frame, "   Ignore   ");
    ResizeFrame(fTB_Ignore);
    fTB_Ignore->SetToolTipText("Go to next element and ignore current one", 200);
    fTB_Ignore->Connect("Clicked()", "ButtonWindow", this, "DoIgnore()");
    nav_man_frame->AddFrame(fTB_Ignore, new TGLayoutHints(kLHintsLeft, 0, 20, 10, 0));

    fTB_Goto = new TGTextButton(nav_man_frame, "Go to");
    ResizeFrame(fTB_Goto);
    fTB_Goto->SetToolTipText("Go to specified element", 200);
    fTB_Goto->Connect("Released()", "ButtonWindow", this, "Goto()");
    nav_man_frame->AddFrame(fTB_Goto, new TGLayoutHints(kLHintsLeft, 0, 0, 10, 0));
    
    fNE_Elem = new TGNumberEntry(nav_man_frame, 0, 3, -1, TGNumberFormat::kNESInteger,
                      TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, 0, 719);
    ResizeFrame(fNE_Elem);
    nav_man_frame->AddFrame(fNE_Elem, new TGLayoutHints(kLHintsLeft, 0, 0, 10, 0));
    
    nav_main_frame->AddFrame(nav_man_frame, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));

    // automatic navigation
    TGGroupFrame* nav_auto_frame = new TGGroupFrame(nav_main_frame, "Automatic navigation", kHorizontalFrame);
    nav_auto_frame->SetTitlePos(TGGroupFrame::kLeft);

    fNE_Delay = new TGNumberEntry(nav_auto_frame, 0.1, 3, -1, TGNumberFormat::kNESRealTwo,
                                  TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, 0.01, 5);
    ResizeFrame(fNE_Delay);
    nav_auto_frame->AddFrame(fNE_Delay, new TGLayoutHints(kLHintsLeft, 0, 5, 10, 0));

    fTB_DoAll = new TGTextButton(nav_auto_frame, "Start");
    ResizeFrame(fTB_DoAll);
    fTB_DoAll->SetToolTipText("Process automatically", 200);
    fTB_DoAll->Connect("Clicked()", "ButtonWindow", this, "DoAll()");
    nav_auto_frame->AddFrame(fTB_DoAll, new TGLayoutHints(kLHintsLeft, 0, 0, 10, 0));

    fTB_Stop = new TGTextButton(nav_auto_frame, "Stop");
    ResizeFrame(fTB_Stop);
    fTB_Stop->SetToolTipText("Stop processing", 200);
    fTB_Stop->Connect("Clicked()", "ButtonWindow", this, "Stop()");
    nav_auto_frame->AddFrame(fTB_Stop, new TGLayoutHints(kLHintsLeft, 0, 0, 10, 0));

    nav_main_frame->AddFrame(nav_auto_frame, new TGLayoutHints(kLHintsLeft, 5, 0, 0, 0));

    AddFrame(nav_main_frame, new TGLayoutHints(kLHintsExpandX, 5, 5, 0, 5));
     
    // window configuration
    Connect("CloseWindow()", "ButtonWindow", this, "Quit()");
    DontCallClose();
    
    // Map all subwindows of main frame
    MapSubwindows();

    // Initialize the layout algorithm
    Resize(GetDefaultSize());
    
    // show window
    MapRaised();

    // move window
    Move(gClient->GetDisplayWidth() - GetDefaultWidth(), 
         gClient->GetDisplayHeight() - GetDefaultHeight() - 30);
}