Merge branch 'bug_474_fix_multicontent_clear'
authorghost <andreas.monzner@multimedia-labs.de>
Wed, 6 Oct 2010 09:48:14 +0000 (11:48 +0200)
committerghost <andreas.monzner@multimedia-labs.de>
Wed, 6 Oct 2010 09:48:14 +0000 (11:48 +0200)
1  2 
lib/gui/elistboxcontent.cpp

index 1d0323cf9b1d2db5aeab9a4a8daca5914d470564,4465d84c1e28250c1e40061959f57ead8973afd9..1c671fa0a51820de556220436fc6fd219a4f7cff
@@@ -49,8 -49,7 +49,8 @@@ int iListboxContent::currentCursorSelec
  
  DEFINE_REF(eListboxPythonStringContent);
  
 -eListboxPythonStringContent::eListboxPythonStringContent(): m_itemheight(25), m_cursor(0)
 +eListboxPythonStringContent::eListboxPythonStringContent()
 +      :m_cursor(0), m_itemheight(25)
  {
  }
  
@@@ -82,7 -81,7 +82,7 @@@ int eListboxPythonStringContent::cursor
  
  int eListboxPythonStringContent::cursorValid()
  {
 -      return ((unsigned int)m_cursor) < size();
 +      return m_cursor < size();
  }
  
  int eListboxPythonStringContent::cursorSet(int n)
@@@ -343,6 -342,7 +343,6 @@@ void eListboxPythonConfigContent::paint
                if (PyTuple_Check(item))
                {
                                /* handle left part. get item from tuple, convert to string, display. */
 -
                        text = PyTuple_GET_ITEM(item, 0);
                        text = PyObject_Str(text); /* creates a new object - old object was borrowed! */
                        const char *string = (text && PyString_Check(text)) ? PyString_AsString(text) : "<not-a-string>";
                        int value_alignment_left = !*string;
  
                                /* now, handle the value. get 2nd part from tuple*/
 -                      value = PyTuple_GET_ITEM(item, 1);
 +                      if (PyTuple_Size(item) >= 2) // when no 2nd entry is in tuple this is a non selectable entry without config part
 +                              value = PyTuple_GET_ITEM(item, 1);
 +
                        if (value)
                        {
                                ePyObject args = PyTuple_New(1);
                                        }
                                }
                                        /* type is borrowed */
 -                      } else
 +                      } else if (value)
                                eWarning("eListboxPythonConfigContent: second value of tuple is not a tuple.");
                        if (value)
                                Py_DECREF(value);
@@@ -516,7 -514,7 +516,7 @@@ void eListboxPythonMultiContent::setSel
                m_listbox->entryChanged(m_cursor);
  }
  
- static void clearRegionHelper(gPainter &painter, eListboxStyle *local_style, const ePoint &offset, ePyObject &pbackColor, bool cursorValid)
+ static void clearRegionHelper(gPainter &painter, eListboxStyle *local_style, const ePoint &offset, ePyObject &pbackColor, bool cursorValid, bool clear=true)
  {
        if (pbackColor)
        {
                else if (local_style->m_transparent_background)
                        return;
        }
-       painter.clear();
+       if (clear)
+               painter.clear();
  }
  
- static void clearRegionSelectedHelper(gPainter &painter, eListboxStyle *local_style, const ePoint &offset, ePyObject &pbackColorSelected, bool cursorValid)
+ static void clearRegionSelectedHelper(gPainter &painter, eListboxStyle *local_style, const ePoint &offset, ePyObject &pbackColorSelected, bool cursorValid, bool clear=true)
  {
        if (pbackColorSelected)
        {
                        return;
                }
        }
-       painter.clear();
+       if (clear)
+               painter.clear();
  }
  
- static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *local_style, ePyObject pforeColor, ePyObject pforeColorSelected, ePyObject pbackColor, ePyObject pbackColorSelected, int selected, gRegion &rc, eRect &sel_clip, const ePoint &offset, bool cursorValid)
+ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *local_style, ePyObject pforeColor, ePyObject pforeColorSelected, ePyObject pbackColor, ePyObject pbackColorSelected, int selected, gRegion &rc, eRect &sel_clip, const ePoint &offset, bool cursorValid, bool clear=true)
  {
        if (selected && sel_clip.valid())
        {
                {
                        painter.clip(part);
                        style.setStyle(painter, eWindowStyle::styleListboxNormal);
-                       clearRegionHelper(painter, local_style, offset, pbackColor, cursorValid);
+                       clearRegionHelper(painter, local_style, offset, pbackColor, cursorValid, clear);
                        painter.clippop();
                        selected = 0;
                }
                {
                        painter.clip(part);
                        style.setStyle(painter, eWindowStyle::styleListboxSelected);
-                       clearRegionSelectedHelper(painter, local_style, offset, pbackColorSelected, cursorValid);
+                       clearRegionSelectedHelper(painter, local_style, offset, pbackColorSelected, cursorValid, clear);
                        painter.clippop();
                        selected = 1;
                }
        else if (selected)
        {
                style.setStyle(painter, eWindowStyle::styleListboxSelected);
-               clearRegionSelectedHelper(painter, local_style, offset, pbackColorSelected, cursorValid);
+               clearRegionSelectedHelper(painter, local_style, offset, pbackColorSelected, cursorValid, clear);
                if (local_style && local_style->m_selection)
                        painter.blit(local_style->m_selection, offset, eRect(), gPainter::BT_ALPHATEST);
        }
        else
        {
                style.setStyle(painter, eWindowStyle::styleListboxNormal);
-               clearRegionHelper(painter, local_style, offset, pbackColor, cursorValid);
+               clearRegionHelper(painter, local_style, offset, pbackColor, cursorValid, clear);
        }
  
        if (selected)
@@@ -820,7 -820,8 +822,8 @@@ void eListboxPythonMultiContent::paint(
  
                                {
                                        gRegion rc(rect);
-                                       clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip, offset, cursorValid);
+                                       bool mustClear = (selected && pbackColorSelected) || (!selected && pbackColor);
+                                       clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip, offset, cursorValid, mustClear);
                                }
  
                                painter.setFont(m_font[fnt]);
  
                                {
                                        gRegion rc(rect);
-                                       clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip, offset, cursorValid);
+                                       bool mustClear = (selected && pbackColorSelected) || (!selected && pbackColor);
+                                       clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip, offset, cursorValid, mustClear);
                                }
  
                                // border
  
                                {
                                        gRegion rc(rect);
-                                       clearRegion(painter, style, local_style, ePyObject(), ePyObject(), pbackColor, pbackColorSelected, selected, rc, sel_clip, offset, cursorValid);
+                                       bool mustClear = (selected && pbackColorSelected) || (!selected && pbackColor);
+                                       clearRegion(painter, style, local_style, ePyObject(), ePyObject(), pbackColor, pbackColorSelected, selected, rc, sel_clip, offset, cursorValid, mustClear);
                                }
  
                                painter.blit(pixmap, rect.topLeft(), rect, (type == TYPE_PIXMAP_ALPHATEST) ? gPainter::BT_ALPHATEST : (type == TYPE_PIXMAP_ALPHABLEND) ? gPainter::BT_ALPHABLEND : 0);