9 #include "../Controllers/MainControllerIndicatorTHStock.h"
16 #include "../ObjectStock/EditorObjStock.h"
17 #include "../ObjectStock/AbstractObjectStock.h"
20 #include "../GUIException.h"
21 #include "../TransientFrame.h"
30 "./pictures/support.xpm",
31 "./pictures/tendance.xpm",
32 "./pictures/ancre.xpm",
33 "./pictures/realtime.xpm",
56 std::string name_frame, UInt_t w,UInt_t h ) :
57 TGMainFrame( p, w, h), fcontroller ( parent_control )
59 #ifdef DEBUG_CONT_FRAME
60 std::cout <<
"\n\tConstructor MainIndicatorTHStockFrame h= " << h <<
" w " << w << std::endl;
61 std::cout <<
"Value of the parent frame " << p << std::endl;
62 std::cout <<
"Value of the parent controller " << parent_control << std::endl;
63 std::cout <<
"name_frame " << name_frame << std::endl;
66 SetName( name_frame.c_str() );
69 SetCleanup ( kDeepCleanup );
72 #ifdef DEBUG_CONT_FRAME
73 std::cout <<
"p == 0, create a kMainFrame " << std::endl;
86 SetWindowName(
"IndependentMainFrame");
89 Connect(
"CloseWindow()",
"MainIndicatorTHStockFrame",
this,
"CloseWindow()");
97 AddFrame( fVMain,
new TGLayoutHints( kLHintsLeft | kLHintsExpandX | kLHintsExpandY ,2,2,2,2));
104 fVMain->AddFrame( fHIndicTHStock,
new TGLayoutHints( kLHintsExpandX | kLHintsExpandY , 2, 2, 2, 2) );
108 fHIndicTHStock->AddFrame(
fVframe_indicator,
new TGLayoutHints( kLHintsExpandY , 2, 2, 2, 2) );
111 fHIndicTHStock->AddFrame(
fHframe_c_stock,
new TGLayoutHints( kLHintsExpandX | kLHintsExpandY , 2, 2, 2, 2) );
114 fStatusBar =
new TGStatusBar(fVMain, 50, 10, kHorizontalFrame);
117 fVMain->AddFrame (
fStatusBar,
new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX,0,0,2,0) );
119 #ifdef DEBUG_CONT_FRAME
120 std::cout <<
"Newly created " << std::endl;
124 std::cout <<
"MainIndicatorTHStockFrame this " <<
this << std::endl;
133 #ifdef DEBUG_CONT_FRAME
134 std::cout <<
"Destructor MainIndicatorTHStockFrame " << std::endl;
140 std::cout <<
"End destructor MainIndicatorTHStockFrame " << std::endl;
147 #ifdef DEBUG_CONT_FRAME
148 std::cout <<
"Entry MainIndicatorTHStockFrame::CloseWindow() this " <<
this << std::endl;
149 std::cout <<
"this " <<
this <<
" name controller " << GetName() << std::endl;
156 TGMainFrame::CloseWindow();
161 #ifdef DEBUG_CONT_FRAME
162 std::cout <<
"Entry MainIndicatorTHStockFrame::CreateToolBar " << std::endl;
165 int separator_gtool=5;
174 fVMain->AddFrame(
fHframe_toolbar,
new TGLayoutHints( kLHintsLeft | kLHintsExpandX ,2,2,2,2) );
178 ftoolbar->Connect(
"Clicked( Int_t )",
"MainIndicatorTHStockFrame",
this,
"HandleToolBar( Int_t )" );
184 ToolBarData_t ftoolbd[6];
185 for (
int i = 0; i < 4; i++) {
187 ftoolbd[i].fPixmap =
xpms[i];
188 ftoolbd[i].fTipText =
tips[i];
191 if ( (i==0) || (i==1) || ( i==2) || (i==3) )
192 ftoolbd[i].fStayDown = kTRUE;
194 ftoolbd[i].fStayDown = kFALSE;
196 ftoolbd[i].fId = i+1;
197 ftoolbd[i].fButton = NULL;
202 if ( i == 3 ) separator_gtool = 25;
217 fTextResearch->Connect(
"ReturnPressed()",
"MainIndicatorTHStockFrame",
this,
"HandleButtons(Int_t)");
226 for (
int i = 0; i < 10; i++) {
234 fComboTime->Connect(
"Selected(Int_t, Int_t )",
"MainIndicatorTHStockFrame",
this,
"HandleComboBox( Int_t, Int_t )");
243 for (
unsigned int i=0; i < tmp_indic.size(); i++ ) {
244 fComboIndic->AddEntry( tmp_indic[i].c_str(), i+20 );
248 fComboIndic->Connect(
"Selected(Int_t, Int_t )",
"MainIndicatorTHStockFrame",
this,
"HandleComboBox( Int_t, Int_t )");
272 check_to_add_canvas->Connect(
"Clicked()",
"MainIndicatorTHStockFrame",
this,
"HandleButtons(Int_t)");
276 check_to_make_main->Connect(
"Clicked()",
"MainIndicatorTHStockFrame",
this,
"HandleButtons(Int_t)");
284 fValidB->Connect(
"Clicked()",
"MainIndicatorTHStockFrame",
this,
"HandleButtons(Int_t)");
285 fHframe_toolbar->AddFrame (
fValidB,
new TGLayoutHints( kLHintsCenterY | kLHintsExpandY | kLHintsRight, 1,1,3,3) );
288 TGHorizontal3DLine *line_separator =
new TGHorizontal3DLine(fVMain);
289 fVMain->AddFrame(line_separator,
new TGLayoutHints(kLHintsTop | kLHintsExpandX));
295 #ifdef DEBUG_CONT_FRAME
296 std::cout <<
"Entry Reset Entries" << std::endl;
301 bool b_default =
false;
302 std::vector<int> default_values;
323 #ifdef DEBUG_CONT_FRAME
324 std::cout <<
"Hide all fParamEntry" << std::endl;
326 for (
int i=0; i < 3; i++ )
331 if ( nb_param > 0 ) {
332 for (
int i=0; i< nb_param; i ++ ) {
337 fParamEntry[i]->SetText( (Utils::toString<Float_t>(default_values[i])).c_str(),
false );
344 #ifdef DEBUG_CONT_FRAME
345 std::cout <<
" \n\t Entry MainIndicatorTHStockFrame::ExtractInfoForValidation" << std::endl;
346 std::cout <<
" pointer to fcontroller " <<
fcontroller << std::endl;
350 std::string namestock;
351 std::string tmscl_str;
352 std::string indic_str;
357 std::cout <<
"name stock: " << namestock << std::endl;
361 indic_str = tmp_indic[
fComboIndic->GetSelected() - 20 ];
364 longname = namestock+
'_' + tmscl_str +
'_' + indic_str;
367 longname +=
'_' + Utils::toString<const char *> (
fParamEntry[0]->GetText() );
370 longname +=
'_' + Utils::toString<const char *> (
fParamEntry[1]->GetText() );
373 longname +=
'_' + Utils::toString<const char *>(
fParamEntry[2]->GetText() );
376 #ifdef DEBUG_CONT_FRAME
377 std::cout <<
"End Extract fullname " << longname << std::endl;
383 #ifdef DEBUG_CONT_FRAME
384 std::cout <<
" Entry MainIndicatorTHStockFrame::HandleButtons(Int_t id) " << std::endl;
391 btn = (TGButton *) gTQSender;
392 id = btn->WidgetId();
412 #ifdef DEBUG_CONT_FRAME
413 std::cout <<
"Valid button has been pressed, will call MainControllerIndicatorTHStockFrame::Validation " << std::endl;
415 std::string longname;
427 std::cout <<
"\nMainIndicatorTHStockFrame:Caugth GUIException from HandleButton " << std::endl;
429 std::cout <<
"what(): " << e.
what() << std::endl;
441 #ifdef DEBUG_CONT_FRAME
442 std::cout <<
" Exit MainIndicatorTHStockFrame::HandleButtons(Int_t id) " << std::endl;
448 #ifdef DEBUG_CONT_FRAME
449 std::cout <<
"Entry HandleComboBox " << std::endl;
450 std::cout <<
"widget " << widgetId <<
" id " <<
id << std::endl;
457 switch ( widgetId ) {
465 #ifdef DEBUG_CONT_FRAME
466 std::cout <<
"Modify ChoiceIndic ResetEntries" << std::endl;
478 #ifdef DEBUG_CONT_FRAME
479 std::cout <<
"Entry HandleToolBar id " <<
id << std::endl;
482 TGButton * but =
ftoolbar->GetButton(
id);
487 #ifdef DEBUG_CONT_FRAME
488 std::cout <<
" Support/Resistance " << std::endl;
495 if ( but->IsDown() ) {
496 #ifdef DEBUG_CONT_FRAME
497 std::cout <<
" IsDown, EditorObject set to Support " << std::endl;
502 #ifdef DEBUG_CONT_FRAME
503 std::cout <<
" IsUp, EditorObject set to None " << std::endl;
516 if ( but->IsDown() ) {
517 #ifdef DEBUG_CONT_FRAME
518 std::cout <<
" IsDown, run EditorObject " << std::endl;
531 if ( but->IsDown() ) {
532 #ifdef DEBUG_CONT_FRAME
533 std::cout <<
" IsDown, run EditorObject Anchor " << std::endl;
538 #ifdef DEBUG_CONT_FRAME
539 std::cout <<
"IsUp Disable Anchor" << std::endl;
579 unsigned int size_entry = vec_str_text.size();
588 for ( i = 0; i < size_entry; ++i ) {
589 fStatusBar->SetText( vec_str_text[i].c_str(),i);
592 for (
unsigned int j = i;j <4; j++ )
623 std::vector < std::string > vec_str_text;
624 std::string text_str0, text_str1, text_str2, text_str3;
627 std::string indic_str;
634 vec_str_text.push_back( text_str0 );
635 vec_str_text.push_back( text_str1 );
638 std::vector<Float_t>
values;
639 std::vector<std::string> add_strings;
649 if ( obj_stock != 0 ) {
653 vec_str_text.push_back( add_strings[0] );
654 vec_str_text.push_back( add_strings[1] );
static const char * ListTimeScaleLabel[]
for TimeScale ComboxBox
void HandleButtons(Int_t id=-1)
TGVerticalFrame * fVframe_indicator
frame for all indicators
Controller for a dual frame containing Indicator+THStock(s).
static std::vector< std::string > GetListAllIndicator()
Get a list of all indicator's label.
"Clever" enumeration of the ListDataStock type : StockCSV, Volume, EMA, BOLL,...
MainControllerIndicatorTHStock * fcontroller
pointer to the parent controller
void ResetEntries()
reset all widget entries, may add options
int nb_param() const
Nb of parameters necessary to be computed.
void CreateToolBar(TGVerticalFrame *fVMain)
void EventInfo(Int_t, Int_t px, Int_t py, TObject *selected)
Called after DistancetoPrimitive for the selection of "objects" Done by the system, appends after a gPad->SetSelected( obj_stock ) in THistPainterStock::DtP.
bool HasDefaultValues() const
Test functions if default values are provided.
virtual const char * what() const noexcept
static const char * xpms[]
MainIndicatorTHStockFrame(const TGWindow *p, MainControllerIndicatorTHStock *parent_control, std::string name_frame, UInt_t w, UInt_t h)
Constructor, create only generic frames to design the output, but empty inserted in a generic frames ...
Independent frame, could be kMainFrame or kChild Frame which group one MainIndicatorFrame and THStock...
void DeleteIndicatorTHstock()
Delete all couples of frames and thstocks Call by MainControllerIndicatorStock::CloseWindow() ...
ClassImp(MainIndicatorTHStockFrame) const char *MainIndicatorTHStockFrame
For ToolBar, define pictures *.xpm.
TGCheckButton * check_to_add_canvas
virtual std::vector< std::string > MakeStringForStatusBar(int, int) const =0
create the string for the StatusBar
TGTextButton * fValidB
Validation button, after update of search and combo.
static Indicator GetIndicator(const std::string &str_name)
Constructor with a string label.
TGLabel * fLabelSearch
For selection and validation of a new indicator.
void ExtractInfoForValidation(std::string &longname)
Extract symbol, timescale, indicator and paramaters from input.
virtual void CloseWindow()
std::string toString(const T &t)
void HandleToolBar(Int_t id)
Frame contains Indicator and THStock.
void SetAnchor(bool kbool)
TGCheckButton * check_to_make_main
TGTextEntry * fTextResearch
void Validation(std::string fullname)
Load stock or indicator after pressing the Validation button.
TGHorizontalFrame * fHframe_toolbar
void HandleComboBox(Int_t widgetId, Int_t id)
void SetMode(std::string mode)
std::vector< int > GetDefaultValues() const
Get the default values, return an empty vector if none are provided.
TGTextEntry * fParamEntry[3]
static Int_t statbar_parts[]
for Status Bar, place in %, no in a namespace, need to be static
Define an abstract base class for all objects to be painted in a THStock.
virtual ~MainIndicatorTHStockFrame()
TGHorizontalFrame * fHframe_c_stock
frame for all THStockFrame ( 1 canvas stock inside each )
void SetStatusBar(std::vector< std::string > &vec_str_text)
print data from EventInfo in the status bar
static const char * tips[]
For ToolBar, define text.