Code Duplication    Length = 37-39 lines in 2 locations

client/pygameui/SkinableTheme.py 2 locations

@@ 474-512 (lines=39) @@
471
    pygame.draw.lines(surface, fg, 1, points)
472
    return widget.rect
473
474
def drawTitleButton(surface, widget):
475
    rect = getDRect(widget.rect)
476
    rect.height += 1
477
    rect.width += 1
478
    oldClip = surface.get_clip()
479
    surface.set_clip(rect)
480
    foreground = widget.foreground or themeForeground
481
    font = widget.font or themeBoldFont
482
    # nicer background
483
    surface.fill(themeTitleLine1, rect)
484
    x1 = rect.left
485
    x2 = rect.right
486
    for y in xrange(rect.top, rect.bottom, 2):
487
        pygame.draw.line(surface, themeTitleLine2, (x1, y), (x2, y), 1)
488
    # icon
489
    if widget.icons:
490
        for img, align in widget.icons:
491
            r = getDRect(rect)
492
            if align & Const.ALIGN_W: r.left += 1
493
            elif align & Const.ALIGN_E: r.left += rect.width - img.get_width()
494
            else: r.left += (rect.width - img.get_width()) / 2
495
            if align & Const.ALIGN_N: r.top += 1
496
            elif align & Const.ALIGN_S: r.top += rect.height - img.get_height()
497
            else: r.top += (rect.height - img.get_height()) / 2
498
            surface.blit(img, r)
499
    # text
500
    if widget.text != None:
501
        if widget.pressed:
502
            foreground = themeHighlightfrg
503
        img = Fonts.renderText(font, widget.text, 1, foreground)
504
        r = getDRect(rect)
505
        if widget.align & Const.ALIGN_W: r.left += 2
506
        elif widget.align & Const.ALIGN_E: r.left += rect.width - img.get_width() - 1
507
        else: r.left += (rect.width - img.get_width()) / 2
508
        if widget.align & Const.ALIGN_N: r.top += 2
509
        elif widget.align & Const.ALIGN_S: r.top += rect.height - img.get_height() - 1
510
        else: r.top += (rect.height - img.get_height()) / 2
511
        surface.blit(img, r)
512
    surface.set_clip(oldClip)
513
514
def drawTitle(surface, widget):
515
    rect = getDRect(widget.rect)
@@ 514-550 (lines=37) @@
511
        surface.blit(img, r)
512
    surface.set_clip(oldClip)
513
514
def drawTitle(surface, widget):
515
    rect = getDRect(widget.rect)
516
    rect.height += 1
517
    rect.width += 1
518
    oldClip = surface.get_clip()
519
    surface.set_clip(rect)
520
    foreground = widget.foreground or themeForeground
521
    font = widget.font or themeDefaultFont
522
    # nicer background
523
    surface.fill(themeTitleLine1, rect)
524
    x1 = rect.left
525
    x2 = rect.right
526
    for y in xrange(rect.top, rect.bottom, 2):
527
        pygame.draw.line(surface, themeTitleLine2, (x1, y), (x2, y), 1)
528
    # icon
529
    if widget.icons:
530
        for img, align in widget.icons:
531
            r = getDRect(rect)
532
            if align & Const.ALIGN_W: r.left += 1
533
            elif align & Const.ALIGN_E: r.left += rect.width - img.get_width()
534
            else: r.left += (rect.width - img.get_width()) / 2
535
            if align & Const.ALIGN_N: r.top += 1
536
            elif align & Const.ALIGN_S: r.top += rect.height - img.get_height()
537
            else: r.top += (rect.height - img.get_height()) / 2
538
            surface.blit(img, r)
539
    # text
540
    if widget.text != None:
541
        img = Fonts.renderText(font, widget.text, 1, foreground)
542
        r = getDRect(rect)
543
        if widget.align & Const.ALIGN_W: r.left += 2
544
        elif widget.align & Const.ALIGN_E: r.left += rect.width - img.get_width() - 1
545
        else: r.left += (rect.width - img.get_width()) / 2
546
        if widget.align & Const.ALIGN_N: r.top += 2
547
        elif widget.align & Const.ALIGN_S: r.top += rect.height - img.get_height() - 1
548
        else: r.top += (rect.height - img.get_height()) / 2
549
        surface.blit(img, r)
550
    surface.set_clip(oldClip)
551
552
def drawEntry(surface, widget):
553
    rect = getDRect(widget.rect)