code: def OnPaint(self, event):
      dc = wx.BufferedPaintDC(self)
      try:
          dc.SetBackgroundMode(wx.PENSTYLE_SOLID)
          background_color = wx.SystemSettings.GetColour(
              wx.SYS_COLOUR_WINDOW
          )
          metadata_color = get_primary_outline_color()
          selected_background_color = wx.SystemSettings.GetColour(
              wx.SYS_COLOUR_HIGHLIGHT
          )
          selected_color = wx.SystemSettings.GetColour(
              wx.SYS_COLOUR_HIGHLIGHTTEXT
          )
          text_color = wx.SystemSettings.GetColour(
              wx.SYS_COLOUR_WINDOWTEXT
          )
          dc.SetBackground(wx.Brush(background_color))
          dc.SetFont(self.Font)
          dc.Clear()
          if self.native_border:
              renderer = wx.RendererNative.Get()
              style = 0
              if self.FindFocus() == self:
                  style |= wx.CONTROL_FOCUSED | wx.CONTROL_CURRENT
              if not self.Enabled:
                  style |= wx.CONTROL_DISABLED
              renderer.DrawTextCtrl(
                  self,
                  dc,
                  (0, 0, self.ClientSize[0], self.ClientSize[1]),
                  style,
              )
              dc.SetClippingRegion(
                  (
                      self.padding,
                      self.padding,
                      self.ClientSize[0] - 2 * self.padding,
                      self.ClientSize[1] - 2 * self.padding,
                  )
              )
          text = self.get_text(0, len(self.__tokens))
          positions = self.get_positions(dc)
  
          last_state = "unknown"
          text_list = []
          state_list = []
          position_list = []
          selection = None
          if self.selection is not None:
              selection = list(self.selection)
              selection.sort()
          for i, token in enumerate(self.__tokens):
              if isinstance(token, self.MetadataToken):
                  current_state = "metadata"
              elif (
                  self.selection is not None
                  and selection[0] <= i < selection[1]
              ):
                  current_state = "selection"
              else:
                  current_state = "boring"
              if current_state != last_state:
                  state_list.append(current_state)
                  text_list.append("")
                  last_state = current_state
                  position_list.append((positions[i], self.padding))
              text_list[-1] += self.get_text(i, i + 1)
          colors = {
              "boring": (background_color, text_color),
              "selection": (selected_background_color, selected_color),
              "metadata": (metadata_color, text_color),
          }
          background_color = [colors[state][0] for state in state_list]
          foreground_color = [colors[state][1] for state in state_list]
          dc.SetBackgroundMode(wx.PENSTYLE_SOLID)
          for text, position, background, foreground in zip(
              text_list,
              position_list,
              background_color,
              foreground_color,
          ):
              dc.SetTextBackground(background)
              dc.SetTextForeground(foreground)
              dc.DrawText(text, position[0], position[1])
      finally:
          dc.Destroy()
  
imports: import wx
  import wx.lib.masked
  from cellprofiler_core.constants.measurement import C_FRAME
  from cellprofiler_core.constants.measurement import C_METADATA
  from cellprofiler_core.constants.measurement import C_SERIES
  from cellprofiler_core.constants.measurement import IMAGE
  from cellprofiler_core.preferences import get_primary_outline_color
label_desc: Use image node_id 26 for calling the MetadataControl obj's underlying member method code with example usage: obj.OnPaint(event) without return types