TCL(Tool Command Language) Scripting

Give "curved corners" to entry widget

I'm trying to add an entry widget to my applications that looks like the Mac-style search widget, i.e. with oval rather than square corners, and with a magnifying glass embedded as an image. Jeff Hobbs' "menuentry" widget provides the magnifying glass, which I'm using now, but not the rounded corners.

Would it be feasible to create an entry megawidget with rounded corners using the canvas? I can't really think of another way to do it. I know that Mozilla apps "fake" the rounded corners with images, and that might be my approach as well. Any pointers on where I can begin?

I've been thinking about this too. I read in your blog that some Macophiles were saying your apps looked ugly because they didn't have a native search entry or whatever. I love when people nitpick over tiny imperfections even when the app looks really good. I think you're pretty close to native-looking apps, we just need to take it that one little extra step further.

I think the canvas is your best bet for approximating the search bar. It's pretty easy to draw the rounded entry, add the search icon, and the canvas even provides facilities for typing and handling text. Though I would probably just draw the rounded polygon and then drop an entry widget on top with an image outside the actual entry. If you keep it all white, it'll all look like it's one widget. You just need to make sure the canvas background matches that of the window beneath it.

It's all pretty easy. I wouldn't use an image though. You have a lot more flexibility with a canvas, and although the canvas generally is a heavier widget, you only ever really have one search box per app.

> I'm trying to add an entry widget to my applications that looks like the > Mac-style search widget, i.e. with oval rather than square corners, and > with a magnifying glass embedded as an image. Jeff Hobbs' "menuentry" > widget provides the magnifying glass, which I'm using now, but not the > rounded corners.

> Would it be feasible to create an entry megawidget with rounded corners > using the canvas? I can't really think of another way to do it. I know > that Mozilla apps "fake" the rounded corners with images, and that might > be my approach as well. Any pointers on where I can begin?

Kevin Walzer wrote: > Would it be feasible to create an entry megawidget with rounded corners > using the canvas?

Yes, that technique works fine. I've successfully created megawidgets by drawing them on a canvas. create an entry on the canvas with a borderwidth of zero, use the canvas to get the bbox of the entry, and draw a polygon around the edges. Or, depending on how round you want the ends, draw arcs or circles.

If you really want it to look "mac-like", take a snapshot of your favorite mac app, use an image manipulation tool to make copies of the edges, and surround the entry widget with pieces of the bitmaps.

> I'm trying to add an entry widget to my applications that looks like the > Mac-style search widget, i.e. with oval rather than square corners, and > with a magnifying glass embedded as an image.

So is the look of the search widget different than the other macos entry widgets? If so, perhaps it would be worthwhile for the MacTcl team to put together a package of MacOS-specific widgets for distribution .

Kevin Walzer wrote: > I'm trying to add an entry widget to my applications that looks > like the Mac-style search widget, i.e. with oval rather than > square corners, and with a magnifying glass embedded as an image. > Jeff Hobbs' "menuentry" widget provides the magnifying glass, > which I'm using now, but not the rounded corners.

Damon Courtney wrote: > I've been thinking about this too. I read in your blog that some > Macophiles were saying your apps looked ugly because they didn't have > a native search entry or whatever. I love when people nitpick over > tiny imperfections even when the app looks really good. I think > you're pretty close to native-looking apps, we just need to take it > that one little extra step further.

> I think the canvas is your best bet for approximating the search > bar. It's pretty easy to draw the rounded entry, add the search icon, > and the canvas even provides facilities for typing and handling text. > Though I would probably just draw the rounded polygon and then drop an > entry widget on top with an image outside the actual entry. If you > keep it all white, it'll all look like it's one widget. You just need > to make sure the canvas background matches that of the window beneath > it.

> It's all pretty easy. I wouldn't use an image though. You have a > lot more flexibility with a canvas, and although the canvas generally > is a heavier widget, you only ever really have one search box per app.

> Damon

I've done some work on this, and have gotten a "rounded rectangle" drawn with an entry embedded in it, and a magnifying glass icon. However, it's butt ugly, and is way too big--it looks much more out of place than what I'm currently using, the "menuentry widget" with a modified search icon. In fact, the only flaw in the menuentry widget is that the corners aren't rounded; otherwise it is perfect for my needs. So, after an hour or two of hacking, I'm inclined to stay with what I've got.

