Jump to: navigation, search

Difference between revisions of "E4/CSS/SWT Mapping"

< E4‎ | CSS
(Pseudo classes which can be used in CSS to style SWT widgets)
(Widget: Control)
Line 56: Line 56:
 
</table>
 
</table>
 
<br>
 
<br>
 +
 +
===Widget: Button===
 +
<table cellpadding="5" border="1">
 +
<tr>
 +
<th>SWT Method</th>
 +
<th>CSS Property Name</th>
 +
<th>CSS Example</th>
 +
</tr>
 +
<tr>
 +
<td>setAlignment(int)</td>
 +
<td>alignment:</td>
 +
<td>Label { alignment: up; } /* if pushbutton mode */</td>
 +
</tr>
 +
 +
===Widget: Label===
 +
<table cellpadding="5" border="1">
 +
<tr>
 +
<th>SWT Method</th>
 +
<th>CSS Property Name</th>
 +
<th>CSS Example</th>
 +
</tr>
 +
<tr>
 +
<td>setAlignment(int)</td>
 +
<td>alignment:</td>
 +
<td>Label { alignment: center; }</td>
 +
</tr>
 +
 +
</table>
 +
<br>
 +
 
===Widget: CTabFolder===
 
===Widget: CTabFolder===
 
<table cellpadding="5" border="1">
 
<table cellpadding="5" border="1">

Revision as of 18:02, 8 July 2009

Many SWT property setting methods can be accessed via CSS. These tables show the equivalent mapping from SWT method to CSS property. They also show pseudo selectors which can be used to choose styling based on widget state.

Mapping of SWT method to CSS property

Widget: Control

SWT Method CSS Property Name CSS Example
setBackground(Color) background-color Button { background-color: #FF0000 }
setBackgroundImage(Image) background-image Button { background-image: some url }
border-color Button { border-color: ##FF0000; }
border-width Button { border-width: 3 }
border-style Button { border-style: dotted }
setCursor(Cursor) cursor Shell { cursor:crosshair }
setFont(Font) font-style

font-size
font-weight

font-family
Label { font-style: italic;

          font-size: 12;
          font-weight: bold;

          font-family: "Terminal"; }
setForeground(Color) color Button { color: #FF0000 }


Widget: Button

Widget: Label

SWT Method CSS Property Name CSS Example
setAlignment(int) alignment: Label { alignment: up; } /* if pushbutton mode */
SWT Method CSS Property Name CSS Example
setAlignment(int) alignment: Label { alignment: center; }


Widget: CTabFolder

SWT Method CSS Property Name CSS Example
setBorderVisible(Boolean) border-visible CTabFolder { border-visible: true }
setMaximized(Boolean) maximized CTabFolder { maximized: true }
setMinimized(Boolean) minimized CTabFolder { minimized: true }
setMaximizeVisible(Boolean) maximize-visible CTabFolder { maximize-visible: true }
setMinimizeVisible(Boolean) minimize-visible CTabFolder { minimize-visible: true }
setMRUVisible(Boolean) mru-visible CTabFolder { mru-visible: true }
setShowClose(Boolean) show-close CTabFolder { show-close: true }
setSimple(Boolean) simple CTabFolder { simple: true }
setSingle(Boolean) single CTabFolder { single: true }
setUnselectedCloseVisible(Boolean) unselected-close-visible CTabFolder { unselected-close-visible: true }
setUnselectedImageVisible(Boolean) unselected-image-visible CTabFolder { unselected-image-visible: true }


Pseudo classes which can be used in CSS to style SWT widgets

SWT Widgets CSS Pseudo Selector CSS Example
Control :focus CTabFolder:focus { background-color: ##FF0000; }
Control :visible † Shell:visible { background-color: ##FF0000; }
Control :enabled † Text:enabled { background-color: ##FF0000; }
Control :disabled † Text:disabled { background-color: ##FF0000; }
Shell :active Shell:active { background-color: ##FF0000; }
Button :checked Button:checked { background-color: ##FF0000; }
CTabFolder :selected CTabFolder:selected { background-color: ##FF0000; }


† As of yet styles are only applied when SWT UI is initially loaded, if widget state is changed afterwards, changes will not take effect