Beispiel #1
0
    def Draw(self):
        start_rect = midRect(self._PosX, self._PosY, self._Width, self._Height,
                             Width, Height)
        aa_round_rect(self._CanvasHWND, start_rect, self._Color, 3, 0,
                      self._Color)

        if self._Value > 10:
            vol_height = int(self._Height * (float(self._Value) / 100.0))
            dheight = self._Height - vol_height

            vol_rect = pygame.Rect(self._PosX - self._Width / 2,
                                   self._PosY - self._Height / 2 + dheight,
                                   self._Width, vol_height)

            aa_round_rect(self._CanvasHWND, vol_rect, self._ValColor, 3, 0,
                          self._ValColor)

        else:
            vol_height = 10
            dheight = self._Height - vol_height
            vol_rect = pygame.Rect(self._PosX - self._Width / 2,
                                   self._PosY - self._Height / 2 + dheight,
                                   self._Width, vol_height)

            aa_round_rect(self._CanvasHWND, vol_rect, self._ValColor, 3, 0,
                          self._ValColor)
    def Draw(self):

        start_rect = midRect(self._PosX + self._StartX,
                             self._StartY + self._Value, self._Width,
                             self._Height, self._Parent._Width,
                             self._Parent._Height)
        aa_round_rect(self._CanvasHWND, start_rect, self._Color, 3, 0,
                      self._Color)
Beispiel #3
0
    def Draw(self):
        if self._BG != None:
            w_ = self._Text.get_width()
            h_ = self._Text.get_height()

            self._BG.blit(
                self._Text,
                midRect(self._Width / 2, self._Height / 2, w_, h_, self._Width,
                        self._Height))
Beispiel #4
0
    def Draw(self):
        self._Width = 0
        self._Height = 0
        self._CanvasHWND.fill( (255,255,255))
        
        words = self._Text.split(' ')
        space = self._FontObj.size(' ')[0]
        max_width = self._Parent._Width-40
        x ,y = (0,0)
        row_total_width = 0
        lines = 0

        for word in words:
            word_surface = self._FontObj.render(word, True, self._Color)
            word_width = word_surface.get_width()
            word_height = word_surface.get_height()
            row_total_width += word_width
            if lines == 0:
                lines += word_height
            if row_total_width+space  >= max_width:
                x = 0  # Reset the x.
                y += word_height  # Start on new row.
                row_total_width = word_width
                
                lines += word_height
                
            self._CanvasHWND.blit(word_surface, (x, y))
            
            if len(words) == 1: # single line 
                x += word_width
            else:
                x += word_width + space
            
            if x > self._Width:
                self._Width = x

            if lines >= (self._Parent._Height - 40):
                break
        
        self._Height = lines
        
        padding = 5
        x = (self._Parent._Width - self._Width)/2
        y = (self._Parent._Height - self._Height)/2
       # print("x %d y %d w %d h %d" %(x,y,self._Width,self._Height ))
        
        pygame.draw.rect(self._HWND,(255,255,255),(x-padding,y-padding, self._Width+padding*2,self._Height+padding*2))        
    
        if self._HWND != None:
            rect = midRect(self._Parent._Width/2,self._Parent._Height/2,self._Width,self._Height,Width,Height)
            self._HWND.blit(self._CanvasHWND,rect,(0,0,self._Width,self._Height))
            #self._HWND.blit(self._CanvasHWND,rect)
            
        pygame.draw.rect(self._HWND,(0,0,0),(x-padding,y-padding, self._Width+padding*2,self._Height+padding*2),1)
Beispiel #5
0
    def Draw(self):
        canvas  = self._Parent._CanvasHWND
        idx     = self._Parent._PsIndex
        iconidx = self._Parent._IconIndex

        if idx < len(self._Parent._Icons):
            x       = self._Parent._Icons[idx]._PosX+self._Parent._PosX
            y       = self._Parent._Icons[iconidx]._PosY ## only use current icon's PosY
        
            rect    = midRect(x,y,self._Width,self._Height,self._Parent._Width,self._Parent._Height)
            if rect.width <=0 or rect.height <= 0 :
                return

            #color = (244,197,66,50)
            #pygame.draw.rect(canvas,color,rect,1)
            if self._IconSurf != None:
                self._Parent._CanvasHWND.blit(self._IconSurf,rect)
