/********************************************************************* * * GUI_ALLOC_GetSize * * Parameter * hMem Handle of the memory block. A 0-handle is permitted; return value is 0 in this case. */ GUI_ALLOC_DATATYPE GUI_ALLOC_GetSize(GUI_HMEM hMem) { GUI_ALLOC_DATATYPE r; r = 0; if (hMem) { r = _GetSize(hMem); } return r; }
/********************************************************************* * * GUI_ALLOC_GetSize */ GUI_ALLOC_DATATYPE GUI_ALLOC_GetSize(GUI_HMEM hMem) { /* Do the error checking first */ #if GUI_DEBUG_LEVEL>0 if (!hMem) { GUI_DEBUG_ERROROUT("\n"__FILE__ " GUI_ALLOC_h2p: illegal argument (0 handle)"); return 0; } #endif return _GetSize(hMem); }
bool KeyboardLayout::_GetShape(const parse_state& state, const char* data, Key& key) { // the default key.shape = kRectangleKeyShape; key.dark = false; while (isalpha(data[0])) { switch (tolower(data[0])) { case 'r': key.shape = kRectangleKeyShape; break; case 'c': key.shape = kCircleKeyShape; break; case 'l': key.shape = kEnterKeyShape; break; case 'd': key.dark = true; break; default: _Error(state, "unknown shape specifier '%c'", data[0]); return false; } data++; } float width, height; if (!_GetSize(state, data, width, height, &key.second_row)) return false; // don't accept second row with anything but kEnterKeyShape if ((key.shape != kEnterKeyShape && key.second_row != 0) || (key.shape == kEnterKeyShape && key.second_row == 0)) { _Error(state, "shape size mismatch"); return false; } key.frame.left = 0; key.frame.top = 0; key.frame.right = width; key.frame.bottom = height; return true; }
/* * call-seq: * image.sub_image(rect) -> WX::Image or nil * * return a sub image of the given place * ===Arguments * * rect is a WX::Rect * ===Return value * WX::Image or nil * === Exceptions * [ArgumentError] * * rect does have negative size * * rect does not fit into the Size of the Image */ DLL_LOCAL VALUE _getSubImage(VALUE self, VALUE vrect) { if(_self->IsOk()) { wxRect rect; wxSize size; if(!check_negative_size(vrect, size)) return Qnil; if(!check_contain_rect(_GetSize(self), _self->GetSize(), vrect, rect)) return Qnil; return wrap(_self->GetSubImage(rect)); } return Qnil; }
/* * call-seq: * image[x,y]= WX::Color or WX::Image or WX::Bitmap * image[pos]= WX::Color or WX::Image or WX::Bitmap * image[rect]= WX::Color * * if giving x and y or pos, and as value a color, sets the color at the given position * if giving x and y or pos, and an image or bitmap does paste it at the given position * if giving a WX::Rect, fill the color at the place with the given one * ===Arguments * * x and y are Integer * * pos is a WX::Point * * rect is a WX::Rect * * === Exceptions * [ArgumentError] * * rect does not fit into the Size of the Image */ DLL_LOCAL VALUE _set(int argc,VALUE *argv,VALUE self) { VALUE vx,vy,value; rb_scan_args(argc, argv, "21",&vx,&vy,&value); rb_check_frozen(self); if(_self->IsOk()) { if(NIL_P(value)) { if(is_wrapable<wxRect>(vx)) { wxColor c(unwrap<wxColor>(vy)); wxSize size(_self->GetSize()); wxRect vrect; if(check_contain_rect(_GetSize(self), size, vx, vrect)) { _self->SetRGB(vrect,c.Red(),c.Green(),c.Blue()); if(_self->HasAlpha()) { for(int i = vrect.x; i <= vrect.GetRight(); ++i) for(int j = vrect.y; j <= vrect.GetBottom(); ++j) if(check_inside(i, j, size)) _self->SetAlpha(i,j,c.Alpha()); } } } else { wxPoint vpoint(unwrap<wxPoint>(vx)); set_at_pos(vpoint.x, vpoint.y, _self, vy); } } else { set_at_pos(RB_NUM2UINT(vx), RB_NUM2UINT(vy), _self, value); } } return NIL_P(value) ? value : vy; }
/*! Initializes the keyboard layout from the data given. The string has to be a valid keyboard layout description, otherwise an error is returned. */ status_t KeyboardLayout::_InitFrom(const char* data) { _FreeKeys(); VariableMap variables; BPoint rowLeftTop; int32 lastKeyCount = 0; Key key; parse_state state = {kPairs, 1}; while (data[0] != '\0') { _SkipCommentsAndSpace(state, data); if (data[0] == '[') { state.mode = kRowStart; rowLeftTop = BPoint(0, 0); data++; continue; } else if (data[0] == '\0') break; switch (state.mode) { case kPairs: { BString name; BString value; if (!_GetPair(state, data, name, value)) return B_BAD_VALUE; TRACE("<%s> = <%s>\n", name.String(), value.String()); if (name == "name") fName = value; else if (name == "default-size") { const char* valueString = value.String(); parse_state tempState = {kSize, state.line}; BString term; if (!_ParseTerm(tempState, valueString, term, variables)) return B_BAD_VALUE; TRACE(" size = %s\n", term.String()); if (!_GetSize(state, term.String(), fDefaultKeySize.width, fDefaultKeySize.height)) return B_BAD_VALUE; } else if (name[0] == '$') variables[name] = value; break; } case kRowStart: case kKeyShape: case kKeyCodes: { if (data[0] == ']') { if (state.mode == kKeyShape) { state.mode = kPairs; data++; continue; } _Error(state, "unexpected row closing bracket"); return B_BAD_VALUE; } BString term; if (!_ParseTerm(state, data, term, variables)) return B_BAD_VALUE; switch (state.mode) { case kRowStart: if (!_GetSize(state, term.String(), rowLeftTop.x, rowLeftTop.y)) return B_BAD_VALUE; TRACE("row: %s (%g:%g)\n", term.String(), rowLeftTop.x, rowLeftTop.y); state.mode = kKeyShape; break; case kKeyShape: memset(&key, 0, sizeof(Key)); if (!_GetShape(state, term.String(), key)) return B_BAD_VALUE; TRACE(" shape: %s (%g:%g:%g)\n", term.String(), key.frame.Width(), key.frame.Height(), key.second_row); lastKeyCount = 0; state.mode = kKeyCodes; break; case kKeyCodes: TRACE(" raw key: %s\n", term.String()); if (!_AddKeyCodes(state, rowLeftTop, key, term.String(), lastKeyCount)) return B_BAD_VALUE; if (data[0] != ':') state.mode = kKeyShape; break; default: break; } if (data[0] != ']' && data[0] != '\0') data++; break; } default: return B_BAD_VALUE; } } return B_OK; }