Files
haiku-beta6/src/prefs/devices/ModemWindow.cpp
T
Phil Greenway 92430c9c7e Added the frame to the modemwindow and the button placement.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4528 a95241bf-73f2-0310-859d-f6bbb57e9c96
2003-09-07 21:12:16 +00:00

119 lines
3.2 KiB
C++
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
ModemWindow
Author: Sikosis
(C)2003 OBOS - Released under the MIT License
*/
// Includes ------------------------------------------------------------------------------------------ //
#include <Application.h>
#include <Box.h>
#include <Button.h>
#include <Path.h>
#include <Screen.h>
#include <stdio.h>
#include <String.h>
#include <Window.h>
#include <View.h>
#include "Devices.h"
#include "DevicesWindows.h"
#include "DevicesViews.h"
// -------------------------------------------------------------------------------------------------- //
const uint32 BTN_ADD = 'badd';
const uint32 BTN_CANCEL = 'bcnl';
// 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);
}
// -------------------------------------------------------------------------------------------------- //
// ModemWindow - Constructor
ModemWindow::ModemWindow(BRect frame) : BWindow (frame, "ModemWindow", B_MODAL_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, 0)
{
InitWindow();
CenterWindowOnScreen(this);
Show();
}
// -------------------------------------------------------------------------------------------------- //
// ModemWindow - Destructor
ModemWindow::~ModemWindow()
{
//exit(0);
}
// -------------------------------------------------------------------------------------------------- //
/*BBox(BRect frame, const char *name = NULL,
  
    uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
      uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | 
            B_NAVIGABLE_JUMP,
      border_style border = B_FANCY_BORDER)*/
// ModemWindow::InitWindow -- Initialization Commands here
void ModemWindow::InitWindow(void)
{
BRect r;
r = Bounds();
boxInternalModem = new BBox(BRect (r.left+10,r.top+15,r.right-10,r.bottom-50),
" Internal Modem ", B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW, B_FANCY_BORDER);
BRect CancelButtonRect(24,r.bottom-37,100,r.bottom-13);
btnCancel = new BButton(CancelButtonRect,"btnCancel","Cancel",
new BMessage(BTN_CANCEL), B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW | B_NAVIGABLE);
BRect AddButtonRect(115,r.bottom-37,r.right - 10,r.bottom-13);
btnAdd = new BButton(AddButtonRect,"btnAdd","Add",
new BMessage(BTN_ADD), B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW | B_NAVIGABLE);
btnAdd->MakeDefault(true);
// Create the Views
AddChild(ptrModemView = new ModemView(r));
ptrModemView->AddChild(boxInternalModem);
ptrModemView->AddChild(btnCancel);
ptrModemView->AddChild(btnAdd);
}
// -------------------------------------------------------------------------------------------------- //
// ModemWindow::MessageReceived -- receives messages
void ModemWindow::MessageReceived (BMessage *message)
{
switch(message->what)
{
case BTN_CANCEL:
{
Quit();
}
break;
default:
BWindow::MessageReceived(message);
break;
}
}
// -------------------------------------------------------------------------------------------------- //