예제 #1
0
    def populate(self, fontName):
        if not BigWorld.ime.candidatesVisible:
            self.comp.visible = False
            return False
        candidates = BigWorld.ime.candidates
        selectedIdx = BigWorld.ime.selectedCandidate
        fullText = u''
        preSelectWidth = 0
        for i in range(len(candidates)):
            fullText += str(i + 1) + candidates[i]
            if i < len(candidates) - 1:
                fullText += u'\n' if BigWorld.ime.candidatesVertical else u' '
            if i == selectedIdx - 1:
                preSelectWidth, _ = self.comp.candidateText.stringDimensions(
                    fullText)

        self.comp.candidateText.font = fontName
        self.comp.candidateText.text = fullText
        sw, sh = self.comp.candidateText.stringDimensions(fullText)
        self._resize(sw, sh)
        if hasattr(self.comp, 'selectedCandidate'):
            self.comp.delChild(self.comp.selectedCandidate)
        if len(candidates) > 0:
            selStr = str(selectedIdx + 1) + candidates[selectedIdx]
            selectedComp = _bgText(selStr, fontName,
                                   SELECTED_CANDIDATE_BGCOLOUR,
                                   SELECTED_CANDIDATE_FGCOLOUR)
            selectedComp.horizontalAnchor = 'LEFT'
            selectedComp.horizontalPositionMode = 'PIXEL'
            selectedComp.verticalAnchor = 'TOP'
            selectedComp.verticalPositionMode = 'PIXEL'
            selectedComp.position.z = 0.01
            selectedComp.text.horizontalPositionMode = 'PIXEL'
            selectedComp.text.horizontalAnchor = 'LEFT'
            selectedComp.text.position.x = 0
            fontWidth, fontHeight = self.comp.candidateText.stringDimensions(
                selStr)
            if BigWorld.ime.candidatesVertical:
                selectedComp.position.x = 0
                selectedComp.position.y = fontHeight * selectedIdx * getVPixelScalar(
                )
                selectedComp.widthMode = self.comp.widthMode
                selectedComp.width = self.comp.width
            else:
                selectedComp.position.x = preSelectWidth * getHPixelScalar()
                selectedComp.position.y = 0
                selectedComp.widthMode = 'PIXEL'
                selectedComp.width = (fontWidth + 1) * getHPixelScalar()
                selectedComp.heightMode = self.comp.heightMode
                selectedComp.height = self.comp.height
            self.comp.addChild(selectedComp, 'selectedCandidate')
        self.comp.visible = True
        return True
예제 #2
0
    def populate(self, fontName):
        if not BigWorld.ime.candidatesVisible:
            self.comp.visible = False
            return False
        candidates = BigWorld.ime.candidates
        selectedIdx = BigWorld.ime.selectedCandidate
        fullText = u''
        preSelectWidth = 0
        for i in range(len(candidates)):
            fullText += str(i + 1) + candidates[i]
            if i < len(candidates) - 1:
                fullText += u'\n' if BigWorld.ime.candidatesVertical else u' '
            if i == selectedIdx - 1:
                preSelectWidth, _ = self.comp.candidateText.stringDimensions(fullText)

        self.comp.candidateText.font = fontName
        self.comp.candidateText.text = fullText
        sw, sh = self.comp.candidateText.stringDimensions(fullText)
        self._resize(sw, sh)
        if hasattr(self.comp, 'selectedCandidate'):
            self.comp.delChild(self.comp.selectedCandidate)
        if len(candidates) > 0:
            selStr = str(selectedIdx + 1) + candidates[selectedIdx]
            selectedComp = _bgText(selStr, fontName, SELECTED_CANDIDATE_BGCOLOUR, SELECTED_CANDIDATE_FGCOLOUR)
            selectedComp.horizontalAnchor = 'LEFT'
            selectedComp.horizontalPositionMode = 'PIXEL'
            selectedComp.verticalAnchor = 'TOP'
            selectedComp.verticalPositionMode = 'PIXEL'
            selectedComp.position.z = 0.01
            selectedComp.text.horizontalPositionMode = 'PIXEL'
            selectedComp.text.horizontalAnchor = 'LEFT'
            selectedComp.text.position.x = 0
            fontWidth, fontHeight = self.comp.candidateText.stringDimensions(selStr)
            if BigWorld.ime.candidatesVertical:
                selectedComp.position.x = 0
                selectedComp.position.y = fontHeight * selectedIdx * getVPixelScalar()
                selectedComp.widthMode = self.comp.widthMode
                selectedComp.width = self.comp.width
            else:
                selectedComp.position.x = preSelectWidth * getHPixelScalar()
                selectedComp.position.y = 0
                selectedComp.widthMode = 'PIXEL'
                selectedComp.width = (fontWidth + 1) * getHPixelScalar()
                selectedComp.heightMode = self.comp.heightMode
                selectedComp.height = self.comp.height
            self.comp.addChild(selectedComp, 'selectedCandidate')
        self.comp.visible = True
        return True
