LCOV - code coverage report
Current view: top level - src/utils/foxtools - MFXLinkLabel.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 0.0 % 46 0
Test Date: 2025-12-06 15:35:27 Functions: 0.0 % 8 0

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2006-2025 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    MFXLinkLabel.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Michael Behrisch
      17              : /// @author  Jakob Erdmann
      18              : /// @date    2006-03-08
      19              : ///
      20              : //
      21              : /****************************************************************************/
      22              : 
      23              : /* =========================================================================
      24              :  * included modules
      25              :  * ======================================================================= */
      26              : #include <config.h>
      27              : 
      28              : #ifdef WIN32
      29              : #define NOMINMAX
      30              : #include <windows.h>
      31              : #undef NOMINMAX
      32              : #endif
      33              : 
      34              : #include <utils/gui/div/GUIDesigns.h>
      35              : 
      36              : #include "MFXLinkLabel.h"
      37              : 
      38              : 
      39              : FXint
      40            0 : MFXLinkLabel::fxexecute(FXString link) {
      41              : #ifdef WIN32
      42              :     return (int)(intptr_t)ShellExecute(nullptr, "open", link.text(), nullptr, nullptr, SW_SHOWNORMAL) > 32 ? 1 : 0;
      43              : #else
      44            0 :     FXString ext = FXPath::extension(link);
      45            0 :     FXString list;
      46            0 :     if (comparecase(link.section(':', 0), "http") == 0 ||
      47            0 :             comparecase(link.section(':', 0), "https") == 0 ||
      48            0 :             comparecase(link.section(':', 0), "ftp") == 0 ||
      49            0 :             comparecase(ext, "htm") == 0 || comparecase(ext, "html") == 0 ||
      50            0 :             comparecase(ext, "php") == 0 || comparecase(ext, "asp") == 0) {
      51            0 :         list = "firefox\tchromium\tkonqueror\tdillo\tlynx\topen";
      52            0 :     } else if (comparecase(ext, "pdf") == 0) {
      53            0 :         list = "acroread\tkghostview\tgpdf\txpdf";
      54              :     }
      55              : 
      56            0 :     if (list.length()) {
      57            0 :         FXString software;
      58              :         FXint index = 0;
      59            0 :         FXString path = FXSystem::getExecPath();
      60              : 
      61            0 :         software = list.section("\t", index);
      62            0 :         while (!software.empty()) {
      63            0 :             software = FXPath::search(path, software);
      64            0 :             if (software.length())
      65            0 :                 return system(FXString().format("%s \"%s\" >/dev/null 2>&1 & ",
      66            0 :                                                 software.text(), link.text()).text()) > 0 ? 0 : 1;
      67            0 :             index++;
      68            0 :             software = list.section("\t", index);
      69              :         }
      70            0 :     } else if (FXStat::isExecutable(link)) {
      71            0 :         return system((link + " >/dev/null 2>&1 & ").text()) > 0 ? 0 : 1;
      72              :     }
      73              :     return 0;
      74              : #endif
      75            0 : }
      76              : 
      77              : 
      78              : 
      79              : FXDEFMAP(MFXLinkLabel) MFXLinkLabelMap[] = {
      80              :     FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, MFXLinkLabel::onLeftBtnPress),
      81              :     FXMAPFUNC(SEL_TIMEOUT, MFXLinkLabel::ID_TIMER, MFXLinkLabel::onTimer),
      82              : };
      83            0 : FXIMPLEMENT(MFXLinkLabel, FXLabel, MFXLinkLabelMap, ARRAYNUMBER(MFXLinkLabelMap))
      84              : 
      85              : 
      86            0 : MFXLinkLabel::MFXLinkLabel(FXComposite* p, const FXString& text, FXIcon* ic, FXuint opts, FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb) : FXLabel(p, text, ic, opts, x, y, w, h, pl, pr, pt, pb) {
      87            0 :     setDefaultCursor(getApp()->getDefaultCursor(DEF_HAND_CURSOR));
      88            0 :     setTextColor(GUIDesignTextColorBlue);
      89            0 : }
      90              : 
      91            0 : MFXLinkLabel::~MFXLinkLabel() {
      92            0 :     getApp()->removeTimeout(this, ID_TIMER);
      93            0 : }
      94              : 
      95            0 : long MFXLinkLabel::onLeftBtnPress(FXObject*, FXSelector, void*) {
      96            0 :     FXString link = getTipText();
      97            0 :     if (link.length()) {
      98            0 :         getApp()->beginWaitCursor();
      99            0 :         if (fxexecute(link)) {
     100            0 :             getApp()->addTimeout(this, ID_TIMER, 2000);  // 2 seconds of way cursor
     101              :         } else {
     102            0 :             getApp()->endWaitCursor();
     103            0 :             getApp()->beep();
     104              :         }
     105              :     }
     106            0 :     return 1;
     107            0 : }
     108              : 
     109            0 : long MFXLinkLabel::onTimer(FXObject*, FXSelector, void*) {
     110            0 :     getApp()->endWaitCursor();
     111            0 :     return 1;
     112              : }
        

Generated by: LCOV version 2.0-1