Exemple #1
0
/* HR 050203: drag & drop */
static
boolean itm_drop(WINDOW *w, int n, int *list, int kstate, ICND *icnlist, int x, int y)
{
	int i, item, apid = -1, hdl = wind_find(x, y);
	long fd;
/*	ITMTYPE type;
*/	const char *path;

	if (hdl > 0)
		wind_get(hdl, WF_OWNER, &apid);

	if (apid > 0)
	{
		char ddsexts[32];

		fd = ddcreate(apid, ap_id, hdl, x, y, kstate, ddsexts);
		if (fd > 0)
		{
			if (ddstry(fd, "ARGS", "", sizeof(LNAME)) != DD_NAK)
			{
				for (i = 0; i < n; i++)
				{
					if ((item = list[i]) == -1)
						continue;
			
					path = itm_fullname(w, item);

					if (path)
					{
					/*	type = itm_type(w, item);
						alert_msg("type %d | %s | '%s'", type, name, path);
					*/
						Fwrite(fd, 1, "'");
						Fwrite(fd, strlen(path), path);
						Fwrite(fd, 1, "'");	
					}
					if (i < n - 1)
						Fwrite(fd, 1, " ");
				}
				ddclose(fd);

				itm_select(w, -1, 0, TRUE);
				return TRUE;
			}
			else
				alert_printf(1, APPNOEXT);

			ddclose(fd);
		}
		else
		{
			alert_printf(1, APPNODD);
			return FALSE;
		}
	}

	alert_printf(1, MILLDEST);
	return FALSE;
}
Exemple #2
0
static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
{
	struct gui_window * gw = input_window;
	static bool prev_url = false;
	static short prev_x=0;
	static short prev_y=0;
	bool within = false;
	LGRECT urlbox, bwbox, sbbox;
	int nx, ny;

	if( gw == NULL)
		return;

	if( prev_x == evnt.mx && prev_y == evnt.my ){
		return;
	}

	short ghandle = wind_find( evnt.mx, evnt.my );
	if( input_window->root->handle->handle == ghandle ){

		// The window found at x,y is an gui_window
		// and it's the input window.

		browser_get_rect( gw, BR_CONTENT, &bwbox );

		if( evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
			evnt.my > bwbox.g_y &&  evnt.my < bwbox.g_y + bwbox.g_h ){
			within = true;
			browser_window_mouse_track(
							input_window->browser->bw,
							0,
							evnt.mx - bwbox.g_x + gw->browser->scroll.current.x,
							evnt.my - bwbox.g_y + gw->browser->scroll.current.y
						);
		}

		if( gw->root->toolbar && within == false ) {
			mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
			if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
				(evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
				gem_set_cursor( &gem_cursors.ibeam );
				prev_url = true;
			} else {
				if( prev_url ) {
					gem_set_cursor( &gem_cursors.arrow );
					prev_url = false;
				}
			}
		}
	} else {
		gem_set_cursor( &gem_cursors.arrow );
		prev_url = false;
	}

	prev_x = evnt.mx;
	prev_y = evnt.my;
}
Exemple #3
0
static WORD hndl_button(WORD clicks, WORD mx, WORD my, WORD button, WORD keystate)
{
    WORD done, junk;
    GRECT c;
    WORD wh, dobj, dest_wh;
    WORD root;
    WNODE *wn;

    done = FALSE;

    wh = wind_find(mx, my);

    if (wh != G.g_cwin)
        desk_clear(G.g_cwin);

    desk_verify(wh, FALSE);

    wind_get_grect(wh, WF_WXYWH, &c);

    if (clicks == 1)
    {
        act_bsclick(G.g_cwin, G.g_screen, G.g_croot, mx, my,
                    keystate, &c, FALSE);
        graf_mkstate(&junk, &junk, &button, &junk);
        if (button & 0x0001)
        {
            dest_wh = act_bdown(G.g_cwin, G.g_screen, G.g_croot, &mx, &my,
                                &keystate, &c, &dobj);
            if (dest_wh != NIL)
            {
                root = 1;
                if (dest_wh != 0)
                {
                    wn = win_find(dest_wh);
                    if (wn)
                        root = wn->w_root;
                }
                desk1_drag(wh, dest_wh, root, dobj, mx, my, keystate);
                desk_clear(wh);
            }
        }
    }
    else
    {
        act_bsclick(G.g_cwin, G.g_screen, G.g_croot, mx, my, keystate, &c, TRUE);
        done = do_filemenu(OPENITEM);
    }

    men_update(G.a_trees[ADMENU]);

    return done;
}
Exemple #4
0
/*! Initialization and main loop */
void main(void) {
	int evnt, quit = FALSE, flacc = FALSE;
	MFDB img;

	/* Initialiser */
	if(initial("BIG2DEMO.RSC", MENU, BUREAU, NUM_TREE,
				TRINDEX, FRSTR, NB_FENETRES, TITREACC)) {
		if(_app) set_bimg();			/* Set image on the desk */
		ptr_fonctions();
		set_form();
		load_fontspeedo();

		if(work_display.n_color >= 16)	/* if we are in color mode */
			relief();
		aide_en_ligne = K_CTRL;			/* Help-bubble with Control key */

		do {
			if((_app == ZERO) &&(NOT flacc)) {	
				acc_loop();
				flacc = TRUE;
			}	/* we are running as an accessory */

			evnt = dialog(DLG_DESK, adr_desk, TRUE, TRUE, PU_LIBRE, &img, FALSE);
			
			if(evnt & MU_MESAG)
				event_mesag(&flacc, &quit);
			
			if((evnt & MU_BUTTON) &&(buf[0] == BEV_FREEPU))
				event_freepu();
			
			if((evnt & MU_BUTTON) &&(buf[0] == BEV_WFORM))
				event_wform();
			
			if((evnt & MU_BUTTON) &&(buf[0] == BEV_WMENU))
				event_wmenu(&flacc);
			
			if((evnt & MU_BUTTON) &&(buf[0] == BEV_WHIER))
				event_whier();
			
			if((evnt & MU_BUTTON) &&(buf[0] == BEV_TOOL))
				event_tool();
			
			if((evnt & MU_BUTTON) &&(NOT wind_find(mx, my)))
				event_desk();
		} while(NOT quit);
		
		if(fgdos)
			vst_unload_fonts(work_display.handle, 0);
		end();
	}	/* init OK */
}	/* end of main */
Exemple #5
0
static void handle_button(int m_x, int m_y, int bstate, int kstate, int breturn)
{
	int		wh;
	WINDOWP	window;

	if (!all_iconified)
	{
		wake_mouse();
		wh = wind_find(m_x, m_y);
		window = get_window(wh);
		if (window != NULL)
			click_window(window, m_x, m_y, bstate, kstate, breturn);
	}
}
Exemple #6
0
int handle_message(int pipe[8])
{
	static int first_open=0;
	int wnr,error; /* ,avmsg[8]; */
	char *vamsg,*o;

#ifdef DEBUG
	char tmp[128];
#endif

	switch (pipe[0]) {
		case AC_OPEN:
			if (pipe[4] == acc_id)
			{
				if(first_open)
				{
					if(windforms[WIND_CTRL].wind_open)
						wind_set(windforms[WIND_CTRL].whandle,WF_TOP);
					else
						fgbg=FG;
				}
				else
				{
					fg_init(&windforms[WIND_CTRL]);
					fgbg=FG;
					first_open=1;
				}
			}
#ifdef DEBUG
				form_alert(1,"[1][Got AC_OPEN][Ok]");
#endif
			break;
		case AC_CLOSE:
/*			if (pipe[4] == acc_id) */

			{
#ifdef DEBUG
				sprintf(tmp,"[1][Got AC_CLOSE|ACC id: %d|pipe4: %d][Ok]",acc_id,pipe[4]);
				form_alert(1,tmp);
#endif

				if(windforms[WIND_CTRL].wind_open)
				{
					wind_close(windforms[WIND_CTRL].whandle);
					wind_delete(windforms[WIND_CTRL].whandle);
					windforms[WIND_CTRL].wind_open=0;
				}
				if(windforms[WIND_INFO].wind_open)
				{
					wind_close(windforms[WIND_INFO].whandle);
					wind_delete(windforms[WIND_INFO].whandle);
					windforms[WIND_INFO].wind_open=0;
				}
#ifdef DEBUG
				sprintf(tmp,"[1][Filepos: %ld][Ok]",filepos);
				form_alert(1,tmp);
#endif
				file_was_open=file_open;
				if(file_open)
					close_file(fd);
				closed_acc=1;
				return 1;
			}
/*			break; */
			
		case AP_TERM:
			quit=1;
			return 1;
/*			switch(pipe[5])
			{
				case AP_RESCHG:
					printf("Got AP_RESCHG!\n");
				break;
				case AP_TERM:
					printf("Got AP_TERM!");
				break;
				default:
					printf("Got unknown AP_TERM!");
			}
*/
/*			break; */
		case RESCHG_COMPLETED:
/*			printf("Got RESCHG_COMPLETED!"); */
			break;
		
		case WM_REDRAW:
			if((wnr=find_windform(pipe[3]))>=0)
				update_objects(&windforms[wnr],windforms[wnr].firstobj,
					windforms[wnr].objdepth,pipe);
			break;
		case WM_MOVED:
			if((wnr=find_windform(pipe[3]))>=0)
			{
				wind_set(windforms[wnr].whandle,WF_CURRXYWH,pipe[4],pipe[5],pipe[6],pipe[7]);
				windforms[wnr].wind.x=pipe[4];
				windforms[wnr].wind.y=pipe[5];
				windforms[wnr].wind.w=pipe[6];
				windforms[wnr].wind.h=pipe[7];
				wind_calc(WC_WORK,windforms[wnr].windkind,
					windforms[wnr].wind.x,windforms[wnr].wind.y,
					windforms[wnr].wind.w,windforms[wnr].wind.h,
					&windforms[wnr].form.x,&windforms[wnr].form.y,
					&windforms[wnr].form.w,&windforms[wnr].form.h);
				windforms[wnr].formtree[windforms[wnr].firstobj].ob_x=windforms[wnr].form.x;
				windforms[wnr].formtree[windforms[wnr].firstobj].ob_y=windforms[wnr].form.y;
				windforms[wnr].formtree[windforms[wnr].firstobj].ob_width=windforms[wnr].form.w;
				windforms[wnr].formtree[windforms[wnr].firstobj].ob_height=windforms[wnr].form.h;
				if(replay)
					update_time();
			}
			break;
		case WM_CLOSED:
			if((wnr=find_windform(pipe[3]))>=0)
			{
				wind_close(windforms[wnr].whandle);
				windforms[wnr].wind_open=0;
				if(wnr==WIND_CTRL)
				{
					if(windforms[WIND_INFO].wind_open)
					{
						wind_close(windforms[WIND_INFO].whandle);
						windforms[WIND_INFO].wind_open=0;
					}
					return 1;
				}
				else
					wind_delete(windforms[wnr].whandle);
			}
			break;
		case WM_TOPPED:
			if((wnr=find_windform(pipe[3]))>=0)
				wind_set(pipe[3],WF_TOP);
			break;
		case AP_DRAGDROP:
			if(wind_find(pipe[4],pipe[5]) == windforms[WIND_CTRL].whandle)
			{
				if(do_dragdrop(pipe,DD_OK))
				{
					exit_replay();

					if(windforms[WIND_CTRL].formtree[CTRL_FF].ob_state & SELECTED)
						toggle_object(&windforms[WIND_CTRL],CTRL_FF,SET_NORMAL);
					Dsp_Hf1(0);				
					if(windforms[WIND_CTRL].formtree[CTRL_PAUSE].ob_state & SELECTED)
						toggle_object(&windforms[WIND_CTRL],CTRL_PAUSE,SET_NORMAL);
					replay_pause=0;

					filepos=0;
					fd=reopen_file();
					filesize=Fseek(0L,fd,2);
					Fseek(0L,fd,0);
					if((error=getmp2info(fd))==MP2_NOERR)
					{
						update_time();
						setfilename(filename);
						if(!(pipe[6] & K_ALT))
							init_replay();
					}
					else
					{
						exit_replay();
						show_mp2_error(error);
						close_file(fd);
						strcpy(windforms[WIND_CTRL].wind_title,"MPEG");
						wind_set(windforms[WIND_CTRL].whandle,WF_NAME,
							windforms[WIND_CTRL].wind_title);
						setfilename("MPEGFILE");
					}
				}
			}
			else
			{
				do_dragdrop(pipe,DD_NAK);
			}
			break;

		case VA_START:
			vamsg=*((char **)&pipe[3]);
			strcpy(path,vamsg);

/* This *should* be sent to the application
	which sent the VA_START msg, but it seems
	to hang Thing doing it. */
/*
			avmsg[0]=AV_STARTED;
			avmsg[1]=app_id;
			avmsg[2]=0;
			avmsg[3]=pipe[3];
			avmsg[4]=pipe[4];
			appl_write(pipe[1],5*2,avmsg);
*/
			if((o=strchr(path,' '))!=NULL)
				o[0]='\0';
			o=strrchr(path,'\\');
			strcpy(filename,&o[1]);
			o=strrchr(path,'\\');
			strncpy(o,"\\*.MP?",6);
			o[6] = '\0';


			exit_replay();

			if(windforms[WIND_CTRL].formtree[CTRL_FF].ob_state & SELECTED)
				toggle_object(&windforms[WIND_CTRL],CTRL_FF,SET_NORMAL);
			Dsp_Hf1(0);				
			if(windforms[WIND_CTRL].formtree[CTRL_PAUSE].ob_state & SELECTED)
				toggle_object(&windforms[WIND_CTRL],CTRL_PAUSE,SET_NORMAL);
			replay_pause=0;

			filepos=0;
			fd=reopen_file();
			filesize=Fseek(0L,fd,2);
			Fseek(0L,fd,0);
			if((error=getmp2info(fd))==MP2_NOERR)
			{
				update_time();
				setfilename(filename);
				init_replay();
			}
			else
			{
				exit_replay();
				show_mp2_error(error);
				close_file(fd);
				strcpy(windforms[WIND_CTRL].wind_title,"MPEG");
				wind_set(windforms[WIND_CTRL].whandle,WF_NAME,
					windforms[WIND_CTRL].wind_title);
				setfilename("MPEGFILE");
			}
			
			break;
		default:
#ifdef DEBUG
			sprintf(tmp,"[1][Unimplemented| message: %d][Ok]",pipe[0]);
			form_alert(1,tmp);
#endif
			break;
	}
	return 0;
}
Exemple #7
0
/* Form window open */
void fg_event_loop()
{
	int x,y,kstate,key,clicks,event,state;
	int pipe[8],obj_id;
	int fgexit=0,tmph,th;
	
	wind_open(windforms[WIND_CTRL].whandle,
		windforms[WIND_CTRL].wind.x,windforms[WIND_CTRL].wind.y,
		windforms[WIND_CTRL].wind.w,windforms[WIND_CTRL].wind.h);
	windforms[WIND_CTRL].wind_open=1;

#ifdef DEBUG
	form_alert(1,"[1][ACC fg][Ok]");
#endif
	do {
		event = evnt_multi( MU_MESAG | MU_TIMER | MU_BUTTON | MU_KEYBD,
							1, 0x3, 0x1,
							0, 0, 0, 0, 0,
							0, 0, 0, 0, 0,
							pipe,
							time_slice, 0,
							&x, &y, &state, &kstate, &key, &clicks );

		if (event & MU_TIMER)
			if (replay)
			{
				if(first_init)
					checkhang();
				load(1);
				update_time();
			}

		if(event & MU_KEYBD)
		{
			obj_id=key2button(key);
			if(obj_id < 0)
			{
				switch(-obj_id)
				{
					case CLOSE_WIND:
						wind_get(0, WF_TOP, &pipe[3]);
						pipe[0]=WM_CLOSED;
						fgexit=handle_message(pipe);
						break;
					case SWITCH_WIND:
						wind_get(0, WF_TOP, &tmph);
						/* find handle of next open window */
						th=tmph;
						while(((th=find_windform(th)+1)%N_WINDS)!=tmph)
						{
							if(windforms[th].wind_open)
							{
								wind_set(windforms[th].whandle,WF_TOP);
								break;
							}
						}
					default:
						break;
				}
			}
			else
				do_formstuff(obj_id);
		}

		if(!fgexit)
		{
			if (event & MU_MESAG)
				fgexit=handle_message(pipe);
	
			if (event & MU_BUTTON)
			{
				if(replay || replay_pause)
				{
					windforms[WIND_CTRL].formtree[CTRL_PAUSE].ob_flags |= KEEPSELECT;
					windforms[WIND_CTRL].formtree[CTRL_FF].ob_flags |= KEEPSELECT;
				}
				else
				{
					windforms[WIND_CTRL].formtree[CTRL_PAUSE].ob_flags &= ~KEEPSELECT;
					windforms[WIND_CTRL].formtree[CTRL_FF].ob_flags &= ~KEEPSELECT;
				}
				if(wind_find(x,y) == windforms[WIND_CTRL].whandle)
					if(ev2_loop(&windforms[WIND_CTRL],x,y))
						event=0;
			}
		}
		
		if(_app)
			quit=fgexit;
		else
			if(fgexit)
				fgbg=BG;

	} while ((replay || fgbg==FG) && !fgexit);
}
Exemple #8
0
/*----------------------------------------------------------------------------------------*/
int16	menu_context( int16 mx, int16 my )
{
	int16 obj, pob, wh;

	wh = wind_find( mx, my );
	
	set_state( tools, POP_ORIGIN, DISABLED, TRUE );
	set_state( tools, POP_ITOPEN, DISABLED, TRUE );
	set_flag( tools, POP_ITCLOSE, HIDETREE, TRUE );
	set_flag( tools, POP_ITOPEN, HIDETREE, FALSE );

	if( wh == wdial->win_handle && wdial->mode == WD_OPEN )
	{
		obj = objc_find( wdial->tree, ROOT, MAX_DEPTH, mx, my );
		
		if( obj > -1 )
		{
			dyn_fnode( wdial, obj );
			
			if( clnode )
			{
				my -= tools[POP_ITOPEN].ob_y;
			
				if( clnode->type == ItemTag && file_exist(clnode->attr.item->path) )
				{
					set_state( tools, POP_ORIGIN, DISABLED, FALSE );
					set_state( tools, POP_ITOPEN, DISABLED, FALSE );
				}
				else if( clnode->type == FolderTag )
				{
					set_state( tools, POP_ITOPEN, DISABLED, FALSE );
					if( clnode->attr.folder->open )
					{
						set_flag( tools, POP_ITOPEN, HIDETREE, TRUE );
						set_flag( tools, POP_ITCLOSE, HIDETREE, FALSE );					
					}
				}
			}
		}
		
		pob = icn_popup( TOOLS, POPUP, mx, my );
		
		switch( pob )
		{
			case POP_INFO:
				simple_mdial( about, 0 );
				break;
			case POP_ORIGIN:
				av_xwind( clnode->attr.item->path );
				break;
			case POP_ITCLOSE:
			case POP_ITOPEN:
				click_node( clnode, wdial, obj );
				break;
			case POP_HELP:
				open_hyp( "*:\\mcontrol.hyp", "" );
				break;				
			default:
				break;
		}
	}
	
	return 0;
}
Exemple #9
0
WINDOW *xw_find(int x, int y)
{
	return xw_hfind(wind_find(x, y));
}