Author | Topic: Re: How to create custom button outlines. | |
---|---|---|
Philip Jackson | How to create custom button outlines. on Tue, 10 May 2011 12:10:30 +1200 I'm considering some menu buttons which have text on top of a designed graphic. The graphic could be non-rectangular - for example the right hand side could have its outline in the shape of an arrow to indicate that it leads to something else. Or I may want to make shapes in a particular form that is well suited to a particular industry. Has anyone done anything like this before, or have some suggestions? I have Topdown and Express++ libraries. Another way of doing this which is a bit more cumbersome and inconvenient, if possible, is to have a customised graphic with text already for each button on it. Cheers Phil Jackson | |
James Loughner | Re: How to create custom button outlines. on Mon, 09 May 2011 22:17:14 -0400 Look at my active text code http://gogalthorp.com/splash Jim On 05/09/2011 08:10 PM, Philip Jackson wrote: > I'm considering some menu buttons which have text on top of a designed > graphic. The graphic could be non-rectangular - for example the right > hand side could have its outline in the shape of an arrow to indicate > that it leads to something else. Or I may want to make shapes in a > particular form that is well suited to a particular industry. > > Has anyone done anything like this before, or have some suggestions? > > I have Topdown and Express++ libraries. > > Another way of doing this which is a bit more cumbersome and > inconvenient, if possible, is to have a customised graphic with text > already for each button on it. > > Cheers > > Phil Jackson | |
Philip Jackson | Re: How to create custom button outlines. on Tue, 10 May 2011 16:10:16 +1200 Hi Jim I recompiled your source code and got it working. It was interesting that you had this all working 7 years ago. It might be useful in some other areas maybe as I would still like to persevere with something that doesn't have a 4-sided border. Is there such a thing as a graphic object that is mouse sensitive, for example a bitmap that I could use effectively as a button? Cheers Phil Jackson On 5/10/2011 2:17 PM, James Loughner wrote: > Look at my active text code > > http://gogalthorp.com/splash > > Jim > > > On 05/09/2011 08:10 PM, Philip Jackson wrote: >> I'm considering some menu buttons which have text on top of a designed >> graphic. The graphic could be non-rectangular - for example the right >> hand side could have its outline in the shape of an arrow to indicate >> that it leads to something else. Or I may want to make shapes in a >> particular form that is well suited to a particular industry. >> >> Has anyone done anything like this before, or have some suggestions? >> >> I have Topdown and Express++ libraries. >> >> Another way of doing this which is a bit more cumbersome and >> inconvenient, if possible, is to have a customised graphic with text >> already for each button on it. >> >> Cheers >> >> Phil Jackson > | |
James Loughner | Re: How to create custom button outlines. on Tue, 10 May 2011 10:23:09 -0400 I just use a transparent static to hold the text you can replace the text with a graphic with a bit of work. But all things in Windows are windows and windows are rectangles. Remember bitmaps are also rectangles. I guess you could use graphic primitives. But you would need a method to determine if the mouse in the interior or the exterior. So basically you would be building a button totally from scratch and I'm not sure how the events would be handled. But you would still draw it on a static which is a rectangle. Jim On 05/10/2011 12:10 AM, Philip Jackson wrote: > Hi Jim > > I recompiled your source code and got it working. > > It was interesting that you had this all working 7 years ago. > > It might be useful in some other areas maybe as I would still like to > persevere with something that doesn't have a 4-sided border. > > Is there such a thing as a graphic object that is mouse sensitive, for > example a bitmap that I could use effectively as a button? > > Cheers > > Phil Jackson > > > On 5/10/2011 2:17 PM, James Loughner wrote: >> Look at my active text code >> >> http://gogalthorp.com/splash >> >> Jim >> >> >> On 05/09/2011 08:10 PM, Philip Jackson wrote: >>> I'm considering some menu buttons which have text on top of a designed >>> graphic. The graphic could be non-rectangular - for example the right >>> hand side could have its outline in the shape of an arrow to indicate >>> that it leads to something else. Or I may want to make shapes in a >>> particular form that is well suited to a particular industry. >>> >>> Has anyone done anything like this before, or have some suggestions? >>> >>> I have Topdown and Express++ libraries. >>> >>> Another way of doing this which is a bit more cumbersome and >>> inconvenient, if possible, is to have a customised graphic with text >>> already for each button on it. >>> >>> Cheers >>> >>> Phil Jackson >> > | |
Philip Jackson | Re: How to create custom button outlines. on Wed, 11 May 2011 08:48:49 +1200 Hi Jim I understand the rectangular need for Windows although it is interesting that in Browsers you can have round buttons for example. I think the simplest way of doing this is to have an invisible Static with the colour same as the background and no text, and a graphic (with the text as part of it) that although may have an irregular outline, fits inside that rectangle. I'll do some experimentation and see what I can produce. Cheers Phil Jackson | |
AUGE_OHR | Re: How to create custom button outlines. on Tue, 10 May 2011 23:26:52 +0200 hi, > that in Browsers you can have round buttons for example. > > I think the simplest way of doing this use Ownerdraw with GraEdge() to get "round" Buttons etc. greetings by OHR Jimmy | |
Philip Jackson | Re: How to create custom button outlines. on Wed, 11 May 2011 16:38:50 +1200 Hi Jimmy I have it all worked out without having to use OwnerDraw and it is really very very simple. The following uses TopDown but can be easily adapted to Express. I'm using tdBmap() to create and show a Bitmap object. I'm loading the Cargo with an array with the keyboard hotkey, and the resource numbers of the BitMap that signifies the button has been pressed and the original BitMap. oTest := tdBmap(10, 50,,, oDlg, 2000) oTest:Cargo := {'Z', 2001, 2000} In my event loop, I am looking for the Left Click - when I get it, I check to see if the object is set up the way I have set it up. The following code shows this IF nEvent = xbeM_LbClick IF ValType(OXBP) = 'O' .and. IsMemberVar(OXBP, 'CAPTION') .and. ; Caption stores bitmap valType(oXbp:Cargo) = 'A' .and. len(OXBP:Cargo) = 3 Cargo identifier - could be more sophisticated if necessary oBmp := NIL oBmp := XbpBitMap():New():CREATE() oBmp:Load(NIL,OXBP:Cargo[2]) oXbp:SetCaption(oBmp) Sleep(200) shorten for live app now show original bitmap again oBmp := NIL oBmp := XbpBitMap():New():CREATE() oBmp:Load(NIL,OXBP:Cargo[3]) oXbpP:SetCaption(oBmp) So even Bitmap objects recognise the mouse after all. One only finds simple solutions when one looks for them! Cheers Phil Jackson On 5/11/2011 9:26 AM, AUGE_OHR wrote: > hi, > >> that in Browsers you can have round buttons for example. >> >> I think the simplest way of doing this > > use Ownerdraw with GraEdge() to get "round" Buttons etc. > > greetings by OHR > Jimmy > > | |
Andreas Gehrs-Pahl | Re: How to create custom button outlines. on Wed, 11 May 2011 07:30:58 -0400 Phil, >oXbpP:SetCaption(oBmp) >So even Bitmap objects recognise the mouse after all. No they don't. The XbpStatic() that you created (oXbp) will react to the mouse events -- and it will do this independently from its caption, which could be a text or a bitmap, or nothing at all. And this XbpStatic() is still a rectangle, and will react to mouse events on its entire surface area, so clicking outside of the bitmap, if that bitmap is smaller or irregular in appearance, will still give the same effect, so the static shouldn't be much different in size and shape to its bitmap caption, or your button will appear to react to clicking "next to it". In addition, I would place all this bitmap changing code into a class -- or at least into CallBacks of the XbpStatic() -- rather than cluttering up and blocking the event loop! You should never do extended operations like this in the event loop -- especially a "Sleep(200)" in your event loop is very, very bad! It is obviously also bad in code that is called from your event loop, such as CallBack code blocks or methods. You could use "oXbp:LbClick := {|aPos, uNIL, obj| ChangeTheBitmap(obj)}" instead. But ":LbDown" and "LbUp" would work even better for simulating the "push down" effect. And you wouldn't need to create an artificial time out (of 2 seconds or less). Also, save both bitmaps in iVars of your class, rather than creating new bitmaps every time the user clicks on the static -- especially when you never destroy them anywhere! Otherwise, every click will create two more bitmaps that use up memory and resources. Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas.GP@Charter.net Andreas.Gehrs-Pahl@EJusticeSolutions.com Andreas@DDPSoftware.com web: http://www.Aerospace-History.net | |
Philip Jackson | Re: How to create custom button outlines. on Thu, 12 May 2011 09:00:43 +1200 Thanks Andreas I'm not worried about the small difference between the graphic and the Static - that's something I'm going to live with. A user typically doesn't press click outside a button. Only if I use Mouseover will it be a problem. I was doing this for an application that has a generic routine for handling menu only screens so the code only appears once. I'll follow your advice about holding the bitmaps in variables though and see what I can do about the callbacks. I'm going to have the text built into the bitmap so I don't need to worry about anything else. Cheers Phil Jackson On 5/11/2011 11:30 PM, Andreas Gehrs-Pahl wrote: > Phil, > >> oXbpP:SetCaption(oBmp) > >> So even Bitmap objects recognise the mouse after all. > > No they don't. The XbpStatic() that you created (oXbp) will react to the > mouse events -- and it will do this independently from its caption, which > could be a text or a bitmap, or nothing at all. > > And this XbpStatic() is still a rectangle, and will react to mouse events > on its entire surface area, so clicking outside of the bitmap, if that > bitmap is smaller or irregular in appearance, will still give the same > effect, so the static shouldn't be much different in size and shape to > its bitmap caption, or your button will appear to react to clicking "next > to it". > > In addition, I would place all this bitmap changing code into a class -- > or at least into CallBacks of the XbpStatic() -- rather than cluttering > up and blocking the event loop! You should never do extended operations > like this in the event loop -- especially a "Sleep(200)" in your event > loop is very, very bad! It is obviously also bad in code that is called > from your event loop, such as CallBack code blocks or methods. > > You could use "oXbp:LbClick := {|aPos, uNIL, obj| ChangeTheBitmap(obj)}" > instead. But ":LbDown" and "LbUp" would work even better for simulating > the "push down" effect. And you wouldn't need to create an artificial > time out (of 2 seconds or less). > > Also, save both bitmaps in iVars of your class, rather than creating new > bitmaps every time the user clicks on the static -- especially when you > never destroy them anywhere! Otherwise, every click will create two more > bitmaps that use up memory and resources. > > Andreas |