Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

qmenuprivate.h

00001 #if 0
00002 
00003 #define ITEM_SEP
00004 
00005 class QMenuDataPrivate
00006 {
00007 public:
00008     QMenuBar *Menu;
00009     QMenuItem *Parent;
00010     QWidget *Widget;
00011     QList<QMenuItem> Items;
00012 
00013     QMenuDataPrivate(QMenuBar *m, QMenuItem *p)
00014     {
00015         Menu = m;
00016         Parent = p;
00017         Widget = 0;
00018     }
00019 
00020     ~QMenuDataPrivate()
00021     {
00022         Items.DeleteObjects();
00023     }
00024 
00025     void insert(QMenuItem *i, int where)
00026     {
00027         Items.Insert(i, where);
00028 
00029         if (Widget)
00030         {
00031             OsPoint p(0, 0);
00032             i->reparent(Widget, p, true);
00033         }
00034     }
00035 };
00036 
00037 
00038 
00039 class QMenuItemPrivate
00040 {
00041 public:
00042     int Sx, Sy;
00043     GMenuItem *Source;
00044     
00045     QMenuBar *Menu;
00046     QMenuData *Parent;
00047     QMenuItem *Item;
00048     int Cmd;
00049     QPopupMenu *Sub;
00050     bool Separator;
00051     bool Clicked;
00052     bool Checked;
00053 
00054     QMenuItemPrivate(QMenuBar *menu, QMenuData *parent, QMenuItem *i, GMenuItem *src)
00055     {
00056         Menu = menu;
00057         Parent = parent;
00058         Item = i;
00059         Source = src;
00060         Cmd = -1;
00061         Separator = false;
00062         Sub = 0;
00063         Clicked = false;
00064         Checked = false;
00065 
00066         Sx = Sy = 0;        
00067     }
00068 
00069     ~QMenuItemPrivate()
00070     {
00071         Parent->Data->Items.Delete(Item);
00072     }
00073 
00074     bool IsOnSub()
00075     {
00076         return dynamic_cast<QPopupMenu*>(Parent) != 0;
00077     }
00078 
00079     void Measure()
00080     {
00081         if (NOT Sx OR NOT Sy)
00082         {
00083             if (Source)
00084             {
00085                 GdcPt2 s;
00086                 Source->_Measure(s);
00087                 Sx = s.x;
00088                 Sy = s.y;
00089             }
00090             else
00091             {
00092                 Sx = 20;
00093                 Sy = 8;
00094             }
00095         }
00096     }
00097         
00098     int x()
00099     {
00100         Measure();
00101         return Sx;
00102     }
00103     
00104     int y()
00105     {
00106         Measure();
00107         return Sy;
00108     }
00109 
00110     /*
00111     void PaintText(GSurface *pDC, GRect &r, int x, int y, char *s)
00112     {
00113         char *Tab = strchr(s, '\t');
00114         if (Tab)
00115         {
00116             SysFont->Text(pDC, r.x1 + x, r.y1 + y, s, (int)Tab-(int)s);
00117 
00118             int Tx = SysFont->X(Tab+1);
00119             SysFont->Text(pDC, r.x1 + r.X() + x - Tx - 7, r.y1 + y, Tab+1);
00120         }
00121         else
00122         {
00123             SysFont->Text(pDC, r.x1 + x, r.y1 + y, s);
00124         }
00125     }
00126     */
00127 
00128     void OnPaint(GSurface *pDC)
00129     {
00130         GRect r(0, 0, Item->width()-1, Item->height()-1);
00131 
00132         if (Separator)
00133         {
00134             pDC->Colour(LC_MED, 24);
00135             pDC->Rectangle(&r);
00136 
00137             int Cy = r.Y()/2;
00138             pDC->Colour(LC_LOW, 24);
00139             pDC->Line(r.x1, Cy, r.x2, Cy);
00140             pDC->Colour(LC_LIGHT, 24);
00141             pDC->Line(r.x1, Cy+1, r.x2, Cy+1);
00142         }
00143         else
00144         {
00145             if (Source)
00146             {
00147                 Source->_Paint(pDC, (Item->Cursor == Item  ? ODS_SELECTED : 0) |
00148                                     (Item->isEnabled() ? 0 : ODS_DISABLED) |
00149                                     (Checked ? ODS_CHECKED : 0));
00150             }
00151             
00152             /*
00153             int x = 4;
00154             int y = 0;
00155             COLOUR Back = Over ? LC_HIGH : LC_MED;
00156 
00157             if (Clicked AND
00158                 Over)
00159             {
00160                 LgiThinBorder(pDC, r, SUNKEN);
00161                 x++;
00162                 y++;
00163             }
00164             else
00165             {
00166                 pDC->Colour(Back, 24);
00167                 pDC->Box(&r);
00168                 r.Size(1, 1);
00169             }
00170 
00171             pDC->Colour(Back, 24);
00172             pDC->Rectangle(&r);
00173 
00174             if (Item->getText())
00175             {
00176                 char t[256], *Out=t;
00177                 for (char *In=Item->getText(); *In; In++)
00178                 {
00179                     if (*In == '&')
00180                     {
00181                         if (In[1] == '&')
00182                         {
00183                             *Out++ = *In++;
00184                         }
00185                     }
00186                     else
00187                     {
00188                         *Out++ = *In;
00189                     }
00190                 }
00191                 *Out++ = 0;
00192 
00193                 SysFont->Transparent(true);
00194                 if (Item->isEnabled())
00195                 {
00196                     SysFont->Colour(LC_BLACK, LC_MED);
00197                     PaintText(pDC, r, r.x1 + x, r.y1 + y, t);
00198                 }
00199                 else
00200                 {
00201                     SysFont->Colour(LC_LIGHT, LC_MED);
00202                     PaintText(pDC, r, r.x1 + x + 1, r.y1 + y + 1, t);
00203 
00204                     SysFont->Colour(LC_LOW, LC_MED);
00205                     PaintText(pDC, r, r.x1 + x, r.y1 + y, t);
00206                 }
00207             }
00208 
00209             if (Sub AND IsOnSub())
00210             {
00211                 int x = r.x2 - 7;
00212                 int y = (r.Y()-7) / 2;
00213 
00214                 pDC->Colour(LC_TEXT, 24);
00215                 for (int i=0; i<4; i++)
00216                 {
00217                     pDC->Line(x+i, y+i, x+i, y+7-i);
00218                 }
00219             }
00220             */
00221         }
00222     }
00223 };
00224 
00225 class QMenuBarPrivate
00226 {
00227 public:
00228     QPopupMenu *Open;
00229 
00230     QMenuBarPrivate()
00231     {
00232         Open = 0;
00233     }
00234 };
00235 
00236 
00237 #endif

Generated on Wed Oct 26 14:46:51 2005 for Lgi by  doxygen 1.4.1