Exemple #1
0
 const char *getstring() const
 {
     switch(type)
     {
         case INT: return intstr(val.i);
         case FLOAT: return intstr(int(floor(val.f)));
         case STRING: return val.s;
         default: return "";
     }
 }
Exemple #2
0
 //tab is always at top of page
 void tab(const char *name, int color) 
 {
     if(curdepth != 0) return;
     if(color) tcolor = color;
     tpos++; 
     if(!name) name = intstr(tpos); 
     int w = max(text_width(name) - 2*INSERT, 0);
     if(layoutpass) 
     {  
         ty = max(ty, ysize); 
         ysize = 0;
     }
     else 
     {	
         cury = -ysize;
         int h = FONTH-2*INSERT,
             x1 = curx + tx,
             x2 = x1 + w + ((skinx[3]-skinx[2]) + (skinx[5]-skinx[4]))*SKIN_SCALE,
             y1 = cury - ((skiny[6]-skiny[1])-(skiny[3]-skiny[2]))*SKIN_SCALE-h,
             y2 = cury;
         bool hit = tcurrent && windowhit==this && hitx>=x1 && hity>=y1 && hitx<x2 && hity<y2;
         if(hit && (!guiclicktab || mousebuttons&G3D_DOWN)) 
             *tcurrent = tpos; //roll-over to switch tab
         
         drawskin(x1-skinx[visible()?2:6]*SKIN_SCALE, y1-skiny[1]*SKIN_SCALE, w, h, visible()?10:19, 9, gui2d ? 1 : 2, light, alpha);
         text_(name, x1 + (skinx[3]-skinx[2])*SKIN_SCALE - (w ? INSERT : INSERT/2), y1 + (skiny[2]-skiny[1])*SKIN_SCALE - INSERT, tcolor, visible());
     }
     tx += w + ((skinx[5]-skinx[4]) + (skinx[3]-skinx[2]))*SKIN_SCALE; 
 }
int main()
{

  UlamTypeKey key1;
  key1.init("Int", 32, 0);
  UlamTypeKey key2;
  key2.init("Int", 32, 1);


  std::map<std::string, UlamTypeKey> m_map;   //name -> key 

  std::string foostr("Foo");
  std::string intstr("Int");
  m_map.insert(std::pair<std::string, UlamTypeKey>(intstr, key1));
  m_map.insert(std::pair<std::string, UlamTypeKey>(foostr, key2));
  //m_map[key1] = 10;
  //m_map[key2] = 1;

  //std::map<UlamTypeKey, int>::key_compare keycomp = m_map.key_comp();
  //UlamTypeKey highest = m_map.rbegin()->first;     // key value of last element


  std::map<std::string,UlamTypeKey >::iterator it = m_map.find(foostr);
    
  if(it != m_map.end())
    {
      std::cout << " found it! " << it->second.m_typeName << "." << it->second.m_bits << "." << it->second.m_arraySize << std::endl;  
    }
  else
    {
      std::cout << " NOT found! "  << std::endl;  
    }

  return 0;
}
Exemple #4
0
    void slider(int &val, int vmin, int vmax, int color, const char *label)
    {
        autotab();
        int x = curx;
        int y = cury;
        line_((FONTH*2)/3);
        if(visible())
        {
            if(!label) label = intstr(val);
            int w = text_width(label);

            bool hit;
            int px, py;
            if(ishorizontal())
            {
                hit = ishit(FONTH, ysize, x, y);
                px = x + (FONTH-w)/2;
                py = y + (ysize-FONTH) - ((ysize-FONTH)*(val-vmin))/((vmax==vmin) ? 1 : (vmax-vmin)); //vmin at bottom
            }
            else
            {
                hit = ishit(xsize, FONTH, x, y);
                px = x + FONTH/2 - w/2 + ((xsize-w)*(val-vmin))/((vmax==vmin) ? 1 : (vmax-vmin)); //vmin at left
                py = y;
            }

            if(hit) color = 0xFF0000;
            text_(label, px, py, color, hit && actionon, hit);
            if(hit && actionon)
            {
                int vnew = (vmin < vmax ? 1 : -1)+vmax-vmin;
                if(ishorizontal()) vnew = int((vnew*(y+ysize-FONTH/2-hity))/(ysize-FONTH));
                else vnew = int((vnew*(hitx-x-FONTH/2))/(xsize-w));
                vnew += vmin;
                vnew = vmin < vmax ? clamp(vnew, vmin, vmax) : clamp(vnew, vmax, vmin);
                if(vnew != val) val = vnew;
            }
        }
    }