00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef MMSMENUWIDGET_H_
00034 #define MMSMENUWIDGET_H_
00035
00036 #include "mmsgui/mmswidget.h"
00037
00038
00039 typedef enum {
00040
00041 MMSMENUWIDGET_PULSER_MODE_SCROLL_DOWN = 0,
00042
00043 MMSMENUWIDGET_PULSER_MODE_SCROLL_UP,
00044
00045 MMSMENUWIDGET_PULSER_MODE_SCROLL_LEFT,
00046
00047 MMSMENUWIDGET_PULSER_MODE_SCROLL_RIGHT,
00048
00049 MMSMENUWIDGET_PULSER_MODE_MOVESEL_DOWN,
00050
00051 MMSMENUWIDGET_PULSER_MODE_MOVESEL_UP,
00052
00053 MMSMENUWIDGET_PULSER_MODE_MOVESEL_LEFT,
00054
00055 MMSMENUWIDGET_PULSER_MODE_MOVESEL_RIGHT
00056 } MMSMENUWIDGET_PULSER_MODE;
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 class MMSMenuWidget : public MMSWidget {
00069 private:
00070 typedef struct {
00071 string name;
00072 class MMSWindow *window;
00073 MMSMenuWidget *menu;
00074 } MMSMENUITEMINFOS;
00075
00076 string className;
00077 MMSMenuWidgetClass *menuWidgetClass;
00078 MMSMenuWidgetClass myMenuWidgetClass;
00079
00080
00081 MMSFBSurface *selimage;
00082 MMSWidget *itemTemplate;
00083
00084 int item_w;
00085 int item_h;
00086 int v_items;
00087 int h_items;
00088
00089
00090 int x;
00091
00092 int y;
00093
00094 int px;
00095
00096 int py;
00097
00098 bool firstFocus;
00099 bool firstSelection;
00100
00101 bool zoomsel;
00102 unsigned int zoomselwidth;
00103 unsigned int zoomselheight;
00104 int zoomselshiftx;
00105 int zoomselshifty;
00106
00107
00108 MMSSEQUENCEMODE smooth_scrolling;
00109 int scrolling_offset;
00110
00111
00112 MMSSEQUENCEMODE smooth_selection;
00113 int selection_offset_x;
00114 int selection_offset_y;
00115
00116 unsigned int frame_delay;
00117 unsigned int frame_delay_set;
00118
00119
00120 MMSPulser pulser;
00121
00122
00123 sigc::connection onBeforeAnimation_connection;
00124
00125
00126 sigc::connection onAnimation_connection;
00127
00128
00129 sigc::connection onAfterAnimation_connection;
00130
00131
00132 MMSMENUWIDGET_PULSER_MODE pulser_mode;
00133
00134
00135 double anim_offset;
00136
00137
00138 int anim_jumpover;
00139
00140
00141 double anim_factor;
00142
00143
00144
00145 MMSFBRectangle virtualGeom;
00146
00147
00148
00149 MMSWindow *parent_window;
00150
00151
00152 vector<MMSMENUITEMINFOS> iteminfos;
00153
00154
00155 int curr_submenu;
00156
00157
00158 MMSMenuWidget *parent_menu;
00159
00160
00161
00162 int back_item;
00163
00164 bool create(MMSWindow *root, string className, MMSTheme *theme);
00165
00166 bool init();
00167 bool release();
00168 void lock();
00169 void unlock();
00170
00171 bool draw(bool *backgroundFilled = NULL);
00172
00173 void add(MMSWidget *widget);
00174
00175 void adjustVirtualRect();
00176
00177 bool getConfig(bool *firstTime = NULL);
00178
00179 void drawchildren(bool toRedrawOnly = false, bool *backgroundFilled = NULL, MMSFBRectangle *rect2update = NULL);
00180 void recalculateChildren();
00181
00182 void initParentWindow(void);
00183 void setRootWindow(MMSWindow *root, MMSWindow *parentroot = NULL);
00184
00185 void switchArrowWidgets();
00186 void setSliders();
00187
00188 bool setSelected(unsigned int item, bool refresh, bool *changed, bool joined);
00189
00190 void selectItem(MMSWidget *item, bool set, bool refresh = true, bool refreshall = false);
00191
00192
00193 bool onBeforeAnimation(MMSPulser *pulser);
00194 bool onAnimation(MMSPulser *pulser);
00195 void onAfterAnimation(MMSPulser *pulser);
00196
00197 void startAnimation(MMSMENUWIDGET_PULSER_MODE pulser_mode, double anim_offset, int anim_jumpover);
00198
00199
00200 bool scrollDownEx(unsigned int count, bool refresh, bool test, bool leave_selection);
00201 bool scrollUpEx(unsigned int count, bool refresh, bool test, bool leave_selection);
00202 bool scrollRightEx(unsigned int count, bool refresh, bool test, bool leave_selection);
00203 bool scrollLeftEx(unsigned int count, bool refresh, bool test, bool leave_selection);
00204
00205 void emitOnReturnForParents(MMSMenuWidget *orw);
00206 bool callOnReturn();
00207
00208 bool switchToSubMenu();
00209 bool switchBackToParentMenu(MMSDIRECTION direction = MMSDIRECTION_NOTSET, bool closeall = false);
00210
00211 public:
00212 MMSMenuWidget(MMSWindow *root, string className, MMSTheme *theme = NULL);
00213 ~MMSMenuWidget();
00214
00215 MMSWidget *copyWidget();
00216
00217 void setItemTemplate(MMSWidget *itemTemplate);
00218 MMSWidget *getItemTemplate();
00219
00220
00221
00222
00223
00224
00225
00226
00227 MMSWidget *newItem(int item = -1, MMSWidget *widget = NULL);
00228
00229
00230
00231
00232
00233 void deleteItem(unsigned int item);
00234
00235
00236 void clear();
00237
00238 void setFocus(bool set, bool refresh = true, MMSInputEvent *inputevent = NULL);
00239
00240 bool setSelected(unsigned int item, bool refresh = true);
00241 unsigned int getSelected();
00242
00243 MMSWidget *getItem(unsigned int item);
00244 MMSWidget *getSelectedItem();
00245
00246 unsigned int getSize();
00247
00248 unsigned int getVItems();
00249 unsigned int getHItems();
00250
00251 bool scrollDown(unsigned int count = 1, bool refresh = true, bool test = false, bool leave_selection = false);
00252 bool scrollUp(unsigned int count = 1, bool refresh = true, bool test = false, bool leave_selection = false);
00253 bool scrollRight(unsigned int count = 1, bool refresh = true, bool test = false, bool leave_selection = false);
00254 bool scrollLeft(unsigned int count = 1, bool refresh = true, bool test = false, bool leave_selection = false);
00255 bool scrollTo(int posx, int posy, bool refresh = true, bool *changed = NULL,
00256 MMSWIDGET_SCROLL_MODE mode = MMSWIDGET_SCROLL_MODE_SETSELECTED, MMSFBRectangle *inputrect = NULL);
00257
00258 bool setSubMenuName(unsigned int item, const char *name);
00259 bool setSubMenuName(unsigned int item, string &name);
00260 bool setBackItem(unsigned int item);
00261
00262 sigc::signal<void, MMSWidget*> *onSelectItem;
00263 sigc::signal<void, MMSWidget*> *onBeforeScroll;
00264
00265 public:
00266
00267 MMSTaffFile *getTAFF();
00268 string getItemWidth();
00269 string getItemHeight();
00270 unsigned int getItemHMargin();
00271 unsigned int getItemVMargin();
00272 unsigned int getCols();
00273 unsigned int getDimItems();
00274 int getFixedPos();
00275 bool getHLoop();
00276 bool getVLoop();
00277 unsigned int getTransItems();
00278 unsigned int getDimTop();
00279 unsigned int getDimBottom();
00280 unsigned int getDimLeft();
00281 unsigned int getDimRight();
00282 unsigned int getTransTop();
00283 unsigned int getTransBottom();
00284 unsigned int getTransLeft();
00285 unsigned int getTransRight();
00286 string getZoomSelWidth();
00287 string getZoomSelHeight();
00288 string getZoomSelShiftX();
00289 string getZoomSelShiftY();
00290 MMSSEQUENCEMODE getSmoothScrolling();
00291 string getParentWindow();
00292 bool getSelImagePath(string &selimagepath);
00293 bool getSelImageName(string &selimagename);
00294 MMSSEQUENCEMODE getSmoothSelection();
00295 unsigned int getSmoothDelay();
00296
00297 void setItemWidth(string itemwidth, bool refresh = true);
00298 void setItemHeight(string itemheight, bool refresh = true);
00299 void setItemHMargin(unsigned int itemhmargin, bool refresh = true);
00300 void setItemVMargin(unsigned int itemvmargin, bool refresh = true);
00301 void setCols(unsigned int cols, bool refresh = true);
00302 void setDimItems(unsigned int dimitems, bool refresh = true);
00303 void setFixedPos(int fixedpos, bool refresh = true);
00304 void setHLoop(bool hloop);
00305 void setVLoop(bool vloop);
00306 void setTransItems(unsigned int transitems, bool refresh = true);
00307 void setDimTop(unsigned int dimtop, bool refresh = true);
00308 void setDimBottom(unsigned int dimbottom, bool refresh = true);
00309 void setDimLeft(unsigned int dimleft, bool refresh = true);
00310 void setDimRight(unsigned int dimright, bool refresh = true);
00311 void setTransTop(unsigned int transtop, bool refresh = true);
00312 void setTransBottom(unsigned int transbottom, bool refresh = true);
00313 void setTransLeft(unsigned int transleft, bool refresh = true);
00314 void setTransRight(unsigned int transright, bool refresh = true);
00315 void setZoomSelWidth(string zoomselwidth, bool refresh = true);
00316 void setZoomSelHeight(string zoomselheight, bool refresh = true);
00317 void setZoomSelShiftX(string zoomselshiftx, bool refresh = true);
00318 void setZoomSelShiftY(string zoomselshifty, bool refresh = true);
00319 void setSmoothScrolling(MMSSEQUENCEMODE seq_mode);
00320 void setParentWindow(string parentwindow);
00321 void setSelImagePath(string selimagepath, bool load = true, bool refresh = true);
00322 void setSelImageName(string selimagename, bool load = true, bool refresh = true);
00323 void setSmoothSelection(MMSSEQUENCEMODE seq_mode);
00324 void setSmoothDelay(unsigned int smoothdelay);
00325
00326 void updateFromThemeClass(MMSMenuWidgetClass *themeClass);
00327 };
00328
00329 #endif
00330