Example #1
0
BOOL CComboBox::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
    QWidget *parentView = (QWidget *)pParentWnd->GetNSWindow();
    QComboBox *comboBox = new QComboBox(parentView);
    QRect contentRect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);

    comboBox->move (contentRect.x(), contentRect.y());
    comboBox->resize(contentRect.width(), contentRect.height());

    comboBox->setAccessibleName(QString().setNum(nID));

    m_hWnd = comboBox;
    mParentWin = pParentWnd;

    return TRUE;
}
Example #2
0
QWidget* EncTtsCfgGui::createWidgets(EncTtsSetting* setting)
{
    // value display
    QWidget* value = NULL;
    switch(setting->type())
    {
        case EncTtsSetting::eDOUBLE:
        {
            QDoubleSpinBox *spinBox = new QDoubleSpinBox(this);
            spinBox->setAccessibleName(setting->name());
            spinBox->setMinimum(setting->min().toDouble());
            spinBox->setMaximum(setting->max().toDouble());
            spinBox->setSingleStep(0.01);
            spinBox->setValue(setting->current().toDouble());
            connect(spinBox,SIGNAL(valueChanged(double)),this,SLOT(updateSetting()));
            value = spinBox;
            break;
        }
        case EncTtsSetting::eINT:
        {
            QSpinBox *spinBox = new QSpinBox(this);
            spinBox->setAccessibleName(setting->name());
            spinBox->setMinimum(setting->min().toInt());
            spinBox->setMaximum(setting->max().toInt());
            spinBox->setValue(setting->current().toInt());
            connect(spinBox,SIGNAL(valueChanged(int)),this,SLOT(updateSetting()));
            value = spinBox;
            break;
        }
        case EncTtsSetting::eSTRING:
        {
            QLineEdit *lineEdit = new QLineEdit(this);
            lineEdit->setAccessibleName(setting->name());
            lineEdit->setText(setting->current().toString());
            connect(lineEdit,SIGNAL(textChanged(QString)),this,SLOT(updateSetting()));
            value = lineEdit;
            break;
        }
        case EncTtsSetting::eREADONLYSTRING:
        {
            value = new QLabel(setting->current().toString(),this);
            break;
        }
        case EncTtsSetting::eSTRINGLIST:
        {
            QComboBox *comboBox = new QComboBox(this);
            comboBox->setAccessibleName(setting->name());
            comboBox->addItems(setting->list());
            int index = comboBox->findText(setting->current().toString());
            comboBox->setCurrentIndex(index);
            connect(comboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateSetting()));
            value = comboBox;
            break;
        }
        case EncTtsSetting::eBOOL:
        {
            QCheckBox *checkbox = new QCheckBox(this);
            checkbox->setAccessibleName(setting->name());
            checkbox->setCheckState(setting->current().toBool() == true ? Qt::Checked : Qt::Unchecked);
            connect(checkbox,SIGNAL(stateChanged(int)),this,SLOT(updateSetting()));
            value = checkbox;
            break;
        }
        default:
        {
            LOG_WARNING() << "Warning: unknown EncTTsSetting type" << setting->type();
            break;
        }
    }

    // remember widget
    if(value != NULL)
    {
        m_settingsWidgetsMap.insert(setting,value);
        connect(setting,SIGNAL(updateGui()),this,SLOT(updateWidget()));
    }

    return value;
}
Example #3
0
bool EV_QtToolbar::synthesize(void)
{
	// create a Qt toolbar from the info provided.
	const EV_Toolbar_ActionSet * pToolbarActionSet = m_pQtApp->getToolbarActionSet();
	UT_ASSERT(pToolbarActionSet);

	XAP_Toolbar_ControlFactory * pFactory = m_pQtApp->getControlFactory();
	UT_ASSERT(pFactory);

	UT_uint32 nrLabelItemsInLayout = m_pToolbarLayout->getLayoutItemCount();
	UT_ASSERT(nrLabelItemsInLayout > 0);

	m_wToolbar = new QToolBar();
	UT_ASSERT(m_wToolbar);

	Qt::ToolButtonStyle style = getStyle();
	m_wToolbar->setToolButtonStyle(style);

	for (UT_uint32 k=0; (k < nrLabelItemsInLayout); k++)
	{
		EV_Toolbar_LayoutItem * pLayoutItem = m_pToolbarLayout->getLayoutItem(k);
		UT_continue_if_fail(pLayoutItem);

		XAP_Toolbar_Id id = pLayoutItem->getToolbarId();
		EV_Toolbar_Action * pAction = pToolbarActionSet->getAction(id);
		UT_ASSERT(pAction);
		EV_Toolbar_Label * pLabel = m_pToolbarLabelSet->getLabel(id);
		UT_ASSERT(pLabel);

		const char * szToolTip = pLabel->getToolTip();
		if (!szToolTip || !*szToolTip)
			szToolTip = pLabel->getStatusMsg();		

		switch (pLayoutItem->getToolbarLayoutFlags())
		{
			case EV_TLF_Normal:
			{
				switch (pAction->getItemType())
				{
					case EV_TBIT_PushButton:
					{
						UT_ASSERT(g_ascii_strcasecmp(pLabel->getIconName(),"NoIcon")!=0);
						if(pAction->getToolbarId() != AP_TOOLBAR_ID_INSERT_TABLE)
						{
							const char *icon_name = pLabel->getIconName();
							QPixmap		pixmap;
							pixmap = abi_pixmap_from_toolbar_id (icon_name);
							if(!pixmap.isNull())
							{
								QIcon icon(pixmap);
								QString str = "";
								QPushButton *item = new QPushButton(icon, str);
								m_wToolbar->addWidget(item);
							}
						}
						else
						{
							const char *icon_name = pLabel->getIconName();
							QPixmap		pixmap;
							pixmap = abi_pixmap_from_toolbar_id (icon_name);
							if(!pixmap.isNull())
							{
								QIcon icon(pixmap);
								QString str = "";
								QPushButton *item = new QPushButton(icon, str);
								m_wToolbar->addWidget(item);
							}
						}

						break;
					}
					case EV_TBIT_ToggleButton:
					case EV_TBIT_GroupButton:
					{
						UT_ASSERT(g_ascii_strcasecmp(pLabel->getIconName(),"NoIcon")!=0);
						const char *icon_name = pLabel->getIconName();
						QPixmap		pixmap;
						pixmap = abi_pixmap_from_toolbar_id (icon_name);
						if(!pixmap.isNull())
						{
							QIcon icon(pixmap);					
							QString str = "";
							QPushButton *item = new QPushButton(icon, str);
							item->setCheckable(true);
							m_wToolbar->addWidget(item);
						}
						break;
					}
					case EV_TBIT_EditText:
					{
						break;
					}
					case EV_TBIT_DropDown:
					{
						break;
					}
					case EV_TBIT_ComboBox:
					{
						EV_Toolbar_Control * pControl = pFactory->getControl(this, id);
						UT_ASSERT(pControl);

						QComboBox *combo;
						bool isFontCombo = false;
						if(id == AP_TOOLBAR_ID_FMT_SIZE) 
						{
							combo = new QComboBox();
						}
						else if(id == AP_TOOLBAR_ID_FMT_FONT)
						{
							isFontCombo = true;
							combo = new QFontComboBox();
							QString str = "AbiFontCombo";
							combo->setAccessibleName(str); 
						}
						else if(id == AP_TOOLBAR_ID_ZOOM) 
						{
							combo = new QComboBox();
							QString str = "AbiZoomCombo";
							combo->setAccessibleName(str); 
						}
						else if(id == AP_TOOLBAR_ID_FMT_STYLE) 
						{
							combo = new QComboBox();
							QString str = "AbiStyleCombo";
							combo->setAccessibleName(str); 
						}
						else
						{
							UT_ASSERT(0);
						}

						// populate it
						if (pControl) 
						{
							pControl->populate();
							const UT_GenericVector<const char*> * v = pControl->getContents();
							UT_ASSERT(v);
							gint items = v->getItemCount();	
							if (isFontCombo) 
							{
								for (gint m=0; m < items; m++) 
								{
									QString str = v->getNthItem(m);
									combo->addItem(str);
								}	
							}
							else
							{
								for (gint m=0; m < items; m++) 
								{
									const char * sz = v->getNthItem(m);
									std::string sLoc;
									if (id == AP_TOOLBAR_ID_FMT_STYLE)
									{
										pt_PieceTable::s_getLocalisedStyleName(sz, sLoc);
										sz = sLoc.c_str();
									}
									QString str = sz;
									combo->addItem(str);
								}	
							}
						}

						m_wToolbar->addWidget(combo);

						// for now, we never repopulate, so can just toss it
						DELETEP(pControl);
						break;
					}
					case EV_TBIT_ColorFore:
					case EV_TBIT_ColorBack:
					{

						UT_ASSERT (g_ascii_strcasecmp(pLabel->getIconName(),"NoIcon") != 0);
						QComboBox *combo;

						if (pAction->getItemType() == EV_TBIT_ColorFore) 
						{
							// TODO Some icon implementation
							const XAP_StringSet * pSS = XAP_App::getApp()->getStringSet();
							std::string sClear;
							pSS->getValueUTF8(XAP_STRING_ID_TB_ClearForeground,sClear);	
							combo = new QComboBox();
							QString str = sClear.c_str();		
							combo->setAccessibleName(str); 				
						}
						else
						{
							// TODO Some icon implementation
							const XAP_StringSet * pSS = XAP_App::getApp()->getStringSet();
							std::string sClear;
							pSS->getValueUTF8(XAP_STRING_ID_TB_ClearForeground,sClear);	
							combo = new QComboBox();
							QString str = sClear.c_str();		
							combo->setAccessibleName(str); 								
						}
						m_wToolbar->addWidget(combo);
						break;
					}
					case EV_TBIT_StaticLabel:
					{
						// TODO do these...
						break;
					}
					case EV_TBIT_Spacer:
					{
						break;
					}
#ifdef ENABLE_MENUBUTTON
					case EV_TBIT_MenuButton:
					{
						break;
					}
#endif
					case EV_TBIT_BOGUS:
					default:
					{
						break;
					}
				}
				break;
			}
			case EV_TLF_Spacer:
			{
				m_wToolbar->addSeparator();
				break;
			}
			default:
			{
				UT_ASSERT(0);
			}
		}
	}

	QMainWindow * wTopLevel = static_cast<XAP_QtFrameImpl *>(m_pFrame->getFrameImpl())->getTopLevel();
	wTopLevel->addToolBar(m_wToolbar);
	wTopLevel->show();
	return true;
}