commented out non-working stuff except the menu bar. color text controls no always show the current really used values.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12749 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
3f513bbafe
commit
81cc749f6b
@ -17,7 +17,7 @@ if ( $(TARGET_PLATFORM) = haiku ) {
|
||||
} else {
|
||||
# for running in the Haiku app_server under R5:
|
||||
LinkSharedOSLibs Playground :
|
||||
# <boot!home!config!lib>libopenbeos.so ;
|
||||
be ;
|
||||
<boot!home!config!lib>libopenbeos.so ;
|
||||
# be ;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,12 @@ ObjectView::ObjectView(BRect frame, const char* name,
|
||||
rgb_color bg = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_1_TINT);
|
||||
SetViewColor(bg);
|
||||
SetLowColor(bg);
|
||||
|
||||
BFont font;
|
||||
GetFont(&font);
|
||||
font.SetSize(20.0);
|
||||
font.SetRotation(6.0);
|
||||
SetFont(&font, B_FONT_ROTATION | B_FONT_SIZE);
|
||||
}
|
||||
|
||||
// AttachedToWindow
|
||||
@ -66,11 +72,12 @@ ObjectView::Draw(BRect updateRect)
|
||||
message = "to draw an object!";
|
||||
width = StringWidth(message);
|
||||
p.x = r.left + r.Width() / 2.0 - width / 2.0;
|
||||
p.y += 20;
|
||||
p.y += 25;
|
||||
|
||||
DrawString(message, p);
|
||||
|
||||
SetDrawingMode(B_OP_ALPHA);
|
||||
// SetDrawingMode(B_OP_OVER);
|
||||
for (int32 i = 0; State* state = (State*)fStateList.ItemAt(i); i++)
|
||||
state->Draw(this);
|
||||
|
||||
|
@ -10,7 +10,9 @@
|
||||
#include <CheckBox.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuBar.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <String.h>
|
||||
#include <RadioButton.h>
|
||||
#include <TextControl.h>
|
||||
@ -26,6 +28,7 @@ enum {
|
||||
MSG_SET_FILL_OR_STROKE = 'stfs',
|
||||
MSG_SET_COLOR = 'stcl',
|
||||
MSG_SET_PEN_SIZE = 'stps',
|
||||
MSG_SET_DRAWING_MODE = 'stdm',
|
||||
|
||||
MSG_NEW_OBJECT = 'nobj',
|
||||
|
||||
@ -123,6 +126,25 @@ ObjectWindow::ObjectWindow(BRect frame, const char* name)
|
||||
radioButton = new BRadioButton(b, "radio 4", "Ellipse", message);
|
||||
controlGroup->AddChild(radioButton);
|
||||
|
||||
// drawing mode
|
||||
/* BPopUpMenu* popupMenu = new BPopUpMenu("<pick>");
|
||||
|
||||
message = new BMessage(MSG_SET_DRAWING_MODE);
|
||||
message->AddInt32("mode", B_OP_COPY);
|
||||
popupMenu->AddItem(new BMenuItem("B_OP_COPY", message));
|
||||
|
||||
message = new BMessage(MSG_SET_DRAWING_MODE);
|
||||
message->AddInt32("mode", B_OP_OVER);
|
||||
popupMenu->AddItem(new BMenuItem("B_OP_OVER", message));
|
||||
|
||||
b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
|
||||
fDrawingModeMF = new BMenuField(b, "drawing mode field", "Mode",
|
||||
popupMenu);
|
||||
|
||||
controlGroup->AddChild(fDrawingModeMF);
|
||||
|
||||
fDrawingModeMF->SetDivider(fDrawingModeMF->StringWidth(fDrawingModeMF->Label()) + 10.0);
|
||||
*/
|
||||
// red text control
|
||||
b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
|
||||
fRedTC = new BTextControl(b, "red text control", "Red", "",
|
||||
@ -217,6 +239,7 @@ ObjectWindow::MessageReceived(BMessage* message)
|
||||
}
|
||||
case MSG_SET_COLOR:
|
||||
fObjectView->SetStateColor(_GetColor());
|
||||
_UpdateColorControls();
|
||||
break;
|
||||
case MSG_OBJECT_COUNT_CHANGED:
|
||||
fClearB->SetEnabled(fObjectView->CountObjects() > 0);
|
||||
@ -225,8 +248,8 @@ ObjectWindow::MessageReceived(BMessage* message)
|
||||
fObjectView->SetState(NULL);
|
||||
break;
|
||||
case MSG_CLEAR: {
|
||||
BAlert *alert = new BAlert("Playground", "Do you really want to clear all drawing objects?", "No", "Yes");
|
||||
if (alert->Go() == 1)
|
||||
// BAlert *alert = new BAlert("Playground", "Do you really want to clear all drawing objects?", "No", "Yes");
|
||||
// if (alert->Go() == 1)
|
||||
fObjectView->MakeEmpty();
|
||||
break;
|
||||
}
|
||||
@ -241,6 +264,29 @@ ObjectWindow::MessageReceived(BMessage* message)
|
||||
// _UpdateControls
|
||||
void
|
||||
ObjectWindow::_UpdateControls() const
|
||||
{
|
||||
_UpdateColorControls();
|
||||
|
||||
// update buttons
|
||||
fClearB->SetEnabled(fObjectView->CountObjects() > 0);
|
||||
|
||||
fFillCB->SetEnabled(fObjectView->ObjectType() != OBJECT_LINE);
|
||||
|
||||
// pen size
|
||||
char string[32];
|
||||
sprintf(string, "%.1f", fObjectView->StatePenSize());
|
||||
fPenSizeTC->SetText(string);
|
||||
|
||||
// disable penSize if fill is on
|
||||
if (!fFillCB->IsEnabled())
|
||||
fPenSizeTC->SetEnabled(true);
|
||||
else
|
||||
fPenSizeTC->SetEnabled(fFillCB->Value() == B_CONTROL_OFF);
|
||||
}
|
||||
|
||||
// _UpdateColorControls
|
||||
void
|
||||
ObjectWindow::_UpdateColorControls() const
|
||||
{
|
||||
// update color
|
||||
rgb_color c = fObjectView->StateColor();
|
||||
@ -257,20 +303,6 @@ ObjectWindow::_UpdateControls() const
|
||||
|
||||
sprintf(string, "%d", c.alpha);
|
||||
fAlphaTC->SetText(string);
|
||||
|
||||
|
||||
// update buttons
|
||||
fClearB->SetEnabled(fObjectView->CountObjects() > 0);
|
||||
|
||||
fFillCB->SetEnabled(fObjectView->ObjectType() != OBJECT_LINE);
|
||||
|
||||
// disable penSize if fill is on
|
||||
sprintf(string, "%.1f", fObjectView->StatePenSize());
|
||||
fPenSizeTC->SetText(string);
|
||||
if (!fFillCB->IsEnabled())
|
||||
fPenSizeTC->SetEnabled(true);
|
||||
else
|
||||
fPenSizeTC->SetEnabled(fFillCB->Value() == B_CONTROL_OFF);
|
||||
}
|
||||
|
||||
// _GetColor
|
||||
|
@ -5,16 +5,9 @@
|
||||
|
||||
#include <Window.h>
|
||||
|
||||
/*
|
||||
class Box;
|
||||
class Button;
|
||||
class CheckBox;
|
||||
class Menu;
|
||||
class MenuBar;
|
||||
class RadioButton;
|
||||
class TextView;*/
|
||||
class BButton;
|
||||
class BCheckBox;
|
||||
class BMenuField;
|
||||
class BTextControl;
|
||||
class ObjectView;
|
||||
|
||||
@ -29,6 +22,7 @@ class ObjectWindow : public BWindow {
|
||||
|
||||
private:
|
||||
void _UpdateControls() const;
|
||||
void _UpdateColorControls() const;
|
||||
rgb_color _GetColor() const;
|
||||
|
||||
ObjectView* fObjectView;
|
||||
@ -36,6 +30,11 @@ class ObjectWindow : public BWindow {
|
||||
BButton* fNewB;
|
||||
BButton* fClearB;
|
||||
|
||||
BButton* fUndoB;
|
||||
BButton* fRedoB;
|
||||
|
||||
BMenuField* fDrawingModeMF;
|
||||
|
||||
BTextControl* fRedTC;
|
||||
BTextControl* fGreenTC;
|
||||
BTextControl* fBlueTC;
|
||||
|
@ -143,7 +143,7 @@ class RoundRectState : public State {
|
||||
if (fValid) {
|
||||
view->SetHighColor(fColor);
|
||||
BRect r = _ValidRect();
|
||||
float radius = min_c(r.Width() / 4.0, r.Height() / 4.0);
|
||||
float radius = min_c(r.Width() / 3.0, r.Height() / 3.0);
|
||||
if (fFill)
|
||||
view->FillRoundRect(r, radius, radius);
|
||||
else {
|
||||
|
@ -10,7 +10,7 @@ main(int argc, char** argv)
|
||||
{
|
||||
BApplication* app = new BApplication("application/x.vnd-Haiku.Objects");
|
||||
|
||||
BRect frame(50.0, 50.0, 450.0, 430.0);
|
||||
BRect frame(50.0, 50.0, 450.0, 450.0);
|
||||
(new ObjectWindow(frame, "Playground"))->Show();
|
||||
|
||||
app->Run();
|
||||
|
Loading…
x
Reference in New Issue
Block a user