def ClearDrawing(self, dc=None): #print "ihm.ClearDrawing()" if dc is None: dc = wxClientDC(self.two_d_window) # draw background picture two_d_bitmap = ImageManager.get2DBackgrounddWxBitmap() dc.DrawBitmap(two_d_bitmap, 0, 0, TRUE)
def DoDrawing(self, dc=None): if dc is None: dc = wxClientDC(self.two_d_window) # opions for the device context dc.SetBackground( wxBrush("White",wxSOLID) ) dc.SetBackgroundMode(wxTRANSPARENT) dc.SetFont( wxFont(10, wxSWISS, wxNORMAL, wxBOLD, FALSE) ) dc.SetPen( wxPen("White",1) ) dc.SetTextForeground("White") dc.SetBrush( wxBrush("White",wxTRANSPARENT) ) # draw background picture two_d_bitmap = ImageManager.get2DBackgrounddWxBitmap() dc.DrawBitmap(two_d_bitmap, 0, 0, TRUE) # display the image and the pseudo of my node if self.myNode_pseudo : avatar_bitmap = wxImage(self.myNode_avatar, wxBITMAP_TYPE_PNG).ConvertToBitmap() self.pos_avatar_x = long(((self.two_d_window.GetClientSize().GetWidth()- avatar_bitmap.GetWidth()) /2) + self.delta_x) self.pos_avatar_y = long(((self.two_d_window.GetClientSize().GetHeight()- avatar_bitmap.GetHeight()) /2) + self.delta_y) dc.DrawBitmap(avatar_bitmap, self.pos_avatar_x,self.pos_avatar_y, TRUE) # display pseudo of my node if self.isDisplayPseudos == 1: self.pos_pseudo_x = self.pos_avatar_x self.pos_pseudo_y = long(self.pos_avatar_y + avatar_bitmap.GetHeight()) dc.DrawText(self.myNode_pseudo, self.pos_pseudo_x, self.pos_pseudo_y) # we display the awarness radius if self.myNode_ar : # Coordinates of the square enclosing the circle #arInDisplay2d = long(self.newCoordinates(long(self.myNode_ar))) #dc.DrawCircle(self.pos_avatar_x, self.pos_avatar_y, arInDisplay2d) dc.DrawCircle( self.two_d_window.GetClientSize().GetWidth()/2, self.two_d_window.GetClientSize().GetHeight()/2, self.two_d_window.GetClientSize().GetWidth()/2) # display neighbor items for neighbor_object in self.neighbor_item.values(): # recompute position in the screen posX = long(self.newCoordinates(neighbor_object[0])+(self.two_d_window.GetClientSize().GetWidth() /2)) posY = long(self.newCoordinates(neighbor_object[1])+(self.two_d_window.GetClientSize().GetHeight() /2)) pseudo = neighbor_object[2] #print "display Neighbor : [%s]" %pseudo # display neighbor image if it belongs to the screen if 0 < posY < self.two_d_window.GetClientSize().GetHeight() and 0 < posX < self.two_d_window.GetClientSize().GetWidth(): #print "display Neighbor image : [%s]" %pseudo # resize the image in accordance with the ar #self.display2d.chgSize(id) # get the photo image object if self.isDisplayAvatars == 1: if (neighbor_object[6]): avatar_bitmap = wxImage(neighbor_object[6], wxBITMAP_TYPE_PNG).ConvertToBitmap() else: # if the neighbor has no image, display the default image avatar_bitmap = wxImage(self.neighbor_avatar, wxBITMAP_TYPE_PNG).ConvertToBitmap() else: avatar_bitmap = wxImage("img//avat_blanc.png", wxBITMAP_TYPE_PNG).ConvertToBitmap() # display the image of neighbor pos_avatar_x = long(posX-(avatar_bitmap.GetWidth())/2) pos_avatar_y = long(posY-(avatar_bitmap.GetHeight())/2) dc.DrawBitmap(avatar_bitmap, pos_avatar_x, pos_avatar_y, TRUE) # display pseudo of the neighbor if self.isDisplayPseudos == 1: pos_pseudo_x = pos_avatar_x pos_pseudo_y = long(pos_avatar_y + avatar_bitmap.GetHeight()) dc.DrawText(pseudo, pos_pseudo_x, pos_pseudo_y) # display services picto bitmap chat_bitmap = wxImage('img//picto_chat.png', wxBITMAP_TYPE_PNG).ConvertToBitmap() pos_chat_x = long(pos_avatar_x + avatar_bitmap.GetWidth()) pos_chat_y = pos_avatar_y avat_bitmap = wxImage('img//picto_avat.png', wxBITMAP_TYPE_PNG).ConvertToBitmap() pos_avat_x = long(pos_avatar_x + avatar_bitmap.GetWidth()) pos_avat_y = long(pos_chat_y + chat_bitmap.GetHeight()) file_bitmap = wxImage('img//picto_fichier.png', wxBITMAP_TYPE_PNG).ConvertToBitmap() pos_file_x = long(pos_avatar_x + avatar_bitmap.GetWidth()) pos_file_y = long(pos_avat_y + avat_bitmap.GetHeight()) # display the image of neighbor chat service if neighbor_object[3]: dc.DrawBitmap(chat_bitmap, pos_chat_x, pos_chat_y, TRUE) # display the image of neighbor display2d service if neighbor_object[4]: dc.DrawBitmap(avat_bitmap, pos_avat_x, pos_avat_y, TRUE) # display the image of neighbor chat service if neighbor_object[5]: dc.DrawBitmap(file_bitmap, pos_file_x, pos_file_y, TRUE)
def _init_ctrls(self): # frame initialization wxFrame.__init__(self, id=wxID_WXMAINFRAME, name='wxMainFrame', parent=None, pos=wxPoint(0, 0), size=wxSize(1024, 768), style=wxDEFAULT_FRAME_STYLE & ~ (wxRESIZE_BORDER | wxRESIZE_BOX | wxMAXIMIZE_BOX), title='Solipsis') self._init_utils() self.SetClientSize(wxSize(1016, 741)) # set the Solipsis icon in the frame iconSolipsis = ImageManager.getSolipsisIconWxIcon() bitmap = ImageManager.getSolipsisIconWxBitmap() iconSolipsis.CopyFromBitmap(bitmap) self.SetIcon(iconSolipsis) # navigation window self.navig_window = wxWindow(id=wxID_WXMAINFRAMENAVIG_WINDOW, name='navig_window', parent=self, pos=wxPoint(0, 0), size=wxSize(1014, 46), style=0) top = ImageManager.getTopBannerWxBitmap() self.bannerBitmap = wxStaticBitmap(bitmap=top, id=wxID_WXMAINFRAMETOPBANNERBITMAP, name='topBannerBitmap', parent=self.navig_window, pos=wxPoint(0, 0), size=wxSize(1014, 46), style=0) # logo window self.logo_window = wxWindow(id=wxID_WXMAINFRAMELOGO_WINDOW, name='logo_window', parent=self, pos=wxPoint(719, 46), size=wxSize(295, 76), style=0) logo = ImageManager.getSolipsisLogoWxBitmap() self.logoBitmap = wxStaticBitmap(bitmap=logo, id=wxID_WXMAINFRAMELOGOBITMAP, name='logoBitmap', parent=self.logo_window, pos=wxPoint(0, 0), size=wxSize(295, 76), style=0) # 2D view window self.two_d_window = wxWindow(id=wxID_WXMAINFRAMETWO_D_WINDOW, name='two_d_window', parent=self, pos=wxPoint(0, 46), size=wxSize(719, 676), style=0) # application window self.appli_window = wxWindow(id=wxID_WXMAINFRAMEAPPLI_WINDOW, name='appli_window', parent=self, pos=wxPoint(719, 122), size=wxSize(295, 600), style=0) self.transferButton = wxBitmapButton(bitmap= ImageManager.getBlueTransferWxBitmap(), id=wxID_WXMAINFRAMETRANSFERBUTTON, name='transferButton', parent=self.navig_window, pos=wxPoint(812, 9), size=wxSize(100, 31), style=0, validator=wxDefaultValidator) self.chatButton = wxBitmapButton(bitmap=ImageManager.getRedChatWxBitmap(), id=wxID_WXMAINFRAMECHATBUTTON, name='chatButton', parent=self.navig_window, pos=wxPoint(912, 9), size=wxSize(100, 31), style=wxBU_AUTODRAW, validator=wxDefaultValidator) self.chattersListBox = wxListBox(choices=[], id=wxID_WXMAINFRAMECHATTERSLISTBOX, name='chattersList', parent=self.appli_window, pos=wxPoint(6, 30), size=wxSize(279,135), style=wxNO_BORDER|wxLB_ALWAYS_SB, validator=wxDefaultValidator) self.chatTextCtrl = wxTextCtrl(id=wxID_WXMAINFRAMECHATTEXTCTRL, name='chatTextCtrl',parent=self.appli_window, pos=wxPoint(6, 201), size=wxSize(279, 233), style=wxNO_BORDER|wxTE_MULTILINE|wxTE_READONLY, value='') self.messageTextCtrl = wxTextCtrl(id=wxID_WXMAINFRAMEMESSAGETEXTCTRL, name='messageTextCtrl', parent=self.appli_window, pos=wxPoint(6, 460),size=wxSize(279, 115), style=wxNO_BORDER|wxTE_MULTILINE,value='') sendBitmap =ImageManager.getBlueSendWxBitmap() self.sendMessageButton = wxBitmapButton(bitmap=sendBitmap, id=wxID_WXMAINFRAMESENDMESSAGEBUTTON, name='sendMessageButton', parent=self.appli_window, pos=wxPoint(190, 441), size=wxSize(81, 17), validator=wxDefaultValidator)