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:
Stephan Aßmus
2005-05-20 23:30:17 +00:00
parent 3f513bbafe
commit 81cc749f6b
6 changed files with 67 additions and 29 deletions
+2 -2
View File
@@ -17,7 +17,7 @@ if ( $(TARGET_PLATFORM) = haiku ) {
} else { } else {
# for running in the Haiku app_server under R5: # for running in the Haiku app_server under R5:
LinkSharedOSLibs Playground : LinkSharedOSLibs Playground :
# <boot!home!config!lib>libopenbeos.so ; <boot!home!config!lib>libopenbeos.so ;
be ; # 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); rgb_color bg = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_1_TINT);
SetViewColor(bg); SetViewColor(bg);
SetLowColor(bg); SetLowColor(bg);
BFont font;
GetFont(&font);
font.SetSize(20.0);
font.SetRotation(6.0);
SetFont(&font, B_FONT_ROTATION | B_FONT_SIZE);
} }
// AttachedToWindow // AttachedToWindow
@@ -66,11 +72,12 @@ ObjectView::Draw(BRect updateRect)
message = "to draw an object!"; message = "to draw an object!";
width = StringWidth(message); width = StringWidth(message);
p.x = r.left + r.Width() / 2.0 - width / 2.0; p.x = r.left + r.Width() / 2.0 - width / 2.0;
p.y += 20; p.y += 25;
DrawString(message, p); DrawString(message, p);
SetDrawingMode(B_OP_ALPHA); SetDrawingMode(B_OP_ALPHA);
// SetDrawingMode(B_OP_OVER);
for (int32 i = 0; State* state = (State*)fStateList.ItemAt(i); i++) for (int32 i = 0; State* state = (State*)fStateList.ItemAt(i); i++)
state->Draw(this); state->Draw(this);
@@ -10,7 +10,9 @@
#include <CheckBox.h> #include <CheckBox.h>
#include <Menu.h> #include <Menu.h>
#include <MenuBar.h> #include <MenuBar.h>
#include <MenuField.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <PopUpMenu.h>
#include <String.h> #include <String.h>
#include <RadioButton.h> #include <RadioButton.h>
#include <TextControl.h> #include <TextControl.h>
@@ -26,6 +28,7 @@ enum {
MSG_SET_FILL_OR_STROKE = 'stfs', MSG_SET_FILL_OR_STROKE = 'stfs',
MSG_SET_COLOR = 'stcl', MSG_SET_COLOR = 'stcl',
MSG_SET_PEN_SIZE = 'stps', MSG_SET_PEN_SIZE = 'stps',
MSG_SET_DRAWING_MODE = 'stdm',
MSG_NEW_OBJECT = 'nobj', MSG_NEW_OBJECT = 'nobj',
@@ -123,6 +126,25 @@ ObjectWindow::ObjectWindow(BRect frame, const char* name)
radioButton = new BRadioButton(b, "radio 4", "Ellipse", message); radioButton = new BRadioButton(b, "radio 4", "Ellipse", message);
controlGroup->AddChild(radioButton); 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 // red text control
b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
fRedTC = new BTextControl(b, "red text control", "Red", "", fRedTC = new BTextControl(b, "red text control", "Red", "",
@@ -217,6 +239,7 @@ ObjectWindow::MessageReceived(BMessage* message)
} }
case MSG_SET_COLOR: case MSG_SET_COLOR:
fObjectView->SetStateColor(_GetColor()); fObjectView->SetStateColor(_GetColor());
_UpdateColorControls();
break; break;
case MSG_OBJECT_COUNT_CHANGED: case MSG_OBJECT_COUNT_CHANGED:
fClearB->SetEnabled(fObjectView->CountObjects() > 0); fClearB->SetEnabled(fObjectView->CountObjects() > 0);
@@ -225,8 +248,8 @@ ObjectWindow::MessageReceived(BMessage* message)
fObjectView->SetState(NULL); fObjectView->SetState(NULL);
break; break;
case MSG_CLEAR: { case MSG_CLEAR: {
BAlert *alert = new BAlert("Playground", "Do you really want to clear all drawing objects?", "No", "Yes"); // BAlert *alert = new BAlert("Playground", "Do you really want to clear all drawing objects?", "No", "Yes");
if (alert->Go() == 1) // if (alert->Go() == 1)
fObjectView->MakeEmpty(); fObjectView->MakeEmpty();
break; break;
} }
@@ -241,6 +264,29 @@ ObjectWindow::MessageReceived(BMessage* message)
// _UpdateControls // _UpdateControls
void void
ObjectWindow::_UpdateControls() const 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 // update color
rgb_color c = fObjectView->StateColor(); rgb_color c = fObjectView->StateColor();
@@ -257,20 +303,6 @@ ObjectWindow::_UpdateControls() const
sprintf(string, "%d", c.alpha); sprintf(string, "%d", c.alpha);
fAlphaTC->SetText(string); 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 // _GetColor
@@ -5,16 +5,9 @@
#include <Window.h> #include <Window.h>
/*
class Box;
class Button;
class CheckBox;
class Menu;
class MenuBar;
class RadioButton;
class TextView;*/
class BButton; class BButton;
class BCheckBox; class BCheckBox;
class BMenuField;
class BTextControl; class BTextControl;
class ObjectView; class ObjectView;
@@ -29,6 +22,7 @@ class ObjectWindow : public BWindow {
private: private:
void _UpdateControls() const; void _UpdateControls() const;
void _UpdateColorControls() const;
rgb_color _GetColor() const; rgb_color _GetColor() const;
ObjectView* fObjectView; ObjectView* fObjectView;
@@ -36,6 +30,11 @@ class ObjectWindow : public BWindow {
BButton* fNewB; BButton* fNewB;
BButton* fClearB; BButton* fClearB;
BButton* fUndoB;
BButton* fRedoB;
BMenuField* fDrawingModeMF;
BTextControl* fRedTC; BTextControl* fRedTC;
BTextControl* fGreenTC; BTextControl* fGreenTC;
BTextControl* fBlueTC; BTextControl* fBlueTC;
+1 -1
View File
@@ -143,7 +143,7 @@ class RoundRectState : public State {
if (fValid) { if (fValid) {
view->SetHighColor(fColor); view->SetHighColor(fColor);
BRect r = _ValidRect(); 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) if (fFill)
view->FillRoundRect(r, radius, radius); view->FillRoundRect(r, radius, radius);
else { else {
+1 -1
View File
@@ -10,7 +10,7 @@ main(int argc, char** argv)
{ {
BApplication* app = new BApplication("application/x.vnd-Haiku.Objects"); 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(); (new ObjectWindow(frame, "Playground"))->Show();
app->Run(); app->Run();