Ticket #3930: mythtv-mouse.diff

File mythtv-mouse.diff, 29.6 KB (added by Anthony D'Alberto <afd1009@…>, 5 years ago)

Patch for Mythtv - adds mouse support to controls

  • mythtv/libs/libmythui/myththemedmenu.cpp

     
    103103    void parseButtonDefinition(const QString &dir, QDomElement &element); 
    104104    void parseButton(const QString &dir, QDomElement &element); 
    105105 
     106//added by Anthony D'Alberto to support back button 
     107    void parseBackButton(const QString &dir, QDomElement &element); 
     108//end of added section 
     109 
    106110    void parseText(TextAttributes &attributes, QDomElement &element); 
    107111    void parseOutline(TextAttributes &attributes, QDomElement &element); 
    108112    void parseShadow(TextAttributes &attributes, QDomElement &element); 
     
    146150    MythImage *downarrow; 
    147151    QRect downarrowRect; 
    148152 
     153//added by Anthony D'Alberto to support back button 
     154    MythImage *backbutton; 
     155    QRect backbuttonRect; 
     156//end of added section 
     157 
    149158    QPoint watermarkPos; 
    150159    QRect watermarkRect; 
    151160 
     
    233242    MythUIStateType *watermark; 
    234243    MythUIImage *uparrow; 
    235244    MythUIImage *downarrow; 
     245 
     246//added by Anthony D'Alberto to support back button 
     247    MythUIImage *backbutton; 
     248//end of added section 
     249 
    236250}; 
    237251 
    238252///////////////////////////////////////////////////////////////////////////// 
     
    249263    downarrow = NULL; 
    250264    buttonBackground = NULL; 
    251265 
     266//added by Anthony D'Alberto to support back button 
     267    backbutton = NULL; 
     268//end of added section 
     269 
    252270    loaded = false; 
    253271 
    254272    callback = NULL; 
     
    275293        downarrow->DownRef(); 
    276294    if (buttonBackground) 
    277295        buttonBackground->DownRef(); 
     296//added by Anthony D'Alberto to support back button 
     297    if (backbutton) 
     298        backbutton->DownRef(); 
     299//end of added section 
    278300 
    279301    logo = NULL; 
    280302    buttonnormal = NULL; 
     
    282304    uparrow = NULL; 
    283305    downarrow = NULL; 
    284306    buttonBackground = NULL; 
     307//added by Anthony D'Alberto to support back button 
     308    backbutton = NULL; 
     309//end of added section 
    285310 
    286311    QMap<QString, ButtonIcon>::Iterator it; 
    287312    for (it = allButtonIcons.begin(); it != allButtonIcons.end(); ++it) 
     
    958983    } 
    959984    else 
    960985    { 
    961         downarrow = MythImage::FromQImage(&pix); 
    962         downarrowRect = arrowrect; 
     986        downarrow = MythImage::FromQImage(&pix); 
     987        downarrowRect = arrowrect; 
    963988    } 
    964989} 
    965990 
     991//added by Anthony D'Alberto to support back button 
     992void MythThemedMenuState::parseBackButton(const QString &dir, QDomElement &element) 
     993{ 
     994    QRect backrect; 
     995    QPoint backpos; 
     996    QImage *pix = NULL; 
     997 
     998    bool hasimage = false; 
     999    bool hasposition = false; 
     1000 
     1001    for (QDomNode child = element.firstChild(); !child.isNull(); 
     1002         child = child.nextSibling()) 
     1003    { 
     1004        QDomElement info = child.toElement(); 
     1005        if (!info.isNull()) 
     1006        { 
     1007            if (info.tagName() == "image") 
     1008            { 
     1009                QString backpath = dir + getFirstText(info); 
     1010                pix = gContext->LoadScaleImage(backpath); 
     1011                if (pix) 
     1012                    hasimage = true; 
     1013            } 
     1014            else if (info.tagName() == "position") 
     1015            { 
     1016                backpos = parsePoint(info); 
     1017                hasposition = true; 
     1018            } 
     1019            else 
     1020            { 
     1021                VERBOSE(VB_GENERAL, QString("MythThemedMenuPrivate: Unknown tag %1 " 
     1022                                            "in back button").arg(info.tagName())); 
     1023                return; 
     1024            } 
     1025        } 
     1026    } 
     1027 
     1028    if (!hasimage) 
     1029    { 
     1030        VERBOSE(VB_IMPORTANT, "MythThemedMenuPrivate: Missing image tag in back button"); 
     1031        return; 
     1032    } 
     1033 
     1034    if (!hasposition) 
     1035    { 
     1036        VERBOSE(VB_IMPORTANT, "MythThemedMenuPrivate: Missing position tag in back button"); 
     1037        return; 
     1038    } 
     1039 
     1040    backrect = QRect(backpos.x(), backpos.y(), pix->width(), 
     1041                      pix->height()); 
     1042 
     1043    backbutton = MythImage::FromQImage(&pix); 
     1044    backbuttonRect = backrect; 
     1045} 
     1046//end of added section 
     1047 
     1048 
     1049 
     1050 
     1051 
     1052 
     1053 
     1054 
     1055 
     1056 
    9661057void MythThemedMenuState::parseButton(const QString &dir, QDomElement &element) 
    9671058{ 
    9681059    bool hasname = false; 
     
    11081199    titleText = ""; 
    11091200    uparrow = NULL; 
    11101201    downarrow = NULL; 
     1202//added by Anthony D'Albeto to support back button 
     1203    backbutton = NULL; 
     1204//end of added section 
     1205 
    11111206    watermarkPos = QPoint(0, 0); 
    11121207    watermarkRect = QRect(0, 0, 0, 0); 
    11131208} 
     
    11831278            { 
    11841279                parseArrow(dir, e, false); 
    11851280            } 
     1281//added by Anthony D'Alberto to support back button 
     1282            else if (e.tagName() == "backbutton") 
     1283            { 
     1284                parseBackButton(dir, e); 
     1285            } 
     1286//end of added section 
    11861287            else if (e.tagName() == "font") 
    11871288            { 
    11881289                if (parseFonts) 
     
    15131614    downarrow->SetVisible(false); 
    15141615    downarrow->SetCanTakeFocus(true); 
    15151616 
     1617//added by Anthony D'Alberto to support back button 
     1618    backbutton = new MythUIImage(parent, "menu back button"); 
     1619    if (m_state->backbutton) 
     1620    { 
     1621        backbutton->SetArea(m_state->backbuttonRect); 
     1622        backbutton->SetImage(m_state->backbutton); 
     1623    } 
     1624    backbutton->SetVisible(true); 
     1625    backbutton->SetCanTakeFocus(true); 
     1626//end of added section 
     1627 
    15161628    checkScrollArrows(); 
    15171629} 
    15181630 
     
    20352147            QStringList action = "PAGEDOWN"; 
    20362148            keyHandler(action, false); 
    20372149        } 
     2150//added by Anthony D'Alberto to support back button 
     2151        else if (origtype == backbutton) 
     2152        { 
     2153            QStringList action = "ESCAPE"; 
     2154            keyHandler(action, true); 
     2155            return(true); 
     2156        } 
     2157//end of added section 
    20382158        else 
    20392159        { 
    20402160            if (ThemedButton *button = reinterpret_cast<ThemedButton*>(origtype)) 
  • mythtv/libs/libmyth/uilistbtntype.h

     
    2727class UIListBtnType; 
    2828class UIListBtnTypeItem; 
    2929 
     30//added by Anthony D'Alberto to support the mouse press 
     31enum MouseMove{ListMoveLeft=1, ListMoveRight=2, ClickCheck=4, ListMoveUp=8, ListMoveDown=16, ListPageUp=32, ListPageDown=64}; 
     32//end of added section 
     33 
    3034class MPUBLIC UIListGenericTree : public GenericTree 
    3135{ 
    3236  public: 
     
    123127  public slots: 
    124128    bool takeFocus(); 
    125129    void looseFocus(); 
    126        
     130      
     131//Added by Anthony D'Alberto to support mouse press 
     132    int mousePressHandler(QMouseEvent *e); 
     133//end of added section 
     134  
    127135  private: 
    128136    void FillLevelFromTree(UIListGenericTree *item, UIListBtnType *list); 
    129137    void ClearLevel(UIListBtnType *list); 
     
    220228    bool takeFocus(); 
    221229    void looseFocus(); 
    222230 
     231//added by Anthony D'Alberto to support mouse press 
     232    int mousePressHandler(QMouseEvent *e); 
     233//end if added section 
     234 
    223235  private: 
    224236    void  Init(); 
    225237    void  LoadPixmap(QPixmap& pix, const QString& fileName); 
     
    337349    bool moveUpDown(bool flag); 
    338350     
    339351    void paint(QPainter *p, fontProp *font, int x, int y, bool active_on); 
    340      
     352 
     353//added by Anthony D'Alberto to support mouse presses 
     354    int MouseClicked(int x, int y); 
     355//end of added section 
     356  
    341357  protected: 
    342358    void  CalcDimensions(void); 
    343359 
  • mythtv/libs/libmyth/mythdialogs.cpp

     
    528528    popup.addLabel(message, Medium, true); 
    529529     
    530530    MythRemoteLineEdit* textEdit = new MythRemoteLineEdit(&popup, "chooseEdit"); 
     531 
    531532    textEdit->setText(text); 
    532533    popup.addWidget(textEdit); 
    533534     
     
    13231324    widget_with_current_focus->takeFocus(); 
    13241325} 
    13251326 
     1327//added by Anthony D'Alberto to support back button...and mouse presses 
     1328void MythThemedDialog::mouseReleaseEvent(QMouseEvent *e) 
     1329{ 
     1330        if(e->button() == QMouseEvent::RightButton) 
     1331        { 
     1332                e->accept(); 
     1333                reject(); 
     1334                return; 
     1335        } 
     1336        else if(e->button() == QMouseEvent::LeftButton) 
     1337        { 
     1338                int x=e->x(); 
     1339                int y=e->y(); 
     1340                //qDebug("MythThemedDialog::mouseReleaseEvent %d %d", x, y); 
     1341 
     1342                UIType *type = widget_with_current_focus; 
     1343 
     1344                if(type) 
     1345                { 
     1346                        QRect rc = type->getScreenArea(); 
     1347                        if(rc.contains(x,y)) 
     1348                        { 
     1349                        //      qDebug("target %p %s %d %d \n", 
     1350                       //                      type, 
     1351                        //              type->getName().local8Bit().data(), 
     1352                        //              rc.x(), 
     1353                        //              rc.y()); 
     1354                                type->activate(); 
     1355                                e->accept(); 
     1356                                return; 
     1357                        } 
     1358                }else 
     1359                { 
     1360                        //qDebug("Widget not defined"); 
     1361                } 
     1362        } 
     1363        MythDialog::mouseReleaseEvent(e); 
     1364} 
     1365 
     1366 
     1367void MythThemedDialog::mousePressEvent(QMouseEvent *e) 
     1368{ 
     1369        if(e->button() != QMouseEvent::LeftButton) 
     1370        { 
     1371//              MythDialog::mouseReleaseEvent(e); 
     1372                return; 
     1373        } 
     1374        int x=e->x(); 
     1375        int y=e->y(); 
     1376        //printf("MythThemedDialog::mousePressEvent %d %d", x, y); 
     1377        QPtrListIterator<LayerSet> an_it(my_containers); 
     1378        LayerSet        *looper; 
     1379 
     1380        while((looper= an_it.current()) != 0) 
     1381        { 
     1382                QRect container_area = looper->GetAreaRect(); 
     1383                if(container_area.isValid() && 
     1384                        container_area.contains(x,y) && 
     1385                        looper->GetName().lower() != "background") 
     1386                { 
     1387                        //loop over UI types within each container 
     1388                        vector<UIType *> *all_ui_type_objects = looper->getAllTypes(); 
     1389                        vector<UIType *>::iterator i=all_ui_type_objects->begin(); 
     1390                        for(; i!=all_ui_type_objects->end();i++) 
     1391                        { 
     1392                                UIType *type = (*i); 
     1393                                QRect rc = type->getScreenArea(); 
     1394                               //if the UI element is under the mouse 
     1395                                if(rc.contains(x,y)) 
     1396                                { 
     1397                                        printf("target %p %s %d %d\n", 
     1398                                        type, 
     1399                                        type->getName().local8Bit().data(), 
     1400                                        rc.x(), 
     1401                                        rc.y()); 
     1402 
     1403                                        if(type->canTakeFocus()) 
     1404                                        { 
     1405                                                if(widget_with_current_focus) 
     1406                                                { 
     1407                                                        widget_with_current_focus->looseFocus(); 
     1408                                                } 
     1409                                                widget_with_current_focus=type; 
     1410                                                widget_with_current_focus->takeFocus(); 
     1411                                        } 
     1412                                        else 
     1413                                        { 
     1414                                                //qDebug("Cannot Take Focus"); 
     1415                                                //type->mousePressHandler(e); 
     1416                                                //the child class should take care of this 
     1417                                        } 
     1418 
     1419                                        e->accept(); 
     1420                                        return; 
     1421                                } 
     1422                        } 
     1423                } 
     1424                ++an_it; 
     1425        } 
     1426        MythDialog::mousePressEvent(e); 
     1427} 
     1428 
     1429//end of added section 
     1430 
    13261431UIManagedTreeListType* MythThemedDialog::getUIManagedTreeListType(const QString &name) 
    13271432{ 
    13281433    QPtrListIterator<LayerSet> an_it(my_containers); 
     
    17531858    QStringList actions; 
    17541859    if (gContext->GetMainWindow()->TranslateKeyPress("qt", e, actions)) 
    17551860    { 
    1756         for (unsigned int i = 0; i < actions.size() && !handled; i++) 
     1861        for (unsigned int i = 0; i < actions.size() && !handled; i++)                                    
    17571862        { 
    17581863            QString action = actions[i]; 
    17591864            if (action == "ESCAPE") 
  • mythtv/libs/libmyth/mythwidgets.cpp

     
    736736{ 
    737737    bool handled = false; 
    738738    QStringList actions; 
    739  
     739    
    740740    if ((!popup || !popup->isShown()) && 
    741741          gContext->GetMainWindow()->TranslateKeyPress("qt", e, actions, false)) 
    742742    { 
     
    769769            { 
    770770                if (gContext->GetNumSetting("UseVirtualKeyboard", 1) == 1) 
    771771                { 
     772                  printf("UseVirtualKeyboard\n"); 
    772773                    popup = new VirtualKeyboard(gContext->GetMainWindow(), this); 
    773774                    gContext->GetMainWindow()->detach(popup); 
    774775                    popup->exec(); 
  • mythtv/libs/libmyth/uilistbtntype.cpp

     
    853853    UIType::looseFocus(); 
    854854} 
    855855 
     856//added by Anthony D'Alberto to support mouse press 
     857int UIListTreeType::mousePressHandler(QMouseEvent *e) 
     858{ 
     859    int iReturnValue = -1; 
     860    QRect       rect; 
     861    QRect       arearect; 
     862 
     863        if(currentlevel != NULL) 
     864        { 
     865                //get screen area where widget resides 
     866                arearect = currentlevel->GetArea(); 
     867                int iDrawOffset = currentlevel->GetDrawOffset(); 
     868                 
     869                //now create a new rectangle, adjusting for the offset 
     870                rect.setRect(arearect.x() + iDrawOffset + screen_area.x(), 
     871                                arearect.y() + screen_area.y(), 
     872                                arearect.width(), 
     873                                arearect.height() ); 
     874 
     875                if(rect.contains(e->x(), e->y())) 
     876                { 
     877                        //define a new point with the screen offset taken out 
     878                        //to get relative position in widget 
     879                        QPoint pt(e->x() - rect.x(), e->y() - rect.y()); 
     880 
     881                        //now define a new event with our new point 
     882                        QMouseEvent NewEvent(QEvent::MouseButtonPress, 
     883                                                pt, 
     884                                                e->button(), 
     885                                                e->state()); 
     886                        iReturnValue = currentlevel->mousePressHandler(&NewEvent); 
     887                        SetCurrentPosition(); 
     888                        RedrawCurrent(); 
     889 
     890                        if((iReturnValue & ListMoveRight) == ListMoveRight) 
     891                        { 
     892                                MoveRight(true); 
     893                        } 
     894 
     895                        if((iReturnValue & ListPageDown) == ListPageDown) 
     896                        { 
     897                                MoveDown(MovePage); 
     898                        } 
     899 
     900                        if((iReturnValue & ListPageUp) == ListPageUp) 
     901                        { 
     902                                MoveUp(MovePage); 
     903                        } 
     904                } 
     905                else 
     906                { 
     907                        //if the Y position is good, and we are just not 
     908                        //in on the X, we are probably going back a menu 
     909                        if(e->y() >= rect.y() && e->y() <= rect.y() + rect.height()) 
     910                        { 
     911                                MoveLeft(true); 
     912                        }else 
     913                        { 
     914                                //indicate we did not handle this case 
     915                                iReturnValue = -1; 
     916                        } 
     917                } 
     918        } 
     919        else 
     920        { 
     921                iReturnValue = -2; 
     922        } 
     923 
     924     return(iReturnValue); 
     925} 
     926//end of added section 
     927 
    856928////////////////////////////////////////////////////////////////////////////// 
    857929 
    858930UIListBtnType::UIListBtnType(const QString& name, const QRect& area, 
     
    19201992    UIType::looseFocus(); 
    19211993} 
    19221994 
     1995//added by Anthony D'Alberto to support mouse press 
     1996int UIListBtnType::mousePressHandler(QMouseEvent *e) 
     1997{ 
     1998        int mousepos; 
     1999        int iReturnValue = 0; 
     2000        if(m_arrowsRect.contains(e->x(), e->y())) 
     2001        { 
     2002                iReturnValue = 0; 
     2003                if( ((e->x() - m_arrowsRect.x()) <= m_upArrowRegPix.width()) && 
     2004                    m_showUpArrow == true) 
     2005                { 
     2006                        iReturnValue = ListPageUp; 
     2007                } 
     2008                else if( (e->x()-m_arrowsRect.x() >= m_upArrowRegPix.width() + 
     2009                                                        m_itemMargin) && 
     2010                        m_showDnArrow == true) 
     2011                { 
     2012                        iReturnValue = ListPageDown; 
     2013                } 
     2014        } 
     2015        else 
     2016        { 
     2017                //the x and y positions were already adjusted by previous 
     2018                //ListType 
     2019                //now attempt to calculate which item the mouse is over 
     2020                 
     2021                mousepos = (e->y() / (m_itemHeight + m_itemSpacing)) + 
     2022                                m_topPosition; 
     2023 
     2024                if(mousepos < m_itemCount) 
     2025                { 
     2026                        if(mousepos > m_selPosition) 
     2027                        { 
     2028                                for(int i=0;i<mousepos - m_selPosition;i++) 
     2029                                        ++(*m_selIterator); 
     2030                        } 
     2031                        else if(mousepos < m_selPosition) 
     2032                        { 
     2033                                for(int i=0;i<m_selPosition - mousepos;i++) 
     2034                                        --(*m_selIterator); 
     2035                        } 
     2036                         
     2037                        if(m_selIterator->current()) 
     2038                        { 
     2039                                m_selItem = m_selIterator->current(); 
     2040                        } 
     2041                        m_selPosition = mousepos; 
     2042                } 
     2043         
     2044                mousepos -= m_topPosition; 
     2045 
     2046                iReturnValue = m_selItem->MouseClicked(e->x(), 
     2047                        e->y() - (mousepos * (m_itemHeight+m_itemSpacing))); 
     2048 
     2049                emit itemSelected(m_selItem); 
     2050        } 
     2051 
     2052        return(iReturnValue); 
     2053} 
     2054//end of added section 
     2055 
    19232056////////////////////////////////////////////////////////////////////////////// 
    19242057 
    19252058UIListBtnTypeItem::UIListBtnTypeItem(UIListBtnType* lbtype, const QString& text, 
     
    21552288    p->drawText(tr, Qt::AlignLeft|Qt::AlignVCenter, text);     
    21562289} 
    21572290 
     2291//added by Anthony D'Alberto to support mouse press 
     2292int UIListBtnTypeItem::MouseClicked(int x, int y) 
     2293{ 
     2294        int iReturnValue = 0; 
     2295        QRect NewArrowRect(m_arrowRect.x() - 50, 
     2296                        m_arrowRect.y() - 50, 
     2297                        m_arrowRect.width() + 100, 
     2298                        m_arrowRect.height() + 100); 
     2299 
     2300        QRect NewCheckRect(m_checkRect.x() - 50, 
     2301                        m_checkRect.y() - 50, 
     2302                        m_checkRect.width() + 100, 
     2303                        m_checkRect.height() + 100); 
     2304 
     2305        if(NewArrowRect.contains(x,y)) 
     2306                iReturnValue |= ListMoveRight; 
     2307 
     2308        if(NewCheckRect.contains(x,y)) 
     2309                iReturnValue |= ClickCheck; 
     2310 
     2311        return(iReturnValue); 
     2312} 
     2313 
     2314//end of added section 
     2315 
     2316 
  • mythtv/libs/libmyth/uitypes.cpp

     
    33583358    rightArrowOffset.setX(0); 
    33593359    rightArrowOffset.setY(0); 
    33603360    incSearch = ""; 
     3361 
     3362//added by Anhtony D'Alberto to support mouse presses 
     3363    iMapUsed = -1; 
     3364    x_map_location = 0; 
     3365    y_map_location = 0; 
     3366    boHasChildren = false; 
     3367    boHasParent = false; 
     3368//end of added section 
     3369 
    33613370} 
    33623371 
    33633372UIManagedTreeListType::~UIManagedTreeListType() 
     
    34343443        return; 
    34353444    } 
    34363445 
     3446//added by Anthony D'Alberto to support mouse press 
     3447//initialize this each time the screen is drawn 
     3448        boHasChildren = false; 
     3449        boHasParent = false; 
     3450//end of added section 
    34373451    // 
    34383452    //  Put something on the LCD device (if one exists) 
    34393453    // 
     
    35573571            int x_location = bin_corners[i].left(); 
    35583572            int y_location = bin_corners[i].top() + (bin_corners[i].height() / 2) 
    35593573                             + (QFontMetrics(tmpfont->face).height() / 2); 
    3560  
    35613574            if (!show_whole_tree) 
    35623575            { 
    35633576                x_location = area.left(); 
     
    36583671                    p->drawPixmap(x_location + selectPoint.x(), y_location - QFontMetrics(tmpfont->face).height() + QFontMetrics(tmpfont->face).descent() + selectPoint.y(), (*highlight_map[i])); 
    36593672                    //p->drawPixmap(x_location, y_location - QFontMetrics(tmpfont->face).height() + QFontMetrics(tmpfont->face).descent(), (*highlight_map[i])); 
    36603673 
     3674//added by Anthony D'Alberto to support mouse presses 
     3675                    x_map_location = x_location + selectPoint.x() + screen_area.left(); 
     3676 
     3677                    y_map_location = y_location - QFontMetrics(tmpfont->face).height() + 
     3678                                        QFontMetrics(tmpfont->face).descent() + selectPoint.y() + 
     3679                                        screen_area.top(); 
     3680 
     3681                    iMapUsed = i; 
     3682 
     3683//end of added section 
     3684 
    36613685                    // 
    36623686                    //  Left or right arrows 
    36633687                    // 
    36643688                    if (i == bins && hotspot_node->childCount() > 0) 
    36653689                    { 
     3690//added by Anthony D'Alberto to support mouse press 
     3691//see if there is a child node 
     3692                        boHasChildren = true; 
     3693//end of added section 
     3694 
    36663695                        p->drawPixmap(x_location + (*highlight_map[i]).width() - right_arrow_image.width() + rightArrowOffset.x(), 
    36673696                                      y_location + rightArrowOffset.y() - QFontMetrics(tmpfont->face).height() + right_arrow_image.height() / 2, 
    36683697                                      right_arrow_image); 
    36693698                    } 
    36703699                    if (i == 1 && hotspot_node->getParent()->getParent()) 
    36713700                    { 
     3701//added by Anthony D'Alberto to support mouse press 
     3702//see if there is a parent node 
     3703                        boHasParent = true; 
     3704//end of added section 
    36723705                        p->drawPixmap(x_location + leftArrowOffset.x(), 
    36733706                                      y_location + leftArrowOffset.y() - QFontMetrics(tmpfont->face).height() + left_arrow_image.height() / 2, 
    36743707                                      left_arrow_image); 
     
    36773710                else 
    36783711                { 
    36793712                    p->drawPixmap(x_location + selectPoint.x(), y_location - QFontMetrics(tmpfont->face).height() + QFontMetrics(tmpfont->face).descent() + selectPoint.y(), (*highlight_map[0])); 
     3713 
     3714//added by Anthony D'Alberto to support mouse presses 
     3715                    x_map_location = x_location + selectPoint.x() + screen_area.left(); 
     3716                    y_map_location = y_location - QFontMetrics(tmpfont->face).height() + 
     3717                                        QFontMetrics(tmpfont->face).descent() + selectPoint.y() + 
     3718                                        screen_area.top(); 
     3719                
     3720                    iMapUsed = 0; 
     3721//end of added section 
     3722 
    36803723                } 
    36813724            } 
    36823725 
     
    47544797        QRect r = (*it); 
    47554798        r.moveBy(m_parent->GetAreaRect().left(), 
    47564799                 m_parent->GetAreaRect().top()); 
     4800         
    47574801        ++i; 
    47584802        screen_corners[i] = r; 
    47594803    } 
     
    47614805    screen_area = m_parent->GetAreaRect(); 
    47624806} 
    47634807 
     4808//added by Anthony D'Alberto to support mouse presses 
     4809 
     4810int UIManagedTreeListType::mousePressHandler(QMouseEvent *e) 
     4811{ 
     4812        int iReturnValue = -1; 
     4813 
     4814        //printf("X: %i - Y: %i\n", e->x(), e->y()); 
     4815 
     4816        //see if we are inside the control// 
     4817        if(screen_area.contains(e->x(), e->y())) 
     4818        { 
     4819                
     4820                 
     4821                QRect   BinRect(bin_corners[active_bin].left(), 
     4822                                bin_corners[active_bin].top() +  
     4823                                       screen_corners[active_bin].top(), 
     4824                                 bin_corners[active_bin].right(), 
     4825                                 bin_corners[active_bin].bottom() - 
     4826                                        screen_corners[active_bin].top()); 
     4827 
     4828 
     4829                //if I'm inside the active bin 
     4830                if(BinRect.contains(e->x(), e->y())) 
     4831                { 
     4832                        //if I'm in the active bin, I might want out 
     4833                        //this is identified by going over the next bin's 
     4834                        //left edge.  Bins can overlap.  Therefore... 
     4835 
     4836                        //check to see if there is another higher bin 
     4837                        if( ((active_bin +1) <= bins) &&  
     4838                                (e->x() >= bin_corners[active_bin+1].left()) ) 
     4839                        { 
     4840                                pushDown(); 
     4841                        } 
     4842 
     4843                        //get the height of the selection rectangle 
     4844                        //to try to figure out how many items to move 
     4845                        int iItemHeight = highlight_map[iMapUsed]->height(); 
     4846 
     4847                        int iItems; 
     4848                         
     4849                        //create a temp rectangle the size of the selection map 
     4850                        QRect   tmpRect(x_map_location, 
     4851                                        y_map_location, 
     4852                                        highlight_map[iMapUsed]->width(), 
     4853                                        highlight_map[iMapUsed]->height()); 
     4854 
     4855                        //if I'm not in the rectangle 
     4856                        if(!tmpRect.contains(e->x(), e->y())) 
     4857                        { 
     4858                                //if I'm above the rectangle 
     4859                                if(e->y() < tmpRect.top()) 
     4860                                { 
     4861                                        iItems = (tmpRect.top() - e->y()) / (iItemHeight) + 1; 
     4862 
     4863                                        //now move the number of items 
     4864                                        for(int i=0;i<iItems;i++) 
     4865                                        { 
     4866                                                moveUp(false); 
     4867                                        } 
     4868                                } 
     4869 
     4870                                //now check for being below the rectangle 
     4871                                if(e->y() > tmpRect.bottom()) 
     4872                                { 
     4873                                        iItems = (e->y() - tmpRect.bottom()) / (iItemHeight) + 1; 
     4874                                         
     4875                                        //now move the number of items 
     4876                                        for(int i=0;i<iItems;i++) 
     4877                                        { 
     4878                                                moveDown(false); 
     4879                                        } 
     4880                                } 
     4881                        }else 
     4882                        { 
     4883                                //I'm in the selection rectangle 
     4884                                //but first, check for a next higher bin 
     4885                                //if I'm near the edge of the rectangle, 
     4886                                //go to the next higher bin 
     4887 
     4888                                //if I've drawn the right hand arrow 
     4889                                if(boHasChildren == true) 
     4890                                { 
     4891                                        //if I've clicked within 25% of the right edge  
     4892                                        if(e->x() >= (0.85 * (x_map_location + highlight_map[iMapUsed]->width())) ) 
     4893                                        { 
     4894                                                pushDown(); 
     4895                                        }else 
     4896                                        { 
     4897                                                select(); 
     4898                                        } 
     4899                                }else if(boHasParent == true)   //if there is a left arrow 
     4900                                { 
     4901                                        if(e->x() <= (x_map_location + (0.15 * highlight_map[iMapUsed]->width()))) 
     4902                                        { 
     4903                                                popUp(); 
     4904                                        }else 
     4905                                        { 
     4906                                                select(); 
     4907                                        } 
     4908                                 
     4909                                }else 
     4910                                { 
     4911                                        select(); 
     4912                                } 
     4913                        } 
     4914                       
     4915                        iReturnValue = 0;  
     4916                }else   //I'm not inside the active bin 
     4917                { 
     4918 
     4919                        //I'm to the left of the active bin 
     4920                        if(e->x() < BinRect.left()) 
     4921                        { 
     4922                                popUp(); 
     4923                                iReturnValue = 0; 
     4924                        } 
     4925 
     4926                        //I'm to the right of the active bin 
     4927                        if(e->x() > BinRect.right()) 
     4928                        { 
     4929                                pushDown(); 
     4930                                iReturnValue = 0; 
     4931                        } 
     4932                } 
     4933 
     4934        refresh(); 
     4935        
     4936        }         
     4937 
     4938        return(iReturnValue); 
     4939} 
     4940 
     4941//end of added section 
     4942 
    47644943// ******************************************************************** 
    47654944 
    47664945UIPushButtonType::UIPushButtonType(const QString &name, QPixmap on, QPixmap off, QPixmap pushed) 
  • mythtv/libs/libmyth/uitypes.h

     
    125125    virtual void hide(); 
    126126    virtual bool toggleShow(); 
    127127 
     128//added by Anthony D'Alberto to support mouse presses in UITypes 
     129//this is done by making calling the handler function in  
     130//the event handler. 
     131//for some reason, the uipushbutton already has this. 
    128132 
     133//this is the default handler, do nothing 
     134    virtual int mousePressHandler(QMouseEvent *e){return (-1);} 
     135//end of added section 
     136 
    129137  signals: 
    130138 
    131139    // 
     
    11131121    bool    incSearchStart(); 
    11141122    bool    incSearchNext(); 
    11151123 
     1124//added by Anthony D'Alberto to support mouse press in Managed List 
     1125    int     mousePressHandler(QMouseEvent *e); 
     1126//end of added section 
     1127 
    11161128  signals: 
    11171129 
    11181130    void    nodeSelected(int, IntVector*); //  emit int and attributes when user selects a node 
     
    11591171    QPoint                  rightArrowOffset; 
    11601172    QString                 incSearch; 
    11611173    bool                    bIncSearchContains; 
     1174 
     1175//added by Anthony D'Alberto to support mouse presses in List box 
     1176 
     1177    int                     iMapUsed; 
     1178    int                     x_map_location; 
     1179    int                     y_map_location; 
     1180    bool                    boHasChildren; 
     1181    bool                    boHasParent; 
     1182//end of added section 
    11621183}; 
    11631184 
    11641185class MPUBLIC UIPushButtonType : public UIType 
  • mythtv/libs/libmyth/mythdialogs.h

     
    322322    QPixmap my_background; 
    323323    QPixmap my_foreground; 
    324324 
     325//added by Anthony D'Alberto to support back button 
     326    virtual void mousePressEvent(QMouseEvent *e); 
     327    virtual void mouseReleaseEvent(QMouseEvent *e); 
     328//end of added section 
     329 
    325330  private: 
    326331 
    327332    void ReallyUpdateForeground(const QRect &);