void hist_to_png_h1(TH1F * h_c, TH1F* h_e, TH1F* h_f, TString saveTitle, TString type_string)
{
  TCanvas *cPNG = new TCanvas(saveTitle,"",700,500);
  TImage *img = TImage::Create();
  char * type = type_string.Data();
  gStyle->SetOptStat(0);
  gPad->SetLogy();
  auto legend = new TLegend(0.7,0.7,0.9,0.9);
  legend->SetTextSize(0.06);
  legend->AddEntry(h_c,"CEMC","l");
  legend->AddEntry(h_e,"EEMC","l");
  legend->AddEntry(h_f,"FEMC","l");
  
  if(strcmp(type,"spatial")==0)
    {  
      h_e->GetXaxis()->SetTitle("Extrapolation distance from cluster [cm]");
      h_e->GetYaxis()->SetTitle("Counts");
    }
  h_e->Draw();
  h_c->Draw("SAME");
  h_f->Draw("SAME");
  legend->Draw();
  img->FromPad(cPNG);
  img->WriteImage(saveTitle);
}
示例#2
0
int CGUIEditWindow::Cut()
{
	if(readonly) return 0;
	if(!text->IsMarked()){
		text->GetCursor()->MoveHome();
		text->SetMarkStart();
		text->GetCursor()->MoveEnd();
		text->GetCursor()->MoveRight();
		text->SetMarkEnd();
	}
	
	Copy();
	text->DeleteSelectedText(); //smazu oznaceny text
	
	if(highlight)
	{//highlightuju
		highlighter->HighlightFromBlock(text->GetCursor()->GetBlock());
		text->GetCursor()->CalcFormat();		
	}
	blttext->BlinkCursor(1);
	SetTextSize();
	ScrollToCursor();
	blttext->SetNeedRecalc();

	changed = 1; ChangedEvent();
	CursorMoved();

	return 1;
}
示例#3
0
LIB_TEXT::LIB_TEXT( LIB_PART * aParent ) :
    LIB_ITEM( LIB_TEXT_T, aParent ),
    EDA_TEXT()
{
    SetTextSize( wxSize( 50, 50 ) );
    m_typeName   = _( "Text" );
    m_rotate     = false;
    m_updateText = false;
}
示例#4
0
int CGUIEditWindow::Redo()
{
	if(readonly) return 0;
		
	text->Redo(highlighter);
	blttext->BlinkCursor(1);
	SetTextSize();
	ScrollToCursor();
	blttext->SetNeedRecalc();

	changed = 1; ChangedEvent();
	CursorMoved();

	return 1;
}
示例#5
0
//prenos dat do editboxu
int CGUIEditWindow::SetParametr(void *value, int type, int size, int which)
{
	char *s;int dels=0;
	int sz=-1;
	switch(which)
	{
	case 0:
		switch(type)
		{
		case dtString:
		case dtChar: //dostal jsem string
			s=(char*)value;
			sz=size;
			break;
		case dtInt: //dostal jsem int
			s  = new char[100]; dels=1;
			_snprintf(s,99,"%i",*(int*)value);
			break;
		case dtDouble: //dostal jsem double
			s  = new char[100]; dels=1;
			_snprintf(s,99,"%.10g",*(double*)value);
			break;
		default:
			return 1;
		}

		text->UnMark();
		text->SetText(s,sz); 
		if(dels) delete[] s;
		text->GetCursor()->MoveTextHome();
		
		if(highlight&&highlighter)
		{
			highlighter->Highlight();
			text->GetCursor()->CalcFormat();
		}

		SetTextSize();
		ScrollToCursor();
		blttext->SetNeedRecalc();

		changed = 1; ChangedEvent();
		CursorMoved();
		break;
	}
	return 1;
}
示例#6
0
int CGUIEditWindow::Paste()
{
	if(readonly) return 0;

	if(text->IsMarked())
		text->DeleteSelectedText(1,1); //smazu oznaceny text	
	text->PasteFromClipboard(multiline,highlighter); //paste&highlight
	blttext->BlinkCursor(1);
	SetTextSize();
	ScrollToCursor();
	blttext->SetNeedRecalc();

	changed = 1; ChangedEvent();
	CursorMoved();

	return 1;
}
void CToolsCtlPanelText::UpdateCalendarTextControls(CAGSymCalendar* pCalendarSym)
{
	CAGSpec* pAGSpec = pCalendarSym->GetActiveSpec();
	if (!pAGSpec)
		return;
	
	// Update the FillType control
	SetFillType(pAGSpec->m_FillType);

	// Update the FillColor control
	SetFillColor(pAGSpec->m_FillColor);

	// Update the FillColor2 control
	SetFillColor2(pAGSpec->m_FillColor2);

	// Update the LineWidth control
	SetLineWidth(pAGSpec->m_LineWidth);

	// Update the LineColor control
	SetLineColor(pAGSpec->m_LineColor);

	// Update the Title control
	//SetTitleText(pCalendarSym->GetActivePanelTitle());

	//UpdateFillCtrls();
	//UpdateLineCtrls();
	ShowHideColors();

	// Update the TextSize control
	SetTextSize(abs(pAGSpec->m_Font.lfHeight));

	// Update the Font control
	LOGFONT& SymFont = pAGSpec->m_Font;
	SetFontControl(&pAGSpec->m_Font, true/*bClearIfBad*/);

	// Update the text style controls
	m_ButtonBold.Check(SymFont.lfWeight != FW_NORMAL);
	m_ButtonItalic.Check(!!SymFont.lfItalic);
	m_ButtonUnderline.Check(!!SymFont.lfUnderline);

	// Update the Vertical adjustment controls
	UpdateTextAlignCtrls(pCalendarSym);
}
void DialogTitle::OnMeasure(
    /* [in] */ Int32 widthMeasureSpec,
    /* [in] */ Int32 heightMeasureSpec)
{
    TextView::OnMeasure(widthMeasureSpec, heightMeasureSpec);

    AutoPtr<ILayout> layout = GetLayout();
    if (layout != NULL) {
        Int32 lineCount;
        layout->GetLineCount(&lineCount);

        if (lineCount > 0) {
            Int32 ellipsisCount;
            layout->GetEllipsisCount(lineCount - 1, &ellipsisCount);

            if (ellipsisCount > 0) {
                SetSingleLine(FALSE);
                SetMaxLines(2);

                AutoPtr<ArrayOf<Int32> > attrIds = ArrayOf<Int32>::Alloc(
                    const_cast<Int32 *>(R::styleable::TextAppearance),
                    ARRAY_SIZE(R::styleable::TextAppearance));
                AutoPtr<ITypedArray> a;
                ASSERT_SUCCEEDED(mContext->ObtainStyledAttributes(
                        NULL, attrIds, R::attr::textAppearanceMedium,
                        R::style::TextAppearance_Medium, (ITypedArray**)&a));

                Int32 textSize;
                a->GetDimensionPixelSize(
                    R::styleable::TextAppearance_textSize, 0, &textSize);

                if (textSize != 0) {
                    // textSize is already expressed in pixels
                    SetTextSize(ITypedValue::COMPLEX_UNIT_PX, textSize);
                }
                a->Recycle();

                TextView::OnMeasure(widthMeasureSpec, heightMeasureSpec);
            }
        }
    }
}
示例#9
0
//prelozene znaky - psani
int CGUIEditWindow::KeyboardChar(UINT ch, UINT state)
{
	if(readonly) return 0;

	if(mainGUI->key_ctrl)
		return 0;

	if(ch==VK_TAB) return 0;
	
	if(isprint(ch)/*||ch==VK_TAB*/)
	{
		CTextCursor *cur=text->GetCursor();
		int insm=-1;
		if(text->IsMarked())
		{
			text->DeleteSelectedText(1,1); //smazu oznaceny text
			insm = cur->GetInsertMode();
			cur->SetInsertMode(0);
		}
		cur->InsertChar(ch); //vlozi znak

		if(insm!=-1)
			cur->SetInsertMode(insm);
		if(highlight)
		{//highligtuju
			highlighter->HighlightFromBlock(cur->GetBlock());
			cur->CalcFormat();		
		}
		blttext->BlinkCursor(1);
		SetTextSize();
		ScrollToCursor();
		blttext->SetNeedRecalc();

		changed = 1; ChangedEvent();
		CursorMoved();
	}
	return 0;
}
示例#10
0
VOID KeyEventProc(PCONSOLE_INFO pdp, KEY_EVENT_RECORD event)
{
#ifdef USE_OLD_CODE
   // this must here gather keystrokes and pass them forward into the
   // opened sentience...
//   PTEXT temp;
	int bOutput = FALSE;
   lprintf( "Entering handle a key event..." );
	Lock( pdp );
   lprintf( "Got the lock, waiting for collection buffer..." );
   if( event.bKeyDown )
   {
      PTEXT key;
      // here is where we evaluate the curent keystroke....

      for( ; event.wRepeatCount; event.wRepeatCount-- )
      {
         int mod = KEYMOD_NORMAL;
         extern PSIKEYDEFINE KeyDefs[];
         if(event.dwControlKeyState& (RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED))
            mod |= KEYMOD_CTRL;
         if(event.dwControlKeyState& (RIGHT_ALT_PRESSED|LEFT_ALT_PRESSED))
            mod |= KEYMOD_ALT;
         if( KeyDefs[event.wVirtualKeyCode].flags & KDF_CAPSKEY )
         {
            if( event.dwControlKeyState & CAPSLOCK_ON )
            {
               if( !(event.dwControlKeyState& SHIFT_PRESSED) )
                  mod |= KEYMOD_SHIFT;
            }
            else
            {
               if( event.dwControlKeyState& SHIFT_PRESSED )
                  mod |= KEYMOD_SHIFT;
            }
         }
         else
            if( event.dwControlKeyState& SHIFT_PRESSED )
               mod |= KEYMOD_SHIFT;
         if( pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bStroke ||
             pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bMacro )
         {
            if( pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bStroke )
            {
               bOutput |= DoStroke(pdp, pdp->Keyboard[event.wVirtualKeyCode][mod].data.stroke);
            }
            else if( pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bMacro )
            {
               if( pdp->common.Owner->pRecord != pdp->Keyboard[event.wVirtualKeyCode][mod].data.macro )
                  InvokeMacro( pdp->common.Owner
                             , pdp->Keyboard[event.wVirtualKeyCode][mod].data.macro
                             , NULL );
               // do macro!!!!!
            }
         }
         else
         {
				if( key = KeyDefs[event.wVirtualKeyCode].op[mod].data.pStroke )
				{
					if( KeyDefs[event.wVirtualKeyCode].op[mod].bFunction )
						bOutput |= ((KeyFunc)key)(pdp);
					else
					{
						bOutput |= DoStroke( pdp, key );
					}
				}
         }
      }
      // call to clear and re-write the current buffer....
      //if( bOutput ) // so we don't output on shift, control, etc...
         //RenderCommandLine( pdp );
   }
   else
   {
      // key up's don't matter like ever...
   }
	Unlock( pdp );
#else
   // this must here gather keystrokes and pass them forward into the
   // opened sentience...
//   PTEXT temp;
   int bOutput = FALSE;
   int mod = KEYMOD_NORMAL;
   if( !pdp ) // not a valid window handle/device path
        return;
   //Log( "Entering keyproc..." );
   EnterCriticalSec( &pdp->Lock );
   //while( LockedExchange( &pdp->common.CommandInfo->CollectionBufferLock, 1 ) )
   //   Sleep(0);
   Log1( "mod = %x", pdp->dwControlKeyState );
   mod = pdp->dwControlKeyState;

   if( KeyDefs[event.wVirtualKeyCode].flags & KDF_CAPSKEY )
   {
      if( event.dwControlKeyState & CAPSLOCK_ON )
      {
         mod ^= KEYMOD_SHIFT;
      }
   }

   if( event.bKeyDown )
   {
      for( ; event.wRepeatCount; event.wRepeatCount-- )
		{
			unsigned char KeyState[256];
			DECLTEXT( key, "                   " );
			GetKeyboardState( KeyState );
			SetTextSize( &key, ToAscii( event.wVirtualKeyCode
											  , event.wVirtualScanCode
											  , KeyState
											  , (unsigned short*)key.data.data
											  , 0 ) );
			KeyPressHandler( pdp, event.wVirtualKeyCode, mod, (PTEXT)&key );
		}
#if 0
      // here is where we evaluate the curent keystroke....
      for( ; event.wRepeatCount; event.wRepeatCount-- )
		{

         // check current keyboard override...
         if( pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bStroke ||
             pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bMacro )
         {
            if( pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bStroke )
            {
               bOutput |= DoStroke(pdp, pdp->Keyboard[event.wVirtualKeyCode][mod].data.stroke);
            }
            else if( pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bMacro )
            {
               if( pdp->common.Owner->pRecord != pdp->Keyboard[event.wVirtualKeyCode][mod].data.macro )
                  InvokeMacro( pdp->common.Owner
                             , pdp->Keyboard[event.wVirtualKeyCode][mod].data.macro
                             , NULL );
            }
         }
         else // key was not overridden
         {
            int result;
            Log1( "Keyfunc = %d", KeyDefs[event.wVirtualKeyCode].op[mod].bFunction );
            switch( KeyDefs[event.wVirtualKeyCode].op[mod].bFunction )
            {
            case KEYDATA_DEFINED:
               Log( "Key data_defined" );
               bOutput |= DoStroke( pdp, (PTEXT)&KeyDefs[event.wVirtualKeyCode].op[mod].data.pStroke );
                    result = UPDATE_NOTHING; // unsure about this - recently added.
                    // well it would appear that the stroke results in whether to update
                    // the command prompt or not.
                break;
            case KEYDATA:
               {
                  char KeyState[256];
                  DECLTEXT( key, "                   " );
                  GetKeyboardState( KeyState );
                  SetTextSize( &key, ToAscii( event.wVirtualKeyCode
                                            , event.wVirtualScanCode
                                            , KeyState
                                            , (void*)key.data.data
                                            , 0 ) );
                  if( GetTextSize( (PTEXT)&key ) )
                     bOutput |= DoStroke( pdp, (PTEXT)&key );
                  result = UPDATE_NOTHING; // already taken care of?!
               }
               break;
            case COMMANDKEY:
               result = KeyDefs[event.wVirtualKeyCode].op[mod].data.CommandKey( pdp->common.CommandInfo );
               break;
            case HISTORYKEY:
               result = KeyDefs[event.wVirtualKeyCode].op[mod].data.HistoryKey( pdp->pHistoryDisplay );
               break;
            case CONTROLKEY:
               KeyDefs[event.wVirtualKeyCode].op[mod].data.ControlKey( &pdp->dwControlKeyState, TRUE );
               result = UPDATE_NOTHING;
               break;
            case SPECIALKEY:
               result = KeyDefs[event.wVirtualKeyCode].op[mod].data.SpecialKey( pdp );
               break;
            }
            switch( result )
            {
            case UPDATE_COMMAND:
               bOutput = TRUE;
               break;
				case UPDATE_HISTORY:
					if( UpdateHistory( pdp ) )
						DoRenderHistory(pdp, TRUE);
						DoRenderHistory(pdp, FALSE);

					break;
				case UPDATE_DISPLAY:
					ChildCalculate( pdp );
					break;
            }
         }
      }
      //if( bOutput )
		//   RenderCommandLine( pdp );
#endif
   }
   else
   {
    // flag is redundant for CONTOLKEY type...
      // key up's only matter if key is upaction flaged...
    switch( KeyDefs[event.wVirtualKeyCode].op[mod].bFunction )
    {
        case CONTROLKEY:
            KeyDefs[event.wVirtualKeyCode].op[mod].data.ControlKey( &pdp->dwControlKeyState, FALSE );
            break;
        }
   }
   LeaveCriticalSec( &pdp->Lock );
   //lprintf( "Left critical section on wincon." );
#endif
}
int plot_true_false_positive()
{

  /*----------------------------------------- */
  /* Add Cuts Here                            */
  /*                                          */
  /* add_CEMC_cut(float_1, float_2)           */
  /*   Cut 1 : E/p  > float_1                 */
  /*   Cut 2 : prob > float_2                 */
  /*   (if float_#=0, Cut # is not applied    */
  /* add_EEMC_cut(float_1)                    */
  /*   Cut 1 : E/True E > float_1             */
  /* add_FEMC_cut(float_1)                    */
  /*   Cut 1 : E/True E > float_1             */
  /* ---------------------------------------- */

  add_CEMC_Cut(0.807,0.02);
  add_CEMC_Cut(0.703,0.02);
  
  add_EEMC_Cut(0.703);
  add_EEMC_Cut(0.807);
  add_EEMC_Cut(0.95);

  add_FEMC_Cut(0.703);
  add_FEMC_Cut(0.807);
  add_FEMC_Cut(0.95);

  /* ---------------------------------------- */

  // Momentums //
  vector< float > v_momenta;
  v_momenta.push_back(1.0);
  v_momenta.push_back(2.0);
  v_momenta.push_back(5.0);
  v_momenta.push_back(10.0);
  v_momenta.push_back(20.0);
  
  // Marker Styles //
  vector< int > v_styles;
  v_styles.push_back(20);
  v_styles.push_back(24);
  v_styles.push_back(21);
  v_styles.push_back(25);
  v_styles.push_back(22);
  v_styles.push_back(26);
  v_styles.push_back(23);
  v_styles.push_back(27);
  v_styles.push_back(34);
  v_styles.push_back(28);
  v_styles.push_back(29);
  v_styles.push_back(30);
 
  /* Loading Macros */

  gROOT->LoadMacro("efficiency_purity_analysisMacro.C");
  gROOT->LoadMacro("/sphenix/user/gregtom3/SBU/research/macros/macros/sPHENIXStyle/sPhenixStyle.C");
  SetsPhenixStyle();
  
  /* Useful local variables */
  float v_rate_tp; //true positive rate value holder
  float v_rate_fp; //false positive rate value holder

  //------------------------------------------------------------//
  //--------                CEMC Plots                  --------//
  //------------------------------------------------------------//

  //CEMC Graph Initialization//
  const int size_C=2*v_cuts_CEMC.size(); //T.P & F.P graph per cut 
  TCanvas *c_CEMC = new TCanvas("cc","cc",1000,600);
  TGraph *graphs_CEMC[size_C]; //Array of TGraph pointers
  auto legend_CEMC_t = new TLegend(0.51,0.2,1.0,0.9); //Legend
  auto legend_CEMC_f = new TLegend(0.51,0.2,1.0,0.9); //Legend

  legend_CEMC_t->SetTextSize(0.06);
  legend_CEMC_f->SetTextSize(0.06);
  // Create the CEMC TGraphs ( 2 per cut )//
  for(unsigned idx_cut=0;idx_cut < v_cuts_CEMC.size(); idx_cut++)
    /* loop over cuts */
    {
      // Index for each graph in TGraph vector //
      int idx_tp=idx_cut*2;
      int idx_fp=idx_cut*2+1;
      
      // Create new TGraphs_CEMC //
      graphs_CEMC[idx_tp]=new TGraph(v_momenta.size());
      graphs_CEMC[idx_fp]=new TGraph(v_momenta.size());
      
      // Clear true positive and false positive //
      v_rate_tp = v_rate_fp = 0.0;

      // Set Points in TGraph for True Positive and False Positive per momenta//
      for ( unsigned idx_p = 0; idx_p < v_momenta.size(); idx_p++ )
	{
	  v_rate_tp=get_true_positive("C",v_cuts_CEMC.at(idx_cut),v_momenta.at(idx_p));
	  v_rate_fp=get_false_positive("C",v_cuts_CEMC.at(idx_cut),v_momenta.at(idx_p));
	  graphs_CEMC[idx_tp]->SetPoint(idx_p,v_momenta[idx_p],v_rate_tp);
	  graphs_CEMC[idx_fp]->SetPoint(idx_p,v_momenta[idx_p],v_rate_fp);	
	}
      
      // Tweak Graph Style //
      graphs_CEMC[idx_tp]->SetMarkerColor(kGreen+2);
      graphs_CEMC[idx_fp]->SetMarkerColor(kRed+2);
      
      graphs_CEMC[idx_tp]->SetLineColor(graphs_CEMC[idx_tp]->GetMarkerColor());
      graphs_CEMC[idx_fp]->SetLineColor(graphs_CEMC[idx_fp]->GetMarkerColor());

      graphs_CEMC[idx_tp]->SetMarkerStyle(v_styles.at(idx_cut));
      graphs_CEMC[idx_fp]->SetMarkerStyle(v_styles.at(idx_cut));
      
      graphs_CEMC[idx_tp]->SetMarkerSize(1); // Possibly too large? //
      graphs_CEMC[idx_fp]->SetMarkerSize(1);

      graphs_CEMC[idx_tp]->SetTitle("");
      graphs_CEMC[idx_fp]->SetTitle("");
      
      

      legend_CEMC_t->AddEntry(graphs_CEMC[idx_tp],v_cuts_CEMC_short.at(idx_cut)+" True Positive","P");
      legend_CEMC_f->AddEntry(graphs_CEMC[idx_fp],v_cuts_CEMC_short.at(idx_cut)+ " False Positive","P");
    }
  
  // Draw all graphs on same canvas (CEMC) //
  c_CEMC->Divide(1,2);
  for(int i = 0; i<size_C; i++)
    {
      if(i==0) 
	{
	  c_CEMC->cd(1);
	  //gPad->SetBottomMargin(0.2);
	  gPad->SetRightMargin(0.5);
	  graphs_CEMC[0]->Draw("PA");
	  graphs_CEMC[0]->GetXaxis()->SetTitle("True Momentum (GeV)");
	  graphs_CEMC[0]->GetYaxis()->SetRangeUser(0.7,1.0);
	  graphs_CEMC[0]->GetYaxis()->SetTitle("Rate");
	}
      else if(i==1)
	{
	  c_CEMC->cd(2);
	  //gPad->SetTopMargin(0.2);
	  gPad->SetRightMargin(0.5);
	  graphs_CEMC[1]->GetXaxis()->SetTitle("True Momentum (GeV)");
	  graphs_CEMC[1]->GetYaxis()->SetRangeUser(-0.01,0.11);
	  graphs_CEMC[1]->GetYaxis()->SetTitle("Rate");
	  graphs_CEMC[1]->Draw("PA");
	}
      else if (i%2==0)
	{
	  c_CEMC->cd(1);
	  graphs_CEMC[i]->Draw("PSame");
	}
      else
	{
	  c_CEMC->cd(2);
	  graphs_CEMC[i]->Draw("P");
	}
      
    }
  c_CEMC->cd(1);
  legend_CEMC_t->Draw();
  c_CEMC->cd(2);
  legend_CEMC_f->Draw();

  //------------------------------------------------------------//
  //--------                EEMC Plots                  --------//
  //------------------------------------------------------------//


  // Create EEMC Graphs (2 per cut) //
   const int size_E=v_cuts_EEMC.size(); //T.P & F.P graph per cut
   TCanvas *c_EEMC = new TCanvas("ce","ce",1000,600);
   TGraph *graphs_EEMC[size_E]; //Array of TGraph pointers
   auto legend_EEMC_t = new TLegend(0.51,0.2,1,0.9); //Legend
   auto legend_EEMC_f = new TLegend(0.51,0.2,1,0.9); //Legend
   
   legend_EEMC_t->SetTextSize(0.06);
   legend_EEMC_f->SetTextSize(0.06);
   for(unsigned idx_cut=0;idx_cut < v_cuts_EEMC.size()/2; idx_cut++)
    // loop over cuts //
    {
      // Index for each graph in TGraph vector //
      int idx_tp=idx_cut*2;
      int idx_fp=idx_cut*2+1;
      
      // Create new TGraphs //
      graphs_EEMC[idx_tp]=new TGraph(v_momenta.size());
      graphs_EEMC[idx_fp]=new TGraph(v_momenta.size());

      // Clear true positive and false positive //
      v_rate_tp = v_rate_fp = 0.0;
      
      // Fill data points for True Positve and False Positive Plot //
      for ( unsigned idx_p = 0; idx_p < v_momenta.size(); idx_p++ )
	{
	  TString cut = v_cuts_EEMC.at(idx_cut*2)+ getCut(v_momenta.at(idx_p)) + v_cuts_EEMC.at(idx_cut*2+1); 
	  v_rate_tp=get_true_positive("E",cut,v_momenta.at(idx_p));
	  v_rate_fp=get_false_positive("E",cut,v_momenta.at(idx_p));	  
	  graphs_EEMC[idx_tp]->SetPoint(idx_p,v_momenta[idx_p],v_rate_tp);
	  graphs_EEMC[idx_fp]->SetPoint(idx_p,v_momenta[idx_p],v_rate_fp);	  
	}
      
      graphs_EEMC[idx_tp]->SetMarkerColor(kGreen+2);
      graphs_EEMC[idx_fp]->SetMarkerColor(kRed+2);

      graphs_EEMC[idx_tp]->SetLineColor(graphs_EEMC[idx_tp]->GetMarkerColor());
      graphs_EEMC[idx_fp]->SetLineColor(graphs_EEMC[idx_fp]->GetMarkerColor());

      graphs_EEMC[idx_tp]->SetMarkerStyle(v_styles.at(idx_cut));
      graphs_EEMC[idx_fp]->SetMarkerStyle(v_styles.at(idx_cut));
      
      graphs_EEMC[idx_tp]->SetMarkerSize(1); // Possibly too large? //
      graphs_EEMC[idx_fp]->SetMarkerSize(1);

      graphs_EEMC[idx_tp]->SetTitle("");
      graphs_EEMC[idx_fp]->SetTitle("");
      
      legend_EEMC_t->AddEntry(graphs_EEMC[idx_tp],v_cuts_EEMC_short.at(idx_cut)+" True Positive","P");
      legend_EEMC_f->AddEntry(graphs_EEMC[idx_tp],v_cuts_EEMC_short.at(idx_cut)+" False Positive","P");
    }
    // Draw all graphs on same canvas (EEMC) //
   c_EEMC->Divide(1,2);
   for(int i = 0; i<size_E; i++)
     {
       if(i==0) 
	 {
	   c_EEMC->cd(1);
	   gPad->SetRightMargin(0.5);
	   graphs_EEMC[0]->Draw("PA");
	   graphs_EEMC[0]->GetXaxis()->SetTitle("True Momentum (GeV)");
	   graphs_EEMC[0]->GetYaxis()->SetRangeUser(0.7,1.0);
	   graphs_EEMC[0]->GetYaxis()->SetTitle("Rate");
	 }
       else if (i==1)
	 {
	   c_EEMC->cd(2);
	   gPad->SetRightMargin(0.5);
	   graphs_EEMC[1]->Draw("PA");
	   graphs_EEMC[1]->GetXaxis()->SetTitle("True Momentum (GeV)");
	   graphs_EEMC[1]->GetYaxis()->SetRangeUser(-0.01,0.11);
	   graphs_EEMC[1]->GetYaxis()->SetTitle("Rate"); 
	 }
       else if (i%2==0)
	 {
	   c_EEMC->cd(1);
	   graphs_EEMC[i]->Draw("PSame");
	 }
       else
	 {
	   c_EEMC->cd(2);
	   graphs_EEMC[i]->Draw("P");
	 }
     }
   c_EEMC->cd(1);
   legend_EEMC_t->Draw();
   c_EEMC->cd(2);
   legend_EEMC_f->Draw();

   //------------------------------------------------------------//
   //--------                FEMC Plots                  --------//
   //------------------------------------------------------------//
  
   
   // Create FEMC Graphs (2 per cut) //
   const int size_F=v_cuts_FEMC.size(); //T.P & F.P graph per cut
   TCanvas *c_FEMC = new TCanvas("cf","cf",1000,600);
   TGraph *graphs_FEMC[size_F]; //Array of TGraph pointers
   auto legend_FEMC_t = new TLegend(0.51,0.2,1.0,0.9); //Legend
   auto legend_FEMC_f = new TLegend(0.51,0.2,1.0,0.9); //Legend
   
   legend_FEMC_t->SetTextSize(0.06);
   legend_FEMC_f->SetTextSize(0.06);
  
   for(unsigned idx_cut=0;idx_cut < v_cuts_FEMC.size()/2; idx_cut++)
    // loop over cuts //
     {
       // Index for each graph in TGraph vector //
      int idx_tp=idx_cut*2;
      int idx_fp=idx_cut*2+1;
      
      // Create new TGraphs //
      graphs_FEMC[idx_tp]=new TGraph(v_momenta.size());
      graphs_FEMC[idx_fp]=new TGraph(v_momenta.size());
     
      // Clear true positive and false positive //
      v_rate_tp = v_rate_fp = 0.0;
      
      // Fill data points for True Positve and False Positive Plot //
      for ( unsigned idx_p = 0; idx_p < v_momenta.size(); idx_p++ )
	{
	  TString cut = v_cuts_FEMC.at(idx_cut*2)+ getCut(v_momenta.at(idx_p)) + v_cuts_FEMC.at(idx_cut*2+1); 
	  v_rate_tp=get_true_positive("F",cut,v_momenta.at(idx_p));
	  v_rate_fp=get_false_positive("F",cut,v_momenta.at(idx_p));
	  graphs_FEMC[idx_tp]->SetPoint(idx_p,v_momenta[idx_p],v_rate_tp);
	  graphs_FEMC[idx_fp]->SetPoint(idx_p,v_momenta[idx_p],v_rate_fp);	  
	}
      
      graphs_FEMC[idx_tp]->SetMarkerColor(kGreen+2);
      graphs_FEMC[idx_fp]->SetMarkerColor(kRed+2);

      graphs_FEMC[idx_tp]->SetLineColor(graphs_FEMC[idx_tp]->GetMarkerColor());
      graphs_FEMC[idx_fp]->SetLineColor(graphs_FEMC[idx_fp]->GetMarkerColor());

      graphs_FEMC[idx_tp]->SetMarkerStyle(v_styles.at(idx_cut));
      graphs_FEMC[idx_fp]->SetMarkerStyle(v_styles.at(idx_cut));
      
      graphs_FEMC[idx_tp]->SetMarkerSize(1); // Possibly too large? //
      graphs_FEMC[idx_fp]->SetMarkerSize(1);

      graphs_FEMC[idx_tp]->SetTitle("");
      graphs_FEMC[idx_fp]->SetTitle("");
      
      legend_FEMC_t->AddEntry(graphs_FEMC[idx_tp],v_cuts_FEMC_short.at(idx_cut)+" True Positive","P");
      legend_FEMC_f->AddEntry(graphs_FEMC[idx_fp],v_cuts_FEMC_short.at(idx_cut)+ " False Positive","P");
    }
   
   // Draw all graphs on same canvas (FEMC) //
   c_FEMC->Divide(1,2);
   for(int i = 0; i<size_F; i++)
     {
        if(i==0) 
	{
	  c_FEMC->cd(1);
	  //gPad->SetBottomMargin(0.2);
	  gPad->SetRightMargin(0.5);
	  graphs_FEMC[0]->Draw("PA");
	  graphs_FEMC[0]->GetXaxis()->SetTitle("True Momentum (GeV)");
	  graphs_FEMC[0]->GetYaxis()->SetRangeUser(0.7,1.0);
	  graphs_FEMC[0]->GetYaxis()->SetTitle("Rate");
	}
      else if(i==1)
	{
	  c_FEMC->cd(2);
	  //gPad->SetTopMargin(0.2);
	  gPad->SetRightMargin(0.5);
	  graphs_FEMC[1]->GetXaxis()->SetTitle("True Momentum (GeV)");
	  graphs_FEMC[1]->GetYaxis()->SetRangeUser(-0.01,0.11);
	  graphs_FEMC[1]->GetYaxis()->SetTitle("Rate");
	  graphs_FEMC[1]->Draw("PA");
	}
      else if (i%2==0)
	{
	  c_FEMC->cd(1);
	  graphs_FEMC[i]->Draw("PSame");
	}
      else
	{
	  c_FEMC->cd(2);
	  graphs_FEMC[i]->Draw("PSame");
	}
     }
   c_FEMC->cd(1);
   legend_FEMC_t->Draw();
   c_FEMC->cd(2);
   legend_FEMC_f->Draw();
   
  return 0;
}
示例#12
0
CORE_PROC( PTEXT, GatherLineEx )( PTEXT *pOutput, INDEX *pIndex, int bInsert, int bSaveCR, int bData, PTEXT pInput )
// if data - assume data is coming from a preformatted source
// otherwise use escape as command entry and clear buffer...
{
	// this routine should be used to process user type character
	// input into a legible line buffer....
	// results in a complete line....
	// the line returned must be used - the output buffer
	// is an accumulator and will contain any partial input buffer
	// which remaineder if an EOL sequence was found....

	// build line in buffer using standard console
	// behavior... 

	INDEX pos
       , len = 0
       , size
       , maxlen = 0;
	PTEXT pReturn = NULL;
	PTEXT pDelete = NULL;
	TEXTCHAR character;
	TEXTSTR output;

	if( !pOutput ) // must supply a holder for partial collection...
		return NULL;

	if( !pInput ) // nothing new input - just using previous collection...
	{
		if( *pOutput )
		{
			// use prior partial as new input....
			pInput = *pOutput;
			pDelete = pInput; // this is never deleted if we use prior...
			SetStart( pInput );
			*pOutput = NULL;
		}
		else
			return NULL;
	}
	// probably first pass of gathering...
	if( !*pOutput )
	{
		*pOutput = SegCreate( BUILD_LINE_OUTPUT_SIZE );
		if( pIndex )
			*pIndex = 0;
		SetTextSize( *pOutput, 0 );
		output = GetText( *pOutput );
		len = 0;
	}
	else if( pIndex )
	{
		output = GetText( *pOutput );
		len = *pIndex;
		if( (*pOutput)->data.size != len )
		{
			if( bInsert )
			{
				// creates a new segment inbetween here.....
				*pOutput = SplitLine( *pOutput, *pIndex );
				output = GetText( *pOutput );
				len = *pIndex = GetTextSize( *pOutput );
			}
			else
			{
				maxlen = (*pOutput)->data.size;
			}
		}
	}
	else
	{
		output = GetText( *pOutput );
		len = GetTextSize( *pOutput );
	}

	while( pInput )
	{
		size = GetTextSize( pInput );
		for( pos = 0; pos < size; pos++ )
		{
			switch( character = GetText( pInput )[pos] )
			{
			case '\x1b':
				if( !bData )
				{
					SetEnd( *pOutput );
					SetStart( *pOutput )
					{
						SetTextSize( *pOutput, 0 );
					}
					SetTextSize( *pOutput, 0 );
					output = GetText( *pOutput );
					len = 0;
				}
				else
					goto defaultcase;
				break;
			case '\x7f': // handle unix type delete too ? perhaps...
				if( !bInsert )
				{
					PTEXT pNext;
					// this will slide from the middle to the end...
					// if bInsert - then prior to entrying this switch
					// the data was split and THIS segment is set to zero.
					pNext = *pOutput;
					if( len != (maxlen = GetTextSize( *pOutput )) )
					{
						MemCpy( output + len, output+len+1, maxlen - len );
						SetTextSize( *pOutput, --maxlen );
					}
					else
					{
						PTEXT pDel;
						pNext = *pOutput;
						do {
							pDel = pNext;
							pNext = NEXTLINE( pNext );
							if( pDel != *pOutput )
							{
								SegGrab( pDel );
								LineRelease( pDel );
							}
						} while( pNext && !GetTextSize( pNext ) );
						if( pNext )
						{
							size_t len2;
							output = GetText( pNext );
							len2 = GetTextSize( pNext ) - 1;
							*pOutput = pNext;
							len = 0;
							MemCpy( output, output+1, len2 );
							SetTextSize( pNext, len2 );
						}
					}
				}
				else // was insert is either at end....
				{
					// I dunno perform sliding delete operation...
					// must refresh the output string....
					{
						PTEXT pNext, pDel;
						pNext = *pOutput;
						do {
							pDel = pNext;
							pNext = NEXTLINE( pNext );
							if( pDel != *pOutput )
							{
								SegGrab( pDel );
								LineRelease( pDel );
							}
						} while( pNext && !GetTextSize( pNext ) );
						if( pNext )
						{
							size_t len2;
							TEXTCHAR *data;
							data = GetText( pNext );
							MemCpy( data, data+1, len2 = (GetTextSize( pNext ) - 1 ));
							SetTextSize( pNext, len2 );
						}
					}
				}
				break;
			case '\b':
				/* perhaps consider using split for backspace in a line...*/
				if( !bInsert )
				{
					PTEXT pNext;
					size_t maxlen;
					// this will slide from the middle to the end...
					// if bInsert - then prior to entrying this switch
					// the data was split and THIS segment is set to zero.
					pNext = *pOutput;
					maxlen = GetTextSize( *pOutput );
					while( !maxlen && PRIORLINE( *pOutput ) )
					{
						*pOutput = PRIORLINE( *pOutput );
						len = maxlen = GetTextSize( *pOutput );
					}
					if( maxlen )
					{
						if( len != maxlen )
						{
							size_t sz;
							sz = maxlen - len;
							MemCpy( output + len - 1, output + len, sz );
							SetTextSize( *pOutput, maxlen - 1 );
							len--;
						}
						else
						{
							SetTextSize( *pOutput, --len );
						}
					}
				}
				else // was insert is either at end....
				{
					if( len )
					{
						SetTextSize( *pOutput, --len );
					}
					else
					{
						if( PRIORLINE( *pOutput ) )
						{
							*pOutput = PRIORLINE( *pOutput );
							len = GetTextSize( *pOutput );
						}

						if( len )
							SetTextSize( *pOutput, --len );
					}
				}
				break;
			case '\r': // ignore this character...
				if( !bSaveCR )
					break;
				// falls through .. past this and saves the return...
				if(0)
			case '\n':
				if( !pReturn )
				{
					// transfer *pOutput to pReturn....
					pReturn = *pOutput;
					SetEnd( pReturn );
					output = GetText( pReturn );
					len = GetTextSize( pReturn );
					output[len] = character;
					SetTextSize( pReturn, ++len );
					// begin next collection in case more data is in the input...
					*pOutput = SegCreate( BUILD_LINE_OUTPUT_SIZE );
					SetTextSize( *pOutput, 0 );
					output = GetText( *pOutput );
					len = 0;
					break;
				}
				// store carriage return... 
			default:
    defaultcase:
				output[len++] = character;

				if( (maxlen && len == maxlen ) ||
                len == BUILD_LINE_OUTPUT_SIZE )
				{
					PTEXT pTemp;
					SetTextSize( *pOutput, len );
					if( !NEXTLINE( *pOutput ) )
					{
						SegAppend( *pOutput, pTemp = SegCreate( BUILD_LINE_OUTPUT_SIZE ) );
						SetTextSize( pTemp, 0 );
					}
					else
					{
						pTemp = NEXTLINE( *pOutput );
						maxlen = GetTextSize( pTemp );
					}
					*pOutput = pTemp;
					output = GetText( *pOutput );
					len = 0;
				}
				else
				{
					if( bInsert ) // insertion happens at end of segment
                             // and the segment is broken...
					{
						if( !pIndex || ( len > *pIndex ) )
							SetTextSize( *pOutput, len );
					}
					else
						if( len > GetTextSize( *pOutput ) )
						{
							SetTextSize( *pOutput, len );
						}
				}

				break;
			}
		}
示例#13
0
void CToolsCtlPanelText::UpdateTextControls(CAGText* pText)
{
	scTypeSpecList tsList;
	pText->GetSelTSList(tsList);
	int nNumItems = tsList.NumItems();
	if (!nNumItems)
		return;

	CAGSpec* pAGSpec = (CAGSpec*)(tsList[0].ptr());

	LOGFONT SymFont = pAGSpec->m_Font;
	int SymTextSize = abs(pAGSpec->m_Font.lfHeight);
	FillType Fill = pAGSpec->m_FillType;
	COLORREF FillColor = pAGSpec->m_FillColor;
	COLORREF FillColor2 = pAGSpec->m_FillColor2;
	int LineWidth = pAGSpec->m_LineWidth;
	COLORREF LineColor = pAGSpec->m_LineColor;
	bool bSameFont = true;
	bool bSameBold = true;
	bool bSameItalic = true;
	bool bSameUnderline = true;
	bool bSameTextSize = true;
	bool bSameFillType = true;
	bool bSameFillColor = true;
	bool bSameFillColor2 = true;
	bool bSameLineWidth = true;
	bool bSameLineColor = true;
	
	for (int i = 1; i < nNumItems; i++)
	{
		pAGSpec = (CAGSpec*)(tsList[i].ptr());
		if (lstrcmp(SymFont.lfFaceName, pAGSpec->m_Font.lfFaceName))
			bSameFont = false;

		if (SymFont.lfWeight != pAGSpec->m_Font.lfWeight)
			bSameBold = false;

		if (!SymFont.lfItalic != !pAGSpec->m_Font.lfItalic)
			bSameItalic = false;

		if (!SymFont.lfUnderline != !pAGSpec->m_Font.lfUnderline)
			bSameUnderline = false;

		int nTextSize = abs(pAGSpec->m_Font.lfHeight);
		if (SymTextSize != nTextSize)
			bSameTextSize = false;

		if (Fill != pAGSpec->m_FillType)
			bSameFillType = false;

		if (FillColor != pAGSpec->m_FillColor)
			bSameFillColor = false;

		if (FillColor2 != pAGSpec->m_FillColor2)
			bSameFillColor2 = false;

		if (LineWidth != pAGSpec->m_LineWidth)
			bSameLineWidth = false;

		if (LineColor != pAGSpec->m_LineColor)
			bSameLineColor = false;
	}

	// Update the FillType control
	if (!bSameFillType)
		Fill = (FillType)-1;
	SetFillType(Fill);

	// Update the FillColor control
	if (!bSameFillColor)
		FillColor = CLR_NONE;
	SetFillColor(FillColor);

	// Update the FillColor2 control
	if (!bSameFillColor2)
		FillColor2 = CLR_NONE;
	SetFillColor2(FillColor2);

	// Update the LineWidth control
	if (!bSameLineWidth)
		LineWidth = -999;
	SetLineWidth(LineWidth);

	// Update the LineColor control
	if (!bSameLineColor)
		LineColor = CLR_NONE;
	SetLineColor(LineColor);

	// Update the Text Control
	//SetTitleText("Text");

	//UpdateFillCtrls();
	//UpdateLineCtrls();
	ShowHideColors();

	// Update the TextSize control
	if (!bSameTextSize)
		SymTextSize = -1;
	SetTextSize(SymTextSize);

	// Update the Font control
	LOGFONT* pFont = &SymFont;
	if (!bSameFont)
		pFont = NULL;
	SetFontControl(pFont, true/*bClearIfBad*/);

	// Update the text style controls
	m_ButtonBold.Check(bSameBold ? SymFont.lfWeight != FW_NORMAL : false);
	m_ButtonItalic.Check(bSameItalic ? !!SymFont.lfItalic : false);
	m_ButtonUnderline.Check(bSameUnderline ? !!SymFont.lfUnderline : false);

	// Update the Vertical adjustment controls
	eVertJust SpecVertJust = pText->GetVertJust();
	m_ButtonTop.Check(SpecVertJust == eVertTop);
	m_ButtonMiddle.Check(SpecVertJust == eVertCentered);
	m_ButtonBottom.Check(SpecVertJust == eVertBottom);

	// Get the spec to determine Horizontal alignment
	scTypeSpecList tsListPara;
	pText->GetSelParaTSList(tsListPara);
	nNumItems = tsListPara.NumItems();
	pAGSpec = (CAGSpec*)(tsListPara[0].ptr());

	// Update the Horizontal adjustment controls
	eTSJust SpecHorzJust = pAGSpec->m_HorzJust;
	for (i = 1; i < nNumItems; i++)
	{
		pAGSpec = (CAGSpec*)(tsListPara[i].ptr());
		if (SpecHorzJust != pAGSpec->m_HorzJust)
		{
			SpecHorzJust = eNoRag;
			break;
		}
	}

	m_ButtonLeft.Check(SpecHorzJust == eFlushLeft);
	m_ButtonCenter.Check(SpecHorzJust == eRagCentered);
	m_ButtonRight.Check(SpecHorzJust == eFlushRight);
}
示例#14
0
//intiace - vola se ze vsech konstruktoru
void CGUIEditWindow::InitEditWindow(float _x, float _y, float _sx, float _sy, CDXFont *dxfont, int textColor, int bgColor, int wordwrap,int noscrollbars, int _multiline, int xmargin, int ymargin, char *title_text, CGUIRectHost *_icon, UINT resizer_color)
{
	RemoveFromTrash(); //kvuli vyjimkam - viz. GUI

	highlight = 0; //bez highlitovani
	highlighter = 0;

	selectonfocus = 0;
	changed = 0;

	mousesel=0; //mysi se ted nic neoznacuje

	SetAvailableEvents(availableEvents,numEvents); //nastavi eventy

	multiline = _multiline; //viceradkovy editor?

	defaultfont=0; //defaultni font

	allowtab = 0; //zakazu psat tab

	readonly = 0; //neni readonly

	if(title_text)
	{	//pridam titulek, ikonu, resizery a scrolbary

		AddResizers(resizer_color,styleSet->Get("Resizers")); //pridam resizery
		AddTitle(title_text,_icon,STD_TITLE_HEIGHT); //pridam titulek

		//nastavi velikost viewportu
		CGUIStyle &style = *(styleSet->Get("Resizers"));
		SetViewPortBackWnd(style[1], style[0]+STD_TITLE_HEIGHT, _sx - 2*style[1], _sy - 2*style[0]-STD_TITLE_HEIGHT);

		//nastavi limity velikosti
		SetLimitSizes(4*STD_TITLE_HEIGHT,3*STD_SCROLLBAR_WIDTH+STD_TITLE_HEIGHT+2*style[0]);

		if(!noscrollbars)
		{
			//pridam vertikalni scrolbar
			CGUIScrollBar* dual = AddSimpleScrollbar(Vertical, sx-style[1]-STD_SCROLLBAR_WIDTH, style[0]+STD_TITLE_HEIGHT, STD_SCROLLBAR_WIDTH, sy - 2*style[0]-STD_TITLE_HEIGHT, STD_SCROLLBAR_SHIFT, 0, STD_SCROLLBAR_SLIDER_RESIZE,0,0,0);

			if(!wordwrap) //budu zalamovat radky?
			{
				//nebudu - pridam horizontalni scrolbar
				AddSimpleScrollbar(Horizontal, style[1], sy-style[0]-STD_SCROLLBAR_WIDTH, STD_SCROLLBAR_WIDTH, sx - 2*style[1], STD_SCROLLBAR_SHIFT, 0, STD_SCROLLBAR_SLIDER_RESIZE,dual,0,0);
			}
		}

	}else{
		//bez titulku, ramecku
		if(!noscrollbars)
		{
			//pridam vertikalni scrolbar
			CGUIScrollBar* dual = AddSimpleScrollbar(Vertical, sx-STD_SCROLLBAR_WIDTH, 0, STD_SCROLLBAR_WIDTH, sy, STD_SCROLLBAR_SHIFT, 0, STD_SCROLLBAR_SLIDER_RESIZE,0,0,0);

			if(!wordwrap) //budu zalamovat radky?
			{
				//nebudu - pridam horizontalni scrolbar
				AddSimpleScrollbar(Horizontal, 0, sy-STD_SCROLLBAR_WIDTH, STD_SCROLLBAR_WIDTH, sx, STD_SCROLLBAR_SHIFT, 0, STD_SCROLLBAR_SLIDER_RESIZE,dual,0,0);
			}
		}
	}

	//chci dostaveat zpravy od mysi a timeru
	MsgAcceptConsume(MsgMouseL|MsgMouseOver);
	MsgAcceptConsume(MsgTimer);

	text = NULL;
	blttext = NULL;

	focused=0; //nejsem focusovany

	if(!dxfont)
	{   //neni zadam defaultni font
		dxfont = (CDXFont*) RefMgr->Find(DEFAULT_EDITFONT); //najdu defaultfont
		if(!dxfont)
		{
			//chyba - font neexistuje
			throw CExc(eGUI,E_BAD_ARGUMENTS,"Font not exist!");
		}
	}

	dxfont->AddRef(); //zvysim pocet referenci
	defaultfont = dxfont;

	text = new CFormatedText(dxfont,textColor,wordwrap); //vytvori formatovany text

	CTextBlock *b;
	b = new CTextBlock("");
	text->AddTextBlockToEnd(b); //pridam jeden prazdny blok
	
	blttext = new CBltFormatedText(text,xmargin,ymargin); //vytvori zobrazovac formatovaneho textu

	back->AddChild(blttext); //pridam zobrazovac dovnitr okna

	text->CreateCursor(); //vytvori textovy kurzor
	blttext->SetCursor(1);

	if(_sy<0) //pokud _sy<0 -> spocitam vysku editboxu
	{
		_sy = (float)blttext->CmpEditBoxHeight();
		Resize(_sx,_sy);
	}

	float xx,yy;
	GetVPSize(xx,yy); //zjisti velikost viewportu
	blttext->SetWidth((int)xx); //nastavi sirku textu - pro zalamovani
	SetTextSize(); //opravi scrollbary

	ScrollToCursor();

	blttext->BlinkCursor(0); //zmizi kurzor

	cursorblinktimerID=0;
	mousescrolltimerID=0;
	mousescroll=0;

	AddToTrash(); //kvuli vyjimkam - viz. GUI

}
示例#15
0
//reakce na klavesnici
int CGUIEditWindow::Keyboard(UINT ch, UINT state)
{
	int dy;

	switch(ch)
	{
	case VK_ESCAPE:
		EventArise(ECancel);
		break;
	case VK_RIGHT: //sipka doprava
		text->DoneUndo(); //uzavru posledni krok undo
		if(mainGUI->key_shift){ //se siftem oznacuju
			if(!text->GetMarkStart()) text->SetMarkStart();		
		} else text->UnMark();
		
		if(mainGUI->key_ctrl) //s controlem lezu po slovech
			text->GetCursor()->MoveWordRight();
		else
			text->GetCursor()->MoveRight();

		if(mainGUI->key_shift)
			text->SetMarkEnd();

		blttext->BlinkCursor(1); //zobrazi kurzor (blika)
		ScrollToCursor(); // nascroluje, aby byl kurzor videt
		blttext->SetNeedRecalc();
		CursorMoved();
		break;
	case VK_LEFT: //sipka doleve
		text->DoneUndo(); //uzavru posledni krok undo
		if(mainGUI->key_shift){ //se shiftem oznacuju
			if(!text->GetMarkStart()) text->SetMarkStart();
		}else text->UnMark();

		if(mainGUI->key_ctrl) //s crtl lezu po slovech
			text->GetCursor()->MoveWordLeft();
		else
			text->GetCursor()->MoveLeft();

		if(mainGUI->key_shift)
			text->SetMarkEnd();

		blttext->BlinkCursor(1);
		ScrollToCursor(); //nascroluje, aby byl kurzor videt
		blttext->SetNeedRecalc();
		CursorMoved();
		break;
	case VK_UP: //sipka nahoru
		text->DoneUndo(); //uzavru posledni krok undo
		if(multiline) //viceradkovy editor?
		{
			if(mainGUI->key_shift){ //se shiftem oznacuju
				if(!text->GetMarkStart()) text->SetMarkStart();		
			} else text->UnMark();
			text->GetCursor()->MoveUp(); //lezu nahoru
			if(mainGUI->key_shift)
				text->SetMarkEnd();
			blttext->BlinkCursor(1);
			ScrollToCursor(); //nascroluje, aby byl kurzor videt
			blttext->SetNeedRecalc();
		}else{
			if(changed) {EventArise(EOk); changed=0;}
			EventArise(EChangeTABElement,-1); //presune focus na predchozi element
		}
		CursorMoved();
		break;
	case VK_DOWN: //sipka dolu
		text->DoneUndo(); //uzavru posledni krok undo
		if(multiline)
		{
			if(mainGUI->key_shift){
				if(!text->GetMarkStart()) text->SetMarkStart();		
			} else text->UnMark();
			text->GetCursor()->MoveDown(); //lezu dolu
			if(mainGUI->key_shift) text->SetMarkEnd();
			blttext->BlinkCursor(1);
			ScrollToCursor(); //nascroluje, aby byl kurzor videt
			blttext->SetNeedRecalc();
		}else{
			if(changed) {EventArise(EOk); changed=0;}
			EventArise(EChangeTABElement,1); //presune focus na dalsi element
		}
		CursorMoved();
		break;
	case VK_PRIOR:  //PageUp
		text->DoneUndo();
		if(mainGUI->key_shift){
			if(!text->GetMarkStart()) text->SetMarkStart();		
		} else text->UnMark();
		dy = text->GetCursor()->MovePageUp((int)vp_sy);
		if(mainGUI->key_shift) text->SetMarkEnd();
		blttext->BlinkCursor(1);
		SetWindowPositionVP(0,(float)-dy);
		ScrollToCursor();
		blttext->SetNeedRecalc();
		CursorMoved();
		break;
	case VK_NEXT: //PageDown
		text->DoneUndo();
		if(mainGUI->key_shift){
			if(!text->GetMarkStart()) text->SetMarkStart();		
		} else text->UnMark();
		dy = text->GetCursor()->MovePageDown((int)vp_sy);
		if(mainGUI->key_shift) text->SetMarkEnd();
		blttext->BlinkCursor(1);
		SetWindowPositionVP(0,(float)dy);
		ScrollToCursor();
		blttext->SetNeedRecalc();
		CursorMoved();
		break;
	case VK_HOME: //home
		text->DoneUndo();
		if(mainGUI->key_shift){
			if(!text->GetMarkStart()) text->SetMarkStart();		
		} else text->UnMark();

		if(mainGUI->key_ctrl)
			text->GetCursor()->MoveTextHome(); //ctrl+home -> presune cursor na zacatek textu
		else
			text->GetCursor()->MoveHome();
		if(mainGUI->key_shift) text->SetMarkEnd();
		blttext->BlinkCursor(1);
		ScrollToCursor();
		blttext->SetNeedRecalc();
		CursorMoved();
		break;
	case VK_END: //end
		text->DoneUndo();
		if(mainGUI->key_shift){
			if(!text->GetMarkStart()) text->SetMarkStart();		
		} else text->UnMark();

		if(mainGUI->key_ctrl) //ctrl+end -> presuna cursor na konec textu
			text->GetCursor()->MoveTextEnd();
		else
		text->GetCursor()->MoveEnd();
		if(mainGUI->key_shift) text->SetMarkEnd();
		blttext->BlinkCursor(1);
		ScrollToCursor();
		blttext->SetNeedRecalc();
		CursorMoved();
		break;
	case VK_DELETE:
		if(!readonly){
			if(mainGUI->key_shift) Cut();
			else
			{
				//delete
				if(text->IsMarked())
					text->DeleteSelectedText(); //smazu oznaceny text
				else
					text->GetCursor()->Delete(); //mazu znak
				if(highlight)
				{//highlituju
					highlighter->HighlightFromBlock(text->GetCursor()->GetBlock());
					text->GetCursor()->CalcFormat();		
				}
				blttext->BlinkCursor(1);
				SetTextSize();
				ScrollToCursor();
				blttext->SetNeedRecalc();

				changed = 1; ChangedEvent();		
				CursorMoved();
			}
		}
		break;
	case VK_BACK:
		if(!readonly){	//backspace
			if(text->IsMarked())
				text->DeleteSelectedText(); //smazu oznaceny text
			else
				text->GetCursor()->Backspace(); //smazu znak
			if(highlight)
			{//highlightuju
				highlighter->HighlightFromBlock(text->GetCursor()->GetBlock());
				text->GetCursor()->CalcFormat();		
			}
			blttext->BlinkCursor(1);
			SetTextSize();
			ScrollToCursor();
			blttext->SetNeedRecalc();

			changed = 1; ChangedEvent();
			CursorMoved();
		}
		break;
	case VK_RETURN:
		if(multiline&&!readonly){ //return
			CTextBlock *b=text->GetCursor()->GetBlock();
			if(text->IsMarked())
				text->DeleteSelectedText(1,1); //smazu oznaceny text

			text->GetCursor()->Return(); //vlozim enter

			text->DoIdent(); //vlozim taby na zacatek radky

			if(highlight) 
			{//highlightuju
				highlighter->HighlightFromBlock(b);
				text->GetCursor()->CalcFormat();		
			}

			blttext->BlinkCursor(1);
			SetTextSize();
			ScrollToCursor();
			blttext->SetNeedRecalc();

			changed = 1; ChangedEvent();
			CursorMoved();
		}else
		{ //u jednoradkovyho boxu - presune focus na dalsi element
			text->DoneUndo();
			changed = 0;
			EventArise(EOk);
			EventArise(EChangeTABElement,1); //posunu focus na dalsi element
		}
		break;
	case VK_INSERT:
		if(mainGUI->key_shift)//paste
		{
			Paste();
		}else
		if(mainGUI->key_ctrl)//copy
		{
			Copy();
		}else{//change insert mode	
			text->GetCursor()->ChangeInsertMode();
			blttext->BlinkCursor(1);
			blttext->SetNeedRecalc();
			CursorMoved();
		}
		break;
	case 'A':
		if(mainGUI->key_ctrl) //select all
		{
			text->UnMark();
			text->GetCursor()->MoveTextHome();
			text->SetMarkStart();
			text->GetCursor()->MoveTextEnd();
			text->SetMarkEnd();
			blttext->BlinkCursor(1);
			ScrollToCursor();
			blttext->SetNeedRecalc();
			CursorMoved();
		}
		break;		
	case 'C': //ctrl+C -> copy to clipboard
		if(mainGUI->key_ctrl)
		{
			Copy();
		}
		break;
	case 'V': //ctrl+V ->paste from clipboard
		if(mainGUI->key_ctrl)
		{
			Paste();
		}
		break;
	case 'X': //ctrl+X -> cut
		if(mainGUI->key_ctrl){
			Cut();
		}
		break;
	case 'Z':
		if(mainGUI->key_ctrl) //undo
		{
			Undo();
		}
		break;
	case 'Y': 
		if(mainGUI->key_ctrl) //redo
		{
			Redo();
		}
		break;
	case VK_TAB:
		if(allowtab && !mainGUI->key_ctrl && !readonly){
			CTextCursor *cur=text->GetCursor();
			if(text->IsMarked())
			{
				int insm=-1;

				insm = cur->GetInsertMode();
				cur->SetInsertMode(0);

				CTextBlock *b=text->FindFirstMark()->GetBlock();

				text->IdentBlock(mainGUI->key_shift);

				if(highlight)
				{//highligtuju
					highlighter->HighlightFromBlock(b);
					cur->CalcFormat();		
				}
				cur->SetInsertMode(insm);

				blttext->BlinkCursor(1);
				SetTextSize();
				ScrollToCursor();
				blttext->SetNeedRecalc();

				changed = 1; ChangedEvent();
			}else
			if(!mainGUI->key_shift){
				cur->InsertChar('\t'); //vlozi tab
				if(highlight)
				{//highligtuju
					highlighter->HighlightFromBlock(cur->GetBlock());
					cur->CalcFormat();		
				}
				blttext->BlinkCursor(1);
				SetTextSize();
				ScrollToCursor();
				blttext->SetNeedRecalc();

				changed = 1; ChangedEvent();
			}
			CursorMoved();
		}
		break;

/*	case 'H':
		if(mainGUI->key_ctrl) //vyhighligtuje cely text - pro testovaci ucely
		{
			if(highlight&&highlighter)
			{
				highlighter->Highlight();
				text->GetCursor()->CalcFormat();
				blttext->BlinkCursor(1);
				SetTextSize();
				blttext->SetNeedRecalc();
			}
		}*/
	}

	return 0;
}