Dillo
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 
8 namespace dw {
9 namespace core {
10 
214 namespace ui {
215 
216 class Resource;
217 
223 class Embed: public Widget
224 {
225  friend class Resource;
226 
227 private:
229 
230 protected:
234 
235  int getAvailWidthOfChild (Widget *child, bool forceValue);
236  int getAvailHeightOfChild (Widget *child, bool forceValue);
237  void correctRequisitionOfChild (Widget *child,
239  void (*splitHeightFun) (int, int*, int*),
240  bool allowDecreaseWidth,
241  bool allowDecreaseHeight);
243  bool useAdjustmentWidth);
244 
246 
247  void enterNotifyImpl (core::EventCrossing *event);
248  void leaveNotifyImpl (core::EventCrossing *event);
249  bool buttonPressImpl (core::EventButton *event);
250 
251 public:
252  static int CLASS_ID;
253 
254  Embed(Resource *resource);
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);
261  void setStyle (style::Style *style);
262 
263  inline Resource *getResource () { return resource; }
264 
265  inline void correctReqWidthOfChildNoRec (Widget *child,
266  Requisition *requisition,
267  bool allowDecreaseWidth)
268  { Widget::correctReqWidthOfChild (child, requisition, allowDecreaseWidth); }
269 
271  Requisition *requisition,
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 
288 class Resource
289 {
290  friend class Embed;
291 
292 public:
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 
312 private:
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 ();
343 protected:
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 
356 public:
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 {
401 public:
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 {
410 private:
412  {
413  public:
415 
416  void resizeQueued (bool extremesChanged);
417  };
418 
419  friend class LayoutReceiver;
421 
423 
424 protected:
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 
438 public:
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);
448  void correctRequisitionOfChild (Widget *child,
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 {
468 public:
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 
479 {
480 public:
488 
496 
504 
509  };
510 };
511 
513 {
514 };
515 
516 class TextResource: public Resource
517 {
518 public:
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 {
529 public:
530  enum { UNLIMITED_SIZE = -1 };
531  virtual void setMaxLength (int maxlen) = 0;
532 };
533 
535 {
536 };
537 
538 
540 {
541 public:
542  virtual bool isActivated () = 0;
543  virtual void setActivated (bool activated) = 0;
544 };
545 
547 {
548 public:
549  Iterator *iterator (Content::Type mask, bool atEnd);
550 };
551 
553 {
554 public:
556  {
557  protected:
559  virtual ~GroupIterator ();
560 
561  public:
562  virtual bool hasNext () = 0;
563  virtual RadioButtonResource *getNext () = 0;
564  virtual void unref () = 0;
565  };
566 
571  virtual GroupIterator *groupIterator () = 0;
572 
573  Iterator *iterator (Content::Type mask, bool atEnd);
574 };
575 
576 
581 {
582 public:
583  virtual LabelButtonResource *createLabelButtonResource (const char *label)
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__
void sizeAllocateImpl(Allocation *allocation)
See Sizes of Dillo Widgets.
Definition: ui.cc:66
virtual GroupIterator * groupIterator()=0
Return an iterator, to access all radio button resources within the group.
void connectClicked(ClickedReceiver *receiver)
Definition: ui.hh:332
Iterator * iterator(Content::Type mask, bool atEnd)
Return an iterator for this widget.
Definition: ui.cc:146
At most one item is selected.
Definition: ui.hh:503
virtual ListResource * createListResource(ListResource::SelectionMode selectionMode, int rows)=0
Extremes extremes
Analogue to dw::core::Widget::requisition.
Definition: widget.hh:146
void enterNotifyImpl(core::EventCrossing *event)
Definition: ui.cc:105
int getAvailHeightOfChild(Widget *child, bool forceValue)
Definition: ui.cc:76
virtual void setEmbed(Embed *embed)
Definition: ui.cc:211
style::Style * style
Definition: widget.hh:130
virtual void containerSizeChangedForChildren()
Definition: ui.cc:268
virtual void setStyle(style::Style *style)
Definition: ui.cc:281
Iterator * iterator(Content::Type mask, bool atEnd)
Definition: ui.cc:483
void getExtremes(Extremes *extremes)
Definition: ui.cc:385
virtual void correctExtremesOfChild(Widget *child, Extremes *extremes, bool useAdjustmentWidth)
Definition: ui.cc:261
virtual void setLabel(const char *label)=0
void connect(Receiver *receiver)
Connect a receiver to the emitter.
Definition: signal.cc:65
void draw(View *view, Rectangle *area, DrawingContext *context)
Definition: ui.cc:140
virtual void correctExtremesOfChild(Widget *child, Extremes *extremes, bool useAdjustmentWidth)
Definition: widget.cc:1828
Layout * layout
Definition: ui.hh:425
A factory for the common resource.
Definition: ui.hh:580
Definition: ui.hh:393
Requisition requisition
Size_request() stores the result of the last call of size_request_impl().
Definition: widget.hh:140
void containerSizeChangedForChildren()
Definition: ui.cc:478
dw::core::Shape implemtation for simple rectangles.
Definition: types.hh:69
Embed(Resource *resource)
Definition: ui.cc:36
void emitClicked(EventButton *event)
Definition: ui.hh:353
Receiver interface for the "activate" signal.
Definition: ui.hh:296
Type
Definition: types.hh:199
Iterator * iterator(Content::Type mask, bool atEnd)
Definition: ui.cc:503
~Embed()
Definition: ui.cc:45
Definition: ui.hh:516
void setStyle(style::Style *style)
Change the style of a widget.
Definition: ui.cc:151
SelectionMode
Definition: ui.hh:481
Exactly one item is selected, except possibly at the beginning.
Definition: ui.hh:495
ComplexButtonResource()
Definition: ui.cc:334
void correctRequisitionOfChild(Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseWidth, bool allowDecreaseHeight)
Definition: ui.cc:81
The central class for managing and drawing a widget tree.
Definition: layout.hh:16
void containerSizeChangedForChildren()
Definition: ui.cc:98
An arbitrary number of items may be selected.
Definition: ui.hh:508
This is the base class for many other classes, which defines very common virtual methods.
Definition: object.hh:24
Definition: ui.hh:527
void correctExtremesOfChild(Widget *child, Extremes *extremes, bool useAdjustmentWidth)
Definition: ui.cc:456
Represents a button press or release event.
Definition: events.hh:57
Receiver interface for the "clicked" signal.
Definition: ui.hh:306
virtual OptionMenuResource * createOptionMenuResource()=0
Represents a enter or leave notify event.
Definition: events.hh:74
virtual void leave(Resource *resource)=0
Iterator * iterator(Content::Type mask, bool atEnd)
Definition: ui.cc:494
void queueResize(int ref, bool extremesChanged)
Definition: widget.hh:280
Receiver interface different signals.
Definition: layout.hh:47
Resource * resource
Definition: ui.hh:228
Resource * getResource()
Definition: ui.hh:263
The base class for signal emitters.
Definition: signal.hh:212
virtual LabelButtonResource * createLabelButtonResource(const char *label)=0
Iterators are used to iterate through the contents of a widget.
Definition: iterator.hh:19
void correctExtremesOfChild(Widget *child, Extremes *extremes, bool useAdjustmentWidth)
Definition: ui.cc:92
int getClickX()
Definition: ui.hh:458
ClickedEmitter clickedEmitter
Definition: ui.hh:339
virtual RadioButtonResource * createRadioButtonResource(RadioButtonResource *groupedWith, bool activated)=0
virtual void sizeRequest(Requisition *requisition)=0
bool buttonPressImpl(core::EventButton *event)
Definition: ui.cc:117
~ComplexButtonResource()
Definition: ui.cc:364
void setEmbed(Embed *embed)
Definition: ui.cc:356
virtual Iterator * iterator(Content::Type mask, bool atEnd)=0
void connectActivate(ActivateReceiver *receiver)
Definition: ui.hh:319
Definition: style.hh:613
LayoutReceiver layoutReceiver
Definition: ui.hh:420
virtual Platform * createPlatform()=0
void emitLeave()
Definition: ui.cc:290
Definition: types.hh:172
Represents the allocation, i.e. actual position and size of a dw::core::Widget.
Definition: types.hh:163
virtual ComplexButtonResource * createComplexButtonResource(Widget *widget, bool relief)=0
Iterator * iterator(Content::Type mask, bool atEnd)
Definition: ui.cc:517
virtual void setMaxLength(int maxlen)=0
virtual bool isEditable()=0
virtual ~Resource()
Definition: ui.cc:206
#define DBG_OBJ_CREATE(klass)
Definition: debug_rtfl.hh:412
virtual void setText(const char *text)=0
virtual void correctRequisitionOfChild(Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseWidth, bool allowDecreaseHeight)
Definition: ui.cc:250
The base class of all dillo widgets.
Definition: widget.hh:23
virtual int getAvailWidthOfChild(Widget *child, bool forceValue)
Definition: ui.cc:236
Set at the top when drawing.
Definition: types.hh:294
void connectClicked(ClickedReceiver *receiver)
Definition: ui.hh:388
The base class for signal receiver base classes.
Definition: signal.hh:253
void emitActivate()
Definition: ui.hh:351
ComplexButtonResource * resource
Definition: ui.hh:414
static int CLASS_ID
Definition: ui.hh:252
virtual void setActivated(bool activated)=0
virtual Embed * getEmbed()
Definition: ui.hh:348
void correctReqHeightOfChild(Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseHeight)
Definition: widget.cc:1784
Definition: types.hh:179
virtual ~GroupIterator()
Definition: ui.cc:513
void sizeRequest(Requisition *requisition)
Definition: ui.cc:370
virtual CheckButtonResource * createCheckButtonResource(bool activated)=0
virtual bool isSelected(int index)=0
Basic interface for all resources.
Definition: ui.hh:288
virtual void setEditable(bool editable)=0
Allocation allocation
The current allocation: size and position, always relative to the canvas.
Definition: widget.hh:183
virtual void sizeAllocate(Allocation *allocation)
Definition: ui.cc:232
A widget for embedding UI widgets.
Definition: ui.hh:223
void emitActivate(Resource *resource)
Definition: ui.cc:183
int getAvailWidthOfChild(Widget *child, bool forceValue)
Definition: ui.cc:405
void resizeQueued(bool extremesChanged)
Definition: ui.cc:326
void sizeAllocate(Allocation *allocation)
Definition: ui.cc:401
void setEnabled(bool enabled)
Definition: ui.cc:135
Definition: ui.hh:478
int getAvailHeightOfChild(Widget *child, bool forceValue)
Definition: ui.cc:414
virtual void enter(Resource *resource)=0
virtual MultiLineTextResource * createMultiLineTextResource(int cols, int rows, const char *placeholder)=0
virtual void correctExtremesOfChildNoRec(Widget *child, Extremes *extremes, bool useAdjustmentWidth)
Definition: ui.hh:278
virtual void setDisplayed(bool displayed)
Definition: ui.cc:273
void emitEnter(Resource *resource)
Definition: ui.cc:190
Widget * childWidget
Definition: ui.hh:422
ActivateEmitter activateEmitter
Definition: ui.hh:338
virtual void activate(Resource *resource)=0
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtablecell.cc:28
An interface to encapsulate platform dependent drawing.
Definition: view.hh:16
void sizeRequestSimpl(Requisition *requisition)
Simple variant, to be implemented by widgets with sizes not depending on positions.
Definition: ui.cc:51
void setDisplayed(bool displayed)
Definition: ui.cc:130
void correctReqWidthOfChildNoRec(Widget *child, Requisition *requisition, bool allowDecreaseWidth)
Definition: ui.hh:265
virtual bool isEnabled()=0
void emitEnter()
Definition: ui.cc:285
virtual void clicked(Resource *resource, EventButton *event)=0
void correctReqWidthOfChild(Widget *child, Requisition *requisition, bool allowDecreaseWidth)
Definition: widget.cc:1763
virtual const char * getLabel()=0
virtual void draw(View *view, Rectangle *area, DrawingContext *context)
Definition: ui.cc:277
An interface to encapsulate some platform dependencies.
Definition: platform.hh:16
virtual RadioButtonResource * getNext()=0
void emitClicked(Resource *resource, EventButton *event)
Definition: ui.cc:305
int click_y
Definition: ui.hh:426
virtual void setItem(int index, bool selected)=0
void correctRequisitionOfChild(Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseWidth, bool allowDecreaseHeight)
Definition: ui.cc:424
virtual void setEnabled(bool enabled)=0
int click_x
Definition: ui.hh:426
void emitLeave(Resource *resource)
Definition: ui.cc:197
void getExtremesSimpl(Extremes *extremes)
Simple variant, to be implemented by widgets with extremes not depending on positions.
Definition: ui.cc:58
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
Resource()
Definition: ui.hh:357
virtual int getAvailHeightOfChild(Widget *child, bool forceValue)
Definition: ui.cc:243
void init(Widget *widget)
Definition: ui.cc:342
Base interface for dw::core::ui::ListResource and dw::core::ui::OptionMenuResource.
Definition: ui.hh:466
Exactly one item is selected.
Definition: ui.hh:487
void queueResize(bool extremesChanged)
Definition: ui.hh:344
void correctReqHeightOfChildNoRec(Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseHeight)
Definition: ui.hh:270
Iterator * iterator(Content::Type mask, bool atEnd)
Definition: ui.cc:316
virtual void addItem(const char *str, bool enabled, bool selected)=0
Interface for labelled buttons resources.
Definition: ui.hh:399
Embed * embed
Definition: ui.hh:337
virtual void getExtremes(Extremes *extremes)
Definition: ui.cc:216
int getClickY()
Definition: ui.hh:459
virtual EntryResource * createEntryResource(int size, bool password, const char *label, const char *placeholder)=0
virtual void pushGroup(const char *name, bool enabled)=0
virtual const char * getText()=0
int getAvailWidthOfChild(Widget *child, bool forceValue)
Definition: ui.cc:71
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 connectActivate(ActivateReceiver *receiver)
Definition: ui.hh:386
virtual void setLayout(Layout *layout)=0
void leaveNotifyImpl(core::EventCrossing *event)
Definition: ui.cc:111