Fixed side lists, clean up

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8287 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2004-07-03 17:51:51 +00:00
parent 07587c7b9f
commit 4a92b80d78
4 changed files with 83 additions and 104 deletions
+3 -5
View File
@@ -1,11 +1,9 @@
SubDir OBOS_TOP src prefs keymap ; SubDir OBOS_TOP src prefs keymap ;
AddResources Keymap : Keymap.rsrc ; AddResources Keymap : Keymap.rdef ;
Preference Keymap : Preference Keymap :
main.cpp
KeymapApplication.cpp KeymapApplication.cpp
KeymapWindow.cpp KeymapWindow.cpp
KeymapListItem.cpp ; KeymapListItem.cpp
: be ;
LinkSharedOSLibs Keymap : be ;
+9
View File
@@ -180,3 +180,12 @@ int KeymapApplication::NotifyInputServer()
system("kill -KILL input_server"); system("kill -KILL input_server");
return B_NO_ERROR; return B_NO_ERROR;
} }
int main ()
{
new KeymapApplication;
be_app->Run();
delete be_app;
return 0;
}
+70 -99
View File
@@ -1,15 +1,14 @@
#include <app/Application.h> #include <Alert.h>
#include <interface/View.h> #include <Application.h>
#include <interface/GraphicsDefs.h> #include <Box.h>
#include <interface/MenuItem.h> #include <Button.h>
#include <interface/ListView.h> #include <Debug.h>
#include <interface/ScrollView.h> #include <GraphicsDefs.h>
#include <interface/Button.h> #include <ListView.h>
#include <interface/Alert.h> #include <MenuItem.h>
#include <interface/Box.h> #include <ScrollView.h>
#ifdef DEBUG #include <StringView.h>
#include <stdio.h> #include <View.h>
#endif //DEBUG
#include "KeymapWindow.h" #include "KeymapWindow.h"
#include "KeymapListItem.h" #include "KeymapListItem.h"
#include "KeymapApplication.h" #include "KeymapApplication.h"
@@ -54,7 +53,9 @@ KeymapWindow::KeymapWindow( BRect frame )
} }
BMenuBar * KeymapWindow::AddMenuBar()
BMenuBar *
KeymapWindow::AddMenuBar()
{ {
BRect bounds; BRect bounds;
BMenu *menu; BMenu *menu;
@@ -103,86 +104,44 @@ BMenuBar * KeymapWindow::AddMenuBar()
// Create the Font menu // Create the Font menu
menu = new BMenu( "Font" ); menu = new BMenu( "Font" );
int32 numFamilies = count_font_families();
font_family family, current_family;
font_style current_style;
uint32 flags;
be_plain_font->GetFamilyAndStyle(&current_family, &current_style);
for ( int32 i = 0; i < numFamilies; i++ )
if ( get_font_family(i, &family, &flags) == B_OK ) {
BMenuItem *item =
new BMenuItem(family, new BMessage( MENU_FONT_CHANGED));
menu->AddItem(item);
if(strcmp(family, current_family) == 0)
item->SetMarked(true);
}
menubar->AddItem( menu ); menubar->AddItem( menu );
return menubar; return menubar;
} }
void KeymapWindow::AddMaps()
void
KeymapWindow::AddMaps()
{ {
BBox *mapsBox;
BRect bounds;
BList *entryList;
BList *listItems;
KeymapListItem *currentKeymapItem;
// The Maps box // The Maps box
bounds = BRect( 9,11, 140, 227 ); BRect bounds = BRect(9,11,140,226);
mapsBox = new BBox( bounds ); BBox *mapsBox = new BBox(bounds);
mapsBox->SetLabel( "Maps" ); mapsBox->SetLabel("Maps");
fPlaceholderView->AddChild( mapsBox ); fPlaceholderView->AddChild( mapsBox );
/*
// Set drawing mode to B_OP_COPY
mapsBox->SetDrawingMode( B_OP_COPY );
// Set mapsBox->LowColor to background color
rgb_color tempColor;
tempColor = ui_color( B_MENU_BACKGROUND_COLOR );
mapsBox->SetLowColor( tempColor );
// Set mapsBox->HighColor to black
tempColor.red = 0;
tempColor.green = 0;
tempColor.blue = 0;
tempColor.alpha = 0;
mapsBox->SetHighColor( tempColor );
// Set font to something nice
BFont *font = new BFont();
font->SetFace( B_REGULAR_FACE );
// font->SetFamilyAndStyle();
font->SetRotation( 0.0 );
font->SetShear( 90.0 );
font->SetSize( 12.0 );
font->SetSpacing( B_BITMAP_SPACING );
mapsBox->SetFont( font );
*/
// The System list // The System list
bounds = BRect( 209,20, 370,135 ); BStringView *systemLabel = new BStringView(BRect(13,13,113,33), "system", "System");
/* mapsBox->AddChild(systemLabel);
BView *textSystem = new BView( bounds, NULL, B_NOT_RESIZABLE, 0 );
rgb_color tempColor; bounds = BRect( 13,35, 103,105 );
tempColor = ui_color( B_MENU_BACKGROUND_COLOR ); BList *entryList = fApplication->SystemMaps();
*/
/*
tempColor.red = 0;
tempColor.green = 0;
tempColor.blue = 0;
tempColor.alpha = 0;
*/
// textSystem->SetViewColor( tempColor );
// textSystem->SetLowColor( tempColor );
/*
tempColor.red = 0;
tempColor.green = 0;
tempColor.blue = 0;
tempColor.alpha = 0;
textSystem->SetHighColor( tempColor );
tempColor.red = 0;
tempColor.green = 0;
tempColor.blue = 0;
tempColor.alpha = 0;
textSystem->SetLowColor( tempColor );
textSystem->DrawString( "System", BPoint( 0, 14 ) );
fPlaceholderView->AddChild( textSystem );
*/
bounds = BRect( 13,36, 103,106 );
entryList = fApplication->SystemMaps();
fSystemListView = new BListView( bounds, "systemList" ); fSystemListView = new BListView( bounds, "systemList" );
listItems = ListItemsFromEntryList( entryList ); BList *listItems = ListItemsFromEntryList( entryList );
fSystemListView->AddList( listItems ); fSystemListView->AddList( listItems );
mapsBox->AddChild( new BScrollView( "systemScrollList", fSystemListView, mapsBox->AddChild( new BScrollView( "systemScrollList", fSystemListView,
B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true )); B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true ));
@@ -191,12 +150,14 @@ void KeymapWindow::AddMaps()
delete entryList; delete entryList;
// The User list // The User list
mapsBox->DrawString( "User", BPoint( 13, 113 )); BStringView *userLabel = new BStringView(BRect(13,110,113,128), "user", "User");
bounds = BRect( 13,129, 103,199 ); mapsBox->AddChild(userLabel);
bounds = BRect(13,130,103,200);
entryList = fApplication->UserMaps(); entryList = fApplication->UserMaps();
fUserListView = new BListView( bounds, "userList" ); fUserListView = new BListView( bounds, "userList" );
// '(Current)' // '(Current)'
currentKeymapItem = ItemFromEntry( fApplication->CurrentMap() ); KeymapListItem *currentKeymapItem = ItemFromEntry( fApplication->CurrentMap() );
if( currentKeymapItem != NULL ) if( currentKeymapItem != NULL )
fUserListView->AddItem( currentKeymapItem ); fUserListView->AddItem( currentKeymapItem );
// Saved keymaps // Saved keymaps
@@ -209,7 +170,9 @@ void KeymapWindow::AddMaps()
delete entryList; delete entryList;
} }
BList* KeymapWindow::ListItemsFromEntryList( BList * entryList)
BList*
KeymapWindow::ListItemsFromEntryList( BList * entryList)
{ {
BEntry *currentEntry; BEntry *currentEntry;
BList *listItems; BList *listItems;
@@ -233,7 +196,9 @@ BList* KeymapWindow::ListItemsFromEntryList( BList * entryList)
return listItems; return listItems;
} }
KeymapListItem* KeymapWindow::ItemFromEntry( BEntry *entry )
KeymapListItem*
KeymapWindow::ItemFromEntry( BEntry *entry )
{ {
KeymapListItem *item; KeymapListItem *item;
@@ -247,13 +212,17 @@ KeymapListItem* KeymapWindow::ItemFromEntry( BEntry *entry )
return item; return item;
} }
bool KeymapWindow::QuitRequested()
bool
KeymapWindow::QuitRequested()
{ {
be_app->PostMessage( B_QUIT_REQUESTED ); be_app->PostMessage( B_QUIT_REQUESTED );
return true; return true;
} }
void KeymapWindow::MessageReceived( BMessage* message )
void
KeymapWindow::MessageReceived( BMessage* message )
{ {
switch( message->what ) { switch( message->what ) {
case MENU_FILE_OPEN: case MENU_FILE_OPEN:
@@ -292,23 +261,23 @@ void KeymapWindow::MessageReceived( BMessage* message )
} }
} }
void KeymapWindow::HandleSystemMapSelected( BMessage *selectionMessage )
void
KeymapWindow::HandleSystemMapSelected( BMessage *selectionMessage )
{ {
#if DEBUG
printf("System map selected\n");
#endif //DEBUG
HandleMapSelected( selectionMessage, fSystemListView, fUserListView ); HandleMapSelected( selectionMessage, fSystemListView, fUserListView );
} }
void KeymapWindow::HandleUserMapSelected( BMessage *selectionMessage )
void
KeymapWindow::HandleUserMapSelected( BMessage *selectionMessage )
{ {
#if DEBUG
printf("User map selected\n");
#endif //DEBUG
HandleMapSelected( selectionMessage, fUserListView, fSystemListView ); HandleMapSelected( selectionMessage, fUserListView, fSystemListView );
} }
void KeymapWindow::HandleMapSelected( BMessage *selectionMessage,
void
KeymapWindow::HandleMapSelected( BMessage *selectionMessage,
BListView * selectedView, BListView * otherView ) BListView * selectedView, BListView * otherView )
{ {
int32 index; int32 index;
@@ -339,7 +308,9 @@ void KeymapWindow::HandleMapSelected( BMessage *selectionMessage,
otherView->DeselectAll(); otherView->DeselectAll();
} }
void KeymapWindow::UseKeymap()
void
KeymapWindow::UseKeymap()
{ {
if( fSelectedMap != NULL ) if( fSelectedMap != NULL )
fApplication->UseKeymap( fSelectedMap ); fApplication->UseKeymap( fSelectedMap );
+1
View File
@@ -10,6 +10,7 @@
#define MENU_EDIT_PASTE 'mMEV' #define MENU_EDIT_PASTE 'mMEV'
#define MENU_EDIT_CLEAR 'mMEL' #define MENU_EDIT_CLEAR 'mMEL'
#define MENU_EDIT_SELECT_ALL 'mMEA' #define MENU_EDIT_SELECT_ALL 'mMEA'
#define MENU_FONT_CHANGED 'mMFC'
#define SYSTEM_MAP_SELECTED 'SmST' #define SYSTEM_MAP_SELECTED 'SmST'
#define USER_MAP_SELECTED 'UmST' #define USER_MAP_SELECTED 'UmST'
#define USE_KEYMAP 'UkyM' #define USE_KEYMAP 'UkyM'