window.c
changeset 4077 d3022f976946
parent 4000 bab1ebc37da0
child 4171 3fadda3afe70
equal deleted inserted replaced
4076:e3ef1c1f149c 4077:d3022f976946
    41 		if (e.click.widget < 0) return; /* exit if clicked outside of widgets */
    41 		if (e.click.widget < 0) return; /* exit if clicked outside of widgets */
    42 
    42 
    43 		wi = &w->widget[e.click.widget];
    43 		wi = &w->widget[e.click.widget];
    44 
    44 
    45 		/* don't allow any interaction if the button has been disabled */
    45 		/* don't allow any interaction if the button has been disabled */
    46 		if (HASBIT(w->disabled_state, e.click.widget))
    46 		if (HASBIT(w->disabled_state, e.click.widget)) return;
    47 			return;
       
    48 
    47 
    49 		if (wi->type & 0xE0) {
    48 		if (wi->type & 0xE0) {
    50 			/* special widget handling for buttons*/
    49 			/* special widget handling for buttons*/
    51 			switch (wi->type) {
    50 			switch (wi->type) {
    52 			case WWT_IMGBTN  | WWB_PUSHBUTTON: /* WWT_PUSHIMGBTN */
    51 			case WWT_IMGBTN  | WWB_PUSHBUTTON: /* WWT_PUSHIMGBTN */
   228 
   227 
   229 void DeleteWindow(Window *w)
   228 void DeleteWindow(Window *w)
   230 {
   229 {
   231 	WindowClass wc;
   230 	WindowClass wc;
   232 	WindowNumber wn;
   231 	WindowNumber wn;
   233 	ViewPort *vp;
       
   234 	Window *v;
   232 	Window *v;
   235 	int count;
   233 	int count;
   236 
   234 
   237 	if (w == NULL) return;
   235 	if (w == NULL) return;
   238 
   236 
   239 	if (_thd.place_mode != 0 && _thd.window_class == w->window_class && _thd.window_number == w->window_number) {
   237 	if (_thd.place_mode != VHM_NONE &&
       
   238 			_thd.window_class == w->window_class &&
       
   239 			_thd.window_number == w->window_number) {
   240 		ResetObjectToPlace();
   240 		ResetObjectToPlace();
   241 	}
   241 	}
   242 
   242 
   243 	wc = w->window_class;
   243 	wc = w->window_class;
   244 	wn = w->window_number;
   244 	wn = w->window_number;
   245 
   245 
   246 	CallWindowEventNP(w, WE_DESTROY);
   246 	CallWindowEventNP(w, WE_DESTROY);
   247 
   247 
   248 	w = FindWindowById(wc, wn);
   248 	w = FindWindowById(wc, wn);
   249 
   249 
   250 	vp = w->viewport;
   250 	if (w->viewport != NULL) {
   251 	w->viewport = NULL;
   251 		CLRBIT(_active_viewports, w->viewport - _viewports);
   252 	if (vp != NULL) {
   252 		w->viewport->width = 0;
   253 		_active_viewports &= ~(1 << (vp - _viewports));
   253 		w->viewport = NULL;
   254 		vp->width = 0;
       
   255 	}
   254 	}
   256 
   255 
   257 	SetWindowDirty(w);
   256 	SetWindowDirty(w);
   258 
   257 
   259 	free(w->widget);
   258 	free(w->widget);
   645 		pt.y = desc->top;
   644 		pt.y = desc->top;
   646 		if (pt.x == WDP_AUTO) {
   645 		if (pt.x == WDP_AUTO) {
   647 			pt = GetAutoPlacePosition(desc->width, desc->height);
   646 			pt = GetAutoPlacePosition(desc->width, desc->height);
   648 		} else {
   647 		} else {
   649 			if (pt.x == WDP_CENTER) pt.x = (_screen.width - desc->width) >> 1;
   648 			if (pt.x == WDP_CENTER) pt.x = (_screen.width - desc->width) >> 1;
   650 			if (pt.y == WDP_CENTER) pt.y = (_screen.height - desc->height) >> 1;
   649 			if (pt.y == WDP_CENTER) {
   651 			else if(pt.y < 0) pt.y = _screen.height + pt.y; // if y is negative, it's from the bottom of the screen
   650 				pt.y = (_screen.height - desc->height) >> 1;
       
   651 			} else if (pt.y < 0) {
       
   652 				pt.y = _screen.height + pt.y; // if y is negative, it's from the bottom of the screen
       
   653 			}
   652 		}
   654 		}
   653 	}
   655 	}
   654 
   656 
   655 	w = AllocateWindow(pt.x, pt.y, desc->width, desc->height, desc->proc, desc->cls, desc->widgets);
   657 	w = AllocateWindow(pt.x, pt.y, desc->width, desc->height, desc->proc, desc->cls, desc->widgets);
   656 	w->desc_flags = desc->flags;
   658 	w->desc_flags = desc->flags;
  1616 	// Delete all sticked windows
  1618 	// Delete all sticked windows
  1617 	for (w = _windows; w != _last_window;) {
  1619 	for (w = _windows; w != _last_window;) {
  1618 		if (w->flags4 & WF_STICKY) {
  1620 		if (w->flags4 & WF_STICKY) {
  1619 			DeleteWindow(w);
  1621 			DeleteWindow(w);
  1620 			w = _windows;
  1622 			w = _windows;
  1621 		} else
  1623 		} else {
  1622 			w++;
  1624 			w++;
       
  1625 		}
  1623 	}
  1626 	}
  1624 }
  1627 }
  1625 
  1628 
  1626 /* Delete all always on-top windows to get an empty screen */
  1629 /* Delete all always on-top windows to get an empty screen */
  1627 void HideVitalWindows(void)
  1630 void HideVitalWindows(void)
  1632 
  1635 
  1633 int PositionMainToolbar(Window *w)
  1636 int PositionMainToolbar(Window *w)
  1634 {
  1637 {
  1635 	DEBUG(misc, 1) ("Repositioning Main Toolbar...");
  1638 	DEBUG(misc, 1) ("Repositioning Main Toolbar...");
  1636 
  1639 
  1637 	if (w == NULL || w->window_class != WC_MAIN_TOOLBAR)
  1640 	if (w == NULL || w->window_class != WC_MAIN_TOOLBAR) {
  1638 		w = FindWindowById(WC_MAIN_TOOLBAR, 0);
  1641 		w = FindWindowById(WC_MAIN_TOOLBAR, 0);
       
  1642 	}
  1639 
  1643 
  1640 	switch (_patches.toolbar_pos) {
  1644 	switch (_patches.toolbar_pos) {
  1641 		case 1:  w->left = (_screen.width - w->width) >> 1; break;
  1645 		case 1:  w->left = (_screen.width - w->width) >> 1; break;
  1642 		case 2:  w->left = _screen.width - w->width; break;
  1646 		case 2:  w->left = _screen.width - w->width; break;
  1643 		default: w->left = 0;
  1647 		default: w->left = 0;