Laxkit
0.0.7.1
|
Simple class for a button that is an icon with optional label. Sends message when pressed. More...
Public Member Functions | |
Button (anXWindow *parnt, const char *nname, const char *ntitle, unsigned long nstyle, int xx, int yy, int ww, int hh, int brder, anXWindow *prev, unsigned long nowner, const char *nsendmes, int nid=-1, const char *nlabel=NULL, const char *filename=NULL, LaxImage *img=NULL, int npad=-1, int ngap=-1) | |
virtual | ~Button () |
Calls dec_count() on images. | |
virtual const char * | whattype () |
virtual int | SetGraphic (int newthing, int newwidth, int newheight) |
Use a graphic instead of an image. | |
virtual int | SetIcon (const char *filename, int makebw=0) |
Return 0 on success, else nonzero error. | |
virtual int | SetIcon (LaxImage *img, int makebw=0) |
Return 0 on success, 1 otherwise. If makebw, then make a black and white copy too. | |
virtual const char * | Label (unsigned int which) |
Pass in something like BUTTON_OK or BUTTON_CANCEL. | |
virtual const char * | Label (const char *nlabel) |
Change the label to nlabel, and set needtodraw. | |
virtual const char * | Label () |
Return what is the current label. | |
virtual void | draw () |
virtual void | WrapToExtent (int which) |
Set win_w (if which&1) and win_h (if which&2) to the extent of the icon/label. | |
virtual LaxFiles::Attribute * | dump_out_atts (LaxFiles::Attribute *att, int what, anObject *context) |
virtual void | dump_in_atts (LaxFiles::Attribute *att, int flag, anObject *context) |
Public Member Functions inherited from Laxkit::ButtonBase | |
ButtonBase (anXWindow *parnt, const char *nname, const char *ntitle, unsigned long nstyle, int xx, int yy, int ww, int hh, int brder, anXWindow *prev, unsigned long nowner, const char *nsendmes, int nid=0) | |
virtual | ~ButtonBase () |
Detaches button from a button group, if any. | |
virtual int | Grayed () |
Return anXWindow::Grayed()|(state==LAX_GRAY). | |
virtual int | Grayed (int g) |
virtual int | LBDown (int x, int y, unsigned int wstate, int count, const LaxMouse *d) |
virtual int | LBUp (int x, int y, unsigned int wstate, const LaxMouse *d) |
virtual int | WheelDown (int x, int y, unsigned int wstate, int count, const LaxMouse *d) |
For Momentary buttons, send() with direction=1. | |
virtual int | WheelUp (int x, int y, unsigned int wstate, int count, const LaxMouse *d) |
For Momentary buttons, send() with direction=-1. | |
virtual int | MouseMove (int x, int y, unsigned int state, const LaxMouse *d) |
virtual int | CharInput (unsigned int ch, const char *buffer, int len, unsigned int state, const LaxKeyboard *d) |
Sends on enter. | |
virtual int | Event (const EventData *e, const char *mes) |
On enter or leave, swap oldstate and newstate. | |
virtual int | send (int deviceid, int direction) |
Send a SimpleMessage with type==LAX_ButtonEvent. | |
virtual void | Refresh () |
virtual void | drawon () |
virtual void | drawoff () |
virtual void | drawgrayed () |
virtual void | drawother () |
virtual int | toggle () |
If state==LAX_ON, make LAX_OFF and vice versa, and set needtodraw=1. Returns state. Does net send. | |
virtual int | State (int newstate) |
Set the state to newstate (if a button is not currently pressed). Typically LAX_ON or LAX_OFF. | |
virtual int | State () |
Return the state. | |
Public Member Functions inherited from Laxkit::anXWindow | |
anXWindow (anXWindow *parnt, const char *nname, const char *ntitle, unsigned long nstyle, int xx, int yy, int ww, int hh, int brder, anXWindow *prev, unsigned long nowner, const char *nsend) | |
Constructor. | |
virtual | ~anXWindow () |
anXWindow destructor. Its X window should have been XDestroy'd before here. | |
virtual const char * | WindowTitle (int which=0) |
Return basically the name of the window. | |
virtual void | WindowTitle (const char *newtitle) |
Change the title of the window. This text would usually be displayed in the bar provided by a window manager. | |
virtual const char * | tooltip (int mouseid=0) |
By default, return win_tooltip. | |
virtual const char * | tooltip (const char *newtooltip) |
Replace the current tooltip, return the current tooltip (after replacing). | |
virtual anXWindow * | findChildWindowByTitle (const char *title) |
Find the first immediate child window that has win_title==title. | |
virtual anXWindow * | findChildWindowByName (const char *name) |
Find the first immediate child window that has win_name==name. | |
virtual int | preinit () |
virtual int | init () |
Empty placeholeder. Just returns 0. | |
virtual int | close () |
Called by anXApp from anXApp::destroywindow() when a window is to be destroyed. | |
virtual int | Idle (int tid=0) |
anXWindow::Idle() is an empty placeholeder. Just returns 1. | |
virtual Displayer * | MakeCurrent () |
virtual int | Needtodraw () |
Default is to return needtodraw. | |
virtual void | Needtodraw (int nntd) |
If 0, then the window does not need refreshing. Otherwise it does. | |
virtual int | deletenow () |
Return whether the window is allowed to be deleted. | |
virtual int | setWinStyle (unsigned int stylebit, int newvalue) |
Control various window related basic styling of win_style. | |
virtual int | getWinStyle (unsigned int stylebit) |
Currently, simply return win_style&stylebit. | |
virtual void | installColors (WindowColors *newcolors) |
Dec_count old and inc_count new. | |
virtual ShortcutHandler * | GetShortcuts () |
Return a ShortcutHandler that contains stacks of bound shortcuts and possible window actions. | |
virtual int | PerformAction (int action_number) |
virtual int | ExposeChange (ScreenEventData *e) |
Default behavior on Expose events is to call Needtodraw(1). | |
virtual int | DeviceChange (const DeviceEventData *e) |
virtual int | KeyUp (unsigned int ch, unsigned int state, const LaxKeyboard *kb) |
Called when a key is released. | |
virtual int | ButtonDown (int button, int x, int y, unsigned int state, int count, const LaxMouse *m) |
virtual int | ButtonUp (int button, int x, int y, unsigned int state, const LaxMouse *m) |
virtual int | MBDown (int x, int y, unsigned int state, int count, const LaxMouse *d) |
Default is just to return 1. | |
virtual int | MBUp (int x, int y, unsigned int state, const LaxMouse *d) |
Default is just to return 1. | |
virtual int | RBDown (int x, int y, unsigned int state, int count, const LaxMouse *d) |
Default is just to return 1. | |
virtual int | RBUp (int x, int y, unsigned int state, const LaxMouse *d) |
Default is just to return 1. | |
virtual int | FocusOn (const FocusChangeData *e) |
Increment win_active, and highlights the window's border, if the event refers to this window. | |
virtual int | FocusOff (const FocusChangeData *e) |
Decrements win_active, and de-highlights the window's border if win_active==0, if event is a real focus off. | |
virtual int | MoveResize (int nx, int ny, int nw, int nh) |
Move and resize the window. | |
virtual int | Resize (int nw, int nh) |
Resize with new nw, and nh. | |
virtual void | contentChanged () |
Windows may call this when their contents change. | |
virtual void | selectionChanged () |
Windows may call this when their selections change. | |
virtual anXWindow * | GetController () |
Return the window most relevant for tab control loops. | |
virtual int | SelectNextControl (const LaxDevice *d) |
Transfer focus to nextcontrol. | |
virtual int | SelectPrevControl (const LaxDevice *d) |
Transfer the focus to prevcontrol. | |
virtual void | ControlActivation (int on) |
Do special activation or not when controls are activated by tabbing. | |
virtual int | AddPrevControl (anXWindow *prev) |
virtual int | AddNextControl (anXWindow *next) |
virtual int | ConnectControl (anXWindow *towhat, int after=1) |
Connect towhat to this. Used for tab loops. | |
virtual int | CloseControlLoop () |
Close a tab loop. | |
virtual void | SetOwner (anXWindow *nowner, const char *mes=NULL, unsigned int send_mask=0) |
Set the new owner and control message. | |
virtual void | SetOwner (unsigned long nowner_id, const char *mes=NULL, unsigned int send_mask=0) |
virtual void | dump_out (FILE *f, int indent, int what, anObject *context) |
Simple dumping function. | |
Public Member Functions inherited from Laxkit::Tagged | |
virtual int | HasTag (const char *tag, int casematters) |
Return whether the tag exists. | |
virtual int | NumberOfTags () |
Return the number of tags, strangely enough. | |
virtual const char * | GetTag (int i) |
Return const pointer to the tag text for tag number i, where i==0 is the first tag. | |
virtual char * | GetAllTags () |
Return a new char[] with a space separated list of all the tags. | |
virtual int | InsertTags (const char *tags, int casematters) |
Insert tags from a string such as 'tag1 tag2 tag3 "tag with spaces" tag4'. | |
virtual int | InsertTag (const char *tag, int casematters) |
Insert tag if it doesn't exist already. | |
virtual int | RemoveTag (const char *tag) |
The tag must be an exact match. | |
virtual int | RemoveTag (int i) |
Remove tag number i. i must be in range [0..NumberOfTags()-1]. | |
virtual void | FlushTags () |
Public Member Functions inherited from LaxFiles::DumpUtility | |
virtual void | dump_in (FILE *f, int indent, int what, Laxkit::anObject *loadcontext, Attribute **att) |
Read in a file segment as an Attribute, and pass parsing duties to dump_in_atts. | |
virtual | ~DumpUtility () |
Empty virtual destructor. | |
Public Member Functions inherited from Laxkit::aDrawable | |
aDrawable (Drawable d=0) | |
virtual int | DrawableType () |
virtual int | ValidDrawable () |
Public Attributes | |
int | pad |
int | gap |
int | labelstyle |
Public Attributes inherited from Laxkit::ButtonBase | |
unsigned int | highlight |
unsigned int | shadow |
int | bevel |
Public Attributes inherited from Laxkit::anXWindow | |
WindowColors * | win_colors |
anXApp * | app |
char * | win_name |
An arbitrary string to be used as an id. | |
char * | win_title |
The title of the window. | |
anXWindow * | win_parent |
int | win_screen |
unsigned long | win_style |
int | win_x |
int | win_y |
int | win_w |
int | win_h |
unsigned int | win_border |
int | win_pointer_shape |
Identifier for a stock mouse shape. | |
char | win_on |
Nonzero if the window is mapped. | |
char | win_active |
Should be positive when the window has a keyboard focus, 0 otherwise. | |
unsigned long | win_owner |
Who gets control messages from this window. | |
unsigned int | win_owner_send_mask |
char * | win_sendthis |
The type of message that gets sent to owner. | |
anXWindow * | nextcontrol |
anXWindow * | prevcontrol |
Public Attributes inherited from Laxkit::Tagged | |
int | sorttags |
Protected Attributes | |
LaxImage * | image |
LaxImage * | bwimage |
int | thing |
int | thingw |
int | thingh |
char * | label |
Protected Attributes inherited from Laxkit::ButtonBase | |
int | mousein |
The number of mice in the button, so 0 if none. | |
int | state |
int | oldstate |
int | id |
ButtonBase * | nextbutton |
ButtonBase * | prevbutton |
ButtonDownInfo | buttondown |
unsigned int | button_style |
Protected Attributes inherited from Laxkit::anXWindow | |
char * | win_tooltip |
Convenience variable to hold the window's tooltip, if any. | |
int | needtodraw |
RefPtrStack< anXWindow > | _kids |
Stack of children of the window. | |
Protected Attributes inherited from Laxkit::Tagged | |
PtrStack< char > | list_of_tags |
Simple class for a button that is an icon with optional label. Sends message when pressed.
If the image is not valid, then the text is used. If neither are valid, then no image is drawn, but the bevel will still be drawn.
labelstyle can be LAX_ICON_ONLY, LAX_TEXT_ONLY, LAX_TEXT_ICON, LAX_ICON_TEXT, You can specify for this with the corresponding styles: IBUT_ICON_ONLY, IBUT_TEXT_ONLY, IBUT_TEXT_ICON, IBUT_ICON_TEXT
Laxkit::Button::Button | ( | anXWindow * | parnt, |
const char * | nname, | ||
const char * | ntitle, | ||
unsigned long | nstyle, | ||
int | xx, | ||
int | yy, | ||
int | ww, | ||
int | hh, | ||
int | brder, | ||
anXWindow * | prev, | ||
unsigned long | nowner, | ||
const char * | nsendmes, | ||
int | nid = -1 , |
||
const char * | nlabel = NULL , |
||
const char * | filename = NULL , |
||
LaxImage * | img = NULL , |
||
int | npad = -1 , |
||
int | ngap = -1 |
||
) |
If img, then install img in preference to filename.
Does not call inc_count() on the image.
References isblank(), Label(), newstr(), SetIcon(), and WrapToExtent().
|
virtual |
Implements Laxkit::ButtonBase.
References Laxkit::LaxImage::doneForNow(), Laxkit::draw_bevel(), Laxkit::draw_thing(), Laxkit::fill_rectangle(), Laxkit::getextent(), Laxkit::ButtonBase::Grayed(), Laxkit::LaxImage::h(), Laxkit::image_out, Laxkit::ButtonBase::mousein, Laxkit::textout(), and Laxkit::LaxImage::w().
|
virtual |
Default is to read in text, and whatever anXWindow reads.
Reimplemented from Laxkit::anXWindow.
References Laxkit::PtrStack< T >::e, Label(), makestr(), Laxkit::PtrStack< T >::n, SetIcon(), Laxkit::anXWindow::setWinStyle(), and Laxkit::anXWindow::win_sendthis.
|
virtual |
Append to att if att!=NULL, else return a new Attribute whose name is whattype().
Default is to add attributes for "text", and whatever anXWindow adds.
Reimplemented from Laxkit::anXWindow.
References Label(), LaxFiles::Attribute::push(), Laxkit::anXWindow::win_name, and Laxkit::anXWindow::win_sendthis.
Pass in something like BUTTON_OK or BUTTON_CANCEL.
Choices are: Ok, Cancel, Open, Save, Save As, Save All, Close, Close All, Quit, Quit Anyway, Print, Preview, Yes, No, and Overwrite.
Referenced by Laxkit::FileDialog::OkButton().
Change the label to nlabel, and set needtodraw.
Return what the label is made into.
References makestr().
Use a graphic instead of an image.
This is something that can be drawn with draw_thing().
This will dec_count the image if present.
Return 0 for thing installed. Nonzero for no change.
References Laxkit::anObject::dec_count(), and Laxkit::getextent().
Referenced by Laxkit::MenuButton::MenuButton().
Return 0 on success, else nonzero error.
if makebw, then also make a black and white version of the icon.
References Laxkit::anObject::dec_count(), and Laxkit::load_image.
Referenced by Button(), and dump_in_atts().
Return 0 on success, 1 otherwise. If makebw, then make a black and white copy too.
Transfers pointer, does not make copy and does not call inc_count() on img.
References Laxkit::anObject::dec_count(), and Laxkit::LaxImage::imagestate().