示例#1
0
void StFolder::addItem(const StArrayList<StString>& theExtensions,
                       int theDeep,
                       const StString& theSearchFolderPath,
                       const StString& theCurrentItemName) {
    if(theCurrentItemName == IGNORE_DIR_CURR_NAME || theCurrentItemName == IGNORE_DIR_UP_NAME) {
        return;
    }

    StString aCurrItemFullName = theSearchFolderPath + SYS_FS_SPLITTER + theCurrentItemName;
    if(isFolder(aCurrItemFullName)) {
        if(theDeep > 1) {
            StFolder* aSubFolder = new StFolder(theCurrentItemName, this);
            aSubFolder->init(theExtensions, theDeep - 1);
            if(aSubFolder->size() > 0) {
                add(aSubFolder);
            } else {
                // ignore empty folders
                delete aSubFolder;
            }
        }
    } else {
        StString anItemExtension = StFileNode::getExtension(theCurrentItemName);
        for(size_t anExt = 0; anExt < theExtensions.size(); ++anExt) {
            if(anItemExtension.isEqualsIgnoreCase(theExtensions[anExt])) {
                add(new StFileNode(theCurrentItemName, this));
                break;
            }
        }
    }
}
示例#2
0
unsigned int decodeHotKey(const StString& theString) {
    unsigned int aKey = 0;
    if(theString.isEmpty()) {
        return aKey;
    }

    // decode flags (split by + separator)
    StUtf8Iter aFrom  = theString.iterator();
    StUtf8Iter anIter = theString.iterator();
    for(; *anIter != 0; ++anIter) {
        if(*anIter == stUtf32_t('+')) {
            if(anIter.getIndex() == 0) {
                return ST_VK_OEM_PLUS; // single '+'
            }

            const StCStringUtf8 aSubStr = {
                aFrom.getBufferHere(),
                size_t(anIter.getBufferHere() - aFrom.getBufferHere()),
                       anIter.getIndex()      - aFrom.getIndex()
            };

            if(aSubStr.isEquals(THE_VKEYS_NAMES[ST_VK_SHIFT])) {
                aKey |= ST_VF_SHIFT;
            } else if(aSubStr.isEquals(THE_VKEYS_NAMES[ST_VK_CONTROL])) {
                aKey |= ST_VF_CONTROL;
            }

            aFrom = anIter;
            ++aFrom;
        }
    }

    // decode VKey itself
    const StCStringUtf8 aSubStr = {
        aFrom.getBufferHere(),
        size_t(anIter.getBufferHere() - aFrom.getBufferHere()),
               anIter.getIndex()      - aFrom.getIndex()
    };

    if(aSubStr.Size == 1) {
        // optimized code for letters
        if(*aSubStr.String >= 'A'
        && *aSubStr.String <= 'Z') {
            aKey |= (unsigned int )*aSubStr.String;
            return aKey;
        } else if(*aSubStr.String >= '0'
               && *aSubStr.String <= '9') {
            aKey |= (unsigned int )*aSubStr.String;
            return aKey;
        }
    }
    for(unsigned int aKeyIter = 0; aKeyIter <= 223; ++aKeyIter) {
        if(aSubStr.isEquals(THE_VKEYS_NAMES[aKeyIter])) {
            aKey |= aKeyIter;
            break;
        }
    }

    return aKey;
}
示例#3
0
StString StProcess::getStCoreFolder() {
    StString aCoreEnvValue = getEnv(ST_ENV_NAME_STCORE_PATH);
#ifdef _WIN32
    if(aCoreEnvValue.isEmpty()) {
        // read env. value directly from registry (before first log off / log in)
        const StString aRegisterPath = "Environment";
        loadStringFromRegister(aRegisterPath, ST_ENV_NAME_STCORE_PATH, aCoreEnvValue);
    }
#endif

    // repair filesystem splitter
    if(!aCoreEnvValue.isEmpty() && !aCoreEnvValue.isEndsWith(SYS_FS_SPLITTER)) {
        aCoreEnvValue += StString(SYS_FS_SPLITTER);
    }

    if(isValidStCorePath(aCoreEnvValue)) {
        // environment variable is correctly set
        return aCoreEnvValue;
    }

    const StString aProcessPath = getProcessFolder();
    if(isValidStCorePath(aProcessPath)) {
        return aProcessPath;
    }
    return StString();
}
示例#4
0
    /**
     * Create context.
     */
    bool create(const StString& theFile) {
        if(myFormat == NULL) {
            return false;
        }

    #if !defined(ST_LIBAV_FORK)
        avformat_alloc_output_context2(&Context, myFormat, NULL, theFile.toCString());
    #else
        Context = avformat_alloc_context();
        if(Context == NULL) {
            return false;
        }

        Context->oformat = myFormat;
        if(Context->oformat->priv_data_size > 0) {
            Context->priv_data = av_mallocz(Context->oformat->priv_data_size);
            if(!Context->priv_data) {
                //goto nomem;
            }
            if(Context->oformat->priv_class) {
                *(const AVClass**)Context->priv_data = Context->oformat->priv_class;
                //av_opt_set_defaults(aCtxOut->priv_data);
            }
        } else {
            Context->priv_data = NULL;
        }

        const size_t aStrLen = stMin(theFile.Size + 1, size_t(1024));
        stMemCpy(Context->filename, theFile.toCString(), aStrLen);
        Context->filename[1023] = '\0';
    #endif
        return Context != NULL;
    }
