Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

ugadgets.hpp

00001 /* ==================================================== ======== ======= * 00002 * 00003 * ugadgets.hpp 00004 * Ubit Project [Elc::2003] 00005 * Author: Eric Lecolinet 00006 * 00007 * Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs 00008 * 00009 * (C) 1999-2003 Eric Lecolinet @ ENST Paris 00010 * WWW: http://www.enst.fr/~elc/ubit Email: elc@enst.fr (subject: ubit) 00011 * 00012 * *********************************************************************** 00013 * COPYRIGHT NOTICE : 00014 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 00015 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 00016 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 00017 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 00018 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION. 00019 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS. 00020 * *********************************************************************** 00021 * 00022 * ==================================================== [Elc:03] ======= * 00023 * ==================================================== ======== ======= */ 00024 00025 #ifndef _ugadgets_hpp_ 00026 #define _ugadgets_hpp_ 00027 //pragma ident "@(#)ugadgets.hpp ubit:03.06.04" 00028 #include <ubit/ustr.hpp> 00029 #include <ubit/ubox.hpp> 00030 #include <ubit/uedit.hpp> 00031 00032 00035 class USepar: public UBox { 00036 int orient; 00037 public: 00038 static UStyle *hstyle, *vstyle; 00039 00040 USepar(const class UOrient&, const UArgs& a = UArgs::none); 00041 USepar(const UArgs& a = UArgs::none); 00042 00043 friend USepar& usepar(const UArgs& a = UArgs::none); 00044 friend USepar& usepar(const class UOrient&, const UArgs& a = UArgs::none); 00045 friend USepar& uhsepar(const UArgs& a = UArgs::none); 00046 friend USepar& uvsepar(const UArgs& a = UArgs::none); 00047 00048 virtual const UStyle& getStyle(UContext*) const; 00049 static const UStyle& makeVStyle(); 00050 static const UStyle& makeHStyle(); 00051 }; 00052 00053 /* ==================================================== [Elc:03] ======= */ 00054 /* ==================================================== ======== ======= */ 00055 00072 class ULabel: public UBox { 00073 public: 00074 static UStyle *style; 00075 00076 ULabel(const UArgs& a = UArgs::none); 00078 00079 friend ULabel& ulabel(const UArgs& a = UArgs::none) {return *new ULabel(a);} 00081 00082 virtual const UStyle& getStyle(UContext*) const {return makeStyle();} 00083 static const UStyle& makeStyle(); 00084 }; 00085 00086 /* ==================================================== [Elc:03] ======= */ 00087 /* ==================================================== ======== ======= */ 00100 class UItem: public UBox { 00101 public: 00102 static UStyle *style; 00103 00104 UItem(const UArgs& = UArgs::none); 00105 friend UItem& uitem(const UArgs& a = UArgs::none) {return *new UItem(a);} 00106 00107 virtual const UStyle& getStyle(UContext*) const {return makeStyle();} 00108 static const UStyle& makeStyle(); 00109 }; 00110 00111 /* ==================================================== [Elc:03] ======= */ 00112 /* ==================================================== ======== ======= */ 00154 class UButton: public UBox { 00155 public: 00156 static UStyle *style, *menuStyle, *barStyle, *flatStyle, *linkStyle; 00158 00159 UButton(const UArgs& a = UArgs::none); 00161 00162 friend UButton& ubutton(const UArgs& a = UArgs::none) {return *new UButton(a);} 00164 00165 virtual const UStyle& getStyle(UContext*) const; 00173 static const UStyle& makeStyle(); 00174 static const UStyle& makeMenuStyle(); 00175 static const UStyle& makeBarStyle(); 00176 static const UStyle& makeFlatStyle(); 00177 static const UStyle& makeLinkStyle(); 00178 }; 00179 00180 /* ==================================================== ======== ======= */ 00184 class UFlatbutton: public UButton { 00185 public: 00186 UFlatbutton(const UArgs& a = UArgs::none); 00187 friend UFlatbutton& uflatbutton(const UArgs& a = UArgs::none) {return *new UFlatbutton(a);} 00188 00189 virtual const UStyle& getStyle(UContext*) const {return UButton::makeFlatStyle();} 00190 }; 00191 00192 /* ==================================================== ======== ======= */ 00196 class ULinkbutton: public UButton { 00197 public: 00198 ULinkbutton(const UArgs& a = UArgs::none); 00199 friend ULinkbutton& ulinkbutton(const UArgs& a = UArgs::none) {return *new ULinkbutton(a);} 00200 00201 virtual const UStyle& getStyle(UContext*) const {return UButton::makeLinkStyle();} 00202 }; 00203 00204 /* ==================================================== ======== ======= */ 00207 class URadiobutton: public UButton { 00208 public: 00209 URadiobutton(const UArgs& a = UArgs::none); 00210 friend URadiobutton& uradiobutton(const UArgs& a = UArgs::none) {return *new URadiobutton(a);} 00211 00212 virtual const UStyle& getStyle(UContext*) const; 00213 }; 00214 00215 /* ==================================================== ======== ======= */ 00229 class UCheckbox: public UBox { 00230 public: 00232 static UStyle *style, *menuStyle, *barStyle; 00233 00234 UCheckbox(const UArgs& = UArgs::none); 00235 friend UCheckbox& ucheckbox(const UArgs& a = UArgs::none) {return *new UCheckbox(a);}; 00236 00237 virtual const UStyle& getStyle(UContext*) const; 00238 }; 00239 00240 /* ==================================================== [Elc:03] ======= */ 00241 /* ==================================================== ======== ======= */ 00289 class UTextbox: public UBox { 00290 public: 00291 static UStyle *style; 00292 00293 UTextbox(const UArgs& = UArgs::none); 00295 00296 friend UTextbox& utextbox(const UArgs& a = UArgs::none) {return *new UTextbox(a);} 00298 00299 virtual const UStyle& getStyle(UContext*) const {return makeStyle();} 00300 static const UStyle& makeStyle(); 00301 }; 00302 00303 /* ==================================================== [Elc:03] ======= */ 00304 /* ==================================================== ======== ======= */ 00366 class UTextfield: public UTextbox { 00367 public: 00368 UTextfield(const UArgs& = UArgs::none); 00370 00371 friend UTextfield& utextfield(const UArgs& a = UArgs::none) 00372 {return *new UTextfield(a);} 00374 00375 UEdit& edit() {return *pedit;} 00376 const UEdit& edit() const {return *pedit;} 00377 00378 virtual void setEditable(bool state = true) {edit().setEditable(state);} 00379 virtual bool isEditable() const {return edit().isEditable();} 00380 00381 private: 00382 uptr<UEdit> pedit; 00383 }; 00384 00385 /* ==================================================== [Elc:03] ======= */ 00386 /* ==================================================== ======== ======= */ 00458 class UListbox: public UBox { 00459 public: 00460 static UStyle *style; 00461 00462 UListbox(const UArgs& a = UArgs::none); 00463 00464 friend UListbox& ulistbox(const UArgs& a = UArgs::none) 00465 {return *new UListbox(a);} 00466 00467 virtual const UStyle& getStyle(UContext*) const {return makeStyle();} 00468 static const UStyle& makeStyle(); 00469 00470 class UChoice& choice() const {return *pchoice;} 00471 00472 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00473 00474 // inherited: add(), addlist(), etc 00475 00476 UListbox& addItem(UStr*); 00477 UListbox& addItems(const std::vector<UStr*>& str_list); 00478 UListbox& addItems(const UArgs& item_prefix, const std::vector<UStr*>& str_list); 00480 00481 UListbox& addItem(const char*); 00482 UListbox& addItems(const char* string_list[]); 00483 UListbox& addItems(const UArgs& item_prefix, const char* string_list[]); 00485 00486 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00487 // implementation 00488 00489 // modif: UGroup::getBrowsingGroup() fait le necessaire 00490 // virtual UGroup* getBrowsingGroup() {return this;} 00491 00492 protected: 00493 uptr<class UChoice> pchoice; 00494 uptr<UCall> callbacks; 00495 virtual void mouseCB(UEvent&); 00496 }; 00497 00498 /* ==================================================== [Elc:03] ======= */ 00499 /* ==================================================== ======== ======= */ 00535 class UCombobox : public UTextfield { 00536 public: 00537 UCombobox(class UListbox& list, const UArgs& = UArgs::none); 00538 00539 friend UCombobox& ucombobox(class UListbox& list, const UArgs& a = UArgs::none) 00540 {return *new UCombobox(list, a);} 00541 00542 class UListbox& list() {return *plist;} 00543 const class UListbox& list() const {return *plist;} 00544 00545 class UChoice& choice(); 00546 const class UChoice& choice() const; 00547 00548 bool isTextMode() const {return text_only;}; 00549 void setTextMode(bool = true); 00550 UCombobox& textMode(bool st = true) {setTextMode(st); return *this;} 00551 00552 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00553 00554 private: 00555 uptr<class UListbox> plist; 00556 uptr<UGroup> pentry; 00557 uptr<class UMenu> pmenu; 00558 bool text_only; 00559 virtual void changed(bool upd, bool call_cb); 00560 virtual void openMenu(UEvent&); 00561 }; 00562 00563 /* ==================================================== [Elc:03] ======= */ 00564 /* ==================================================== ======== ======= */ 00567 class USpinbox : public UBox { 00568 public: 00569 static UStyle *style; 00570 00571 USpinbox(const UArgs& = UArgs::none); 00573 00574 USpinbox(UIntg& value, const UArgs& = UArgs::none); 00575 USpinbox(UIntg& value, UIntg& increment, const UArgs& = UArgs::none); 00588 friend USpinbox& uspinbox(const UArgs& a = UArgs::none) 00589 {return *new USpinbox(a);} 00590 00591 friend USpinbox& uspinbox(UIntg& value, const UArgs& a = UArgs::none) 00592 {return *new USpinbox(value, a);} 00594 00595 virtual const UStyle& getStyle(UContext*) const {return makeStyle();} 00596 static const UStyle& makeStyle(); 00597 00598 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00599 00600 virtual void setValue(const UIntg&); 00601 virtual void setIncrement(const UIntg&); 00602 virtual void setStr(const UStr&); 00603 00604 UIntg& value() const {return *pvalue;} 00605 UIntg& increment() const {return *pincrement;} 00606 UStr& str() const {return *pstr;} 00614 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00615 // implementation 00616 00617 virtual void constructs(const UArgs& a); 00618 virtual void valueChanged(); 00619 virtual void updateValue(int dir); 00620 00621 private: 00622 uptr<UIntg> pvalue, pincrement; 00623 uptr<UStr> pstr; 00624 UTextbox textbox; 00625 }; 00626 00627 /* ==================================================== [Elc:03] ======= */ 00628 /* ==================================================== ======== ======= */ 00631 class UAlertbox : public UVbox { 00632 UGroup message; 00633 00634 public: 00635 UAlertbox(const UArgs& = UArgs::none); 00636 virtual void show(bool = true); 00637 virtual void show(const UStr& mesg); 00638 }; 00639 00640 #endif 00641 /* ==================================================== [TheEnd] ======= */ 00642 /* ==================================================== [Elc:03] ======= */

Generated on Wed Aug 18 07:38:55 2004 for Ubit[Eric.Lecolinet@enst.fr] by doxygen 1.3.7