Beispiel #1
0
/*
	OnRButtonDown()

	Gestore per il click con il bottone destro del mouse sull'elemento del controllo.
	Visualizza il menu popup ed invia il messaggio alla finestra principale (in wParam
	l'indice dell'elemento selezionato ed in lParam le coordinate del click).
*/
void CListCtrlEx::OnRButtonDown(UINT nFlags,CPoint point)
{
	// salva le coordinate del click
	m_Point.x = point.x;
	m_Point.y = point.y;

	// chiama il gestore originale
	CListCtrl::OnRButtonDown(nFlags,point);

	// indice dell'item cliccato
	m_nCurrentItem = CListCtrl::HitTest(point);

	// a seconda del flag imposta l'item corrente come selezionato
	// (per default solo il click con il sinistro imposta l'elemento come selezionato)
	if(m_bRightClickSelects)
	{
		// resetta le selezioni correnti dato la selezione multiple puo' effettuarsi solo con CTRL+click destro
		ResetItemsSelection();
		
		// seleziona l'item
		SetItemSelection(m_nCurrentItem,TRUE);
	}

	// visualizza il menu a comparsa
	PopUpMenu(point);

	// se e' stato specificato un gestore, invia il messaggio relativo
	// in wParam l'indice dell'elemento ed in lParam le coordinate del click
	if(m_pWnd!=NULL && m_nRButtonDownMessage!=(UINT)-1L)
		::PostMessage(m_pWnd->m_hWnd,m_nRButtonDownMessage,(WPARAM)m_nCurrentItem,(LPARAM)&m_Point);
}
Beispiel #2
0
U0 ViewComics()
{
  I64 i=0;
  U8 *st;
  CDirEntry *tempm,*tempm1;
  CDoc *doc=DocNew;
  DocPutS(doc,"$$FG,LTBLUE$$");
  tempm=FilesFind("Comics/*.TXT*");
  tempm1=tempm;
  while (tempm1) {
    st=StrNew(tempm1->name);
    FileExtRem(st);
    tempm1->user_data=DocPrintF(doc,"$$MU-UL,\"%-10ts\",%d$$ ",st,tempm1);
    Free(st);
    tempm1=tempm1->next;
    if ((i++&3)==3)
      DocPutS(doc,"\n");
  }
  while (TRUE) {
    if ((tempm1=PopUpMenu(doc))>0)
      Ed(tempm1->full_name);
    else
      break;
  }
  DocDel(doc);
  CDirLstDel(tempm);
}
I64 PopUpEdFmt()
{
  I64 i;
  CDoc *doc=DocNew;
  DocPutS(doc,"$$FG,LTBLUE$$$$MU,\"Check Compile\",EF_CHK_COMPILE$$\n"
	"$$MU,\"Reindent CPP.Z Fun\",EF_REINDENT$$\n"
	"$$MU,\"Renum Asm Local @@ Labels for Fun\",EF_RENUM_ASM$$\n"
	"$$MU,\"Insert Mgd Code: Slider Ctrl\",EF_SLIDER_CTRL$$\n"
	"$$MU,\"Insert ASCII/Scan Code Hex Codes for key pressed\",EF_CH_SC$$\n"
	"$$MU,\"CANCEL\",DOCM_CANCEL$$\n\n"
	"$$FG,GREEN$$<ALT-BACKSPACE>$$FG$$ to undo if not happy\n"
	"with the results.\n");
  i=PopUpMenu(doc);
  DocDel(doc);
  return i;
}
void OptionBox::set_in_window() {
	
	popup = GUI_NEW( PopUpMenu( get_window() ) );
	popup->selected_id_signal.connect( this, &OptionBox::item_activated );
	
	DeferredAdd *l=deferred_add_list;
	while (l) {
		
		if (l->is_sep)
			add_separator();
		else if (l->bitmap<0)
			add_item( l->text, l->id,l->shortcut, l->shortcut_active );
		else
			add_item( l->bitmap, l->text, l->id,l->shortcut, l->shortcut_active );
		
		l=l->next;		
	}
	
	clear_deferred_list();
}
Beispiel #5
0
/****************************************************************************
 *
 * Initiates a menu pop-up
 *
 * Style = 1 = sticky menu, stays up on initial button release.
 * Style = 0 = transient menu, drops on initial release.
 ***************************************************************************/