示例#5
0
void StBrowserPlugin::streamAsFile(NPStream*   theStream,
                                   const char* theFileName) {
    if(theFileName == NULL) {
        ///ST_DEBUG_LOG("streamAsFile ERROR");
        return;
    }

    const StString anUrl((theStream->url != NULL) ? theStream->url : "");
    const bool isPreview = !myPreviewUrl.isEmpty()
                           && (anUrl.isEndsWith(myPreviewUrl) || anUrl.isEndsWith(myPreviewUrlUtf8));
    StString aFileName = StString(theFileName);
    StString aFolder, aDummy;
    StFileNode::getFolderAndFile(aFileName, aFolder, aDummy);
    if(aFileName.isStartsWith(StProcess::getTempFolder())) {
        // Some browsers (Safari) returns file copies in temporary folder
        // and imidiatly remove it after function execution.
        // sView load image async, so we need to copy file until it will be read.
        StString aFileNameNew = aFileName + ".sView.tmp";
        if(StFileNode::moveFile(aFileName, aFileNameNew)) {
            aFileName = aFileNameNew;
            myTmpFiles.add(aFileName);
        }
    }

    StMutexAuto aLock(myMutex);
    if(isPreview) {
        myPreviewPath = aFileName;
    } else {
        myFullPath    = aFileName;
    }
}
示例#6
0
StSettings::StSettings(const StHandle<StResourceManager>& /*theResMgr*/,
                       const StString&                    theSettingsSet)
