10 #include "../../utils/FullName.h"
11 #include "../../utils/Utils.h"
12 #include "../Controllers/ControllerIndicatorTHStock.h"
13 #include "../Garbage.h"
16 #include <TGColorSelect.h>
26 #ifdef DEBUG_CONT_FRAME
27 std::cout <<
"Entry Constructor IndicatorFrame w=" << w <<
" h= " << h <<
" name_frame " << name_frame << std::endl;
30 SetCleanup ( kDeepCleanup );
36 SetName ( name_frame );
40 ChangeOptions( (GetOptions() & ~kRaisedFrame) | kRaisedFrame );
45 #ifdef DEBUG_CONT_FRAME
46 std::cout <<
"Destructor IndicatorFrame " << std::endl;
55 #ifdef DEBUG_CONT_FRAME
56 std::cout <<
"Entry CheckFirstPad with fullname " << fullname << std::endl;
62 TList *list = GetList();
64 el = (TGFrameElement * ) list->At(0);
68 std::string str_tmp_name = Utils::toString<const char *>( tghframe->GetName() );
69 if ( str_tmp_name == fullname )
78 if ( GetList()->First() == 0 ) {
88 std::string indic_label;
90 #ifdef DEBUG_CONT_FRAME
91 std::cout <<
"\n\t IndicatorFrame::AddIndicator fullname "<< fullname << std::endl;
101 #ifdef DEBUG_CONT_FRAME
102 std::cout <<
"indic_label " << indic_label << std::endl;
107 AddFrame( hframe_label,
new TGLayoutHints(kLHintsExpandX | kLHintsCenterY, 2,2,2,2) );
119 #ifdef DEBUG_CONT_FRAME
120 std::cout <<
"Entry IndicatorFrame::DeleteLines " << fullname << std::endl;
124 TIter next( GetList() );
126 while ( (el = ((TGFrameElement *) next())) != 0 ) {
127 if ( el->fFrame->GetName() == fullname ) {
128 std::cout <<
" Remove " << el->fFrame->GetName() << std::endl;
132 RemoveFrame ( el->fFrame );
149 std::cout <<
"Ok" << std::endl;
151 Resize(GetDefaultSize());
156 #ifdef DEBUG_CONT_FRAME
157 std::cout <<
"Entry IndicatorFrame::HideLines " << std::endl;
161 TIter next( GetList() );
164 el = ( (TGFrameElement *) next() );
165 #ifdef DEBUG_CONT_FRAME
166 std::cout <<
" first el->fFrame->GetName() " << el->fFrame->GetName() << std::endl;
170 while ( (el = ((TGFrameElement *) next())) != 0 ) {
171 std::cout <<
" Will hide " << el->fFrame->GetName() << std::endl;
172 HideFrame ( el->fFrame );
181 #ifdef DEBUG_CONT_FRAME
182 std::cout <<
"Entry IndicatorFrame::ShowLines " << std::endl;
186 TIter next( GetList() );
189 el = ( (TGFrameElement *) next() );
190 std::cout <<
" first el->fFrame->GetName() " << el->fFrame->GetName() << std::endl;
192 while ( (el = ((TGFrameElement *) next())) != 0 ) {
193 std::cout <<
" Will show " << el->fFrame->GetName() << std::endl;
194 ShowFrame ( el->fFrame );
204 #ifdef DEBUG_CONT_FRAME
205 std::cout <<
"Enter IndicatorFrame::HandleButtons" << std::endl;
208 std::string classname;
209 std::string fullname;
216 TGButton *btn = (TGButton *) gTQSender;
219 fullname = btn->GetParent()->GetName();
221 classname = btn->ClassName();
223 #ifdef DEBUG_CONT_FRAME
224 std::cout <<
"this " <<
this << std::endl;
225 std::cout <<
"GetParent->GetParent classname " << btn->GetParent()->GetParent()->ClassName() << std::endl;
226 std::cout <<
"GetParent->GetParent->GetName " << btn->GetParent()->GetParent()->GetName() << std::endl;
231 std::cout <<
"classname " << classname << std::endl;
232 std::cout <<
"fullname " << fullname << std::endl;
237 #ifdef DEBUG_CONT_FRAME
238 std::cout <<
"first_pad " << first_pad << std::endl;
244 if ( classname ==
"TGTextButton" ) {
263 else if ( classname ==
"TGCheckButton" ) {
265 if ( btn->IsDown() ) {
266 #ifdef DEBUG_CONT_FRAME
267 std::cout <<
" TGCheckButton is down, so to show " << std::endl;
277 #ifdef DEBUG_CONT_FRAME
278 std::cout <<
" TGCheckButton is on, so to hide " << std::endl;
288 else if ( classname ==
"TGColorSelect" ) {
295 #ifdef DEBUG_CONT_FRAME
296 std::cout <<
"Color selected " << std::endl;
297 std::cout <<
"Pixel_t color " << color << std::endl;
298 std::cout <<
"unsigned long color " << (
unsigned long)color << std::endl;
305 std::cout <<
"error IndicatorFrame::HandleButtons() classname button not known " << std::endl;
311 if ( ( mode ==
"SHOW_ALL" ) || ( mode ==
"HIDE_ALL" ) || ( mode ==
"DELETE_ALL" ) ) {
320 std::cout <<
"After fcontroller->UpdateIndicator in IndicatorFrame " << std::endl;
326 std::cout <<
"\n\t PrintList IndicatorFrame " << std::endl;
332 GetList()->Print(opt,3);
334 std::string tmp_name;
337 TIter next( GetList() );
345 while ((el = (TGFrameElement*)next())) {
347 std::cout <<
"name " << el->fFrame->GetName() << std::endl;
349 TIter next2( el_tgh->GetList() );
352 while ( (el2 = ((TGFrameElement*) next2())) != 0 ) {
353 std::cout <<
"name2 " << el2->fFrame->GetName() << std::endl;
368 #ifdef DEBUG_CONT_FRAME
369 std::cout <<
"Entry Constructor IndicatorFrameLabel name_label " << fullname << std::endl;
370 std::cout <<
"label " << label << std::endl;
371 std::cout <<
"color " << color << std::endl;
374 SetCleanup ( kDeepCleanup );
379 SetName ( fullname );
381 MakeLineLabel( Utils::toString<std::string>( label ), color );
386 #ifdef DEBUG_CONT_FRAME
387 std::cout <<
"Destructor IndicatorFrameLabel " << std::endl;
397 std::cout <<
"Entry IndicatorFrameLabel::MakeLineLabel() label " << label << std::endl;
400 TGCheckButton *checkb =
new TGCheckButton(
this,
"");
401 AddFrame ( checkb,
new TGLayoutHints( kLHintsLeft | kLHintsCenterY, 1,1,1,1) );
402 checkb->SetState( kButtonDown );
405 checkb->Connect(
"Clicked()",
"IndicatorFrame", (
void*)fParent,
"HandleButtons()" );
409 AddFrame(
flabel_indic,
new TGLayoutHints( kLHintsLeft | kLHintsCenterY ,2,2,2,2) );
413 TGTextButton *btn =
new TGTextButton (
this,
" ");
414 btn->ChangeOptions( (btn->GetOptions() & ~kFitHeight) | kFixedHeight );
415 btn->SetHeight( 10 );
416 AddFrame( btn,
new TGLayoutHints( kLHintsRight | kLHintsCenterY , 1,1,1,1) );
417 btn->Connect(
"Clicked()",
"IndicatorFrame", (
void*)fParent,
"HandleButtons()" );
421 TGColorSelect* fColorSel = 0;
425 fColorSel =
new TGColorSelect(
this );
426 AddFrame ( fColorSel,
new TGLayoutHints( kLHintsRight | kLHintsCenterY ,2,2,2,2) );
430 fColorSel->Connect(
"ColorSelected(Pixel_t)",
"IndicatorFrameLabel",
this,
"SetColorLabel(Pixel_t)");
432 fColorSel->Connect(
"ColorSelected(Pixel_t)",
"IndicatorFrame", (
void*)fParent,
"HandleButtons()");
440 fColorSel->SetColor( color,
false );
446 Resize(GetDefaultSize());
451 #ifdef DEBUG_CONT_FRAME
452 std::cout <<
"Entry SetColorLabel, slot to change label color " << color << std::endl;
void HideLines()
hide/show all lines, except the first one
TGLabel * flabel_indic
simple label with indicator name, can change color of the label
void Add(TObject *)
Add a TOBject to be deleted.
Deal with labels in IndicatorFrame.
void ModifyColorIndic(std::string fullname, unsigned long color)
void UpdateIndicator(std::string mode, std::string fullname)
UpdateIndicator, call by IndicatorFrame.
ControllerIndicatorTHStock * fcontroller
virtual ~IndicatorFrame()
void DeleteLines(std::string fullname)
new unique for Label and Indicator
Garbage collector for ROOT TObjects.
void HandleButtons()
manages all buttons of IndicatorFrameLabel.
Pixel_t fcolor_indic
keep memory of the color of the associated indicator
static Garbage & getInstance()
Pixel_t GetColorLabel() const
void MakeLineLabel(std::string fullname, const int color)
create a line with label and all buttons
void SetColorLabel(Pixel_t color)
Slot when color is changed, modify the text label color.
std::string GetFrameName(const std::string &fname)
Extract NameStock_Timescale (FrameName) from a fullname.
Show all data loaded in memory, allow to deal with Button.
std::string GetShortName(const std::string &fname)
Extract Indicator_params (string) from a fullname.
ClassImp(IndicatorFrame) IndicatorFrame
void PrintList()
for debug
void AddIndicator(std::string, int color)
Add an indicator , call MakeLineLabel now should be called by ControllerIndicatorTHStockFrame.