Make Widget::update_region member private.

+ Renamed jwidget_flush_redraw to Widget::flushRedraw().
This commit is contained in:
David Capello 2012-03-20 16:24:46 -03:00
parent 01b6afb531
commit 6bd39e0aff
6 changed files with 35 additions and 44 deletions

View File

@ -221,7 +221,7 @@ bool ColorCurveEditor::onProcessMessage(Message* msg)
NULL, NULL);
if (m_editPoint) {
invalidate();
jwidget_flush_redraw(this);
this->flushRedraw();
if (editNodeManually(*m_editPoint))
CurveEditorChange();

View File

@ -562,7 +562,7 @@ bool jmanager_generate_messages(JWidget manager)
}
/* generate redraw events */
jwidget_flush_redraw(manager);
manager->flushRedraw();
/* make some OSes happy */
rest(0);

View File

@ -261,11 +261,12 @@ bool View::onProcessMessage(Message* msg)
case JM_FOCUSENTER:
case JM_FOCUSLEAVE:
/* TODO add something to avoid this (theme specific stuff) */
// TODO This is theme specific stuff
// Redraw the borders each time the focus enters or leaves the view.
{
JRegion reg1 = jwidget_get_drawable_region(this, JI_GDR_CUTTOPWINDOWS);
jregion_union(this->update_region, this->update_region, reg1);
jregion_free(reg1);
JRegion region = jwidget_get_drawable_region(this, JI_GDR_CUTTOPWINDOWS);
invalidateRegion(region);
jregion_free(region);
}
break;
}

View File

@ -69,7 +69,7 @@ Widget::Widget(int type)
this->m_font = this->m_theme ? this->m_theme->default_font: NULL;
this->m_bg_color = -1;
this->update_region = jregion_new(NULL, 0);
this->m_update_region = jregion_new(NULL, 0);
this->theme_data[0] = NULL;
this->theme_data[1] = NULL;
@ -116,8 +116,8 @@ Widget::~Widget()
jlist_free(this->children);
/* destroy the update region */
if (this->update_region)
jregion_free(this->update_region);
if (m_update_region)
jregion_free(m_update_region);
/* destroy the name */
if (this->name)
@ -1065,10 +1065,7 @@ void jwidget_set_bg_color(JWidget widget, int color)
widget->setBgColor(color);
}
/**********************************************************************/
/* drawing methods */
void jwidget_flush_redraw(JWidget widget)
void Widget::flushRedraw()
{
std::queue<Widget*> processing;
int c, nrects;
@ -1076,13 +1073,13 @@ void jwidget_flush_redraw(JWidget widget)
JLink link;
JRect rc;
if (widget->flags & JI_DIRTY) {
widget->flags ^= JI_DIRTY;
processing.push(widget);
if (this->flags & JI_DIRTY) {
this->flags ^= JI_DIRTY;
processing.push(this);
}
while (!processing.empty()) {
widget = processing.front();
Widget* widget = processing.front();
processing.pop();
ASSERT_VALID_WIDGET(widget);
@ -1099,18 +1096,18 @@ void jwidget_flush_redraw(JWidget widget)
}
}
nrects = JI_REGION_NUM_RECTS(widget->update_region);
nrects = JI_REGION_NUM_RECTS(widget->m_update_region);
if (nrects > 0) {
/* get areas to draw */
JRegion region = jwidget_get_drawable_region(widget, JI_GDR_CUTTOPWINDOWS);
jregion_intersect(widget->update_region,
widget->update_region, region);
jregion_intersect(widget->m_update_region,
widget->m_update_region, region);
jregion_free(region);
nrects = JI_REGION_NUM_RECTS(widget->update_region);
nrects = JI_REGION_NUM_RECTS(widget->m_update_region);
/* draw the widget */
for (c=0, rc=JI_REGION_RECTS(widget->update_region);
for (c=0, rc=JI_REGION_RECTS(widget->m_update_region);
c<nrects;
c++, rc++) {
/* create the draw message */
@ -1123,7 +1120,7 @@ void jwidget_flush_redraw(JWidget widget)
jmanager_enqueue_message(msg);
}
jregion_empty(widget->update_region);
jregion_empty(widget->m_update_region);
}
}
}
@ -1144,7 +1141,7 @@ void Widget::invalidate()
JRegion reg1 = jwidget_get_drawable_region(this, JI_GDR_CUTTOPWINDOWS);
JLink link;
jregion_copy(this->update_region, reg1);
jregion_copy(this->m_update_region, reg1);
jregion_free(reg1);
mark_dirty_flag(this);
@ -1181,11 +1178,11 @@ void Widget::invalidateRegion(const JRegion region)
JI_GDR_CUTTOPWINDOWS);
JLink link;
jregion_union(reg1, this->update_region, region);
jregion_intersect(this->update_region, reg1, reg2);
jregion_union(reg1, this->m_update_region, region);
jregion_intersect(this->m_update_region, reg1, reg2);
jregion_free(reg2);
jregion_subtract(reg1, region, this->update_region);
jregion_subtract(reg1, region, this->m_update_region);
mark_dirty_flag(this);
@ -1213,13 +1210,13 @@ void Widget::scrollRegion(JRegion region, int dx, int dy)
jregion_translate(reg2, dx, dy);
jregion_union(this->update_region, this->update_region, region);
jregion_subtract(this->update_region, this->update_region, reg2);
jregion_union(this->m_update_region, this->m_update_region, region);
jregion_subtract(this->m_update_region, this->m_update_region, reg2);
mark_dirty_flag(this);
// Generate the JM_DRAW messages for the widget's update_region
jwidget_flush_redraw(this);
// Generate the JM_DRAW messages for the widget's m_update_region
this->flushRedraw();
jregion_free(reg2);
}

View File

@ -77,10 +77,6 @@ void jwidget_set_min_size(JWidget widget, int w, int h);
void jwidget_set_max_size(JWidget widget, int w, int h);
void jwidget_set_bg_color(JWidget widget, int color);
/* drawing methods */
void jwidget_flush_redraw(JWidget widget);
/* signal handle */
void jwidget_signal_on(JWidget widget);
@ -122,20 +118,15 @@ public:
/* virtual properties */
JList hooks; /* hooks with msg_proc and specific data */
/* common widget properties */
private:
Theme* m_theme; // Widget's theme
int m_align; // Widget alignment
std::string m_text; // Widget text
struct FONT *m_font; // Text font type
int m_bg_color; // Background color
JRegion m_update_region; // Region to be redrawed.
public:
/* drawable cycle */
JRegion update_region; /* region to be redrawed */
/* more properties... */
// Extra data for the theme
void *theme_data[4];
@ -280,6 +271,8 @@ public:
void invalidateRect(const JRect rect);
void invalidateRegion(const JRegion region);
void flushRedraw();
void scrollRegion(JRegion region, int dx, int dy);
// ===============================================================

View File

@ -465,7 +465,7 @@ void ToolBar::openPopupFrame(int group_index, ToolGroup* tool_group)
jrect_free(rcTemp);
// Flush JM_DRAW messages and send them
jwidget_flush_redraw(ji_get_default_manager());
ji_get_default_manager()->flushRedraw();
jmanager_dispatch_messages(ji_get_default_manager());
// Save the area
@ -605,7 +605,7 @@ void ToolBar::closeTipWindow()
m_tipWindow = NULL;
// Flush JM_DRAW messages and send them
jwidget_flush_redraw(ji_get_default_manager());
ji_get_default_manager()->flushRedraw();
jmanager_dispatch_messages(ji_get_default_manager());
}
}