Skip to main content



      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 03:42 Go to next message
Eclipse UserFriend
Hello,

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

[Updated on: Mon, 07 September 2009 03:04] by Moderator

Re: Text Field with buttons in it [message #484517 is a reply to message #484065] Mon, 07 September 2009 22:42 Go to previous messageGo to next message
Eclipse UserFriend
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 05:47 Go to previous messageGo to next message
Eclipse UserFriend
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 09:52 Go to previous messageGo to next message
Eclipse UserFriend
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 10:01 Go to previous messageGo to next message
Eclipse UserFriend
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 10:58 Go to previous messageGo to next message
Eclipse UserFriend
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 14:35 Go to previous messageGo to next message
Eclipse UserFriend
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 06:15 Go to previous messageGo to next message
Eclipse UserFriend
Any ideas on this?
Re: Text Field with buttons in it [message #487064 is a reply to message #486581] Mon, 21 September 2009 13:45 Go to previous messageGo to next message
Eclipse UserFriend
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 02:19 Go to previous message
Eclipse UserFriend
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 04:34] by Moderator

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


Current Time: Tue Jul 22 18:35:46 EDT 2025

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

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

Back to the top