Pwrap Generic Functions
From OpenAlchemy.org
Apart from the APIs that we saw above, Pwrap library provides several generic functions. As the name suggests, these can be used for more than one widget. The generic functions are listed below along with brief explanations.
1. void_pw_show(pw_widget_widget);
This is used for showing a hidden widget. This can be applied to any widget.You can refer to the example, dialog box in the Pwrap samples directory.
2. void_pw_show_many(pw_widget_widget, ...);
This is the same as pw_show, but can work on more than one widget.
3. void_pw_hide(pw_widget_widget);
This is used to hide any widget. This can be applied to any widget. You can refer to the example, dialog box in the Pwrap samples directory.
4. void_pw_hide_many(pw_widget_widget, ...);
This is the same as pw_hide, but can work on more than one widget.
5. void_pw_raise(pw_widget_widget);
This will bring the specified widget to the top. For example, if widgets arecreated, such that they overlap each other, we can see one widget obscuring the other. If we want to see a widget fully, doing a raise will bring it into full view. This can be applied to any widget. You can refer to examples, drag widget and labelled frame, in the Pwrap samples directory.
6. void_pw_lower(pw_widget_widget);
This does exactly the opposite of pw_raise. It will push the specified widget behind another widget bringing the widget that is just behind it into view.
7. void_pw_enable(pw_widget_widget);
This is used to bring a widget to active state from a disabled state. This can be applied to any widget. Refer to example, progress bar, in the Pwrap samples directory.
8. void_pw_enable_many(pw_widget_widget, ...);
This is same as pw_enable except that it works on more than one widget.
9. void_pw_disable(pw_widget_widget);
This is used to disable a widget. It can be applied to any widget. Refer to example, progress bar, in the Pwrap samples directory.
10. void_pw_disable_many(pw_widget_widget, ...);
This is same as pw_disable except that it works on more than one widget.
11. void_pw_focus(pw_widget_widget);
As the name goes, this will get the specified widget into focus or selected.For example, if the specified widget is an entry widget, the cursor will be in the entry widget when the application starts. Refer to example, tab example, in the Pwrap samples directory.
12. void_pw_grab(pw_widget_widget);
If you use this function on a widget, all events on the screen go to that widget. For example, the top menu in alchemy uses it. You get the menu by tapping the title in the topbar, but you can make it disappear, by tapping anywhere on the screen. So, when the menu is shown a grab is set on it and on anyevent it is hidden.
13. void_pw_ungrab();
This will ungrab the widget that is set for grab.
14. void_pw_configure(pw_widget_widget, ...);
This function is to configure a widget at any point of time in the program. The only condition is that the specified widget should be already created.
15. void_pw_update(pw_widget_widget, int show);
This function is to update a widget and if the show is 1, it will do a show of that widget, else it will just redraw.
16. void_pw_set_title(pw_widget_widget, const char *title);
This function is used to set the title for any widget, especially the toplevel.
17. void_pw_set_text(pw_widget_widget, const char *text, ...);
This function is used to set the text of the specified widget. This can be applied to all widgets that require text like label and buttons. Widgets likeframes and listbox can not be used with this function.
18. void_pw_set_font(pw_widget_widget, const char *font);
This function is to set the font for a specified widget. Like the above function, this can also be applied only to widgets that require text. The font can be any one of the five fonts as specified in the pwrap.h file in /usr/local/include. They are,
- PW NORMAL FONT
- PW BOLD FONT
- PW SMALL FONT
- PW TINY FONT
- PW LARGE FONT
The above fonts are picopeta fonts designed specially for Amida Simputer.
19. void_pw_set_justify(pw_widget_widget, unsigned justification);
This function is to justify the text. The text can be justified either in left, right or center. The macros are,
- PW JUSTIFY LEFT
- PW JUSTIFY CENTER
- PW JUSTIFY RIGHT
20. void_pw_set_wrap(pw_widget_widget, unsigned wraptype);
This function is used to wrap the text if it exceeds the window size. The text can be wrapped for character or word or no wrap at all. The macros are,
- PW NO WRAP
- PW CHAR WRAP
- PW WORD WRAP
21. void_pw_set_border(pw_widget_widget, unsigned bordertype);
This function is used to set the border for the specified widget. This can be applied to any widget. The different types of borders are,
- PW NO BORDER
- PW RECTANGLE BORDER
- PW BEVELLED BORDER
- PW ELLIPTIC BORDER
22. void_pw_set_tag(pw_widget_widget, const char *tag, ...);
This function is used to set a tag for any widget. Tag names are useful in addressing a widget in a condition.
23. void_pw_set_fgcolor(pw_widget_widget, const char *color);
This is used to set fore ground colour for any widget.
24. void_pw_set_bgcolor(pw_widget_widget, const char *color);
This is used to set back ground colour for any widget.
25. void_pw_set_bgtransparent(pw_widget_widget);
By default, all pwrap widgets are solid. So to make any widget transparent, we can use this function.
26. void_pw_set_bgimage file(pw_widget_widget, const char *file, ...);
This function is used to set an image file in a widget. The image has to be either jpeg, gif, animated gif, png, xpm or a bmp file only.
27. void_pw_set_position(pw_widget_widget, int x, int y);
This function is used to change the position of a widget once it has been created. Refer to example, drag widget, in the pwrap samples directory.
28. void_pw_set_size(pw_widget_widget, unsigned long width, unsigned long height);
This function is used to change the dimension of a widget once it has been created.
29. void_pw_set_normal image(pw_widget_widget, char *filename);
This function can be used only with a button widget. This is used to set an image for a button when it is in normal state.
30. void_pw_set_active image(pw_widget_widget, char *filename);
This function can also be used only with a button widget. This is used to set an image for a button when it is in active state (i.e) when it is pressed.
31. void_pw_set_disabled image(pw_widget_widget, char *filename);
This function can also be used only with a button widget. This is used to set an image for a button when it is in disabled state.
32. void_pw_set_callback(pw_widget_widget, unsigned eventtype, Bool (*callback)(px widget*, px event*));
This function is used to set a callback for any widget on the corresponding event. To know more about events and callbacks refer to section $$$.
33. void_pw_set_callback parameter(pw_widget_widget, unsigned eventtype, <tt>void *parameter);
This is used to send a parameter to the callback function which is set by the pw_set callback. In the callback function, the parameter can be accessed using pw_event callback parameter function.
34. void_pw_get_position(pw_widget_widget, int *x, int *y);
This function is used to get the position of a particular widget.
35. const char *pw_get_text(pw_widget_widget);</tt>
This function is used to get the text from the specified widget. This can beapplied to widgets that already have text.
36. const char *pw_get_tag(pw_widget_widget);</tt>
This function is used to get the tag name of a widget for which the tag is already set.
37. void_pw_get_size(pw_widget_widget, unsigned long *width, unsigned long *height);
This function is used to get the dimension of a widget.
38. void_pw_alchemy command(pw_widget toplevel, int command, const char *data, ...);
This function is used to set an alchemy API for the toplevel. This function can be applied only to the toplevel of an application. Refer to the example,display info, in the pwrap samples directory.
39. void_pw_set_display orientation(pw_widget window, unsigned orientation);
This function is used to set the orientation of the toplevel in landscape orportrait mode. The different types of orientations are,
- PW ORIENT TOP
- PW ORIENT BOTTOM
- PW ORIENT LEFT
- PW ORIENT RIGHT
40. unsigned pw_get_display width(pw_widget window);</tt>
This function returns the width of a toplevel. This is essentially used to get the orientation of the toplevel window.
41. unsigned pw_get_display height(pw_widget window);</tt>
This function returns the height of a toplevel. This is also essentially used to get the orientation the toplevel window.
42. unsigned pw_get_display orientation(pw_widget window);</tt>
This function will return the type of orientation the toplevel window is setto. The return value will be 0, 1, 2 or 3 for the orientation being top, left, bottom or right respectively.
43. void_pw_toggle fullscreen(pw_widget window);
This function is to toggle the toplevel between fullscreen(240x320) mode andstandard 240x270 mode.
