HaikuDepot: BGroupView holding buttons for package actions...

... that can be applied to the selected package(s). Does nothing
except create the buttons and layout.
This commit is contained in:
Stephan Aßmus 2013-07-27 22:25:08 +02:00
parent 7fa83160f8
commit f344b1dca6
2 changed files with 110 additions and 0 deletions

View File

@ -0,0 +1,81 @@
/*
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "PackageActionsView.h"
#include <algorithm>
#include <stdio.h>
#include <Button.h>
#include <Catalog.h>
#include <LayoutBuilder.h>
#include <Message.h>
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "PackageActionsView"
enum {
MSG_INSTALL = 'inst',
MSG_TOGGLE_ACTIVE = 'tgac',
MSG_UPDATE = 'stmd',
MSG_UNINSTALL = 'dein',
};
PackageActionsView::PackageActionsView()
:
BGroupView("package actions view")
{
// Contruct action buttons
fInstallButton = new BButton("install", B_TRANSLATE("Install"),
new BMessage(MSG_INSTALL));
fToggleActiveButton = new BButton("toggle active",
B_TRANSLATE("Deactivate"), new BMessage(MSG_TOGGLE_ACTIVE));
fUpdateButton = new BButton("update",
B_TRANSLATE("Update"), new BMessage(MSG_UPDATE));
fUninstallButton = new BButton("uninstall", B_TRANSLATE("Uninstall"),
new BMessage(MSG_UNINSTALL));
// Build layout
BLayoutBuilder::Group<>(this)
.AddGlue(1.0f)
.Add(fUninstallButton)
.AddGlue(0.1f)
.Add(fUpdateButton)
.Add(fToggleActiveButton)
.Add(fInstallButton)
;
}
PackageActionsView::~PackageActionsView()
{
}
void
PackageActionsView::AttachedToWindow()
{
fInstallButton->SetTarget(this);
fToggleActiveButton->SetTarget(this);
fUpdateButton->SetTarget(this);
fUninstallButton->SetTarget(this);
}
void
PackageActionsView::MessageReceived(BMessage* message)
{
switch (message->what) {
default:
BGroupView::MessageReceived(message);
break;
}
}

View File

@ -0,0 +1,29 @@
/*
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef PACKAGE_ACTIONS_VIEW_H
#define PACKAGE_ACTIONS_VIEW_H
#include <GroupView.h>
class BButton;
class PackageActionsView : public BGroupView {
public:
PackageActionsView();
virtual ~PackageActionsView();
virtual void AttachedToWindow();
virtual void MessageReceived(BMessage* message);
private:
BButton* fInstallButton;
BButton* fToggleActiveButton;
BButton* fUpdateButton;
BButton* fUninstallButton;
};
#endif // PACKAGE_ACTIONS_VIEW_H