//--- açıklama #property description "Script, çizelge üzerinde bir düğme oluşturur." //--- betiğin çalıştırılması sırasında giriş parametreleri penceresini göster #property script_show_inputs //--- betiğin giriş parametreleri input string InpName="Button"; // Düğme ismi input ENUM_BASE_CORNER InpCorner=CORNER_LEFT_UPPER; // Tutturma için çizelge köşesi input string InpFont="Arial"; // Yazı tipi input int InpFontSize=14; // Yazı tipi büyüklüğü input color InpColor=clrBlack; // Metin rengi input color InpBackColor=C'236,233,216'; // Arka-plan rengi input color InpBorderColor=clrNONE; // Kenar rengi input bool InpState=false; // Basılı/Serbest input bool InpBack=false; // Arka-plan nesnesi input bool InpSelection=false; // Taşıma için vurgula input bool InpHidden=true; // Nesne listesinde gizle input long InpZOrder=0; // Fare tıklaması önceliği //+------------------------------------------------------------------+ //| Düğmeyi oluştur | //+------------------------------------------------------------------+ bool ButtonCreate(const long chart_ID=0, // çizelge kimliği const string name="Button", // düğme ismi const int sub_window=0, // alt pencere indisi const int x=0, // X koordinatı const int y=0, // Y koordinatı const int width=50, // düğme genişliği const int height=18, // düğme yüksekliği const ENUM_BASE_CORNER corner=CORNER_LEFT_UPPER, // tutturulacak çizelge köşesi const string text="Button", // metin const string font="Arial", // yazı tipi const int font_size=10, // yazı tipi boyutu const color clr=clrBlack, // metin rengi const color back_clr=C'236,233,216', // arka-plan rengi const color border_clr=clrNONE, // kenar rengi const bool state=false, // basılı serbest const bool back=false, // arkaplanda const bool selection=false, // taşıma için vurgula const bool hidden=true, // nesne listesinde gizle const long z_order=0) // fare tıklaması için öncelik { //--- hata değerini sıfırla ResetLastError(); //--- düğmeyi oluştur if(!ObjectCreate(chart_ID,name,OBJ_BUTTON,sub_window,0,0)) { Print(__FUNCTION__, ": düğmenin oluşturulması başarısız oldu! Hata kodu = ",GetLastError()); return(false); } //--- düğme koordinatlarını ayarla ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x); ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y); //--- düğme boyutunu ayarla ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width); ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height); //--- tanımlanan nokta koordinatlarına göre çapa (tutturma) köşesini ayarla ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner); //--- metni ayarla ObjectSetString(chart_ID,name,OBJPROP_TEXT,text); //--- metin yazı tipini ayarla ObjectSetString(chart_ID,name,OBJPROP_FONT,font); //--- yazı tipi boyutunu ayarla ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size); //--- metin rengini ayara ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); //--- arkaplan rengini ayarla ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr); //--- kenar çizgisinin rengini ayarla ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_COLOR,border_clr); //--- ön-planda (false) veya arkaplanda (true) göster ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back); //--- set button state ObjectSetInteger(chart_ID,name,OBJPROP_STATE,state); //--- düğmeyi fare ile taşıma modunu etkinleştir (true) veya devre dışı bırak (false) ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection); ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection); //--- nesne listesinde grafiksel nesnenin adını sakla (true) veya göster (false) ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden); //--- çizelge üzerinde fare tıklaması olayının alınması için özellik ayarla ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order); //--- başarılı çalıştırma return(true); } //+------------------------------------------------------------------+ //| Düğmeyi taşı | //+------------------------------------------------------------------+ bool ButtonMove(const long chart_ID=0, // çizelge kimliği const string name="Button", // düğme ismi const int x=0, // X koordinatı const int y=0) // Y koordinatı { //--- hata değerini sıfırla ResetLastError(); //--- düğmeyi taşı if(!ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x)) { Print(__FUNCTION__, ": düğmenin X koordinatı taşınamadı! Hata kodu = ",GetLastError()); return(false); } if(!ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y)) { Print(__FUNCTION__, ": düğmenin Y koordinatı taşınamadı! Hata kodu = ",GetLastError()); return(false); } //--- başarılı çalıştırma return(true); } //+------------------------------------------------------------------+ //| Düğme boyutunu değiştir | //+------------------------------------------------------------------+ bool ButtonChangeSize(const long chart_ID=0, // çizelge kimliği const string name="Button", // düğme ismi const int width=50, // düğme genişliği const int height=18) // düğme yüksekliği { //--- hata değerini sıfırla ResetLastError(); //--- düğme boyutunu değiştir if(!ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width)) { Print(__FUNCTION__, ": düğme genişliği değiştirilemedi! Hata kodu = ",GetLastError()); return(false); } if(!ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height)) { Print(__FUNCTION__, ": düğme yüksekliği değiştirilemedi! Hata kodu = ",GetLastError()); return(false); } //--- başarılı çalıştırma return(true); } //+------------------------------------------------------------------+ //| Düğmenin bağlanacağı çizelge köşesini değiştir | //+------------------------------------------------------------------+ bool ButtonChangeCorner(const long chart_ID=0, // çizelge kimliği const string name="Button", // düğme ismi const ENUM_BASE_CORNER corner=CORNER_LEFT_UPPER) // tutturmanın yapılacağı çizelge köşesi { //--- hata değerini sıfırla ResetLastError(); //--- tutturma köşesini değiştir if(!ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner)) { Print(__FUNCTION__, ": tutturma köşesi değiştirilemedi! Hata kodu = ",GetLastError()); return(false); } //--- başarılı çalıştırma return(true); } //+------------------------------------------------------------------+ //| Düğme metnini değiştir | //+------------------------------------------------------------------+ bool ButtonTextChange(const long chart_ID=0, // çizelge kimliği const string name="Button", // düğme ismi const string text="Text") // metin { //--- hata değerini sıfırla ResetLastError(); //--- nesne metnini değiştir if(!ObjectSetString(chart_ID,name,OBJPROP_TEXT,text)) { Print(__FUNCTION__, ": metin değiştirilemedi! Hata kodu = ",GetLastError()); return(false); } //--- başarılı çalıştırma return(true); } //+------------------------------------------------------------------+ //| Düğmeyi sil | //+------------------------------------------------------------------+ bool ButtonDelete(const long chart_ID=0, // çizelge kimliği const string name="Button") // düğme ismi { //--- hata değerini sıfırla ResetLastError(); //--- düğmeyi sil if(!ObjectDelete(chart_ID,name)) { Print(__FUNCTION__, ": düğme silinemedi! Hata kodu = ",GetLastError()); return(false); } //--- başarılı çalıştırma return(true); } //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- çizelge penceresi büyüklüğü long x_distance; long y_distance; //--- pencere büyüklüğünü ayarla if(!ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0,x_distance)) { Print("Çizelgenin genişlik değeri alınamadı! Hata kodu = ",GetLastError()); return; } if(!ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0,y_distance)) { Print("Çizelgenin yükseklik değeri alınamadı! Hata kodu = ",GetLastError()); return; } //--- düğme boyutunun değiştirilmesi için adım değerini tanımla int x_step=(int)x_distance/32; int y_step=(int)y_distance/32; //--- düğmenin koordinatlarını ve boyutunu ayarla int x=(int)x_distance/32; int y=(int)y_distance/32; int x_size=(int)x_distance*15/16; int y_size=(int)y_distance*15/16; //--- düğmeyi oluştur if(!ButtonCreate(0,InpName,0,x,y,x_size,y_size,InpCorner,"Press",InpFont,InpFontSize, InpColor,InpBackColor,InpBorderColor,InpState,InpBack,InpSelection,InpHidden,InpZOrder)) { return; } //--- çizelgeyi yeniden çiz ChartRedraw(); //--- düğmeyi döngü içinde indirge int i=0; while(i<13) { //--- yarım saniyelik gecikme Sleep(500); //--- düğmeyi basılı konuma getir ObjectSetInteger(0,InpName,OBJPROP_STATE,true); //--- çizelgeyi yenile ve 0.2 saniye bekle ChartRedraw(); Sleep(200); //--- koordinatları ve düğme büyüklüğünü yeniden tanımla x+=x_step; y+=y_step; x_size-=x_step*2; y_size-=y_step*2; //--- düğmeyi indirge ButtonMove(0,InpName,x,y); ButtonChangeSize(0,InpName,x_size,y_size); //--- düğmeyi serbest duruma getir ObjectSetInteger(0,InpName,OBJPROP_STATE,false); //--- çizelgeyi yenile ChartRedraw(); //--- script işlemi devre dışı bırakıldı mı kontrol et if(IsStopped()) return; //--- döngü sayacını artır i++; } //--- yarım saniyelik gecikme Sleep(500); //--- düğmeyi sil ButtonDelete(0,InpName); ChartRedraw(); //--- 1 saniye bekle Sleep(1000); //--- } |