int do_menu(MenuRoot * menu, int style)
{
  int prevStashedX = 0, prevStashedY = 0;
  MenuRoot *PrevActiveMenu = 0;
  MenuItem *PrevActiveItem = 0;
  int retval = MENU_NOP;
  int x, y;
  Time t0;
  extern Time lastTimestamp;
  int PrevMenuX = PrevActiveMenuX;

  /* this condition could get ugly */
  if (menu->in_use)
    return MENU_ERROR;

  /* In case we wind up with a move from a menu which is
   * from a window border, we'll return to here to start
   * the move */
  XQueryPointer(dpy, Scr.Root, &JunkRoot, &JunkChild,
		&x, &y, &JunkX, &JunkY, &JunkMask);

  if (menu_on) {
    prevStashedX = Stashed_X;
    prevStashedY = Stashed_Y;

    PrevActiveMenu = ActiveMenu;
    PrevActiveItem = ActiveItem;

    if (ActiveMenu)
      x = Stashed_X + ActiveMenu->width - 3;

    if (ActiveItem)
      y = ActiveItem->y_offset + MenuY;
  } else {
    mouse_moved = 0;
    t0 = lastTimestamp;
    if (!GrabEm(MENU)) {
      XBell(dpy, Scr.screen);
      return MENU_DONE;
    }
    x += 2;
  }
  if (PopUpMenu(menu, x, y)) {
    retval = UpdateMenu(style);
  } else
    XBell(dpy, Scr.screen);

  ActiveMenu = PrevActiveMenu;
  ActiveItem = PrevActiveItem;
  if ((ActiveItem) && (menu_on))
    ActiveItem->state = 1;
  Stashed_X = prevStashedX;
  Stashed_Y = prevStashedY;


  if (!menu_on) {
    UngrabEm();
    WaitForButtonsUp();
  }
  if (((lastTimestamp - t0) < 3 * Scr.ClickTime) && (mouse_moved == 0))
    menu_aborted = 1;
  else
    menu_aborted = 0;

  PrevActiveMenuX = PrevMenuX;
  return retval;
}
/*
	OnRButtonDown()
*/
void CWallBrowserFileView::OnRButtonDown(UINT nFlags,CPoint point)
{
	CListViewEx::OnRButtonDown(nFlags,point);
	if(OnSelectItem(point) >= 0)
		PopUpMenu(point);
}
static void DoClickMenus(
    PF_InData       *in_data,
    PF_OutData      *out_data,
    PF_ParamDef     *params[],
    PF_LayerDef     *output,
    PF_EventExtra   *event_extra,
    ArbitraryData   *arb_data,
    SequenceData    *seq_data,
    UIRegion        reg )
{
    if(seq_data->context != NULL && arb_data->action == seq_data->context->getAction())
    {
        if(arb_data->action == OCIO_ACTION_CONVERT ||
            (arb_data->action == OCIO_ACTION_DISPLAY && (reg == REGION_MENU1)))
        {
            // colorSpace menus
            std::string selected_item;
        
            if(reg == REGION_MENU1)
            {
                selected_item = arb_data->input;
            }
            else
            {
                selected_item = arb_data->output;
            }
            
            
            void *hwndOwner = NULL;

        #ifdef WIN_ENV
            PF_GET_PLATFORM_DATA(PF_PlatData_MAIN_WND, &hwndOwner);
        #endif
        
            const bool changed = ColorSpacePopUpMenu(seq_data->context->config(), selected_item, true, hwndOwner);
            
            
            if(changed)
            {
                if(reg == REGION_MENU1)
                {
                    strncpy(arb_data->input, selected_item.c_str(), ARB_SPACE_LEN);
                }
                else
                {
                    strncpy(arb_data->output, selected_item.c_str(), ARB_SPACE_LEN);
                }
                
                params[OCIO_DATA]->uu.change_flags = PF_ChangeFlag_CHANGED_VALUE;
            }
        }
        else
        {
            // standard menus
            MenuVec menu_items;
            int selected_item;
            
            if(arb_data->action == OCIO_ACTION_LUT)
            {
                if(reg == REGION_MENU1)
                {
                    menu_items.push_back("Nearest Neighbor");
                    menu_items.push_back("Linear");
                    menu_items.push_back("Tetrahedral");
                    menu_items.push_back("(-");
                    menu_items.push_back("Best");
                    
                    selected_item = arb_data->interpolation == OCIO_INTERP_NEAREST ? 0 :
                                    arb_data->interpolation == OCIO_INTERP_LINEAR ? 1 :
                                    arb_data->interpolation == OCIO_INTERP_TETRAHEDRAL ? 2 :
                                    arb_data->interpolation == OCIO_INTERP_BEST ? 4 :
                                    -1;
                }
            }
            else if(arb_data->action == OCIO_ACTION_CONVERT)
            {
                menu_items = seq_data->context->getInputs();
                
                if(reg == REGION_MENU1)
                {
                    selected_item = FindInVec(menu_items, arb_data->input);
                }
                else
                {
                    selected_item = FindInVec(menu_items, arb_data->output);
                }
            }
            else if(arb_data->action == OCIO_ACTION_DISPLAY)
            {
                if(reg == REGION_MENU1)
                {
                    menu_items = seq_data->context->getInputs();
                    
                    selected_item = FindInVec(menu_items, arb_data->input);
                }
                else if(reg == REGION_MENU2)
                {
                    menu_items = seq_data->context->getDevices();
                    
                    selected_item = FindInVec(menu_items, arb_data->device);
                }
                else if(reg == REGION_MENU3)
                {
                    menu_items = seq_data->context->getTransforms();
                    
                    selected_item = FindInVec(menu_items, arb_data->transform);
                }
            }
            
            
            
            void *hwndOwner = NULL;

        #ifdef WIN_ENV
            PF_GET_PLATFORM_DATA(PF_PlatData_MAIN_WND, &hwndOwner);
        #endif

            int result = PopUpMenu(menu_items, selected_item, hwndOwner);
            
            
            if(result != selected_item)
            {
                std::string color_space = menu_items[ result ];
                
                if(arb_data->action == OCIO_ACTION_LUT)
                {
                    if(reg == REGION_MENU1)
                    {
                        arb_data->interpolation =   result == 0 ? OCIO_INTERP_NEAREST :
                                                    result == 2 ? OCIO_INTERP_TETRAHEDRAL :
                                                    result == 4 ? OCIO_INTERP_BEST :
                                                    OCIO_INTERP_LINEAR;
                                                
                        seq_data->context->setupLUT(arb_data->invert, arb_data->interpolation);
                    }
                }
                else if(arb_data->action == OCIO_ACTION_CONVERT)
                {
                    if(reg == REGION_MENU1)
                    {
                        strncpy(arb_data->input, color_space.c_str(), ARB_SPACE_LEN);
                    }
                    else if(reg == REGION_MENU2)
                    {
                        strncpy(arb_data->output, color_space.c_str(), ARB_SPACE_LEN);
                    }
                    
                    seq_data->context->setupConvert(arb_data->input, arb_data->output);
                }
                else if(arb_data->action == OCIO_ACTION_DISPLAY)
                {
                    if(reg == REGION_MENU1)
                    {
                        strncpy(arb_data->input, color_space.c_str(), ARB_SPACE_LEN);
                    }
                    else if(reg == REGION_MENU2)
                    {
                        strncpy(arb_data->device, color_space.c_str(), ARB_SPACE_LEN);
                    }
                    else if(reg == REGION_MENU3)
                    {
                        strncpy(arb_data->transform, color_space.c_str(), ARB_SPACE_LEN);
                    }
                    
                    seq_data->context->setupDisplay(arb_data->input, arb_data->device, arb_data->transform);
                    
                    // transform may have changed
                    strncpy(arb_data->transform, seq_data->context->getTransform().c_str(), ARB_SPACE_LEN);
                }
                        
                params[OCIO_DATA]->uu.change_flags = PF_ChangeFlag_CHANGED_VALUE;
            }
        }
    }
}
static void DoClickConfig(
    PF_InData       *in_data,
    PF_OutData      *out_data,
    PF_ParamDef     *params[],
    PF_LayerDef     *output,
    PF_EventExtra   *event_extra,
    ArbitraryData   *arb_data,
    SequenceData    *seq_data)
{
    void *hwndOwner = NULL;

#ifdef WIN_ENV
    PF_GET_PLATFORM_DATA(PF_PlatData_MAIN_WND, &hwndOwner);
#endif

    ConfigVec configs;
    GetStdConfigs(configs);
    
    if(configs.size() == 0)
        configs.push_back("(nada)"); // menu makes a gray entry that says "No configs in $PATH"
    
    
    MenuVec menu_items;
    int selected = 0;
    
    menu_items.push_back("$OCIO"); // menu will gray this out if $OCIO is not defined
    
    menu_items.push_back("(-"); // this tells the menu to make a seperator
    
    for(ConfigVec::const_iterator i = configs.begin(); i != configs.end(); ++i)
    {
        menu_items.push_back( *i );
        
        if(arb_data->source == OCIO_SOURCE_STANDARD && arb_data->path == *i)
        {
            selected = menu_items.size() - 1;
        }
    }
    
    menu_items.push_back("(-");
    
    menu_items.push_back("Custom...");
    
    int custom_choice = menu_items.size() - 1;
    
    if(arb_data->source == OCIO_SOURCE_CUSTOM)
    {
        selected = -1;
    }
    
    
    int choice = PopUpMenu(menu_items, selected, hwndOwner);
    
    
    if(choice == custom_choice)
    {
        // custom is the same as clicking the path
        DoClickPath(in_data, out_data, params, output, event_extra, arb_data, seq_data);
    }
    else if(choice != selected)
    {
        OpenColorIO_AE_Context *new_context = NULL;
        
        if(choice == 0)
        {
            // $OCIO
            char *file = std::getenv("OCIO");
            
            if(file)
            {
                Path path(file, GetProjectDir(in_data));
                
                new_context = new OpenColorIO_AE_Context(path.full_path(),
                                                            OCIO_SOURCE_ENVIRONMENT);
                
                arb_data->source = seq_data->source = OCIO_SOURCE_ENVIRONMENT;
                
                strncpy(arb_data->path, path.full_path().c_str(), ARB_PATH_LEN);
                strncpy(arb_data->relative_path, path.relative_path(false).c_str(), ARB_PATH_LEN);
            }
            else
                throw OCIO::Exception("No $OCIO environment variable defined."); 
        }
        else
        {
            // standard configs
            std::string config = configs[choice - 2];
            
            std::string path = GetStdConfigPath(config);
            
            if( !path.empty() )
            {
                new_context = new OpenColorIO_AE_Context(config, OCIO_SOURCE_STANDARD);
                
                arb_data->source = seq_data->source = OCIO_SOURCE_STANDARD;
                
                strncpy(arb_data->path, config.c_str(), ARB_PATH_LEN);
                strncpy(arb_data->relative_path, path.c_str(), ARB_PATH_LEN);
            }
            else
                throw OCIO::Exception("Problem loading OCIO configuration."); 
        }
        
        
        if(new_context)
        {
            if(seq_data->context)
            {
                delete seq_data->context;
            }
            
            seq_data->context = new_context;
            
            
            strncpy(seq_data->path, arb_data->path, ARB_PATH_LEN);
            strncpy(seq_data->relative_path, arb_data->relative_path, ARB_PATH_LEN);
            
            // try to retain settings if it looks like the same situation,
            // possibly fixing a moved path
            if(OCIO_ACTION_NONE == arb_data->action ||
                (OCIO_ACTION_LUT == new_context->getAction() && OCIO_ACTION_LUT != arb_data->action) ||
                (OCIO_ACTION_LUT != new_context->getAction() && OCIO_ACTION_LUT == arb_data->action) ||
                (OCIO_ACTION_LUT != new_context->getAction() &&
                   (-1 == FindInVec(new_context->getInputs(), arb_data->input) ||
                    -1 == FindInVec(new_context->getInputs(), arb_data->output) ||
                    -1 == FindInVec(new_context->getTransforms(), arb_data->transform) ||
                    -1 == FindInVec(new_context->getDevices(), arb_data->device) ) ) )
            {
                // Configuration is different, so initialize defaults
                arb_data->action = seq_data->context->getAction();
                
                if(arb_data->action == OCIO_ACTION_LUT)
                {
                    arb_data->invert = FALSE;
                    arb_data->interpolation = OCIO_INTERP_LINEAR;
                }
                else
                {
                    strncpy(arb_data->input, seq_data->context->getInput().c_str(), ARB_SPACE_LEN);
                    strncpy(arb_data->output, seq_data->context->getOutput().c_str(), ARB_SPACE_LEN);
                    strncpy(arb_data->transform, seq_data->context->getTransform().c_str(), ARB_SPACE_LEN);
                    strncpy(arb_data->device, seq_data->context->getDevice().c_str(), ARB_SPACE_LEN);
                }
            }
            else
            {
                // Configuration is the same, retain current settings
                if(arb_data->action == OCIO_ACTION_LUT)
                {
                    seq_data->context->setupLUT(arb_data->invert, arb_data->interpolation);
                }
                else if(arb_data->action == OCIO_ACTION_CONVERT)
                {
                    seq_data->context->setupConvert(arb_data->input, arb_data->output);
                }
                else if(arb_data->action == OCIO_ACTION_DISPLAY)
                {
                    seq_data->context->setupDisplay(arb_data->input, arb_data->device, arb_data->transform);
                    
                    // transform may have changed
                    strncpy(arb_data->transform, seq_data->context->getTransform().c_str(), ARB_SPACE_LEN);
                }
            }
            
            params[OCIO_DATA]->uu.change_flags = PF_ChangeFlag_CHANGED_VALUE;
            
            seq_data->status = STATUS_OK;
        }
    }
}
void OptionButton::set_in_window() {
	
	popup = GUI_NEW( PopUpMenu( get_window() ) );
	popup->selected_id_signal.connect( this, &OptionButton::item_activated );	
}