Updated by Mark Hogben <[email protected]>

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8142 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Phil Greenway
2004-06-24 11:54:21 +00:00
parent 7f4d45d773
commit 825849ba91
2 changed files with 623 additions and 610 deletions
+122 -109
View File
@@ -207,9 +207,11 @@ void DevicesWindow::InitWindow(void)
BBox *BottomFrame; BBox *BottomFrame;
BRect BottomFrameRect(r.left+11,r.bottom-124,r.right-12,r.bottom-12); BRect BottomFrameRect(r.left+11,r.bottom-124,r.right-12,r.bottom-12);
BottomFrame = new BBox(BottomFrameRect, "BottomFrame", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW, B_FANCY_BORDER); BottomFrame = new BBox(BottomFrameRect, "BottomFrame", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW, B_FANCY_BORDER);
BRect bottomFrameBounds = BottomFrame->Bounds();
// Create BButton - Configure // Create BButton - Configure
BRect ConfigureButtonRect(r.left+298,r.bottom-47,r.right-23,r.bottom-23); BRect ConfigureButtonRect(bottomFrameBounds.left+290, bottomFrameBounds.bottom-37,
bottomFrameBounds.right-13, bottomFrameBounds.bottom-13);
btnConfigure = new BButton(ConfigureButtonRect,"btnConfigure","Configure", new BMessage(BTN_CONFIGURE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE); btnConfigure = new BButton(ConfigureButtonRect,"btnConfigure","Configure", new BMessage(BTN_CONFIGURE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE);
btnConfigure->MakeDefault(true); btnConfigure->MakeDefault(true);
btnConfigure->SetEnabled(false); btnConfigure->SetEnabled(false);
@@ -218,17 +220,17 @@ void DevicesWindow::InitWindow(void)
BBox *background = new BBox(Bounds(), "background", B_FOLLOW_ALL_SIDES, B_WILL_DRAW, B_PLAIN_BORDER); BBox *background = new BBox(Bounds(), "background", B_FOLLOW_ALL_SIDES, B_WILL_DRAW, B_PLAIN_BORDER);
AddChild(background); AddChild(background);
// Add Child(ren) // Add Child(ren) - in reverse order to avoid one control overwriting another
background->AddChild(menubar); background->AddChild(BottomFrame);
BottomFrame->AddChild(btnConfigure);
background->AddChild(outlinesv);
background->AddChild(stvMemoryRanges);
background->AddChild(stvIORanges);
background->AddChild(stvDMA);
background->AddChild(stvIRQ);
background->AddChild(stvDeviceName); background->AddChild(stvDeviceName);
background->AddChild(stvCurrentState); background->AddChild(stvCurrentState);
background->AddChild(stvIRQ); background->AddChild(menubar);
background->AddChild(stvDMA);
background->AddChild(stvIORanges);
background->AddChild(stvMemoryRanges);
background->AddChild(outlinesv);
background->AddChild(btnConfigure);
background->AddChild(BottomFrame);
// Set Window Limits // Set Window Limits
float xsize = 396 + (be_plain_font->Size()-10)*40; float xsize = 396 + (be_plain_font->Size()-10)*40;
@@ -318,12 +320,12 @@ DevicesWindow::MessageReceived (BMessage *message)
break; break;
case BTN_CONFIGURE: case BTN_CONFIGURE:
{ {
DeviceItem *item = (DeviceItem *)outline->ItemAt(outline->CurrentSelection()); DeviceItem *devItem = dynamic_cast<DeviceItem *>(outline->ItemAt(outline->CurrentSelection()));
if (item && is_instance_of(item, DeviceItem) ) { if (devItem && devItem->GetInfo()) {
if (item->GetWindow()!=NULL) if (devItem->GetWindow()!=NULL)
item->GetWindow()->Activate(); devItem->GetWindow()->Activate();
else else
new ConfigurationWindow(BRect(150,150,562,602), item); new ConfigurationWindow(BRect(150,150,562,602), devItem);
} }
} }
break; break;
@@ -331,6 +333,7 @@ DevicesWindow::MessageReceived (BMessage *message)
BWindow::MessageReceived(message); BWindow::MessageReceived(message);
break; break;
} }
UpdateIfNeeded();
} }
// ---------------------------------------------------------------------------------------------------------- // // ---------------------------------------------------------------------------------------------------------- //
@@ -396,106 +399,116 @@ DevicesWindow::InitDevices(bus_type bus)
void void
DevicesWindow::UpdateDeviceInfo() DevicesWindow::UpdateDeviceInfo()
{ {
DeviceItem *item = (DeviceItem *)outline->ItemAt(outline->CurrentSelection()); DeviceItem *item = dynamic_cast<DeviceItem *>(outline->ItemAt(outline->CurrentSelection()));
if (item && is_instance_of(item, DeviceItem) ) { if (item) {
DevicesInfo *deviceInfo = item->GetInfo(); DevicesInfo *deviceInfo = item->GetInfo();
struct device_configuration *current = deviceInfo->GetCurrent(); if (deviceInfo) {
resource_descriptor r; struct device_configuration *current = deviceInfo->GetCurrent();
resource_descriptor r;
{ {
BString text = "IRQs: "; BString text = "IRQs: ";
bool first = true; bool first = true;
int32 num = count_resource_descriptors_of_type(current, B_IRQ_RESOURCE); int32 num = count_resource_descriptors_of_type(current, B_IRQ_RESOURCE);
for (int32 i=0;i<num;i++) { for (int32 i=0;i<num;i++) {
get_nth_resource_descriptor_of_type(current, i, B_IRQ_RESOURCE, get_nth_resource_descriptor_of_type(current, i, B_IRQ_RESOURCE,
&r, sizeof(resource_descriptor)); &r, sizeof(resource_descriptor));
uint32 mask = r.d.m.mask; uint32 mask = r.d.m.mask;
int i = 0; int i = 0;
if (!mask) if (!mask)
continue; continue;
for (;mask;mask>>=1,i++) for (;mask;mask>>=1,i++)
if (mask & 1) { if (mask & 1) {
char value[50]; char value[50];
sprintf(value, "%s%d", first ? "" : ",", i); sprintf(value, "%s%d", first ? "" : ",", i);
text += value; text += value;
first = false; first = false;
} }
}
stvIRQ->SetText(text.String());
} }
stvIRQ->SetText(text.String());
{
BString text = "DMAs: ";
bool first = true;
int32 num = count_resource_descriptors_of_type(current, B_DMA_RESOURCE);
for (int32 i=0;i<num;i++) {
get_nth_resource_descriptor_of_type(current, i, B_DMA_RESOURCE,
&r, sizeof(resource_descriptor));
uint32 mask = r.d.m.mask;
int i = 0;
if (!mask)
continue;
for (;mask;mask>>=1,i++)
if (mask & 1) {
char value[50];
sprintf(value, "%s%d", first ? "" : ",", i);
text += value;
first = false;
}
}
stvDMA->SetText(text.String());
}
{
BString text = "IO Ranges: ";
bool first = true;
int32 num = count_resource_descriptors_of_type(current, B_IO_PORT_RESOURCE);
for (int32 i=0;i<num;i++) {
get_nth_resource_descriptor_of_type(current, i, B_IO_PORT_RESOURCE,
&r, sizeof(resource_descriptor));
char value[50];
sprintf(value, "%s0x%04lx - 0x%04lx", first ? "" : ", ", r.d.r.minbase, r.d.r.minbase + r.d.r.len - 1);
text += value;
first = false;
}
if (text.Length()>70) {
text.Truncate(70);
text += "...";
}
stvIORanges->SetText(text.String());
}
{
BString text = "Memory Ranges: ";
bool first = true;
int32 num = count_resource_descriptors_of_type(current, B_MEMORY_RESOURCE);
for (int32 i=0;i<num;i++) {
get_nth_resource_descriptor_of_type(current, i, B_MEMORY_RESOURCE,
&r, sizeof(resource_descriptor));
char value[50];
sprintf(value, "%s0x%06lx - 0x%06lx", first ? "" : ", ", r.d.r.minbase, r.d.r.minbase + r.d.r.len - 1);
text += value;
first = false;
}
if (text.Length()>70) {
text.Truncate(70);
text += "...";
}
stvMemoryRanges->SetText(text.String());
}
btnConfigure->SetEnabled(true);
} else {
BlankDeviceInfoBox();
} }
{
BString text = "DMAs: ";
bool first = true;
int32 num = count_resource_descriptors_of_type(current, B_DMA_RESOURCE);
for (int32 i=0;i<num;i++) {
get_nth_resource_descriptor_of_type(current, i, B_DMA_RESOURCE,
&r, sizeof(resource_descriptor));
uint32 mask = r.d.m.mask;
int i = 0;
if (!mask)
continue;
for (;mask;mask>>=1,i++)
if (mask & 1) {
char value[50];
sprintf(value, "%s%d", first ? "" : ",", i);
text += value;
first = false;
}
}
stvDMA->SetText(text.String());
}
{
BString text = "IO Ranges: ";
bool first = true;
int32 num = count_resource_descriptors_of_type(current, B_IO_PORT_RESOURCE);
for (int32 i=0;i<num;i++) {
get_nth_resource_descriptor_of_type(current, i, B_IO_PORT_RESOURCE,
&r, sizeof(resource_descriptor));
char value[50];
sprintf(value, "%s0x%04lx - 0x%04lx", first ? "" : ", ", r.d.r.minbase, r.d.r.minbase + r.d.r.len - 1);
text += value;
first = false;
}
if (text.Length()>70) {
text.Truncate(70);
text += "...";
}
stvIORanges->SetText(text.String());
}
{
BString text = "Memory Ranges: ";
bool first = true;
int32 num = count_resource_descriptors_of_type(current, B_MEMORY_RESOURCE);
for (int32 i=0;i<num;i++) {
get_nth_resource_descriptor_of_type(current, i, B_MEMORY_RESOURCE,
&r, sizeof(resource_descriptor));
char value[50];
sprintf(value, "%s0x%06lx - 0x%06lx", first ? "" : ", ", r.d.r.minbase, r.d.r.minbase + r.d.r.len - 1);
text += value;
first = false;
}
if (text.Length()>70) {
text.Truncate(70);
text += "...";
}
stvMemoryRanges->SetText(text.String());
}
btnConfigure->SetEnabled(true);
} else { } else {
stvIRQ->SetText("IRQs: "); BlankDeviceInfoBox();
stvDMA->SetText("DMAs: ");
stvIORanges->SetText("IO Ranges: ");
stvMemoryRanges->SetText("Memory Ranges: ");
btnConfigure->SetEnabled(false);
} }
} }
void
DevicesWindow::BlankDeviceInfoBox()
{
stvIRQ->SetText("IRQs: ");
stvDMA->SetText("DMAs: ");
stvIORanges->SetText("IO Ranges: ");
stvMemoryRanges->SetText("Memory Ranges: ");
btnConfigure->SetEnabled(false);
}
+1 -1
View File
@@ -85,6 +85,7 @@ class DevicesWindow : public BWindow
void LoadSettings(BMessage *msg); void LoadSettings(BMessage *msg);
void SaveSettings(void); void SaveSettings(void);
void UpdateDeviceInfo(); void UpdateDeviceInfo();
void BlankDeviceInfoBox();
ResourceUsageWindow* ptrResourceUsageWindow; ResourceUsageWindow* ptrResourceUsageWindow;
ModemWindow* ptrModemWindow; ModemWindow* ptrModemWindow;
@@ -106,4 +107,3 @@ class DevicesWindow : public BWindow
#endif #endif