Dillo v3.2.0-90-g29a46a2d
Loading...
Searching...
No Matches
ruler.cc
Go to the documentation of this file.
1/*
2 * Dillo Widget
3 *
4 * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
5 * Copyright 2025 Rodrigo Arias Mallo <rodarima@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21
22
23#include "ruler.hh"
24#include "../lout/misc.hh"
25
26#include <stdio.h>
27
28namespace dw {
29
30int Ruler::CLASS_ID = -1;
31
33{
34 DBG_OBJ_CREATE ("dw::Ruler");
35 registerName ("dw::Ruler", &CLASS_ID);
36}
37
39{
41}
42
44{
45 /* The ruler will be drawn by using a 1px border, so we substract the
46 * border from the available width when computing the content width. */
47 int w = lout::misc::max(0, getAvailWidth(true) - boxDiffWidth());
48 requisition->width = w;
51}
52
62
64{
65 return true;
66}
67
69{
70 DBG_OBJ_ENTER0 ("resize", 0, "containerSizeChangedForChildren");
71 // Nothing to do.
73}
74
76{
77 return true;
78}
79
81 core::DrawingContext *context)
82{
83 drawWidgetBox (view, area, false);
84}
85
88 *context)
89{
90 // Override (complex) implementation OOFAwareWidget::getWidgetAtPoint().
91
92 if (inAllocation (x, y))
93 return this;
94 else
95 return NULL;
96}
97
99{
101 return new core::EmptyIterator (this, mask, atEnd);
102}
103
104} // namespace dw
~Ruler()
Definition ruler.cc:38
void sizeRequestSimpl(core::Requisition *requisition)
Simple variant, to be implemented by widgets with sizes not depending on positions.
Definition ruler.cc:43
bool isBlockLevel()
Definition ruler.cc:63
bool usesAvailWidth()
Must be implemengted by a method returning true, when getAvailWidth() is called.
Definition ruler.cc:75
static int CLASS_ID
Definition ruler.hh:33
core::Widget * getWidgetAtPoint(int x, int y, core::GettingWidgetAtPointContext *context)
Definition ruler.cc:86
void draw(core::View *view, core::Rectangle *area, core::DrawingContext *context)
Area is given in widget coordinates.
Definition ruler.cc:80
void getExtremesSimpl(core::Extremes *extremes)
Simple variant, to be implemented by widgets with extremes not depending on positions.
Definition ruler.cc:53
core::Iterator * iterator(core::Content::Type mask, bool atEnd)
Return an iterator for this widget.
Definition ruler.cc:98
void containerSizeChangedForChildren()
Definition ruler.cc:68
Ruler()
Definition ruler.cc:32
Set at the top when drawing.
Definition types.hh:295
This implementation of dw::core::Iterator can be used by widgets with no contents.
Definition iterator.hh:97
Set at the top when getting the widget at the point.
Definition types.hh:313
Iterators are used to iterate through the contents of a widget.
Definition iterator.hh:20
dw::core::Shape implementation for simple rectangles.
Definition types.hh:70
An interface to encapsulate platform dependent drawing.
Definition view.hh:17
The base class of all dillo widgets.
Definition widget.hh:44
Extremes extremes
Analogue to dw::core::Widget::requisition.
Definition widget.hh:166
int boxDiffWidth()
Definition widget.hh:495
int getAvailWidth(bool forceValue)
Return available width including margin/border/padding (extraSpace?), not only the content width.
Definition widget.cc:665
void drawWidgetBox(View *view, Rectangle *area, bool inverse)
Draw borders and background of a widget.
Definition widget.cc:1512
Requisition requisition
Size_request() stores the result of the last call of size_request_impl().
Definition widget.hh:160
bool inAllocation(int x, int y)
Definition widget.hh:485
int boxRestHeight()
Definition widget.hh:498
void correctExtremes(Extremes *extremes, bool useAdjustmentWidth)
Definition widget.cc:870
void registerName(const char *className, int *classId)
This method must be called in the constructor for the sub class.
Definition identity.cc:83
#define DBG_OBJ_ENTER0(aspect, prio, funname)
#define DBG_OBJ_DELETE()
#define DBG_OBJ_CREATE(klass)
#define DBG_OBJ_LEAVE()
Dw is in this namespace, or sub namespaces of this one.
T min(T a, T b)
Definition misc.hh:40
T max(T a, T b)
Definition misc.hh:41