예제 #3
0
    def _populateChineseJapanese(self, fontName):
        compString = BigWorld.ime.composition
        self.comp.text.font = fontName
        self.comp.text.text = ''
        compBlocks = _compositionStringBlocks()
        raise len(compBlocks) > 0 or AssertionError
        self._firstTargetConvertedBlock = -1
        fullWidth = 0
        idx = 0
        for attr, str in compBlocks:
            bgColour, fgColour = _attrToColours(attr)
            if self._firstTargetConvertedBlock < 0 and attr not in [ATTR_INPUT, ATTR_CONVERTED]:
                self._firstTargetConvertedBlock = idx
            w = _bgText(str, fontName, bgColour, fgColour)
            w.horizontalAnchor = 'LEFT'
            w.horizontalPositionMode = 'PIXEL'
            w.position.x = fullWidth
            self.comp.addChild(w, 'compBlock%d' % idx)
            idx += 1
            fullWidth += w.width

        self.comp.widthMode = 'PIXEL'
        self.comp.width = fullWidth
        _, self.comp.height = self.comp.compBlock0.text.stringDimensions(compString)
        self.comp.height = self.comp.height * getVPixelScalar()
        cursorIndex = BigWorld.ime.compositionCursorPosition
        cursorOffset = self.comp.compBlock0.text.stringWidth(compString[:cursorIndex])
        self.cursor.comp.position.x = cursorOffset * getHPixelScalar()
        self.comp.backgroundColouriser.colourProvider = BACKGROUND_COLOUR
        self.cursor.enable(True)
        self.cursor.touch()
예제 #4
0
    def _populateChineseJapanese(self, fontName):
        compString = BigWorld.ime.composition
        self.comp.text.font = fontName
        self.comp.text.text = ''
        compBlocks = _compositionStringBlocks()
        raise len(compBlocks) > 0 or AssertionError
        self._firstTargetConvertedBlock = -1
        fullWidth = 0
        idx = 0
        for attr, str in compBlocks:
            bgColour, fgColour = _attrToColours(attr)
            if self._firstTargetConvertedBlock < 0 and attr not in [ATTR_INPUT, ATTR_CONVERTED]:
                self._firstTargetConvertedBlock = idx
            w = _bgText(str, fontName, bgColour, fgColour)
            w.horizontalAnchor = 'LEFT'
            w.horizontalPositionMode = 'PIXEL'
            w.position.x = fullWidth
            self.comp.addChild(w, 'compBlock%d' % idx)
            idx += 1
            fullWidth += w.width

        self.comp.widthMode = 'PIXEL'
        self.comp.width = fullWidth
        _, self.comp.height = self.comp.compBlock0.text.stringDimensions(compString)
        self.comp.height = self.comp.height * getVPixelScalar()
        cursorIndex = BigWorld.ime.compositionCursorPosition
        cursorOffset = self.comp.compBlock0.text.stringWidth(compString[:cursorIndex])
        self.cursor.comp.position.x = cursorOffset * getHPixelScalar()
        self.comp.backgroundColouriser.colourProvider = BACKGROUND_COLOUR
        self.cursor.enable(True)
        self.cursor.touch()
