/usr/lib/Wt/examples/widgetgallery/GraphicsWidgets.C is in witty-examples 3.1.10-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | /*
* Copyright (C) 2008 Emweb bvba
*
* See the LICENSE file for terms of use.
*/
#include "GraphicsWidgets.h"
#include "PaintExample.h"
#include "PaintBrush.h"
#include <Wt/WText>
#include <Wt/WGlobal>
#include <Wt/WCssDecorationStyle>
#include <Wt/WBorder>
#include <Wt/WBreak>
#include <Wt/WPushButton>
GraphicsWidgets::GraphicsWidgets(EventDisplayer *ed)
: ControlsWidget(ed, true)
{
topic("WPaintedWidget", this);
new WText(tr("graphics-intro"), this);
}
void GraphicsWidgets::populateSubMenu(WMenu *menu)
{
menu->addItem("Emweb logo example", emwebLogo());
menu->addItem("Paintbrush example", paintbrush());
}
WWidget* GraphicsWidgets::emwebLogo()
{
WContainerWidget *result = new WContainerWidget();
topic("WPaintedWidget", result);
new PaintExample(result, false);
return result;
}
void addColor(PaintBrush *const canvas,
WTableCell *cell,
const WColor& color)
{
cell->decorationStyle().setBackgroundColor(color);
cell->resize(15, 15);
const WColor *const javaColor = &color;
cell->clicked().connect(boost::bind(&PaintBrush::setColor,
canvas,
*javaColor));
}
WWidget* GraphicsWidgets::paintbrush()
{
WContainerWidget *result = new WContainerWidget();
topic("WPaintedWidget", result);
new WText(tr("graphics-paintbrush"), result);
WTable* layout = new WTable(result);
PaintBrush *const canvas = new PaintBrush(710, 400, layout->elementAt(0,0));
canvas->decorationStyle().setBorder(WBorder::Solid);
new WText("Color chooser:", layout->elementAt(0,1));
WTable* colorTable = new WTable(layout->elementAt(0,1));
addColor(canvas, colorTable->elementAt(0, 0), WColor(black));
addColor(canvas, colorTable->elementAt(0, 1), WColor(red));
addColor(canvas, colorTable->elementAt(1, 0), WColor(green));
addColor(canvas, colorTable->elementAt(1, 1), WColor(blue));
new WBreak(layout->elementAt(0,1));
WPushButton* clearButton = new WPushButton("Clear", layout->elementAt(0,1));
clearButton->clicked().connect(canvas, &PaintBrush::clear);
layout->elementAt(0,1)->setPadding(3);
return result;
}
|