[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Increase and decrease a var with two GFX buttons.



PureBytes Links

Trading Reference Links

Thank you very much Aron, here is an intermediate version.

Stangely, beyond 5.6 I get 6 digits and under 0.95 as well. A matter of 
rounding an integer maybe ? i don't know...

Best regards


// Buttons in right margin

/*
draw a minus red button and a plus green button

Blank bars in the right margin = 10 to avoid the following SetChartOptions

//SetChartOptions( 2, chartHideQuoteMarker );

*/

RequestTimedRefresh( 1 );

function DrawButton( Text, x1, y1, x2, y2, BackColor )
{
     GfxSetOverlayMode( 0 );
     GfxSelectFont( "Tahoma", 12, 800 );
     GfxSelectPen( colorBlack );
     GfxSetBkMode( 1 );
     GfxSelectSolidBrush( BackColor );
     GfxSetBkColor( BackColor );
     GfxSetTextColor( 1 );
     GfxRectangle( x1, y1, x2, y2 );
     GfxDrawText( Text, x1, y1, x2, y2, 32 | 1 | 4 );
}

step = 0.05;
sDefaultValue = StaticVarGet ( "sDefaultValue" );
StaticVarSet( "sDefaultValue", 3 );
pxchartwidth = Status( "pxchartwidth" );

shiftM = 40;
XOffset  = StaticVarGet( "XOffset" );
YOffset  = StaticVarGet( "YOffset" );
XOffset  = pxchartwidth - shiftM ; // X1 minus button
YOffset  = 0;//Y1 minus button
SquareSide = 20;
X1m = XOffset  ;
X2m = Xoffset + SquareSide ;
Y1m = YOffset  ;
Y2m = yOffset + SquareSide ;
// Draw Minus Button
DrawButton( "-", Xoffset, yOffset, Xoffset + SquareSide , yOffset + 
SquareSide , colorRed );

shiftP = 17;
XOffsetP  = StaticVarGet( "XOffset" );
YOffsetP  = StaticVarGet( "YOffset" );
XOffsetP  = pxchartwidth - shiftP ; // X1 plus button
YOffsetP  = 0;//Y1 plus button
X1p = XOffsetP  ;
X2p = XoffsetP + SquareSide ;
Y1p = YOffsetP  ;
Y2p = yOffsetP + SquareSide ;
// Draw Plus Button
DrawButton( "+", XoffsetP, yOffsetP, XoffsetP + SquareSide , yOffsetP + 
SquareSide , colorGreen );

//LButtonTrigger = GetCursorMouseButtons() & 1;
LButtonTrigger	= GetCursorMouseButtons() == 9;
numClicks = Nz( StaticVarGet( "counter" ), sDefaultValue );

if ( LButtonTrigger )
{
     MousePx  = Nz( GetCursorXPosition( 1 ) );
     MousePy  = Nz( GetCursorYPosition( 1 ) );

     CursorInMinus = MousePx > X1m AND MousePx < X2m AND MousePy > Y1m 
AND MousePy < Y2m;
     CursorInPlus = MousePx > X1p AND MousePx < X2p AND MousePy > Y1p 
AND MousePy < Y2p;

     if ( CursorInMinus )
     {
         DrawButton( "-", Xoffset, yOffset, Xoffset + SquareSide , 
yOffset + SquareSide , colorYellow );
         StaticVarSet( "counter", numClicks - step   );
     }

     if ( CursorInPlus )
     {
         DrawButton( "+", XoffsetP, yOffsetP, XoffsetP + SquareSide , 
yOffsetP + SquareSide , colorYellow );
         StaticVarSet( "counter", numClicks + step   );
     }
}

Title = "Clicks Counter: " + StaticVarGet( "counter" );


Aron a écrit :
>  
> 
> Look at this example:
> 
> |RequestTimedRefresh( 1 );
> LeftButton = GetCursorMouseButtons() & 1;
> reset = GetCursorMouseButtons() &4 ; // middle button pressed
> 
> numClicks = Nz( StaticVarGet( "counter" ) );
> 
> *if* ( leftButton )
> StaticVarSet( "counter", numClicks + 1 );
> 
> *if* (reset )
> {
>     StaticVarSet( "counter" ,0);
> *    Title* = "Counter Reseted !" ;
> }
> *else*
> 
> *Title* = "Clicks Counter: " + StaticVarGet( "counter" );|
> 
> On 11/7/2009 6:58 PM, Reinsley wrote:
> 
>> Hello,
>>
>> I would like to decrease Myparam of 0.25 on each clic inside the red button.
>>
>> I complicated with static var but Myparam comes back to 5 as it is declared at the beginning of the formula.
>>
>> How to decrease a var with a GFX button ?
>>
>> To give an idea of what I want to do , once this point solved, my next step will be to increase of 0.25 the same Myparam with a Plus button to adjust a Fibonacci step. I will add Fibonacci code at the very end.
>>
>> AB parameters windows lacks some ergonomics in real time.
>>
>> I draw the buttons in the upper right side, after the bars, as quote marker will not be activate.
>>
>> Thanks for the help
>>
>> Best regards
>>
>>
>>
>>
>> // draw a red square + inside click
>>
>> //SetChartOptions( 2, chartHideQuoteMarker );
>>
>> Myparam = Param( "TheValue", 5, 0, 5, 0.25 );
>> StaticVarSet( "Myparamstat ", Myparam );
>>
>> Myparam = StaticVarGet( "Myparamstat " );
>> _TRACE( "Myparamstat = " + Myparam );
>>
>>
>> function DrawButton( Text, x1, y1, x2, y2, BackColor )
>> {
>>     GfxSetOverlayMode( 0 );
>>     GfxSelectFont( "Tahoma", 12, 800 );
>>     GfxSelectPen( colorBlack );
>>     GfxSetBkMode( 1 );
>>     GfxSelectSolidBrush( BackColor );
>>     GfxSetBkColor( BackColor );
>>     GfxSetTextColor( 1 );
>>     GfxRectangle( x1, y1, x2, y2 );
>>     GfxDrawText( Text, x1, y1, x2, y2, 32 | 1 | 4 );
>> }
>>
>> shift = 40;
>> XOffset  = StaticVarGet( "XOffset" );
>> YOffset  = StaticVarGet( "YOffset" );
>>
>> pxchartwidth = Status( "pxchartwidth" );
>> XOffset  = pxchartwidth - shift ; // X1
>> YOffset  = 0;//Y1
>> SquareSide = 20;
>>
>> X1m = XOffset  ;
>> X2m = Xoffset + SquareSide ;
>> Y1m = YOffset  ;
>> Y2m = yOffset + SquareSide ;
>>
>> DrawButton( "-", Xoffset, yOffset, Xoffset + SquareSide , yOffset + SquareSide , colorRed );
>>
>> LButtonTrigger	= GetCursorMouseButtons() == 9;
>> _TRACE( "LButtonTrigger = " + LButtonTrigger );
>>
>> if ( LButtonTrigger )
>> {
>>     MousePx  = Nz( GetCursorXPosition( 1 ) );
>>     MousePy  = Nz( GetCursorYPosition( 1 ) );
>>
>>     CursorInMinus = MousePx > X1m AND MousePx < X2m AND MousePy > Y1m AND MousePy < Y2m;
>>     _TRACE( "CursorInMinus = " + CursorInMinus );
>>
>>     if ( CursorInMinus )
>>     {
>>         DrawButton( "-", Xoffset, yOffset, Xoffset + SquareSide , yOffset + SquareSide , colorYellow );
>>         Myparam = StaticVarGet( "Myparamstat " );
>>         Myparam = Myparam - 0.25;
>>         _TRACE( "Myparamstat2 = " + Myparam );
>>         RequestTimedRefresh( 1 );
>>     }
>> }
>>
>>
>>
>>
>>
>>
>>
>>
>> ------------------------------------
>>
>> **** IMPORTANT PLEASE READ ****
>> This group is for the discussion between users only.
>> This is *NOT* technical support channel.
>>
>> TO GET TECHNICAL SUPPORT send an e-mail directly to 
>> SUPPORT {at} amibroker.com
>>
>> TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
>> http://www.amibroker.com/feedback/
>> (submissions sent via other channels won't be considered)
>>
>> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
>> http://www.amibroker.com/devlog/
>>
>> Yahoo! Groups Links
>>
>>
>>
>>   
> 
> 



------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    amibroker-digest@xxxxxxxxxxxxxxx 
    amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/