1. RE: LaGard (was no subject)
Hi Tony,
Here's my quick 'n dirty analysis:
If you are going to have a w32HMouse handler, avoid also having a
w32HClick handler. Two routines essentially servicing one action is
typically a bad thing.
Here's what I suggest... get rid of the click handler completely and do
something like this:
-----------------------------
function getCurrentButton( integer x, integer y )
-- If Button 1
if x > 70 and x < 105 and y >46 and y < 75 then
return 1
-- If Button 2
elsif x > 117 and x < 150 and y > 40 and y < 73 then
return 2
-- If Button 3
elsif x > 164 and x < 195 and y > 45 and y < 73 then
return 3
-- If Button 4
elsif x > 73 and x < 105 and y > 90 and y < 122 then
return 4
-- If Button 5
elsif x > 121 and x < 151 and y > 89 and y < 121 then
return 5
-- If Button 6
elsif x > 166 and x < 195 and y > 87 and y < 119 then
return 6
-- If Button 7
elsif x > 75 and x < 106 and y > 139 and y < 169 then
return 7
-- If Button 8
elsif x > 122 and x < 153 and y > 137 and y < 169 then
return 8
-- If Button 9
elsif x > 166 and x < 196 and y > 136 and y < 166 then
return 9
-- If Button 0
elsif x > 122 and x < 152 and y > 184 and y < 215 then
return 0
-- If Button * Ill call 11
elsif x > 76 and x < 106 and y > 185 and y < 211 then
return 11
-- If Button # Ill call 12
elsif x > 166 and x < 193 and y > 188 and y < 209 then
return 12
else
return -1
end if
end function
-----------------------------
procedure Bitmap2_onMouse (integer self, integer event, sequence
params)--params is ( int event, int x, int y, int shift, int wheelmove )
if params[1] = LeftUp then
CurButton = getCurrentButton( params[2], params[3] )
if CurButton > -1 then
UpdateSession()
CurButton = -1
else
setText(SBar, "")
end if
end if
end procedure
setHandler( Bitmap2, w32HMouse, routine_id("Bitmap2_onMouse"))
-----------------------------
As for the LED, the generic answer is: just brighten the colors where
the LED is... I'd show you a quick way if I had my old programs in
front of me. Maybe somebody else can help with that.
-- Brian
Tony Steward wrote:
>
>
> Hello,
> I am writing a safe lock emulator, but I have a couple of problems.
> 1. When I click differant areas ove a bitmap it sometimes registers
> twice. - Not sure how to prevent this.
> 2. Part of the bitmap there is an LED. Is there a way I can make it
> appear to blink on a mouse click without loading a whole second bitmap.
>
> Find my code at www.locksdownunder.com/LaGard.zip
>
> Any help or comments on a better way to do this would be appreciated
>
> Thanks
> Tony
>
2. RE: LaGard (was no subject)
Brian Broker wrote:
>
> Hi Tony,
>
> Here's my quick 'n dirty analysis:
>
> If you are going to have a w32HMouse handler, avoid also having a
> w32HClick handler. Two routines essentially servicing one action is
> typically a bad thing.
>
> Here's what I suggest... get rid of the click handler completely and do
> something like this:
> }}}
<eucode>
> -----------------------------
>
> function getCurrentButton( integer x, integer y )
> -- If Button 1
> if x > 70 and x < 105 and y >46 and y < 75 then
> return 1
> -- If Button 2
> elsif x > 117 and x < 150 and y > 40 and y < 73 then
> return 2
> -- If Button 3
> elsif x > 164 and x < 195 and y > 45 and y < 73 then
> return 3
> -- If Button 4
> elsif x > 73 and x < 105 and y > 90 and y < 122 then
> return 4
> -- If Button 5
> elsif x > 121 and x < 151 and y > 89 and y < 121 then
> return 5
> -- If Button 6
> elsif x > 166 and x < 195 and y > 87 and y < 119 then
> return 6
> -- If Button 7
> elsif x > 75 and x < 106 and y > 139 and y < 169 then
> return 7
> -- If Button 8
> elsif x > 122 and x < 153 and y > 137 and y < 169 then
> return 8
> -- If Button 9
> elsif x > 166 and x < 196 and y > 136 and y < 166 then
> return 9
> -- If Button 0
> elsif x > 122 and x < 152 and y > 184 and y < 215 then
> return 0
> -- If Button * Ill call 11
> elsif x > 76 and x < 106 and y > 185 and y < 211 then
> return 11
> -- If Button # Ill call 12
> elsif x > 166 and x < 193 and y > 188 and y < 209 then
> return 12
> else
> return -1
> end if
>
> end function
>
> -----------------------------
>
> procedure Bitmap2_onMouse (integer self, integer event, sequence
> params)--params is ( int event, int x, int y, int shift, int wheelmove )
> if params[1] = LeftUp then
> CurButton = getCurrentButton( params[2], params[3] )
> if CurButton > -1 then
> UpdateSession()
> CurButton = -1
> else
> setText(SBar, "")
> end if
> end if
> end procedure
> setHandler( Bitmap2, w32HMouse, routine_id("Bitmap2_onMouse"))
>
> -----------------------------
> </eucode>
{{{
>
> As for the LED, the generic answer is: just brighten the colors where
> the LED is... I'd show you a quick way if I had my old programs in
> front of me. Maybe somebody else can help with that.
>
> -- Brian
>
> Tony Steward wrote:
> >
> >
> > Hello,
> > I am writing a safe lock emulator, but I have a couple of problems.
> > 1. When I click differant areas ove a bitmap it sometimes registers
> > twice. - Not sure how to prevent this.
> > 2. Part of the bitmap there is an LED. Is there a way I can make it
> > appear to blink on a mouse click without loading a whole second bitmap.
> >
> > Find my code at www.locksdownunder.com/LaGard.zip
> >
> > Any help or comments on a better way to do this would be appreciated
> >
> > Thanks
> > Tony
> >
>
Hi Tony,
You could use the bitBlt function with the DstInvert operation to make the
button 'blink'. For example add this:
if CurButton=5 then
bitBlt(Bitmap2,120,90,Bitmap2,120,90,32,32,DstInvert)
end if
to the end of your UpdateSession() procedure to see what that looks like for the
number 5. Off course it is better to make a separate paint routine for this.
I don't know if it is possible to bitBlt rounded shapes however.
Erik-Jan
3. RE: LaGard (was no subject)
Erik-Jan van Kampen wrote:
>
> Brian Broker wrote:
> >
> > Hi Tony,
> >
> > Here's my quick 'n dirty analysis:
> >
> > If you are going to have a w32HMouse handler, avoid also having a
> > w32HClick handler. Two routines essentially servicing one action is
> > typically a bad thing.
> >
> > Here's what I suggest... get rid of the click handler completely and do
> > something like this:
> > }}}
<eucode>
> > -----------------------------
> >
> > function getCurrentButton( integer x, integer y )
> > -- If Button 1
> > if x > 70 and x < 105 and y >46 and y < 75 then
> > return 1
> > -- If Button 2
> > elsif x > 117 and x < 150 and y > 40 and y < 73 then
> > return 2
> > -- If Button 3
> > elsif x > 164 and x < 195 and y > 45 and y < 73 then
> > return 3
> > -- If Button 4
> > elsif x > 73 and x < 105 and y > 90 and y < 122 then
> > return 4
> > -- If Button 5
> > elsif x > 121 and x < 151 and y > 89 and y < 121 then
> > return 5
> > -- If Button 6
> > elsif x > 166 and x < 195 and y > 87 and y < 119 then
> > return 6
> > -- If Button 7
> > elsif x > 75 and x < 106 and y > 139 and y < 169 then
> > return 7
> > -- If Button 8
> > elsif x > 122 and x < 153 and y > 137 and y < 169 then
> > return 8
> > -- If Button 9
> > elsif x > 166 and x < 196 and y > 136 and y < 166 then
> > return 9
> > -- If Button 0
> > elsif x > 122 and x < 152 and y > 184 and y < 215 then
> > return 0
> > -- If Button * Ill call 11
> > elsif x > 76 and x < 106 and y > 185 and y < 211 then
> > return 11
> > -- If Button # Ill call 12
> > elsif x > 166 and x < 193 and y > 188 and y < 209 then
> > return 12
> > else
> > return -1
> > end if
> >
> > end function
> >
> > -----------------------------
> >
> > procedure Bitmap2_onMouse (integer self, integer event, sequence
> > params)--params is ( int event, int x, int y, int shift, int wheelmove )
> > if params[1] = LeftUp then
> > CurButton = getCurrentButton( params[2], params[3] )
> > if CurButton > -1 then
> > UpdateSession()
> > CurButton = -1
> > else
> > setText(SBar, "")
> > end if
> > end if
> > end procedure
> > setHandler( Bitmap2, w32HMouse, routine_id("Bitmap2_onMouse"))
> >
> > -----------------------------
> > </eucode>
{{{
> >
> > As for the LED, the generic answer is: just brighten the colors where
> > the LED is... I'd show you a quick way if I had my old programs in
> > front of me. Maybe somebody else can help with that.
> >
> > -- Brian
> >
> > Tony Steward wrote:
> > >
> > >
> > > Hello,
> > > I am writing a safe lock emulator, but I have a couple of problems.
> > > 1. When I click differant areas ove a bitmap it sometimes registers
> > > twice. - Not sure how to prevent this.
> > > 2. Part of the bitmap there is an LED. Is there a way I can make it
> > > appear to blink on a mouse click without loading a whole second bitmap.
> > >
> > > Find my code at www.locksdownunder.com/LaGard.zip
> > >
> > > Any help or comments on a better way to do this would be appreciated
> > >
> > > Thanks
> > > Tony
> > >
> >
> Hi Tony,
>
> You could use the bitBlt function with the DstInvert operation to make the
> button
> 'blink'. For example add this:
>
> }}}
<eucode>
> if CurButton=5 then
> bitBlt(Bitmap2,120,90,Bitmap2,120,90,32,32,DstInvert)
> end if
> </eucode>
{{{
>
> to the end of your UpdateSession() procedure to see what that looks like for
> the number 5. Off course it is better to make a separate paint routine for
> this.
>
> I don't know if it is possible to bitBlt rounded shapes however.
>
> Erik-Jan
<snip>
When I read this again I saw this is not exactly what you wanted, but you may be
able to use it anyway.
Erik-Jan