subclass

Manual positioning of titleLabel in a custom UIButton (using layoutSubviews)

hi all, i've create a UIButton subclass for my app and i need to manually reposition the titleLabel to be about 1/4 of the button's height. this post; http://forums.macrumors.com/showthread.php?t=763140 appears to directly address the same issue, and the solution is simple and perfectly understandable. however, i have failed to implemen...

Why aren't Python's superclass __init__ methods automatically invoked?

Why did the Python designers decide that subclasses' __init__() methods don't automatically call the __init__() methods of their superclasses, as in some other languages? Is the Pythonic and recommended idiom really like the following? def Superclass(object): def __init__(self): print 'Do something' def Subclass(Superclass)...

How to add a Subview using [self.view addSubview: myView] where myView is subclass of UIView?

Hello everyone, In my Project, I have a customised @interface GraphView: UIView. Hence GraphView is a subclass of UIView and is meant to show a graph. Then, I create a new View Controller called Summary using a NIB. In the Interface builder, I just add a UIToolbar at the bottom of the View. In the implementation of Summary, in the vie...

Cocoa Touch - UIButtons - Subclassing UIButton

Hey all, can anyone please explain how I can subclass UIButton and override some method so that when the user drags off a button it comes up right away? The problem is that when I drag out of the button frame it remains active and down. I want it to stop as soon as the finger leaves the button frame. Any ideas? (Cocoa Touch) ...

Casting subclasses extending the same original class

How can I cast two extends class like that in java? class B extends Object{ } class C extends Object{ } B b = new B(); C c = (C)b;//Cannot cast from B to C ...

NSTextView Subclass - A4 Paper Look

Hello, I am thinking about modifying my NSTextView to look like an A4 sheet. So basically a line drawn around the textContainer, but I don't know how this could be done... Just in case no one understands what I mean, I've attached a screenshot :P http://web.me.com/david.schiefer/a4.png Thanks :) ...

Overriding a parent class's methods.

Something that I see people doing all the time is: class Man(object): def say_hi(self): print('Hello, World.') class ExcitingMan(Man): def say_hi(self): print('Wow!') super(ExcitingMan, self).say_hi() # Calling the parent version once done with custom stuff. Something that I never see peop...

Is my class a subclass of other generic class?

I have an abstract generic class. public abstract class FieldHandlerWithData<DataType extends Parcelable> extends FieldHandler Now I have an object c Class<? extends FieldHandler> c = getHandlerClass(type); and now I want to test if c inherits FieldHandlerWithData (directly or indirectly). How to determine whether c inherits F...

How to correctly model a changed return type when subclass overrides a super classes method

http://yfrog.com/5iumlp Here we have a class diagram for a personal program I am working on. The question I am asking is whether I have modelled the subclasses of UserControl Correctly. Specifically the base class has a method public abstract JComponent toComponent(). During implementation the subclasses should override the method keepi...

Java - GUI's, Panels, and Subclassing.

I'm reading an introduction to Java book. I'm about three/fourths of the way through the GUI section, and learning about add different JComponents to a JFrame to create a UI. I'm confused about one thing, though. The book (in the examples) created a Frame, and then added 4 panels by subclassing one after the other. (In other words: It e...

warning: incompatible Objective-C types assigning superClass to subClass

Assume a valid super class, and a valid subclass ie the classes work. the following line in a constructor of the subclass self = [super init] ; throws the following warning // warning: incompatible Objective-C types assigning 'struct Animal *', expected 'struct Cat *' Any ideas on how to fix this and remove the warning ? Cheers ...

Java - GUI, Panel, and Data Accessing.

I'm making a game with three main panels and a few subpanels, and I'm confused about how you "connect" the panels and their data. I have my main class, which extends JFrame and adds three JPanels. Each of those panels is a subclass of JPanel. (Ex: JPanel gameControlPanel = new GameControlPanel(), where GameControlPanel is a class I crea...

Should I subclass the NSMutableArray class

I have an NSMutableArray object that I want to add custom methods to. I tried subclassing NSMutableArray but then I get an error saying "method only defined for abstract class" when trying to get the number of objects with the count method. Why is the count method not inherited? I read somewhere else that I will have to import some NSMu...

Adding a CSS sublcass to a CSS item used in javascript?

First time using CSS so my question may not make sense. I am using a menu template that uses javascript to slide CSS items around. I have multiple items next to each other and I wanted to alternate the background by making a subclass for the item(eg: .cc_item .odd{ background:#fff}). style: .cc_item{ text-align:center; width:140px; hei...

Reload a subclassed QFrame in PyQT

I have a subclassed QFrame that generates a list of buttons when my project loads, and at times, I want to be able to completely destroy and rebuild "buttonGrid". Rather than add a button in the proper spot with the proper geometry settings etc. I figured it'd be easiest to destroy this and then call it again as it was originally one. ...

Using a custom UITableView without linking in IB

I have a custom UITableView class for creating shadow effects on all of my UITableViews. Is it possible to incorporate this class with my UITableViewController(s) without creating a nib file for each table view controller? Is there another way to link this custom UITableView other then in IB? ...

Python Range Class/Subclass

I have code for a Range class like this: class Range: def __init__(self, start, end): self.setStart(start) self.setEnd(end) def getStart(self): return self.start def setStart(self, s): self.start = s def getEnd(self): return self.end def setEnd(self, e): self.end = e def getLength(se...

What's are options for simplifying calls to functions with the same name, but different signatures in separate subclasses in python?

I have an base class, and two subclasses. Each needs to implement a method that's defined in the base class (but in the base class raises an NotImplementedError.. the base class is basically an abstract class). But, the implementation of the method in one of the subclasses requires more parameters than in the other subclass. class Subc...

Subclassing file class in Python raises NameError

I have to do a very simple project in python where I add error checking to the built in file class. So far, I've got: class RobustFile(file): def __init__(self,name,mode): file.__init__(self,name,mode) I'm just starting out, but to make sure I hadn't messed anything up, I ran it. Well, right off the bat, I raised a NameE...

UIView subclass creating its own UIButtons

Hi all, I have subclassed UIView so I can draw some lines in it. In this UIView are a whole bunch of buttons which I decided to create as a method that drawRect calls after the lines are drawn. It works but sometimes only part of the button renders. If i remove the button creation and instead add the UIButton in the subclassed UIViews p...