void ActionConfigDialog::slotRemoveToolbar() { QListViewItem *item = actionTreeView->currentItem(); QString s = item->text(0); if (item->parent()) { item = item->parent(); s = item->text(0); } if (s != i18n("All")) { if ( KMessageBox::warningContinueCancel(this, i18n("Do you really want to remove the \"%1\" toolbar?").arg(s),QString::null,KStdGuiItem::del()) == KMessageBox::Continue ) { m_toolbarItem = item; connect(m_mainWindow, SIGNAL(toolbarRemoved(const QString&)), SLOT(slotToolbarRemoved(const QString&))); emit removeToolbar(s.lower()); } } }
void CNativeToolbar::createToolbar(rho_param *p) { if (!rho_rhodesapp_check_mode() || !rho_wmsys_has_touchscreen() ) return; int bar_type = TOOLBAR_TYPE; m_rgbBackColor = RGB(220,220,220); m_rgbMaskColor = RGB(255,255,255); m_nHeight = MIN_TOOLBAR_HEIGHT; rho_param *params = NULL; switch (p->type) { case RHO_PARAM_ARRAY: params = p; break; case RHO_PARAM_HASH: { for (int i = 0, lim = p->v.hash->size; i < lim; ++i) { const char *name = p->v.hash->name[i]; rho_param *value = p->v.hash->value[i]; if (strcasecmp(name, "background_color") == 0) m_rgbBackColor = getColorFromString(value->v.string); else if (strcasecmp(name, "mask_color") == 0) m_rgbMaskColor = getColorFromString(value->v.string); else if (strcasecmp(name, "view_height") == 0) m_nHeight = atoi(value->v.string); else if (strcasecmp(name, "buttons") == 0 || strcasecmp(name, "tabs") == 0) params = value; } } break; default: { LOG(ERROR) + "Unexpected parameter type for create_nativebar, should be Array or Hash"; return; } } if (!params) { LOG(ERROR) + "Wrong parameters for create_nativebar"; return; } int size = params->v.array->size; if ( size == 0 ) { removeToolbar(); return; } if ( m_hWnd ) { removeAllButtons(); }else { RECT rcToolbar; rcToolbar.left = 0; rcToolbar.right = 0; rcToolbar.top = 0; rcToolbar.bottom = m_nHeight; Create(getAppWindow().m_hWnd, rcToolbar, NULL, WS_CHILD|CCS_NOPARENTALIGN|CCS_NORESIZE|CCS_NOMOVEY|CCS_BOTTOM|CCS_NODIVIDER | TBSTYLE_FLAT |TBSTYLE_LIST|TBSTYLE_TRANSPARENT ); //TBSTYLE_AUTOSIZE SetButtonStructSize(); } for (int i = 0; i < size; ++i) { rho_param *hash = params->v.array->value[i]; if (hash->type != RHO_PARAM_HASH) { LOG(ERROR) + "Unexpected type of array item for create_nativebar, should be Hash"; return; } const char *label = NULL; const char *action = NULL; const char *icon = NULL; const char *colored_icon = NULL; int nItemWidth = 0; for (int j = 0, lim = hash->v.hash->size; j < lim; ++j) { const char *name = hash->v.hash->name[j]; rho_param *value = hash->v.hash->value[j]; if (value->type != RHO_PARAM_STRING) { LOG(ERROR) + "Unexpected '" + name + "' type, should be String"; return; } if (strcasecmp(name, "label") == 0) label = value->v.string; else if (strcasecmp(name, "action") == 0) action = value->v.string; else if (strcasecmp(name, "icon") == 0) icon = value->v.string; else if (strcasecmp(name, "colored_icon") == 0) colored_icon = value->v.string; else if (strcasecmp(name, "width") == 0) nItemWidth = atoi(value->v.string); } if (label == NULL && bar_type == TOOLBAR_TYPE) label = ""; if ( label == NULL || action == NULL) { LOG(ERROR) + "Illegal argument for create_nativebar"; return; } if ( strcasecmp(action, "forward") == 0 && rho_conf_getBool("jqtouch_mode") ) continue; m_arButtons.addElement( new CToolbarBtn(label, action, icon, nItemWidth) ); } CSize sizeMax = getMaxImageSize(); m_nHeight = max(m_nHeight, sizeMax.cy+MIN_TOOLBAR_IDENT); int nBtnSize = m_nHeight-MIN_TOOLBAR_IDENT; SetButtonSize(max(nBtnSize,sizeMax.cx), max(nBtnSize,sizeMax.cy)); SetBitmapSize(sizeMax.cx, sizeMax.cy); m_listImages.Create(sizeMax.cx, sizeMax.cy, ILC_MASK|ILC_COLOR32, m_arButtons.size(), 0); SetImageList(m_listImages); for ( int i = 0; i < (int)m_arButtons.size(); i++ ) addToolbarButton( *m_arButtons.elementAt(i), i ); AutoSize(); alignSeparatorWidth(); ShowWindow(SW_SHOW); #if defined (OS_WINDOWS) RECT rcWnd; getAppWindow().GetWindowRect(&rcWnd); getAppWindow().SetWindowPos( 0, 0,0,rcWnd.right-rcWnd.left-1,rcWnd.bottom-rcWnd.top, SWP_NOMOVE|SWP_NOZORDER|SWP_FRAMECHANGED); getAppWindow().SetWindowPos( 0, 0,0,rcWnd.right-rcWnd.left,rcWnd.bottom-rcWnd.top, SWP_NOMOVE|SWP_NOZORDER|SWP_FRAMECHANGED); #else getAppWindow().SetWindowPos( 0, 0,0,0,0, SWP_NOMOVE|SWP_NOZORDER|SWP_NOSIZE|SWP_FRAMECHANGED); #endif }