Exemple #1
0
    def __init__(self, menuRoot, item, cssFName=None, toggle='off'):
        PGItem.__init__(self, item['txt'])
        PGItem.setPythonTag(self, "extras", self)
        self.item = item
        self.menuRoot = menuRoot
        self.cssFName = cssFName
        self.dragSound = None
        if item['kind'] in ('checkBox', 'radioBTN'):
            tt = item['txt'].split('\n')
            ll = len(tt)
            ttt = ''
            for t in tt:
                ttt += checkBoxShim * ll + t + '\n'  # make room for checkbox)
            item['txt'] = ttt[:-1]  #remove last new-line
            self.setTag('toggle', toggle)
        self.style = getStyle(getSelectors(item), self.cssFName)
        width, height, lineHeight, fr = getTextSize(item['txt'], self.style)
        self.setFrame(fr)
        if item['kind'] == 'separator':
            sh = self.style['height'] * self.style['font-size']
            self.setFrame(0, width, -sh / 2, sh / 2)
        fs = PGFrameStyle()
        fs.setType(PGFrameStyle.TNone)
        self.setFrameStyle(0, fs)
        self.setTag('id', item['id'])
        if 'groupID' in item: self.setTag('groupID', item['groupID'])

        ###
        self.clickAccepted = False  #JUSTIN'S INSERTED CODE
Exemple #2
0
	def __init__(self, menuRoot, item, cssFName=None, toggle='off'):
		PGItem.__init__(self, item['txt'])
		PGItem.setPythonTag(self, "extras", self)
		self.item = item
		self.menuRoot = menuRoot
		self.cssFName = cssFName
		self.dragSound = None
		if item['kind'] in ('checkBox', 'radioBTN'):
			tt = item['txt'].split('\n')
			ll = len(tt)
			ttt = ''
			for t in tt:
				ttt += checkBoxShim*ll + t + '\n' # make room for checkbox)
			item['txt'] = ttt[:-1] #remove last new-line
			self.setTag('toggle', toggle)
		self.style = getStyle(getSelectors(item), self.cssFName)
		width, height, lineHeight,fr = getTextSize(item['txt'], self.style)
		self.setFrame(fr)
		if item['kind']=='separator':
			sh = self.style['height']*self.style['font-size']
			self.setFrame(0,width, -sh/2, sh/2) 
		fs=PGFrameStyle() 
		fs.setType(PGFrameStyle.TNone) 
		self.setFrameStyle(0, fs) 
		self.setTag('id', item['id'])
		if 'groupID' in item: self.setTag('groupID', item['groupID'])

		###
		self.clickAccepted = False  #JUSTIN'S INSERTED CODE
Exemple #3
0
def getBackgroundSet(menuItem, frame, arrowhead):
    item = menuItem.item
    kind = item['kind']
    txt = item['txt']
    grphcs = []
    slctrs = ['menu ' + kind]
    if 'class' in item:  # class after kind: class has higher priority
        slctrs.append('.' + item['class'])
    if 'id' in item:  # id after class: id has higher priority
        slctrs.append('#' + item['id'])
    style = getStyle(slctrs, menuItem.cssFName)
    if 'enter-sound' in style:
        loadSound(menuItem, menuItem.getEnterEvent(), style, 'enter-sound')
    if 'exit-sound' in style:
        loadSound(menuItem, menuItem.getExitEvent(), style, 'exit-sound')
    if 'press-sound' in style:
        loadSound(menuItem, menuItem.getPressEvent(MouseButton.one()), style,
                  'press-sound')
    if 'release-sound' in style:
        loadSound(menuItem, menuItem.getReleaseEvent(MouseButton.one()), style,
                  'release-sound')
    if 'drag-sound' in style: loadSound(menuItem, None, style, 'drag-sound')
    for state in STATES:
        slctrs = ['menu ' + kind + ' :' + stateName[state].lower()]
        if 'class' in item:  # class after kind: class has higher priority
            slctrs.append('.' + item['class'] + ' :' +
                          stateName[state].lower())
        if 'id' in item:  # id after class: id has higher priority
            slctrs.append('#' + item['id'] + ' :' + stateName[state].lower())
        style = getStyle(slctrs, menuItem.cssFName)
        # Want to add more style properties?
        # Do it here:
        # Match style keys here to property names in .ccss
        fontSize = style['font-size']
        bevel = style['bevel'] * fontSize
        font = style['font']
        color = style['color']
        tn = TextNode(txt)
        tn.setText(txt)
        tn.setFont(loader.loadFont(font))
        tn.setSlant(style['slant'])
        tn.setTextColor(color)
        tn.setShadow(*style['shadow-offset'])
        tn.setShadowColor(*style['shadow-color'])
        NodePath(tn).setScale(fontSize)
        sHolder = NodePath(PandaNode('sHolder'))
        sHolder.attachNewNode(tn)
        grphcs.append(sHolder)
        sHolder.attachNewNode(tn)
        borderColor = style['border-Color']
        thk = style['border-thickness']
        if 'background-Color' in style and\
         style['background-Color'] != 'transparent':
            bgColor = style['background-Color']
        else:
            bgColor = None
        if kind == 'parent':
            if state == HOVER: ar = arrowhead * 2
            else: ar = arrowhead
            grphcs[state].attachNewNode(
                bevelArrow(frame, bevel, ar, thk, color, borderColor, bgColor))
        elif kind in ('horizontal', 'titleBar', 'close'):
            grphcs[state].attachNewNode(
                rectangle(frame, thk, color, borderColor, bgColor))
        elif kind == 'checkBox':
            grphcs[state].attachNewNode(
                checkBox(frame, bevel, thk, color, borderColor, bgColor))
            cb = grphcs[state].attachNewNode(
                checkedBox(frame, bevel, thk, color, borderColor, bgColor))
            cb.hide()
        elif kind == 'radioBTN':
            grphcs[state].attachNewNode(
                radioBTN(frame, bevel, thk, color, borderColor, bgColor))
            cb = grphcs[state].attachNewNode(
                checkedRadioBTN(frame, bevel, thk, color, borderColor,
                                bgColor))
            cb.hide()
        else:
            grphcs[state].attachNewNode(
                bevelBG(frame, bevel, thk, borderColor, bgColor))
    return grphcs