Beispiel #6
0
    def Draw(self):
        if self._Align==ALIGN["VCenter"]: #default
            if self._Label != None:
                self._Label._PosX = self._PosX - self._Label._Width/2
                self._Label._PosY = self._PosY + self._Height/2 + 12

        elif self._Align ==ALIGN["HLeft"]:
            if self._Label != None:
                self._Label._PosX = self._PosX + self._Width/2 + 3
                self._Label._PosY = self._PosY - self._Label._Height/2

        if self._Label!=None:
            self._Label.Draw()

        if self._ImgSurf != None:
            self._Parent._CanvasHWND.blit(self._ImgSurf,midRect(self._PosX,
                                                                self._PosY,
                                                                self._Width,self._Height,Width,Height),
                                          (0,self._IconIndex*self._IconHeight,self._IconWidth,self._IconHeight))
    def Draw(self, title):
        self.ClearCanvas()
        title = MyLangManager.Tr(title)
        self._Title = title

        cur_time = datetime.now().strftime("%H:%M")
        time_text_font = MySkinManager.GiveFont("varela12")
        time_text_size = time_text_font.size(cur_time)
        title_text_size = MyLangManager.TrFont("varela16").size(title)

        self._CanvasHWND.blit(
            MyLangManager.TrFont("varela16").render(
                title, True, self._SkinManager.GiveColor("Text")),
            midRect(
                title_text_size[0] / 2 + self._LOffset,
                title_text_size[1] / 2 +
                (self._BarHeight - title_text_size[1]) / 2, title_text_size[0],
                title_text_size[1], Width, Height))
        self._CanvasHWND.blit(
            time_text_font.render(cur_time, True,
                                  self._SkinManager.GiveColor("Text")),
            midRect(
                Width - time_text_size[0] / 2 - self._ROffset,
                time_text_size[1] / 2 +
                (self._BarHeight - time_text_size[1]) / 2, time_text_size[0],
                time_text_size[1], Width, Height))

        start_x = Width - time_text_size[
            0] - self._ROffset - self._icon_width * 3  # near by the time_text

        self._Icons["dlstatus"].NewCoord(
            start_x - self._icon_width * 2,
            self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2)

        self._Icons["bluetooth"].NewCoord(
            start_x - self._icon_width,
            self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2)

        self._Icons["sound"].NewCoord(
            start_x,
            self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2)

        #self._Icons["wifi"].NewCoord(start_x+self._icon_width+5,    self._icon_height/2+(self._BarHeight-self._icon_height)/2)

        self._Icons["battery"].NewCoord(
            start_x + self._icon_width + self._icon_width + 8,
            self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2)

        if is_wifi_connected_now():
            ge = self.GetWifiStrength(wifi_strength())
            if ge > 0:
                self._Icons["wifistatus"]._IconIndex = ge
                self._Icons["wifistatus"].NewCoord(
                    start_x + self._icon_width + 5, self._icon_height / 2 +
                    (self._BarHeight - self._icon_height) / 2)
                self._Icons["wifistatus"].Draw()
            else:
                self._Icons["wifistatus"]._IconIndex = 0
                self._Icons["wifistatus"].Draw()
                print("wifi strength error")
        else:
            if self._InAirPlaneMode == False:
                self._Icons["wifistatus"]._IconIndex = 0
            else:
                self._Icons["wifistatus"]._IconIndex = 5  ## airplane mode icon

            self._Icons["wifistatus"].NewCoord(
                start_x + self._icon_width + 5, self._icon_height / 2 +
                (self._BarHeight - self._icon_height) / 2)
            self._Icons["wifistatus"].Draw()

        self._Icons["sound"].Draw()

        self._Icons["battery"].Draw()

        self._Icons["bluetooth"].Draw()

        #self._Icons["dlstatus"].Draw()

        pygame.draw.line(self._CanvasHWND, self._SkinManager.GiveColor("Line"),
                         (0, self._BarHeight), (self._Width, self._BarHeight),
                         self._BorderWidth)

        if self._HWND != None:
            self._HWND.blit(
                self._CanvasHWND,
                (self._PosX, self._PosY, self._Width, self._Height))
