CComponentsForm: fix item offset with enabled frame

frame width was not considered
This commit is contained in:
2014-10-04 00:20:48 +02:00
parent 8aa2b6a5ab
commit f7faf07ab1
2 changed files with 17 additions and 12 deletions

View File

@@ -363,6 +363,7 @@ void CComponentsForm::paintCCItems()
//using of real x/y values to paint items if this text object is bound in a parent form
int this_x = x, auto_x = x, this_y = y, auto_y = y, this_w = width;
int w_parent_frame = 0;
if (cc_parent){
this_x = auto_x = cc_xr;
this_y = auto_y = cc_yr;
@@ -406,14 +407,14 @@ void CComponentsForm::paintCCItems()
dprintf(DEBUG_INFO, "[CComponentsForm] %s: page_count = %u, item_page = %u, cur_page = %u\n", __func__, getPageCount(), cc_item->getPageNumber(), this->cur_page);
//get current dimension of item
int w_item = cc_item->getWidth();
int h_item = cc_item->getHeight();
//get current position of item
int xpos = cc_item->getXPos();
int ypos = cc_item->getYPos();
//get current dimension of item
int w_item = cc_item->getWidth() - (xpos <= fr_thickness ? fr_thickness : 0);
int h_item = cc_item->getHeight() - (ypos <= fr_thickness ? fr_thickness : 0);
//check item for corrupt position, skip current item if found problems
if (ypos > height || xpos > this_w){
dprintf(DEBUG_INFO, "[CComponentsForm] %s: [form: %d] [item-index %d] [type=%d] WARNING: item position is out of form size:\ndefinied x=%d, defined this_w=%d \ndefinied y=%d, defined height=%d \n",
@@ -422,37 +423,41 @@ void CComponentsForm::paintCCItems()
continue;
}
w_parent_frame = xpos <= fr_thickness ? fr_thickness : 0;
//set required x-position to item:
//append vertical
if (xpos == CC_APPEND){
auto_x += append_x_offset;
cc_item->setRealXPos(auto_x + xpos);
cc_item->setRealXPos(auto_x + xpos + w_parent_frame);
auto_x += w_item;
}
//positionize vertical centered
else if (xpos == CC_CENTERED){
auto_x = this_w/2 - w_item/2;
cc_item->setRealXPos(this_x + auto_x);
cc_item->setRealXPos(this_x + auto_x + w_parent_frame);
}
else{
cc_item->setRealXPos(this_x + xpos);
cc_item->setRealXPos(this_x + xpos + w_parent_frame);
auto_x = (cc_item->getRealXPos() + w_item);
}
w_parent_frame = ypos <= fr_thickness ? fr_thickness : 0;
//set required y-position to item
//append hor
if (ypos == CC_APPEND){
auto_y += append_y_offset;
cc_item->setRealYPos(auto_y + ypos);
cc_item->setRealYPos(auto_y + ypos + w_parent_frame);
auto_y += h_item;
}
//positionize hor centered
else if (ypos == CC_CENTERED){
auto_y = height/2 - h_item/2;
cc_item->setRealYPos(this_y + auto_y);
cc_item->setRealYPos(this_y + auto_y + w_parent_frame);
}
else{
cc_item->setRealYPos(this_y + ypos);
cc_item->setRealYPos(this_y + ypos + w_parent_frame);
auto_y = (cc_item->getRealYPos() + h_item);
}

View File

@@ -184,7 +184,7 @@ void CComponentsButton::initCaption()
x_cap += cc_btn_icon_obj ? cc_btn_icon_obj->getWidth() : 0;
int w_cap = width - fr_thickness - append_x_offset - x_cap - fr_thickness;
int h_cap = height - 2*fr_thickness;
int h_cap = height*80/100/* - 2*fr_thickness*/;
/*NOTE:
paint of centered text in y direction without y_offset
@@ -192,7 +192,7 @@ void CComponentsButton::initCaption()
but text render isn't wrong here, because capitalized chars or long chars like e. 'q', 'y' are considered!
Therefore we here need other icons or a hack, that considers some different height values.
*/
int y_cap = height/2 - h_cap/2 - fr_thickness;
int y_cap = height/2 - h_cap/2 + fr_thickness/2;
cc_btn_capt_obj->setDimensionsAll(x_cap, y_cap, w_cap, h_cap);