예제 #5
0
 def populate(self, fontName):
     readingString = BigWorld.ime.reading
     if not BigWorld.ime.readingVisible or len(readingString) == 0:
         self.comp.visible = False
         return False
     self.comp.text.font = fontName
     if BigWorld.ime.readingVertical:
         readingString = '\n'.join([ c for c in readingString ])
     horzMargin = self.MARGIN_SIZE * getHPixelScalar()
     vertMargin = self.MARGIN_SIZE * getVPixelScalar()
     self.comp.text.text = readingString
     self.comp.text.position.x = horzMargin
     self.comp.text.position.y = vertMargin
     self.comp.widthMode = 'PIXEL'
     textWidth, textHeight = self.comp.text.stringDimensions(readingString)
     self.comp.width = horzMargin * 2 + textWidth * getHPixelScalar()
     self.comp.height = vertMargin * 2 + textHeight * getVPixelScalar()
     self.comp.visible = True
     return True
예제 #6
0
 def populate(self, fontName):
     readingString = BigWorld.ime.reading
     if not BigWorld.ime.readingVisible or len(readingString) == 0:
         self.comp.visible = False
         return False
     self.comp.text.font = fontName
     if BigWorld.ime.readingVertical:
         readingString = '\n'.join([ c for c in readingString ])
     horzMargin = self.MARGIN_SIZE * getHPixelScalar()
     vertMargin = self.MARGIN_SIZE * getVPixelScalar()
     self.comp.text.text = readingString
     self.comp.text.position.x = horzMargin
     self.comp.text.position.y = vertMargin
     self.comp.widthMode = 'PIXEL'
     textWidth, textHeight = self.comp.text.stringDimensions(readingString)
     self.comp.width = horzMargin * 2 + textWidth * getHPixelScalar()
     self.comp.height = vertMargin * 2 + textHeight * getVPixelScalar()
     self.comp.visible = True
     return True
예제 #7
0
 def _populateKorean(self, fontName):
     compString = BigWorld.ime.composition
     self.comp.text.font = fontName
     self.comp.text.text = compString
     sw, sh = self.comp.text.stringDimensions(compString)
     hratio = getHPixelScalar()
     vratio = getVPixelScalar()
     self.comp.width = sw * hratio
     self.comp.height = sh * vratio
     self.comp.text.position.x = 0
     self.comp.backgroundColouriser.colourProvider = blinkingColourProvider(BACKGROUND_COLOUR, Utils.CURSOR_BLINK_PERIOD)
     self.cursor.enable(False)
예제 #8
0
 def _populateKorean(self, fontName):
     compString = BigWorld.ime.composition
     self.comp.text.font = fontName
     self.comp.text.text = compString
     sw, sh = self.comp.text.stringDimensions(compString)
     hratio = getHPixelScalar()
     vratio = getVPixelScalar()
     self.comp.width = sw * hratio
     self.comp.height = sh * vratio
     self.comp.text.position.x = 0
     self.comp.backgroundColouriser.colourProvider = blinkingColourProvider(BACKGROUND_COLOUR, Utils.CURSOR_BLINK_PERIOD)
     self.cursor.enable(False)
예제 #9
0
 def _resize(self, pixelW, pixelH):
     self.comp.width = pixelW * getHPixelScalar()
     self.comp.height = pixelH * getVPixelScalar()
예제 #10
0
 def _resize(self, pixelW, pixelH):
     self.comp.width = pixelW * getHPixelScalar()
     self.comp.height = pixelH * getVPixelScalar()