Beispiel #8
0
    def Draw(self, title):
        self.ClearCanvas()
        title = MyLangManager.Tr(title)
        self._Title = title

        # get battery percentage, but not for music spectrum(GameShell RTA)
        RTA_title = "GameShell RTA"
        bat_pct = ""
        if title != RTA_title and title != MyLangManager.Tr(RTA_title):
            out = commands.getstatusoutput(
                "upower -i /org/freedesktop/UPower/devices/battery_axp20x_battery | grep percentage | tail -c 5"
            )
            bat_pct = "".join(out[1]).strip() + "  "

        cur_time = datetime.now().strftime("%H:%M")
        cur_time = bat_pct + cur_time
        time_text_font = MySkinManager.GiveFont("Eurostile12")
        time_text_size = time_text_font.size(cur_time)
        title_text_size = MyLangManager.TrFont("Eurostile16").size(title)

        self._CanvasHWND.blit(
            MyLangManager.TrFont("Eurostile16").render(
                title, True, self._SkinManager.GiveColor("Text")),
            midRect(
                title_text_size[0] / 2 + self._LOffset,
                title_text_size[1] / 2 +
                (self._BarHeight - title_text_size[1]) / 2, title_text_size[0],
                title_text_size[1], Width, Height))
        self._CanvasHWND.blit(
            time_text_font.render(cur_time, True,
                                  self._SkinManager.GiveColor("Text")),
            midRect(
                Width - time_text_size[0] / 2 - self._ROffset,
                time_text_size[1] / 2 +
                (self._BarHeight - time_text_size[1]) / 2, time_text_size[0],
                time_text_size[1], Width, Height))

        start_x = Width - time_text_size[
            0] - self._ROffset - self._icon_width * 3  # near by the time_text

        self._Icons["dlstatus"].NewCoord(
            start_x - self._icon_width * 2,
            self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2)

        self._Icons["bluetooth"].NewCoord(
            start_x - self._icon_width,
            self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2)

        self._Icons["sound"].NewCoord(
            start_x,
            self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2)

        #self._Icons["wifi"].NewCoord(start_x+self._icon_width+5,    self._icon_height/2+(self._BarHeight-self._icon_height)/2)

        self._Icons["battery"].NewCoord(
            start_x + self._icon_width + self._icon_width + 8,
            self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2)

        if is_wifi_connected_now():
            ge = self.GetWifiStrength(wifi_strength())
            if ge > 0:
                self._Icons["wifistatus"]._IconIndex = ge
                self._Icons["wifistatus"].NewCoord(
                    start_x + self._icon_width + 5, self._icon_height / 2 +
                    (self._BarHeight - self._icon_height) / 2)
                self._Icons["wifistatus"].Draw()
            else:
                self._Icons["wifistatus"]._IconIndex = 0
                self._Icons["wifistatus"].Draw()
                print("wifi strength error")
        else:
            if self._InAirPlaneMode == False:
                self._Icons["wifistatus"]._IconIndex = 0
            else:
                self._Icons["wifistatus"]._IconIndex = 5  ## airplane mode icon

            self._Icons["wifistatus"].NewCoord(
                start_x + self._icon_width + 5, self._icon_height / 2 +
                (self._BarHeight - self._icon_height) / 2)
            self._Icons["wifistatus"].Draw()

        self._Icons["sound"].Draw()

        self._Icons["battery"].Draw()

        self._Icons["bluetooth"].Draw()

        #self._Icons["dlstatus"].Draw()

        pygame.draw.line(self._CanvasHWND, self._SkinManager.GiveColor("Line"),
                         (0, self._BarHeight), (self._Width, self._BarHeight),
                         self._BorderWidth)

        if self._HWND != None:
            self._HWND.blit(
                self._CanvasHWND,
                (self._PosX, self._PosY, self._Width, self._Height))