Exemple #4
0
def getBackgroundSet(menuItem, frame, arrowhead):
	item = menuItem.item
	kind = item['kind']
	txt = item['txt']
	grphcs = []
	slctrs = ['menu '+kind]
	if 'class' in item: # class after kind: class has higher priority
		slctrs.append('.'+item['class'])
	if 'id' in item: # id after class: id has higher priority
		slctrs.append('#'+item['id'])
	style = getStyle(slctrs, menuItem.cssFName)
	if 'enter-sound' in style: loadSound(menuItem, menuItem.getEnterEvent(), style, 'enter-sound')
	if 'exit-sound' in style: loadSound(menuItem, menuItem.getExitEvent(), style, 'exit-sound')
	if 'press-sound' in style: loadSound(menuItem, menuItem.getPressEvent(MouseButton.one()), style, 'press-sound')
	if 'release-sound' in style: loadSound(menuItem, menuItem.getReleaseEvent(MouseButton.one()), style, 'release-sound')
	if 'drag-sound' in style: loadSound(menuItem, None, style, 'drag-sound')
	for state in STATES:
		slctrs = ['menu '+kind+' :'+stateName[state].lower()]
		if 'class' in item: # class after kind: class has higher priority
			slctrs.append('.'+item['class']+' :'+stateName[state].lower())
		if 'id' in item: # id after class: id has higher priority
			slctrs.append('#'+item['id']+' :'+stateName[state].lower())
		style = getStyle(slctrs, menuItem.cssFName)
		# Want to add more style properties?
		# Do it here:
		# Match style keys here to property names in .ccss
		fontSize = style['font-size']
		bevel = style['bevel']*fontSize
		font  = style['font']
		color = style['color']
		tn = TextNode(txt)
		tn.setText(txt)
		tn.setFont(loader.loadFont(font))
		tn.setSlant(style['slant'])
		tn.setTextColor(color)
		tn.setShadow(*style['shadow-offset'])
		tn.setShadowColor(*style['shadow-color'])
		NodePath(tn).setScale(fontSize)
		sHolder = NodePath(PandaNode('sHolder'))
		sHolder.attachNewNode(tn)
		grphcs.append(sHolder)
		sHolder.attachNewNode(tn)
		borderColor = style['border-Color']
		thk = style['border-thickness']
		if 'background-Color' in style and\
			style['background-Color'] != 'transparent':
			bgColor = style['background-Color']
		else: bgColor = None
		if kind=='parent':
			if state==HOVER: ar = arrowhead*2
			else: ar = arrowhead
			grphcs[state].attachNewNode(bevelArrow(frame, bevel, ar, thk, color, borderColor, bgColor))
		elif kind in ('horizontal', 'titleBar', 'close'):
			grphcs[state].attachNewNode(rectangle(frame, thk, color, borderColor, bgColor))
		elif kind=='checkBox':
			grphcs[state].attachNewNode(checkBox(frame, bevel, thk, color, borderColor, bgColor))
			cb = grphcs[state].attachNewNode(checkedBox(frame, bevel, thk, color, borderColor, bgColor))
			cb.hide()
		elif kind=='radioBTN':
			grphcs[state].attachNewNode(radioBTN(frame, bevel, thk, color, borderColor, bgColor))
			cb = grphcs[state].attachNewNode(checkedRadioBTN(frame, bevel, thk, color, borderColor, bgColor))
			cb.hide()
		else:
			grphcs[state].attachNewNode(bevelBG(frame, bevel, thk, borderColor, bgColor))
	return grphcs