|
From: CVS C. to T. <the...@li...> - 2011-06-05 13:05:23
|
Revision: 656
http://themis.svn.sourceforge.net/themis/?rev=656&view=rev
Author: mark_hellegers
Date: 2011-06-05 13:05:17 +0000 (Sun, 05 Jun 2011)
Log Message:
-----------
- Cleaned up the styling.
- Moved the buttons variable of ThemisNavView to be private and fixed code that depended on it being public.
Modified Paths:
--------------
trunk/themis/framework/ThemisNavView.cpp
trunk/themis/framework/ThemisNavView.h
trunk/themis/framework/ThemisTabView.cpp
trunk/themis/framework/win.cpp
Modified: trunk/themis/framework/ThemisNavView.cpp
===================================================================
--- trunk/themis/framework/ThemisNavView.cpp 2011-06-04 23:34:50 UTC (rev 655)
+++ trunk/themis/framework/ThemisNavView.cpp 2011-06-05 13:05:17 UTC (rev 656)
@@ -15,21 +15,23 @@
#include "ThemisNavView.h"
#include "TPictureButton.h"
-ThemisNavView::ThemisNavView( BRect rect ) :
- BView( rect, "THEMISNAVVIEW", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE )
-{
+ThemisNavView :: ThemisNavView(BRect rect)
+ : BView(rect,
+ "THEMISNAVVIEW",
+ B_FOLLOW_LEFT_RIGHT,
+ B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE) {
+
}
-ThemisNavView::~ThemisNavView( void )
-{
+ThemisNavView :: ~ThemisNavView() {
+
}
-void
-ThemisNavView::AttachedToWindow( void )
-{
+void ThemisNavView :: AttachedToWindow() {
+
BRect rect = Bounds();
- SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
+ SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// create the urlview first( we need its frame for go button later )
urlview = new ThemisUrlView(
@@ -39,87 +41,80 @@
rect.right - 25,
rect.bottom - 5 ), // minimum height automatically set by BTextControl
"URLVIEW", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | //B_NAVIGABLE |
- B_FULL_UPDATE_ON_RESIZE );
+ B_FULL_UPDATE_ON_RESIZE);
urlview->TextView()->AddFilter(new ThemisUrlViewMessageFilter(Window()));
- AddChild( urlview );
+ AddChild(urlview);
// now create the buttons in my adventurous method :D
CreateInterfaceButtons();
}
-void
-ThemisNavView::Draw( BRect updaterect )
-{
+void ThemisNavView :: Draw(BRect updaterect) {
+
// compromise for now
// make the updaterect the Bounds rectangle
updaterect = Bounds();
rgb_color lo = LowColor();
- rgb_color panel_color = ui_color( B_PANEL_BACKGROUND_COLOR );
+ rgb_color panel_color = ui_color(B_PANEL_BACKGROUND_COLOR);
- SetLowColor( panel_color );
- FillRect( updaterect, B_SOLID_LOW );
+ SetLowColor(panel_color);
+ FillRect(updaterect, B_SOLID_LOW);
- SetLowColor( kColorDarkBorder );
+ SetLowColor(kColorDarkBorder);
StrokeLine(
- BPoint( updaterect.left, updaterect.bottom ),
- BPoint( updaterect.right, updaterect.bottom ),
- B_SOLID_LOW );
+ BPoint(updaterect.left, updaterect.bottom),
+ BPoint(updaterect.right, updaterect.bottom),
+ B_SOLID_LOW);
- SetLowColor( kColorLightBorder );
+ SetLowColor(kColorLightBorder);
StrokeLine(
- BPoint( updaterect.left, updaterect.bottom - 1 ),
- BPoint( updaterect.right, updaterect.bottom - 1 ),
- B_SOLID_LOW );
+ BPoint(updaterect.left, updaterect.bottom - 1),
+ BPoint(updaterect.right, updaterect.bottom - 1),
+ B_SOLID_LOW);
- if( CountChildren() > 0 )
- {
- BView* child = NULL;
- for( int32 i = 0; i < CountChildren(); i++ )
- {
- child = ChildAt( i );
- child->Draw( child->Bounds() );
+ if (CountChildren() > 0) {
+ BView * child = NULL;
+ for (int32 i = 0; i < CountChildren(); i++) {
+ child = ChildAt(i);
+ child->Draw(child->Bounds());
}
}
- SetLowColor( lo );
+ SetLowColor(lo);
}
-void
-ThemisNavView::MouseDown( BPoint point )
-{
+void ThemisNavView :: MouseDown(BPoint point) {
+
// check, if the urlpopupwindow is still open
// if yes, close it and return.
- Win* win = ( Win* )Window();
+ Win * win = (Win *)Window();
if (!win->CloseUrlPopUpWindow()) {
BView::MouseDown(point);
}
}
-void
-ThemisNavView::CreateInterfaceButtons()
-{
- //cout << "ThemisNavView::CreateInterfaceButton()" << endl;
+void ThemisNavView :: CreateInterfaceButtons() {
// the small 16x16 bitmap for on, over, active or off
- BBitmap* smallbmp = NULL;
+ BBitmap * smallbmp = NULL;
// the pictures
- BPicture* onpic = NULL;
- BPicture* overpic = NULL;
- BPicture* activepic = NULL;
- BPicture* offpic = NULL;
+ BPicture * onpic = NULL;
+ BPicture * overpic = NULL;
+ BPicture * activepic = NULL;
+ BPicture * offpic = NULL;
// the start rect
- BRect posrect( 10,7,25,22 );
+ BRect posrect(10, 7, 25, 22);
// the view in which we will draw the Pictures
- BView *tempview = new BView( BRect( 0,0,15,15 ), "TEMPVIEW", B_FOLLOW_NONE, B_WILL_DRAW );
- tempview->SetDrawingMode( B_OP_ALPHA );
- AddChild( tempview );
+ BView * tempview = new BView(BRect(0, 0, 15, 15), "TEMPVIEW", B_FOLLOW_NONE, B_WILL_DRAW);
+ tempview->SetDrawingMode(B_OP_ALPHA);
+ AddChild(tempview);
- Win* win = ( Win* )Window();
+ Win * win = (Win *)Window();
// the array with button-names
const char* names[7];
@@ -133,61 +128,71 @@
names[5] = "BUTTONRELOADPICBUTTON";
names[6] = "BUTTONGOPICBUTTON";
- for( int i = 0; i < 7; i++ )
- {
+ for (int i = 0; i < 7; i++) {
// either 64x16 or 48x16 behaviour
int limit = 0;
- if( i <= 4 )
+ if (i <= 4)
limit = 3;
else
limit = 2;
- for( int j = 0; j <= limit; j++ )
- {
+ for (int j = 0; j <= limit; j++) {
// extract partial bitmaps
-
- smallbmp = new BBitmap( BRect( 0,0,15,15 ), B_RGB32 );
+ smallbmp = new BBitmap(BRect(0, 0, 15, 15), B_RGB32);
- unsigned char* p1 = ( unsigned char* )win->GetBitmap(i)->Bits();
- unsigned char* p2 = ( unsigned char* )smallbmp->Bits();
+ unsigned char * p1 = (unsigned char *)win->GetBitmap(i)->Bits();
+ unsigned char * p2 = (unsigned char *)smallbmp->Bits();
- for( int k = 0; k < 16; k++ )
- {
+ for (int k = 0; k < 16; k++) {
memcpy(
- ( void* )( p2 + ( k * 64 ) ),
- ( const void* )( p1 + ( ( j + ( ( limit + 1 ) * k ) ) * 64 ) ),
- 64 );
+ (void *)(p2 + (k * 64)),
+ (const void *)(p1 + ((j + ((limit + 1) * k)) * 64)),
+ 64);
}
- tempview->BeginPicture( new BPicture );
- tempview->DrawBitmap( smallbmp );
- if( j == 0 ) onpic = tempview->EndPicture();
- if( j == 1 ) overpic = tempview->EndPicture();
- if( j == 2 ) activepic = tempview->EndPicture();
- if( j == 3 ) offpic = tempview->EndPicture();
+ tempview->BeginPicture(new BPicture);
+ tempview->DrawBitmap(smallbmp);
+ if (j == 0) onpic = tempview->EndPicture();
+ if (j == 1) overpic = tempview->EndPicture();
+ if (j == 2) activepic = tempview->EndPicture();
+ if (j == 3) offpic = tempview->EndPicture();
delete smallbmp;
}
- BMessage* msg = NULL;
- if( i == 0 ) msg = new BMessage( BUTTON_BACK );
- if( i == 1 ) msg = new BMessage( BUTTON_FORWARD );
- if( i == 2 ) msg = new BMessage( BUTTON_STOP );
- if( i == 3 ) msg = new BMessage( BUTTON_HOME );
- if( i == 4 ) msg = new BMessage( TAB_ADD );
- if( i == 5 ) msg = new BMessage( BUTTON_RELOAD ); // URL_OPEN ??
- if( i == 6 ) msg = new BMessage( URL_OPEN );
+ BMessage * msg = NULL;
+ if (i == 0) msg = new BMessage(BUTTON_BACK);
+ if (i == 1) msg = new BMessage(BUTTON_FORWARD);
+ if (i == 2) msg = new BMessage(BUTTON_STOP);
+ if (i == 3) msg = new BMessage(BUTTON_HOME);
+ if (i == 4) msg = new BMessage(TAB_ADD);
+ if (i == 5) msg = new BMessage(BUTTON_RELOAD); // URL_OPEN ??
+ if (i == 6) msg = new BMessage(URL_OPEN);
// calculate the position rect
- switch( i )
- {
- case 0 : // back
- case 1 : // fwd
- case 2 : { posrect.left = 5 + ( i * 25 ); break; } // stop
- case 3 : { posrect.left = 5 + ( 4 * 25 ); break; } // home
- case 4 : { posrect.left = 5 + ( 5 * 25 ); break; } // newtab
- case 5 : { posrect.left = 5 + ( 3 * 25 ); break; } // reload
- case 6 : { posrect.left = urlview->Frame().right + 5; break; } // go
+ switch (i) {
+ case 0: // back
+ case 1: // fwd
+ case 2: {
+ posrect.left = 5 + ( i * 25 );
+ break;
+ } // stop
+ case 3: {
+ posrect.left = 5 + ( 4 * 25 );
+ break;
+ } // home
+ case 4: {
+ posrect.left = 5 + ( 5 * 25 );
+ break;
+ } // newtab
+ case 5: {
+ posrect.left = 5 + ( 3 * 25 );
+ break;
+ } // reload
+ case 6: {
+ posrect.left = urlview->Frame().right + 5;
+ break;
+ } // go
}
posrect.right = posrect.left + 15;
@@ -201,20 +206,22 @@
offpic,
msg,
0,
- B_WILL_DRAW );
+ B_WILL_DRAW);
- if( i == 6 )
- buttons[i]->SetResizingMode( buttons[i]->ResizingMode() | B_FOLLOW_RIGHT );
+ if (i == 6)
+ buttons[i]->SetResizingMode(buttons[i]->ResizingMode() | B_FOLLOW_RIGHT);
// set initial behaviour for back, fwd and stop button ( disabled )
- switch( i )
- {
- case 0 :
- case 1 :
- case 2 : buttons[i]->SetMode( 3 ); break;
+ switch(i) {
+ case 0:
+ case 1:
+ case 2: {
+ buttons[i]->SetMode( 3 );
+ break;
+ }
}
- AddChild( buttons[i] );
+ AddChild(buttons[i]);
// reset the bitmaps and pics
smallbmp = NULL;
@@ -225,6 +232,14 @@
}
// remove the tempview
- RemoveChild( tempview );
+ RemoveChild(tempview);
delete tempview;
}
+
+void ThemisNavView :: SetButtonMode(int aButton,
+ int8 aMode,
+ bool aForceMode) {
+
+ buttons[aButton]->SetMode(aMode, aForceMode);
+
+}
Modified: trunk/themis/framework/ThemisNavView.h
===================================================================
--- trunk/themis/framework/ThemisNavView.h 2011-06-04 23:34:50 UTC (rev 655)
+++ trunk/themis/framework/ThemisNavView.h 2011-06-05 13:05:17 UTC (rev 656)
@@ -6,27 +6,25 @@
// BeOS headers
#include <View.h>
-// C/C++ headers
-
// Declarations used
class ThemisUrlView;
class TPictureButton;
-class ThemisNavView : public BView
-{
+class ThemisNavView : public BView {
+
+ private:
+ TPictureButton * buttons[7];
+
public:
- ThemisNavView(
- BRect rect );
- virtual ~ThemisNavView( void );
- void AttachedToWindow( void );
- void Draw( BRect updaterect );
- void MouseDown( BPoint point );
-
- void CreateInterfaceButtons();
-
- ThemisUrlView* urlview;
-
- TPictureButton* buttons[7];
+ ThemisNavView(BRect rect);
+ virtual ~ThemisNavView();
+ void AttachedToWindow();
+ void Draw(BRect updaterect);
+ void MouseDown(BPoint point);
+ void CreateInterfaceButtons();
+ void SetButtonMode(int aButton, int8 aMode, bool aForceMode = false);
+
+ ThemisUrlView * urlview;
};
#endif
Modified: trunk/themis/framework/ThemisTabView.cpp
===================================================================
--- trunk/themis/framework/ThemisTabView.cpp 2011-06-04 23:34:50 UTC (rev 655)
+++ trunk/themis/framework/ThemisTabView.cpp 2011-06-05 13:05:17 UTC (rev 656)
@@ -19,6 +19,7 @@
#include <String.h>
#include <Messenger.h>
#include <Window.h>
+#include <Picture.h>
// Themis headers
#include "win.h"
@@ -362,7 +363,7 @@
// if the newtab button is disabled, and no more tabs are
// out of range, enable the button
if( ( CountTabs() * tab_width ) <= ( Bounds().right - 22 ) )
- ( ( Win* )Window() )->GetNavView()->buttons[4]->SetMode( 0 );
+ ( ( Win* )Window() )->GetNavView()->SetButtonMode(4, 0);
// calculate new ( bigger ) size of tabs and draw again
DynamicTabs( false );
@@ -764,25 +765,25 @@
if (tab->GetHistory()->GetCurrentPosition() == 0) {
if (tab->GetHistory()->GetEntryCount() > 1) {
// printf("TABVIEW: enabling back, disabling fwd button if needed.\n");
- nv->buttons[0]->SetMode(0);
- nv->buttons[1]->SetMode(3);
+ nv->SetButtonMode(0, 0);
+ nv->SetButtonMode(1, 3);
}
else {
// printf( "TABVIEW: only one ( or no )history item. disabling back and fwd if needed.\n" );
- nv->buttons[0]->SetMode(3);
- nv->buttons[1]->SetMode(3);
+ nv->SetButtonMode(0, 3);
+ nv->SetButtonMode(1, 3);
}
}
else {
if (tab->GetHistory()->GetCurrentPosition() == (tab->GetHistory()->GetEntryCount() - 1)) {
// printf("TABVIEW: at history end. disable back, enable fwd if needed.\n");
- nv->buttons[0]->SetMode(3);
- nv->buttons[1]->SetMode(0);
+ nv->SetButtonMode(0, 3);
+ nv->SetButtonMode(1, 0);
}
else {
// printf("TABVIEW: in middle of history. enabling back and fwd if needed.\n");
- nv->buttons[0]->SetMode(0);
- nv->buttons[1]->SetMode(0);
+ nv->SetButtonMode(0, 0);
+ nv->SetButtonMode(1, 0);
}
}
}
Modified: trunk/themis/framework/win.cpp
===================================================================
--- trunk/themis/framework/win.cpp 2011-06-04 23:34:50 UTC (rev 655)
+++ trunk/themis/framework/win.cpp 2011-06-05 13:05:17 UTC (rev 656)
@@ -56,7 +56,6 @@
#include "../common/commondefs.h"
#include "../common/PrefsDefs.h"
#include "GlobalHistory.h"
-#include "TPictureButton.h"
#include "win.h"
extern plugman *PluginManager;
@@ -260,7 +259,7 @@
Lock();
// if the newtab button is disabled, enable it again
- navview->buttons[4]->SetMode(0);
+ navview->SetButtonMode(4, 0);
uint32 current_tab = 0;
uint32 count = tabview->CountTabs();
@@ -308,7 +307,7 @@
if (Bounds().right - width <= 22) {
// disable the newtab button
- navview->buttons[4]->SetMode(3);
+ navview->SetButtonMode(4, 3);
break;
}
// if we won't cover the button, go on...
@@ -491,9 +490,9 @@
// enable or disable the newtab button
if ((tabview->CountTabs() * tabview->tab_width) <= (Bounds().right - 22))
- navview->buttons[4]->SetMode(0);
+ navview->SetButtonMode(4, 0);
else
- navview->buttons[4]->SetMode(3);
+ navview->SetButtonMode(4, 3);
// resize urlpopupwindow
if (urlpopupwindow != NULL) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|