Kevin Walzer wrote: > I've done some work on this, and have gotten a "rounded rectangle" drawn > with an entry embedded in it, and a magnifying glass icon. However, it's > butt ugly, and is way too big--it looks much more out of place than what > I'm currently using, the "menuentry widget" with a modified search icon. > In fact, the only flaw in the menuentry widget is that the corners > aren't rounded; otherwise it is perfect for my needs. So, after an hour > or two of hacking, I'm inclined to stay with what I've got.

If you're good with a bitmap editor, create four tiny rounded corner images (each probably 4x4 or so) and use "place" to place them over the corners of your menuentry widget. If you are precise, and pick the right colors, no one will be the wiser.

Schelte Bron wrote: > Kevin Walzer wrote: >> I'm trying to add an entry widget to my applications that looks >> like the Mac-style search widget, i.e. with oval rather than >> square corners, and with a magnifying glass embedded as an image. >> Jeff Hobbs' "menuentry" widget provides the magnifying glass, >> which I'm using now, but not the rounded corners.

> I would expect this should be reasonably easy to do with Tile.

I was right and tried to post my results of about an hour of hacking here twice. However those posts never showed up. I'm guessing some "intelligent" filter decided my posts were garbage, probably due to the inlined gif image data.

Schelte Bron wrote: > Schelte Bron wrote: >> I would expect this should be reasonably easy to do with Tile.

> I was right and tried to post my results of about an hour of hacking > here twice. However those posts never showed up. I'm guessing some > "intelligent" filter decided my posts were garbage, probably due to > the inlined gif image data.

Schelte Bron wrote: > Schelte Bron wrote: >> Kevin Walzer wrote: >>> I'm trying to add an entry widget to my applications that looks >>> like the Mac-style search widget, i.e. with oval rather than >>> square corners, and with a magnifying glass embedded as an image. >>> Jeff Hobbs' "menuentry" widget provides the magnifying glass, >>> which I'm using now, but not the rounded corners.

>> I would expect this should be reasonably easy to do with Tile.

> I was right and tried to post my results of about an hour of hacking > here twice. However those posts never showed up. I'm guessing some > "intelligent" filter decided my posts were garbage, probably due to > the inlined gif image data.

You can do a lot of tricks with tile. See the shot at: http://coccinella.sourceforge.net/downloads/tileTricks.png and my code in coccinella/contrib/tileutils.tcl The shot was generated from the code at the bottom of that file with hardcoded image file paths. Coccinella: coccinella.sourceforge.net

>> I was right and tried to post my results of about an hour of >> hacking here twice. However those posts never showed up. I'm >> guessing some "intelligent" filter decided my posts were garbage, >> probably due to the inlined gif image data.

Mats wrote: > You can do a lot of tricks with tile. See the shot at: > http://coccinella.sourceforge.net/downloads/tileTricks.png > and my code in coccinella/contrib/tileutils.tcl > The shot was generated from the code at the bottom of that file with > hardcoded > image file paths. Coccinella: coccinella.sourceforge.net

> /Mats

What's the license on the tileutils code? Coccinella as a whole is GPL, but a lot of the supporting bits say they are licensed under BSD--tileutils.tcl, however, doesn't specify. I can use BSD stuff, but not GPL, in my applications.

> Mats wrote: > > You can do a lot of tricks with tile. See the shot at: > >http://coccinella.sourceforge.net/downloads/tileTricks.png > > and my code in coccinella/contrib/tileutils.tcl > > The shot was generated from the code at the bottom of that file with > > hardcoded > > image file paths. Coccinella: coccinella.sourceforge.net

> > /Mats

> What's the license on the tileutils code? Coccinella as a whole is GPL, > but a lot of the supporting bits say they are licensed under > BSD--tileutils.tcl, however, doesn't specify. I can use BSD stuff, but > not GPL, in my applications.

>>> I was right and tried to post my results of about an hour of >>> hacking here twice. However those posts never showed up. I'm >>> guessing some "intelligent" filter decided my posts were garbage, >>> probably due to the inlined gif image data.

If someone would like to add this to mentry.tcl or in some other way enshrine it as a tklib widget, I think it would be generally useful by all. (read: I accept patches, no time now to integrate it myself).