paragui-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paragui-cvs] CVS: paragui/src/widgets pgtabbar.cpp,NONE,1.1 Makefile.am


From: Alexander Pipelka <address@hidden>
Subject: [paragui-cvs] CVS: paragui/src/widgets pgtabbar.cpp,NONE,1.1 Makefile.am,1.3,1.4 pgbutton.cpp,1.6,1.7 pgwidgetlist.cpp,1.4,1.5
Date: Sat, 27 Apr 2002 15:08:13 -0400

Update of /cvsroot/paragui/paragui/src/widgets
In directory subversions:/tmp/cvs-serv3041/src/widgets

Modified Files:
        Makefile.am pgbutton.cpp pgwidgetlist.cpp 
Added Files:
        pgtabbar.cpp 
Log Message:
added new PG_TabBar class
PG_Button togglemode fixes
PG_WidgetList improvements needed for PG_TabBar



--- NEW FILE ---
#include "pgtabbar.h"
#include "pglog.h"

PG_TabBar::PG_TabBar(PG_Widget* parent, const PG_Rect r, const char* style) : 
PG_Widget(parent, r) {

        my_tabList = new PG_WidgetListEx(this, PG_Rect(0,0,r.w-50,r.h), style);
        my_tabList->EnableScrollBar(false, PG_SB_VERTICAL);
        my_tabList->EnableScrollBar(false, PG_SB_HORIZONTAL);

        my_btnPrev = new PG_Button(this, -1, PG_Rect(0,r.w-50,25,h), "<");
        my_btnPrev->sigButtonClick.connect(slot(this, 
&PG_TabBar::handleTabNav));
        my_btnPrev->Hide();
        
        my_btnNext = new PG_Button(this, -1, PG_Rect(0,r.w-25,25,h), ">");
        my_btnNext->sigButtonClick.connect(slot(this, 
&PG_TabBar::handleTabNav));
        my_btnNext->Hide();
        
        my_selectedTab = NULL;
        
        SizeWidget(r.w, r.h);
}

PG_TabBar::~PG_TabBar() {
}
        
PG_Button* PG_TabBar::AddTab(const char* text, int id) {
        Uint16 height = 0;
        Uint16 width = 0;
        
        GetTextSize(width, height, text);
        width += 6;
        
        PG_Button* b = new PG_Button(NULL, id, 
PG_Rect(my_tabList->GetListWidth(), 0, width, my_height), text);
        b->SetToggle(true);
        b->sigButtonClick.connect(slot(this, &PG_TabBar::handleTabClick));
        
        my_tabList->AddWidget(b);
        
        if(my_tabList->GetListWidth() > my_width) {
                SizeWidget(my_width, my_height);
        }
        Update();
        
        int c = my_tabList->GetWidgetCount();
        
        if(c == 1) {
                b->SetPressed(true);
                my_selectedTab = b;
        }
        return b;
}

void PG_TabBar::eventSizeWidget(Uint16 w, Uint16 h) {
        
        Uint16 listw = w - ((my_tabList->GetListWidth() <= w) ? 0 : 
(my_btnPrev->w + my_btnNext->w));
        
        my_tabList->SizeWidget(listw, h);
        my_tabList->Update();
        
        if(my_tabList->GetListWidth() <= w) {
                my_btnNext->Hide();
                my_btnPrev->Hide();
                return;
        }

        my_btnPrev->MoveWidget(PG_Rect(listw, 0, my_btnPrev->w, h));

        listw += my_btnPrev->w;
        my_btnNext->MoveWidget(PG_Rect(listw, 0, my_btnNext->w, h));


        my_btnNext->Show();
        my_btnPrev->Show();
}

bool PG_TabBar::handleTabClick(PG_Button* button) {
        if(my_selectedTab == button) {
                my_selectedTab->SetPressed(true);
                return false;
        }
        
        if(my_selectedTab != NULL) {
                my_selectedTab->SetPressed(false);
        }
        
        my_selectedTab = button;
        my_selectedTab->SetPressed(true);
        
        sigTabSelect(this, button);
        
        return true;
}

bool PG_TabBar::handleTabNav(PG_Button* button) {
        int index = -1;
        int dir = 0;
        
        if(button == my_btnPrev) {
                index = my_tabList->FindIndex(my_selectedTab);
                dir = -1;
        }

        if(button == my_btnNext) {
                index = my_tabList->FindIndex(my_selectedTab);
                dir = +1;
        }

        if(index == -1) {
                return false;
        }
        
        index += dir;
        PG_Widget* w = my_tabList->FindWidget(index);
        
        if(w == NULL) {
                return false;
        }
        
        my_tabList->ScrollTo(w, PG_SB_HORIZONTAL);
        PG_Button* b = static_cast<PG_Button*>(w);
        handleTabClick(b);
        
        return true;
}

Index: Makefile.am
===================================================================
RCS file: /cvsroot/paragui/paragui/src/widgets/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Makefile.am 27 Apr 2002 11:57:22 -0000      1.3
--- Makefile.am 27 Apr 2002 19:08:11 -0000      1.4
***************
*** 28,34 ****
  pgwidgetlistex.cpp \
  pgwindow.cpp \
! pgmenubar.cpp
! #pgbuttongroup.cpp \
! #pgnotebook.cpp \
  
  EXTRA_DIST =
--- 28,33 ----
  pgwidgetlistex.cpp \
  pgwindow.cpp \
! pgmenubar.cpp \
! pgtabbar.cpp
  
  EXTRA_DIST =

Index: pgbutton.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/widgets/pgbutton.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** pgbutton.cpp        27 Apr 2002 15:36:55 -0000      1.6
--- pgbutton.cpp        27 Apr 2002 19:08:11 -0000      1.7
***************
*** 350,353 ****
--- 350,362 ----
        }
  
+       if(!IsMouseInside() && my_internaldata->togglemode) {
+               if(my_state == BTN_STATE_PRESSED && 
!my_internaldata->isPressed) {
+                       my_state = BTN_STATE_NORMAL;
+               }
+               ReleaseCapture();
+               Update();
+               return false;
+       }
+       
        if(my_internaldata->togglemode) {
                if(!my_internaldata->isPressed) {
***************
*** 578,581 ****
--- 587,595 ----
        }
  
+       if(my_internaldata->isPressed) {
+               t = my_transparency[1];
+               srf = my_internaldata->srf_down;
+       }
+       
        // blit it
  

Index: pgwidgetlist.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/widgets/pgwidgetlist.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** pgwidgetlist.cpp    27 Apr 2002 11:57:23 -0000      1.4
--- pgwidgetlist.cpp    27 Apr 2002 19:08:11 -0000      1.5
***************
*** 444,447 ****
--- 444,457 ----
  }
  
+ int PG_WidgetList::FindIndex(PG_Widget* widget) {
+       for(int i=0; i< (int)my_widgetList.size(); i++) {
+               if(my_widgetList[i] == widget) {
+                       return i;
+               }
+       }
+       
+       return -1;
+ }
+ 
  int PG_WidgetList::GetWidgetCount() {
        return my_widgetCount;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]