diff --git a/src/prefs/keymap/Jamfile b/src/prefs/keymap/Jamfile index d11a4c203f..38384c415d 100644 --- a/src/prefs/keymap/Jamfile +++ b/src/prefs/keymap/Jamfile @@ -1,11 +1,9 @@ SubDir OBOS_TOP src prefs keymap ; -AddResources Keymap : Keymap.rsrc ; +AddResources Keymap : Keymap.rdef ; Preference Keymap : - main.cpp KeymapApplication.cpp KeymapWindow.cpp - KeymapListItem.cpp ; - -LinkSharedOSLibs Keymap : be ; + KeymapListItem.cpp + : be ; diff --git a/src/prefs/keymap/KeymapApplication.cpp b/src/prefs/keymap/KeymapApplication.cpp index 592122b713..953f7f4ab6 100644 --- a/src/prefs/keymap/KeymapApplication.cpp +++ b/src/prefs/keymap/KeymapApplication.cpp @@ -180,3 +180,12 @@ int KeymapApplication::NotifyInputServer() system("kill -KILL input_server"); return B_NO_ERROR; } + + +int main () +{ + new KeymapApplication; + be_app->Run(); + delete be_app; + return 0; +} diff --git a/src/prefs/keymap/KeymapWindow.cpp b/src/prefs/keymap/KeymapWindow.cpp index c6c57e3adc..918b5e4652 100644 --- a/src/prefs/keymap/KeymapWindow.cpp +++ b/src/prefs/keymap/KeymapWindow.cpp @@ -1,15 +1,14 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef DEBUG - #include -#endif //DEBUG +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "KeymapWindow.h" #include "KeymapListItem.h" #include "KeymapApplication.h" @@ -54,7 +53,9 @@ KeymapWindow::KeymapWindow( BRect frame ) } -BMenuBar * KeymapWindow::AddMenuBar() + +BMenuBar * +KeymapWindow::AddMenuBar() { BRect bounds; BMenu *menu; @@ -103,86 +104,44 @@ BMenuBar * KeymapWindow::AddMenuBar() // Create the Font menu menu = new BMenu( "Font" ); + int32 numFamilies = count_font_families(); + font_family family, current_family; + font_style current_style; + uint32 flags; + be_plain_font->GetFamilyAndStyle(¤t_family, ¤t_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 ); return menubar; } -void KeymapWindow::AddMaps() + +void +KeymapWindow::AddMaps() { - BBox *mapsBox; - BRect bounds; - BList *entryList; - BList *listItems; - KeymapListItem *currentKeymapItem; - // The Maps box - bounds = BRect( 9,11, 140, 227 ); - mapsBox = new BBox( bounds ); - mapsBox->SetLabel( "Maps" ); + BRect bounds = BRect(9,11,140,226); + BBox *mapsBox = new BBox(bounds); + mapsBox->SetLabel("Maps"); 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 - bounds = BRect( 209,20, 370,135 ); -/* - BView *textSystem = new BView( bounds, NULL, B_NOT_RESIZABLE, 0 ); - rgb_color tempColor; - tempColor = ui_color( B_MENU_BACKGROUND_COLOR ); -*/ -/* - 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(); + BStringView *systemLabel = new BStringView(BRect(13,13,113,33), "system", "System"); + mapsBox->AddChild(systemLabel); + + bounds = BRect( 13,35, 103,105 ); + BList *entryList = fApplication->SystemMaps(); fSystemListView = new BListView( bounds, "systemList" ); - listItems = ListItemsFromEntryList( entryList ); + BList *listItems = ListItemsFromEntryList( entryList ); fSystemListView->AddList( listItems ); mapsBox->AddChild( new BScrollView( "systemScrollList", fSystemListView, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true )); @@ -191,12 +150,14 @@ void KeymapWindow::AddMaps() delete entryList; // The User list - mapsBox->DrawString( "User", BPoint( 13, 113 )); - bounds = BRect( 13,129, 103,199 ); + BStringView *userLabel = new BStringView(BRect(13,110,113,128), "user", "User"); + mapsBox->AddChild(userLabel); + + bounds = BRect(13,130,103,200); entryList = fApplication->UserMaps(); fUserListView = new BListView( bounds, "userList" ); // '(Current)' - currentKeymapItem = ItemFromEntry( fApplication->CurrentMap() ); + KeymapListItem *currentKeymapItem = ItemFromEntry( fApplication->CurrentMap() ); if( currentKeymapItem != NULL ) fUserListView->AddItem( currentKeymapItem ); // Saved keymaps @@ -209,7 +170,9 @@ void KeymapWindow::AddMaps() delete entryList; } -BList* KeymapWindow::ListItemsFromEntryList( BList * entryList) + +BList* +KeymapWindow::ListItemsFromEntryList( BList * entryList) { BEntry *currentEntry; BList *listItems; @@ -233,7 +196,9 @@ BList* KeymapWindow::ListItemsFromEntryList( BList * entryList) return listItems; } -KeymapListItem* KeymapWindow::ItemFromEntry( BEntry *entry ) + +KeymapListItem* +KeymapWindow::ItemFromEntry( BEntry *entry ) { KeymapListItem *item; @@ -247,13 +212,17 @@ KeymapListItem* KeymapWindow::ItemFromEntry( BEntry *entry ) return item; } -bool KeymapWindow::QuitRequested() + +bool +KeymapWindow::QuitRequested() { be_app->PostMessage( B_QUIT_REQUESTED ); return true; } -void KeymapWindow::MessageReceived( BMessage* message ) + +void +KeymapWindow::MessageReceived( BMessage* message ) { switch( message->what ) { 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 ); } -void KeymapWindow::HandleUserMapSelected( BMessage *selectionMessage ) + +void +KeymapWindow::HandleUserMapSelected( BMessage *selectionMessage ) { - #if DEBUG - printf("User map selected\n"); - #endif //DEBUG HandleMapSelected( selectionMessage, fUserListView, fSystemListView ); } -void KeymapWindow::HandleMapSelected( BMessage *selectionMessage, + +void +KeymapWindow::HandleMapSelected( BMessage *selectionMessage, BListView * selectedView, BListView * otherView ) { int32 index; @@ -339,7 +308,9 @@ void KeymapWindow::HandleMapSelected( BMessage *selectionMessage, otherView->DeselectAll(); } -void KeymapWindow::UseKeymap() + +void +KeymapWindow::UseKeymap() { if( fSelectedMap != NULL ) fApplication->UseKeymap( fSelectedMap ); diff --git a/src/prefs/keymap/messages.h b/src/prefs/keymap/messages.h index c1bbd3424e..326d85c727 100644 --- a/src/prefs/keymap/messages.h +++ b/src/prefs/keymap/messages.h @@ -10,6 +10,7 @@ #define MENU_EDIT_PASTE 'mMEV' #define MENU_EDIT_CLEAR 'mMEL' #define MENU_EDIT_SELECT_ALL 'mMEA' +#define MENU_FONT_CHANGED 'mMFC' #define SYSTEM_MAP_SELECTED 'SmST' #define USER_MAP_SELECTED 'UmST' #define USE_KEYMAP 'UkyM'