Dillo v3.1.1-95-g3af05307
Loading...
Searching...
No Matches
ui.hh
Go to the documentation of this file.
1#ifndef __DW_UI_HH__
2#define __DW_UI_HH__
3
4#ifndef __INCLUDED_FROM_DW_CORE_HH__
5# error Do not include this file directly, use "core.hh" instead.
6#endif
7
8namespace dw {
9namespace core {
10
214namespace ui {
215
216class Resource;
217
223class Embed: public Widget
224{
225 friend class Resource;
226
227private:
229
230protected:
234
235 int getAvailWidthOfChild (Widget *child, bool forceValue);
236 int getAvailHeightOfChild (Widget *child, bool forceValue);
239 void (*splitHeightFun) (int, int*, int*),
240 bool allowDecreaseWidth,
241 bool allowDecreaseHeight);
243 bool useAdjustmentWidth);
244
246
250
251public:
252 static int CLASS_ID;
253
255 ~Embed();
256
257 void setDisplayed (bool displayed);
258 void setEnabled (bool enabled);
259 void draw (View *view, Rectangle *area, DrawingContext *context);
260 Iterator *iterator (Content::Type mask, bool atEnd);
262
263 inline Resource *getResource () { return resource; }
264
267 bool allowDecreaseWidth)
268 { Widget::correctReqWidthOfChild (child, requisition, allowDecreaseWidth); }
269
272 void (*splitHeightFun) (int, int*,
273 int*),
274 bool allowDecreaseHeight)
275 { Widget::correctReqHeightOfChild (child, requisition, splitHeightFun,
276 allowDecreaseHeight); }
277
279 bool useAdjustmentWidth)
280 { Widget::correctExtremesOfChild (child, extremes, useAdjustmentWidth); }
281};
282
289{
290 friend class Embed;
291
292public:
297 {
298 public:
299 virtual void activate (Resource *resource) = 0;
300 virtual void enter (Resource *resource) = 0;
301 virtual void leave (Resource *resource) = 0;
302 };
307 {
308 public:
309 virtual void clicked (Resource *resource, EventButton *event) = 0;
310 };
311
312private:
314 {
315 protected:
316 bool emitToReceiver (lout::signal::Receiver *receiver, int signalNo,
317 int argc, Object **argv);
318 public:
319 inline void connectActivate (ActivateReceiver *receiver) {
320 connect (receiver); }
321 void emitActivate (Resource *resource);
322 void emitEnter (Resource *resource);
323 void emitLeave (Resource *resource);
324 };
325
327 {
328 protected:
329 bool emitToReceiver (lout::signal::Receiver *receiver, int signalNo,
330 int argc, Object **argv);
331 public:
332 inline void connectClicked (ClickedReceiver *receiver) {
333 connect (receiver); }
334 void emitClicked (Resource *resource, EventButton *event);
335 };
336
340
341 void emitEnter ();
342 void emitLeave ();
343protected:
344 inline void queueResize (bool extremesChanged) {
345 if (embed) embed->queueResize (0, extremesChanged);
346 }
347
348 virtual Embed *getEmbed () { return embed; }
349 virtual void setEmbed (Embed *embed);
350
351 inline void emitActivate () {
352 return activateEmitter.emitActivate (this); }
353 inline void emitClicked (EventButton *event) {
354 clickedEmitter.emitClicked (this, event); }
355
356public:
357 inline Resource ()
358 { embed = NULL; DBG_OBJ_CREATE ("dw::core::ui::Resource"); }
359
360 virtual ~Resource ();
361
362 virtual void sizeRequest (Requisition *requisition) = 0;
363 virtual void getExtremes (Extremes *extremes);
364 virtual void sizeAllocate (Allocation *allocation);
365
366 virtual int getAvailWidthOfChild (Widget *child, bool forceValue);
367 virtual int getAvailHeightOfChild (Widget *child, bool forceValue);
368 virtual void correctRequisitionOfChild (Widget *child,
369 Requisition *requisition,
370 void (*splitHeightFun) (int, int*,
371 int*),
372 bool allowDecreaseWidth,
373 bool allowDecreaseHeight);
374 virtual void correctExtremesOfChild (Widget *child, Extremes *extremes,
375 bool useAdjustmentWidth);
376 virtual void containerSizeChangedForChildren ();
377
378 virtual void setDisplayed (bool displayed);
379 virtual void draw (View *view, Rectangle *area, DrawingContext *context);
380 virtual Iterator *iterator (Content::Type mask, bool atEnd) = 0;
381 virtual void setStyle (style::Style *style);
382
383 virtual bool isEnabled () = 0;
384 virtual void setEnabled (bool enabled) = 0;
385
386 inline void connectActivate (ActivateReceiver *receiver) {
387 activateEmitter.connectActivate (receiver); }
388 inline void connectClicked (ClickedReceiver *receiver) {
389 clickedEmitter.connectClicked (receiver); }
390};
391
392
394{};
395
400{
401public:
402 Iterator *iterator (Content::Type mask, bool atEnd);
403
404 virtual const char *getLabel () = 0;
405 virtual void setLabel (const char *label) = 0;
406};
407
409{
410private:
412 {
413 public:
415
416 void resizeQueued (bool extremesChanged);
417 };
418
419 friend class LayoutReceiver;
421
423
424protected:
427
428 void setEmbed (Embed *embed);
429
430 virtual Platform *createPlatform () = 0;
431 virtual void setLayout (Layout *layout) = 0;
432
433 virtual int reliefXThickness () = 0;
434 virtual int reliefYThickness () = 0;
435
436 void init (Widget *widget);
437
438public:
441
442 void sizeRequest (Requisition *requisition);
443 void getExtremes (Extremes *extremes);
444 void sizeAllocate (Allocation *allocation);
445
446 int getAvailWidthOfChild (Widget *child, bool forceValue);
447 int getAvailHeightOfChild (Widget *child, bool forceValue);
449 Requisition *requisition,
450 void (*splitHeightFun) (int, int*, int*),
451 bool allowDecreaseWidth,
452 bool allowDecreaseHeight);
453 void correctExtremesOfChild (Widget *child, Extremes *extremes,
454 bool useAdjustmentWidth);
456
457 Iterator *iterator (Content::Type mask, bool atEnd);
458 int getClickX () {return click_x;};
459 int getClickY () {return click_y;};
460};
461
467{
468public:
469 virtual void addItem (const char *str, bool enabled, bool selected) = 0;
470 virtual void setItem (int index, bool selected) = 0;
471 virtual void pushGroup (const char *name, bool enabled) = 0;
472 virtual void popGroup () = 0;
473
474 virtual int getNumberOfItems () = 0;
475 virtual bool isSelected (int index) = 0;
476};
477
511
513{
514};
515
517{
518public:
519 Iterator *iterator (Content::Type mask, bool atEnd);
520
521 virtual const char *getText () = 0;
522 virtual void setText (const char *text) = 0;
523 virtual bool isEditable () = 0;
524 virtual void setEditable (bool editable) = 0;
525};
526
528{
529public:
530 enum { UNLIMITED_SIZE = -1 };
531 virtual void setMaxLength (int maxlen) = 0;
532};
533
535{
536};
537
538
540{
541public:
542 virtual bool isActivated () = 0;
543 virtual void setActivated (bool activated) = 0;
544};
545
547{
548public:
549 Iterator *iterator (Content::Type mask, bool atEnd);
550};
551
553{
554public:
556 {
557 protected:
559 virtual ~GroupIterator ();
560
561 public:
562 virtual bool hasNext () = 0;
564 virtual void unref () = 0;
565 };
566
572
573 Iterator *iterator (Content::Type mask, bool atEnd);
574};
575
576
581{
582public:
584 = 0;
586 bool relief)
587 = 0;
589 selectionMode, int rows) = 0;
591 virtual EntryResource *createEntryResource (int size, bool password,
592 const char *label,
593 const char *placeholder) = 0;
595 int rows,
596 const char *placeholder) = 0;
597 virtual CheckButtonResource *createCheckButtonResource (bool activated) = 0;
599 *groupedWith,
600 bool activated) = 0;
601};
602
603} // namespace ui
604} // namespace core
605} // namespace dw
606
607#endif // __DW_UI_HH__
Set at the top when drawing.
Definition types.hh:295
Represents a button press or release event.
Definition events.hh:58
Represents a enter or leave notify event.
Definition events.hh:75
Iterators are used to iterate through the contents of a widget.
Definition iterator.hh:20
Receiver interface different signals.
Definition layout.hh:48
The central class for managing and drawing a widget tree.
Definition layout.hh:17
An interface to encapsulate some platform dependencies.
Definition platform.hh:17
dw::core::Shape implemtation 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
Allocation allocation
The current allocation: size and position, always relative to the canvas.
Definition widget.hh:204
Requisition requisition
Size_request() stores the result of the last call of size_request_impl().
Definition widget.hh:160
virtual void correctExtremesOfChild(Widget *child, Extremes *extremes, bool useAdjustmentWidth)
Definition widget.cc:2128
style::Style * style
Definition widget.hh:150
void queueResize(int ref, bool extremesChanged, bool fast)
This method should be called, when a widget changes its size.
Definition widget.cc:321
void correctReqHeightOfChild(Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseHeight)
Definition widget.cc:2077
void correctReqWidthOfChild(Widget *child, Requisition *requisition, bool allowDecreaseWidth)
Correct a child requisition to fit the parent.
Definition widget.cc:2056
Iterator * iterator(Content::Type mask, bool atEnd)
Definition ui.cc:504
void resizeQueued(bool extremesChanged)
Definition ui.cc:326
void setEmbed(Embed *embed)
Definition ui.cc:356
virtual void setLayout(Layout *layout)=0
LayoutReceiver layoutReceiver
Definition ui.hh:420
virtual Platform * createPlatform()=0
int getAvailHeightOfChild(Widget *child, bool forceValue)
Definition ui.cc:414
void sizeRequest(Requisition *requisition)
Definition ui.cc:370
Iterator * iterator(Content::Type mask, bool atEnd)
Definition ui.cc:484
void sizeAllocate(Allocation *allocation)
Definition ui.cc:401
void correctRequisitionOfChild(Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseWidth, bool allowDecreaseHeight)
Definition ui.cc:424
void correctExtremesOfChild(Widget *child, Extremes *extremes, bool useAdjustmentWidth)
Definition ui.cc:457
void init(Widget *widget)
Definition ui.cc:342
void getExtremes(Extremes *extremes)
Definition ui.cc:385
int getAvailWidthOfChild(Widget *child, bool forceValue)
Definition ui.cc:405
A widget for embedding UI widgets.
Definition ui.hh:224
void correctRequisitionOfChild(Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseWidth, bool allowDecreaseHeight)
Definition ui.cc:81
void setEnabled(bool enabled)
Definition ui.cc:135
void correctExtremesOfChild(Widget *child, Extremes *extremes, bool useAdjustmentWidth)
Definition ui.cc:92
void leaveNotifyImpl(core::EventCrossing *event)
Definition ui.cc:111
void enterNotifyImpl(core::EventCrossing *event)
Definition ui.cc:105
void correctReqHeightOfChildNoRec(Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseHeight)
Definition ui.hh:270
int getAvailHeightOfChild(Widget *child, bool forceValue)
Definition ui.cc:76
Resource * resource
Definition ui.hh:228
static int CLASS_ID
Definition ui.hh:252
void draw(View *view, Rectangle *area, DrawingContext *context)
Area is given in widget coordinates.
Definition ui.cc:140
void setDisplayed(bool displayed)
Definition ui.cc:130
Iterator * iterator(Content::Type mask, bool atEnd)
Return an iterator for this widget.
Definition ui.cc:146
int getAvailWidthOfChild(Widget *child, bool forceValue)
Computes the content width available of a child widget.
Definition ui.cc:71
void getExtremesSimpl(Extremes *extremes)
Simple variant, to be implemented by widgets with extremes not depending on positions.
Definition ui.cc:58
Resource * getResource()
Definition ui.hh:263
void correctReqWidthOfChildNoRec(Widget *child, Requisition *requisition, bool allowDecreaseWidth)
Definition ui.hh:265
void sizeAllocateImpl(Allocation *allocation)
See Sizes of Dillo Widgets.
Definition ui.cc:66
void sizeRequestSimpl(Requisition *requisition)
Simple variant, to be implemented by widgets with sizes not depending on positions.
Definition ui.cc:51
void containerSizeChangedForChildren()
Definition ui.cc:98
bool buttonPressImpl(core::EventButton *event)
Definition ui.cc:117
void setStyle(style::Style *style)
Change the style of a widget.
Definition ui.cc:151
virtual void correctExtremesOfChildNoRec(Widget *child, Extremes *extremes, bool useAdjustmentWidth)
Definition ui.hh:278
virtual void setMaxLength(int maxlen)=0
Interface for labelled buttons resources.
Definition ui.hh:400
Iterator * iterator(Content::Type mask, bool atEnd)
Definition ui.cc:316
virtual const char * getLabel()=0
virtual void setLabel(const char *label)=0
@ SELECTION_AT_MOST_ONE
At most one item is selected.
Definition ui.hh:503
@ SELECTION_MULTIPLE
An arbitrary number of items may be selected.
Definition ui.hh:508
@ SELECTION_EXACTLY_ONE
Exactly one item is selected.
Definition ui.hh:487
@ SELECTION_EXACTLY_ONE_BY_USER
Exactly one item is selected, except possibly at the beginning.
Definition ui.hh:495
virtual RadioButtonResource * getNext()=0
virtual GroupIterator * groupIterator()=0
Return an iterator, to access all radio button resources within the group.
Iterator * iterator(Content::Type mask, bool atEnd)
Definition ui.cc:518
A factory for the common resource.
Definition ui.hh:581
virtual OptionMenuResource * createOptionMenuResource()=0
virtual EntryResource * createEntryResource(int size, bool password, const char *label, const char *placeholder)=0
virtual MultiLineTextResource * createMultiLineTextResource(int cols, int rows, const char *placeholder)=0
virtual RadioButtonResource * createRadioButtonResource(RadioButtonResource *groupedWith, bool activated)=0
virtual CheckButtonResource * createCheckButtonResource(bool activated)=0
virtual ListResource * createListResource(ListResource::SelectionMode selectionMode, int rows)=0
virtual ComplexButtonResource * createComplexButtonResource(Widget *widget, bool relief)=0
virtual LabelButtonResource * createLabelButtonResource(const char *label)=0
bool emitToReceiver(lout::signal::Receiver *receiver, int signalNo, int argc, Object **argv)
A sub class must implement this for a call to a single receiver.
Definition ui.cc:159
void emitActivate(Resource *resource)
Definition ui.cc:183
void connectActivate(ActivateReceiver *receiver)
Definition ui.hh:319
Receiver interface for the "activate" signal.
Definition ui.hh:297
virtual void activate(Resource *resource)=0
virtual void leave(Resource *resource)=0
virtual void enter(Resource *resource)=0
bool emitToReceiver(lout::signal::Receiver *receiver, int signalNo, int argc, Object **argv)
A sub class must implement this for a call to a single receiver.
Definition ui.cc:295
void connectClicked(ClickedReceiver *receiver)
Definition ui.hh:332
void emitClicked(Resource *resource, EventButton *event)
Definition ui.cc:305
Receiver interface for the "clicked" signal.
Definition ui.hh:307
virtual void clicked(Resource *resource, EventButton *event)=0
Basic interface for all resources.
Definition ui.hh:289
virtual ~Resource()
Definition ui.cc:206
virtual void setEnabled(bool enabled)=0
void connectClicked(ClickedReceiver *receiver)
Definition ui.hh:388
virtual Iterator * iterator(Content::Type mask, bool atEnd)=0
virtual void containerSizeChangedForChildren()
Definition ui.cc:268
virtual int getAvailWidthOfChild(Widget *child, bool forceValue)
Definition ui.cc:236
virtual int getAvailHeightOfChild(Widget *child, bool forceValue)
Definition ui.cc:243
virtual bool isEnabled()=0
virtual void sizeAllocate(Allocation *allocation)
Definition ui.cc:232
virtual void setEmbed(Embed *embed)
Definition ui.cc:211
void connectActivate(ActivateReceiver *receiver)
Definition ui.hh:386
ClickedEmitter clickedEmitter
Definition ui.hh:339
virtual void setDisplayed(bool displayed)
Definition ui.cc:273
virtual void draw(View *view, Rectangle *area, DrawingContext *context)
Definition ui.cc:277
virtual void correctExtremesOfChild(Widget *child, Extremes *extremes, bool useAdjustmentWidth)
Definition ui.cc:261
void emitClicked(EventButton *event)
Definition ui.hh:353
virtual void setStyle(style::Style *style)
Definition ui.cc:281
virtual void correctRequisitionOfChild(Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseWidth, bool allowDecreaseHeight)
Definition ui.cc:250
virtual void getExtremes(Extremes *extremes)
Definition ui.cc:216
void queueResize(bool extremesChanged)
Definition ui.hh:344
virtual Embed * getEmbed()
Definition ui.hh:348
ActivateEmitter activateEmitter
Definition ui.hh:338
void emitActivate()
Definition ui.hh:351
virtual void sizeRequest(Requisition *requisition)=0
Base interface for dw::core::ui::ListResource and dw::core::ui::OptionMenuResource.
Definition ui.hh:467
virtual void pushGroup(const char *name, bool enabled)=0
virtual bool isSelected(int index)=0
virtual void setItem(int index, bool selected)=0
virtual void addItem(const char *str, bool enabled, bool selected)=0
Iterator * iterator(Content::Type mask, bool atEnd)
Definition ui.cc:495
virtual void setText(const char *text)=0
virtual const char * getText()=0
virtual bool isEditable()=0
virtual void setEditable(bool editable)=0
virtual void setActivated(bool activated)=0
This is the base class for many other classes, which defines very common virtual methods.
Definition object.hh:25
The base class for signal emitters.
Definition signal.hh:213
void connect(Receiver *receiver)
Connect a receiver to the emitter.
Definition signal.cc:65
The base class for signal receiver base classes.
Definition signal.hh:254
#define DBG_OBJ_CREATE(klass)
Dw is in this namespace, or sub namespaces of this one.
Represents the allocation, i.e.
Definition types.hh:164