示例#1
0
    def __init__(self,appli_window):
        wx.Panel.__init__(self, appli_window, -1)
        self.appli_window = appli_window

        [ wxID_WXMAINFRAMECHATTERSLISTBOX, wxID_WXMAINFRAMECHATTEXTCTRL,
          wxID_WXMAINFRAMEMESSAGETEXTCTRL, wxID_WXMAINFRAMESENDMESSAGEBUTTON
          ] = map(lambda _init_ctrls: wx.NewId(), range(4))

        [ wxID_WXMAINFRAMELOGO_WINDOW, wxID_WXMAINFRAMELOGOBITMAP
          ] = map(lambda _init_ctrls: wx.NewId(), range(2))

        self.logo_window = wx.Window(id=wxID_WXMAINFRAMELOGO_WINDOW,
                                     name='logo_window', parent=self,
                                     pos=wx.Point(0, 0),
                                     size=wx.Size(295, 76), style=0)

        logo = ImageManager.getBitmap(ImageManager.IMG_SOLIPSIS_LOGO)
        self.logoBitmap = wx.StaticBitmap(bitmap=logo,
                                          id=wxID_WXMAINFRAMELOGOBITMAP,
                                          name='logoBitmap', parent=self.logo_window,
                                          pos=wx.Point(0, 0), size=wx.Size(295, 76),
                                          style=0)

        self.logoHeight = 76
        self.chattersListBox = wx.ListBox(choices=[],
                                          id=wxID_WXMAINFRAMECHATTERSLISTBOX,
                                          name='chattersList',
                                          parent=self,
                                          pos=wx.Point(6, 30 + self.logoHeight),
                                          size=wx.Size(279,135),
                                          style=wx.NO_BORDER|wx.LB_ALWAYS_SB,
                                          validator=wx.DefaultValidator)

        self.chatTextCtrl = wx.TextCtrl(id=wxID_WXMAINFRAMECHATTEXTCTRL,
                                        name='chatTextCtrl',
                                        parent=self,
                                        pos=wx.Point(6, 201 + self.logoHeight),
                                        size=wx.Size(279, 233),
                                        style=wx.NO_BORDER|wx.TE_MULTILINE|wx.TE_READONLY,
                                        value='')

        self.messageTextCtrl = wx.TextCtrl(id=wxID_WXMAINFRAMEMESSAGETEXTCTRL,
                                           name='messageTextCtrl',
                                           parent=self,
                                           pos=wx.Point(6, 460 + self.logoHeight),
                                           size=wx.Size(279, 115),
                                           style=wx.NO_BORDER|wx.TE_MULTILINE,
                                           value='')

        sendBitmap =ImageManager.getBitmap(ImageManager.IMG_SEND_BLUE)
        self.sendMessageButton = wx.BitmapButton(bitmap=sendBitmap,
                                                 id=wxID_WXMAINFRAMESENDMESSAGEBUTTON,
                                                 name='sendMessageButton',
                                                 parent=self,
                                                 pos=wx.Point(190, 441 + self.logoHeight),
                                                 size=wx.Size(81, 17),
                                                 validator=wx.DefaultValidator)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
    def OnPaint(self, event):
        dc = wx.ClientDC(self.two_d_window)

        # opions for the device context
        dc.SetBackground( wx.Brush("White",wx.SOLID) )
        dc.SetBackgroundMode(wx.TRANSPARENT)
        dc.SetFont( wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD, False) )
        dc.SetPen( wx.Pen("White",1) )
        dc.SetTextForeground("White")
        dc.SetBrush( wx.Brush("White",wx.TRANSPARENT) )


        # draw background picture
        two_d_bitmap = ImageManager.getBitmap(ImageManager.IMG_2D_BACKGROUND)
        dc.DrawBitmap(two_d_bitmap, 0, 0, True)

        width  = self.two_d_window.GetClientSize().GetWidth()
        height = self.two_d_window.GetClientSize().GetHeight()
        # we are not connected, just display a 'not connected' message
        if not self.navigatorInfo.isConnected():
            dc.DrawText('Not connected', width // 2, height // 2)
        else:
            # display awareness radius
            dc.DrawCircle(width / 2, height / 2, width / 2)

            self.displayEntity(dc, self.navigatorInfo.getNode())
            print '---'
            for peer in self.navigatorInfo.enumeratePeers():
                print peer.getId()
                self.displayEntity(dc, peer)
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)

        [wxID_WXMAINFRAMELOGO_WINDOW, wxID_WXMAINFRAMELOGOBITMAP] = map(lambda _init_ctrls: wx.NewId(), range(2))

        self.logo_window = wx.Window(
            id=wxID_WXMAINFRAMELOGO_WINDOW,
            name="logo_window",
            parent=self,
            pos=wx.Point(0, 0),
            size=wx.Size(295, 76),
            style=0,
        )

        logo = ImageManager.getBitmap(ImageManager.IMG_SOLIPSIS_LOGO)
        self.logoBitmap = wx.StaticBitmap(
            bitmap=logo,
            id=wxID_WXMAINFRAMELOGOBITMAP,
            name="logoBitmap",
            parent=self.logo_window,
            pos=wx.Point(0, 0),
            size=wx.Size(295, 76),
            style=0,
        )

        button = wx.Button(self, -1, "I do nothing")
    def _init_ctrls(self):

        # frame initialization
        wx.Frame.__init__(self, id=wxID_WXMAINFRAME, name='wxMainFrame',
                         parent=None, pos=wx.DefaultPosition, size=wx.Size(1024, 768),
                         style=wx.DEFAULT_FRAME_STYLE,
                         title='Solipsis')
        self._init_utils()
        self.SetClientSize(wx.Size(1016, 741))

        # set the Solipsis icon in the frame
        iconSolipsis = ImageManager.getIcon(ImageManager.IMG_SOLIPSIS_ICON)
        bitmap = ImageManager.getBitmap(ImageManager.IMG_SOLIPSIS_ICON)
        iconSolipsis.CopyFromBitmap(bitmap)
        self.SetIcon(iconSolipsis)

        # navigation window
        self.navig_window = wx.Window(id=wxID_WXMAINFRAMENAVIG_WINDOW,
              name='navig_window', parent=self, pos=wx.Point(0, 0),
              size=wx.Size(1014, 46), style=0)

        top = ImageManager.getBitmap(ImageManager.IMG_TOP_BANNER)
        self.bannerBitmap = wx.StaticBitmap(bitmap=top,
                                           id=wxID_WXMAINFRAMETOPBANNERBITMAP,
                                           name='topBannerBitmap',
                                           parent=self.navig_window,
                                           pos=wx.Point(0, 0), size=wx.Size(1014, 46),
                                           style=0)

        # logo window


        # 2D view window
        self.two_d_window = wx.Window(id=wxID_WXMAINFRAMETWO_D_WINDOW,
              name='two_d_window', parent=self, pos=wx.Point(0, 46),
              size=wx.Size(719, 676), style=0)

        # application window
        self.appli_window = wx.Notebook(id=wxID_WXMAINFRAMEAPPLI_WINDOW,
                                     name='appli_window', par
    def displayEntity(self, dc, entity):

        # display pseudo
        if self.navigatorInfo.arePseudosDisplayed() :
            pseudoCoordinate = self.getPseudoWindowCoordinate(entity)
            dc.DrawTextPoint(entity.getPseudo(), pseudoCoordinate)

        # display avatar
        if self.navigatorInfo.areAvatarsDisplayed() :
            avatarBitmap = ImageManager.getBitmap(ImageManager.IMG_AVATAR_GREY)
            self.posAvatar = self.getWindowCoordinate(entity)
            dc.DrawBitmapPoint(avatarBitmap, self.posAvatar, True)


        # display services picto bitmap
        for service in entity.enumerateServices():
            if service.id == Service.ID_CHAT:
                chatBitmap = ImageManager.getBitmap(ImageManager.IMG_CHAT_PICTO)
                chatCoordinate = self.getServiceWindowCoordinate(entity,
                                                                 Service.ID_CHAT)
                dc.DrawBitmapPoint(chatBitmap, chatCoordinate, True)
            elif service.id == Service.ID_AVATAR:
                avatarPicto = ImageManager.getBitmap(ImageManager.IMG_AVATAR_PICTO)
                avatarCoordinate = self.getServiceWindowCoordinate(entity,
                                                             Service.ID_AVATAR)
                dc.DrawBitmapPoint(avatarPicto, avatarCoordinate, True)
            elif service.id == Service.ID_FILE_TRANSFER:
                filePicto = ImageManager.getBitmap(ImageManager.IMG_TRANSFER_PICTO)
                fileCoordinate = self.getServiceWindowCoordinate(entity,
                                                           Service.ID_FILE_TRANSFER)
                dc.DrawBitmapPoint(filePicto, fileCoordinate, True)
            # unknown service type : display a question mark pictogram
            else:
                unknownPicto = ImageManager.getBitmap(ImageManager.IMG_UNKNOWN_PICTO)
                unknownCoord = self.getServiceWindowCoordinate(entity,
                                                               Service.ID_UNKNOWN)
                dc.DrawBitmapPoint(unknownPicto, unknownCoord, True)
示例#6
0
 def OnPaint(self, event):
     dc = wx.ClientDC(self)
     background = ImageManager.getBitmap(ImageManager.IMG_CHAT)
     dc.DrawBitmap(background, 0, self.logoHeight, True)
    def _init_ctrls(self):

        # frame initialization
        wx.Frame.__init__(self, id=wxID_WXMAINFRAME, name='wxMainFrame',
                         parent=None, pos=wx.DefaultPosition, size=wx.Size(1024, 768),
                         style=wx.DEFAULT_FRAME_STYLE,
                         title='Solipsis')
        self._init_utils()
        self.SetClientSize(wx.Size(1016, 741))

        # set the Solipsis icon in the frame
        iconSolipsis = ImageManager.getIcon(ImageManager.IMG_SOLIPSIS_ICON)
        bitmap = ImageManager.getBitmap(ImageManager.IMG_SOLIPSIS_ICON)
        iconSolipsis.CopyFromBitmap(bitmap)
        self.SetIcon(iconSolipsis)

        # navigation window
        self.navig_window = wx.Window(id=wxID_WXMAINFRAMENAVIG_WINDOW,
              name='navig_window', parent=self, pos=wx.Point(0, 0),
              size=wx.Size(1014, 46), style=0)

        top = ImageManager.getBitmap(ImageManager.IMG_TOP_BANNER)
        self.bannerBitmap = wx.StaticBitmap(bitmap=top,
                                           id=wxID_WXMAINFRAMETOPBANNERBITMAP,
                                           name='topBannerBitmap',
                                           parent=self.navig_window,
                                           pos=wx.Point(0, 0), size=wx.Size(1014, 46),
                                           style=0)

        # logo window


        # 2D view window
        self.two_d_window = wx.Window(id=wxID_WXMAINFRAMETWO_D_WINDOW,
              name='two_d_window', parent=self, pos=wx.Point(0, 46),
              size=wx.Size(719, 676), style=0)

        # application window
        self.appli_window = wx.Notebook(id=wxID_WXMAINFRAMEAPPLI_WINDOW,
                                     name='appli_window', parent=self,
                                     pos=wx.Point(719, 0), size=wx.Size(295, 722),
                                     style=0)

        #imgList = wx.ImageList(100,31)
        #imgList.Add(ImageManager.getRedChatWxBitmap())
        #imgList.Add(ImageManager.getBlueTransferWxBitmap())

        #imgList = wx.ImageList(80,30)
        #imgList.Add(ImageManager.getSmallBlueChatWxBitmap())
        #imgList.Add(ImageManager.getSmallRedTransferWxBitmap())

        imgList = wx.ImageList(16,16)
        imgList.Add(ImageManager.getBitmap(ImageManager.IMG_SOLIPSIS_ICON))
        imgList.Add(ImageManager.getBitmap(ImageManager.IMG_SOLIPSIS_ICON))
        self.appli_window.SetImageList(imgList)

        self.wxChat = WxChat(self.appli_window)
        import solipsis.navigator.filetransfer
        self.wxFileTransfer = solipsis.navigator.filetransfer.WxFileTransfer(self.appli_window)

        self.appli_window.AddPage(self.wxChat, 'chat', imageId=0)
        self.appli_window.AddPage(self.wxFileTransfer, 'transfer', imageId=1)