001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.gwt.client.ui; 029 030import org.opencms.gwt.client.ui.FontOpenCms.IconHTML; 031 032import com.google.gwt.dom.client.Document; 033import com.google.gwt.user.client.ui.HTML; 034 035/** 036 * OpenCms font icons.<p> 037 */ 038public enum FontOpenCms { 039 040 /** The apps icon. */ 041 APPS(0xe617), 042 043 /** The brackets icon. */ 044 BRACKETS(0xe64f), 045 046 /** The circle icon. */ 047 CIRCLE(0xe62a), 048 049 /** The circle cancel icon. */ 050 CIRCLE_CANCEL(0x622), 051 052 /** The circle check icon. */ 053 CIRCLE_CHECK(0xe61e), 054 055 /** The circle info icon. */ 056 CIRCLE_INFO(0xe640), 057 058 /** The circle invert icon. */ 059 CIRCLE_INV(0xe62b), 060 061 /** The circle invert cancel icon. */ 062 CIRCLE_INV_CANCEL(0xe623), 063 064 /** The circle invert check icon. */ 065 CIRCLE_INV_CHECK(0xe61f), 066 067 /** The circle invert minus icon. */ 068 CIRCLE_INV_MINUS(0xe629), 069 070 /** The circle invert pause icon. */ 071 CIRCLE_INV_PAUSE(0x0621), 072 073 /** The circle invert play icon. */ 074 CIRCLE_INV_PLAY(0xe625), 075 076 /** The circle invert plus icon. */ 077 CIRCLE_INV_PLUS(0xe627), 078 079 /** The circle minus icon. */ 080 CIRCLE_MINUS(0xe628), 081 082 /** The circle pause icon. */ 083 CIRCLE_PAUSE(0xe620), 084 085 /** The circle play icon. */ 086 CIRCLE_PLAY(0xe624), 087 088 /** The circle plus icon. */ 089 CIRCLE_PLUS(0xe626), 090 091 /** The circle help icon. */ 092 CIRCLE_HELP(0xe900), 093 094 /** The clipboard icon. */ 095 CLIPBOARD(0xe60f), 096 097 /** The context menu icon. */ 098 CONTEXT_MENU(0xe616), 099 100 /** The context menu dots icon. */ 101 CONTEXT_MENU_DOTS(0xe64a), 102 103 /** The copy locale icon. */ 104 COPY_LOCALE(0xe61a), 105 106 /** The bulls eye edit icon. */ 107 EDIT_POINT(0xe600), 108 109 /** The disabled bulls eye edit icon. */ 110 EDIT_POINT_DISABLED(0xe601), 111 112 /** The error icon. */ 113 ERROR(0xe63f), 114 115 /** The exit icon. */ 116 EXIT(0xe615), 117 118 /** The filter icon. */ 119 FILTER(0xe60c), 120 121 /** The gallery icon. */ 122 GALLERY(0xe611), 123 124 /** The help icon. */ 125 HELP(0xe602), 126 127 /** The disabled help icon. */ 128 HELP_DISABLED(0xe603), 129 130 /** The hide icon. */ 131 HIDE(0xe609), 132 133 /** The highlight icon. */ 134 HIGHLIGHT(0xe64c), 135 136 /** The info icon. */ 137 INFO(0xe612), 138 139 /** The invisible chars icon. */ 140 INVISIBLE_CHARS(0xe64d), 141 142 /** The pen/edit icon. */ 143 PEN(0xe614), 144 145 /** The publish icon. */ 146 PUBLISH(0xe60e), 147 148 /** The redo icon. */ 149 REDO(0xe607), 150 151 /** The remove locale icon. */ 152 REMOVE_LOCALE(0xe619), 153 154 /** The save icon. */ 155 SAVE(0xe60b), 156 157 /** The save and exit icon. */ 158 SAVE_EXIT(0xe60a), 159 160 /** The search icon. */ 161 SEARCH(0xe60d), 162 163 /** The search replace icon. */ 164 SEARCH_REPLACE(0xe64b), 165 166 /** The settings icon. */ 167 SETTINGS(0xe618), 168 169 /** The show icon. */ 170 SHOW(0xe608), 171 172 /** The sitemap icon. */ 173 SITEMAP(0xe613), 174 175 /** The undo icon. */ 176 UNDO(0xe606), 177 178 /** The upload icon. */ 179 UPLOAD(0xe604), 180 181 /** The wand icon. */ 182 WAND(0xe610), 183 184 /** The warning icon. */ 185 WARNING(0xe63e), 186 187 /** The wrap lines icon. */ 188 WRAP_LINES(0xe64e); 189 190 /** 191 * Font icon widget.<p> 192 */ 193 protected class IconHTML extends HTML { 194 195 /** 196 * Constructor.<p> 197 * 198 * @param codepoint the icon character code point 199 */ 200 IconHTML(int codepoint) { 201 202 super(Document.get().createSpanElement()); 203 getElement().setInnerHTML("&#x" + Integer.toHexString(codepoint) + ";"); 204 getElement().setClassName(FONT_ICON_CLASS); 205 } 206 207 /** 208 * Constructor.<p> 209 * 210 * @param codepoint the icon character code point 211 * @param size the icon size 212 */ 213 IconHTML(int codepoint, int size) { 214 215 this(codepoint); 216 getElement().setAttribute("style", "font-size: " + size + "px; line-height: " + size + "px;"); 217 } 218 219 /** 220 * Constructor.<p> 221 * 222 * @param codepoint the icon character code point 223 * @param size the icon size 224 * @param color the icon color 225 */ 226 IconHTML(int codepoint, int size, String color) { 227 228 this(codepoint); 229 getElement().setAttribute( 230 "style", 231 "font-size: " + size + "px; line-height: " + size + "px; color: " + color + ";"); 232 } 233 } 234 235 /** The font icon CSS class. */ 236 public static final String FONT_ICON_CLASS = "opencms-font-icon"; 237 238 /** The icon code point. */ 239 private int m_codepoint; 240 241 /** 242 * Constructor.<p> 243 * 244 * @param codepoint the icon code point 245 */ 246 FontOpenCms(int codepoint) { 247 248 m_codepoint = codepoint; 249 } 250 251 /** 252 * Gets the code point. 253 * 254 * @return the code point 255 */ 256 public int getCodePoint() { 257 258 return m_codepoint; 259 } 260 261 /** 262 * Formats the code point as an HTML entity. 263 * 264 * @return the code point as an HTML entity 265 */ 266 public String getCodePointEntity() { 267 268 return "&#x" + Integer.toHexString(m_codepoint) + ";"; 269 } 270 271 /** 272 * Returns the font family.<p> 273 * 274 * @return the font family 275 */ 276 public String getFontFamily() { 277 278 return "opencms-font"; 279 } 280 281 /** 282 * Returns the icon HTML.<p> 283 * 284 * @param size the icon size 285 * 286 * @return the icon HTML 287 */ 288 public String getHtml(int size) { 289 290 return "<span class=\"" 291 + FONT_ICON_CLASS 292 + "\" style=\"font-size: " 293 + size 294 + "px; line-height: " 295 + size 296 + "px;\">&#x" 297 + Integer.toHexString(m_codepoint) 298 + ";</span>"; 299 } 300 301 /** 302 * Returns the icon HTML.<p> 303 * 304 * @param size the icon size 305 * @param color the icon color 306 * 307 * @return the icon HTML 308 */ 309 public String getHtml(int size, String color) { 310 311 return "<span class=\"" 312 + FONT_ICON_CLASS 313 + "\" style=\"font-size: " 314 + size 315 + "px; line-height: " 316 + size 317 + "px; color: " 318 + color 319 + ";\">&#x" 320 + Integer.toHexString(m_codepoint) 321 + ";</span>"; 322 } 323 324 /** 325 * Returns the icon widget.<p> 326 * 327 * @param size the icon size 328 * 329 * @return the icon widget 330 */ 331 public HTML getWidget(int size) { 332 333 return new IconHTML(m_codepoint, size); 334 } 335 336 /** 337 * Returns the icon widget.<p> 338 * 339 * @param size the icon size 340 * @param color the icon color 341 * 342 * @return the icon widget 343 */ 344 public HTML getWidget(int size, String color) { 345 346 return new IconHTML(m_codepoint, size, color); 347 } 348 349}