Exemple #1
0
void StylesPlugin::setStyles()
{
    QStyle *style = NULL;
#if QT_VERSION >= 300
    if (*getStyle())
        style = QStyleFactory::create(getStyle());
#else
if (*getStyle()){
    string s = getStyle();
    if (s == "windows"){
        style = new QWindowsStyle;
    }else if (s == "motif"){
        style = new QMotifStyle;
    }else if (s == "cde"){
        style = new QCDEStyle;
    }else if (s == "motifplus"){
        style = new QMotifPlusStyle;
    }else if (s == "platinum"){
        style = new QPlatinumStyle;
    }else if (s == "sgi"){
        style = new QSGIStyle;
#ifdef WIN32
    }else{
        bool bOK = true;
        if (s == "xpstyle"){
            HINSTANCE hLib = LoadLibraryA("UxTheme.dll");
            if (hLib){
                FreeLibrary(hLib);
            }else{
                bOK = false;
            }
        }
        if (bOK){
            string dll = "plugins\\styles\\";
            dll += s;
            dll += ".dll";
            HINSTANCE hLib = LoadLibraryA(app_file(dll.c_str()).c_str());
            if (hLib){
                StyleInfo*  (*getStyleInfo)() = NULL;
                (DWORD&)getStyleInfo = (DWORD)GetProcAddress(hLib,"GetStyleInfo");
                if (getStyleInfo){
                    StyleInfo *info = getStyleInfo();
                    if (info && info->create)
                        style = info->create();
                }
            }
        }
#endif
    }
}
#endif
    if (style){
        QApplication::setStyle(style);
        if (!getSystemColors())
            setColors();
    }else{
        setStyle(NULL);
    }
}
void Buffer::applyStyle(int styleNumber, const StyleInfo& style) {
    if (style.foregroundColor() >= 0) {
        styleSetFore(styleNumber, style.foregroundColor());
    }
    if (style.backgroundColor() >= 0) {
        styleSetBack(styleNumber, style.backgroundColor());
    }
    styleSetBold(styleNumber, style.bold());
    styleSetItalic(styleNumber, style.italic());
    styleSetUnderline(styleNumber, style.underline());
    styleSetEOLFilled(styleNumber, style.eolFilled());
}
Exemple #3
0
void Doc_Stc::SetStyle (int style, const StyleInfo & data)
{
    StyleSetForeground (style, data.GetFG());
    StyleSetBackground (style, data.GetBG());
    StyleSetFontAttr (
        style,
        data.GetSize(), data.GetFont(),
        data.IsBold(), data.IsItalic(), data.IsUnderlined()
    );
}
Exemple #4
0
int main(int argc, char *argv[])
{
    int res = 1;
#ifdef WIN32
    HANDLE hMutex = CreateMutexA(NULL, FALSE, "SIM_Mutex");
#endif
    QApplication::setColorSpec( QApplication::ManyColor );
    qInstallMsgHandler(simMessageOutput);
    KAboutData aboutData(PACKAGE,
                         I18N_NOOP("SIM"),
                         _VERSION,
                         I18N_NOOP("Multiprotcol instant messenger"),
                         KAboutData::License_GPL,
                         "Copyright (C) 2002-2004, Vladimir Shutoff",
                         0,
                         "http://sim-icq.sourceforge.net/",
                         "*****@*****.**");
    aboutData.addAuthor("Vladimir Shutoff",I18N_NOOP("Maintainer"),"*****@*****.**");
    aboutData.addAuthor("Christian Ehrlicher",I18N_NOOP("Developer"),"*****@*****.**");
    setAboutData(&aboutData);
#ifndef WIN32
    int _argc = 0;
    char **_argv = new char*[argc + 1];
    _argv[_argc++] = argv[0];
    char **to = argv + 1;
    // check all parameters and sort them
    // _argc/v: parameter for KUnqiueApplication
    //  argc/v: plugin parameter
    for (char **p = argv + 1; *p; ++p){
        char *arg = *p;
        // check if "-" or "--"
        if (arg[0] != '-') {
            *(to++) = *p;
            continue;
        }
        arg++;
        if (arg[0] == '-')
            arg++;
        // if they are parameters with variable params we need
        // to skip the next param
        bool bSkip = false;
        const char **q;
        // check for qt or kde - parameters
        for (q = qt_args; *q; ++q){
            unsigned len = strlen(*q);
            bSkip = false;
            // variable parameter?
            if ((*q)[len-1] == ':'){
                len--;
                bSkip = true;
            }
            // copy them for KUnqiueApplication-args
            if ((strlen(arg) == len) && !memcmp(arg, *q, len))
                break;
        }
        // dunno know what to do here
        if (*q){
            _argv[_argc++] = *p;
            argc--;
            if (bSkip){
                ++p;
                if (*p == NULL) break;
                _argv[_argc++] = *p;
                argc--;
            }
        }else{
            *(to++) = *p;
        }
    }
    *to = NULL;
    _argv[_argc] = NULL;
#ifdef USE_KDE
    KCmdLineArgs::init( _argc, _argv, &aboutData );
    KCmdLineOptions options[] =
        {
            { 0, 0, 0 }
        };
    KCmdLineArgs::addCmdLineOptions( options );
    KUniqueApplication::addCmdLineOptions();
    if (!KUniqueApplication::start())
        exit(-1);
    SimApp app;
#else
    SimApp app(_argc, _argv);
#endif
#ifndef QT_MACOSX_VERSION
    old_errhandler = XSetErrorHandler(x_errhandler);
#endif
#else
	for (int i = 0; i < argc; i++){
		string arg = argv[i];
		if ((arg[0] == '/') || (arg[0] == '-'))
			arg = arg.substr(1);
		if ((arg == "reinstall") || (arg == "showicons") || (arg == "hideicons"))
			return 0;
	}
    SimApp app(argc, argv);
    StyleInfo*  (*getStyleInfo)() = NULL;
    HINSTANCE hLib = LoadLibraryA("UxTheme.dll");
    if (hLib != NULL)
        hLib = LoadLibraryA(app_file("plugins\\styles\\xpstyle.dll").c_str());
    if (hLib != NULL)
        (DWORD&)getStyleInfo = (DWORD)GetProcAddress(hLib,"GetStyleInfo");
    if (getStyleInfo){
        StyleInfo *info = getStyleInfo();
        if (info)
            qApp->setStyle(info->create());
    }
#endif
    PluginManager p(argc, argv);
    if (p.isLoaded())
        res = app.exec();
#ifdef WIN32
    CloseHandle(hMutex);
#endif
    return res;
};
void ColorScheme::processColorSchemeXml(QXmlStreamReader &xml,
        QHash<QString, ColorScheme *> &colorSchemes) {
    // The color scheme
    ColorScheme *colorScheme = new ColorScheme;
    // The styles defined
    QHash<QString, StyleInfo> definedStyles;

    QString langId;
    while (!xml.atEnd() && !xml.hasError()) {
        QXmlStreamReader::TokenType token = xml.readNext();
        if (token == QXmlStreamReader::StartElement) {
            if (xml.name() == "colorscheme") {
                QString name = xml.attributes().value("name").toString();
                colorSchemes[name] = colorScheme;
            } else if (xml.name() == "color") {
                QString type = xml.attributes().value("type").toString();
                QString text = xml.readElementText(
                            QXmlStreamReader::ErrorOnUnexpectedElement);
                if (type == "foreground") {
                    colorScheme->m_foreground = convertColor(text);
                } else if (type == "background") {
                    colorScheme->m_background = convertColor(text);
                } else if (type == "caret") {
                    colorScheme->m_caret = convertColor(text);
                } else if (type == "caretLine") {
                    colorScheme->m_caretLine = convertColor(text);
                } else if (type == "selection") {
                    colorScheme->m_selection = convertColor(text);
                } else if (type == "whitespace") {
                    colorScheme->m_whitespaceForeground = convertColor(text);
                }
            } else if (xml.name() == "style") {
                StyleInfo styleInfo;
                QXmlStreamAttributes attrs = xml.attributes();
                QString name = attrs.value("name").toString();
                if (attrs.hasAttribute("foreground")) {
                    styleInfo.setForegroundColor(
                            convertColor(attrs.value("foreground").toString()));
                }
                if (attrs.hasAttribute("background")) {
                    styleInfo.setBackgroundColor(
                            convertColor(attrs.value("background").toString()));
                }
                if (attrs.hasAttribute("bold")) {
                    styleInfo.setBold(attrs.value("bold").toString() == "true");
                }
                if (attrs.hasAttribute("italic")) {
                    styleInfo.setItalic(
                            attrs.value("italic").toString() == "true");
                }
                if (attrs.hasAttribute("underline")) {
                    styleInfo.setUnderline(
                            attrs.value("underline").toString() == "true");
                }
                if (attrs.hasAttribute("eolFilled")) {
                    styleInfo.setEolFilled(
                            attrs.value("eolFilled").toString() == "true");
                }
                definedStyles[name] = styleInfo;
            } else if (xml.name() == "language") {
                langId = xml.attributes().value("id").toString();
                colorScheme->m_languagesStyles[langId] = QHash<int, StyleInfo>();
            } else if (xml.name() == "styleInfo") {
                QString idStr = xml.attributes().value("id").toString();
                bool ok;
                int id = idStr.toInt(&ok);
                if (ok) {
                    QXmlStreamAttributes attrs = xml.attributes();
                    if (attrs.hasAttribute("styleRef")) {
                        QString styleRef = attrs.value("styleRef").toString();
                        colorScheme->m_languagesStyles[langId][id] = definedStyles[styleRef];
                    }
                }
            }
        }
    }
}