Initial Checkin - Basic GUI with Menu 10% - Coded by Sikosis
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2866 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
cb82985296
commit
333dca6673
71
src/prefs/devices/Devices.cpp
Normal file
71
src/prefs/devices/Devices.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
|
||||
Devices by Sikosis
|
||||
|
||||
(C)2003 OBOS
|
||||
|
||||
*/
|
||||
|
||||
// Includes -------------------------------------------------------------------------------------------------- //
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Button.h>
|
||||
#include <Deskbar.h>
|
||||
#include <Entry.h>
|
||||
#include <File.h>
|
||||
#include <FilePanel.h>
|
||||
#include <ListView.h>
|
||||
#include <Path.h>
|
||||
#include <Screen.h>
|
||||
#include <ScrollView.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
|
||||
#include "Devices.h"
|
||||
#include "DevicesWindows.h"
|
||||
#include "DevicesViews.h"
|
||||
#include "DevicesConstants.h"
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
DevicesWindow *ptrDevicesWindow;
|
||||
|
||||
// Devices -- constructor
|
||||
Devices::Devices() : BApplication (APP_SIGNATURE)
|
||||
{
|
||||
// Default Window Size - even though we centre the form to the current screen size
|
||||
BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());
|
||||
|
||||
float FormTopDefault = 0;
|
||||
float FormLeftDefault = 0;
|
||||
float FormWidthDefault = 396;
|
||||
float FormHeightDefault = 400;
|
||||
|
||||
BRect DevicesWindowRect(FormTopDefault,FormLeftDefault,FormLeftDefault+FormWidthDefault,FormTopDefault+FormHeightDefault);
|
||||
|
||||
ptrDevicesWindow = new DevicesWindow(DevicesWindowRect);
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// Devices::MessageReceived -- handles incoming messages
|
||||
void Devices::MessageReceived (BMessage *message)
|
||||
{
|
||||
switch(message->what)
|
||||
{
|
||||
default:
|
||||
BApplication::MessageReceived(message); // pass it along ...
|
||||
break;
|
||||
}
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
// Devices Main
|
||||
int main(void)
|
||||
{
|
||||
Devices theApp;
|
||||
theApp.Run();
|
||||
return 0;
|
||||
}
|
||||
// end ------------------------------------------------------------------------------------------------------ //
|
24
src/prefs/devices/Devices.h
Normal file
24
src/prefs/devices/Devices.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
|
||||
Devices Header by Sikosis
|
||||
|
||||
(C)2003 OBOS
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __DEVICES_H__
|
||||
#define __DEVICES_H__
|
||||
|
||||
extern const char *APP_SIGNATURE;
|
||||
|
||||
class Devices : public BApplication
|
||||
{
|
||||
public:
|
||||
Devices();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
BIN
src/prefs/devices/Devices.rsrc
Normal file
BIN
src/prefs/devices/Devices.rsrc
Normal file
Binary file not shown.
15
src/prefs/devices/DevicesConstants.h
Normal file
15
src/prefs/devices/DevicesConstants.h
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
|
||||
Devices Constants by Sikosis
|
||||
|
||||
(C)2003
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __DEVICESCONSTANTS_H__
|
||||
#define __DEVICESCONSTANTS_H__
|
||||
|
||||
// Constants ------------------------------------------------------------------------------------------------- //
|
||||
const char *APP_SIGNATURE = "application/x-vnd.OBOS.Devices"; // Application Signature and Title
|
||||
|
||||
#endif
|
36
src/prefs/devices/DevicesViews.cpp
Normal file
36
src/prefs/devices/DevicesViews.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
|
||||
DevicesViews by Sikosis
|
||||
|
||||
(C)2003 OBOS
|
||||
|
||||
*/
|
||||
|
||||
// Includes -------------------------------------------------------------------------------------------------- //
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Screen.h>
|
||||
#include <stdio.h>
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
|
||||
#include "DevicesWindows.h"
|
||||
#include "DevicesViews.h"
|
||||
//#include "DevicesConstants.h"
|
||||
// ------------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
// DevicesView - Constructor
|
||||
DevicesView::DevicesView (BRect frame) : BView (frame, "DevicesView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW )
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
void DevicesView::Draw(BRect updateRect)
|
||||
{
|
||||
BRect r;
|
||||
r = Bounds();
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
22
src/prefs/devices/DevicesViews.h
Normal file
22
src/prefs/devices/DevicesViews.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
|
||||
Devices Views Header by Sikosis
|
||||
|
||||
(C)2003 OBOS
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __DEVICESVIEWS_H__
|
||||
#define __DEVICESVIEWS_H__
|
||||
|
||||
#include "Devices.h"
|
||||
#include "DevicesWindows.h"
|
||||
|
||||
class DevicesView : public BView
|
||||
{
|
||||
public:
|
||||
DevicesView(BRect frame);
|
||||
virtual void Draw(BRect updateRect);
|
||||
};
|
||||
|
||||
#endif
|
149
src/prefs/devices/DevicesWindow.cpp
Normal file
149
src/prefs/devices/DevicesWindow.cpp
Normal file
@ -0,0 +1,149 @@
|
||||
/*
|
||||
|
||||
Devices - DevicesWindow by Sikosis
|
||||
|
||||
(C)2003 OBOS
|
||||
|
||||
*/
|
||||
|
||||
|
||||
// Includes -------------------------------------------------------------------------------------------------- //
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Button.h>
|
||||
#include <MenuBar.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Path.h>
|
||||
#include <Screen.h>
|
||||
#include <ScrollView.h>
|
||||
#include <Shape.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <StringView.h>
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
#include "Devices.h"
|
||||
#include "DevicesViews.h"
|
||||
#include "DevicesWindows.h"
|
||||
|
||||
const uint32 MENU_FILE_ABOUT_DEVICES = 'mfad';
|
||||
const uint32 MENU_FILE_QUIT = 'mfqt';
|
||||
const uint32 MENU_DEVICES_REMOVE_JUMPERED_DEVICE = 'mdrj';
|
||||
const uint32 MENU_DEVICES_NEW_JUMPERED_DEVICE = 'mdnj';
|
||||
const uint32 MENU_DEVICES_RESOURCE_USAGE = 'mdru';
|
||||
|
||||
|
||||
// CenterWindowOnScreen -- Centers the BWindow to the Current Screen
|
||||
static void CenterWindowOnScreen(BWindow* w)
|
||||
{
|
||||
BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());
|
||||
BPoint pt;
|
||||
pt.x = screenFrame.Width()/2 - w->Bounds().Width()/2;
|
||||
pt.y = screenFrame.Height()/2 - w->Bounds().Height()/2;
|
||||
|
||||
if (screenFrame.Contains(pt))
|
||||
w->MoveTo(pt);
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// DevicesWindow - Constructor
|
||||
DevicesWindow::DevicesWindow(BRect frame) : BWindow (frame, "OBOS Devices Alpha", B_TITLED_WINDOW, B_NORMAL_WINDOW_FEEL , 0)
|
||||
{
|
||||
InitWindow();
|
||||
CenterWindowOnScreen(this);
|
||||
Show();
|
||||
}
|
||||
|
||||
|
||||
// DevicesWindow - Destructor
|
||||
DevicesWindow::~DevicesWindow()
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
// DevicesWindow::InitWindow -- Initialization Commands here
|
||||
void DevicesWindow::InitWindow(void)
|
||||
{
|
||||
int LeftMargin = 16;
|
||||
int RightMargin = 246;
|
||||
BRect r;
|
||||
r = Bounds(); // the whole view
|
||||
|
||||
BMenu *FileMenu;
|
||||
BMenu *DevicesMenu;
|
||||
|
||||
// Add the menu bar
|
||||
menubar = new BMenuBar(r, "menu_bar");
|
||||
|
||||
// Add File menu to menu bar
|
||||
FileMenu = new BMenu("File");
|
||||
FileMenu->AddItem(new BMenuItem("About Devices" B_UTF8_ELLIPSIS, new BMessage(MENU_FILE_ABOUT_DEVICES), NULL));
|
||||
FileMenu->AddSeparatorItem();
|
||||
FileMenu->AddItem(new BMenuItem("Quit", new BMessage(MENU_FILE_QUIT), 'Q'));
|
||||
|
||||
DevicesMenu = new BMenu("Devices");
|
||||
DevicesMenu->AddItem(new BMenuItem("New Jumpered Device", new BMessage(MENU_DEVICES_NEW_JUMPERED_DEVICE), NULL));
|
||||
DevicesMenu->AddItem(new BMenuItem("Remove Jumpered Device", new BMessage(MENU_DEVICES_REMOVE_JUMPERED_DEVICE), 'R'));
|
||||
DevicesMenu->AddSeparatorItem();
|
||||
DevicesMenu->AddItem(new BMenuItem("Resource Usage", new BMessage(MENU_DEVICES_RESOURCE_USAGE), 'U'));
|
||||
|
||||
menubar->AddItem(FileMenu);
|
||||
menubar->AddItem(DevicesMenu);
|
||||
|
||||
stvDeviceName = new BStringView(BRect(LeftMargin, 16, 150, 40), "DeviceName", "Device Name");
|
||||
stvCurrentState = new BStringView(BRect(RightMargin, 16, r.right-10, 40), "CurrentState", "Current State");
|
||||
|
||||
// Create a basic View
|
||||
AddChild(ptrDevicesView = new DevicesView(r));
|
||||
|
||||
ptrDevicesView->AddChild(menubar);
|
||||
ptrDevicesView->AddChild(stvDeviceName);
|
||||
ptrDevicesView->AddChild(stvCurrentState);
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// DevicesWindow::FrameResized
|
||||
void DevicesWindow::FrameResized (float width, float height)
|
||||
{
|
||||
BRect r;
|
||||
r = Bounds();
|
||||
|
||||
// enforce width but not height
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// DevicesWindow::QuitRequested -- Post a message to the app to quit
|
||||
bool DevicesWindow::QuitRequested()
|
||||
{
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// DevicesWindow::MessageReceived -- receives messages
|
||||
void DevicesWindow::MessageReceived (BMessage *message)
|
||||
{
|
||||
switch(message->what)
|
||||
{
|
||||
case MENU_FILE_ABOUT_DEVICES:
|
||||
(new BAlert("", "Devices\n\n\t'Just write a simple app to add a jumpered\n\tdevice to the system', he said.\n\n\tAnd many years later another he said\n\t'recreate it' ;)", "OK"))->Go();
|
||||
break;
|
||||
case MENU_FILE_QUIT:
|
||||
QuitRequested();
|
||||
break;
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
35
src/prefs/devices/DevicesWindows.h
Normal file
35
src/prefs/devices/DevicesWindows.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
|
||||
Devices Windows Header by Sikosis
|
||||
|
||||
(C)2003 OBOS
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __DEVICESWINDOWS_H__
|
||||
#define __DEVICESWINDOWS_H__
|
||||
|
||||
#include "Devices.h"
|
||||
#include "DevicesViews.h"
|
||||
|
||||
class DevicesView;
|
||||
|
||||
class DevicesWindow : public BWindow
|
||||
{
|
||||
public:
|
||||
DevicesWindow(BRect frame);
|
||||
~DevicesWindow();
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void FrameResized(float width, float height);
|
||||
private:
|
||||
void InitWindow(void);
|
||||
|
||||
BStringView *stvDeviceName;
|
||||
BStringView *stvCurrentState;
|
||||
BMenuBar *menubar;
|
||||
|
||||
DevicesView* ptrDevicesView;
|
||||
};
|
||||
|
||||
#endif
|
13
src/prefs/devices/Jamfile
Normal file
13
src/prefs/devices/Jamfile
Normal file
@ -0,0 +1,13 @@
|
||||
SubDir OBOS_TOP src prefs devices ;
|
||||
|
||||
AddResources Devices : Devices.rsrc ;
|
||||
|
||||
UsePrivateHeaders Devices ;
|
||||
|
||||
Preference Devices :
|
||||
Devices.cpp
|
||||
DevicesWindow.cpp
|
||||
DevicesViews.cpp
|
||||
;
|
||||
|
||||
LinkSharedOSLibs Devices : be ;
|
Loading…
Reference in New Issue
Block a user