KeyboardButton.qml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /**
  2. * Copyright © 2010 Digia Plc
  3. * Copyright © 2010 Nokia Corporation
  4. *
  5. * All rights reserved.
  6. *
  7. * Nokia and Nokia Connecting People are registered trademarks of
  8. * Nokia Corporation.
  9. * Java and all Java-based marks are trademarks or registered
  10. * trademarks of
  11. * Sun Microsystems, Inc. Other product and company names
  12. * mentioned herein may be
  13. * trademarks or trade names of their respective owners.
  14. *
  15. *
  16. * Subject to the conditions below, you may, without charge:
  17. *
  18. * · Use, copy, modify and/or merge copies of this software and
  19. * associated documentation files (the "Software")
  20. *
  21. * · Publish, distribute, sub-licence and/or sell new software
  22. * derived from or incorporating the Software.
  23. *
  24. *
  25. * This file, unmodified, shall be included with all copies or
  26. * substantial portions
  27. * of the Software that are distributed in source code form.
  28. *
  29. * The Software cannot constitute the primary value of any new
  30. * software derived
  31. * from or incorporating the Software.
  32. *
  33. * Any person dealing with the Software shall not misrepresent
  34. * the source of the Software.
  35. *
  36. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  37. * KIND, EXPRESS OR IMPLIED,
  38. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  39. * MERCHANTABILITY, FITNESS FOR A
  40. * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  41. * AUTHORS OR COPYRIGHT
  42. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  43. * WHETHER IN AN ACTION
  44. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  45. * CONNECTION WITH THE
  46. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  47. */
  48. import Qt 4.7
  49. import "../"
  50. CLButton {
  51. id: structure
  52. property CLStyle style : CLStyle{}
  53. property string value: ""
  54. property string shiftValue: value.toUpperCase()
  55. property string shiftTextFontFamily : style.fontFamily
  56. property string shiftTextFontWeight : style.fontWeight
  57. property real shiftTextFontSize: structure.height*0.2
  58. property color shiftTextColor: "red"
  59. property string shiftText: shiftValue
  60. property Image nullImage : Image { //this property is "private" don't write it to documentation
  61. id: "null"
  62. source: ""
  63. width: buttonWidth
  64. height: buttonHeight
  65. fillMode: Image.PreserveAspectCrop
  66. smooth: false
  67. scale: 1
  68. }
  69. property Image specialImage : nullImage
  70. property CLButton buttonCLStyle : CLButton{}
  71. /**
  72. * Returns HTML auml tag to uppercase
  73. * "<html>&auml;</html>" -> "<html>&Auml;</html>"
  74. */
  75. function htmlToUpperCase(htmlString) {
  76. return (htmlString.replace(htmlString.substring(7,8),htmlString.substring(7,8).toUpperCase()));
  77. }
  78. /**
  79. * Checks if word has html-tag in start.
  80. * "<html>&auml;</html>" -> true
  81. * "<html>" -> true
  82. * "<htm" -> false
  83. * "dog" -> false
  84. */
  85. function isHtml(string) {
  86. return (string.substring(0,6) == "<html>")
  87. }
  88. colorWhenDefault: buttonCLStyle.colorWhenDefault;
  89. colorWhenPressed: buttonCLStyle.colorWhenPressed;
  90. colorWhenHovered: buttonCLStyle.colorWhenHovered;
  91. textColor: buttonCLStyle.textColor;
  92. roundness: buttonCLStyle.roundness;
  93. borderColor: buttonCLStyle.borderColor;
  94. borderWidth: buttonCLStyle.borderWidth;
  95. fontSize: buttonCLStyle.fontSize;
  96. fontFamily: buttonCLStyle.fontFamily;
  97. fontWeight: buttonCLStyle.fontWeight;
  98. borderColorWhenHovered: buttonCLStyle.borderColorWhenHovered;
  99. borderColorWhenPressed: buttonCLStyle.borderColorWhenPressed;
  100. backgroundImage: buttonCLStyle.backgroundImage;
  101. backgroundImageWhenHovered: buttonCLStyle.backgroundImageWhenHovered;
  102. backgroundImageWhenPressed: buttonCLStyle.backgroundImageWhenPressed;
  103. gradientDefaultOn: buttonCLStyle.gradientDefaultOn;
  104. gradientHoveredOn: buttonCLStyle.gradientHoveredOn;
  105. gradientPressedOn: buttonCLStyle.gradientPressedOn;
  106. hoveredStateOn: buttonCLStyle.hoveredStateOn;
  107. pressedStateOn: buttonCLStyle.pressedStateOn;
  108. gradientWhenDefault: buttonCLStyle.gradientWhenDefault;
  109. gradientWhenHovered: buttonCLStyle.gradientWhenHovered;
  110. gradientWhenPressed: buttonCLStyle.gradientWhenPressed;
  111. textAlign: buttonCLStyle.textAlign;
  112. leftMargin: buttonCLStyle.leftMargin;
  113. rightMargin: buttonCLStyle.rightMargin
  114. smooth: buttonCLStyle.smooth
  115. gradientSelectedOn: buttonCLStyle.gradientSelectedOn;
  116. gradientWhenSelected: buttonCLStyle.gradientWhenSelected;
  117. colorWhenSelected: buttonCLStyle.colorWhenSelected;
  118. Image {
  119. source: specialImage.source
  120. width: if(source != "") specialImage.width
  121. height: if(source != "") specialImage.height
  122. anchors.verticalCenter: parent.verticalCenter
  123. anchors.horizontalCenter: parent.horizontalCenter
  124. smooth: specialImage.smooth
  125. scale: specialImage.scale
  126. }
  127. /** Shows shift mark in upleft corner**/
  128. Text {
  129. anchors.left: parent.left;
  130. anchors.leftMargin: structure.width*0.1;
  131. anchors.top: parent.top;
  132. anchors.topMargin: structure.height*0.1;
  133. text: shiftText;
  134. color: shiftTextColor
  135. font.pointSize: 0.001+shiftTextFontSize
  136. }
  137. }