00001
00075 #ifndef INC_MI32_GRLIST_H
00076 #define INC_MI32_GRLIST_H
00077
00078 #if !defined(INC_MI32_XDEFNS_H) && defined(X_NATIVE)
00079 #include <mi32/xdefns.h>
00080 #endif
00081
00082 #ifndef INC_MI32_MG2X_H
00083 #include <mi32/mg2x.h>
00084 #endif
00085
00086 #ifndef INC_MI32_DOUBLECLICKTEST_H
00087 #include <mi32/doubleclicktest.h>
00088 #endif
00089
00090
00091 class GRAPHICLIST {
00092
00093 public:
00094
00095 enum FLAGS {
00096 FLAG_NoScrollHorizontal = 0x00000001,
00097 FLAG_AllowItemSelection = 0x00000002,
00098 FLAG_AllowMultiSelection = 0x00000004,
00099 FLAG_NoAutoTraversal = 0x00000008
00100 };
00101
00102 struct MSG {
00103
00104 enum MSGTYPE {
00105 MSGTYPE_NoMessage = 0,
00106 MSGTYPE_Draw,
00107 MSGTYPE_PointerMotion,
00108 MSGTYPE_ButtonPressed,
00109 MSGTYPE_ButtonReleased,
00110 MSGTYPE_ButtonMotion,
00111 MSGTYPE_ButtonDoubleClick,
00112 MSGTYPE_KeyPressed,
00113 MSGTYPE_KeyReleased,
00114 MSGTYPE_RequestSize,
00115 MSGTYPE_Deselected,
00116 MSGTYPE_Selected,
00117 MSGTYPE_RequestToolTip,
00118 MSGTYPE_DoubleClick
00119 };
00120
00122 enum MSGPROC {
00123 MSGPROC_Ignored = 0,
00124 MSGPROC_Normal = 1,
00125 MSGPROC_Reset = 2,
00126 MSGPROC_PopupMenu
00127 };
00128
00129 enum BTNKEY {
00130 BTNKEY_ButtonLeft = 0x01,
00131 BTNKEY_ButtonMiddle = 0x02,
00132 BTNKEY_ButtonRight = 0x04,
00133 BTNKEY_Shift = 0x10,
00134 BTNKEY_Control = 0x20
00135 };
00136
00137
00138
00139 MSGTYPE type;
00140 int itemnum;
00141 void *PrivPtr;
00142 LPOINT2D origin;
00143 LPOINT2D pointer;
00144 MSGPROC proc;
00145 BTNKEY state;
00146 BTNKEY button;
00147 MIUNICODE key;
00148 LRECT2D drawrect;
00149 MGD::CONTEXT* gc;
00150 INT16 width;
00151 UINT8 selected;
00152 MIUNICODE *tooltip;
00153 #ifndef WIN32_NATIVE
00154 Widget popupmenu;
00155 #endif
00156 };
00157
00158
00159
00160 typedef void (*MSGHANDLER)(MSG*);
00161
00162
00163
00164 #ifndef WIN32_NATIVE
00166 GRAPHICLIST (
00167 Widget parent,
00168 MSGHANDLER MsgHandler,
00169 void *privptr,
00170 const char *sizefield,
00171 Arg *arglist,
00172 int argcount,
00173 FLAGS flags=FLAG_AllowItemSelection
00174 );
00175 #endif
00177 ~GRAPHICLIST (
00178 );
00179
00180
00181
00183 void DisableRedraw (
00184 ) {
00185 m_DisableRedraw = 1;
00186 return;
00187 };
00188
00190 void EnableRedraw (
00191 bool redraw=true
00192 ) {
00193 m_DisableRedraw = 0;
00194 if (redraw) Redraw();
00195 return;
00196 };
00197
00199 INT16 GetItemHeight (
00200 ) const {
00201 return (m_ItemHeight);
00202 }
00203
00205 int GetMaxVisible (
00206 ) const {
00207 return (m_MaxVisible);
00208 };
00209
00211 int GetNumItems (
00212 ) const {
00213 return (m_NumItems);
00214 };
00215
00217 int GetSelectedItem (
00218 ) const {
00219 return (m_SelectedItem);
00220 };
00221
00222 #ifndef WIN32_NATIVE
00224 inline Widget GetDrawingArea (
00225 ) const {
00226 return (m_da);
00227 };
00228 #endif
00229
00230 #ifndef WIN32_NATIVE
00232 inline Widget GetWidget (
00233 ) const {
00234 return (XtParent(m_da));
00235 };
00236 #endif
00237
00239 void Redraw (
00240 LRECT2D *rect=0
00241 );
00242
00244 void RedrawItem (
00245 int itemnum
00246 );
00247
00249 void SelectItem (
00250 int itemnum,
00251 bool exclusive=true
00252 );
00253
00255 void SetChanged (
00256 );
00257
00259 void SetFirstVisibleItem (
00260 int itemnum
00261 );
00262
00264 void SetItemChanged (
00265 int itemnum
00266 );
00267
00269 void SetItemHeight (
00270 int height
00271 );
00272
00274 void SetItemSpacing (
00275 int spacing
00276 );
00277
00279 void SetItemWidth (
00280 int width
00281 );
00282
00284 void SetNumItems (
00285 int numitems
00286 );
00287
00288 private:
00289 #ifndef GENERATING_DOXYGEN_OUTPUT
00290
00291
00292
00293 MSGHANDLER m_MsgHandler;
00294 void *m_privptr;
00295 int m_NumItems;
00296 int m_FirstVisible;
00297 int m_MaxVisible;
00298 int m_CursorItem;
00299 int m_SelectedItem;
00300 int m_LastItemPressed;
00301 UINT8 *m_SelectedSet;
00302 INT16 m_ItemSpacing;
00303 INT16 m_ItemHeight;
00304 INT16 *m_ItemWidths;
00305 INT16 m_MaxItemWidth;
00306 INT16 m_LeftPos;
00307 UINT8 m_AllowMultiSelect;
00308 UINT8 m_AllowItemSelect;
00309 UINT8 m_NoAutoTraversal;
00310 UINT8 m_DoingRedraw;
00311 UINT8 m_DisableRedraw;
00312 UINT8 m_UpdateHSB;
00313 UINT8 m_UpdateVSB;
00314 UINT8 m_ToolTipVisible;
00315 MGD::DEVICE_X* m_sdisp;
00316 MGD::CONTEXT* m_sgc;
00317 MPIXEL m_BackgroundPixel;
00318 MPIXEL m_HighlightPixel;
00319 LPOINT2D m_CursorPos;
00320 LPOINT2D m_DrawSize;
00321 LRECT2D m_DrawClipRect;
00322 #ifndef WIN32_NATIVE
00323 Widget m_da;
00324 Widget m_hsb;
00325 Widget m_vsb;
00326 DOUBLECLICKTEST m_DoubleClickTest;
00327 void *m_ToolTipHandle;
00328 XtIntervalId m_IntervalID;
00329 LPOINT2D m_ToolTipPos;
00330 #endif
00331
00332
00333
00335 void ComputeMaxVisible ();
00336
00338 void Destroy (
00339 bool removecb
00340 );
00341
00343 void DrawHighlight (
00344 int itemnum,
00345 bool dohighlight
00346 );
00347
00349 void DrawHighlights (
00350 bool dohighlight = true
00351 );
00352
00354 void DrawItem (
00355 int itemnum
00356 );
00357
00359 void HandleInput (
00360 XEvent* event,
00361 Boolean* continuedispatch);
00362
00364 void SendMsg (
00365 int itemnum,
00366 MSG& msg,
00367 MSG::MSGTYPE msgtype=MSG::MSGTYPE_NoMessage
00368 );
00369
00371 void SendMsg (
00372 int itemnum,
00373 MSG::MSGTYPE msgtype
00374 );
00375
00377 void UpdateSize ();
00378
00379 #ifndef WIN32_NATIVE
00380
00381
00383 static void CB_Destroy (
00384 Widget w,
00385 GRAPHICLIST *grlist,
00386 void*
00387 );
00388
00390 static void CB_Expose (
00391 Widget w,
00392 GRAPHICLIST *grlist,
00393 void *vcbs
00394 );
00395
00397 static void CB_Resize (
00398 Widget w,
00399 GRAPHICLIST *grlist,
00400 void*
00401 );
00402
00404 static void CB_ScrollH (
00405 Widget w,
00406 GRAPHICLIST *grlist,
00407 void *v
00408 );
00409
00411 static void CB_ScrollV (
00412 Widget w,
00413 GRAPHICLIST *grlist,
00414 void*
00415 );
00416
00418 static void CBT_ToolTipPopup (
00419 GRAPHICLIST *grlist,
00420 XtIntervalId*
00421 );
00422
00424 static void EH_Input (
00425 Widget w,
00426 GRAPHICLIST *grlist,
00427 XEvent *event,
00428 Boolean *continuedispatch
00429 );
00430
00431 class EVENTSENTRY;
00432 friend class EVENTSENTRY;
00433
00434 MXXTCB_ADD(GRAPHICLIST);
00435 MXXTEH_ADD(GRAPHICLIST);
00436 MXXTTO_ADD(GRAPHICLIST);
00437 MXXTCB_REMOVE(GRAPHICLIST);
00438 MXXTEH_REMOVE(GRAPHICLIST);
00439 #endif // GENERATING_DOXYGEN_OUTPUT
00440 #endif
00441 };
00442
00443 #ifndef GENERATING_DOXYGEN_OUTPUT
00444 DEFINE_ENUM_OP_BITWISE(GRAPHICLIST::FLAGS)
00445 DEFINE_ENUM_OP_BITWISE(GRAPHICLIST::MSG::BTNKEY)
00446 #endif
00447
00448
00449 #endif // INC_MI32_GRLIST_H