aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/utils
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2017-10-08 20:03:45 +0200
committerRobert Jaros <rjaros@finn.pl>2017-10-08 20:03:45 +0200
commitd5b33bcbcca3d9ef512703a42a562770600e6836 (patch)
tree252ac0e93885af2ce87088367dbf3e7900090029 /src/main/kotlin/pl/treksoft/kvision/utils
parentdc9dc5df0e012b487dd6fd5918a1e0bd3d06a4ce (diff)
downloadkvision-d5b33bcbcca3d9ef512703a42a562770600e6836.tar.gz
kvision-d5b33bcbcca3d9ef512703a42a562770600e6836.tar.bz2
kvision-d5b33bcbcca3d9ef512703a42a562770600e6836.zip
Refactoring StyledComponent out of Widget
Implementation of border, margin and padding properties
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/utils')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt
new file mode 100644
index 00000000..5a9bf5a6
--- /dev/null
+++ b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt
@@ -0,0 +1,38 @@
+@file:Suppress("TooManyFunctions")
+package pl.treksoft.kvision.utils
+
+import pl.treksoft.kvision.css.CssSize
+import pl.treksoft.kvision.css.UNIT
+
+fun Int.px(): CssSize = Pair(this, UNIT.px)
+fun Int.em(): CssSize = Pair(this, UNIT.em)
+fun Int.pt(): CssSize = Pair(this, UNIT.pt)
+fun Int.perc(): CssSize = Pair(this, UNIT.perc)
+fun Int.rem(): CssSize = Pair(this, UNIT.rem)
+fun Int.ch(): CssSize = Pair(this, UNIT.ch)
+fun Int.cm(): CssSize = Pair(this, UNIT.cm)
+fun Int.mm(): CssSize = Pair(this, UNIT.mm)
+@Suppress("FunctionNaming")
+fun Int.`in`(): CssSize = Pair(this, UNIT.`in`)
+fun Int.pc(): CssSize = Pair(this, UNIT.pc)
+fun Int.vh(): CssSize = Pair(this, UNIT.vh)
+fun Int.vw(): CssSize = Pair(this, UNIT.vw)
+fun Int.vmin(): CssSize = Pair(this, UNIT.vmin)
+fun Int.vmax(): CssSize = Pair(this, UNIT.vmax)
+
+object Utils {
+
+ private val hex = arrayOf("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f")
+
+ @Suppress("MagicNumber")
+ fun intToHexString(n: Int): String {
+ var result = ""
+ var num = n
+ for (i in 0 until 6) {
+ result = hex[num and 0xF] + result
+ num = num shr 4
+ }
+ return result
+ }
+
+}