An old code cleanup I have had along time.. run that python also..
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33851 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2009, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Artur Wyszynski <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#include "GradientsApp.h"
|
||||
|
||||
|
||||
#include "GradientsWindow.h"
|
||||
|
||||
|
||||
GradientsApp::GradientsApp(void)
|
||||
: BApplication("application/x-vnd.Haiku-Gradients")
|
||||
{
|
||||
GradientsWindow* window = new GradientsWindow();
|
||||
window->Show();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
GradientsApp app;
|
||||
app.Run();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2009, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Artur Wyszynski <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#include <Application.h>
|
||||
|
||||
|
||||
class GradientsApp : public BApplication {
|
||||
public:
|
||||
GradientsApp(void);
|
||||
};
|
||||
@@ -1,161 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2008, Haiku, Inc.
|
||||
* Copyright (c) 2008-2009, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Artur Wyszynski <harakash@gmail.com>
|
||||
*/
|
||||
|
||||
#include <Application.h>
|
||||
|
||||
#include "GradientsView.h"
|
||||
#include <GradientLinear.h>
|
||||
#include <GradientRadial.h>
|
||||
#include <GradientRadialFocus.h>
|
||||
#include <GradientDiamond.h>
|
||||
#include <GradientConic.h>
|
||||
#include <View.h>
|
||||
#include <Screen.h>
|
||||
#include <Window.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
#include <PopUpMenu.h>
|
||||
|
||||
|
||||
#define MSG_LINEAR 'gtli'
|
||||
#define MSG_RADIAL 'gtra'
|
||||
#define MSG_RADIAL_FOCUS 'gtrf'
|
||||
#define MSG_DIAMOND 'gtdi'
|
||||
#define MSG_CONIC 'gtco'
|
||||
|
||||
class GradientsApp : public BApplication {
|
||||
public:
|
||||
GradientsApp(void);
|
||||
};
|
||||
|
||||
|
||||
class GradientsView : public BView {
|
||||
public:
|
||||
GradientsView(const BRect &r);
|
||||
virtual ~GradientsView(void);
|
||||
|
||||
virtual void Draw(BRect update);
|
||||
void DrawLinear(BRect update);
|
||||
void DrawRadial(BRect update);
|
||||
void DrawRadialFocus(BRect update);
|
||||
void DrawDiamond(BRect update);
|
||||
void DrawConic(BRect update);
|
||||
void SetType(BGradient::Type type);
|
||||
|
||||
private:
|
||||
BGradient::Type fType;
|
||||
};
|
||||
|
||||
|
||||
class GradientsWindow : public BWindow {
|
||||
public:
|
||||
GradientsWindow(void);
|
||||
|
||||
bool QuitRequested(void);
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
|
||||
private:
|
||||
BPopUpMenu* fGradientsMenu;
|
||||
BMenuItem* fLinearItem;
|
||||
BMenuItem* fRadialItem;
|
||||
BMenuItem* fRadialFocusItem;
|
||||
BMenuItem* fDiamondItem;
|
||||
BMenuItem* fConicItem;
|
||||
BMenuField* fGradientsTypeField;
|
||||
GradientsView* fGradientsView;
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
GradientsApp::GradientsApp(void)
|
||||
: BApplication("application/x-vnd.Haiku-Gradients")
|
||||
{
|
||||
GradientsWindow *window = new GradientsWindow();
|
||||
window->Show();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
GradientsWindow::GradientsWindow()
|
||||
: BWindow(BRect(0, 0, 230, 490), "Gradients Test", B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
|
||||
{
|
||||
BRect field(10, 10, Bounds().Width() - 10, 30);
|
||||
fGradientsMenu = new BPopUpMenu("gradientsType");
|
||||
fLinearItem = new BMenuItem("Linear", new BMessage(MSG_LINEAR));
|
||||
fRadialItem = new BMenuItem("Radial", new BMessage(MSG_RADIAL));
|
||||
fRadialFocusItem = new BMenuItem("Radial Focus",
|
||||
new BMessage(MSG_RADIAL_FOCUS));
|
||||
fDiamondItem = new BMenuItem("Diamond", new BMessage(MSG_DIAMOND));
|
||||
fConicItem = new BMenuItem("Conic", new BMessage(MSG_CONIC));
|
||||
fGradientsMenu->AddItem(fLinearItem);
|
||||
fGradientsMenu->AddItem(fRadialItem);
|
||||
fGradientsMenu->AddItem(fRadialFocusItem);
|
||||
fGradientsMenu->AddItem(fDiamondItem);
|
||||
fGradientsMenu->AddItem(fConicItem);
|
||||
fLinearItem->SetMarked(true);
|
||||
fGradientsTypeField = new BMenuField(field, "gradientsField",
|
||||
"Gradient type:",
|
||||
fGradientsMenu,
|
||||
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
|
||||
B_WILL_DRAW | B_NAVIGABLE
|
||||
| B_FRAME_EVENTS);
|
||||
fGradientsTypeField->SetViewColor(255, 255, 255);
|
||||
fGradientsTypeField->SetDivider(110);
|
||||
AddChild(fGradientsTypeField);
|
||||
|
||||
BRect bounds = Bounds();
|
||||
bounds.top = 40;
|
||||
fGradientsView = new GradientsView(bounds);
|
||||
AddChild(fGradientsView);
|
||||
|
||||
MoveTo((BScreen().Frame().Width() - Bounds().Width()) / 2,
|
||||
(BScreen().Frame().Height() - Bounds().Height()) / 2 );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
GradientsWindow::QuitRequested()
|
||||
{
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GradientsWindow::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch (msg->what) {
|
||||
case MSG_LINEAR:
|
||||
fGradientsView->SetType(BGradient::TYPE_LINEAR);
|
||||
break;
|
||||
case MSG_RADIAL:
|
||||
fGradientsView->SetType(BGradient::TYPE_RADIAL);
|
||||
break;
|
||||
case MSG_RADIAL_FOCUS:
|
||||
fGradientsView->SetType(BGradient::TYPE_RADIAL_FOCUS);
|
||||
break;
|
||||
case MSG_DIAMOND:
|
||||
fGradientsView->SetType(BGradient::TYPE_DIAMOND);
|
||||
break;
|
||||
case MSG_CONIC:
|
||||
fGradientsView->SetType(BGradient::TYPE_CONIC);
|
||||
break;
|
||||
default:
|
||||
BWindow::MessageReceived(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
GradientsView::GradientsView(const BRect &rect)
|
||||
@@ -174,33 +31,33 @@ void
|
||||
GradientsView::Draw(BRect update)
|
||||
{
|
||||
switch (fType) {
|
||||
case BGradient::TYPE_LINEAR: {
|
||||
case BGradient::TYPE_LINEAR:
|
||||
DrawLinear(update);
|
||||
break;
|
||||
}
|
||||
case BGradient::TYPE_RADIAL: {
|
||||
|
||||
case BGradient::TYPE_RADIAL:
|
||||
DrawRadial(update);
|
||||
break;
|
||||
}
|
||||
case BGradient::TYPE_RADIAL_FOCUS: {
|
||||
|
||||
case BGradient::TYPE_RADIAL_FOCUS:
|
||||
DrawRadialFocus(update);
|
||||
break;
|
||||
}
|
||||
case BGradient::TYPE_DIAMOND: {
|
||||
|
||||
case BGradient::TYPE_DIAMOND:
|
||||
DrawDiamond(update);
|
||||
break;
|
||||
}
|
||||
case BGradient::TYPE_CONIC: {
|
||||
|
||||
case BGradient::TYPE_CONIC:
|
||||
DrawConic(update);
|
||||
break;
|
||||
}
|
||||
|
||||
case BGradient::TYPE_NONE:
|
||||
default: {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GradientsView::DrawLinear(BRect update)
|
||||
{
|
||||
@@ -238,7 +95,8 @@ GradientsView::DrawLinear(BRect update)
|
||||
FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330));
|
||||
gradient.SetStart(BPoint(60, 230));
|
||||
gradient.SetEnd(BPoint(60, 330));
|
||||
FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), gradient);
|
||||
FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330),
|
||||
gradient);
|
||||
|
||||
// Ellipse
|
||||
SetHighColor(0, 0, 0);
|
||||
@@ -283,7 +141,8 @@ GradientsView::DrawRadial(BRect update)
|
||||
SetHighColor(0, 0, 0);
|
||||
FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330));
|
||||
gradient.SetCenter(BPoint(170, 280));
|
||||
FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), gradient);
|
||||
FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330),
|
||||
gradient);
|
||||
|
||||
// Ellipse
|
||||
SetHighColor(0, 0, 0);
|
||||
@@ -327,7 +186,8 @@ GradientsView::DrawRadialFocus(BRect update)
|
||||
SetHighColor(0, 0, 0);
|
||||
FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330));
|
||||
gradient.SetCenter(BPoint(170, 280));
|
||||
FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), gradient);
|
||||
FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330),
|
||||
gradient);
|
||||
|
||||
// Ellipse
|
||||
SetHighColor(0, 0, 0);
|
||||
@@ -371,7 +231,8 @@ GradientsView::DrawDiamond(BRect update)
|
||||
SetHighColor(0, 0, 0);
|
||||
FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330));
|
||||
gradient.SetCenter(BPoint(170, 280));
|
||||
FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), gradient);
|
||||
FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330),
|
||||
gradient);
|
||||
|
||||
// Ellipse
|
||||
SetHighColor(0, 0, 0);
|
||||
@@ -415,7 +276,8 @@ GradientsView::DrawConic(BRect update)
|
||||
SetHighColor(0, 0, 0);
|
||||
FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330));
|
||||
gradient.SetCenter(BPoint(170, 280));
|
||||
FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), gradient);
|
||||
FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330),
|
||||
gradient);
|
||||
|
||||
// Ellipse
|
||||
SetHighColor(0, 0, 0);
|
||||
@@ -431,15 +293,3 @@ GradientsView::SetType(BGradient::Type type)
|
||||
fType = type;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
GradientsApp app;
|
||||
app.Run();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2009, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Artur Wyszynski <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#include <View.h>
|
||||
#include <Gradient.h>
|
||||
|
||||
|
||||
class GradientsView : public BView {
|
||||
public:
|
||||
GradientsView(const BRect &r);
|
||||
virtual ~GradientsView(void);
|
||||
|
||||
virtual void Draw(BRect update);
|
||||
void DrawLinear(BRect update);
|
||||
void DrawRadial(BRect update);
|
||||
void DrawRadialFocus(BRect update);
|
||||
void DrawDiamond(BRect update);
|
||||
void DrawConic(BRect update);
|
||||
void SetType(BGradient::Type type);
|
||||
|
||||
private:
|
||||
BGradient::Type fType;
|
||||
};
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2009, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Artur Wyszynski <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#include "GradientsWindow.h"
|
||||
|
||||
|
||||
GradientsWindow::GradientsWindow()
|
||||
: BWindow(BRect(0, 0, 230, 490), "Gradients Test", B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
|
||||
{
|
||||
BRect field(10, 10, Bounds().Width() - 10, 30);
|
||||
fGradientsMenu = new BPopUpMenu("gradientsType");
|
||||
fLinearItem = new BMenuItem("Linear", new BMessage(MSG_LINEAR));
|
||||
fRadialItem = new BMenuItem("Radial", new BMessage(MSG_RADIAL));
|
||||
fRadialFocusItem = new BMenuItem("Radial Focus",
|
||||
new BMessage(MSG_RADIAL_FOCUS));
|
||||
|
||||
fDiamondItem = new BMenuItem("Diamond", new BMessage(MSG_DIAMOND));
|
||||
fConicItem = new BMenuItem("Conic", new BMessage(MSG_CONIC));
|
||||
fGradientsMenu->AddItem(fLinearItem);
|
||||
fGradientsMenu->AddItem(fRadialItem);
|
||||
fGradientsMenu->AddItem(fRadialFocusItem);
|
||||
fGradientsMenu->AddItem(fDiamondItem);
|
||||
fGradientsMenu->AddItem(fConicItem);
|
||||
fLinearItem->SetMarked(true);
|
||||
fGradientsTypeField = new BMenuField(field, "gradientsField",
|
||||
"Gradient type:", fGradientsMenu, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
|
||||
B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS);
|
||||
fGradientsTypeField->SetViewColor(255, 255, 255);
|
||||
fGradientsTypeField->SetDivider(110);
|
||||
AddChild(fGradientsTypeField);
|
||||
|
||||
BRect bounds = Bounds();
|
||||
bounds.top = 40;
|
||||
fGradientsView = new GradientsView(bounds);
|
||||
AddChild(fGradientsView);
|
||||
|
||||
MoveTo((BScreen().Frame().Width() - Bounds().Width()) / 2,
|
||||
(BScreen().Frame().Height() - Bounds().Height()) / 2 );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
GradientsWindow::QuitRequested()
|
||||
{
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GradientsWindow::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch (msg->what) {
|
||||
case MSG_LINEAR:
|
||||
fGradientsView->SetType(BGradient::TYPE_LINEAR);
|
||||
break;
|
||||
case MSG_RADIAL:
|
||||
fGradientsView->SetType(BGradient::TYPE_RADIAL);
|
||||
break;
|
||||
case MSG_RADIAL_FOCUS:
|
||||
fGradientsView->SetType(BGradient::TYPE_RADIAL_FOCUS);
|
||||
break;
|
||||
case MSG_DIAMOND:
|
||||
fGradientsView->SetType(BGradient::TYPE_DIAMOND);
|
||||
break;
|
||||
case MSG_CONIC:
|
||||
fGradientsView->SetType(BGradient::TYPE_CONIC);
|
||||
break;
|
||||
default:
|
||||
BWindow::MessageReceived(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2009, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Artur Wyszynski <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#include <Application.h>
|
||||
#include <Window.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Screen.h>
|
||||
|
||||
#include "GradientsView.h"
|
||||
|
||||
#define MSG_LINEAR 'gtli'
|
||||
#define MSG_RADIAL 'gtra'
|
||||
#define MSG_RADIAL_FOCUS 'gtrf'
|
||||
#define MSG_DIAMOND 'gtdi'
|
||||
#define MSG_CONIC 'gtco'
|
||||
|
||||
class GradientsWindow : public BWindow {
|
||||
public:
|
||||
GradientsWindow(void);
|
||||
|
||||
bool QuitRequested(void);
|
||||
virtual void MessageReceived(BMessage* msg);
|
||||
|
||||
private:
|
||||
BPopUpMenu* fGradientsMenu;
|
||||
BMenuItem* fLinearItem;
|
||||
BMenuItem* fRadialItem;
|
||||
BMenuItem* fRadialFocusItem;
|
||||
BMenuItem* fDiamondItem;
|
||||
BMenuItem* fConicItem;
|
||||
BMenuField* fGradientsTypeField;
|
||||
GradientsView* fGradientsView;
|
||||
};
|
||||
@@ -1,7 +1,10 @@
|
||||
SubDir HAIKU_TOP src apps gradients ;
|
||||
|
||||
Application Gradients :
|
||||
Gradients.cpp
|
||||
# Gradients.cpp
|
||||
GradientsApp.cpp
|
||||
GradientsWindow.cpp
|
||||
GradientsView.cpp
|
||||
: be $(TARGET_LIBSUPC++)
|
||||
: Gradients.rdef
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user