Beispiel #9
0
 def DrawCenter(self,bold=False):
     self._FontObj.set_bold(bold) ## avoing same font tangling set_bold to others
     my_text = self._FontObj.render( self._Text,True,self._Color)        
     self._CanvasHWND.blit(my_text,midRect(self._PosX,self._PosY,self._Width,self._Height,Width,Height))
Beispiel #10
0
    def Draw(self, title):
        self.ClearCanvas()
        title = MyLangManager.Tr(title)

        # Couldn't see where to change this anywhere, so let's be super explicit
        if title == "GameShell":
            title = "PocketCHIP"
        self._Title = title
        title_text_size = MyLangManager.TrFont("varela16").size(title)
        self._CanvasHWND.blit(
            MyLangManager.TrFont("varela16").render(
                title, True, self._SkinManager.GiveColor("Text")),
            # x,y,width,height,canWidth,canHeight
            midRect(
                title_text_size[0] / 2 + self._LOffset,
                title_text_size[1] / 2 +
                (self._BarHeight - title_text_size[1]) / 2, title_text_size[0],
                title_text_size[1], Width, Height))

        cur_time = datetime.now().strftime("%H:%M")
        time_text_font = MySkinManager.GiveFont("varela12")
        time_text_size = time_text_font.size(cur_time)
        self._CanvasHWND.blit(
            time_text_font.render(cur_time, True,
                                  self._SkinManager.GiveColor("Text")),
            # x,y,width,height,canWidth,canHeight
            midRect(
                Width - time_text_size[0] / 2 - self._ROffset,
                time_text_size[1] / 2 +
                (self._BarHeight - time_text_size[1]) / 2, time_text_size[0],
                time_text_size[1], Width, Height))

        #### Debug: Output the battery value as text...
        # cur_batt =  "Batt: %s, %s" % (str(BatteryAbstraction.AsPercentage()), str(BatteryAbstraction.IsCharging()))
        # batt_text_font = MySkinManager.GiveFont("varela12")
        # batt_text_size = batt_text_font.size(cur_batt)
        # self._CanvasHWND.blit(batt_text_font.render(
        #     cur_batt,
        #     True,
        #     self._SkinManager.GiveColor("Text")),
        #     # x,y,width,height,canWidth,canHeight
        #     midRect(
        #         # Width-batt_text_size[0]/2-self._ROffset,
        #         200,
        #         batt_text_size[1]/2+(self._BarHeight-batt_text_size[1])/2,
        #         batt_text_size[0],
        #         batt_text_size[1],
        #         Width,
        #         Height
        #     )
        # )

        start_x = Width - time_text_size[
            0] - self._ROffset - self._icon_width * 3  # near by the time_text

        self._Icons["bluetooth"].NewCoord(
            start_x - self._icon_width,
            self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2)

        self._Icons["sound"].NewCoord(
            start_x,
            self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2)

        #self._Icons["wifi"].NewCoord(start_x+self._icon_width+5,    self._icon_height/2+(self._BarHeight-self._icon_height)/2)

        self._Icons["battery"].NewCoord(
            start_x + self._icon_width + self._icon_width + 8,
            self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2)

        if is_wifi_connected_now():
            ge = self.GetWifiStrength(wifi_strength())
            if ge > 0:
                self._Icons["wifistatus"]._IconIndex = ge
                self._Icons["wifistatus"].NewCoord(
                    start_x + self._icon_width + 5, self._icon_height / 2 +
                    (self._BarHeight - self._icon_height) / 2)
                # self._Icons["wifistatus"].Draw()
            else:
                self._Icons["wifistatus"]._IconIndex = 0
                # self._Icons["wifistatus"].Draw()
                print("wifi strength error")
        else:
            if self._InAirPlaneMode == False:
                self._Icons["wifistatus"]._IconIndex = 0
            else:
                self._Icons["wifistatus"]._IconIndex = 5  ## airplane mode icon

            self._Icons["wifistatus"].NewCoord(
                start_x + self._icon_width + 5, self._icon_height / 2 +
                (self._BarHeight - self._icon_height) / 2)
            # self._Icons["wifistatus"].Draw()

        # Draw the title bar icons
        self._Icons["wifistatus"].Draw()
        self._Icons["sound"].Draw()
        self._Icons["battery"].Draw()
        # self._Icons["bluetooth"].Draw()

        pygame.draw.line(self._CanvasHWND, self._SkinManager.GiveColor("Line"),
                         (0, self._BarHeight), (self._Width, self._BarHeight),
                         self._BorderWidth)

        if self._HWND != None:
            self._HWND.blit(
                self._CanvasHWND,
                (self._PosX, self._PosY, self._Width, self._Height))
