void ofxUIImageButton::init(float x, float y, float w, float h, bool *_value, string _pathURL, string _name, int _size) { initRect(0,0,w,h); name = string(_name); kind = OFX_UI_WIDGET_IMAGEBUTTON; label = new ofxUILabel(w+padding,0, (name+" LABEL"), name, _size); addEmbeddedWidget(label); setLabelVisible(false); if(useReference) { value = _value; } else { value = new bool(); *value = *_value; } setValue(*_value); img = new ofImage(_pathURL); bChangedImage = false; }
void SplashInitFrameShape(Splash * splash, int imageIndex) { ImageRect maskRect; XRectangle *rects; SplashImage *frame = splash->frames + imageIndex; frame->rects = NULL; frame->numRects = 0; if (!splash->maskRequired) return; if (!shapeSupported) return; initRect(&maskRect, 0, 0, splash->width, splash->height, 1, splash->width * splash->imageFormat.depthBytes, splash->frames[imageIndex].bitmapBits, &splash->imageFormat); if (!IS_SAFE_SIZE_MUL(splash->width / 2 + 1, splash->height)) { return; } rects = SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(XRectangle), (splash->width / 2 + 1) * splash->height); if (!rects) { return; } frame->numRects = BitmapToYXBandedRectangles(&maskRect, rects); frame->rects = SAFE_SIZE_ARRAY_ALLOC(malloc, frame->numRects, sizeof(XRectangle)); if (frame->rects) { // handle the error after the if(){} memcpy(frame->rects, rects, frame->numRects * sizeof(XRectangle)); } free(rects); }
void ofxUIEnvelopeEditor::init(string _name, ofxUIEnvelope *_envelope, float w, float h, float x, float y) { initRect(x, y, w, h); name = string(_name); kind = OFX_UI_WIDGET_ENVELOPEEDITOR; draw_fill = true; draw_outline = true; if(useReference) { envelope = _envelope; } else { envelope = new ofxUIEnvelope(); } labelPrecision = 2; label = new ofxUILabel(0,h+padding*2.0,(name+" LABEL"), (name + ":"), OFX_UI_FONT_SMALL); addEmbeddedWidget(label); hitThreshold = 0.05; pointNodeRadius = OFX_UI_GLOBAL_PADDING*1.5; pointNodeRectWidth = OFX_UI_GLOBAL_PADDING*2.5; pointNodeRectHeight = OFX_UI_GLOBAL_PADDING*2.5; bHitPoint = false; bHitCurve = false; hitPoint = NULL; hitCurve = NULL; hitCurveNext = NULL; }
void ofxUITextArea::init(string _name, string _textstring, float w, float h, float x, float y, int _size) { initRect(x,y,w,h); setName(_name); setKind(OFX_UI_WIDGET_TEXTAREA); textstring = _textstring; setDrawFill(true); setDrawBack(false); drawShadow = false; drawLabel = false; label = new ofxUILabel(padding*2.0,0,(name+" LABEL"), _size); addEmbeddedWidget(label); label->setVisible(drawLabel); if(h == 0) { autoSize = true; } else { autoSize = false; } }
// set a pixel at position x, y int screenmatrix_setpixel(screenmatrix_t *screenmatrix, unsigned char x, unsigned char y, screenmatrix_color_t color) { //const int colorSendBufferSize = SCREENMATRIX_PIXEL_SIZE * SCREENMATRIX_PIXEL_SIZE; //static uint16_t colorSendBuffer[colorSendBufferSize]; if (screenmatrix_isLegalMove(x, y)) { // set the value in the matrix screenmatrix->matrix[x][y] = color; // write the corresponding stm color into the send buffer uint16_t stm32Color = screenmatrix_convertColor(color); /*int i; for (i = 0; i < colorSendBufferSize; i++) { colorSendBuffer[i] = stm32Color; }*/ // push the colors onto the LCD screen int startX = SCREENMATRIX_PIXEL_SIZE * x; int startY = SCREENMATRIX_PIXEL_SIZE * y; //ST7735_setAddrWindow(startX, startX + SCREENMATRIX_PIXEL_SIZE, startY, startY + SCREENMATRIX_PIXEL_SIZE, MADCTLGRAPHICS); //ST7735_pushColor(colorSendBuffer, colorSendBufferSize); rect_t r; initRect(&r, startX, startY, SCREENMATRIX_PIXEL_SIZE, SCREENMATRIX_PIXEL_SIZE, stm32Color); redrawRect(&r); return 1; } return 0; }
void OzUITextEditSetAllowMultiline(struct OzUITextEdit *textEdit, int allow) { if ((allow==0) ^ textEdit->allowMultiline) return; textEdit->allowMultiline = (allow!=0); if (allow) { tlc.flags = 0; initRect(&tlc.rect, 0, 0, textEdit->widget->rect.w - textEdit->fontSize/2, textEdit->widget->rect.h); } else { tlc.flags = OZUI_TEXT_ALIGN_VCENTER; initRect(&tlc.rect, 0, 0, 100000, textEdit->widget->rect.h); } textEditDoLayout(textEdit); OzUIWidgetInvalidateAll(textEdit->widget); }
// // Set selection rectangle position and size // void CChartViewer::drawRect(int x, int y, int width, int height) { // Create the edges of the rectangle if not already created if (m_TopLine.m_hWnd == 0) initRect(); // width < 0 is interpreted as the rectangle extends to the left or x. // height <0 is interpreted as the rectangle extends to above y. if (width < 0) x -= (width = -width); if (height < 0) y -= (height = -height); // Compute the position of the selection rectangle as relative to the parent window RECT rect; rect.left = x; rect.top = y; rect.right = x + width; rect.bottom = y + height; MapWindowPoints(GetParent(), &rect); // Put the edges along the sides of the rectangle m_TopLine.MoveWindow(rect.left, rect.top, rect.right - rect.left, m_selectBoxLineWidth); m_LeftLine.MoveWindow(rect.left, rect.top, m_selectBoxLineWidth, rect.bottom - rect.top); m_BottomLine.MoveWindow(rect.left, rect.bottom - m_selectBoxLineWidth + 1, rect.right - rect.left, m_selectBoxLineWidth); m_RightLine.MoveWindow(rect.right - m_selectBoxLineWidth + 1, rect.top, m_selectBoxLineWidth, rect.bottom - rect.top); }
Rect *newRect(int x, int y, int w, int h) { Rect *rect = (Rect *)malloc(sizeof(Rect)); initRect(rect, x, y, w, h); return rect; }
/* * Class: java_awt_SplashScreen * Method: _update * Signature: (J[IIIIII)V */ JNIEXPORT void JNICALL Java_java_awt_SplashScreen__1update(JNIEnv * env, jclass thisClass, jlong jsplash, jintArray data, jint x, jint y, jint width, jint height, jint stride) { Splash *splash = (Splash *) jlong_to_ptr(jsplash); int dataSize; if (!splash) { return; } SplashLock(splash); dataSize = (*env)->GetArrayLength(env, data); if (splash->overlayData) { free(splash->overlayData); } splash->overlayData = SAFE_SIZE_ARRAY_ALLOC(malloc, dataSize, sizeof(rgbquad_t)); if (splash->overlayData) { /* we need a copy anyway, so we'll be using GetIntArrayRegion */ (*env)->GetIntArrayRegion(env, data, 0, dataSize, (jint *) splash->overlayData); initFormat(&splash->overlayFormat, 0xFF0000, 0xFF00, 0xFF, 0xFF000000); initRect(&splash->overlayRect, x, y, width, height, 1, stride * sizeof(rgbquad_t), splash->overlayData, &splash->overlayFormat); SplashUpdate(splash); } SplashUnlock(splash); }
void OzUIWidgetInvalidateAll(struct OzUIWidget *widget) { struct Rect dirtyRect; initRect(&dirtyRect, 0, 0, widget->rect.w, widget->rect.h); OzUIWidgetInvalidate(widget, &dirtyRect); }
void ofxUISlider_<T>::init(string _name, T _min, T _max, T *_value, float w, float h, float x, float y) { initRect(x,y,w,h); name = string(_name); setOrientation(w, h); setKind(); draw_fill = true; value = *_value; //the widget's value if(useReference) { valueRef = _value; } else { valueRef = new T(); *valueRef = value; } max = _max; min = _min; labelPrecision = 2; if(value > max) { value = max; } if(value < min) { value = min; } value = ofxUIMap(value, min, max, 0.0, 1.0, true); valueString = ofxUIToString(getScaledValue(),labelPrecision); if(orientation == OFX_UI_ORIENTATION_HORIZONTAL) { label = new ofxUILabel(0,h+padding,string(name+" LABEL"), string(name + ": " + ofxUIToString(max,labelPrecision)), OFX_UI_FONT_SMALL); } else { label = new ofxUILabel(0,h+padding,string(name+" LABEL"), string(name), OFX_UI_FONT_SMALL); } addEmbeddedWidget(label); label->setVisible(drawLabel); increment = ABS(max - min) / 100.0; bRoundedToNearestInt = false; bClampValue = true; bSticky = false; stickyValue = MAX(10.0*ceil(increment), 1.0); warp = 1.0; setInternalValueFromValue(); }
void init(void) { mapState.border = createPanelBorder(X_BORD, Y_BORD, WIDTH_BORD); mapState.button_rect = initRect(); mapState.button_triangle = initTriangle(); mapState.button_line = initLine(); mapState.button_circle = initCircle(); mapState.points_storage = createLinkedList(); mapState.edges_storage = createLinkedList(); }
void ofxUILabel::init(float x, float y, float w, float h, string _name, string _label, int _size) { initRect(x,y,w,h); name = string(_name); kind = OFX_UI_WIDGET_LABEL; label = string(_label); size = _size; font = NULL; draw_back = OFX_UI_LABEL_DRAW_BACK; draw_fill = true; }
void initBox(Box *box, int x, int y, int s) { Rect *rect = (Rect*)box; initRect(rect, x, y, s, s); rect->getW = &getW; rect->getH = &getW; rect->setW = &setW; rect->setH = &setW; box->print = &printBox; }
// Mitchell Nordine - custom copy constructor for heap allocation handling. ofxUIWidget::ofxUIWidget(const ofxUIWidget &other) : parent(NULL), rect(NULL), paddedRect(NULL), //font(NULL), font(other.font), name(other.name), kind(other.kind), ID(other.ID), hit(other.hit), visible(other.visible), state(other.state), draw_back(other.draw_back), draw_outline(other.draw_outline), draw_outline_highlight(other.draw_outline_highlight), draw_fill(other.draw_fill), draw_fill_highlight(other.draw_fill_highlight), padding(other.padding), draw_padded_rect(other.draw_padded_rect), draw_padded_rect_outline(other.draw_padded_rect_outline), color_back(other.color_back), color_outline(other.color_outline), color_outline_highlight(other.color_outline_highlight), color_fill(other.color_fill), color_fill_highlight(other.color_fill_highlight), color_padded_rect(other.color_padded_rect), color_padded_rect_outline(other.color_padded_rect_outline), embedded(other.embedded), modal(other.modal), bKeyHit(other.bKeyHit), keyBindings(other.keyBindings), triggerType(OFX_UI_TRIGGER_ALL) { if (other.rect) { initRect(other.rect->getX(), other.rect->getY(), other.rect->getWidth(), other.rect->getHeight()); } else { initRect(); } }
void ofxUIBaseDraws::init(float x, float y, float w, float h, ofBaseDraws* _image, string _name) { initRect(x, y, w, h); name = _name; kind = OFX_UI_WIDGET_BASE_DRAWS; draw_back = false; draw_fill = true; image = _image; label = new ofxUILabel(0,h+padding*2.0,(name+" LABEL"),name, OFX_UI_FONT_SMALL); addEmbeddedWidget(label); }
struct OzUITextEdit *OzUICreateTextEdit(struct OzUIWindow *window, struct Rect *rect, struct OzUITextEditOperation *ops, void *userData) { struct OzUITextEdit *textEdit; textEdit = (struct OzUITextEdit*)malloc(sizeof(struct OzUITextEdit)); memset(textEdit, 0, sizeof(struct OzUITextEdit)); textEdit->widget = OzUICreateWidget(window, OZUI_WIDGET_TYPE_TEXT_EDIT, OZUI_WIDGET_FLAG_FOCUSABLE, rect, &textEditOps, textEdit); textEdit->fontSize = OZUI_TEXT_EDIT_DEFAULT_FONT_SIZE; textEdit->ops = ops; textEdit->d = userData; initRect(&tlc.rect, 0, 0, 100000, textEdit->widget->rect.h); OzUITextEditSetText(textEdit, L""); //OzUIWidgetInvalidateAll(textEdit->widget); return textEdit; }
void ofxUI2DGraph::init(string _name, ofPoint _rangeX, ofPoint _rangeY, float _bufferSize, float * _xValues, float * _yValues, float w, float h, float x, float y) { initRect(x, y, w, h); name = string(_name); kind = OFX_UI_WIDGET_2DGRAPH; draw_fill = true; bufferSize = _bufferSize; rangeX = _rangeX; rangeY = _rangeY; xValues = _xValues; yValues = _yValues; inc = MAX(rect->getHalfHeight(), rect->getHalfWidth())/6.0; }
// // Show/hide selection rectangle // void CChartViewer::setRectVisible(bool b) { // Create the edges of the rectangle if not already created if (b && (m_TopLine.m_hWnd == 0)) initRect(); // Show/hide the edges if (m_TopLine.m_hWnd != 0) { int state = b ? SW_SHOW : SW_HIDE; m_TopLine.ShowWindow(state); m_LeftLine.ShowWindow(state); m_BottomLine.ShowWindow(state); m_RightLine.ShowWindow(state); } }
/* Returns an initialized control */ control* initControl(enum control_type ctrl_type, int x, int y, int width, int height) { control* ctrl = NULL; ctrl = (control*) malloc(sizeof(control)); if (ctrl != NULL) { ctrl->ctrl_type = ctrl_type; ctrl->rect = initRect(x,y,width,height); ctrl->color = initColor(255,255,255); /* default color: white */ ctrl->print = TRUE; ctrl->freeControl = &freeControl; ctrl->surface = NULL; ctrl->next = NULL; ctrl->children = NULL; } else { printf("ERROR: standard function malloc has failed\n"); } return ctrl; }
struct OzUIWidget *OzUICreateWidget(struct OzUIWindow *window, int type, int flags, struct Rect *rect, struct OzUIWidgetOperation *ops, void *userData) { struct OzUIWidget *widget; widget = (struct OzUIWidget*)malloc(sizeof(struct OzUIWidget)); memset(widget, 0, sizeof(struct OzUIWidget)); widget->window = window; widget->type = type; widget->flags = flags; copyRect(&widget->rect, rect); translateRect(&widget->rect, widget->window->clientRect.x, widget->window->clientRect.y); initRect(&widget->dirtyRect, 0, 0, 0, 0); widget->ops = ops; widget->d = userData; listAdd(&widget->link, &window->widgetList); if (widget->ops && widget->ops->onCreate) widget->ops->onCreate(widget); return widget; }
void ofxUIValuePlotter::init(float x, float y, float w, float h, int _bufferSize, float _min, float _max, float *_value, string _name) { initRect(x,y,w,h); name = string(_name); kind = OFX_UI_WIDGET_VALUEPLOTTER; value = _value; //the widget's value draw_fill = true; bufferSize = _bufferSize; max = _max; min = _min; for(unsigned int i = 0; i < bufferSize; i++) { buffer.push_back(*value); } scale = rect->getHeight()*.5; inc = rect->getWidth()/((float)bufferSize-1.0); }
int ViewFilesDialog::OnCreate(LPCREATESTRUCT lpcs) { LOGD("VFD OnCreate"); HICON hIcon; hIcon = ::AfxGetApp()->LoadIcon(IDI_FILE_VIEWER); SetIcon(hIcon, TRUE); GetClientRect(&fLastWinSize); CRect initRect(fLastWinSize); initRect.left = initRect.right - ::GetSystemMetrics(SM_CXVSCROLL); initRect.top = initRect.bottom - ::GetSystemMetrics(SM_CYHSCROLL); fGripper.Create(WS_CHILD | WS_VISIBLE | SBS_SIZEBOX | SBS_SIZEBOXBOTTOMRIGHTALIGN | SBS_SIZEGRIP, initRect, this, AFX_IDW_SIZE_BOX); LOGD("VFD OnCreate done"); return 0; }
void ofxUIDropDownList::init(string _name, vector<string> items, float w, float x, float y, int _size) { initRect(x,y,w,0); autoSize = (w == 0) ? true : false; name = string(_name); kind = OFX_UI_WIDGET_DROPDOWNLIST; size = _size; label = new ofxUILabel(0,0,(name+" LABEL"), name, _size); addEmbeddedWidget(label); value = new bool(); *value = false; draw_fill = *value; bShowCurrentSelected = false; allowMultiple = false; addToggles(items); autoClose = false; singleSelected = NULL; }
void SplashInitFrameShape(Splash * splash, int imageIndex) { RGNDATA *pRgnData; RGNDATAHEADER *pRgnHdr; ImageRect maskRect; if (!splash->maskRequired) return; /* reserving memory for the worst case */ if (!IS_SAFE_SIZE_MUL(splash->width / 2 + 1, splash->height)) { return; } pRgnData = (RGNDATA *) SAFE_SIZE_STRUCT_ALLOC(malloc, sizeof(RGNDATAHEADER), sizeof(RECT), (splash->width / 2 + 1) * splash->height); if (!pRgnData) { return; } pRgnHdr = (RGNDATAHEADER *) pRgnData; initRect(&maskRect, 0, 0, splash->width, splash->height, 1, splash->width * splash->imageFormat.depthBytes, splash->frames[imageIndex].bitmapBits, &splash->imageFormat); pRgnHdr->dwSize = sizeof(RGNDATAHEADER); pRgnHdr->iType = RDH_RECTANGLES; pRgnHdr->nRgnSize = 0; pRgnHdr->rcBound.top = 0; pRgnHdr->rcBound.left = 0; pRgnHdr->rcBound.bottom = splash->height; pRgnHdr->rcBound.right = splash->width; pRgnHdr->nCount = BitmapToYXBandedRectangles(&maskRect, (RECT *) (((BYTE *) pRgnData) + sizeof(RGNDATAHEADER))); splash->frames[imageIndex].hRgn = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + sizeof(RECT) * pRgnHdr->nCount, pRgnData); free(pRgnData); }
void ofxUIRotarySlider::init(float x, float y, float w, float _min, float _max, float *_value, string _name, int _size) { initRect(x,y,w,w); name = string(_name); kind = OFX_UI_WIDGET_ROTARYSLIDER; draw_fill = true; value = *_value; //the widget's value if(useReference) { valueRef = _value; } else { valueRef = new float(); *valueRef = value; } max = _max; min = _min; if(value > max) { value = max; } if(value < min) { value = min; } outerRadius = rect->getWidth()*.5; innerRadius = rect->getWidth()*.25; value = ofxUIMap(value, min, max, 0.0, 1.0, true); valueString = ofxUIToString(getValue(),2); label = new ofxUILabel(0,w+padding,(name+" LABEL"), (name + ": " + valueString), _size); addEmbeddedWidget(label); increment = fabs(max - min) / 10.0; }
void ofxUITextInput::init(string _name, string _textstring, float w, float h, float x, float y, int _size) { initRect(x,y,w,h); name = string(_name); kind = OFX_UI_WIDGET_TEXTINPUT; textstring = string(_textstring); defaultstring = string(_textstring); displaystring = string(_textstring); clicked = false; //the widget's value autoclear = true; triggerOnClick = true; label = new ofxUILabel((name+" LABEL"), _size); addEmbeddedWidget(label); inputTriggerType = OFX_UI_TEXTINPUT_ON_FOCUS; cursorWidth = 0; spaceOffset = 0; theta = 0; autoUnfocus = true; cursorPosition = 0; firstVisibleCharacterIndex = 0; }
void ofxUIButton::init(string _name, bool *_value, float w, float h, float x, float y, int _size) { initRect(x,y,w,h); name = string(_name); kind = OFX_UI_WIDGET_BUTTON; label = new ofxUILabel((name+" LABEL"),name,_size); addEmbeddedWidget(label); labelPosition = OFX_UI_WIDGET_POSITION_RIGHT; if(useReference) { value = _value; } else { value = new bool(); *value = *_value; } setValue(*_value); }
void ofxUILabelToggle::init(string _name, bool *_value, float w, float h, float x, float y, int _size, bool _justifyLeft) { initRect(x,y,w,h); autoSize = (w == 0) ? true : false; justifyLeft = _justifyLeft; name = string(_name); kind = OFX_UI_WIDGET_LABELTOGGLE; label = new ofxUILabel((name+" LABEL"), name, _size); addEmbeddedWidget(label); if(useReference) { value = _value; } else { value = new bool(); *value = *_value; } setValue(*_value); }
static void textEditPaint(struct OzUIWidget *widget) { struct Rect rect, cursorRect; struct OzUITextEdit *textEdit; struct Point p1, p2; int dx, dy; textEdit = (struct OzUITextEdit*)widget->d; initRect(&rect, 0, 0, widget->rect.w, widget->rect.h); //initRect(&tlc.rect, 0, 0, 100000, 100000); OzUIWidgetDrawRectangle(widget, &rect, &blackLS, &whiteFS); if (textEdit && textEdit->layout) { copyRect(&cursorRect, &textEdit->layout->charLayout[textEdit->cursorPos].rect); cursorRect.w = textEdit->fontSize/2; dx = dy = 0; if (rectLeft(&cursorRect) < rectLeft(&rect)) dx = rectLeft(&rect) - rectLeft(&cursorRect); if (rectRight(&cursorRect) > rectRight(&rect)) dx = rectRight(&rect) - rectRight(&cursorRect); if (rectTop(&cursorRect) < rectTop(&rect)) dy = rectTop(&rect) - rectTop(&cursorRect); if (rectBottom(&cursorRect) > rectBottom(&rect)) dy = rectBottom(&rect) - rectBottom(&cursorRect); OzUITextLayoutTransform(textEdit->layout, dx, dy); translateRect(&cursorRect, dx, dy); OzUIWidgetDrawTextLayout(widget, &tlc, &blackLS, textEdit->layout); if (widget->window->focusWidget == widget) { p1.x = rectLeft(&cursorRect); p1.y = rectBottom(&cursorRect); p2.x = rectRight(&cursorRect); p2.y = rectBottom(&cursorRect); OzUIWidgetDrawLine(widget, &p1, &p2, &blackLS); } } }