Commit often, commit small...

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8861 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Houdoin 2004-09-06 09:51:12 +00:00
parent 33efb91915
commit 606359d937
3 changed files with 41 additions and 13 deletions

View File

@ -1,15 +1,19 @@
#include <stdlib.h> #include <stdlib.h>
#include <kernel/image.h>
#include <storage/Resources.h>
#include "NetworkSetupAddOn.h" #include "NetworkSetupAddOn.h"
NetworkSetupAddOn::NetworkSetupAddOn(image_id image) NetworkSetupAddOn::NetworkSetupAddOn(image_id image)
: is_dirty(false), profile(NULL), addon_image(image) : m_is_dirty(false), m_profile(NULL), m_addon_image(image), m_addon_resources(NULL)
{ {
} }
NetworkSetupAddOn::~NetworkSetupAddOn() NetworkSetupAddOn::~NetworkSetupAddOn()
{ {
delete m_addon_resources;
} }
BView * NetworkSetupAddOn::CreateView(BRect *bounds) BView * NetworkSetupAddOn::CreateView(BRect *bounds)
@ -34,7 +38,7 @@ status_t NetworkSetupAddOn::Revert()
status_t NetworkSetupAddOn::ProfileChanged(NetworkSetupProfile *new_profile) status_t NetworkSetupAddOn::ProfileChanged(NetworkSetupProfile *new_profile)
{ {
profile = new_profile; m_profile = new_profile;
return B_OK; return B_OK;
} }
@ -43,3 +47,24 @@ const char * NetworkSetupAddOn::Name()
return "Dummy NetworkSetupAddon"; return "Dummy NetworkSetupAddon";
} }
BResources * NetworkSetupAddOn::Resources()
{
if (!m_addon_resources) {
image_info info;
if (get_image_info(m_addon_image, &info) != B_OK)
return NULL;
BResources *resources = new BResources();
BFile addon_file(info.name, O_RDONLY);
if (resources->SetTo(&addon_file) == B_OK)
m_addon_resources = resources;
else
delete resources;
};
return m_addon_resources;
}

View File

@ -1,8 +1,9 @@
#ifndef NETWORKSETUPADDON_H #ifndef NETWORKSETUPADDON_H
#define NETWORKSETUPADDON_H #define NETWORKSETUPADDON_H
#include <View.h> #include <interface/View.h>
#include <kernel/image.h> // for image_id #include <kernel/image.h> // for image_id
#include <storage/Resources.h>
class NetworkSetupProfile; class NetworkSetupProfile;
@ -23,18 +24,20 @@ class NetworkSetupAddOn {
NetworkSetupProfile * Profile(); NetworkSetupProfile * Profile();
bool IsDirty(); bool IsDirty();
void SetDirty(bool dirty = true); void SetDirty(bool dirty = true);
image_id AddonImageId(); image_id ImageId();
BResources * Resources();
private: private:
bool is_dirty; bool m_is_dirty;
NetworkSetupProfile * profile; NetworkSetupProfile * m_profile;
image_id addon_image; image_id m_addon_image;
BResources * m_addon_resources;
}; };
inline bool NetworkSetupAddOn::IsDirty() { return is_dirty; }; inline bool NetworkSetupAddOn::IsDirty() { return m_is_dirty; };
inline void NetworkSetupAddOn::SetDirty(bool dirty) { is_dirty = dirty; }; inline void NetworkSetupAddOn::SetDirty(bool dirty) { m_is_dirty = dirty; };
inline NetworkSetupProfile * NetworkSetupAddOn::Profile() { return profile; }; inline NetworkSetupProfile * NetworkSetupAddOn::Profile() { return m_profile; };
inline image_id NetworkSetupAddOn::AddonImageId() { return addon_image; }; inline image_id NetworkSetupAddOn::ImageId() { return m_addon_image; };
extern "C" { extern "C" {

View File

@ -143,7 +143,7 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title)
fHelpButton = button; fHelpButton = button;
#endif #endif
r.top += h + SMALL_MARGIN; r.top += h + V_MARGIN;
r.left = H_MARGIN; r.left = H_MARGIN;
fPanel = new BBox(r, "showview_box", B_FOLLOW_ALL, fPanel = new BBox(r, "showview_box", B_FOLLOW_ALL,
@ -228,7 +228,7 @@ void NetworkSetupWindow::MessageReceived
fPanel->AddChild(fAddonView); fPanel->AddChild(fAddonView);
fAddonView->ResizeTo(fPanel->Bounds().Width(), fPanel->Bounds().Height()); fAddonView->ResizeTo(fPanel->Bounds().Width(), fPanel->Bounds().Height());
fAddonView->SetViewColor((rand() % 256), (rand() % 256), (rand() % 256)); // fAddonView->SetViewColor((rand() % 256), (rand() % 256), (rand() % 256));
break; break;
} }