Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Text Field with buttons in it
Text Field with buttons in it [message #484065] Fri, 04 September 2009 07:42 Go to next message
Artem Redkin is currently offline Artem RedkinFriend
Messages: 26
Registered: July 2009
Junior Member
Hello,

can i create Text control with buttons in its field in SWT (Cocoa-only variant is acceptable)?

[Updated on: Mon, 07 September 2009 07:04]

Report message to a moderator

Re: Text Field with buttons in it [message #484517 is a reply to message #484065] Tue, 08 September 2009 02:42 Go to previous messageGo to next message
Benjamin Gold is currently offline Benjamin GoldFriend
Messages: 6
Registered: July 2009
Junior Member
Out of curiosity, why would you want to do this that you couldn't just piece together some sort of Text + Buttons in a Composite?

-----------------
Ben Gold
Re: Text Field with buttons in it [message #484567 is a reply to message #484517] Tue, 08 September 2009 09:47 Go to previous messageGo to next message
Artem Redkin is currently offline Artem RedkinFriend
Messages: 26
Registered: July 2009
Junior Member
I need to create cocoa version of a widget ( http://picasaweb.google.com/lh/photo/ZWLusJ1RhrXosCeqSHXcsA? feat=directlink - it's a carbon version), and thats how it was designed on other platforms.
Re: Text Field with buttons in it [message #484610 is a reply to message #484567] Tue, 08 September 2009 13:52 Go to previous messageGo to next message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3070
Registered: July 2009
Senior Member
On 9/8/09 5:47 AM, Artem Redkin wrote:
> I need to create cocoa version of a widget
> ( http://picasaweb.google.com/lh/photo/ZWLusJ1RhrXosCeqSHXcsA? feat=directlink
> - it's a carbon version), and thats how it was designed on other platforms.

That looks like it could be implemented as a Composite with a border,
that contains a Text with no border and the necessary Buttons (also with
no borders).

Hope this helps,
Eric
Re: Text Field with buttons in it [message #484613 is a reply to message #484610] Tue, 08 September 2009 14:01 Go to previous messageGo to next message
Artem Redkin is currently offline Artem RedkinFriend
Messages: 26
Registered: July 2009
Junior Member
Original carbon, win32 and GTK versions were made this way, the problem, actually, is how to draw text field frame and its focus (when needed) on cocoa.
Re: Text Field with buttons in it [message #484642 is a reply to message #484613] Tue, 08 September 2009 14:58 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Which styles are you creating your Text and Buttons with? Or, can you
provide the lines that create the Composite and its children? If you are
able to get the visual that you want on Carbon then it should be doable on
Cocoa as well. A Text should draw its frame and focus rect iff it's created
with style SWT.BORDER.

Grant


"Artem Redkin" <artem@redkin.su> wrote in message
news:h85o36$f72$1@build.eclipse.org...
> Original carbon, win32 and GTK versions were made this way, the problem,
actually, is how to draw text field frame and its focus (when needed) on
cocoa.
Re: Text Field with buttons in it [message #484692 is a reply to message #484642] Tue, 08 September 2009 18:35 Go to previous messageGo to next message
Artem Redkin is currently offline Artem RedkinFriend
Messages: 26
Registered: July 2009
Junior Member
TextField is drawn next to buttons, so if SWT.Border style is set, buttons wil be out of text field frame.

Now on carbon, gtk and win32 control created like this: composite with borderless text field and buttons (i added red background to text field to illustrate this: http://picasaweb.google.com/lh/photo/a5egjEQDuYLjH96WGSA7bQ? feat=directlink). Then with paint listener a frame is drawn around composite, so buttons and text inside it, like this:

composite.addPaintListener(new PaintListener() {

public void paintControl(PaintEvent e) {

int [] context = new int [1];
context[0] = e.gc.handle;
OS.CGContextSaveGState (context[0]);
int [] outMetric = new int [1];
OS.GetThemeMetric (OS.kThemeMetricFocusRectOutset, outMetric);
CGRect rect = new CGRect ();
OS.HIViewGetBounds (handle, rect);
rect.x += outMetric [0] + 1;
rect.y += outMetric [0];
rect.width -= outMetric [0] * 2 + 2;
rect.height -= outMetric [0] * 2;
int state = 0;
if (OS.IsControlEnabled (text.handle)) {
state = OS.IsControlActive (text.handle) ? OS.kThemeStateActive : OS.kThemeStateInactive;
} else {
state = OS.IsControlActive (text.handle) ? OS.kThemeStateUnavailable : OS.kThemeStateUnavailableInactive;
}
HIThemeFrameDrawInfo info = new HIThemeFrameDrawInfo ();
info.state = state;
info.isFocused = text.isFocusControl();
info.kind = OS.kHIThemeFrameTextFieldSquare;
OS.HIThemeDrawFrame (rect, info, context [0], OS.kHIThemeOrientationNormal);
OS.CGContextRestoreGState (context[0]);

}
});

The problem was that in cocoa there i could not find a method to draw simple frame. And i thought, maybe this design was a bit odd and there is a better way to do text field with buttons.
Re: Text Field with buttons in it [message #486581 is a reply to message #484692] Fri, 18 September 2009 10:15 Go to previous messageGo to next message
Artem Redkin is currently offline Artem RedkinFriend
Messages: 26
Registered: July 2009
Junior Member
Any ideas on this?
Re: Text Field with buttons in it [message #487064 is a reply to message #486581] Mon, 21 September 2009 17:45 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Sorry for the late response. It's fine to still use the HITheme* calls in
Cocoa, they aren't part of native Carbon that will be dead in the 64-bit
world. SWT uses HIThemeDrawFocusRect() in GC.drawFocus(...), which is
probably what you want (or if not, you can stick with HIThemeDrawFrame).

Grant


"Artem Redkin" <artem@redkin.su> wrote in message
news:h8vmk4$hj0$1@build.eclipse.org...
> Any ideas on this?
Re: Text Field with buttons in it [message #487133 is a reply to message #487064] Tue, 22 September 2009 06:19 Go to previous message
Artem Redkin is currently offline Artem RedkinFriend
Messages: 26
Registered: July 2009
Junior Member
All references about HITheme* calls i could find describe calls in HITheme.h of HIToolbox, which is part of Carbon. Even "quick-find" in XCode points to it. Are there such calls in Cocoa?

Thanks.

[Updated on: Tue, 22 September 2009 08:34]

Report message to a moderator

Previous Topic:Re: Drag and drop and cut, copy, paste between awt / swing and swt.
Next Topic:NoClassDefFoundError
Goto Forum:
  


Current Time: Sat Apr 20 02:04:34 GMT 2024

Powered by FUDForum. Page generated in 0.04315 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top