Community
Participate
Working Groups
org.eclipse.swt.Button has the following setters which are candidates for styling: Properties: setAlignment: LEFT/RIGHT/CENTER or LEFT/RIGHT/UP/DOWN if ARROW button setGrayed: boolean Pseudo Selectors: :selected I'm not sure what happens for setAlignment as we don't have the notion of a constant in CSS ... do you just write Button { alignment: LEFT; } and the value just comes in as a string?
>I'm not sure what happens for setAlignment as we don't have the notion of a >constant in CSS ... do you just write >Button { > alignment: LEFT; >} I have two ideas : 1. Perhaps whe should follow the same idea than SWT style used into selector. Button[style~='SWT.CHECK'] { ... } So we could write : Button { alignment: 'SWT.LEFT'; } We could use (and update it if need) class SWTStyleHelpers which manage CSS SWT style String by using int style value. 2. Follow CSS2 Properties I believe SWT button alignment is the same thing CSS text-align properties. See at http://www.w3schools.com/CSS/pr_text_text-align.asp. So we could write : Button { text-align:left; } In this cas, value comes from String. Regards Angelo
(In reply to comment #1) > >I'm not sure what happens for setAlignment as we don't have the notion of a > >constant in CSS ... do you just write > > >Button { > > alignment: LEFT; > >} > > I have two ideas : > > 1. Perhaps whe should follow the same idea than SWT style used into selector. > > Button[style~='SWT.CHECK'] { > ... > } > > So we could write : > > Button { > alignment: 'SWT.LEFT'; > } And just treat it as a string property right? How about how handle boolean ... it's also not a CSS2 property value so we just read as a string but then convert. In this case we don't quote it in the CSS source. > We could use (and update it if need) class SWTStyleHelpers which manage CSS SWT > style String by using int style value. Interesting, didn't know about this class. But we'd need a different method that went the other direction: took an SWT style string and returned the matching SWT constant. > 2. Follow CSS2 Properties > > I believe SWT button alignment is the same thing CSS text-align properties. See > at http://www.w3schools.com/CSS/pr_text_text-align.asp. > > So we could write : > > > Button { > text-align:left; > } > > In this cas, value comes from String. Very clever, but unfortunately doesn't include all the cases since for arrow buttons we also have SWT.UP, SWT.DOWN. In any case I like the other approach where we have a standardized way of reading in SWT constant values, validating, and converting. Thanks for the ideas Angelo.
Created attachment 132293 [details] checked pseudo selector for Button I added a selector for the Button widget. It is pretty much what you had, selected, but due to current implementation of the selected pseudo, I thought it might be easier to name it "checked" instead. So "Button: checked" can be used for styling. I've been trying for a while to make a Junit test for this, but since the implementation makes use of a SelectionListener, and the fact that setSelection() doesn't seem to send an event, I was unable to do so at the moment.
Created attachment 132295 [details] checked pseudo selector for Button Going through some of my code I realized that there were some unnecessary lines of code, so I removed them.
(In reply to comment #3) > Created an attachment (id=132293) [details] > checked pseudo selector for Button > > I added a selector for the Button widget. It is pretty much what you had, > selected, but due to current implementation of the selected pseudo, I thought > it might be easier to name it "checked" instead. So "Button: checked" can be > used for styling. I don't understand, why is "button:selected" a problem? The issue with the word "checked" is one that it doesn't match the getter getSelection(), plus Buttons can be style CHECK, so the pseudo ":checked" and the style "CHECK" seem related but are not. For example, this is the javadoc for getSelection(): * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>, * it is selected when it is checked. When it is of type <code>TOGGLE</code>, * it is selected when it is pushed in. If the receiver is of any other type, * this method returns false.
(In reply to comment #5) > I don't understand, why is "button:selected" a problem? I looked into my code and made a few changes, and it doesn't seem to conflict with the other "selected" pseudo. The patch is updated, and it is not Button:selected
Created attachment 132823 [details] selected pseudo selector for Button
Sorry there was a typo. It is NOW Button:selected
(In reply to comment #7) > Created an attachment (id=132823) [details] > selected pseudo selector for Button Great! Junit?
Verified it works for a standalone test, will close when junit attached. Releasing code now though.
Created attachment 132948 [details] junit for button:selected
Created attachment 133183 [details] Label and Button now have alignment stylable property Both Button and Label can now be styled with alignment. Unfortunately the engine cannot accept values with quotation marks, single quotes, and periods, therefore the available values are: left, right, center, up, down
Applied patch with following changes: - Label does *not* support alignment UP and DOWN (only for Buttons in arrow mode). Removed from property handler, tests. - Tests were a bit thin, only testing one alignment for each of Button and Label, added all alignments, including a second test for Button to create it in ARROW mode. - test superclass change for bug #277230 Note test classes released as part of #277230.
*** Bug 271532 has been marked as a duplicate of this bug. ***
reopening to fix owner
changing owner
re-closing