: mySettingsSet(theSettingsSet.toUtfWide()),
  myRegisterPath(StStringUtfWide("SOFTWARE\\sView\\") + theSettingsSet.toUtfWide()),
  myToFlush(false) {
    //
}
示例#7
0
NPError StBrowserPlugin::streamNew(NPMIMEType ,
                                   NPStream* theStream,
                                   NPBool ,
                                   uint16_t* theStreamType) {
    *theStreamType = NP_ASFILEONLY;
    // here we got MIME from server header (not object MIME-type!)
    // because jps/pns/mpo are actually jpeg/png files - we ignore returned MIME here
    //myOpenInfo.setMIME(StString(mimeString) + ST_TEXT(":*:*"));

    if(myToLoadFull) {
        // load full-size image only when switched to fullscreen
        return NPERR_NO_ERROR;
    }

    // notice that some browsers (Chromium) returns NOT the same string as requested by NPNFuncs.geturl()!
    // instead here we got URL with decoded Unicode characters
    const StString anUrl((theStream->url != NULL) ? theStream->url : "");
    if(myPreviewUrl.isEmpty()
            || anUrl.isEndsWith(myPreviewUrl)
            || anUrl.isEndsWith(myPreviewUrlUtf8)) {
        return NPERR_NO_ERROR;
    }
    myFullUrl = anUrl;

    // block wrong streams
    return NPERR_INVALID_URL;
}
示例#8
0
int main(int , char** ) { // force console output
#else
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { // prevent console output
#endif
    setlocale(LC_ALL, ".OCP"); // we set default locale for console output (useful only for debug)
#else
int main(int , char** ) {
#endif
    StOutPageFlip::initGlobalsAsync();
    if(!StVersionInfo::checkTimeBomb("sView")) {
        return 1;
    }

    // setup environment variables
    const StString ST_ENV_NAME_STCORE_PATH =
    #if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
        "StCore64";
    #else
        "StCore32";
    #endif
    const StString aProcessPath = StProcess::getProcessFolder();
    StString aProcessUpPath = StFileNode::getFolderUp(aProcessPath);
    if(!aProcessUpPath.isEmpty()) {
        aProcessUpPath += SYS_FS_SPLITTER;
    }
    StProcess::setEnv(ST_ENV_NAME_STCORE_PATH, aProcessPath);
    if(StFolder::isFolder(aProcessPath + "textures")) {
        StProcess::setEnv("StShare", aProcessPath);
    } else if(StFolder::isFolder(aProcessUpPath + "textures")) {
        StProcess::setEnv("StShare", aProcessUpPath);
    }

    StString aResDir = StProcess::getStShareFolder();
    StProcess::setEnv("CSF_UnitsLexicon",          aResDir + "UnitsAPI" ST_FILE_SPLITTER "Lexi_Expr.dat");
    StProcess::setEnv("CSF_UnitsDefinition",       aResDir + "UnitsAPI" ST_FILE_SPLITTER "Units.dat");
    StProcess::setEnv("CSF_ShadersDirectory",      aResDir + "shaders" ST_FILE_SPLITTER "StCADViewer");
    StProcess::setEnv("CSF_SHMessage",             aResDir + "lang");
    StProcess::setEnv("CSF_MDTVTexturesDirectory", aResDir + "textures");

    StHandle<StOpenInfo> anInfo;
    if(anInfo.isNull()
    || (!anInfo->hasPath() && !anInfo->hasArgs())) {
        anInfo = StApplication::parseProcessArguments();
    }
    if(anInfo.isNull()) {
        // show help
        StString aShowHelpString = getAbout();
        st::cout << aShowHelpString;
        stInfo(aShowHelpString);
        return 0;
    }

    StHandle<StResourceManager> aResMgr = new StResourceManager();
    StHandle<StCADViewer> anApp  = new StCADViewer(aResMgr, NULL, anInfo);
    if(!anApp->open()) {
        return 1;
    }
    return anApp->exec();
}
示例#9
0
int StActiveXCtrl::OnCreate(LPCREATESTRUCT theCreateStruct) {
    myBackBrush.CreateSolidBrush(RGB(0, 0, 0));
    if(COleControl::OnCreate(theCreateStruct) == -1) {
        return -1;
    }

    const StString ST_ASTERIX = '*';
    StMIME aMime(StString(myMimeType), ST_ASTERIX, ST_ASTERIX);
    myOpenInfo.setMIME(aMime);

    StArgumentsMap aDrawerArgs;
    const StString ST_SETTING_SRCFORMAT    = stCString("srcFormat");
    const StString ST_SETTING_COMPRESS     = stCString("toCompress");
    const StString ST_SETTING_ESCAPENOQUIT = stCString("escNoQuit");
    const StMIME ST_MIME_X_JPS("image/x-jps", ST_ASTERIX, ST_ASTERIX);
    const StMIME ST_MIME_JPS  ("image/jps",   ST_ASTERIX, ST_ASTERIX);
    const StMIME ST_MIME_X_PNS("image/x-pns", ST_ASTERIX, ST_ASTERIX);
    const StMIME ST_MIME_PNS  ("image/pns",   ST_ASTERIX, ST_ASTERIX);
    StArgument anArgSrcFormat = aDrawerArgs[ST_SETTING_SRCFORMAT];
    if(!anArgSrcFormat.isValid()) {
        anArgSrcFormat.setKey(ST_SETTING_SRCFORMAT);
        if(aMime == ST_MIME_X_JPS
        || aMime == ST_MIME_JPS
        || aMime == ST_MIME_X_PNS
        || aMime == ST_MIME_PNS) {
            anArgSrcFormat.setValue(st::formatToString(StFormat_SideBySide_RL));
            aDrawerArgs.add(anArgSrcFormat);
        }
    }
    aDrawerArgs.add(StArgument(ST_SETTING_COMPRESS,     "true")); // optimize memory usage
    aDrawerArgs.add(StArgument(ST_SETTING_ESCAPENOQUIT, "true")); // do not close plugin instance by Escape key
    myOpenInfo.setArgumentsMap(aDrawerArgs);

    // set window
    myParentWin = m_hWnd;

    // starts out plugin main loop in another thread
    myThread = new StThread(stThreadFunction, (void* )this, "StActiveXCtrl");

    // load URL
    StString aFilePath = loadURL(myHasPreview ? myUrlPreview : myUrlFull);
    if(aFilePath.isEmpty()) {
        if(!myHasPreview) {
            return 0;
        }
        if(myHasPreview) {
            // if we have 2 URLs - try to load another one
            aFilePath = loadURL(myUrlFull);
            if(aFilePath.isEmpty()) {
                return 0;
            }
            myHasPreview = false;
        }
    }

    myOpenInfo.setPath(aFilePath);
    myOpenEvent.set();
    return 0;
}
示例#10
0
int StApplication::getActionIdFromName(const StString& theActionName) const {
    StString aNameLower = theActionName;
    aNameLower.toLowerCase();
    const std::string aName(aNameLower.toCString());
    std::map< std::string, int >::const_iterator anAction = myActionLookup.find(aName);
    return anAction != myActionLookup.end()
         ? anAction->second
         : -1;
}
示例#11
0
StString StFileNode::getExtension(const StString& theFileName) {
    size_t aPntId = size_t(-1);
    for(StUtf8Iter anIter = theFileName.iterator(); *anIter != 0; ++anIter) {
        if(*anIter == stUtf32_t('.')) {
            aPntId = anIter.getIndex();
        }
    }
    return (aPntId != size_t(-1)) ? theFileName.subString(aPntId + 1, theFileName.getLength()) : StString();
}
示例#12
0
void StDictEntry::parseString(const StString& theString) {
    for(StUtf8Iter anIter = theString.iterator(); *anIter != 0; ++anIter) {
        if(*anIter == stUtf32_t('=')) {
            myKey   = theString.subString(0, anIter.getIndex());
            myValue = theString.subString(anIter.getIndex() + 1, theString.getLength()).unquoted();
            return;
        }
    }
    myKey = theString;
}
示例#13
0
void StApplication::addAction(const int                 theActionId,
                              const StHandle<StAction>& theAction) {
    myActions[theActionId] = theAction;
    if(!theAction.isNull()) {
        StString aNameLower = theAction->getName();
        aNameLower.toLowerCase();
        const std::string aName(aNameLower.toCString());
        myActionLookup[aName] = theActionId;
    }
}
示例#14
0
StBrowserPlugin::StBrowserPlugin(NSPluginCreateData* theCreateDataStruct)
    : nppInstance(theCreateDataStruct->instance),
      myResMgr(new StResourceManager()),
      myParentWin((StNativeWin_t )NULL),
#ifdef _WIN32
      myProcOrig(NULL),
      myBackBrush(CreateSolidBrush(RGB(0, 0, 0))),
#endif
      myToLoadFull(false),
      myIsActive(false),
      myToQuit(false) {
    if(ST_PLUGIN_INSTANCES.increment() == 1) {
        StSearchMonitors aMonitors;
        aMonitors.init(true); // force update of cached state
    }

    StArgumentsMap aDrawerArgs;
    for(int aParamId = 0; aParamId < theCreateDataStruct->argc; ++aParamId) {
        StString aParamName  = StString(theCreateDataStruct->argn[aParamId]);
        StString aParamValue = StString(theCreateDataStruct->argv[aParamId]);

        StArgument stArg(aParamName, aParamValue);
        aDrawerArgs.add(stArg);

        if(aParamName.isEqualsIgnoreCase(stCString("data-prv-url"))) {
            myPreviewUrl = aParamValue;
            myPreviewUrlUtf8.fromUrl(aParamValue);
        }
    }
    const StString ST_ASTERIX = '*';
    StMIME stMIME(StString(theCreateDataStruct->type), ST_ASTERIX, ST_ASTERIX);
    myOpenInfo.setMIME(stMIME);

    const StString ST_SETTING_SRCFORMAT    = stCString("srcFormat");
    const StString ST_SETTING_COMPRESS     = stCString("toCompress");
    const StString ST_SETTING_ESCAPENOQUIT = stCString("escNoQuit");
    const StMIME ST_MIME_X_JPS("image/x-jps", ST_ASTERIX, ST_ASTERIX);
    const StMIME ST_MIME_JPS  ("image/jps",   ST_ASTERIX, ST_ASTERIX);
    const StMIME ST_MIME_X_PNS("image/x-pns", ST_ASTERIX, ST_ASTERIX);
    const StMIME ST_MIME_PNS  ("image/pns",   ST_ASTERIX, ST_ASTERIX);
    StArgument anArgSrcFormat = aDrawerArgs[ST_SETTING_SRCFORMAT];
    if(!anArgSrcFormat.isValid()) {
        anArgSrcFormat.setKey(ST_SETTING_SRCFORMAT);
        if(stMIME == ST_MIME_X_JPS
                || stMIME == ST_MIME_JPS
                || stMIME == ST_MIME_X_PNS
                || stMIME == ST_MIME_PNS) {
            anArgSrcFormat.setValue(st::formatToString(StFormat_SideBySide_RL));
            aDrawerArgs.add(anArgSrcFormat);
        }
    }
    aDrawerArgs.add(StArgument(ST_SETTING_COMPRESS,     "true")); // optimize memory usage
    aDrawerArgs.add(StArgument(ST_SETTING_ESCAPENOQUIT, "true")); // do not close plugin instance by Escape key
    myOpenInfo.setArgumentsMap(aDrawerArgs);
}
示例#15
0
bool StSettings::saveString(const StString& theParam,
                            const StString& theValue) {
    StRegKey aKey;
    if(!aKey.create(myRegisterPath)) {
        return false; // No write registry success!
    }

    StStringUtfWide aValue = theValue.toUtfWide();
    return RegSetValueExW(aKey, theParam.toUtfWide().toCString(), 0,
                          REG_SZ, (LPBYTE )aValue.toCString(), DWORD(aValue.getSize() + sizeof(stUtfWide_t))) == ERROR_SUCCESS;
}
示例#16
0
StString StProcess::getAbsolutePath(const StString& thePath) {
    StString aPath;
    if(thePath.isStartsWith(ST_FILE_PROTOCOL)) {
        const StString aData = thePath.subString(ST_FILE_PROTOCOL.getLength(), thePath.getLength());
        aPath.fromUrl(aData);
    } else {
        aPath = thePath;
    }

    if(StFileNode::isAbsolutePath(aPath)) {
        return aPath;
    }
    return StProcess::getWorkingFolder() + aPath; // make absolute path
}
示例#17
0
StString StProcess::getProcessName() {
    StString aFullPath = getProcessFullPath();
    size_t aLastSplit = size_t(-1);
    for(StUtf8Iter anIter = aFullPath.iterator(); *anIter != 0; ++anIter) {
        if(*anIter == stUtf32_t(SYS_FS_SPLITTER)) {
            aLastSplit = anIter.getIndex();
        }
    }

    if(aLastSplit != size_t(-1)) {
        return aFullPath.subString(aLastSplit + 1, aFullPath.getLength());
    } else {
        return aFullPath;
    }
}
示例#18
0
StString StProcess::getProcessFolder() {
    StString aFullPath = getProcessFullPath();
    size_t aLastSplit = size_t(-1);
    for(StUtf8Iter anIter = aFullPath.iterator(); *anIter != 0; ++anIter) {
        if(*anIter == stUtf32_t(SYS_FS_SPLITTER)) {
            aLastSplit = anIter.getIndex();
        }
    }

    if(aLastSplit != size_t(-1)) {
        return aFullPath.subString(0, aLastSplit + 1); // including trailing separator!
    } else {
        return StString();
    }
}
示例#19
0
bool loadStringFromRegister(const StString& theRegisterPath, const StString& theParamPath, StString& theOutValue) {
    // TODO (Kirill Gavrilov) parse ERROR_MORE_DATA error (increase buffer)
    stUtfWide_t* aDataOut = new stUtfWide_t[4096U];
    HKEY hKey = NULL;
    DWORD aValueSize = sizeof(stUtfWide_t) * 4096U;
    RegOpenKeyExW(HKEY_CURRENT_USER, theRegisterPath.toUtfWide().toCString(), 0, KEY_READ, &hKey);
    if(RegQueryValueExW(hKey, theParamPath.toUtfWide().toCString(), NULL, NULL, (LPBYTE )aDataOut, &aValueSize) == ERROR_SUCCESS) {
        RegCloseKey(hKey);
        theOutValue = StString(aDataOut);
        delete[] aDataOut;
        return true;
    }
    RegCloseKey(hKey);
    delete[] aDataOut;
    return false;
}
示例#20
0
bool StSettings::loadString(const StString& theParam,
                            StString&       theValue) {
    const StStringUtfWide aParam = theParam.toUtfWide();
    StRegKey aKey;
    if(!aKey.open(myRegisterPath)) {
        return false;
    }

    // request size
    DWORD aValueSize = 0;
    if(RegQueryValueExW(aKey, aParam.toCString(), NULL, NULL, NULL, &aValueSize) != ERROR_SUCCESS) {
        return false;
    }

    if(aValueSize == 0) {
        theValue = "";
        return true;
    }

    DWORD aValueSizeRead = aValueSize;
    stUtfWide_t* aDataOut = new stUtfWide_t[aValueSize / sizeof(stUtfWide_t) + 1];
    if(RegQueryValueExW(aKey, aParam.toCString(), NULL, NULL, (LPBYTE )aDataOut, &aValueSizeRead) != ERROR_SUCCESS) {
        return false;
    }

    aDataOut[aValueSize / sizeof(stUtfWide_t)] = L'\0'; // NULL-terminate
    theValue = StString(aDataOut);
    return true;
}
示例#21
0
bool StPlayList::checkExtension(const StString& thePath) {
    if(StFolder::isFolder(thePath)) {
        // just folder
        return true;
    }
    StString anExtension = StFileNode::getExtension(thePath);
    for(size_t anExtId = 0; anExtId < myExtensions.size(); ++anExtId) {
        if(anExtension.isEqualsIgnoreCase(myExtensions[anExtId])) {
            return true;
        }
    }
    if(anExtension.isEqualsIgnoreCase(stCString("m3u"))) {
        return true;
    }
    return false;
}
示例#22
0
void StFileNode::getNameAndExtension(const StString& theFileName,
                                     StString& theName,
                                     StString& theExtension) {
    size_t aLastPnt = size_t(-1);
    for(StUtf8Iter anIter = theFileName.iterator(); *anIter != 0; ++anIter) {
        if(*anIter == stUtf32_t('.')) {
            aLastPnt = anIter.getIndex();
        }
    }
    if(aLastPnt != size_t(-1)) {
        theName      = theFileName.subString(0, aLastPnt);
        theExtension = theFileName.subString(aLastPnt + 1, theFileName.getLength());
    } else {
        theName      = theFileName;
        theExtension = StString();
    }
}
示例#23
0
void StFileNode::getFolderAndFile(const StString& theFilePath,
                                  StString& theFolder,
                                  StString& theFileName) {
    size_t aLastSplit = size_t(-1);
    for(StUtf8Iter anIter = theFilePath.iterator(); *anIter != 0; ++anIter) {
        if(*anIter == stUtf32_t(SYS_FS_SPLITTER)) {
            aLastSplit = anIter.getIndex();
        }
    }

    if(aLastSplit != size_t(-1)) {
        theFolder   = theFilePath.subString(0, aLastSplit);
        theFileName = theFilePath.subString(aLastSplit + 1, theFilePath.getLength());
    } else {
        theFolder   = StString();
        theFileName = theFilePath;
    }
}
示例#24
0
StString StFileNode::getCompatibleName(const StString& theFileName) {
#ifdef _WIN32
    stUtfWide_t aShortNameWide[MAX_PATH];
    GetShortPathNameW(theFileName.toUtfWide().toCString(), aShortNameWide, MAX_PATH);
    return *aShortNameWide != L'\0' ? StString(aShortNameWide) : theFileName;
#else
    return theFileName;
#endif
}
示例#25
0
LRESULT StActiveXCtrl::WindowProc(UINT theMsg, WPARAM theParamW, LPARAM theParamL) {
    // Special case for WM_INITMENUPOPUP event.
    // Standard implementation of COleControl::WindowProc does not find handlers for popup menu items created
    // by plugin and disables them
    if(theMsg == WM_INITMENUPOPUP) {
        return 0;
    } else if(theMsg == WM_ERASEBKGND) {
        return 1;
    } else if(theMsg == WM_PAINT) {
        if(!myIsActive) {
            PAINTSTRUCT aPaintStruct;
            CDC* aDevCtx = BeginPaint(&aPaintStruct);
            FillRect(aDevCtx->GetSafeHdc(), &aPaintStruct.rcPaint, myBackBrush);
            EndPaint(&aPaintStruct);
        }
        return 0;
    }

    // use fake WM_TIMER event to switch between fullscreen / windowed image in correct thread
    if(theMsg == WM_TIMER && myHasPreview) {
        if(theParamW == 1) {
            const StString aFilePath = loadURL(myUrlFull);
            if(!aFilePath.isEmpty()) {
                myOpenInfo.setPath(aFilePath);
                myOpenEvent.set();
            } else {
                // don't try to load broken URL anymore
                myHasPreview = false;
            }
        } else if(theParamW == 0) {
            const StString aFilePath = loadURL(myUrlPreview);
            if(!aFilePath.isEmpty()) {
                myOpenInfo.setPath(aFilePath);
                myOpenEvent.set();
            } else {
                // don't try to load broken URL anymore
                myHasPreview = false;
            }
        }
    }

    return COleControl::WindowProc(theMsg, theParamW, theParamL);
}
示例#26
0
StString StFileNode::getCompatibleName(const StString& theFileName) {
#ifdef _WIN32
    /// TODO (Kirill Gavrilov#1) if result is empty - not a filesystem element or no DOS-names enabled
    stUtfWide_t aShortNameWide[MAX_PATH];
    GetShortPathName(theFileName.toUtfWide().toCString(), aShortNameWide, MAX_PATH);
    return *aShortNameWide != L'\0' ? StString(aShortNameWide) : theFileName;
#else
    return theFileName;
#endif
}
示例#27
0
bool StGLProgram::link(StGLContext& theCtx) {
    if(!isValid()) {
        return false;
    }
    theCtx.core20fwd->glLinkProgram(myProgramId);

    // if linkage failed - automatically remove the program!
    if(!isLinked(theCtx)) {
        theCtx.pushError(StString("Linking of the program '") + myTitle + "' failed!\n" + getLinkageInfo(theCtx));
        release(theCtx);
        return false;
    }
#ifdef __ST_DEBUG_SHADERS__
    const StString anInfo = getLinkageInfo(theCtx);
    ST_DEBUG_LOG("Program '" + myTitle + "' has been linked"
              + (!anInfo.isEmpty() ? (StString(". Log:\n") + anInfo) : (StString())));
#endif
    return true;
}
示例#28
0
StString StFileNode::getFolderUp(const StString& thePath) {
    size_t aLastSplit = size_t(-1);
    size_t aPreSplit  = size_t(-1);
    for(StUtf8Iter anIter = thePath.iterator(); *anIter != 0; ++anIter) {
        if(*anIter == stUtf32_t(SYS_FS_SPLITTER)) {
            aPreSplit  = aLastSplit;
            aLastSplit = anIter.getIndex();
        }
    }

    if(aLastSplit != size_t(-1)
    && aLastSplit + 1 == thePath.getLength()) {
        aLastSplit = aPreSplit;
    }
    if(aLastSplit == size_t(-1)) {
        return StString();
    }

    return thePath.subString(0, aLastSplit);
}
示例#29
0
bool StSettings::saveInt32(const StString& theParam,
                           const int32_t&  theValue) {
    StRegKey aKey;
    if(!aKey.create(myRegisterPath)) {
        return false; // No write registry success!
    }

    DWORD aData = theValue;
    return RegSetValueExW(aKey, theParam.toUtfWide().toCString(), 0,
                          REG_DWORD, (LPBYTE )&aData, sizeof(DWORD)) == ERROR_SUCCESS;
}
示例#30
0
void StDictionary::parseString(const StString& theString) {
    size_t aStart = 0;
    bool isInQuotes1 = false;
    bool isInQuotes2 = false;
    for(StUtf8Iter anIter = theString.iterator();; ++anIter) {
        if(*anIter == stUtf32_t('\'') && !isInQuotes2) {
            isInQuotes1 = !isInQuotes1;
        } else if(*anIter == stUtf32_t('\"') && !isInQuotes1) {
            isInQuotes2 = !isInQuotes2;
        } else if((*anIter == stUtf32_t('\n')
                || *anIter == stUtf32_t('\0')) && !isInQuotes1 && !isInQuotes2) {
            StDictEntry aNewArgument;
            aNewArgument.parseString(theString.subString(aStart, anIter.getIndex()));
            add(aNewArgument);
            aStart = anIter.getIndex() + 1;
        }
        if(*anIter == 0) {
            return;
        }
    }
}