예제 #1
0
파일: screen.cpp 프로젝트: Jaxo/yaxx
/*--------------------------------------------------------------------display-+
|                                                                             |
+----------------------------------------------------------------------------*/
void display(char const * text, int len)
{
   FormPtr frm = FrmGetActiveForm();
   FieldPtr field = (FieldPtr)FrmGetObjectPtr(
      frm,
      FrmGetObjectIndex(frm, MainConsoleField)
   );
   FldInsert(field, text, len);
   updateScroll();
   FldDrawField(field);
}
예제 #2
0
파일: URLForm.c 프로젝트: openmobl/Atlas
static void URLFormInit(FormType *frmP)
{
    GlobalsPtr gP = GetGlobals();
    
    if (gP->navigationOpen) {
        FieldPtr urlFldP = GetObjectPtr(kURLField);
        
        // TODO: Get current page's URL instead!
        FldInsert(urlFldP, gP->navigationOpen, StrLen(gP->navigationOpen));
        FldSetSelection(urlFldP, 0, StrLen(gP->navigationOpen));
    }
    FrmSetFocus(frmP, FrmGetObjectIndex(frmP, kURLField));
}
예제 #3
0
static Boolean ResidentBrowseFormWinEnter(AppContext* appContext, FormType* form, EventType* event)
{
    struct _WinEnterEventType* winEnter=(struct _WinEnterEventType*)&event->data;
    if (winEnter->enterWindow==(void*)form) // this means we're entering this window for the first time and we have to do initial list drawing
    {
        FieldType* field=NULL;
        ListType* list=NULL;
        UInt16 index=FrmGetObjectIndex(form, fieldWord);
        Assert(index!=frmInvalidObjectId);
        field=(FieldType*)FrmGetObjectPtr(form, index);
        index=FrmGetObjectIndex(form, listMatching);
        Assert(index!=frmInvalidObjectId);
        list=(ListType*)FrmGetObjectPtr(form, index);
        appContext->prevSelectedWord = 0xffffffff;
        LstSetListChoicesEx(list, NULL, dictGetWordsCount(GetCurrentFile(appContext)));
        LstSetDrawFunction(list, ListDrawFunc);
        appContext->prevTopItem = 0;
        Assert(appContext->selectedWord < appContext->wordsCount);
        if (*appContext->lastWord)
        {
            appContext->selectedWord = 0;
            FldInsert(field, appContext->lastWord, StrLen(appContext->lastWord));
            FldSendChangeNotification(field);
        }
        else
        {
            if (-1==appContext->currentWord)
                appContext->selectedWord=0;
            else
                appContext->selectedWord=appContext->currentWord;             
            LstSetSelectionEx(appContext, list, appContext->selectedWord);
        }            
        index=FrmGetObjectIndex(form, fieldWord);
        Assert(index!=frmInvalidObjectId);
        FrmSetFocus(form, index);
        FrmUpdateForm(formResidentBrowse, frmRedrawUpdateCode);
    }
    return false;
}
예제 #4
0
파일: EventLib.c 프로젝트: ycheng/APDA
////////////////////////////////////////////////////////////////////////
// FUNCTION:    SysHandleEvent
//
// DESCRIPTION: This routine return the next available event.
//
// PARAMETERS:  (EventType *) event - Pointer to the structure to hold
//											the event returned.
//
// RETURNED:    Returns nothing
//
// REVISION HISTORY:
//			Name	Date		Description
//			----	----		-----------
//			Jerry	2/14/01	Initial Revision
//			Jerry	7/04/01	Add push button control handler
//			Jerry 8/03/01	Add popSelectEvent
//			Jerry 8/07/01	Modify popSelectEvent to get the correct List
//			Jerry 8/08/01	Complete event->data.popSelect event
//			Jerry	8/09/01	Add frmListObj option
//			Jerry	8/28/01	Processing frmCloseEvent, blinking field cursor
//			Jerry	9/03/01	Clear control before redraw it
//			Jerry	9/12/01	Fixed push button showing problem
//			Jerry	9/13/01	Put the string on the center of control
////////////////////////////////////////////////////////////////////////
Boolean SysHandleEvent(EventType *event)
{
	if ( MenuActive || (!ActiveForm) || (ActiveObjIndex == -1) )
		return	0;

	// if current active control is fieldtype, draw cursor if editable
	if ( (ActiveForm->objects[ActiveObjIndex].objectType == frmFieldObj) &&
			(ActiveForm->objects[ActiveObjIndex].object.field->attr.editable) ) {
		VDrawCursor ( (Coord)(ActiveForm->objects[ActiveObjIndex].object.field->insPtXPos),
						  (Coord)(ActiveForm->objects[ActiveObjIndex].object.field->insPtYPos+2),
						  CUR_DRAW);
		VDrawGrafState (TRUE);
	} else {
		VDrawGrafState (FALSE);
	}

	// close current form, free all allocate memory on this form.
	if ( event->eType == ctlSelectEvent ) {
		if ( (ActiveForm->objects[ActiveObjIndex].objectType == frmControlObj) ) {
			if (ActiveForm->objects[ActiveObjIndex].object.control->style == checkboxCtl) {
				// CHECKBOX Style[0] is used for checked message
				ControlType *ctlP = ActiveForm->objects[ActiveObjIndex].object.control;

//				VSetCheckBox (ctlP, ctlP->attr.on);
				ctlP->attr.on = ~ctlP->attr.on;

				VRedrawControl (ActiveForm->objects[ActiveObjIndex]);
			} else if (ActiveForm->objects[ActiveObjIndex].object.control->style == pushButtonCtl) {
				// Press on push button, invert the push button
				ControlType *ctlP = ActiveForm->objects[ActiveObjIndex].object.control;
				RectangleType	rect;
				int			strWidth;

				if ( !ctlP->attr.on ) {
					int	i;

					rect.topLeft.x = (ctlP->bounds.topLeft.x+1);
					rect.topLeft.y = (ctlP->bounds.topLeft.y+1);
					// get the width of string
					strWidth = FntCharsWidth (ctlP->text, (Int16)Vstrlen(ctlP->text));

					if ( ctlP->bounds.extent.x == -1 ) {
						rect.extent.x = (UInt16)strWidth+2;
					} else {
						rect.extent.x = (ctlP->bounds.extent.x-3);
					}
					if ( ctlP->bounds.extent.y == -1 ) {
						rect.extent.y = FntCharHeight()-3;
					} else {
						rect.extent.y = (ctlP->bounds.extent.y-4);
					}

					VDrawRect (&rect, PS_SOLID, 0, CL_FOREGROUND, COORD_STRETCH, DRAW_XOR);
/*
					VDrawRect (&rect, PS_SOLID, 0, CL_FOREGROUND, COORD_STRETCH, DRAW_SET);

					// calculate string width (put the string on the center of control)
					VDrawString ((Coord)(ctlP->bounds.topLeft.x+((ctlP->bounds.extent.x-strWidth)/2)), 
									(ctlP->bounds.topLeft.y), 
									ctlP->text, 
									Vstrlen(ctlP->text), 
									SINGLELINE, CL_BACKGROUND, COORD_STRETCH);
*/
					ctlP->attr.on = 1;
	
					for ( i = 0; i < ActiveForm->numObjects; i++ ) {
						// if other same group push button is on, off it
						if ( (i != ActiveObjIndex) &&
							  (ActiveForm->objects[i].objectType == frmControlObj) &&
							  (ActiveForm->objects[i].object.control->style == pushButtonCtl) &&
							  (ActiveForm->objects[i].object.control->attr.on) ) {
							ctlP = ActiveForm->objects[i].object.control;
							rect.topLeft.x = (ctlP->bounds.topLeft.x+1);
							rect.topLeft.y = (ctlP->bounds.topLeft.y+1);
							// get the width of string
							strWidth = FntCharsWidth (ctlP->text, (Int16)Vstrlen(ctlP->text));
							if ( ctlP->bounds.extent.x == -1 ) {
								rect.extent.x = strWidth+2;
							} else {
								rect.extent.x = (ctlP->bounds.extent.x-3);
							}
							if ( ctlP->bounds.extent.y == -1 ) {
								rect.extent.y = FntCharHeight()-3;
							} else {
								rect.extent.y = (ctlP->bounds.extent.y-4);
							}
	
							VDrawRect (&rect, PS_SOLID, 0, CL_FOREGROUND, COORD_STRETCH, DRAW_XOR);
/*
							VDrawRect (&rect, PS_SOLID, 0, CL_FOREGROUND, COORD_STRETCH, DRAW_SET);

							VDrawString ((Coord)(ctlP->bounds.topLeft.x+((ctlP->bounds.extent.x-strWidth)/2)), 
											(ctlP->bounds.topLeft.y), 
											ctlP->text, 
											Vstrlen(ctlP->text), 
											SINGLELINE, CL_FOREGROUND, COORD_STRETCH);
*/
							ctlP->attr.on = 0;
						}
					}
				}
			}
		} // end of	if ( (ActiveForm->objects[ActiveObjIndex].objectType == frmControlObj) ) {
/*
	} else if ( event->eType == popSelectEvent ) {
		Int16				theIndex, i, listObjIndex = -1;
		UInt16			hitObjIndex = ActiveObjIndex;
		UInt16			popupID = ActiveForm->objects[ActiveObjIndex].object.control->id;
		UInt16			listID=0;

		event->data.popSelect.controlP = (ControlType *)ActiveForm->objects[ActiveObjIndex].object.control;
		for ( i = 0; i < ActiveForm->numObjects; i++ ) {
			if ( (ActiveForm->objects[i].objectType == frmPopupObj) && 
					(popupID == ActiveForm->objects[i].object.popup->controlID) ) {
				listID = ActiveForm->objects[i].object.popup->listID;
				break;
			}
		}

		if ( listID ) {
			event->data.popSelect.listID = listID;
			for ( i = 0; i < ActiveForm->numObjects; i++ ) {
				if ( (ActiveForm->objects[i].objectType == frmListObj) && 
						(listID == ActiveForm->objects[i].object.list->id) ) {
					listObjIndex = i;
					event->data.popSelect.listP = ActiveForm->objects[ActiveObjIndex].object.list;
					break;
				}
			}

			if ( listObjIndex >= 0 ) {
				ListType *listP = (ListType *)ActiveForm->objects[listObjIndex].object.list;

				event->data.popSelect.priorSelection = LstGetSelection (listP);
				theIndex = LstPopupList(listP);

				if (theIndex >= 0) {
					RectangleType	rect;
					ControlType *controlP;
					int		strWidth;
						
					event->data.popSelect.selection = theIndex;
					ActiveObjIndex = hitObjIndex;
					controlP = (ControlType *)ActiveForm->objects[ActiveObjIndex].object.control;

					// clear the control first
					Vmemcpy (&rect, &(controlP->bounds), sizeof(RectangleType));

					strWidth = FntCharsWidth (controlP->text, (Int16)Vstrlen(controlP->text));
					// recalculate size if attribute is AUTO
					if ( controlP->bounds.extent.x == -1 ) {
						rect.extent.x = strWidth;
						if ( controlP->style == popupTriggerCtl ) 
							rect.extent.x += ArrowWidth;
					}
					if ( controlP->bounds.extent.y == -1 ) {
						rect.extent.y = FntCharHeight();
					}
					VDrawRect (&rect, PS_SOLID, 0, CL_BACKGROUND, COORD_STRETCH, DRAW_SET);

					// draw control
					CtlSetLabel (ActiveForm->objects[ActiveObjIndex].object.control, 
						LstGetSelectionText(listP,theIndex));
				}
			}
		}
*/
	} else if ( event->eType == keyDownEvent ) {
		// CHECKBOX Style[0] is used for checked message
		FormObjListType	object = ActiveForm->objects[ActiveObjIndex];
		switch (object.objectType) {
			case frmTableObj:
				{
					TableType	*tableP = object.object.table;
					UInt16	index = tableP->currentRow*tableP->numColumns+tableP->currentColumn;

					if ( !tableP->attr.editable )
						return	false;

					if ( tableP->items[index].ptr == NULL ) {
						tableP->items[index].ptr = (char *) Vmalloc(1);
						tableP->items[index].ptr[0] = 0;
					}
					tableP->items[index].ptr = 
						(char *) Vrealloc(tableP->items[index].ptr, Vstrlen(tableP->items[index].ptr)+2);
					VAppendStr (tableP->items[index].ptr, (UInt16)event->data.keyDown.keyCode);
					VRedrawControl (object);
				}
				break;
			case frmFieldObj:
				{
					FieldType *fldP = object.object.field;

					if ( !fldP->attr.editable )
						return	false;

					FldInsert (fldP, (char*)&(event->data.keyDown.chr), 1);
//					VRedrawControl (object);
					break;
				}
			default :
				{
/*
					ControlType *ctlP = object.object.control;

					if ( !ctlP->attr.enabled )
						return	false;

					if ( ctlP->text == NULL ) {
						ctlP->text = (char *) Vmalloc(1);
						ctlP->text[0] = 0;
					}
					ctlP->text = (char *) Vrealloc(ctlP->text, Vstrlen(ctlP->text)+2);
					VAppendStr (ctlP->text, (UInt16)event->data.keyDown.keyCode);
					VRedrawControl (object);
*/
					break;
				}
		}
	}

	return	0;
}
예제 #5
0
파일: URLForm.c 프로젝트: openmobl/Atlas
static Boolean URLFormDoCommand(UInt16 command)
{
    GlobalsPtr  gP = GetGlobals();
    Boolean     handled = false;

    if (!gP)
        return false;

    switch (command) {
        // Menus
        // Control Objects
        case kURLOpenButton:
            {
                Char    *navigationText = FldGetTextPtr(GetObjectPtr(kURLField));
                Boolean openInNewTab = false;
                
                if (navigationText && StrLen(navigationText)) {
                    if (gP->navigationOpen) {
                        MemPtrFree(gP->navigationOpen);
                    }
                    gP->navigationOpen = StrDup(navigationText);
                    
                    if (CtlGetValue(GetObjectPtr(kURLOpenInNewTabCheckbox))) {
                        openInNewTab = true;
                    }
                    
                    FrmReturnToForm(0);
                    if (openInNewTab) {
                        FrmUpdateForm(kMainForm, frmUpdateNewTab);
                    }
                    FrmUpdateForm(kMainForm, URLFormDetermineRequestType(navigationText));
                }
            }
            break;
        case kURLCancelButton:
            FrmReturnToForm(0);
            break;
        // Handle inserting text using the insert buttons, or list.
        case kWWWPushButton:
        case kCOMPushButton:
        case kORGPushButton:
        case kNETPushButton:
        case kSlashPushButton:
        case kDotPushButton:
        case kHTMLPushButton:
            {
                FieldPtr    urlFldP         = GetObjectPtr(kURLField);
                const Char  *buttonLabelP   = CtlGetLabel(GetObjectPtr(command));
                
                FldInsert(urlFldP, buttonLabelP, StrLen(buttonLabelP));
                CtlSetValue(GetObjectPtr(command), 0);
                
                handled = true;
            }
            break;
        case kMoreTrigger:
            {
                ListPtr     moreListP   = GetObjectPtr(kMoreList);
                FieldPtr    urlFldP     = GetObjectPtr(kURLField);
                Int16       selection   = LstPopupList(moreListP);
                
                if (selection >= 0) {
                    const Char  *selectionP = LstGetSelectionText(moreListP, selection);
                
                    FldInsert(urlFldP, selectionP, StrLen(selectionP));
                }
                handled = true;
            }
            break;
        // Default
        default:
            break;
    }

    return handled;
}