static void DoScrollDrag( p_gadget gadget, int prev, int diff ) { gui_event top; gui_event bottom; gui_event scroll; prev = prev; if( gadget->dir == VERTICAL ) { top = GUI_SCROLL_TOP; bottom = GUI_SCROLL_BOTTOM; scroll = GUI_SCROLL_VERTICAL; } else { top = GUI_SCROLL_FULL_LEFT; bottom = GUI_SCROLL_FULL_RIGHT; scroll = GUI_SCROLL_HORIZONTAL; } uisetgadgetnodraw( gadget, gadget->pos - diff ); if( prev + diff == 0 ) { GUIEVENTWND( GUICurrWnd, top, NULL ); } else if( ( prev + diff ) == ( gadget->total_size - gadget->page_size ) ) { GUIEVENTWND( GUICurrWnd, bottom, NULL ); } else { GUIEVENTWND( GUICurrWnd, scroll, &diff ); } }
LRESULT CALLBACK F1Proc( int code, WPARAM dummy, LPARAM msg_param ) #endif { WPI_MSG message; WPI_PARAM1 parm1; WPI_PARAM2 parm2; gui_window *curr; gui_window *root; bool b; #ifdef __OS2_PM__ int code; #else WPI_QMSG *qmsg; #endif #ifdef __OS2_PM__ fs = fs; // unused hab = hab; // unused code = 0; #else qmsg = (WPI_QMSG *) msg_param; #endif message = _wpi_qmsgmessage( qmsg ); parm1 = _wpi_qmsgparam1( qmsg ); parm2 = _wpi_qmsgparam2( qmsg ); if( code >= 0 ) { if( scroll_catch_check( qmsg ) ) { return( 1 ); } else if( _wpi_ismsgkeydown( message, parm1 ) && _wpi_getvk( parm1, parm2 ) == VK_F1 ) { curr = getFirstGUIParent( qmsg->hwnd ); if( curr != NULL ) { b = true; GUIEVENTWND( curr, GUI_CONTEXTHELP, &b ); root = GUIGetRootWindow(); if( root != NULL ) { b = false; GUIEVENTWND( root, GUI_CONTEXTHELP, &b ); } } } } #ifdef __OS2_PM__ return( false ); // No, we didn't gobble this msg #else return( CallNextHookEx( F1HookHandle, code, dummy, msg_param ) ); #endif }
static void ListNotify( EVENT ev, a_dialog *ui_dlg_info, gui_window *wnd ) { gui_event gui_ev; a_list *list; unsigned id; if( ui_dlg_info->curr != NULL ) { list = GUIGetList( ui_dlg_info->curr ); id = GUIGetControlId( wnd, ui_dlg_info->curr ); if( id != 0 ) { switch( ev ) { case EV_LIST_BOX_CHANGED : gui_ev = GUI_CONTROL_CLICKED; break; case EV_LIST_BOX_DCLICK : gui_ev = GUI_CONTROL_DCLICKED; break; case EV_LIST_BOX_CLOSED : gui_ev = GUI_CONTROL_CLICKED; break; default : return; } GUIEVENTWND( wnd, gui_ev, &id ); } } }
EVENT GUIProcessControlNotify( EVENT ev, a_dialog *ui_dlg_info, gui_window *wnd ) { unsigned id; switch( ev ) { case EV_CHECK_BOX_CLICK : CheckNotify( ui_dlg_info, wnd ); return( EV_NO_EVENT ); case EV_LIST_BOX_DCLICK : case EV_LIST_BOX_CHANGED : case EV_LIST_BOX_CLOSED : ListNotify( ev, ui_dlg_info, wnd ); return( EV_NO_EVENT ); case EV_CURSOR_UP : EditNotify( GUI_KEY_UP, ui_dlg_info, wnd ); return( EV_NO_EVENT ); case EV_CURSOR_DOWN : EditNotify( GUI_KEY_DOWN, ui_dlg_info, wnd ); return( EV_NO_EVENT ); default : if( ev >= GUI_FIRST_USER_EVENT ) { id = GETID( ev ); GUIEVENTWND( wnd, GUI_CONTROL_CLICKED, &id ); return( EV_NO_EVENT ); } return( ev ); } }
bool GUIXCloseToolBar( gui_window *wnd ) { int i; bool switching; toolbarinfo *tbar; if( wnd->tbinfo == NULL ) { return( true ); } tbar = wnd->tbinfo; switching = tbar->switching; if( tbar->fixed ) { for( i = 0; i < tbar->num_items; i++ ) { GUIDeleteToolbarMenuItem( wnd, tbar->info[i].id ); } } else { if( tbar->floattoolbar != NULL ) { GUIDestroyWnd( tbar->floattoolbar ); } } if( ( tbar->info != NULL ) && !switching ) { for( i = 0; i < tbar->num_items; i++ ) { GUIMemFree( (void *)tbar->info[i].label ); } GUIMemFree( tbar->info ); GUIMemFree( tbar ); wnd->tbinfo = NULL; } if( !switching ) { GUIEVENTWND( wnd, GUI_TOOLBAR_DESTROYED, NULL ); } return( true ); }
static void SendPointEvent( gui_window *wnd, gui_event gui_ev, gui_coord *point ) { gui_point pt; bool down_sent; down_sent = ButtonDownSent == wnd; switch( gui_ev ) { case GUI_LBUTTONDOWN : case GUI_RBUTTONDOWN : ButtonDownSent = wnd; break; case GUI_LBUTTONUP : case GUI_RBUTTONUP : ButtonDownSent = NULL; break; default : break; } /* if the mouse event is not on the border, or if it is a mouse up on * the border */ if( down_sent || ( MouseState == MOUSE_CLIENT ) ) { if( ( wnd->hgadget != NULL ) && !GUI_HSCROLL_EVENTS_SET( wnd ) ) { point->x += wnd->hgadget->pos; } if( ( wnd->vgadget != NULL ) && !GUI_VSCROLL_EVENTS_SET( wnd ) ) { point->y += wnd->vgadget->pos; } GUIMakeRelative( wnd, point, &pt ); GUIEVENTWND( wnd, gui_ev, &pt ); } }
static void SetFont( gui_window *wnd, HFONT font ) { wnd->font = font; GUISetRowCol( wnd, NULL ); GUISetScroll( wnd ); GUIEVENTWND( wnd, GUI_FONT_CHANGED, NULL ); }
void GUIDoResize( gui_window *wnd, HWND hwnd, gui_coord *size ) { hwnd = hwnd; if( wnd->style & GUI_CHANGEABLE_FONT ) { GUIEnableSysMenuItem( wnd, GUI_CHANGE_FONT, TRUE ); } if( wnd->hwnd != NULLHANDLE ) { GUIResizeStatus( wnd ); GUIResizeBackground( wnd, FALSE ); } GUIResizeToolBar( wnd ); if( !(wnd->flags & NEEDS_RESIZE_REDRAW ) ) { wnd->old_rows = wnd->num_rows; } GUISetRowCol( wnd, size ); wnd->flags |= NEEDS_RESIZE_REDRAW; GUISetScroll( wnd ); if( wnd->flags & SENT_INIT ) { GUIScreenToScaleR( size ); GUIEVENTWND( wnd, GUI_RESIZE, size ); } GUIInvalidatePaintHandles( wnd ); #ifdef __OS2_PM__ //_wpi_invalidaterect( hwnd, NULL, TRUE ); #endif GUIInvalidateResize( wnd ); //_wpi_updatewindow( hwnd ); }
void GUIBringToFront( gui_window *wnd ) { bool parent_is_dlg; bool same_window; if( wnd == NULL ) { return; } same_window = ( GUICurrWnd == wnd ); parent_is_dlg = false; if( wnd->parent ) { if( wnd->parent->flags & IS_DIALOG ) { parent_is_dlg = true; } } if( !same_window || parent_is_dlg ) { if( !same_window && ( GUICurrWnd != NULL ) ) { if( _wpi_getparent( GUICurrWnd->hwnd_frame ) != HWND_DESKTOP ) { ActivateNC( GUICurrWnd, false ); } GUIEVENTWND( GUICurrWnd, GUI_NOT_ACTIVE, NULL ); } // if the application indicates that it has processed the message // then do not proceed to bring the window to top if( !GUIEVENTWND( wnd, GUI_NOW_ACTIVE, NULL ) ) { GUICurrWnd = wnd; GUIFrontOfList( wnd ); ActivateNC( wnd, true ); GUIMDIBroughtToFront( wnd ); _wpi_bringwindowtotop( wnd->hwnd_frame ); _wpi_setfocus( wnd->hwnd_frame ); } } if( same_window && !parent_is_dlg ) { ActivateNC( wnd, true ); } if( parent_is_dlg ) { ActivateNC( wnd->parent, true ); } }
static void CheckNotify( a_dialog *ui_dlg_info, gui_window *wnd ) { unsigned id; if( ui_dlg_info->curr != NULL ) { id = GUIGetControlId( wnd, ui_dlg_info->curr ); if( id != 0 ) { GUIEVENTWND( wnd, GUI_CONTROL_CLICKED, &id ); } } }
bool ToolbarCallBack( gui_window *wnd, gui_event gui_ev, void *param ) { gui_ctl_id id; switch( gui_ev ) { case GUI_INIT_WINDOW : GUIEVENTWND( wnd->parent, GUI_TOOLBAR_FLOATING, NULL ); return( true ); case GUI_KEYDOWN : case GUI_KEYUP : GUIEVENTWND( wnd->parent, gui_ev, param ); break; case GUI_CLICKED : GUI_GETID( param, id ); if( id == FIX_TOOLBAR ) { FixToolbar( wnd ); } break; case GUI_CONTROL_CLICKED : GUI_GETID( param, id ); id = EV2ID( id ); GUIEVENTWND( wnd->parent, GUI_CLICKED, &id ); break; case GUI_LBUTTONDBLCLK : FixToolbar( wnd ); break; case GUI_DESTROY : /* didn't get close first */ if( wnd->parent->tbinfo->floattoolbar != NULL ) { wnd->parent->tbinfo->floattoolbar = NULL; } GUICloseToolBar( wnd->parent ); break; case GUI_CLOSE : wnd->parent->tbinfo->floattoolbar = NULL; break; default : break; } return( true ); }
static void ProcessMenu( gui_window *wnd, WORD param ) { if( param < GUI_LAST_MENU_ID ) { GUIEVENTWND( wnd, GUI_CLICKED, ¶m ); } else { switch( param ) { case GUI_CHANGE_FONT : GUIChangeFont( wnd ); break; } } }
WPI_MRESULT GUIProcessInitMenuPopup ( gui_window *wnd, HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam ) { gui_ctl_id id; HMENU hmenu; hmenu = GET_WM_INITMENU_MENU( wparam, lparam ); if ( GetPopupId( wnd, hmenu, &id ) ) { GUIEVENTWND( wnd, GUI_INITMENUPOPUP, &id ); } return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); }
static void ProcessInitPopupEvent( void ) { MENUITEM menu; gui_ctl_id id; if( uigetcurrentmenu ( &menu ) ) { id = EV2ID( menu.event ); if( id != 0 ) { GUIEVENTWND( GUICurrWnd, GUI_INITMENUPOPUP, &id ); } } }
void GUIResizeBackground( gui_window *wnd, bool force_msg ) { WPI_RECT status; int t_height, s_height; GUI_RECTDIM left, top, right, bottom; gui_coord size; if( wnd->root == NULLHANDLE ) { if( wnd->hwnd != NULLHANDLE ) { _wpi_getclientrect( wnd->hwnd, &wnd->hwnd_client ); } return; } t_height = 0; s_height = 0; if( ( wnd->toolbar != NULL ) && ( wnd->toolbar->info.is_fixed ) ) { t_height = _wpi_getheightrect( wnd->toolbar->fixedrect ); } if( wnd->status != NULLHANDLE ) { _wpi_getwindowrect( wnd->status, &status ); s_height = _wpi_getheightrect( status ); } _wpi_getclientrect( wnd->root_frame, &wnd->root_client ); _wpi_getrectvalues( wnd->root_client, &left, &top, &right, &bottom ); bottom -= top; right -= left; top = left = 0; #ifdef __OS2_PM__ top += s_height; bottom -= t_height; #else top += t_height; bottom -= s_height; #endif /* if the root client is a separate window resize it too */ _wpi_movewindow( wnd->hwnd, left, top, right - left, bottom - top, TRUE ); _wpi_getclientrect( wnd->hwnd, &wnd->hwnd_client ); if( force_msg && ( wnd->flags & SENT_INIT ) ) { size.x = right - left; size.y = bottom - top; GUIScreenToScaleR( &size ); GUIEVENTWND( wnd, GUI_RESIZE, &size ); } }
VOID CALLBACK GUITimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ) { gui_window *wnd; gui_timer_event timer; uMsg = uMsg; dwTime = dwTime; wnd = GUIGetWindow( hwnd ); if( wnd == NULL ) { GUITimer(); } else { timer.id = idEvent; GUIEVENTWND( wnd, GUI_TIMER_EVENT, &timer ); } }
static void EditNotify( gui_key key, a_dialog *ui_dlg_info, gui_window *wnd ) { gui_key_control key_control; if( ui_dlg_info->curr != NULL ) { switch( ui_dlg_info->curr->typ ) { case FLD_EDIT : case FLD_INVISIBLE_EDIT : key_control.key_state.key = key; GUIGetKeyState( &key_control.key_state.state ); key_control.id = GUIGetControlId( wnd, ui_dlg_info->curr ); if( key_control.id != 0 ) { GUIEVENTWND( wnd, GUI_KEY_CONTROL, &key_control ); } } } }
bool GUIResizeWindow( gui_window *wnd, gui_rect *rect ) { gui_coord pos; gui_coord size; gui_window *parent; HWND frame; HWND phwnd; HWND rphwnd; WPI_POINT pt; GUIInvalidatePaintHandles( wnd ); if( wnd->hwnd != NULLHANDLE ) { frame = GUIGetParentFrameHWND( wnd ); parent = wnd->parent; phwnd = HWND_DESKTOP; if( parent ) { phwnd = parent->hwnd; } GUICalcLocation( rect, &pos, &size, phwnd ); if( wnd->flags & IS_DIALOG ) { // dialogs are owned by, but not children of, phwnd // so lets map pos to its real parent pt.x = pos.x; pt.y = pos.y; rphwnd = _wpi_getparent( frame ); _wpi_mapwindowpoints( phwnd, rphwnd, &pt, 1 ); _wpi_movewindow( frame, pt.x, pt.y, size.x, size.y, TRUE ); // The following is a bandaid 'till I find out why WM_SIZE's aren't // generated for PM GUI dialogs by this fuction #ifdef __OS2_PM__ _wpi_getclientrect( frame, &wnd->hwnd_client ); wnd->root_client = wnd->hwnd_client; GUISetRowCol( wnd, NULL ); GUIScreenToScaleR( &size ); GUIEVENTWND( wnd, GUI_RESIZE, &size ); #endif } else { _wpi_setwindowpos( frame, NULLHANDLE, pos.x, pos.y, size.x, size.y, SWP_NOACTIVATE | SWP_NOZORDER | SWP_SIZE | SWP_MOVE ); //SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOZORDER | SWP_SIZE | SWP_MOVE ); } } return( true ); }
bool GUIXCloseToolBar( gui_window *wnd ) { toolbarinfo *toolbar; int i; if( ( wnd->toolbar != NULL ) && ( wnd->toolbar->hdl != NULL ) ) { toolbar = wnd->toolbar; wnd->toolbar = NULL; ToolBarFini( toolbar->hdl ); for( i=0; i < toolbar->num; i++ ) { _wpi_deletebitmap( toolbar->bitmaps[i] ); } GUIMemFree( toolbar->bitmaps ); GUIMemFree( toolbar ); GUIResizeBackground( wnd, TRUE ); GUIEVENTWND( wnd, GUI_TOOLBAR_DESTROYED, NULL ); } return( TRUE ); }
bool GUIDrawStatusText( gui_window *wnd, const char *text ) { WPI_PRES pres; const char *out_text; if( !GUIHasStatus( wnd) ) { return( false ); } pres = _wpi_getpres( wnd->status ); if( ( text == NULL ) || ( *text == '\0' ) ) { out_text = LIT( Blank ); } else { out_text = text; } StatusWndDrawLine( GUIStatusWnd, pres, wnd->font, out_text, DT_SINGLELINE | DT_VCENTER | DT_LEFT ); _wpi_releasepres( wnd->status, pres ); if( ( text == NULL ) || ( *text == '\0' ) ) { GUIEVENTWND( wnd, GUI_STATUS_CLEARED, NULL ); } return( true ); }
extern bool GUIXCreateFixedToolbar( gui_window *wnd ) { int i; int j; gui_menu_struct menu; char *with_excl; toolbarinfo *tbar; tbar = wnd->tbinfo; tbar->fixed = true; menu.num_child_menus = 0; menu.child = NULL; menu.style = GUI_ENABLED; for( i = 0; i < tbar->num_items; i++ ) { with_excl = NULL; menu.label = tbar->info[i].label; if( menu.label != NULL ) { with_excl = (char *)GUIMemAlloc( strlen( menu.label ) + 2 ); if( with_excl != NULL ) { strcpy( with_excl, menu.label ); strcat( with_excl, LIT( Exclamation ) ); } menu.label = with_excl; } menu.id = tbar->info[i].id; menu.hinttext = tbar->info[i].hinttext; if( !GUIAppendToolbarMenu( wnd, &menu, ( i == ( tbar->num_items - 1 ) ) ) ) { GUIMemFree( with_excl ); for( j = 0; j < i; j++ ) { GUIDeleteToolbarMenuItem( wnd, tbar->info[j].id ); } return( false ); } GUIMemFree( with_excl ); } GUIEVENTWND( wnd, GUI_TOOLBAR_FIXED, NULL ); return( true ); }
bool SendPointEvent( WPI_PARAM1 wparam, WPI_PARAM2 lparam, gui_window *wnd, gui_event gui_ev, bool force_current ) { WPI_POINT currentpoint; gui_point point; if( force_current || !EditControlHasFocus ) { wparam = wparam; lparam = lparam; currentpoint.x = GET_WM_MOUSEMOVE_POSX( wparam, lparam ); currentpoint.y = GET_WM_MOUSEMOVE_POSY( wparam, lparam ); if( force_current && ( GUICurrWnd != wnd ) && ( GUICurrWnd != NULL ) ) { //wnd = GUICurrWnd; } currentpoint.y = _wpi_cvtc_y( wnd->hwnd, currentpoint.y ); _wpi_clienttoscreen( wnd->hwnd, ¤tpoint ); GUIMakeRelative( wnd, ¤tpoint, &point ); GUIEVENTWND( wnd, gui_ev, &point ); return( TRUE ); } return( FALSE ); }
bool GUIChangeToolBar( gui_window *wnd ) { gui_event gui_ev; toolbarinfo *tbar; HWND toolhwnd; int t; GUI_RECTDIM left, top, right, bottom; tbar = wnd->tbinfo; if( !tbar->info.is_fixed ) { tbar->info.is_fixed = true; tbar->info.style = TOOLBAR_FIXED_STYLE; tbar->info.area = tbar->fixedrect; gui_ev = GUI_TOOLBAR_FIXED; } else { tbar->info.is_fixed = false; tbar->info.style = TOOLBAR_FLOAT_STYLE; tbar->info.area = tbar->floatrect; _wpi_cvtc_rect_plus1( wnd->root, &tbar->info.area ); gui_ev = GUI_TOOLBAR_FLOATING; } ToolBarDisplay( tbar->hdl, &tbar->info ); if( tbar->info.style != TOOLBAR_FLOAT_STYLE ) { ToolBarRedrawButtons( tbar->hdl ); } toolhwnd = ToolBarWindow( tbar->hdl ); if( tbar->info.style == TOOLBAR_FLOAT_STYLE ) { _wpi_getrectvalues( tbar->floatrect, &left, &top, &right, &bottom ); t = top; //t = _wpi_cvtc_y_size( wnd->hwnd, t, bottom - top ); t = _wpi_cvtc_y_plus1( wnd->root, t ); _wpi_movewindow( toolhwnd, left, t, right-left, bottom-top, TRUE ); } GUIResizeBackground( wnd, true ); _wpi_showwindow( toolhwnd, SW_SHOWNORMAL ); _wpi_updatewindow( toolhwnd ); GUIEVENTWND( wnd, gui_ev, NULL ); return( true ); }
bool GUIXCloseToolBar( gui_window *wnd ) { toolbarinfo *tbar; int i; tbar = wnd->tbinfo; if( tbar != NULL ) { wnd->tbinfo = NULL; if( tbar->hdl != NULL ) { ToolBarFini( tbar->hdl ); for( i = 0; i < tbar->num; i++ ) { _wpi_deletebitmap( tbar->bitmaps[i] ); } GUIMemFree( tbar->bitmaps ); } GUIMemFree( tbar ); if( (wnd->flags & DOING_DESTROY) == 0 ) { GUIResizeBackground( wnd, true ); } GUIEVENTWND( wnd, GUI_TOOLBAR_DESTROYED, NULL ); } return( true ); }
void GUIFocusChangeNotify( a_dialog *ui_dlg_info ) { unsigned id; gui_window *wnd; dialog_node *dlg_node; dlg_node = GetDialog( ui_dlg_info ); if( dlg_node != NULL ) { wnd = dlg_node->wnd; if( ( ui_dlg_info->other != NULL ) && ( wnd != NULL ) ) { switch( ui_dlg_info->other->typ ) { case FLD_EDIT : case FLD_INVISIBLE_EDIT : case FLD_PULLDOWN : case FLD_LISTBOX : case FLD_COMBOBOX : case FLD_EDIT_MLE : id = GUIGetControlId( wnd, ui_dlg_info->other ); GUIEVENTWND( wnd, GUI_CONTROL_NOT_ACTIVE, &id ); } } } }
EVENT GUICreateMenuPopup( gui_window *wnd, gui_point *location, MENUITEM *menu, gui_mouse_track track, gui_ctl_id *curr_id ) { EVENT ev; gui_ctl_id id; ATTR attr_active; ATTR attr_hot; ATTR attr_curr_active; ATTR attr_hot_curr; ATTR attr_inactive; ATTR attr_curr_inactive; ATTR attr_menu; gui_window *top; SAREA area; DESCMENU desc; MenuWnd = wnd; if( MenuState == MENU_NONE ) { MenuState = MENU_SYS; } if( menu == NULL ) { return( EV_NO_EVENT ); } attr_active = UIData->attrs[ATTR_ACTIVE]; attr_hot = UIData->attrs[ATTR_HOT]; attr_curr_active = UIData->attrs[ATTR_CURR_ACTIVE]; attr_hot_curr = UIData->attrs[ATTR_HOT_CURR]; attr_inactive = UIData->attrs[ATTR_INACTIVE]; attr_curr_inactive = UIData->attrs[ATTR_CURR_INACTIVE]; attr_menu = UIData->attrs[ATTR_MENU]; UIData->attrs[ATTR_ACTIVE] = wnd->colours[GUI_MENU_PLAIN]; UIData->attrs[ATTR_HOT] = wnd->colours[GUI_MENU_STANDOUT]; UIData->attrs[ATTR_CURR_ACTIVE] = wnd->colours[GUI_MENU_ACTIVE]; UIData->attrs[ATTR_HOT_CURR] = wnd->colours[GUI_MENU_ACTIVE_STANDOUT]; UIData->attrs[ATTR_INACTIVE] = wnd->colours[GUI_MENU_GRAYED]; UIData->attrs[ATTR_CURR_INACTIVE] = wnd->colours[GUI_MENU_GRAYED_ACTIVE]; UIData->attrs[ATTR_MENU] = wnd->colours[GUI_MENU_FRAME]; ev = 0; if( ( curr_id != NULL ) && ( *curr_id != 0 ) ) { ev = ID2EV( *curr_id ); } top = GUIGetTopWnd( wnd ); COPYAREA( top->use, area ); area.row += top->screen.area.row; area.col += top->screen.area.col; if( !uiposfloatingpopup( menu, &desc, wnd->screen.area.row + location->y, wnd->screen.area.col + location->x, &area, NULL ) ) { return( EV_NO_EVENT ); } ev = uicreatepopupinarea( menu, &desc, track & GUI_TRACK_LEFT, track & GUI_TRACK_RIGHT, ev, &area, false ); if( ev == EV_KILL_UI ) { uiforceevadd( EV_KILL_UI ); ev = EV_NO_EVENT; } GUIProcessMenuCurr( NULL ); UIData->attrs[ATTR_ACTIVE] = attr_active; UIData->attrs[ATTR_HOT] = attr_hot; UIData->attrs[ATTR_CURR_ACTIVE] = attr_curr_active; UIData->attrs[ATTR_HOT_CURR] = attr_hot_curr; UIData->attrs[ATTR_INACTIVE] = attr_inactive; UIData->attrs[ATTR_CURR_INACTIVE] = attr_curr_inactive; UIData->attrs[ATTR_MENU] = attr_menu; if( ( ev != EV_MOUSE_DCLICK ) && ( ev != EV_NO_EVENT ) ) { if( IS_CTLEVENT( ev ) ) { id = EV2ID( ev ); GUIEVENTWND( wnd, GUI_CLICKED, &id ); if( curr_id != NULL ) { *curr_id = id; } } else { GUIProcessSysMenuEvent( ev, wnd ); } } if( MenuState == MENU_SYS ) { MenuState = MENU_NONE; } MenuWnd = NULL; return( ev ); }
static void ProcessScrollEvent( EVENT ev ) { gui_event gui_ev; p_gadget gadget; int diff; bool events; gui_event notify; switch( ev ) { case EV_SCROLL_UP : events = (GUICurrWnd->style & GUI_VSCROLL_EVENTS) != 0; gui_ev = GUI_SCROLL_UP; diff = -1; gadget = GUICurrWnd->vgadget; break; case EV_SCROLL_DOWN : events = (GUICurrWnd->style & GUI_VSCROLL_EVENTS) != 0; gui_ev = GUI_SCROLL_DOWN; diff = 1; gadget = GUICurrWnd->vgadget; break; case EV_SCROLL_PAGE_UP : events = (GUICurrWnd->style & GUI_VSCROLL_EVENTS) != 0; gui_ev = GUI_SCROLL_PAGE_UP; diff = -GUICurrWnd->use.height; gadget = GUICurrWnd->vgadget; break; case EV_SCROLL_PAGE_DOWN : events = (GUICurrWnd->style & GUI_VSCROLL_EVENTS) != 0; gui_ev = GUI_SCROLL_PAGE_DOWN; diff = GUICurrWnd->use.height; gadget = GUICurrWnd->vgadget; break; case EV_SCROLL_LEFT : events = (GUICurrWnd->style & GUI_HSCROLL_EVENTS) != 0; gui_ev = GUI_SCROLL_LEFT; diff = -1; gadget = GUICurrWnd->hgadget; break; case EV_SCROLL_RIGHT : events = (GUICurrWnd->style & GUI_HSCROLL_EVENTS) != 0; gui_ev = GUI_SCROLL_RIGHT; diff = 1; gadget = GUICurrWnd->hgadget; break; case EV_SCROLL_LEFT_PAGE : events = (GUICurrWnd->style & GUI_HSCROLL_EVENTS) != 0; gui_ev = GUI_SCROLL_PAGE_LEFT; diff = -GUICurrWnd->use.width; gadget = GUICurrWnd->hgadget; break; case EV_SCROLL_RIGHT_PAGE : events = (GUICurrWnd->style & GUI_HSCROLL_EVENTS) != 0; gui_ev = GUI_SCROLL_PAGE_RIGHT; diff = GUICurrWnd->use.width; gadget = GUICurrWnd->hgadget; break; default: return; } if( events ) { GUIEVENTWND( GUICurrWnd, gui_ev, NULL ); } else { GUIScroll( diff, gadget ); if( gadget->dir == HORIZONTAL ) { notify = GUI_HSCROLL_NOTIFY; } else { notify = GUI_VSCROLL_NOTIFY; } GUIEVENTWND( GUICurrWnd, notify, NULL ); } }
void GUIPaint( gui_window *wnd, HWND hwnd, bool isdlg ) { HDC prev_hdc; PAINTSTRUCT *prev_ps; gui_row_num row_num; PAINTSTRUCT ps; WPI_RECT fill_area; #ifdef __OS2_PM__ ULONG flags; RECTL client; #endif isdlg=isdlg; /* save old state */ prev_hdc = wnd->hdc; prev_ps = wnd->ps; /* Setup Paint */ wnd->ps = &ps; wnd->hdc = _wpi_beginpaint( hwnd, NULLHANDLE, wnd->ps ); _wpi_torgbmode( wnd->hdc ); _wpi_getpaintrect( wnd->ps, &fill_area ); #ifdef __OS2_PM__ fill_area = *(wnd->ps); if( isdlg ) { _wpi_inflaterect( GUIMainHInst, &fill_area, 10, 10); } WinFillRect( wnd->hdc, &fill_area, GUIGetBack( wnd, GUI_BACKGROUND ) ); #endif #if defined( __NT__ ) if( isdlg ) { _wpi_fillrect( wnd->hdc, &fill_area, GUIGetBack( wnd, GUI_BACKGROUND ), wnd->bk_brush ); } #endif if( wnd->font != NULL ) { wnd->prev_font = _wpi_selectfont( wnd->hdc, wnd->font ); } else { wnd->prev_font = NULL; } /* send paint to app */ GUIGetUpdateRows( wnd, hwnd, &row_num.start, &row_num.num ); if( row_num.num > 0 ) { GUIEVENTWND( wnd, GUI_PAINT, &row_num ); } /* finish painting */ if( wnd->prev_font != NULL ) { _wpi_getoldfont( wnd->hdc, wnd->prev_font ); wnd->prev_font = NULL; } #ifdef __OS2_PM__ if( isdlg ) { flags = DB_AREAATTRS | DB_DLGBORDER; #ifdef _M_I86 if( WinQueryActiveWindow( HWND_DESKTOP, FALSE ) != hwnd ) { #else if( WinQueryActiveWindow( HWND_DESKTOP ) != hwnd ) { #endif //if( _wpi_getfocus() != hwnd ) { flags |= DB_PATINVERT; } WinQueryWindowRect( hwnd, &client ); WinDrawBorder( wnd->hdc, &client, 1, 1, 0, 0, flags ); } #endif _wpi_endpaint( hwnd, wnd->hdc, wnd->ps ); /* restore old state */ wnd->hdc = prev_hdc; wnd->ps = prev_ps; } #else // this is some experimental PM stuff void GUIPaint( gui_window *wnd, HWND hwnd, bool isdlg ) { HDC prev_hdc; PAINTSTRUCT *prev_ps; gui_row_num row_num; PAINTSTRUCT ps; PAINTSTRUCT fill_area; // experimenal stuff HPS hps; RECTL client; LONG width, height; ULONG flags; int compat_created; gui_paint_info *pinfo; // figure out which paint info to use if( !isdlg && wnd->root == hwnd ) { pinfo = &wnd->root_pinfo; } else { pinfo = &wnd->hwnd_pinfo; } pinfo->in_use++; compat_created = FALSE; /* save old state */ prev_hdc = wnd->hdc; prev_ps = wnd->ps; if( isdlg ) { _wpi_getclientrect( hwnd, &client ); } else { WinQueryWindowRect( hwnd, &client ); } width = client.xRight - client.xLeft; height = client.yTop - client.yBottom; wnd->ps = &ps; //hps = _wpi_beginpaint( hwnd, pinfo->normal_pres, wnd->ps ); hps = _wpi_beginpaint( hwnd, NULL, wnd->ps ); if( pinfo->compatible_pres == (WPI_PRES)NULL ) { compat_created = TRUE; pinfo->compatible_pres = _wpi_createcompatiblepres( hps, GUIMainHInst, &pinfo->compatible_hdc ); pinfo->draw_bmp = _wpi_createcompatiblebitmap( hps, width, height ); pinfo->old_bmp = _wpi_selectbitmap( pinfo->compatible_pres, pinfo->draw_bmp ); } // the condition is here VERY conservative!! // its gains have to analyzed if( compat_created || pinfo->force_count ) { wnd->hdc = pinfo->compatible_pres; //wnd->hdc = hps; _wpi_torgbmode( wnd->hdc ); fill_area = *(wnd->ps); if( isdlg ) { _wpi_inflaterect( GUIMainHInst, &fill_area, 10, 10); } WinFillRect( wnd->hdc, &fill_area, GUIGetBack( wnd, GUI_BACKGROUND ) ); wnd->prev_font = NULL; if( wnd->font != NULL ) { wnd->prev_font = _wpi_selectfont( wnd->hdc, wnd->font ); } /* send paint to app */ GUIGetUpdateRows( wnd, hwnd, &row_num.start, &row_num.num ); if( row_num.num > 0 ) { GUIEVENTWND( wnd, GUI_PAINT, &row_num ); } /* finish painting */ if( wnd->prev_font != NULL ) { _wpi_getoldfont( wnd->hdc, wnd->prev_font ); wnd->prev_font = NULL; } if( pinfo->force_count ) { //pinfo->force_count--; } } //_wpi_bitblt( hps, client.xLeft, client.yBottom, width, height, // wnd->hdc, 0, 0, SRCCOPY ); if( pinfo->in_use == 1 ) { //_wpi_bitblt( hps, client.xLeft, client.yBottom, width, height, // wnd->hdc, 0, 0, SRCCOPY ); _wpi_bitblt( hps, ps.xLeft, ps.yBottom, ps.xRight - ps.xLeft, ps.yTop - ps.yBottom, wnd->hdc, ps.xLeft, ps.yBottom, SRCCOPY ); if( pinfo->delete_when_done ) { GUIFreePaintHandles( pinfo, TRUE ); } } if( isdlg ) { flags = DB_AREAATTRS | DB_DLGBORDER; #ifdef _M_I86 if( WinQueryActiveWindow( HWND_DESKTOP, FALSE ) != hwnd ) { #else if( WinQueryActiveWindow( HWND_DESKTOP ) != hwnd ) { #endif //if( _wpi_getfocus() != hwnd ) { flags |= DB_PATINVERT; } WinQueryWindowRect( hwnd, &client ); WinDrawBorder( hps, &client, 1, 1, 0, 0, flags ); } _wpi_endpaint( hwnd, hps, wnd->ps ); /* restore old state */ wnd->hdc = prev_hdc; wnd->ps = prev_ps; if( pinfo->in_use ) { pinfo->in_use--; } } #endif void GUIInvalidatePaintHandles( gui_window *wnd ) { GUIFreeWndPaintHandles( wnd, FALSE ); }
bool GUIXCreateDialog( gui_create_info *dlg_info, gui_window *wnd, int num_controls, gui_control_info *controls_info, bool sys, long dlg_id ) { EVENT ev; int i; a_dialog *ui_dlg_info; VFIELD *fields; char *title; VFIELD *focus; int size; bool colours_set; bool ok; if( dlg_id != -1 ) { if( !GUICreateDialogFromRes( dlg_id, dlg_info->parent, dlg_info->call_back, dlg_info->extra ) ) { return( false ); } GUIMemFree( wnd ); return( true ); } sys = sys; RadioGroup = NULL; Group = false; fields = NULL; title = NULL; ui_dlg_info = NULL; colours_set = false; wnd->flags |= DIALOG; if( !GUISetupStruct( wnd, dlg_info, true ) ) { return( false ); } size = ( num_controls + 1 ) * sizeof( VFIELD ); fields = (VFIELD *)GUIMemAlloc( size ); if( fields == NULL ) { return( false ); } memset( fields, 0, size ); focus = NULL; for( i = 0; i < num_controls; i++ ) { uiyield(); if( !GUIDoAddControl( &controls_info[i], wnd, &fields[i] ) ) { GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true ); return( false ); } else { if( ( focus == NULL ) && ( controls_info[i].style & GUI_FOCUS ) ) { focus = &fields[i]; } } } CleanUpRadioGroups(); fields[num_controls].typ = FLD_VOID; /* mark end of list */ title = GUIStrDup( dlg_info->title, &ok ); if( !ok ) { GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true ); return( false ); } colours_set = GUISetDialColours(); ui_dlg_info = uibegdialog( title, fields, wnd->screen.area.height, wnd->screen.area.width, wnd->screen.area.row, wnd->screen.area.col ); if( ui_dlg_info == NULL ) { GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true ); return( false ); } if( focus != NULL ) { uidialogsetcurr( ui_dlg_info, focus ); } if( !InsertDialog( wnd, ui_dlg_info, num_controls, title, colours_set ) ) { GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true ); return( false ); } for( i = 0; i < num_controls; i++ ) { uiyield(); GUIInsertControl( wnd, &controls_info[i], i ); } GUIEVENTWND( wnd, GUI_INIT_DIALOG, NULL ); uipushlist( NULL ); uipushlist( GUIUserEvents ); GUIPushControlEvents(); uipushlist( DlgEvents ); while( ( GetDialog( ui_dlg_info ) != NULL ) ) { ev = uidialog( ui_dlg_info ); switch( ev ) { case EV_KILL_UI: uiforceevadd( EV_KILL_UI ); case EV_ESCAPE: GUIEVENTWND( wnd, GUI_DIALOG_ESCAPE, NULL ); GUICloseDialog( wnd ); break; default : GUIProcessControlNotify( ev, ui_dlg_info, wnd ); } } return( true ); }
bool GUIProcessEvent( EVENT ev ) { gui_event gui_ev; ORD row, col; gui_window *wnd; int prev; int diff; gui_ctl_id id; gui_window *menu_window; bool new_curr_wnd; VSCREEN *screen; // this is processed before all others and signals the end for all // GUI UI windows ( unconditional ) if( ev == EV_KILL_UI ) { GUIDestroyWnd( NULL ); return( false ); } ev = MapMiddleToRight( ev ); ev = CheckPrevEvent( ev ); wnd = NULL; if( uimouseinstalled() ) { screen = uivmousepos( NULL, &row, &col ); if( screen != NULL && (screen->flags & V_GUI_WINDOW) != 0 ) { wnd = (gui_window *)((char *)screen - offsetof( gui_window, screen )); } } if( GUIDoKeyboardMoveResize( ev ) ) { return( true ); } if( MouseState == MOUSE_MOVE || MouseState == MOUSE_SIZE ) { if( GUIDoMoveResizeCheck( GUIMouseWnd, ev, row, col ) ) { MouseState = MOUSE_FREE; return( true ); } if( GUI_WND_MINIMIZED( GUIMouseWnd ) ) { switch( ev ) { case EV_MOUSE_DCLICK : case EV_MOUSE_RELEASE : case EV_MOUSE_DRAG : ProcessMinimizedMouseEvent( ev, row, col ); } } else { switch( ev ) { case EV_MOUSE_RELEASE : case EV_MOUSE_DRAG : case EV_MOUSE_DRAG_R : ProcessMouseReleaseDrag( ev, GUI_LBUTTONUP, row, col ); } } return( true ); } new_curr_wnd = SetCurrWnd( ev, wnd ); if( GUIProcessAltMenuEvent( ev ) ) { return( true ); } /* Only deal with press and dclick events for minimized windows. * All other non-menu events are ingored. */ if( !IS_CTLEVENT( ev ) && ( GUICurrWnd != NULL ) && GUI_WND_MINIMIZED( GUICurrWnd ) ) { /* ignore event if mouse not in minimized current window */ if( GUICurrWnd == wnd ) { switch( ev ) { case EV_MOUSE_PRESS : case EV_MOUSE_DCLICK : case EV_MOUSE_RELEASE : GUIMouseWnd = GUICurrWnd; ProcessMinimizedMouseEvent( ev, row, col ); break; } } return( true ); } if( !IS_CTLEVENT( ev ) && ( GUICurrWnd != NULL ) && GUIIsOpen( GUICurrWnd ) ) { /* see if any of the controls in the window consume the event */ ev = GUIProcessControlEvent( GUICurrWnd, ev, row, col ); /* See if the event is for on of the scroll bars. */ /* Diff and prev are used if the event return is */ /* EV_SCROLL_HORIZONTAL or EV_SCROLL_VERTICAL. */ if( !new_curr_wnd || ( GUIGetWindowStyles() & ( GUI_INACT_GADGETS+GUI_INACT_SAME ) ) ) { ev = GUIGadgetFilter( GUICurrWnd, ev, &prev, &diff ); } if( ev == EV_NO_EVENT ) { return( true ); } } gui_ev = GUI_NO_EVENT; ev = GUIMapKeys( ev ); switch( ev ) { case EV_MOUSE_DCLICK_R : ProcessMousePos( GUI_RBUTTONDBLCLK, row, col, wnd ); return( true ); break; case EV_MOUSE_RELEASE_R : ProcessMouseReleaseDrag( ev, GUI_RBUTTONUP, row, col ); return( true ); break; case EV_MOUSE_DRAG_R : if( GUICurrWnd != GUIMouseWnd ) { /* got drag without press first */ ProcessMousePress( EV_MOUSE_PRESS_R, GUI_LBUTTONDOWN, row, col, new_curr_wnd ); } case EV_MOUSE_MOVE : ProcessMousePos( GUI_MOUSEMOVE, row, col, wnd ); return( true ); break; case EV_MOUSE_RELEASE : ProcessMouseReleaseDrag( ev, GUI_LBUTTONUP, row, col ); return( true ); break; case EV_MOUSE_DRAG : if( GUICurrWnd != GUIMouseWnd ) { /* got drag without press first */ ProcessMousePress( EV_MOUSE_PRESS, GUI_LBUTTONDOWN, row, col, new_curr_wnd ); } ProcessMouseReleaseDrag( ev, GUI_MOUSEMOVE, row, col ); return( true ); break; case EV_MOUSE_PRESS_R : ProcessMousePress( ev, GUI_RBUTTONDOWN, row, col, new_curr_wnd ); return( true ); break; case EV_MOUSE_PRESS : ProcessMousePress( ev, GUI_LBUTTONDOWN, row, col, new_curr_wnd ); return( true ); break; case EV_MOUSE_DCLICK : ProcessMousePress( ev, GUI_LBUTTONDBLCLK, row, col, new_curr_wnd ); return( true ); break; case EV_NO_EVENT : gui_ev = GUI_NO_EVENT; break; case EV_SCROLL_UP : case EV_SCROLL_DOWN : case EV_SCROLL_PAGE_UP : case EV_SCROLL_PAGE_DOWN : case EV_SCROLL_LEFT : case EV_SCROLL_RIGHT : case EV_SCROLL_LEFT_PAGE : case EV_SCROLL_RIGHT_PAGE : if( GUICurrWnd != NULL ) { ProcessScrollEvent( ev ); return( true ); } break; case EV_SCROLL_VERTICAL : if( GUI_VSCROLL_EVENTS_SET( GUICurrWnd ) ) { DoScrollDrag( GUICurrWnd->vgadget, prev, diff ); } else { GUIWholeWndDirty( GUICurrWnd ); } return( true ); break; case EV_SCROLL_HORIZONTAL : if( GUI_HSCROLL_EVENTS_SET( GUICurrWnd ) ) { DoScrollDrag( GUICurrWnd->hgadget, prev, diff ); } else { GUIWholeWndDirty( GUICurrWnd ); } return( true ); break; case EV_MENU_INITPOPUP : ProcessInitPopupEvent(); return( true ); break; #if 0 case EV_BACKGROUND_RESIZE : { gui_window *root; root = GUIGetRootWindow(); if( root != NULL ) { GUIZoomWnd( root, GUI_NONE ); } } return( true ); break; #endif default : if( IS_CTLEVENT( ev ) ) { if( !GUIMDIProcessEvent( ev ) ) { menu_window = GUIGetMenuWindow(); if( menu_window != NULL ) { id = EV2ID( ev ); GUIEVENTWND( menu_window, GUI_CLICKED, &id ); } } return( true ); } break; } if( ( GUICurrWnd != NULL ) && (gui_ev != GUI_NO_EVENT ) ) { GUIEVENTWND( GUICurrWnd, gui_ev, NULL ); } return( true ); }