CComponentsWindow: add member doCenter()

Allows centering of window on screen, mostly senseful for
window objects without parent


Origin commit data
------------------
Commit: 8cad2a3ca5
Author: Thilo Graf <dbt@novatux.de>
Date: 2014-01-18 (Sat, 18 Jan 2014)
This commit is contained in:
2014-01-18 23:49:26 +01:00
parent c3216202f6
commit 50250176c8
2 changed files with 14 additions and 5 deletions

View File

@@ -80,11 +80,13 @@ void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const
//CComponentsForm //CComponentsForm
cc_item_type = CC_ITEMTYPE_FRM_WINDOW; cc_item_type = CC_ITEMTYPE_FRM_WINDOW;
//using current screen settings for default dimensions, do centering if default values == 0 //using current screen settings for default dimensions, do use full screen if default values for width/height = 0
width = w == 0 ? frameBuffer->getScreenWidth(true) : w; int w_tmp = frameBuffer->getScreenWidth(w == 0 ? true : false);
height = h == 0 ? frameBuffer->getScreenHeight(true) : h; int h_tmp = frameBuffer->getScreenHeight(h == 0 ? true : false);
x = x_pos == (CC_CENTERED || 0) ? getScreenStartX(width)/2 - width/2 : x_pos; width = w == 0 ? w_tmp : w;
y = y_pos == (CC_CENTERED || 0) ? getScreenStartY(height)/2 - height/2 : y_pos; height = h == 0 ? h_tmp : h;
x = x_pos;
y = y_pos;
ccw_caption = caption; ccw_caption = caption;
ccw_icon_name = iconname; ccw_icon_name = iconname;
@@ -108,6 +110,11 @@ void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const
initCCWItems(); initCCWItems();
} }
void CComponentsWindow::doCenter(){
x = cc_parent ? cc_parent->getWidth() - width/2 : frameBuffer->getScreenWidth(true)/2 - width/2;
y = cc_parent ? cc_parent->getHeight() - height/2 : frameBuffer->getScreenHeight(true)/2 -height/2;
}
void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const int& align_mode) void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const int& align_mode)
{ {
ccw_caption = g_Locale->getText(locale_text); ccw_caption = g_Locale->getText(locale_text);

View File

@@ -89,6 +89,8 @@ class CComponentsWindow : public CComponentsForm
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
///allow centering of window on screen, mostly senseful for window object without parent
void doCenter();
public: public:
enum enum