subclass

Example of using EM_STREAMOUT with c# and RichEditBox

Hello i trying to get a text from a RichEdit field with WM_GETTEXT, but i run into some problems, so I found EM_STREAMOUT, this is especially for RichEdit. I found this code and played a little bit with it, but i can't get them to work: delegate uint EditStreamCallback(IntPtr dwCookie, IntPtr pbBuff, int cb, out int pcb); struct EDI...

Subclassing int in Python

I'm interested in subclassing the built-in int type in Python (I'm using v. 2.5), but having some trouble getting the initialization working. Here's some example code, which should be fairly obvious. class TestClass(int): def __init__(self): int.__init__(self, 5) However, when I try to use this I get: >>> a = TestClass()...

calling a function in view controller of Utility app

I am new to objective C and I have a c++ background. I want to display a value in the label on the screen. I am calling the label value from the MainView.m. However, the label becomes blank after I click a button instead of printing a value. What is the problem? Here is the code. MainView.h @interface MainView : UIView { int a; } -(...

best way to implement custom pretty-printers

The documentation for the pprint module mentions that the method PrettyPrinter.format is intended to make it possible to customize formatting. I gather that it's possible to override this method in a subclass, but this doesn't seem to provide a way to have the base class methods apply line wrapping and indentation. Am I missing somethi...

Returning an objects subclass with generics.

With an abstract class I want to define a method that returns "this" for the subclasses: public abstract class Foo { ... public <T extends Foo> T eat(String eatCake) { ... return this; } } public class CakeEater extends Foo {} I want to be able to do things like: CakeEater phil = new CakeEater(); phil.e...

ObservableCollection : calling OnCollectionChanged with multiple new items

please note that I am trying to use NotifyCollectionChangedAction.Add action instead of .Reset. the latter does work, but it is not very efficient with large collections. so i subclassed ObservableCollection: public class SuspendableObservableCollection<T> : ObservableCollection<T> for some reason, this code: private List<T> _cache...

Question regarding subclassing.

Hi, This is probably asked before but I have no idea what to search for. This is my hierarchy now: NSObject > FirstSubclass > SecondSubclass. But I'm going to implement a new feature in my app which requires changing a few details in FirstSubclass when a certain condition is met. So actually I would need a subclass between FirstSubclass...

Can I change the super of a class?

Hi, Is it somehow possible to choose the super of a class (preferably in the alloc or init method) so my class inherits from something else? ...

How can I extend Python's datetime.datetime with my own methods?

I'm trying to extend Python's datetime.datetime class with a couple of extra methods. So, for example I'm doing: import datetime class DateTime(datetime.datetime): def millisecond(self): return self.microsecond/1000 but then if I do >>> d = DateTime(2010, 07, 11, microsecond=3000) >>> print d.millisecond() 3 >>> delta = ...

[IPhone] How to subClass UITableViewCell and use it to not clear UILabel background color on UITabeViewCell selected?

Dear All, In my app, I use a label to display a specified color by set background color in a customized UITableViewCell (because this color maybe changed according incoming data from internet), after viewDidLoad, everything is ok, but when this cell is selected (highlighted) the color is cleared. After searching, I found out that some ...

UIControl -contentHorizontalAlignment: how to use in a subclass

UIControl has two properties that are documented to affect the layout of content in the control's view: contentHorizontalAlignment The horizontal alignment of content (text or image) within the receiver. controlVerticalAlignment The vertical alignment of content (text or image) within the receiver. I have a UIControl subclass t...

subclassing view and implementing SurfaceHolder.Callback

Can I have a class that extends View and implements SurfaceHolder.Callback and inside this class have a SurfaceView object? If this is possible, then I’d have to call on the SurfaceView constructor like this: SurfaceView sview = SurfaceView(this) inside the constructor of View’s subclass. I can’t compile because of the foll error: ‘...

Pythonic way to assign an instance of a subclass to a variable when a specific string is presented to the constructor of the parent class.

I want to be able to create an instance of a parent class X, with a string "Q" as an extra argument. This string is to be a name being an identifier for a subclass Q of the parent class X. I want the instance of the parent class to become (or be replaced with) an instance of the subclass. I am aware that this is probably a classic pro...

PHP: call child constructor from static method in parent

I want to have a static method in a parent class that creates instances of whatever subclass i call this method on. An example to make this more clear: class parent { public static method make_objects($conditions){ for (...){ // here i want to create an instance // of whatever subclass i am calling ...

Python ABCs: registering vs. subclassing

(I am using python 2.7) The python documentation indicates that you can pass a mapping to the dict builtin and it will copy that mapping into the new dict: http://docs.python.org/library/stdtypes.html#mapping-types-dict I have a class that implements the Mapping ABC, but it fails: import collections class Mapping(object): def __i...

PHP subclass can't access public variable set by parent

Hello, I'm very new to PHP and OOP in general. I'm using codeigniter for a framework, and am currently attempting to build a class 'BuildLinks' that will redirect the user to the correct link based on what URL they landed on. The controller passes the right variables to the class, while the function build_afflink() selects what class ...

Programmatically defining NSSegmentedCell

I am a little stumped as to how to instruct a programmatically created NSSegmentedControl to use a subclass instance of an NSSegmentedCell. If I want to use a subclasses NSSegmentedCell on an NSSegmentedControl built using IB it would be as simple as doing the following: Drag an NSSegmentedControl into the NSView Click through to the ...

Php inheritance superclass variables

Hi! I try to load an entity with some details and there is a resellerId in the entity. Now I inherit a subclass from it, and try to access the resellerId but it's not there. How to pass the attributes to the subclasses? I really need it loaded. Thanks! edit: class Crm_Entity extends Crm_Abstract { protected $_mapper = 'Crm_Mapp...

Getting the name of a sub-class from within a super-class.

Let's say I have a base class named Entity. In that class, I have a static method to retrieve the class name: class Entity { public static String getClass() { return Entity.class.getClass(); } } Now I have another class extend that. class User extends Entity { } I want to get the class name of User: System.out.pri...

Passing array of custom objects to NSCell in NSMatrix programatically

I have an NSArray of custom NSObjects. Each object has some properties and an image that I would like to display in a grid view. NSMatrix appears to be a good solution to my problem, but I am having issues getting the content of the objects to display. Couple of things to note. I am not using core data I am trying to do this programm...