int main() { GOC_MSG wiesc; GOC_HANDLER napis; int i, w, h; char left[11] = "- Left A -"; char right[11] = "- Right A-"; char *napisStr = NULL; w = goc_screenGetWidth(); h = goc_screenGetHeight(); napisStr = malloc(w + 1); memset(napisStr, '-', w); napisStr[w] = 0; for (i=10; i<=w; i+=10) napisStr[i-1] = ((i/10)%10) + '0'; napis = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 4, w, 1, GOC_EFLAGA_PAINTED | GOC_EFLAGA_CENTER, GOC_GREEN, GOC_HANDLER_SYSTEM ); goc_labelAddLine(napis, napisStr); napis = goc_elementCreate(GOC_ELEMENT_LABEL, 1, -3, w, 1, GOC_EFLAGA_PAINTED | GOC_EFLAGA_CENTER, GOC_GREEN, GOC_HANDLER_SYSTEM ); goc_labelAddLine(napis, napisStr); free(napisStr); h -= 10; for (i=0; i<h; i++) { napis = goc_elementCreate(GOC_ELEMENT_LABEL, 1 + i*5, 6 + i, 10, 1, GOC_EFLAGA_PAINTED | GOC_EFLAGA_CENTER, GOC_RED, GOC_HANDLER_SYSTEM ); goc_labelAddLine(napis, left); napis = goc_elementCreate(GOC_ELEMENT_LABEL, 0 - i*5, 6 + i, 10, 1, GOC_EFLAGA_PAINTED | GOC_EFLAGA_CENTER, GOC_CYAN, GOC_HANDLER_SYSTEM ); goc_labelAddLine(napis, right); left[7]++; right[8]++; if ( 11 + i*5 > w ) break; } while (goc_systemCheckMsg( &wiesc )); return 0; }
int goc_labelSetText(GOC_HANDLER u, char *tekst, GOC_BOOL licz) { GOC_StLabel *napis = (GOC_StLabel*)u; goc_labelRemLines(u); goc_labelAddLine(u, tekst); if ( licz == GOC_TRUE ) goc_elementSetWidth(u, strlen(tekst)); else if ( napis->flag & GOC_EFLAGA_SHOWN ) goc_systemSendMsg(u, GOC_MSG_PAINT, 0, 0); return GOC_ERR_OK; }
static int nasluchOk( GOC_HANDLER uchwyt, GOC_MSG wiesc, void *pBuf, unsigned int nBuf) { if ( wiesc == GOC_MSG_ACTION ) { goc_labelRemLines( napis ); goc_labelAddLine( napis, "Formularz wype³niono" ); goc_formHide( forma ); return GOC_ERR_OK; } return goc_systemDefaultAction(uchwyt, wiesc, pBuf, nBuf); }
int main() { GOC_MSG wiesc; GOC_HANDLER napis; napis = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 1, 0, 1, GOC_EFLAGA_PAINTED | GOC_EFLAGA_ENABLE, GOC_WHITE, GOC_HANDLER_SYSTEM ); goc_labelAddLine(napis, "Ruchomy napis"); goc_elementSetFunc( napis, GOC_FUNID_LISTENER, &nasluch ); goc_elementSetFunc( napis, GOC_FUNID_LABELDRAWER, &labelMoveDrawer ); goc_systemSetTimer( napis, "RuchNapis" ); while (goc_systemCheckMsg( &wiesc )); return 0; }
int main() { GOC_MSG wiesc; GOC_HANDLER przycisk; przycisk = goc_elementCreate( GOC_ELEMENT_BUTTON, 10, 12, 15, 1, GOC_EFLAGA_PAINTED | GOC_EFLAGA_ENABLE | GOC_EFLAGA_CENTER, GOC_WHITE | GOC_FBOLD, GOC_HANDLER_SYSTEM ); goc_buttonSetText( przycisk, "Formularz" ); goc_elementSetFunc( przycisk, GOC_FUNID_LISTENER, nasluchForm ); napis = goc_elementCreate( GOC_ELEMENT_LABEL, 10, 4, 32, 1, GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM ); goc_labelAddLine( napis, "Formularz nie zosta³ wype³niony" ); forma = goc_elementCreate( GOC_ELEMENT_FORM, 10, 2, 24, 10, 0, GOC_WHITE, GOC_HANDLER_SYSTEM ); goc_elementCreate( GOC_ELEMENT_FRAME, 1, 1, 24, 10, GOC_EFLAGA_PAINTED, GOC_WHITE | GOC_FBOLD, forma ); przycisk = goc_elementCreate( GOC_ELEMENT_BUTTON, 3, 7, 10, 1, GOC_EFLAGA_PAINTED | GOC_EFLAGA_ENABLE | GOC_EFLAGA_CENTER, GOC_WHITE | GOC_FBOLD, forma ); goc_buttonSetText( przycisk, "Ok" ); goc_elementSetFunc( przycisk, GOC_FUNID_LISTENER, nasluchOk ); przycisk = goc_elementCreate( GOC_ELEMENT_BUTTON, 13, 7, 10, 1, GOC_EFLAGA_PAINTED | GOC_EFLAGA_ENABLE | GOC_EFLAGA_CENTER, GOC_WHITE | GOC_FBOLD, forma ); goc_buttonSetText( przycisk, "Cancel" ); goc_elementSetFunc( przycisk, GOC_FUNID_LISTENER, nasluchCancel ); while (goc_systemCheckMsg( &wiesc )); return 0; }
static int mapaCommonListener(GOC_HANDLER uchwyt, GOC_StMessage *msg) { if ( msg->id == GOC_MSG_CURSORCHANGE_ID ) { GOC_StMsgMapPoint* msgp = (GOC_StMsgMapPoint*)msg; char buf[80]; GOC_StValuePoint *v; int p; StAirport* airport = NULL; goc_labelRemLines(labelDesc); p = goc_maparawGetPoint(terrain, msgp->x, msgp->y); memset(buf, 0, 80); switch ( p ) { case 0: sprintf(buf, "Terrain: forrest" ); break; case 1: sprintf(buf, "Terrain: clear" ); break; case 2: sprintf(buf, "Terrain: river" ); break; case 3: sprintf(buf, "Terrain: mountains" ); break; default: sprintf(buf, "Terrain: unknown" ); break; } goc_labelAddLine(labelDesc, buf); v = goc_mapaposReadPoint(build, msgp->x, msgp->y); memset(buf, 0, 80); if ( v != NULL ) { switch ( v-> value & 0x0F ) { case 0x00: sprintf(buf, ""); break; case 0x01: sprintf(buf, "Build: Supply"); break; case 0x02: sprintf(buf, "Build: Factory"); break; case 0x03: sprintf(buf, "Build: City"); break; case 0x04: sprintf(buf, "Build: Airport"); airport = (StAirport*)FROMGOC(v); break; case 0x05: sprintf(buf, "Build: Village"); break; case 0x06: sprintf(buf, "Build: Fort"); break; case 0x07: sprintf(buf, "Build: Capital"); break; case 0x08: case 0x09: sprintf(buf, "Build: Bridge"); break; default: sprintf(buf, "Build: unknown" ); break; } } if ( strlen(buf) ) goc_labelAddLine(labelDesc, buf); if ( airport ) { int i; for (i=0; i<airport->nfly; i++) { sprintf(buf, " %-20s [%1s:%1d]", airport->pfly[i]->pilotName, airport->pfly[i]->cname == cn_Fighter ? "F" : "B", airport->pfly[i]->pilotExp/10); goc_labelAddLine(labelDesc, buf); } } memset(buf, 0, 80); if ( v != NULL ) { switch ( v->value & 0xF0 ) { case 0x00: break; case 0x10: sprintf(buf, "Front: green power" ); break; case 0x20: sprintf(buf, "Front: red power" ); break; case 0x30: sprintf(buf, "Front: none power" ); break; default: sprintf(buf, "Front: unknown" ); break; } } if ( strlen( buf ) ) goc_labelAddLine(labelDesc, buf); goc_systemClearArea(labelDesc); GOC_MSG_PAINT( msgPaint ); goc_systemSendMsg(labelDesc, msgPaint); return GOC_ERR_OK; } return goc_systemDefaultAction(uchwyt, msg); }
int controlInit(int (*fun)(unsigned int, void*)) { if ( fun == NULL ) { fprintf(stderr, "Nie podano funkcji kontrolnej.\n%s:%d\n", __FILE__, __LINE__); exit(1); } doAction = fun; // zainicjowanie systemu okienkoc goc_systemSetListenerFunc( &nasluch ); goc_hkAdd(GOC_HANDLER_SYSTEM, 'n', GOC_EFLAGA_ENABLE, hotKeyNext); goc_hkAdd(GOC_HANDLER_SYSTEM, 'N', GOC_EFLAGA_ENABLE, hotKeyNext); goc_hkAdd(GOC_HANDLER_SYSTEM, 'b', GOC_EFLAGA_ENABLE, hotKeyPrev); goc_hkAdd(GOC_HANDLER_SYSTEM, 'B', GOC_EFLAGA_ENABLE, hotKeyPrev); goc_hkAdd(GOC_HANDLER_SYSTEM, 'i', GOC_EFLAGA_ENABLE, hotKeyInfo); goc_hkAdd(GOC_HANDLER_SYSTEM, 'I', GOC_EFLAGA_ENABLE, hotKeyInfo); goc_hkAdd(GOC_HANDLER_SYSTEM, 'p', GOC_EFLAGA_ENABLE, hotKeyPause); goc_hkAdd(GOC_HANDLER_SYSTEM, 'P', GOC_EFLAGA_ENABLE, hotKeyPause); goc_hkAdd(GOC_HANDLER_SYSTEM, 'h', GOC_EFLAGA_ENABLE, hotKeyHelp); goc_hkAdd(GOC_HANDLER_SYSTEM, 'H', GOC_EFLAGA_ENABLE, hotKeyHelp); goc_hkAdd(GOC_HANDLER_SYSTEM, '?', GOC_EFLAGA_ENABLE, hotKeyHelp); goc_hkAdd(GOC_HANDLER_SYSTEM, 'q', GOC_EFLAGA_ENABLE, hotKeyQuit); goc_hkAdd(GOC_HANDLER_SYSTEM, 'Q', GOC_EFLAGA_ENABLE, hotKeyQuit); goc_hkAdd(GOC_HANDLER_SYSTEM, 's', GOC_EFLAGA_ENABLE, hotKeyStop); goc_hkAdd(GOC_HANDLER_SYSTEM, 'S', GOC_EFLAGA_ENABLE, hotKeyStop); goc_hkAdd(GOC_HANDLER_SYSTEM, 0x114, GOC_EFLAGA_ENABLE, hotKeyHome); goc_hkAdd(GOC_HANDLER_SYSTEM, 0x120, GOC_EFLAGA_ENABLE, hotKeyAumixPlus); goc_hkAdd(GOC_HANDLER_SYSTEM, 0x11f, GOC_EFLAGA_ENABLE, hotKeyAumixMinus); goc_hkAdd(GOC_HANDLER_SYSTEM, '+', GOC_EFLAGA_ENABLE, hotKeyAumixPlus); goc_hkAdd(GOC_HANDLER_SYSTEM, '-', GOC_EFLAGA_ENABLE, hotKeyAumixMinus); goc_hkAdd(GOC_HANDLER_SYSTEM, '*', GOC_EFLAGA_ENABLE, hotKeyAumixNext); goc_hkAdd(GOC_HANDLER_SYSTEM, 'r', GOC_EFLAGA_ENABLE, hotKeyShuffleOn); goc_hkAdd(GOC_HANDLER_SYSTEM, 'R', GOC_EFLAGA_ENABLE, hotKeyShuffleOff); goc_hkAdd(GOC_HANDLER_SYSTEM, 'l', GOC_EFLAGA_ENABLE, hotKeyShowList); goc_hkAdd(GOC_HANDLER_SYSTEM, 'L', GOC_EFLAGA_ENABLE, hotKeyShowList); goc_hkAdd(GOC_HANDLER_SYSTEM, 'a', GOC_EFLAGA_ENABLE, hotKeyAddFolder); goc_hkAdd(GOC_HANDLER_SYSTEM, 'A', GOC_EFLAGA_ENABLE, hotKeyAddFolder); goc_hkAdd(GOC_HANDLER_SYSTEM, 'x', GOC_EFLAGA_ENABLE, hotKeyQueue); goc_hkAdd(GOC_HANDLER_SYSTEM, 'X', GOC_EFLAGA_ENABLE, hotKeyQueue); nTytul = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 1, 0, 1, GOC_EFLAGA_PAINTED | GOC_EFLAGA_CENTER, GOC_WHITE, GOC_HANDLER_SYSTEM); goc_labelSetText(nTytul, "Rojkowy kontroler muzyki. Wersja 0.2 :+)",GOC_FALSE); nMixer = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 8, 8, 1, GOC_EFLAGA_PAINTED | GOC_EFLAGA_LEFT, GOC_WHITE, GOC_HANDLER_SYSTEM); pMixer = goc_elementCreate(GOC_ELEMENT_PRECENT, 9, 8, 0, 1, GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM); goc_precentSetMin(pMixer, 0); goc_precentSetMax(pMixer, 100); nPlik = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 3, 0, 2, GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM); nTitle = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 5, 0, 1, GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM); nArtist = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 6, goc_screenGetWidth()>>1, 1, GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM); nAlbum = goc_elementCreate(GOC_ELEMENT_LABEL, (goc_screenGetWidth()>>1) + 1, 6, 0, 1, GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM); nComment = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 7, goc_screenGetWidth()>>1, 1, GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM); nStatus = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 0, 0, 1, GOC_EFLAGA_PAINTED, GOC_GREEN, GOC_HANDLER_SYSTEM); nYear = goc_elementCreate(GOC_ELEMENT_LABEL, (goc_screenGetWidth()>>1) + 1, 7, 20, 1, GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM); lLista = goc_elementCreate(GOC_ELEMENT_SELLIST, 1, 10, 0, -1, 0, GOC_WHITE, GOC_HANDLER_SYSTEM); pLista = goc_elementCreate(GOC_ELEMENT_FILELIST, 1, 10, 0, -1, 0, GOC_WHITE, GOC_HANDLER_SYSTEM); if ( goc_isFileExists(LOGO_FILE) ) { char *line = NULL; nLogo = goc_elementCreate(GOC_ELEMENT_LABEL, -20, -10, 20, 8, GOC_EFLAGA_PAINTED | GOC_EFLAGA_CENTER, GOC_CYAN, GOC_HANDLER_SYSTEM); GOC_IStream* streamLogo = goc_fileIStreamOpen(LOGO_FILE); while ( (line = goc_isReadLine( streamLogo )) ) { goc_labelAddLine(nLogo, line); line = goc_stringFree( line ); } goc_isClose( streamLogo ); } goc_filelistSetFolder(pLista, "."); goc_hkAdd(pLista, ' ', GOC_EFLAGA_ENABLE, hotKeySelectFolder); goc_elementSetFunc(lLista, GOC_FUNID_LISTENER, nasluch); printMixer(); return 0; }