* use Ryan's new BAboutWindow class (also removed the hint that this app

originally was a birthday present for Ingo... hope he is Ok with that)
* fixed ticket #1424, now it uses three empty buttons for new pads
* cloned pads are now opened at an offset, otherwise one wouldn't have any
  visual feedback that something happened with a cloned pad on top of the
  original


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22055 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2007-08-25 17:34:43 +00:00
parent 86519fe39d
commit 227fb2b11c
4 changed files with 48 additions and 19 deletions
+13 -9
View File
@@ -6,9 +6,12 @@
* Stephan Aßmus <[email protected]> * Stephan Aßmus <[email protected]>
*/ */
#include "App.h"
#include <stdio.h> #include <stdio.h>
#include <Alert.h> #include <AboutWindow.h>
#include <Entry.h> #include <Entry.h>
#include <Message.h> #include <Message.h>
#include <String.h> #include <String.h>
@@ -17,7 +20,6 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "App.h"
// constructor // constructor
App::App() App::App()
@@ -73,7 +75,7 @@ App::ReadyToRun()
} }
if (!windowAdded) { if (!windowAdded) {
MainWindow* window = new MainWindow("Pad 1", frame); MainWindow* window = new MainWindow("Pad 1", frame, true);
window->Show(); window->Show();
} }
} }
@@ -85,11 +87,13 @@ App::MessageReceived(BMessage* message)
switch (message->what) { switch (message->what) {
case MSG_ADD_WINDOW: { case MSG_ADD_WINDOW: {
BMessage* settings = new BMessage('sett'); BMessage* settings = new BMessage('sett');
message->FindMessage("window", settings); bool wasCloned = message->FindMessage("window", settings) == B_OK;
BString name("Pad "); BString name("Pad ");
name << CountWindows() + 1; name << CountWindows() + 1;
MainWindow* window = new MainWindow(name.String(), MainWindow* window = new MainWindow(name.String(),
BRect(50.0, 50.0, 65.0, 100.0), settings); BRect(50.0, 50.0, 65.0, 100.0), settings);
if (wasCloned)
window->MoveBy(10, 10);
window->Show(); window->Show();
break; break;
} }
@@ -103,8 +107,8 @@ App::MessageReceived(BMessage* message)
void void
App::AboutRequested() App::AboutRequested()
{ {
(new BAlert("about", "LaunchBox by stippi\n\n" const char* authors[2];
"for bonefish\n\n\n" authors[0] = "Stephan Aßmus (aka stippi)";
"v1.1.0", authors[1] = NULL;
"Neat", NULL, NULL))->Go(NULL); (new BAboutWindow("LaunchBox", 2004, authors))->Show();
} }
+3 -1
View File
@@ -2,6 +2,8 @@ SubDir HAIKU_TOP src apps launchbox ;
AddSubDirSupportedPlatforms libbe_test ; AddSubDirSupportedPlatforms libbe_test ;
UsePrivateHeaders shared ;
Application LaunchBox : Application LaunchBox :
App.cpp App.cpp
IconButton.cpp IconButton.cpp
@@ -12,7 +14,7 @@ Application LaunchBox :
PadView.cpp PadView.cpp
Panel.cpp Panel.cpp
support.cpp support.cpp
: be translation : be translation libshared.a
: LaunchBox.rdef : LaunchBox.rdef
; ;
+27 -5
View File
@@ -27,7 +27,7 @@
#include "PadView.h" #include "PadView.h"
// constructor // constructor
MainWindow::MainWindow(const char* name, BRect frame) MainWindow::MainWindow(const char* name, BRect frame, bool addDefaultButtons)
: BWindow(frame, name, : BWindow(frame, name,
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE
@@ -36,15 +36,19 @@ MainWindow::MainWindow(const char* name, BRect frame)
fSettings(new BMessage('sett')), fSettings(new BMessage('sett')),
fPadView(new PadView("pad view")), fPadView(new PadView("pad view")),
fLastID(0), fLastID(0),
fNamePanelFrame(-1000.0, -1000.0, -900.0, -900.0), fNamePanelFrame(-1000.0, -1000.0, -800.0, -900.0),
fAutoRaise(false), fAutoRaise(false),
fShowOnAllWorkspaces(true) fShowOnAllWorkspaces(true)
{ {
bool buttonsAdded = false; bool buttonsAdded = false;
if (load_settings(fSettings, "main_settings", "LaunchBox") >= B_OK) if (load_settings(fSettings, "main_settings", "LaunchBox") >= B_OK)
buttonsAdded = LoadSettings(fSettings); buttonsAdded = LoadSettings(fSettings);
if (!buttonsAdded) if (!buttonsAdded) {
_AddDefaultButtons(); if (addDefaultButtons)
_AddDefaultButtons();
else
_AddEmptyButtons();
}
SetLayout(new BGroupLayout(B_HORIZONTAL)); SetLayout(new BGroupLayout(B_HORIZONTAL));
AddChild(fPadView); AddChild(fPadView);
@@ -65,7 +69,7 @@ MainWindow::MainWindow(const char* name, BRect frame, BMessage* settings)
fShowOnAllWorkspaces(true) fShowOnAllWorkspaces(true)
{ {
if (!LoadSettings(settings)) if (!LoadSettings(settings))
_AddDefaultButtons(); _AddEmptyButtons();
SetLayout(new BGroupLayout(B_HORIZONTAL)); SetLayout(new BGroupLayout(B_HORIZONTAL));
AddChild(fPadView); AddChild(fPadView);
@@ -474,6 +478,7 @@ MainWindow::_AdjustLocation(BRect frame)
ResizeTo(frame.Width(), frame.Height()); ResizeTo(frame.Width(), frame.Height());
} }
// _AddDefaultButtons
void void
MainWindow::_AddDefaultButtons() MainWindow::_AddDefaultButtons()
{ {
@@ -514,4 +519,21 @@ MainWindow::_AddDefaultButtons()
button->SetTo("application/x-vnd.Haiku-Terminal", true); button->SetTo("application/x-vnd.Haiku-Terminal", true);
} }
// _AddEmptyButtons
void
MainWindow::_AddEmptyButtons()
{
LaunchButton* button = new LaunchButton("launch button", fLastID++, NULL,
new BMessage(MSG_LAUNCH));
fPadView->AddButton(button);
button = new LaunchButton("launch button", fLastID++, NULL,
new BMessage(MSG_LAUNCH));
fPadView->AddButton(button);
button = new LaunchButton("launch button", fLastID++, NULL,
new BMessage(MSG_LAUNCH));
fPadView->AddButton(button);
}
+5 -4
View File
@@ -27,10 +27,10 @@ enum {
class MainWindow : public BWindow { class MainWindow : public BWindow {
public: public:
MainWindow(const char* name, MainWindow(const char* name, BRect frame,
BRect frame); bool addDefaultButtons = false);
MainWindow(const char* name, MainWindow(const char* name, BRect frame,
BRect frame, BMessage* settings); BMessage* settings);
virtual ~MainWindow(); virtual ~MainWindow();
// BWindow interface // BWindow interface
@@ -63,6 +63,7 @@ class MainWindow : public BWindow {
void _GetLocation(); void _GetLocation();
void _AdjustLocation(BRect frame); void _AdjustLocation(BRect frame);
void _AddDefaultButtons(); void _AddDefaultButtons();
void _AddEmptyButtons();
BMessage* fSettings; BMessage* fSettings;
PadView* fPadView; PadView* fPadView;