|
From: CVS C. to T. <the...@li...> - 2010-08-24 22:35:50
|
Revision: 549
http://themis.svn.sourceforge.net/themis/?rev=549&view=rev
Author: mark_hellegers
Date: 2010-08-24 22:35:43 +0000 (Tue, 24 Aug 2010)
Log Message:
-----------
Rewrote parts of the preferences system:
- Moved creation of the views to the constructor and only the really necessary parts stay in AttachedToWindow.
- Now creating the views when the window is opened, instead of every time the preferences of the view are selected.
This costs a bit more memory, but will make it easier to move the preferences to the addons where they belong.
- Now setting the background color on the view itself, instead of on the BBox.
- Changed the style.
Modified Paths:
--------------
trunk/themis/framework/PrefsViews.cpp
trunk/themis/framework/PrefsViews.h
trunk/themis/framework/PrefsWin.cpp
trunk/themis/framework/PrefsWin.h
Modified: trunk/themis/framework/PrefsViews.cpp
===================================================================
--- trunk/themis/framework/PrefsViews.cpp 2010-08-24 19:25:15 UTC (rev 548)
+++ trunk/themis/framework/PrefsViews.cpp 2010-08-24 22:35:43 UTC (rev 549)
@@ -4,6 +4,8 @@
* author: Michael Weirauch
*/
+
+#include <interface/Box.h>
#include <interface/Button.h>
#include <interface/CheckBox.h>
#include <interface/MenuField.h>
@@ -15,7 +17,6 @@
#include <storage/Directory.h>
#include <storage/Entry.h>
#include <storage/Path.h>
-#include <support/String.h>
#include <stdio.h>
@@ -29,57 +30,40 @@
*/
-BasePrefsView::BasePrefsView(
- BRect frame,
- const char* name )
- : BView(
- frame,
- name,
- B_FOLLOW_ALL,
- 0 )
-{
-}
+BasePrefsView :: BasePrefsView(BRect frame,
+ const char* name)
+ : BView(frame,
+ name,
+ B_FOLLOW_ALL,
+ 0) {
-
-void
-BasePrefsView::AttachedToWindow()
-{
fMainBox = new BBox(
Bounds(),
"MainBox",
- B_FOLLOW_ALL );
- fMainBox->SetLabel( Name() );
- AddChild( fMainBox );
- fMainBox->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
-}
+ B_FOLLOW_ALL);
+ fMainBox->SetLabel(Name());
+ AddChild(fMainBox);
+ SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+}
+
/*
* WindowPrefsView
*/
-WindowPrefsView::WindowPrefsView(
- BRect frame,
- const char* name )
- : BasePrefsView(
- frame,
- name )
-{
-}
+WindowPrefsView :: WindowPrefsView(BRect frame,
+ const char* name)
+ : BasePrefsView(frame,
+ name) {
-
-void
-WindowPrefsView::AttachedToWindow()
-{
- BasePrefsView::AttachedToWindow();
-
/* homepage */
BString str;
- AppSettings->FindString( kPrefsHomePage, &str );
+ AppSettings->FindString(kPrefsHomePage, &str);
BRect rect = Bounds();
- rect.InsetBy( kItemSpacing, kItemSpacing );
+ rect.InsetBy(kItemSpacing, kItemSpacing);
rect.top += kBBoxExtraInset;
BTextControl* homepage = new BTextControl(
@@ -87,28 +71,28 @@
"HOMEPAGE",
"Home Page:",
"",
- NULL );
- homepage->SetModificationMessage( new BMessage( HOMEPAGE_CHANGED ) );
- homepage->SetDivider( be_plain_font->StringWidth( "Home Page:" ) + kDividerSpacing );
- homepage->SetText( str.String() );
- fMainBox->AddChild( homepage );
+ NULL);
+ homepage->SetModificationMessage(new BMessage(HOMEPAGE_CHANGED));
+ homepage->SetDivider(be_plain_font->StringWidth("Home Page:") + kDividerSpacing);
+ homepage->SetText(str.String());
+ fMainBox->AddChild(homepage);
/* blank button */
rect.top = homepage->Frame().bottom + kItemSpacing;
- BMessage* blankmsg = new BMessage( SET_BLANK_PAGE );
- blankmsg->AddPointer( "homepagecontrol", homepage );
+ BMessage* blankmsg = new BMessage(SET_BLANK_PAGE);
+ blankmsg->AddPointer("homepagecontrol", homepage);
BButton* blankbtn = new BButton(
rect,
"BLANKBUTTON",
"Use Blank Page",
blankmsg,
B_FOLLOW_ALL,
- B_WILL_DRAW );
+ B_WILL_DRAW);
blankbtn->ResizeToPreferred();
blankbtn->MoveTo(
homepage->Frame().right - blankbtn->Bounds().Width(),
blankbtn->Frame().top );
- fMainBox->AddChild( blankbtn );
+ fMainBox->AddChild(blankbtn);
/* intelligent zoom */
rect.left = Bounds().left + kItemSpacing;
@@ -117,15 +101,15 @@
rect,
"IZCBOX",
"Intelligent Zoom",
- new BMessage( IZ_CHECKBOX ) );
+ new BMessage(IZ_CHECKBOX));
IZcbox->ResizeToPreferred();
bool IntelligentZoom = false;
AppSettings->FindBool( kPrefsIntelligentZoom, &IntelligentZoom );
- if( IntelligentZoom == false )
- IZcbox->SetValue( 0 );
+ if(IntelligentZoom == false)
+ IZcbox->SetValue(0);
else
- IZcbox->SetValue( 1 );
- fMainBox->AddChild( IZcbox );
+ IZcbox->SetValue(1);
+ fMainBox->AddChild(IZcbox);
/* type ahead */
rect.top = IZcbox->Frame().bottom + kItemSpacing;
@@ -133,12 +117,12 @@
rect,
"SHOWTYPEAHEADBOX",
"Show Type Ahead Window",
- new BMessage( SHOWTYPEAHEAD_CHECKBOX ) );
+ new BMessage(SHOWTYPEAHEAD_CHECKBOX));
ShowTypeAheadbox->ResizeToPreferred();
bool ShowTypeAhead = false;
- AppSettings->FindBool( kPrefsShowTypeAheadWindow, &ShowTypeAhead );
- ShowTypeAhead ? ShowTypeAheadbox->SetValue( 1 ) : ShowTypeAheadbox->SetValue( 0 );
- fMainBox->AddChild( ShowTypeAheadbox );
+ AppSettings->FindBool(kPrefsShowTypeAheadWindow, &ShowTypeAhead);
+ ShowTypeAhead ? ShowTypeAheadbox->SetValue(1) : ShowTypeAheadbox->SetValue(0);
+ fMainBox->AddChild(ShowTypeAheadbox);
/* show tabs */
rect.top = ShowTypeAheadbox->Frame().bottom + kItemSpacing;
@@ -146,12 +130,12 @@
rect,
"SHOWTABSCBOX",
"Show Tabs at Startup",
- new BMessage( SHOWTABS_CHECKBOX ) );
+ new BMessage(SHOWTABS_CHECKBOX));
ShowTabscbox->ResizeToPreferred();
bool ShowTabs = false;
- AppSettings->FindBool( kPrefsShowTabsAtStartup, &ShowTabs );
- ShowTabs ? ShowTabscbox->SetValue( 1 ) : ShowTabscbox->SetValue( 0 );
- fMainBox->AddChild( ShowTabscbox );
+ AppSettings->FindBool(kPrefsShowTabsAtStartup, &ShowTabs);
+ ShowTabs ? ShowTabscbox->SetValue(1) : ShowTabscbox->SetValue(0);
+ fMainBox->AddChild(ShowTabscbox);
/* open tabs in background */
rect.top = ShowTabscbox->Frame().bottom + kItemSpacing;
@@ -159,11 +143,11 @@
rect,
"OPENTABSINBACKGROUNDCBOX",
"Open new Tabs in Background",
- new BMessage( TABSBACKGROUND_CHECKBOX ) );
+ new BMessage(TABSBACKGROUND_CHECKBOX));
OpenTabsInBackgroundcbox->ResizeToPreferred();
bool OpenInBackground = false;
- AppSettings->FindBool( kPrefsOpenTabsInBackground, &OpenInBackground );
- OpenInBackground ? OpenTabsInBackgroundcbox->SetValue( 1 ) : OpenTabsInBackgroundcbox->SetValue( 0 );
+ AppSettings->FindBool(kPrefsOpenTabsInBackground, &OpenInBackground);
+ OpenInBackground ? OpenTabsInBackgroundcbox->SetValue(1) : OpenTabsInBackgroundcbox->SetValue(0);
fMainBox->AddChild( OpenTabsInBackgroundcbox );
/* open blank targets in tab (instead of new window) */
@@ -172,140 +156,123 @@
rect,
"OPENBLANKTARGETINTAB",
"Open \"_blank\" target in new Tab",
- new BMessage( TABSBLANK_CHECKBOX ) );
+ new BMessage(TABSBLANK_CHECKBOX));
OpenBlankTargetInTab_CBox->ResizeToPreferred();
bool OpenBlankInTab = false;
- AppSettings->FindBool( kPrefsOpenBlankTargetInTab, &OpenBlankInTab );
- OpenBlankInTab ? OpenBlankTargetInTab_CBox->SetValue( 1 ) : OpenBlankTargetInTab_CBox->SetValue( 0 );
- fMainBox->AddChild( OpenBlankTargetInTab_CBox );
+ AppSettings->FindBool(kPrefsOpenBlankTargetInTab, &OpenBlankInTab);
+ OpenBlankInTab ? OpenBlankTargetInTab_CBox->SetValue(1) : OpenBlankTargetInTab_CBox->SetValue(0);
+ fMainBox->AddChild(OpenBlankTargetInTab_CBox);
/* new windows open with ... */
rect = Bounds();
- rect.InsetBy( kItemSpacing, 0 );
+ rect.InsetBy(kItemSpacing, 0);
rect.top = OpenBlankTargetInTab_CBox->Frame().bottom + kItemSpacing;
rect.bottom = rect.top + 100;
- BBox* newwinpagebox = new BBox( rect, "NEWWINPAGEBOX" );
- newwinpagebox->SetLabel( "New Windows open with ..." );
- fMainBox->AddChild( newwinpagebox );
+ BBox * newInPageBox = new BBox(rect, "NEWWINPAGEBOX");
+ newInPageBox->SetLabel("New Windows open with ...");
+ fMainBox->AddChild(newInPageBox);
/* blank page */
- rect = newwinpagebox->Bounds();
- rect.InsetBy( kItemSpacing, kItemSpacing );
+ rect = newInPageBox->Bounds();
+ rect.InsetBy(kItemSpacing, kItemSpacing);
rect.top += kBBoxExtraInset;
- BMessage* nwspmsg1 = new BMessage( NEW_WINDOW_START_PAGE );
- nwspmsg1->AddInt8( "newpagemode", 0 );
- BRadioButton* rbtn1 = new BRadioButton( rect, "RBTN1", "Blank Page", nwspmsg1 );
+ BMessage* nwspmsg1 = new BMessage(NEW_WINDOW_START_PAGE);
+ nwspmsg1->AddInt8("newpagemode", 0);
+ BRadioButton* rbtn1 = new BRadioButton(rect, "RBTN1", "Blank Page", nwspmsg1);
rbtn1->ResizeToPreferred();
- newwinpagebox->AddChild( rbtn1 );
+ newInPageBox->AddChild(rbtn1);
/* homepage */
rect.top = rbtn1->Frame().bottom + kItemSpacing;
- BMessage* nwspmsg2 = new BMessage( NEW_WINDOW_START_PAGE );
- nwspmsg2->AddInt8( "newpagemode", 1 );
- BRadioButton* rbtn2 = new BRadioButton( rect, "RBTN2", "Home Page", nwspmsg2 );
+ BMessage* nwspmsg2 = new BMessage(NEW_WINDOW_START_PAGE);
+ nwspmsg2->AddInt8("newpagemode", 1);
+ BRadioButton* rbtn2 = new BRadioButton(rect, "RBTN2", "Home Page", nwspmsg2);
rbtn2->ResizeToPreferred();
- newwinpagebox->AddChild( rbtn2 );
+ newInPageBox->AddChild(rbtn2);
/* current page */
rect.top = rbtn2->Frame().bottom + kItemSpacing;
- BMessage* nwspmsg3 = new BMessage( NEW_WINDOW_START_PAGE );
- nwspmsg3->AddInt8( "newpagemode", 2 );
- BRadioButton* rbtn3 = new BRadioButton( rect, "RBTN3", "Current Page", nwspmsg3 );
+ BMessage* nwspmsg3 = new BMessage(NEW_WINDOW_START_PAGE);
+ nwspmsg3->AddInt8("newpagemode", 2);
+ BRadioButton* rbtn3 = new BRadioButton(rect, "RBTN3", "Current Page", nwspmsg3);
rbtn3->ResizeToPreferred();
- newwinpagebox->AddChild( rbtn3 );
+ newInPageBox->AddChild(rbtn3);
- /* resize the box */
- BPoint pt( rbtn3->Frame().LeftBottom() );
- pt.y += kItemSpacing;
- newwinpagebox->ConvertToParent( &pt );
- newwinpagebox->ResizeTo(
- newwinpagebox->Bounds().Width(),
- pt.y - newwinpagebox->Frame().top );
+ newInPageBox->ResizeTo(
+ newInPageBox->Bounds().Width(),
+ rect.top + rbtn3->Bounds().Height() + kItemSpacing);
int8 NewPageMode = 0;
- AppSettings->FindInt8( kPrefsNewWindowStartPage, &NewPageMode );
+ AppSettings->FindInt8(kPrefsNewWindowStartPage, &NewPageMode);
/* select the correct radiobutton */
- switch( NewPageMode )
- {
- case 0 : { rbtn1->SetValue( B_CONTROL_ON ); break; }
- case 1 : { rbtn2->SetValue( B_CONTROL_ON ); break; }
- case 2 : { rbtn3->SetValue( B_CONTROL_ON ); break; }
+ switch(NewPageMode) {
+ case 0: {
+ rbtn1->SetValue(B_CONTROL_ON);
+ break;
+ }
+ case 1: {
+ rbtn2->SetValue(B_CONTROL_ON);
+ break;
+ }
+ case 2: {
+ rbtn3->SetValue(B_CONTROL_ON);
+ break;
+ }
}
}
-
/*
* NetworkPrefsView
*/
-NetworkPrefsView::NetworkPrefsView(
- BRect frame,
- const char* name )
- : BasePrefsView(
- frame,
- name )
-{
+NetworkPrefsView :: NetworkPrefsView(BRect frame,
+ const char* name)
+ : BasePrefsView(frame,
+ name) {
}
-void
-NetworkPrefsView::AttachedToWindow()
-{
- BasePrefsView::AttachedToWindow();
-}
-
-
/*
* PrivacyPrefsView
*/
-PrivacyPrefsView::PrivacyPrefsView(
- BRect frame,
- const char* name )
- : BasePrefsView(
- frame,
- name )
-{
-}
+PrivacyPrefsView :: PrivacyPrefsView(BRect frame,
+ const char* name)
+ : BasePrefsView(frame,
+ name) {
-
-void
-PrivacyPrefsView::AttachedToWindow()
-{
- BasePrefsView::AttachedToWindow();
-
BRect rect = fMainBox->Bounds();
- rect.InsetBy( kItemSpacing, kItemSpacing );
+ rect.InsetBy(kItemSpacing, kItemSpacing);
rect.top += kBBoxExtraInset;
/* history box */
- BBox* HistoryBox = new BBox(
+ BBox * historyBox = new BBox(
rect,
- "HistoryBox" );
- HistoryBox->SetLabel( "History" );
- fMainBox->AddChild( HistoryBox );
+ "historyBox");
+ historyBox->SetLabel("History");
+ fMainBox->AddChild(historyBox);
/* history depth */
- rect = HistoryBox->Bounds();
- rect.InsetBy( kItemSpacing, kItemSpacing );
+ rect = historyBox->Bounds();
+ rect.InsetBy(kItemSpacing, kItemSpacing);
rect.top += kBBoxExtraInset;
BTextControl* ghistdepth = new BTextControl(
rect,
"GLOBALHISTDEPTH",
"History Depth [in Days, 1-127]:",
"",
- NULL );
- BMessage* chmsg1 = new BMessage( HISTORY_CHANGED );
- chmsg1->AddInt8( "which", 0 );
- ghistdepth->SetModificationMessage( chmsg1 );
- char string[ 5 ];
+ NULL);
+ BMessage* chmsg1 = new BMessage(HISTORY_CHANGED);
+ chmsg1->AddInt8("which", 0);
+ ghistdepth->SetModificationMessage(chmsg1);
+ char string[5];
int8 days = 0;
- AppSettings->FindInt8( kPrefsGlobalHistoryDepthInDays, &days );
- sprintf( string, "%d", days );
- ghistdepth->SetText( string );
- ghistdepth->TextView()->AddFilter( new DigitOnlyMessageFilter() );
- HistoryBox->AddChild( ghistdepth );
+ AppSettings->FindInt8(kPrefsGlobalHistoryDepthInDays, &days);
+ sprintf(string, "%d", days);
+ ghistdepth->SetText(string);
+ ghistdepth->TextView()->AddFilter(new DigitOnlyMessageFilter());
+ historyBox->AddChild(ghistdepth);
/* free urls */
rect.top = ghistdepth->Frame().bottom + kItemSpacing;
@@ -314,99 +281,93 @@
"FREEURLCOUNT",
"Number of free URLs [1-127]:",
"",
- NULL );
- BMessage* chmsg2 = new BMessage( HISTORY_CHANGED );
- chmsg2->AddInt8( "which", 1 );
- freeurlcount->SetModificationMessage( chmsg2 );
+ NULL);
+ BMessage* chmsg2 = new BMessage(HISTORY_CHANGED);
+ chmsg2->AddInt8("which", 1);
+ freeurlcount->SetModificationMessage(chmsg2);
int8 count = 0;
- AppSettings->FindInt8( kPrefsGlobalHistoryFreeURLCount, &count );
- sprintf( string, "%d", count );
- freeurlcount->SetText( string );
- freeurlcount->TextView()->AddFilter( new DigitOnlyMessageFilter() );
- HistoryBox->AddChild( freeurlcount );
+ AppSettings->FindInt8(kPrefsGlobalHistoryFreeURLCount, &count);
+ sprintf(string, "%d", count);
+ freeurlcount->SetText(string);
+ freeurlcount->TextView()->AddFilter(new DigitOnlyMessageFilter());
+ historyBox->AddChild(freeurlcount);
/* tab history */
rect.top = freeurlcount->Frame().bottom + kItemSpacing;
- BTextControl* tabhistdepth = new BTextControl(
+ BTextControl* tabHistDepth = new BTextControl(
rect,
"TABHISTDEPTH",
"Tab History Depth [1-127]:",
"",
- NULL );
- BMessage* chmsg3 = new BMessage( HISTORY_CHANGED );
- chmsg3->AddInt8( "which", 2 );
- tabhistdepth->SetModificationMessage( chmsg3 );
- AppSettings->FindInt8( kPrefsTabHistoryDepth, &count );
- sprintf( string, "%d", count );
- tabhistdepth->SetText( string );
- tabhistdepth->TextView()->AddFilter( new DigitOnlyMessageFilter() );
- HistoryBox->AddChild( tabhistdepth );
+ NULL);
+ BMessage* chmsg3 = new BMessage(HISTORY_CHANGED);
+ chmsg3->AddInt8("which", 2);
+ tabHistDepth->SetModificationMessage(chmsg3);
+ AppSettings->FindInt8(kPrefsTabHistoryDepth, &count);
+ sprintf(string, "%d", count);
+ tabHistDepth->SetText(string);
+ tabHistDepth->TextView()->AddFilter(new DigitOnlyMessageFilter());
+ historyBox->AddChild(tabHistDepth);
/* set the dividers, and resize the controls to be smaller */
- float maxwidth = be_plain_font->StringWidth( "History Depth [in Days, 1-127]:" );
- float width2 = be_plain_font->StringWidth( "Number of free URLs [1-127]:" );
- float width3 = be_plain_font->StringWidth( "Tab History Depth [1-127]:" );
- if( maxwidth < width2 )
+ float maxwidth = be_plain_font->StringWidth("History Depth [in Days, 1-127]:");
+ float width2 = be_plain_font->StringWidth("Number of free URLs [1-127]:");
+ float width3 = be_plain_font->StringWidth("Tab History Depth [1-127]:");
+ if(maxwidth < width2)
maxwidth = width2;
- if( maxwidth < width3 )
+ if(maxwidth < width3)
maxwidth = width3;
maxwidth += kDividerSpacing;
- ghistdepth->SetDivider( maxwidth );
- freeurlcount->SetDivider( maxwidth );
- tabhistdepth->SetDivider( maxwidth );
+ ghistdepth->SetDivider(maxwidth);
+ freeurlcount->SetDivider(maxwidth);
+ tabHistDepth->SetDivider(maxwidth);
ghistdepth->ResizeTo(
ghistdepth->Divider() + 50,
- ghistdepth->Bounds().Height() );
+ ghistdepth->Bounds().Height());
freeurlcount->ResizeTo(
freeurlcount->Divider() + 50,
- freeurlcount->Bounds().Height() );
- tabhistdepth->ResizeTo(
- tabhistdepth->Divider() + 50,
- tabhistdepth->Bounds().Height() );
+ freeurlcount->Bounds().Height());
+ tabHistDepth->ResizeTo(
+ tabHistDepth->Divider() + 50,
+ tabHistDepth->Bounds().Height());
+ historyBox->ResizeTo(
+ historyBox->Bounds().Width(),
+ rect.top + tabHistDepth->Bounds().Height() + kItemSpacing);
+
/* clear button */
BButton* clearHistbtn = new BButton(
rect,
"CLEARGHBUTTON",
"Clear History",
- new BMessage( HISTORY_CLEAR ),
+ new BMessage(HISTORY_CLEAR),
B_FOLLOW_RIGHT | B_FOLLOW_TOP,
- B_WILL_DRAW );
+ B_WILL_DRAW);
clearHistbtn->ResizeToPreferred();
- HistoryBox->AddChild( clearHistbtn );
+ historyBox->AddChild(clearHistbtn);
- /* resize HistoryBox */
- BPoint pt( tabhistdepth->Frame().LeftBottom() );
- pt.y += kItemSpacing;
- HistoryBox->ConvertToParent( &pt );
- HistoryBox->ResizeTo(
- HistoryBox->Bounds().Width(),
- pt.y - HistoryBox->Frame().top );
-
/* move button to right center */
clearHistbtn->MoveTo(
- HistoryBox->Bounds().right - ( clearHistbtn->Bounds().Width() + kItemSpacing ),
- HistoryBox->Bounds().Height() / 2 - clearHistbtn->Bounds().Height() / 2 );
+ historyBox->Bounds().right - (clearHistbtn->Bounds().Width() + kItemSpacing),
+ historyBox->Bounds().Height() / 2 - clearHistbtn->Bounds().Height() / 2);
/* cache box */
- rect = HistoryBox->Frame();
+ rect = historyBox->Frame();
rect.top = rect.bottom + kItemSpacing;
rect.bottom = rect.top + 100;
- BBox* CacheBox = new BBox(
- rect, "CACHEBOX" );
- CacheBox->SetLabel( "Cache" );
- fMainBox->AddChild( CacheBox );
+ BBox* CacheBox = new BBox(rect, "CACHEBOX");
+ CacheBox->SetLabel("Cache");
+ fMainBox->AddChild(CacheBox);
/* cookie box */
rect = CacheBox->Frame();
rect.top = rect.bottom + kItemSpacing;
rect.bottom = rect.top + 100;
- BBox* CookieBox = new BBox(
- rect, "COOKIEBOX" );
- CookieBox->SetLabel( "Cookies" );
- fMainBox->AddChild( CookieBox );
+ BBox* CookieBox = new BBox(rect, "COOKIEBOX");
+ CookieBox->SetLabel("Cookies");
+ fMainBox->AddChild(CookieBox);
}
@@ -416,235 +377,216 @@
*/
-HTMLParserPrefsView::HTMLParserPrefsView(
- BRect frame,
- const char* name )
- : BasePrefsView(
- frame,
- name )
-{
-}
+HTMLParserPrefsView :: HTMLParserPrefsView(BRect frame,
+ const char* name)
+ : BasePrefsView(frame,
+ name) {
-
-void
-HTMLParserPrefsView::AttachedToWindow()
-{
- BasePrefsView::AttachedToWindow();
-
/* DTD selection */
- BPopUpMenu* popmenu = new BPopUpMenu( "No DTD selected or available!", true, true, B_ITEMS_IN_COLUMN );
+ mPopUpMenu = new BPopUpMenu(
+ "No DTD selected or available!",
+ true,
+ true,
+ B_ITEMS_IN_COLUMN);
/* find a DTD */
- BString dtddir;
- AppSettings->FindString( kPrefsSettingsDirectory, &dtddir );
- dtddir.Append( "/dtd/" );
- printf( "DTD dir: %s\n", dtddir.String() );
+ AppSettings->FindString(kPrefsSettingsDirectory, &mDTDDir);
+ mDTDDir.Append("/dtd/");
+ printf("DTD dir: %s\n", mDTDDir.String());
- BDirectory dir( dtddir.String() );
- if( dir.InitCheck() != B_OK )
- {
- printf( "DTD directory (%s) not found!\n", dtddir.String() );
- printf( "Setting DTDToUsePath to \"none\"\n" );
- AppSettings->AddString( kPrefsActiveDTDPath, kNoDTDFoundString );
+ BDirectory dir(mDTDDir.String());
+ if(dir.InitCheck() != B_OK) {
+ printf("DTD directory (%s) not found!\n", mDTDDir.String());
+ printf("Setting DTDToUsePath to \"none\"\n");
+ AppSettings->AddString(kPrefsActiveDTDPath, kNoDTDFoundString);
}
- else
- {
+ else {
BString activeDTD;
- AppSettings->FindString( kPrefsActiveDTDPath, &activeDTD );
+ AppSettings->FindString(kPrefsActiveDTDPath, &activeDTD);
BEntry entry;
- while( dir.GetNextEntry( &entry, false ) != B_ENTRY_NOT_FOUND )
- {
+ while(dir.GetNextEntry(&entry, false) != B_ENTRY_NOT_FOUND) {
BPath path;
- entry.GetPath( &path );
+ entry.GetPath(&path);
char name[B_FILE_NAME_LENGTH];
- entry.GetName( name );
+ entry.GetName(name);
- BString nstring( name );
- printf( "----------------\n" );
- printf( "found file: %s\n", nstring.String() );
- if( nstring.IFindFirst( "DTD", nstring.Length() - 3 ) != B_ERROR )
- {
- printf( "found DTD file: %s\n", nstring.String() );
+ BString nstring(name);
+ printf("----------------\n");
+ printf("found file: %s\n", nstring.String());
+ if(nstring.IFindFirst("DTD", nstring.Length() - 3) != B_ERROR) {
+ printf("found DTD file: %s\n", nstring.String());
/* add the file to the popupmenu */
- BMessage* msg = new BMessage( DTD_SELECTED );
- msg->AddString( "DTDFileString", path.Path() );
- BMenuItem* item = new BMenuItem( name, msg, 0, 0 );
- popmenu->AddItem( item );
+ BMessage* msg = new BMessage(DTD_SELECTED);
+ msg->AddString("DTDFileString", path.Path());
+ BMenuItem* item = new BMenuItem(name, msg, 0, 0);
+ mPopUpMenu->AddItem(item);
// if the path of the current file equals the one of the settings,
// mark the item
- if( strcmp( activeDTD.String(), path.Path() ) == 0 )
- {
- printf( "DTD from settings found -> SetMarked( true )\n" );
- ( popmenu->ItemAt( popmenu->CountItems() - 1 ) )->SetMarked( true );
+ if(strcmp(activeDTD.String(), path.Path()) == 0) {
+ printf("DTD from settings found -> SetMarked( true )\n");
+ (mPopUpMenu->ItemAt(mPopUpMenu->CountItems() - 1))->SetMarked(true);
}
}
} // while
- // if we found some DTDs, but still no DTD is saved in the prefs,
- // or no DTD is selected:
- // set the last found DTD in the prefs. we save it to the prefs,
- // because the user might not reselect a DTD in the list, which
- // would save the DTD.
- BMessage imsg( DTD_SELECTED );
- BMessenger msgr( NULL, Window()->Looper() );
- if( popmenu->CountItems() > 0 )
- {
- if( popmenu->FindMarked() == NULL )
- {
- printf( "no marked item found\n" );
- BMenuItem* item = popmenu->ItemAt( popmenu->CountItems() - 1 );
- item->SetMarked( true );
- // as we cannot invoke the item here, send the DTD_SELECTED message here
- BString dtdstring( dtddir.String() );
- dtdstring.Append( item->Label() );
- imsg.AddString( "DTDFileString", dtdstring.String() );
- msgr.SendMessage( &imsg );
- }
- }
- else
- {
- imsg.AddString( "DTDFileString", kNoDTDFoundString );
- msgr.SendMessage( &imsg );
- }
}
// end: find a DTD
-
BRect rect = fMainBox->Bounds();
- rect.InsetBy( kItemSpacing, kItemSpacing );
+ rect.InsetBy(kItemSpacing, kItemSpacing);
rect.top += kBBoxExtraInset;
- BMenuField* dtdmenufield = new BMenuField( rect, "DTDFIELD", "Document Type Definition:", popmenu, true, B_FOLLOW_TOP, B_WILL_DRAW);
- dtdmenufield->SetDivider( be_plain_font->StringWidth( "Document Type Definition:" ) + kItemSpacing );
- fMainBox->AddChild( dtdmenufield );
+ BMenuField* dtdmenufield = new BMenuField(
+ rect,
+ "DTDFIELD", "Document Type Definition:",
+ mPopUpMenu,
+ true,
+ B_FOLLOW_TOP,
+ B_WILL_DRAW);
+ dtdmenufield->SetDivider(be_plain_font->StringWidth("Document Type Definition:") + kItemSpacing);
+ fMainBox->AddChild(dtdmenufield);
+
}
+void HTMLParserPrefsView :: AttachedToWindow() {
+
+ // if we found some DTDs, but still no DTD is saved in the prefs,
+ // or no DTD is selected:
+ // set the last found DTD in the prefs. we save it to the prefs,
+ // because the user might not reselect a DTD in the list, which
+ // would save the DTD.
+ BMessage imsg(DTD_SELECTED);
+ BMessenger msgr(NULL, Window()->Looper());
+ if(mPopUpMenu->CountItems() > 0) {
+ if(mPopUpMenu->FindMarked() == NULL) {
+ printf("no marked item found\n");
+ BMenuItem* item = mPopUpMenu->ItemAt(mPopUpMenu->CountItems() - 1);
+ item->SetMarked(true);
+ // as we cannot invoke the item here, send the DTD_SELECTED message here
+ BString dtdstring(mDTDDir.String());
+ dtdstring.Append(item->Label());
+ imsg.AddString("DTDFileString", dtdstring.String());
+ msgr.SendMessage(&imsg);
+ }
+ }
+ else {
+ imsg.AddString("DTDFileString", kNoDTDFoundString);
+ msgr.SendMessage(&imsg);
+ }
+}
+
/*
* CSSParserPrefsView
*/
-CSSParserPrefsView::CSSParserPrefsView(
- BRect frame,
- const char* name )
- : BasePrefsView(
- frame,
- name )
-{
-}
+CSSParserPrefsView :: CSSParserPrefsView(BRect frame,
+ const char* name)
+ : BasePrefsView(frame,
+ name) {
-
-void
-CSSParserPrefsView::AttachedToWindow()
-{
- BasePrefsView::AttachedToWindow();
-
/* CSS file selection */
- BPopUpMenu* popmenu = new BPopUpMenu( "No CSS selected or available!", true, true, B_ITEMS_IN_COLUMN );
+ mPopUpMenu = new BPopUpMenu(
+ "No CSS selected or available!",
+ true,
+ true,
+ B_ITEMS_IN_COLUMN);
/* find a CSS file */
- BString cssdir;
- AppSettings->FindString( kPrefsSettingsDirectory, &cssdir );
- cssdir.Append( "/css/" );
- printf( "CSS dir: %s\n", cssdir.String() );
+ AppSettings->FindString(kPrefsSettingsDirectory, &mCSSDir);
+ mCSSDir.Append("/css/");
+ printf("CSS dir: %s\n", mCSSDir.String());
- BDirectory dir( cssdir.String() );
- if( dir.InitCheck() != B_OK )
- {
- printf( "CSS directory (%s) not found!\n", cssdir.String() );
- printf( "Setting CSSToUsePath to \"none\"\n" );
- AppSettings->AddString( kPrefsActiveCSSPath, kNoCSSFoundString );
+ BDirectory dir(mCSSDir.String());
+ if(dir.InitCheck() != B_OK) {
+ printf("CSS directory (%s) not found!\n", mCSSDir.String());
+ printf("Setting CSSToUsePath to \"none\"\n");
+ AppSettings->AddString(kPrefsActiveCSSPath, kNoCSSFoundString);
}
- else
- {
+ else {
BString activeCSS;
- AppSettings->FindString( kPrefsActiveCSSPath, &activeCSS );
+ AppSettings->FindString(kPrefsActiveCSSPath, &activeCSS);
BEntry entry;
- while( dir.GetNextEntry( &entry, false ) != B_ENTRY_NOT_FOUND )
- {
+ while(dir.GetNextEntry(&entry, false) != B_ENTRY_NOT_FOUND) {
BPath path;
- entry.GetPath( &path );
+ entry.GetPath(&path);
char name[B_FILE_NAME_LENGTH];
- entry.GetName( name );
+ entry.GetName(name);
- BString nstring( name );
- printf( "----------------\n" );
- printf( "found CSS file: %s\n", nstring.String() );
+ BString nstring(name);
+ printf("----------------\n");
+ printf("found CSS file: %s\n", nstring.String());
/* add the file to the popupmenu */
- BMessage* msg = new BMessage( CSS_SELECTED );
- msg->AddString( "CSSFileString", path.Path() );
- BMenuItem* item = new BMenuItem( name, msg, 0, 0 );
- popmenu->AddItem( item );
+ BMessage* msg = new BMessage(CSS_SELECTED);
+ msg->AddString("CSSFileString", path.Path());
+ BMenuItem* item = new BMenuItem(name, msg, 0, 0);
+ mPopUpMenu->AddItem(item);
// if the path of the current file equals the one of the settings,
// mark the item
- if( strcmp( activeCSS.String(), path.Path() ) == 0 )
- {
- printf( "CSS from settings found -> SetMarked( true )\n" );
- ( popmenu->ItemAt( popmenu->CountItems() - 1 ) )->SetMarked( true );
+ if(strcmp(activeCSS.String(), path.Path() ) == 0) {
+ printf("CSS from settings found -> SetMarked( true )\n");
+ (mPopUpMenu->ItemAt(mPopUpMenu->CountItems() - 1))->SetMarked(true);
}
} // while
+ }
+ // end: find a CSS file
+
+ BRect rect = fMainBox->Bounds();
+ rect.InsetBy(kItemSpacing, kItemSpacing);
+ rect.top += kBBoxExtraInset;
+
+ BMenuField* cssmenufield = new BMenuField(
+ rect,
+ "CSSFIELD", "Cascading Style Sheet:",
+ mPopUpMenu,
+ true,
+ B_FOLLOW_TOP,
+ B_WILL_DRAW);
+ cssmenufield->SetDivider(be_plain_font->StringWidth("Cascading Style Sheet:") + kItemSpacing);
+ fMainBox->AddChild(cssmenufield);
+}
+
+void CSSParserPrefsView :: AttachedToWindow() {
+
// if we found some CSS files, but still no CSS file is saved in the prefs,
// or no CSS file is selected:
// set the last found CSS file in the prefs. we save it to the prefs,
// because the user might not reselect a CSS file in the list, which
// would save the CSS file.
- BMessage imsg( CSS_SELECTED );
- BMessenger msgr( NULL, Window()->Looper() );
- if( popmenu->CountItems() > 0 )
- {
- if( popmenu->FindMarked() == NULL )
- {
- printf( "no marked item found\n" );
- BMenuItem* item = popmenu->ItemAt( popmenu->CountItems() - 1 );
- item->SetMarked( true );
+ BMessage imsg(CSS_SELECTED);
+ BMessenger msgr(NULL, Window()->Looper());
+ if (mPopUpMenu->CountItems() > 0) {
+ if (mPopUpMenu->FindMarked() == NULL) {
+ printf("no marked item found\n");
+ BMenuItem* item = mPopUpMenu->ItemAt(mPopUpMenu->CountItems() - 1);
+ item->SetMarked(true);
// as we cannot invoke the item here, send the CSS_SELECTED message here
- BString cssstring( cssdir.String() );
- cssstring.Append( item->Label() );
- imsg.AddString( "CSSFileString", cssstring.String() );
- msgr.SendMessage( &imsg );
+ BString cssstring(mCSSDir.String());
+ cssstring.Append(item->Label());
+ imsg.AddString("CSSFileString", cssstring.String());
+ msgr.SendMessage(&imsg);
}
}
- else
- {
- imsg.AddString( "CSSFileString", kNoCSSFoundString );
- msgr.SendMessage( &imsg );
+ else {
+ imsg.AddString("CSSFileString", kNoCSSFoundString);
+ msgr.SendMessage(&imsg);
}
- }
- // end: find a CSS file
-
- BRect rect = fMainBox->Bounds();
- rect.InsetBy( kItemSpacing, kItemSpacing );
- rect.top += kBBoxExtraInset;
-
- BMenuField* cssmenufield = new BMenuField( rect, "CSSFIELD", "Cascading Style Sheet:", popmenu, true, B_FOLLOW_TOP, B_WILL_DRAW);
- cssmenufield->SetDivider( be_plain_font->StringWidth( "Cascading Style Sheet:" ) + kItemSpacing );
- fMainBox->AddChild( cssmenufield );
}
-
/*
* RendererPrefsView
*/
-RendererPrefsView::RendererPrefsView(
- BRect frame,
- const char* name )
- : BasePrefsView(
- frame,
- name )
-{
+RendererPrefsView :: RendererPrefsView(BRect frame,
+ const char* name)
+ : BasePrefsView(frame,
+ name) {
}
-
-void
-RendererPrefsView::AttachedToWindow()
-{
- BasePrefsView::AttachedToWindow();
-}
Modified: trunk/themis/framework/PrefsViews.h
===================================================================
--- trunk/themis/framework/PrefsViews.h 2010-08-24 19:25:15 UTC (rev 548)
+++ trunk/themis/framework/PrefsViews.h 2010-08-24 22:35:43 UTC (rev 549)
@@ -7,9 +7,14 @@
#ifndef _PREFSVIEWS_H_
#define _PREFSVIEWS_H_
-#include <Box.h>
+// BeOS headers
#include <View.h>
+#include <String.h>
+// Declarations used
+class BBox;
+class BPopUpMenu;
+
/*
* BasePrefsView
*/
@@ -17,17 +22,15 @@
class WindowPrefsView;
-class BasePrefsView : public BView
-{
+class BasePrefsView : public BView {
+
+ protected:
+ BBox * fMainBox;
+
public:
- BasePrefsView(
- BRect frame,
- const char* name );
+ BasePrefsView(BRect frame,
+ const char* name);
- virtual void AttachedToWindow();
-
- protected:
- BBox* fMainBox;
};
@@ -36,14 +39,12 @@
*/
-class WindowPrefsView : public BasePrefsView
-{
+class WindowPrefsView : public BasePrefsView {
+
public:
- WindowPrefsView(
- BRect frame,
- const char* name );
-
- virtual void AttachedToWindow();
+ WindowPrefsView(BRect frame,
+ const char* name);
+
};
@@ -52,14 +53,12 @@
*/
-class NetworkPrefsView : public BasePrefsView
-{
+class NetworkPrefsView : public BasePrefsView {
+
public:
- NetworkPrefsView(
- BRect frame,
- const char* name );
-
- virtual void AttachedToWindow();
+ NetworkPrefsView(BRect frame,
+ const char* name);
+
};
@@ -68,14 +67,12 @@
*/
-class PrivacyPrefsView : public BasePrefsView
-{
+class PrivacyPrefsView : public BasePrefsView {
+
public:
- PrivacyPrefsView(
- BRect frame,
- const char* name );
-
- virtual void AttachedToWindow();
+ PrivacyPrefsView(BRect frame,
+ const char* name);
+
};
@@ -84,14 +81,17 @@
*/
-class HTMLParserPrefsView : public BasePrefsView
-{
+class HTMLParserPrefsView : public BasePrefsView {
+
+ private:
+ BPopUpMenu * mPopUpMenu;
+ BString mDTDDir;
+
public:
- HTMLParserPrefsView(
- BRect frame,
- const char* name );
-
- virtual void AttachedToWindow();
+ HTMLParserPrefsView(BRect frame,
+ const char* name);
+ virtual void AttachedToWindow();
+
};
@@ -100,14 +100,17 @@
*/
-class CSSParserPrefsView : public BasePrefsView
-{
+class CSSParserPrefsView : public BasePrefsView {
+
+ private:
+ BPopUpMenu * mPopUpMenu;
+ BString mCSSDir;
+
public:
- CSSParserPrefsView(
- BRect frame,
- const char* name );
-
- virtual void AttachedToWindow();
+ CSSParserPrefsView(BRect frame,
+ const char* name);
+ virtual void AttachedToWindow();
+
};
/*
@@ -115,14 +118,12 @@
*/
-class RendererPrefsView : public BasePrefsView
-{
+class RendererPrefsView : public BasePrefsView {
+
public:
- RendererPrefsView(
- BRect frame,
- const char* name );
+ RendererPrefsView(BRect frame,
+ const char* name);
- virtual void AttachedToWindow();
};
#endif
Modified: trunk/themis/framework/PrefsWin.cpp
===================================================================
--- trunk/themis/framework/PrefsWin.cpp 2010-08-24 19:25:15 UTC (rev 548)
+++ trunk/themis/framework/PrefsWin.cpp 2010-08-24 22:35:43 UTC (rev 549)
@@ -49,7 +49,7 @@
Bounds(),
"BackgroundView",
B_FOLLOW_ALL,
- 0 );
+ 0);
AddChild(fBackgroundView);
fBackgroundView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@@ -66,11 +66,52 @@
rect.InsetBy(kItemSpacing, kItemSpacing);
rect.left = fPrefsListView->Frame().right + kItemSpacing;
fViewFrame = rect;
+
+ CreatePrefViews();
Show();
}
+PrefsWin :: ~PrefsWin() {
+
+ if (fCurrentPrefsView) {
+ fCurrentPrefsView->RemoveSelf();
+ fCurrentPrefsView = NULL;
+ }
+ printf("Deleting preferences views\n");
+ for (unsigned int i = 0; i < mPrefViews.size(); i++) {
+ delete mPrefViews[i];
+ }
+
+}
+
+void PrefsWin :: CreatePrefViews() {
+
+ printf("Creating preferences views\n");
+
+ mPrefViews.push_back(
+ new WindowPrefsView(fViewFrame,
+ kPrefsItems[0].name));
+ mPrefViews.push_back(
+ new NetworkPrefsView(fViewFrame,
+ kPrefsItems[1].name));
+ mPrefViews.push_back(
+ new PrivacyPrefsView(fViewFrame,
+ kPrefsItems[2].name));
+ mPrefViews.push_back(
+ new HTMLParserPrefsView(fViewFrame,
+ kPrefsItems[3].name));
+ mPrefViews.push_back(
+ new CSSParserPrefsView(fViewFrame,
+ kPrefsItems[4].name));
+ mPrefViews.push_back(
+ new RendererPrefsView(fViewFrame,
+ kPrefsItems[5].name));
+
+
+}
+
void PrefsWin :: MessageReceived(BMessage* msg) {
switch(msg->what) {
@@ -82,72 +123,21 @@
* but the BListView does take away the focus from the curent
* selected item. So reselect it again. :/
*/
- if(selection < 0)
+ if(selection < 0) {
fPrefsListView->Select(fLastSelection);
-
- if(selection == fLastSelection)
- break;
- else
- fLastSelection = selection;
-
- if(fCurrentPrefsView) {
- fCurrentPrefsView->RemoveSelf();
- delete fCurrentPrefsView;
- fCurrentPrefsView = NULL;
}
-
- /* find the prefs_view_const */
- enum prefs_view_const pvconst = kPrefsItems[selection].pvconst;
-
- switch(pvconst) {
- case PREFSVIEW_WINDOW: {
- fCurrentPrefsView = new WindowPrefsView(
- fViewFrame,
- kPrefsItems[selection].name);
- fBackgroundView->AddChild(fCurrentPrefsView);
+ else {
+ if(selection != fLastSelection) {
+ fLastSelection = selection;
+
+ if (fCurrentPrefsView) {
+ fCurrentPrefsView->RemoveSelf();
+ fCurrentPrefsView = NULL;
+ }
- break;
- }
- case PREFSVIEW_NETWORK: {
- fCurrentPrefsView = new NetworkPrefsView(
- fViewFrame,
- kPrefsItems[selection].name);
+ fCurrentPrefsView = mPrefViews[selection];
fBackgroundView->AddChild(fCurrentPrefsView);
-
- break;
}
- case PREFSVIEW_PRIVACY: {
- fCurrentPrefsView = new PrivacyPrefsView(
- fViewFrame,
- kPrefsItems[selection].name);
- fBackgroundView->AddChild(fCurrentPrefsView);
-
- break;
- }
- case PREFSVIEW_HTMLPARSER: {
- fCurrentPrefsView = new HTMLParserPrefsView(
- fViewFrame,
- kPrefsItems[selection].name);
- fBackgroundView->AddChild(fCurrentPrefsView);
-
- break;
- }
- case PREFSVIEW_CSSPARSER: {
- fCurrentPrefsView = new CSSParserPrefsView(
- fViewFrame,
- kPrefsItems[selection].name);
- fBackgroundView->AddChild(fCurrentPrefsView);
-
- break;
- }
- case PREFSVIEW_RENDERER: {
- fCurrentPrefsView = new RendererPrefsView(
- fViewFrame,
- kPrefsItems[selection].name);
- fBackgroundView->AddChild(fCurrentPrefsView);
-
- break;
- }
}
break;
Modified: trunk/themis/framework/PrefsWin.h
===================================================================
--- trunk/themis/framework/PrefsWin.h 2010-08-24 19:25:15 UTC (rev 548)
+++ trunk/themis/framework/PrefsWin.h 2010-08-24 22:35:43 UTC (rev 549)
@@ -10,6 +10,13 @@
#include <View.h>
#include <Window.h>
+// C++ headers
+#include <vector>
+
+// Namespaces used
+using std::vector;
+
+// Declarations
class PrefsListView;
class PrefsWin : public BWindow {
@@ -20,11 +27,14 @@
BView * fCurrentPrefsView;
int32 fLastSelection;
BRect fViewFrame;
-
+ vector<BView *> mPrefViews;
+
+ void CreatePrefViews();
void SaveAppSettings();
public:
PrefsWin(BRect frame);
+ virtual ~PrefsWin();
virtual void MessageReceived(BMessage* msg);
virtual bool QuitRequested();
@@ -67,6 +77,7 @@
#ifndef PREFSLISTITEM
#define PREFSLISTITEM
+// BeOS headers
#include <Bitmap.h>
#include <ListItem.h>
@@ -75,7 +86,7 @@
private:
const char * fName;
BBitmap * fBitmap;
- float fFontHeight;
+ float fFontHeight;
public:
PrefsListItem(const char* name,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|