Beispiel #11
0
    def Draw(self, title):
        self.ClearCanvas()

        self._Title = title

        cur_time = datetime.now().strftime("%H:%M")
        time_text_size = fonts["varela12"].size(cur_time)
        title_text_size = fonts["varela16"].size(title)

        self._CanvasHWND.blit(
            fonts["varela16"].render(title, True, self._TxtColor),
            midRect(
                title_text_size[0] / 2 + self._LOffset,
                title_text_size[1] / 2 +
                (self._BarHeight - title_text_size[1]) / 2, title_text_size[0],
                title_text_size[1], Width, Height))
        self._CanvasHWND.blit(
            fonts["varela12"].render(cur_time, True, self._TxtColor),
            midRect(
                Width - time_text_size[0] / 2 - self._ROffset,
                time_text_size[1] / 2 +
                (self._BarHeight - time_text_size[1]) / 2, time_text_size[0],
                time_text_size[1], Width, Height))

        start_x = Width - time_text_size[
            0] - self._ROffset - self._icon_width * 3  # near by the time_text

        self._Icons["sound"].NewCoord(
            start_x,
            self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2)

        #self._Icons["wifi"].NewCoord(start_x+self._icon_width+5,    self._icon_height/2+(self._BarHeight-self._icon_height)/2)

        self._Icons["battery"].NewCoord(
            start_x + self._icon_width + self._icon_width + 8,
            self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2)

        if is_wifi_connected_now():
            ge = self.GetWifiStrength(wifi_strength())
            if ge > 0:
                self._Icons["wifistatus"]._IconIndex = ge
                self._Icons["wifistatus"].NewCoord(
                    start_x + self._icon_width + 5, self._icon_height / 2 +
                    (self._BarHeight - self._icon_height) / 2)
                self._Icons["wifistatus"].Draw()
            else:
                self._Icons["wifistatus"]._IconIndex = 0
                self._Icons["wifistatus"].Draw()
                print("strength error")
        else:
            self._Icons["wifistatus"]._IconIndex = 0
            self._Icons["wifistatus"].NewCoord(
                start_x + self._icon_width + 5, self._icon_height / 2 +
                (self._BarHeight - self._icon_height) / 2)
            self._Icons["wifistatus"].Draw()

        self._Icons["sound"].Draw()

        self._Icons["battery"].Draw()

        pygame.draw.line(self._CanvasHWND, self._BottomLineColor,
                         (0, self._BarHeight), (self._Width, self._BarHeight),
                         self._BorderWidth)

        if self._HWND != None:
            self._HWND.blit(
                self._CanvasHWND,
                (self._PosX, self._PosY, self._Width, self._Height))